From a00b32a206aee485d612a2d636ccf87136f17268 Mon Sep 17 00:00:00 2001 From: Reino Ruusu Date: Fri, 14 Feb 2020 16:56:16 +0200 Subject: [PATCH] Allow unsplitting removal of reducers by joining pipe runs gitlab #83 Change-Id: Ia47d7234caae13eee3c23ffa72d8d4950c38070e --- .../plant3d/scenegraph/PipelineComponent.java | 33 +++++++++++++++++++ .../controlpoint/PipeControlPoint.java | 4 +-- 2 files changed, 34 insertions(+), 3 deletions(-) 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); } } -- 2.45.2