//-------------------------------------------------------------------------------------------------- void ProcessMouseInput(MouseEventData data) { SelectedSegment = null; SelectedPointIndex = -1; SelectedElementType = Sketch.ElementType.None; var element = _SketchEditorTool.Elements.FindOwner(data.DetectedAisInteractives.FirstOrDefault()); if (element == null) { return; } if (element is SketchEditorSegmentElement segmentElement) { // // Segment // var segment = segmentElement.Segment; if (!SketchUtils.CanSplitSegment(_SketchEditorTool.Sketch, segment)) { return; } var curve = segment.CachedCurve ?? segment.MakeCurve(_SketchEditorTool.Sketch.Points); if (curve == null) { return; } // Get new point from parameters double u = 0, v = 0; ElSLib.Parameters(_SketchEditorTool.Sketch.Plane, data.PointOnPlane, ref u, ref v); var sketchPoint = new Pnt2d(u, v); var pointOnCurve = new Geom2dAPI_ProjectPointOnCurve(sketchPoint, curve); if (pointOnCurve.NbPoints() < 1) { return; } SelectedParameter = pointOnCurve.LowerDistanceParameter(); SelectedSegment = segment; _SelectedPoint = _SketchEditorTool.Sketch.Plane.Value(curve.Value(SelectedParameter)); SelectedElementType = Sketch.ElementType.Segment; } else if (element is SketchEditorPointElement pointElement) { // // Point // var pointIndex = pointElement.PointIndex; if (!SketchUtils.CanSplitPoint(_SketchEditorTool.Sketch, pointIndex)) { return; } SelectedPointIndex = pointIndex; _SelectedPoint = _SketchEditorTool.Sketch.Plane.Value(_SketchEditorTool.Sketch.Points[pointIndex]); SelectedElementType = Sketch.ElementType.Point; } }