Exemple #1
0
        public void SetProperties(Double xPos, Double yPos, Double majorRadius, Double minorRadius, Double angle)
        {
            OCAIS2D_InteractiveContext context = GetContext();

            _centerX     = xPos;
            _centerY     = yPos;
            _majorRadius = majorRadius;
            _minorRadius = minorRadius;
            _angle       = angle;

            // The OCC requires the minor radius to be higher than 0
            if ((majorRadius < 0.01) || (minorRadius < 0.01))
            {
                return;
            }

            // The OCC ellipse requires the minor radius to be smaller than the major radius
            if (minorRadius > majorRadius)
            {
                return;
            }

            // Build the markers
            _leftMarker   = new PolylineMarker2D(context, 0, 0, GeometryConstants.MarkerWidth, GeometryConstants.MarkerWidth);
            _rightMarker  = new PolylineMarker2D(context, 0, 0, GeometryConstants.MarkerWidth, GeometryConstants.MarkerWidth);
            _topMarker    = new PolylineMarker2D(context, 0, 0, GeometryConstants.MarkerWidth, GeometryConstants.MarkerWidth);
            _bottomMarker = new PolylineMarker2D(context, 0, 0, GeometryConstants.MarkerWidth, GeometryConstants.MarkerWidth);

            // Compute the shape and the markers
            BuildEllipse();
        }
Exemple #2
0
 public SolverDrawerPipe(OCAIS2D_InteractiveContext context2d, OCV2d_View view2d, Solver.Solver solver, SolverDrawer solverDrawer) : base(ActionNames.SolverDrawerPipe)
 {
     _solver       = solver;
     _solverDrawer = solverDrawer;
     _context2d    = context2d;
     _view2d       = view2d;
 }
Exemple #3
0
        public CircleMarker2D(OCAIS2D_InteractiveContext context, double x, double y, double radius)
        {
            base.SetContext(context);

            _xPos   = x;
            _yPos   = y;
            _radius = radius;
            _marker = new OCGraphic2d_Marker(this, 4, _xPos, _yPos, _radius, _radius, _radius);
        }
        public PolylineMarker2D(OCAIS2D_InteractiveContext context, Double xPos, Double yPos, Double width, Double height)
        {
            base.SetContext(context);

            _xPos       = xPos;
            _yPos       = yPos;
            _halfWidth  = width / 2;
            _halfHeight = height / 2;

            ComputeMarker();
        }
        public void Display(bool updateViewer)
        {
            OCAIS2D_InteractiveContext context2d = GetContext();

            if (context2d.IsDisplayed(this))
            {
                context2d.Redisplay(this, updateViewer, false);
            }
            else
            {
                context2d.Display(this, updateViewer);
            }
        }
Exemple #6
0
        /// <summary>
        /// The endpoints of the line can be set to other coordinates.
        /// </summary>
        public void SetEndpoints(Double xPos, Double yPos, Double xEndPos, Double yEndPos)
        {
            OCAIS2D_InteractiveContext context = GetContext();

            // Create the 2 markers for the end of the segment
            _startMarker = new PolylineMarker2D(context, xPos, yPos, GeometryConstants.MarkerWidth, GeometryConstants.MarkerWidth);
            _endMarker   = new PolylineMarker2D(context, xEndPos, yEndPos, GeometryConstants.MarkerWidth, GeometryConstants.MarkerWidth);

            // Store the line attributes
            _array1OfVertex.SetValue(1, new OCGraphic2d_Vertex(xPos, yPos));
            _array1OfVertex.SetValue(2, new OCGraphic2d_Vertex(xEndPos, yEndPos));

            BuildPolyline();
        }
        /// <summary>
        /// The endpoints of the rectangle can be set to other coordinates.
        /// </summary>
        public void SetEndpoints(Double xPos, Double yPos, Double width, Double height, Double angle)
        {
            OCAIS2D_InteractiveContext context = GetContext();

            // Store internally the parameters passed to the constructor
            _leftBottomX  = xPos;
            _leftBottomY  = yPos;
            _rightBottomX = _leftBottomX + width;
            _leftTopY     = _leftBottomY + height;
            _angle        = angle;

            // Build the markers
            _leftBottomMarker  = new PolylineMarker2D(context, 0, 0, GeometryConstants.MarkerWidth, GeometryConstants.MarkerWidth);
            _leftTopMarker     = new PolylineMarker2D(context, 0, 0, GeometryConstants.MarkerWidth, GeometryConstants.MarkerWidth);
            _rightTopMarker    = new PolylineMarker2D(context, 0, 0, GeometryConstants.MarkerWidth, GeometryConstants.MarkerWidth);
            _rightBottomMarker = new PolylineMarker2D(context, 0, 0, GeometryConstants.MarkerWidth, GeometryConstants.MarkerWidth);

            // Build the shape, calculate the vertexes using the internally stored parameters and position the markers
            BuildPolyline();
        }
        /// <summary>
        /// Register additional inputs to the ones inherited from the base class.
        /// </summary>
        /// <param name="inputName"></param>
        /// <param name="data"></param>
        protected override void OnReceiveInputData(string inputName, object data)
        {
            switch (inputName)
            {
            case ActionNames.Document:
                _document = data as Document;
                break;

            case ActionNames.SolverDrawerPipe:
                _occMousePosition = data as Mouse3dPosition;
                break;

            case ActionNames.Context2d:
                Context2d = data as OCAIS2D_InteractiveContext;
                break;

            default:
                base.OnReceiveInputData(inputName, data);
                break;
            }
        }
Exemple #9
0
 public Context2dInput(OCAIS2D_InteractiveContext context2d)
     : base(ActionNames.Context2d)
 {
     _context2d = context2d;
 }
        /// <summary>
        /// Hides the marker.
        /// </summary>
        /// <param name="updateViewer"></param>
        public void Hide(bool updateViewer)
        {
            OCAIS2D_InteractiveContext context2d = GetContext();

            context2d.Erase(this, updateViewer, false);
        }
        /// <summary>
        /// Shows the marker.
        /// </summary>
        /// <param name="updateViewer"></param>
        public void Display(bool updateViewer)
        {
            OCAIS2D_InteractiveContext context2d = GetContext();

            context2d.Display(this, updateViewer);
        }
Exemple #12
0
 public EditDetectionPipe(OCAIS2D_InteractiveContext context2d, OCV2d_View view2d, Solver.Solver solver) : base(ActionNames.EditDetectionPipe)
 {
     _context2d = context2d;
     _solver    = solver;
     _view2d    = view2d;
 }
Exemple #13
0
        public Line2D(OCAIS2D_InteractiveContext context, Double xPos, Double yPos, Double xEndPos, Double yEndPos)
        {
            base.SetContext(context);

            SetEndpoints(xPos, yPos, xEndPos, yEndPos);
        }
        public Rectangle2D(OCAIS2D_InteractiveContext context, Double xPos, Double yPos, Double width, Double height, Double angle)
        {
            base.SetContext(context);

            SetEndpoints(xPos, yPos, width, height, angle);
        }
Exemple #15
0
        public Ellipse2D(OCAIS2D_InteractiveContext context, Double xPos, Double yPos, Double majorRadius, Double minorRadius, Double angle)
        {
            base.SetContext(context);

            SetProperties(xPos, yPos, majorRadius, minorRadius, angle);
        }
Exemple #16
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();
        }