Esempio n. 1
0
        protected override void OnReceiveInputData(string inputName, object data)
        {
            switch (inputName)
            {
            case ActionNames.WorkingPlaneInput:
                Ax2 = data as OCgp_Ax2;
                break;

            default:
                base.OnReceiveInputData(inputName, data);
                break;
            }

            // The input was processed in the base class, just use the coordinates received
            if (null == _occMousePosition)
            {
                return;
            }

            if (inputName == ActionNames.SolverDrawerPipe)
            {
                if (_occMousePosition.IsMouseDown != _previousMouseDown)
                {
                    OnMouseClick3dAction(_occMousePosition);
                }
                else
                {
                    OnMouseMove3dAction(_occMousePosition);
                }

                _previousMouseDown = _occMousePosition.IsMouseDown;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Adds an Ellipse2D to the OCAF tree.
        /// </summary>
        /// <param name="ellipse"></param>
        /// <param name="ax2"></param>
        /// <returns></returns>
        private int AddToOcaf(Ellipse2D ellipse, OCgp_Ax2 ax2)
        {
            Node mainLabel = _document.Root;

            label = mainLabel.AddNewChild();
            return(UpdateElipsePosition(label, ellipse, ax2));
        }
Esempio n. 3
0
        /// <summary>
        /// Adds a Line2D to the OCAF tree
        /// </summary>
        /// <param name="line"></param>
        /// <param name="ax2"></param>
        /// <returns></returns>
        private int AddToOcaf(Line2D line, OCgp_Ax2 ax2)
        {
            OCGraphic2d_Array1OfVertex vertexArray = new OCGraphic2d_Array1OfVertex(1, 2);

            line.GetVertexes(vertexArray);

            Node mainLabel = _document.Root;

            _label = mainLabel.AddNewChild();
            return(UpdateLinePosition(_label, ax2, vertexArray));
        }
Esempio n. 4
0
        private Node AddToOcaf(Rectangle2D rectangle, OCgp_Ax2 ax2)
        {
            Node mainLabel = _document.Root;
            Node L         = mainLabel.AddNewChild();

            double x1 = rectangle.BottomLeftX;
            double y1 = rectangle.BottomLeftY;
            double x2 = rectangle.TopLeftX;
            double y2 = rectangle.TopLeftY;
            double x3 = rectangle.BottomRightX;
            double y3 = rectangle.BottomRightY;


            SetLabelPosition(ax2, L, x1, y1, x2, y2, x3, y3);

            return(L);
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        int UpdateElipsePosition(Node label, Ellipse2D ellipse, OCgp_Ax2 ax2)
        {
            label.Update <StringInterpreter>().Value = DisplayedShapeNames.Ellipse;
            FunctionInterpreter elipseFunction = label.Update <FunctionInterpreter>();

            elipseFunction.Name = "Ellipse";

            elipseFunction.BeginUpdate();
            // Create the data structure : Set the dimensions, position and name attributes
            elipseFunction.Dependency.Child(1).Geometry = GeomUtils.VertexToPnt(ellipse.GetEllipseCenter(), ax2);
            // Add the major radius
            elipseFunction.Dependency.Child(2).Real = ellipse.GetMajorRadius();
            // Add the minor radius
            elipseFunction.Dependency.Child(3).Real = ellipse.GetMinorRadius();
            // Add angle
            elipseFunction.Dependency.Child(4).Real = ellipse.GetAngle();

            if (elipseFunction.Execute() != 0)
            {
                // TODO: Handle the error
            }

            return(0);
        }
Esempio n. 7
0
        int SetLabelPosition(OCgp_Ax2 ax2, Node L, double x1, double y1, double x2, double y2, double x3, double y3)
        {
            L.Update <StringInterpreter>().Value = DisplayedShapeNames.Rectangle;

            // Instanciate a TFunction_Function attribute connected to the current Rectangle driver
            // and attach it to the data structure as an attribute of the Rectangle Label

            FunctionInterpreter rectangleDriver = L.Update <FunctionInterpreter>();

            rectangleDriver.Name = "Rectangle";
            rectangleDriver.BeginUpdate();

            // Create the data structure : Set the dimensions, position and name attributes
            rectangleDriver.Dependency.Child(1).Geometry = GeomUtils.VertexToPnt(new OCGraphic2d_Vertex(x1, y1), ax2);
            rectangleDriver.Dependency.Child(2).Geometry = GeomUtils.VertexToPnt(new OCGraphic2d_Vertex(x2, y2), ax2);
            rectangleDriver.Dependency.Child(3).Geometry = GeomUtils.VertexToPnt(new OCGraphic2d_Vertex(x3, y3), ax2);


            if (rectangleDriver.Execute() != 0)
            {
                // TODO : handle the error
            }
            return(0);
        }
Esempio n. 8
0
        int UpdateLinePosition(Node L, OCgp_Ax2 ax2, OCGraphic2d_Array1OfVertex vertexArray)
        {
            L.Update <StringInterpreter>().Value = DisplayedShapeNames.Line;

            var lineDriver = L.Update <FunctionInterpreter>();

            lineDriver.Name = "Line";
            lineDriver.BeginUpdate();

            // Create the data structure : Set the dimensions, position and name attributes
            OCgp_Pnt point1 = GeomUtils.VertexToPnt(vertexArray.Value(1), ax2);

            lineDriver.Dependency.Child(1).Geometry = point1;

            OCgp_Pnt point2 = GeomUtils.VertexToPnt(vertexArray.Value(2), ax2);

            lineDriver.Dependency.Child(2).Geometry = point2;

            if (lineDriver.Execute() != 0)
            {
                // TODO: Handle the error
            }
            return(0);
        }
 public void AddWorkingPlane(OCgp_Ax2 ax2)
 {
     _ax2 = ax2;
     AddData(_ax2);
 }
 public WorkingPlaneInput(OCgp_Ax2 ax2) : base(ActionNames.WorkingPlaneInput)
 {
     _ax2 = ax2;
 }