//-------------------------------------------------------------------------------------------------- double?_ProcessMouseInputForAxis(MouseEventData data) { var planeDir = WorkspaceController.ActiveViewport.GetRightDirection(); if (planeDir.IsParallel(_MoveAxis.Direction, 0.1)) { planeDir = WorkspaceController.ActiveViewport.GetUpDirection(); } planeDir.Cross(_MoveAxis.Direction); //Console.WriteLine("PlaneDir: {0:0.00} | {1:0.00} | {2:0.00}", planeDir.X(), planeDir.Y(), planeDir.Z()); var plane = new Pln(new Ax3(_MoveAxis.Location, planeDir, _MoveAxis.Direction)); Pnt convertedPoint; if (WorkspaceController.ActiveViewport.ScreenToPoint(plane, Convert.ToInt32(data.ScreenPoint.X), Convert.ToInt32(data.ScreenPoint.Y), out convertedPoint)) { var extrema = new Extrema_ExtPC(convertedPoint, new GeomAdaptor_Curve(new Geom_Line(_MoveAxis)), 1.0e-10); if (extrema.IsDone() && extrema.NbExt() >= 1) { var value = extrema.Point(1).Parameter(); return(value); } } return(null); }
//-------------------------------------------------------------------------------------------------- double?_ProcessMouseInputForAxis(MouseEventData data, out double distance) { var planeDir = WorkspaceController.ActiveViewport.GetRightDirection(); planeDir.Cross(_Axis.Direction); //Console.WriteLine("PlaneDir: {0:0.00} | {1:0.00} | {2:0.00}", planeDir.X(), planeDir.Y(), planeDir.Z()); var plane = new Pln(new Ax3(_Axis.Location, planeDir, _Axis.Direction)); var snapInfo = WorkspaceController.SnapHandler.Snap(data); var snapPoint = WorkspaceController.SnapHandler.SnapOnPlane(snapInfo, plane); if (snapPoint != null) { // Point snapped var extrema = new Extrema_ExtPC(ElSLib.Value(snapPoint.Value.X, snapPoint.Value.Y, plane), new GeomAdaptor_Curve(new Geom_Line(_Axis)), 1.0e-10); if (extrema.IsDone() && extrema.NbExt() >= 1) { var value = extrema.Point(1).Parameter(); distance = snapInfo.Point.Distance(_Axis.Location); return(value); } } else { Pnt convertedPoint; if (WorkspaceController.ActiveViewport.ScreenToPoint(plane, Convert.ToInt32(data.ScreenPoint.X), Convert.ToInt32(data.ScreenPoint.Y), out convertedPoint)) { var extrema = new Extrema_ExtPC(convertedPoint, new GeomAdaptor_Curve(new Geom_Line(_Axis)), 1.0e-10); if (extrema.IsDone() && extrema.NbExt() >= 1) { var value = extrema.Point(1).Parameter(); distance = convertedPoint.Distance(_Axis.Location); return(value); } } } distance = 0; return(null); }