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)); }
protected override void SourceOnData(object data) { var mouseData = data as Mouse3dPosition; // Pass the coordinates through the solver // Check if there are any magic points around Double x = mouseData.Point.X(), y = mouseData.Point.Y(); var geometry = _solver.GetInterestingCloseGeometry(new OCgp_Pnt(x, y, 0)); if (geometry.Count > 0) { OCgp_Pnt point = geometry[0].NaroNode.Children[0].Get <GeometryInterpreter>().Value; x = point.X(); y = point.Y(); // Display the magic point MagicPointType magicPointType = geometry[0].MagicPointType; if (_solverDrawer.Show(_context2d, magicPointType, x, y, 0)) { // It returns true if the view needs update _view2d.Update(); } } else { // Hide the magic point if (_solverDrawer.Show(_context2d, MagicPointType.None, mouseData.Point.X(), mouseData.Point.Y(), mouseData.Point.Z())) { _view2d.Update(); } } // Notiffy listeners AddData(new Mouse3dPosition(new OCgp_Pnt(x, y, 0), mouseData.IsMouseDown)); }
protected override void SourceOnData(object data) { // Check if the pipe is enabled if (!_enableEditDetectionPipe) { return; } var mouseData = data as Mouse3dPosition; // Filter the mouse events, only mouse down is passing if (!mouseData.IsMouseDown) { return; } // Filter also the shape dragging if (_selectedShape != null) { if (_selectedShape.CanDrag(mouseData.Point.X(), mouseData.Point.Y())) { return; } if (_selectedShape.IsDragging) { return; } } // Retrieve the selected shapes and enable the markers for them bool shapeSelected = false; _selectedShape = null; foreach (Shape2d shape2d in _drawnShapesList) { int nb = _context2d.NbSelected(); if (_context2d.IsSelected(shape2d)) { shape2d.Select(); _selectedShape = shape2d; _context2d.AddOrRemoveSelected(shape2d, false); shapeSelected = true; } else { shape2d.Deselect(); } shape2d.EndDragging(); } if (shapeSelected) { log.Debug("EditDetectionPipe shape selected"); // Inform the action controller that it can switch to edit mode ActivateActionHandler(ActionType.Action2d_EditShape, true); // Notify listeners that a new selected shape is found AddData(_selectedShape); } else { //log.Debug("EditDetectionPipe unselect shape"); //ActivateActionHandler(ActionType.Action2d_EditShape, false); } _view2d.Update(); }
/// <summary> /// Initializes the OpenCascade views and assigns them View handles. /// </summary> private void InitializeOpenCascade2D() { // Initialize the Device try { device2d = new OCWNT_GraphicDevice(false, 0); Debug.Assert(device2d != null); } catch (Exception ex) { Debug.Assert(false, ex.Message); throw; //re-throw exception } // Create the 2D viewer try { viewer2d = new OCV2d_Viewer(device2d, "Visu2D", ""); Debug.Assert(viewer2d != null); if (viewer2d != null) { viewer2d.SetCircularGridValues(0, 0, 10, 8, 0); viewer2d.SetRectangularGridValues(0, 0, 10, 10, 0); //viewer2d.SetGridColor(new OCQuantity_Color(OCQuantity_NameOfColor.Quantity_NOC_LIGHTSLATEGRAY), new OCQuantity_Color(OCQuantity_NameOfColor.Quantity_NOC_WHITE)); viewer2d.ActivateGrid(OCAspect_GridType.Aspect_GT_Rectangular, OCAspect_GridDrawMode.Aspect_GDM_Lines); } } catch (Exception ex) { Debug.Assert(false, ex.Message); throw; //re-throw exception } // Create the 2D interactive context try { context2d = new OCAIS2D_InteractiveContext(this.viewer2d); Debug.Assert(context2d != null); } catch (Exception ex) { Debug.Assert(false, ex.Message); throw; // re-throw exception } // Create the 2D View OCWNT_Window aWNTWindow = new OCWNT_Window(device2d, attachedView.GetView().Handle, OCQuantity_NameOfColor.Quantity_NOC_MATRAGRAY); //int w = 1000, h = 1000; //aWNTWindow.Size(w, h); if (!aWNTWindow.IsMapped()) { aWNTWindow.Map(); } OCWNT_WDriver aDriver = new OCWNT_WDriver(aWNTWindow); view2d = new OCV2d_View(aDriver, viewer2d, 0, 0, 200); // Reset the mapping view2d.Reset(); view2d.Update(); }