public void ResumeRunning() { // Set the current 2d context into the local service WorkItem.Services.Get <IContextService>().Current2DContext = context2d; // Show the 2D View WorkItem.Workspaces[Naro.Sketcher.Constants.WorkspaceNames.DrawingAreaWorkspace].Show(attachedView); view2d.Update(); view2d.HasBeenMoved(); view2d.MustBeResized(OCV2d_TypeOfWindowResizingEffect.V2d_TOWRE_ENLARGE_SPACE); // Clear the drawing area context2d.EraseAll(true, true); // Reactivate the grid viewer2d.ActivateGrid(OCAspect_GridType.Aspect_GT_Rectangular, OCAspect_GridDrawMode.Aspect_GDM_Lines); // Build the projection of the 3D to 2D Project3DModel(); // Reset the working plane input OCTopoDS_Shape topoShape = WorkItem.Services.Get <ILocalContextService>().CurrentSelectedShape; workingPlaneInput.AddWorkingPlane(GeomUtils.ExtractAxis(topoShape)); }
void InitializeInputs() { // Build the inputs and pipes inputFactory = new InputFactory(); var viewInput = new View2dInput(view2d, viewer2d); inputFactory.Register(viewInput); mouseInput = new MouseEventsInput(); inputFactory.Register(mouseInput); var mousePipe = new OCCMouseEventsPipe(view2d, viewer2d); inputFactory.RegisterPipe(mouseInput.Name, mousePipe); inputFactory.Register(mousePipe); var solverDrawerPipe = new SolverDrawerPipe(context2d, view2d, _solver, _solverDrawer); inputFactory.RegisterPipe(mousePipe.Name, solverDrawerPipe); inputFactory.Register(solverDrawerPipe); _editDetectionPipe = new EditDetectionPipe(context2d, view2d, _solver); inputFactory.RegisterPipe(solverDrawerPipe.Name, _editDetectionPipe); inputFactory.Register(_editDetectionPipe); _editDetectionPipe.ActivateActionHandler += new ActionActivatedEventHandler(EditDetectionPipe_ActivateActionHandler); var docInput = new DocumentInput(WorkItem.Services.Get <ILocalContextService>().CurrentOcafDocument); inputFactory.Register(docInput); var contextInput = new Context2dInput(context2d); inputFactory.Register(contextInput); OCTopoDS_Shape topoShape = WorkItem.Services.Get <ILocalContextService>().CurrentSelectedShape; workingPlaneInput = new WorkingPlaneInput(GeomUtils.ExtractAxis(topoShape)); inputFactory.Register(workingPlaneInput); }
public void Project3DModel() { OCTopoDS_Shape topoShape = WorkItem.Services.Get <ILocalContextService>().CurrentSelectedShape; if (topoShape == null) { return; } // Project the selected 3d object in the 2D plane // Make the projector bool isPerspective = WorkItem.Services.Get <ILocalContextService>().IsPerspective; OCgp_Pnt viewPoint = WorkItem.Services.Get <ILocalContextService>().ViewPointPosition; OCgp_Vec highPointVector = WorkItem.Services.Get <ILocalContextService>().HighPointVector; OCgp_Ax2 ax2 = GeomUtils.ExtractAxis(topoShape); OCgp_Dir direction; if (ax2 != null) { direction = ax2.Direction(); } else { direction = new OCgp_Dir(0, 1, 0); } // Use as projection vector the direction of the plane of the selected shape OCPrs3d_Projector aPrs3dProjector = new OCPrs3d_Projector(isPerspective, 1, direction.X(), direction.Y(), direction.Z(), viewPoint.X(), viewPoint.Y(), viewPoint.Z(), highPointVector.X(), highPointVector.Y(), highPointVector.Z()); // Display the 2D projection shape OCAIS2D_ProjShape projShape = new OCAIS2D_ProjShape(aPrs3dProjector.Projector(), 3, false, true); projShape.Add(topoShape); context2d.Display(projShape, true); }
public RectangularHandle() { _handleTopoShape = new OCBRepPrimAPI_MakeBox(new OCgp_Pnt(0, 0, 0), boxEdge, boxEdge, boxEdge).Shape(); }