//-------------------------------------------------------------------------------------------------- void _AddEllipseSegment(SketchSegmentEllipse ellipseSegment) { var ellipse = ellipseSegment.GetEllipse(_Sketch.Points); if (_Document.Flags.HasFlag(DxfFlags.ExportEllipseAsPolygon)) { _AddPolygonCurve(new Geom2d_Ellipse(ellipse)); return; } var center = ellipse.Location(); var majorAxisPointOffset = ellipse.XAxis().Direction.ToVec().Multiplied(ellipse.MajorRadius()).ToPnt(); var ratio = ellipse.MinorRadius() / ellipse.MajorRadius(); var entity = new DxfDomEllipse("0", center, majorAxisPointOffset, ratio); _Document.Entities.Add(entity); }
//-------------------------------------------------------------------------------------------------- void _SetFirstRimPoint(Pnt2d point, int mergeCandidateIndex) { if (_Points[0].Distance(point) < 0.001) { // Min distance not met _PointAction.Reset(); return; } if (_HintCircle != null) { _HintCircle.Remove(); _HintCircle = null; } if (_HintLine != null) { _HintLine.Remove(); _HintLine = null; } _Points[1] = point; _MergePointIndices[1] = mergeCandidateIndex; _PointsCompleted++; _Marker[1] = new Marker(_SketchEditorTool.WorkspaceController, Marker.Styles.Bitmap | Marker.Styles.Topmost, Marker.BallImage); _Marker[1].Set(point, _SketchEditorTool.Sketch.Plane); _Points[2] = point; _Segment = new SketchSegmentEllipse(0, 1, 2); _Element = new SketchEditorSegmentElement(_SketchEditorTool, -1, _Segment, _SketchEditorTool.Transform, _SketchEditorTool.Sketch.Plane); _Element.IsCreating = true; _Element.OnPointsChanged(_Points, null); _SketchEditorTool.StatusText = "Select second rim point of the ellipse."; _PointAction.Reset(); _SketchEditorTool.WorkspaceController.Invalidate(); _SketchEditorTool.WorkspaceController.UpdateSelection(); }
//-------------------------------------------------------------------------------------------------- void _OnActionFinished(ToolAction toolAction) { if (toolAction == _PointAction) { switch (_PointsCompleted) { case 0: _Points.Add(0, _PointAction.Point); _MergePointIndices[0] = _PointAction.MergeCandidateIndex; _PointsCompleted++; _Marker[0] = new Marker(_SketchEditorTool.WorkspaceController, Marker.Styles.Bitmap | Marker.Styles.Topmost, Marker.BallImage); _Marker[0].Set(_PointAction.Point, _SketchEditorTool.Sketch.Plane); _SketchEditorTool.StatusText = "Select first rim point of the ellipse."; _PointAction.Reset(); break; case 1: if (_Points[0].Distance(_PointAction.Point) < 0.001) { // Min distance not met _PointAction.Reset(); return; } if (_HintCircle != null) { _HintCircle.Remove(); _HintCircle = null; } if (_HintLine != null) { _HintLine.Remove(); _HintLine = null; } _Points.Add(1, _PointAction.Point); _MergePointIndices[1] = _PointAction.MergeCandidateIndex; _PointsCompleted++; _Marker[1] = new Marker(_SketchEditorTool.WorkspaceController, Marker.Styles.Bitmap | Marker.Styles.Topmost, Marker.BallImage); _Marker[1].Set(_PointAction.Point, _SketchEditorTool.Sketch.Plane); _Points.Add(2, _PointAction.Point); _Segment = new SketchSegmentEllipse(0, 1, 2); _Element = new SketchEditorSegmentElement(_SketchEditorTool, -1, _Segment, _SketchEditorTool.Transform, _SketchEditorTool.Sketch.Plane); _Element.IsCreating = true; _Element.OnPointsChanged(_Points, null); _SketchEditorTool.StatusText = "Select second rim point of the ellipse."; _PointAction.Reset(); break; case 2: if (_Points[0].Distance(_PointAction.Point) < 0.001 || _Points[1].Distance(_PointAction.Point) < 0.001) { // Min distance not met _PointAction.Reset(); return; } _Points[2] = _PointAction.Point; _MergePointIndices[2] = _PointAction.MergeCandidateIndex; _PointAction.Stop(); _SketchEditorTool.FinishSegmentCreation(_Points, _MergePointIndices, new SketchSegment[] { _Segment }, null); break; } } }