public void Update([CanBeNull] ChangeAlongCurves newCurves) { DisposeOverlays(); if (newCurves == null) { return; } Predicate <CutSubcurve> noReshape = c => !c.CanReshape && !c.IsReshapeMemberCandidate && !c.IsFiltered; AddReshapeLines(newCurves.ReshapeCutSubcurves, noReshape, _noReshapeLineSymbol); AddReshapeLines(newCurves.ReshapeCutSubcurves, c => c.IsFiltered, _filteredReshapeLineSymbol); AddReshapeLines(newCurves.ReshapeCutSubcurves, c => c.IsReshapeMemberCandidate, _candidateReshapeLineSymbol); AddReshapeLines(newCurves.ReshapeCutSubcurves, c => c.CanReshape, _reshapeLineSymbol); AddReshapeLineEndpoints(newCurves.ReshapeCutSubcurves, noReshape, _noReshapeLineEnd); AddReshapeLineEndpoints(newCurves.ReshapeCutSubcurves, c => c.IsFiltered, _filteredLineEnd); AddReshapeLineEndpoints(newCurves.ReshapeCutSubcurves, c => c.IsReshapeMemberCandidate, _candidateLineEnd); AddReshapeLineEndpoints(newCurves.ReshapeCutSubcurves, c => c.CanReshape, _reshapeLineEnd); }
protected override List <ResultFeature> ChangeFeaturesAlong(List <Feature> selectedFeatures, IList <Feature> targetFeatures, List <CutSubcurve> cutSubcurves, CancellationToken cancellationToken, out ChangeAlongCurves newChangeAlongCurves) { var updatedFeatures = MicroserviceClient.ApplyCutLines( selectedFeatures, targetFeatures, cutSubcurves, cancellationToken, out newChangeAlongCurves); return(updatedFeatures); }
public List <ResultFeature> ApplyReshapeLines( [NotNull] IList <Feature> sourceFeatures, [NotNull] IList <Feature> targetFeatures, [NotNull] IList <CutSubcurve> selectedReshapeLines, CancellationToken cancellationToken, out ChangeAlongCurves newChangeAlongCurves) { if (targetFeatures == null) { throw new ArgumentNullException(nameof(targetFeatures)); } return(ChangeAlongClientUtils.ApplyReshapeCurves( ChangeAlongClient, sourceFeatures, targetFeatures, selectedReshapeLines, cancellationToken, out newChangeAlongCurves)); }
private async Task <bool> UpdateFeatures(List <Feature> selectedFeatures, List <CutSubcurve> cutSubcurves, CancelableProgressor progressor) { CancellationToken cancellationToken = progressor?.CancellationToken ?? new CancellationTokenSource().Token; ChangeAlongCurves newChangeAlongCurves; IList <Feature> targetFeatures = Assert.NotNull(_changeAlongCurves.TargetFeatures); List <ResultFeature> updatedFeatures = ChangeFeaturesAlong( selectedFeatures, targetFeatures, cutSubcurves, cancellationToken, out newChangeAlongCurves); _changeAlongCurves = newChangeAlongCurves; _feedback.Update(_changeAlongCurves); HashSet <long> editableClassHandles = MapUtils.GetLayers <BasicFeatureLayer>(MapView.Active, bfl => bfl.IsEditable) .Select(l => l.GetTable().Handle.ToInt64()).ToHashSet(); // Updates: Dictionary <Feature, Geometry> resultFeatures = updatedFeatures .Where(f => GdbPersistenceUtils.CanChange( f, editableClassHandles, RowChangeType.Update)) .ToDictionary(r => r.Feature, r => r.NewGeometry); // Inserts (in case of cut), grouped by original feature: Dictionary <Feature, IList <Geometry> > insertsByOriginal = updatedFeatures .Where(f => GdbPersistenceUtils.CanChange( f, editableClassHandles, RowChangeType.Insert)) .GroupBy(f => f.Feature, f => f.NewGeometry) .ToDictionary(g => g.Key, g => (IList <Geometry>)g.ToList()); // TODO //LogReshapeResults(result, selection.Count); var success = await GdbPersistenceUtils.SaveInOperationAsync( EditOperationDescription, resultFeatures, insertsByOriginal); return(success); }
private void RefreshCutSubcurves([NotNull] IList <Feature> selectedFeatures, [CanBeNull] CancelableProgressor progressor = null) { if (_changeAlongCurves == null || _changeAlongCurves.TargetFeatures == null || _changeAlongCurves.TargetFeatures.Count == 0) { return; } ChangeAlongCurves newState = CalculateReshapeCurves(selectedFeatures, _changeAlongCurves.TargetFeatures, progressor); _changeAlongCurves.Update(newState); _feedback.Update(_changeAlongCurves); }
private bool SelectTargets(List <Feature> selectedFeatures, Geometry sketch, CancelableProgressor progressor) { const TargetFeatureSelection targetFeatureSelection = TargetFeatureSelection.VisibleFeatures; sketch = ToolUtils.SketchToSearchGeometry(sketch, GetSelectionTolerancePixels(), out bool _); Predicate <Feature> canUseAsTargetFeature = t => CanUseAsTargetFeature(selectedFeatures, t); SpatialRelationship spatialRel = SketchType == SketchGeometryType.Polygon ? SpatialRelationship.Contains : SpatialRelationship.Intersects; var foundOidsByLayer = MapUtils.FindFeatures(ActiveMapView, sketch, spatialRel, targetFeatureSelection, CanUseAsTargetLayer, canUseAsTargetFeature, selectedFeatures, progressor); // TODO: Picker if single click and several found if (progressor != null && progressor.CancellationToken.IsCancellationRequested) { _msg.Warn("Calculation of reshape lines was cancelled."); return(false); } IList <Feature> allTargetFeatures = GetDistinctSelectedFeatures(foundOidsByLayer, _changeAlongCurves?.TargetFeatures, KeyboardUtils.IsModifierPressed(Keys.Shift)); _changeAlongCurves = allTargetFeatures.Count > 0 ? CalculateReshapeCurves(selectedFeatures, allTargetFeatures, progressor) : new ChangeAlongCurves(new List <CutSubcurve>(), ReshapeAlongCurveUsability.NoTarget); _feedback.Update(_changeAlongCurves); return(true); }
protected abstract List <ResultFeature> ChangeFeaturesAlong( List <Feature> selectedFeatures, [NotNull] IList <Feature> targetFeatures, [NotNull] List <CutSubcurve> cutSubcurves, CancellationToken cancellationToken, out ChangeAlongCurves newChangeAlongCurves);
protected void ResetDerivedGeometries() { _feedback.DisposeOverlays(); _changeAlongCurves = null; }