public override bool redoTool()
        {
            Node temp = (Node)oldNodeDataControl.getContent();

            trajectory.removeNode(temp.getX(), temp.getY());
            trajectoryDataControl.getNodes().Remove(oldNodeDataControl);

            if (wasInitial)
            {
                trajectory.setInitial(null);
                trajectoryDataControl.initialNode = null;

                trajectory.setInitial(trajectory.getNodes()[0].getID());
                trajectoryDataControl.initialNode = trajectoryDataControl.getNodes()[0];
            }

            foreach (SideDataControl side in trajectoryDataControl.getSides())
            {
                if (!trajectory.getSides().Contains((Side)side.getContent()))
                {
                    oldSides.Add(side);
                }
            }
            foreach (SideDataControl side in oldSides)
            {
                trajectoryDataControl.getSides().Remove(side);
            }

            Controller.Instance.updatePanel();

            return(true);
        }
예제 #2
0
        public override bool undoTool()
        {
            node.setValues(oldX, oldY, oldScale);
            if (newX != oldX || newY != oldY)
            {
                foreach (Trajectory.Side side in trajectory.getSides())
                {
                    if (side.getIDEnd().Equals(node.getID()) || side.getIDStart().Equals(node.getID()))
                    {
                        Node  start = trajectory.getNodeForId(side.getIDStart());
                        Node  end   = trajectory.getNodeForId(side.getIDEnd());
                        float x     = start.getX() - end.getX();
                        float y     = start.getY() - end.getY();
                        side.setRealLength((float)Mathf.Sqrt(Mathf.Pow(x, 2) + Mathf.Pow(y, 2)));
                    }

                    float temp = oldLengths[side.getIDStart() + ";" + side.getIDEnd()];
                    if (temp != null)
                    {
                        side.setLenght(temp);
                    }
                }
            }

            Controller.getInstance().updatePanel();
            return(true);
        }
예제 #3
0
        public override bool undoTool()
        {
            node.setValues(oldX, oldY, oldScale);
            bool isEnd;

            if (newX != oldX || newY != oldY)
            {
                foreach (Trajectory.Side side in trajectory.getSides())
                {
                    isEnd = side.getIDEnd().Equals(node.getID());
                    if (side.getIDEnd().Equals(node.getID()) || side.getIDStart().Equals(node.getID()))
                    {
                        Node  start = trajectory.getNodeForId(side.getIDStart());
                        Node  end   = trajectory.getNodeForId(side.getIDEnd());
                        float x     = start.getX() - end.getX();
                        float y     = start.getY() - end.getY();
                        side.setRealLength(new Vector2(x, y).magnitude);
                        side.setLenght(isEnd ? oldLength[side.getIDStart()] : oldLength[side.getIDEnd()]);
                    }
                }
            }

            Controller.Instance.updatePanel();
            return(true);
        }
예제 #4
0
 public override bool redoTool()
 {
     node.setValues(newX, newY, newScale);
     if (newX != oldX || newY != oldY)
     {
         foreach (Trajectory.Side side in trajectory.getSides())
         {
             if (side.getIDEnd().Equals(node.getID()) || side.getIDStart().Equals(node.getID()))
             {
                 Node  start     = trajectory.getNodeForId(side.getIDStart());
                 Node  end       = trajectory.getNodeForId(side.getIDEnd());
                 float x         = start.getX() - end.getX();
                 float y         = start.getY() - end.getY();
                 var   newLength = new Vector2(x, y).magnitude;
                 if (Mathf.Approximately(side.getLength(), side.getRealLength()))
                 {
                     side.setLenght(newLength);
                 }
                 side.setRealLength(newLength);
             }
         }
     }
     Controller.Instance.updatePanel();
     return(true);
 }
예제 #5
0
 public SetNodeValuesTool(Node node, Trajectory trajectory, int newX, int newY, float newScale)
 {
     this.newX       = newX;
     this.newY       = newY;
     this.newScale   = newScale;
     this.oldX       = node.getX();
     this.oldY       = node.getY();
     this.oldScale   = node.getScale();
     this.node       = node;
     this.trajectory = trajectory;
     this.oldLengths = new Dictionary <string, float>();
 }
        public override bool doTool()
        {
            string id = "node" + (new System.Random().Next(10000));

            newNode            = trajectory.addNode(id, x, y, 1.0f);
            newNodeDataControl = new NodeDataControl(sceneDataControl, newNode, trajectory);
            trajectoryDataControl.getNodes().Add(newNodeDataControl);
            if (trajectory.getInitial() == newNode)
            {
                trajectoryDataControl.initialNode = newNodeDataControl;
                wasInitial = true;
            }
            return(true);
        }
        public override bool undoTool()
        {
            Node temp = (Node)oldNodeDataControl.getContent();

            trajectory.getNodes().Add(temp);
            trajectoryDataControl.getNodes().Add(oldNodeDataControl);

            if (wasInitial)
            {
                trajectory.setInitial(temp.getID());
                trajectoryDataControl.initialNode = oldNodeDataControl;
            }

            foreach (SideDataControl side in oldSides)
            {
                trajectory.getSides().Add((Side)side.getContent());
                trajectoryDataControl.getSides().Add(side);
            }

            Controller.Instance.updatePanel();

            return(true);
        }
예제 #8
0
        public SetNodeValuesTool(Node node, Trajectory trajectory, int newX, int newY, float newScale)
        {
            this.newX      = newX;
            this.newY      = newY;
            this.newScale  = newScale;
            this.oldX      = node.getX();
            this.oldY      = node.getY();
            this.oldScale  = node.getScale();
            this.oldLength = new Dictionary <string, float>();
            bool isEnd;

            foreach (Trajectory.Side side in trajectory.getSides())
            {
                isEnd = side.getIDEnd().Equals(node.getID());
                if (isEnd || side.getIDStart().Equals(node.getID()))
                {
                    oldLength.Add(isEnd ? side.getIDStart() : side.getIDEnd(), side.getLength());
                }
            }


            this.node       = node;
            this.trajectory = trajectory;
        }