From: Reino Ruusu Date: Fri, 14 Feb 2020 14:56:16 +0000 (+0200) Subject: Allow unsplitting removal of reducers by joining pipe runs X-Git-Tag: v1.43.0~74 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F72%2F3872%2F1;p=simantics%2F3d.git Allow unsplitting removal of reducers by joining pipe runs gitlab #83 Change-Id: Ia47d7234caae13eee3c23ffa72d8d4950c38070e --- diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/PipelineComponent.java b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/PipelineComponent.java index e1a24f10..d3ded1ef 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/PipelineComponent.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/PipelineComponent.java @@ -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(); diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipeControlPoint.java b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipeControlPoint.java index b6756245..37f118cd 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipeControlPoint.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipeControlPoint.java @@ -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); } }