]> 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 a57fcc4c0be6d4e48db55f71710e2c1515f18be8..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;
                
@@ -1050,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;
        }