Esempio n. 1
0
        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));
        }
Esempio n. 2
0
        /// <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();
        }