// ========================================================================= // Functions (Public) // ========================================================================= public void UpdateObservation(string imageId, double x, double y, double z) { IPoint point = ArcUtils.GsToMapPoint(x, y, z); if (_observations.ContainsKey(imageId)) { _observations[imageId] = new[] { point.X, point.Y, point.Z }; } else { _observations.Add(imageId, new[] { point.X, point.Y, point.Z }); } }
public void UpdatePoint(PointMeasurementData measurementData, int index) { _index = index; bool notCreated = NotCreated; MeasurementPointS measurementPoint = measurementData.measurementPoint; double x = measurementPoint.x; double y = measurementPoint.y; double z = measurementPoint.z; _point = ArcUtils.GsToMapPoint(x, y, z); IActiveView activeView = ArcUtils.ActiveView; var display = activeView.ScreenDisplay; IDisplayTransformation dispTrans = display.DisplayTransformation; double size = dispTrans.FromPoints(PointSize); double xmin = x - size; double xmax = x + size; double ymin = y - size; double ymax = y + size; _oldEnvelope = _envelope; foreach (var observation in _observations) { double[] obs = observation.Value; if (obs.Length >= 2) { double xdir = (_point.X - obs[0]) / 2; double ydir = (_point.Y - obs[1]) / 2; xmin = Math.Min(xmin, _point.X + xdir); ymin = Math.Min(ymin, _point.Y + ydir); xmax = Math.Max(xmax, obs[0]); ymax = Math.Max(ymax, obs[1]); } } _envelope = new EnvelopeClass { XMin = xmin, XMax = xmax, YMin = ymin, YMax = ymax }; var avEvents = ArcUtils.ActiveViewEvents; if (avEvents != null) { if (!notCreated) { avEvents.AfterDraw -= AvEventsAfterDraw; } avEvents.AfterDraw += AvEventsAfterDraw; } IEditor3 editor = ArcUtils.Editor; var sketch = editor as IEditSketch3; if ((sketch != null) && (_measurement != null)) { IGeometry geometry = sketch.Geometry; int nrPoints; var ptColl = _measurement.ToPointCollection(geometry, out nrPoints); if ((ptColl != null) && _measurement.IsSketch) { if (_intId <= nrPoints) { IPoint pointC = ptColl.Point[_intId - 1]; if (!IsSame(pointC)) { ISketchOperation2 sketchOp = new SketchOperationClass(); sketchOp.Start(editor); IPoint point = new PointClass { X = _point.X, Y = _point.Y, Z = _point.Z, M = _index, ZAware = sketch.ZAware }; if (_measurement.IsPointMeasurement) { sketch.Geometry = point; } else { ptColl.UpdatePoint((_intId - 1), point); if ((_intId == 1) && ((nrPoints + 1) == ptColl.PointCount)) { ptColl.UpdatePoint((ptColl.PointCount - 1), point); } sketch.Geometry = ptColl as IGeometry; } geometry = sketch.Geometry; if (geometry != null) { sketchOp.Finish(geometry.Envelope, esriSketchOperationType.esriSketchOperationGeneral, geometry); } } } else { ISketchOperation2 sketchOp = new SketchOperationClass(); sketchOp.Start(editor); IPoint point = new PointClass { X = _point.X, Y = _point.Y, Z = _point.Z, M = _index, ZAware = sketch.ZAware }; int nrPoints2 = ptColl.PointCount; switch (nrPoints2) { case 0: ptColl.AddPoint(point); if (geometry is IPolygon4) { ptColl.AddPoint(point); } break; case 1: ptColl.AddPoint(point); break; default: if (_intId <= (nrPoints + 1)) { object point1 = ((_intId - 1) == nrPoints2) ? Type.Missing : (_intId - 1); object point2 = Type.Missing; ptColl.AddPoint(point, ref point1, ref point2); } break; } sketch.Geometry = ptColl as IGeometry; geometry = sketch.Geometry; if (geometry != null) { sketchOp.Finish(geometry.Envelope, esriSketchOperationType.esriSketchOperationGeneral, geometry); } } } else { if (geometry is IPoint) { if (geometry.IsEmpty) { if ((!double.IsNaN(_point.X)) && (!double.IsNaN(_point.Y))) { if (!_added) { IApplication application = ArcMap.Application; ICommandItem tool = application.CurrentTool; ICommand command = tool.Command; if (!(command is IEditTool)) { _added = true; var editorZ = editor as IEditorZ; double zOffset = 0.0; if (editorZ != null) { zOffset = editorZ.ZOffset; editorZ.ZOffset = _point.Z; } ISketchOperation2 sketchOp = new SketchOperationClass(); sketchOp.Start(editor); IPoint point = new PointClass { X = _point.X, Y = _point.Y, Z = _point.Z, M = _index, ZAware = sketch.ZAware }; sketch.Geometry = point; geometry = sketch.Geometry; sketchOp.Finish(geometry.Envelope, esriSketchOperationType.esriSketchOperationGeneral, geometry); sketch.FinishSketch(); if (editorZ != null) { editorZ.ZOffset = zOffset; } _added = false; } } } } else { var pointC = geometry as IPoint; if (!IsSame(pointC)) { if ((!double.IsNaN(_point.X)) && (!double.IsNaN(_point.Y))) { ISketchOperation2 sketchOp = new SketchOperationClass(); sketchOp.Start(editor); IPoint point = new PointClass { X = _point.X, Y = _point.Y, Z = _point.Z, M = _index, ZAware = sketch.ZAware }; sketch.Geometry = point; geometry = sketch.Geometry; sketchOp.Finish(geometry.Envelope, esriSketchOperationType.esriSketchOperationGeneral, geometry); } } } } } } Update(); }