]> gerrit.simantics Code Review - simantics/3d.git/blobdiff - org.simantics.plant3d/src/org/simantics/plant3d/actions/TranslateInlineAction.java
Replace "turn" with "elbow" in component creation UI
[simantics/3d.git] / org.simantics.plant3d / src / org / simantics / plant3d / actions / TranslateInlineAction.java
index 92a88b53ecdf21ba55b84feed4bbc914f8b611d5..91cc3ceae233e2c68f2f300ed2a612f158ba5620 100644 (file)
@@ -9,6 +9,8 @@ import javax.vecmath.Vector3d;
 import org.simantics.g3d.math.MathTools;
 import org.simantics.g3d.math.Ray;
 import org.simantics.g3d.scenegraph.IG3DNode;
+import org.simantics.g3d.scenegraph.base.INode;
+import org.simantics.g3d.toolbar.ToolComposite;
 import org.simantics.g3d.vtk.common.VTKNodeMap;
 import org.simantics.g3d.vtk.swt.InteractiveVtkComposite;
 import org.simantics.g3d.vtk.swt.TranslateAction;
@@ -26,8 +28,8 @@ public class TranslateInlineAction extends TranslateAction{
        private Vector3d e;
        private Vector3d dir;
 
-       public TranslateInlineAction(InteractiveVtkComposite panel, VTKNodeMap nodeMap) {
-               super(panel, nodeMap);
+       public TranslateInlineAction(InteractiveVtkComposite panel, VTKNodeMap<?, ? extends INode> nodeMap, ToolComposite toolComposite) {
+               super(panel, nodeMap, toolComposite);
                setImageDescriptor(Activator.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/arrow_refresh.png"));
        }
        
@@ -41,7 +43,7 @@ public class TranslateInlineAction extends TranslateAction{
                        } else if (comp.getNext() == null || comp.getPrevious() == null) {
                 setEnabled(true);
                 inline = false;
-                dir = comp.getControlPoint().getPathLegDirection(Direction.NEXT);
+                dir = comp.getControlPoint().getInlineDir();
                 dir.normalize();
             } else {
                                setEnabled(true);
@@ -53,9 +55,9 @@ public class TranslateInlineAction extends TranslateAction{
                                        setEnabled(false);
                                        return;
                                }
-                               if (prev.getControlPoint().isInline() && !prev.getControlPoint().isFixed() && prev.getPrevious() != null)
+                               if (prev.getControlPoint().isInline() && !prev.getControlPoint().isFixedLength() && prev.getPrevious() != null)
                                        prev = prev.getPrevious();
-                               if (next.getControlPoint().isInline() && !next.getControlPoint().isFixed() && next.getNext() != null) {
+                               if (next.getControlPoint().isInline() && !next.getControlPoint().isFixedLength() && next.getNext() != null) {
                                        next = next.getNext();
                                }
                                Point3d ns = new Point3d();
@@ -64,8 +66,7 @@ public class TranslateInlineAction extends TranslateAction{
                                Point3d pe = new Point3d();
                                next.getEnds(ns, ne);
                                prev.getEnds(ps, pe);
-                               dir = comp.getControlPoint().getPathLegDirection(Direction.NEXT);
-                               dir.normalize();
+                               dir = comp.getControlPoint().getInlineDir();
                                // We may have offsets in the path leg, hence we have to project the coordinates.
                                Vector3d wp = node.getWorldPosition();
                                if (prev.getControlPoint().isVariableLength())
@@ -88,6 +89,11 @@ public class TranslateInlineAction extends TranslateAction{
                }
        }
        
+       @Override
+       protected void createTools(ToolComposite toolComposite) {
+           
+       }
+       
        @Override
        public boolean keyPressed(KeyEvent e) {
                if (e.getKeyCode() == KeyEvent.VK_ESCAPE)
@@ -120,7 +126,7 @@ public class TranslateInlineAction extends TranslateAction{
                        //boolean step = ((e.getModifiers() & MouseEvent.CTRL_MASK) > 0);
                        Vector3d pos = new Vector3d(node.getWorldPosition());
                        
-                       System.out.println(pos + " " + translate);
+//                     System.out.println(pos + " " + translate);
                        //pos.add(translate);
                        pos.set(translate);
                        //pos = constaints(pos, step);