]> gerrit.simantics Code Review - simantics/3d.git/blobdiff - org.simantics.plant3d/src/org/simantics/plant3d/actions/RoutePipeAction.java
PipeCOntrolPoint setNext/setPrev/remove improved
[simantics/3d.git] / org.simantics.plant3d / src / org / simantics / plant3d / actions / RoutePipeAction.java
index 7de27a31cde15fc90d939bd19df5e54908387ff2..9f523c956be2b8ac7c08cb2f15740e45dc67c380 100644 (file)
@@ -310,7 +310,7 @@ public class RoutePipeAction extends vtkSwtAction {
        
        protected void activateNextPrev(PipeControlPoint start) throws Exception{
                if (!reversed && start.isDualInline())
-                       start = start.getSubPoint().get(0);
+                       start = start.getDualSub();
                else if (reversed && start.isDualSub())
                        start = start.parent;
                
@@ -839,6 +839,7 @@ public class RoutePipeAction extends vtkSwtAction {
                return true;
        }
        
+       @SuppressWarnings("unused")
        private Vector3d getLockDir() {
                switch (lock) {
                case CUSTOM:
@@ -849,8 +850,9 @@ public class RoutePipeAction extends vtkSwtAction {
                        return new Vector3d(0,1,0);
                case Z:
                        return new Vector3d(0,0,1);
+               default:
+                       return null;
                }
-               return null;
        }
        
        protected void updateRoute(Vector3d o, Vector3d d) {
@@ -1048,21 +1050,29 @@ public class RoutePipeAction extends vtkSwtAction {
        private PipeControlPoint endingToComponent(INode componentNode, Vector3d o, Vector3d d) {
                PipelineComponent component = (PipelineComponent)componentNode;
                PipeControlPoint pcp = component.getControlPoint();
+               PipeControlPoint connect = null;
                if (component instanceof EndComponent) {
                        if (pcp.getNext() != null || pcp.getPrevious() != null)
                                return null;
-                       return pcp;
+                       connect =  pcp;
                } else if (component instanceof TurnComponent) {
                        if (pcp.getNext() == null || pcp.getPrevious() == null)
-                               return pcp;
-                       return null;
+                               connect = pcp;
+                       else
+                           return null;
                } else if (component instanceof InlineComponent) {
                        // TODO : scan all empty pcps of the component and select closest one.
                        if (pcp.getNext() == null || pcp.getPrevious() == null)
-                               return pcp;
-                       return null;
+                               connect =  pcp;
+                       else
+                           return null;
+               }
+               if (connect != null) {
+                   currentPosition.set(connect.getWorldPosition());
+            updateCurrentPoint();
+                   setInfoText("Connect to " + component.getName());
+                   return connect;
                }
-
                return null;
        }