Ejemplo n.º 1
0
        public override void OnActivate()
        {
            _pointAdded = false;
            var firstShape = NodeBuilderUtils.IdentifySelectedObjectLabel(Document.Root);

            if (firstShape == null)
            {
                ErrorSplineSelected();
                return;
            }

            _function = firstShape.Get <FunctionInterpreter>();
            if (_function == null)
            {
                ErrorSplineSelected();
                return;
            }
            if (_function.Name != FunctionNames.Spline)
            {
                ErrorSplineSelected();
                return;
            }

            Document.Transact();
            _pointAdded = true;

            var mouseCursorInput = Inputs[InputNames.MouseCursorInput];

            mouseCursorInput.Send(NotificationNames.SetResourceManager, MetaActionResource.ResourceManager);
            mouseCursorInput.Send(NotificationNames.SetCursorName, "splineaddpoint.cur");
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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);
        }