X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.plant3d%2Fsrc%2Forg%2Fsimantics%2Fplant3d%2Fscenegraph%2FPipelineComponent.java;h=f0621fdd2ce7f76dad1490963b62ba73583065a1;hb=refs%2Fchanges%2F08%2F3908%2F2;hp=7726b203005611c05b89a739b634617018f79295;hpb=ba83a8b8c95b94a035d20e458880beec68b9c450;p=simantics%2F3d.git 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 7726b203..f0621fdd 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/PipelineComponent.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/PipelineComponent.java @@ -4,6 +4,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; +import java.util.Objects; import javax.vecmath.Quat4d; import javax.vecmath.Tuple3d; @@ -459,11 +460,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(); @@ -675,4 +709,29 @@ public abstract class PipelineComponent extends GeometryNode { throw new IllegalStateException("No centroid defined"); } } + + + private String error; + + /** + * Returns possible pipe modelling error, or null; + * @return + */ + @GetPropertyValue(name="Error", value="error", tabId = "Default") + public String getError() { + return error; + } + + /** + * Sets pipe modelling error. + * + * Error is usually set by PipingRules. + * @param error + */ + public void setError(String error) { + if (Objects.equals(this.error, error)) + return; + this.error = error; + firePropertyChanged("error"); + } }