]> gerrit.simantics Code Review - simantics/3d.git/blobdiff - org.simantics.plant3d/src/org/simantics/plant3d/actions/RoutePipeAction.java
Adapters.xml change missing from Flat Nozzle support
[simantics/3d.git] / org.simantics.plant3d / src / org / simantics / plant3d / actions / RoutePipeAction.java
index 24b6a14bdfcef66fd5c1df8876fa6c14ac2fe0ff..9773a9eae8c77a5c3c3a1bf350ffadaee6a0dc39 100644 (file)
@@ -69,7 +69,7 @@ public class RoutePipeAction extends vtkSwtAction {
        private enum ToolState{NOT_ACTIVE, INITIALIZING, SELECTING_POSITION, SELECTING_SPLIT, ROUTING};
        private ToolState state = ToolState.NOT_ACTIVE;
        
-       private ConstraintDetector detector = new DummyConstraintDetector();
+       private ConstraintDetector detector;// = new DummyConstraintDetector();
        
        private boolean useDefault = false;
        private Vector3d direction = null;
@@ -95,6 +95,7 @@ public class RoutePipeAction extends vtkSwtAction {
                nodeMap = root.getNodeMap();
                splitPointSelectionGizmo = new SplitPointSelectionGizmo(panel);
                terminalSelectionGizmo = new TerminalSelectionGizmo(panel);
+               detector = new org.simantics.g3d.vtk.swt.ConstraintDetector(panel);
        }
        
        public void setComponent(PipelineComponent component) {
@@ -529,7 +530,7 @@ public class RoutePipeAction extends vtkSwtAction {
                //                    selectionLine = null;
                                                }
                                        } else if (e.getButton() ==MouseEvent.BUTTON2){
-               //                detector.updateConstraintReference();
+                                           updateConstraints();
                                        } else if (e.getButton() == MouseEvent.BUTTON3){      
                                                endPiping();
                                        }
@@ -595,6 +596,27 @@ public class RoutePipeAction extends vtkSwtAction {
                return true;
        }
        
+       private void updateConstraints() {
+           detector.clearConstraints();
+           if (hoverObject == null) {
+               return;
+           }
+           if (hoverObject instanceof Nozzle) {
+            Nozzle n = (Nozzle)hoverObject;
+            detector.addContraintPoint(new Point3d(n.getWorldPosition()));
+           } else if (hoverObject instanceof InlineComponent) {
+               InlineComponent c = (InlineComponent)hoverObject;
+               Point3d p1 = new Point3d();
+               Point3d p2 = new Point3d();
+               c.getEnds(p1, p2);
+               detector.addContraintPoint(p1);
+               detector.addContraintPoint(p2);
+           } else if (hoverObject instanceof TurnComponent) {
+               TurnComponent n = (TurnComponent)hoverObject;
+            detector.addContraintPoint(new Point3d(n.getWorldPosition()));
+           }
+       }
+       
        @Override
        public boolean mouseMoved(MouseEvent e) {
                if (useDefault) {
@@ -627,7 +649,7 @@ public class RoutePipeAction extends vtkSwtAction {
                return nodes;
        }
        
-
+       INode hoverObject = null;
 
        private void updateRouting(double x, double y) {
 //             if(input.keyPressed(KeyEvent.VK_ESCAPE)) {
@@ -660,12 +682,14 @@ public class RoutePipeAction extends vtkSwtAction {
                
                
                
-               INode hoverObject = null;
+               
                
                List<INode> hover = isOverNode((int)x,(int)y);
                if (hover.size() > 0) {
                        hoverObject = hover.get(0);
-               } 
+               } else {
+                   hoverObject = null;
+               }
 //             System.out.println(hoverObject + " " + getLast());
                if (hoverObject != null) {
                        if (hoverObject.equals(getLast()) ) {