]> gerrit.simantics Code Review - simantics/3d.git/commitdiff
Allow unsplitting removal of reducers by joining pipe runs 72/3872/1
authorReino Ruusu <reino.ruusu@semantum.fi>
Fri, 14 Feb 2020 14:56:16 +0000 (16:56 +0200)
committerReino Ruusu <reino.ruusu@semantum.fi>
Fri, 14 Feb 2020 14:57:19 +0000 (16:57 +0200)
gitlab #83

Change-Id: Ia47d7234caae13eee3c23ffa72d8d4950c38070e

org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/PipelineComponent.java
org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipeControlPoint.java

index e1a24f10369024c61a29a1b3d1e8e525039cac3f..d3ded1efe7b0fe1217fd706844555ea219b4a8ea 100644 (file)
@@ -459,11 +459,44 @@ public abstract class PipelineComponent extends GeometryNode {
                PipeControlPoint pcp = getControlPoint();
                // Second check is needed, when remove process is initiated from control point.
                if (pcp != null && pcp.getPipelineComponent() != null) {
+                       if (pcp.isSizeChange()) {
+                               mergeWithAlternative();
+                       }
+                       
                        pcp.remove();
                }
+               
                setPipeRun(null);
                super.remove();
        }
+
+       private void mergeWithAlternative() {
+               PipeRun run = getPipeRun();
+               PipeRun alternative = getAlternativePipeRun();
+               if (alternative != null) {
+                       // Move components from alternative pipe run to main run
+                       PipelineComponent p = getNext();
+                       while (p != null && p.getPipeRun() == alternative) {
+                               if (p.getParent() == alternative) {
+                                       p.deattach(); // For components
+                                       run.addChild(p);
+                               }
+                               else {
+                                       p.setPipeRun(run); // For nozzles
+                               }
+
+                               p.updateParameters();
+                               PipingRules.requestUpdate(p.getControlPoint());
+                               
+                               p = p.getNext();
+                       }
+                       
+                       setAlternativePipeRun(run);
+                       
+                       if (alternative.getChild().isEmpty())
+                               alternative.remove();
+               }
+       }
        
        public void removeAndSplit() {
            PipeControlPoint pcp = getControlPoint();
index b67562459016b3dddcb1ba730a99a1a5bb016beb..37f118cd05e00bd6b76db739cb661e85efed8ea6 100644 (file)
@@ -1212,9 +1212,7 @@ public class PipeControlPoint extends G3DNode implements IP3DNode {
                                if (link) {
                                    if (currentPrev.isDirected() && currentNext.isDirected())
                                        link = false;
-                                   else if (this.isDualInline()) {
-                                       link = false;
-                                   } else if (this.isDualSub()) {
+                                   else if (this.isDualSub()) {
                                        throw new RuntimeException("_remove() is called for parent point, somehow got to child point. " + this);
                                    }
                                }