X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.plant3d%2Fsrc%2Forg%2Fsimantics%2Fplant3d%2Fscenegraph%2Fcontrolpoint%2FPipeControlPoint.java;h=daab2d111b234d2da42a16f78671a543a9f23607;hb=refs%2Fchanges%2F58%2F3358%2F2;hp=93186779e60d580aa31d23a95585ce4886ff9f7b;hpb=27fb679643fab3ef9aa46d04c5ced2ea82cf60c2;p=simantics%2F3d.git 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 93186779..daab2d11 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 @@ -16,6 +16,8 @@ import org.simantics.g3d.math.MathTools; import org.simantics.g3d.property.annotations.GetPropertyValue; import org.simantics.g3d.scenegraph.G3DNode; import org.simantics.plant3d.scenegraph.IP3DNode; +import org.simantics.plant3d.scenegraph.Nozzle; +import org.simantics.plant3d.scenegraph.P3DRootNode; import org.simantics.plant3d.scenegraph.PipeRun; import org.simantics.plant3d.scenegraph.PipelineComponent; @@ -938,8 +940,12 @@ public class PipeControlPoint extends G3DNode implements IP3DNode { } } } - + public void _remove() { + _remove(true); + } + + public void _remove(boolean renconnect) { if (component == null && next == null && previous == null) return; if (isDualInline() || isDualSub()) { @@ -964,7 +970,7 @@ public class PipeControlPoint extends G3DNode implements IP3DNode { return; } if (currentNext != null && currentPrev != null) { - boolean link = true; + boolean link = renconnect; if (currentNext.isBranchEnd()) { link = false; // currentNext.setPrevious(null); @@ -1125,6 +1131,41 @@ public class PipeControlPoint extends G3DNode implements IP3DNode { e.printStackTrace(); } } + + public void removeAndSplit() { + PipeControlPoint currentPrev = previous; + PipeControlPoint currentNext = next; + + if (next != null && previous != null) { + P3DRootNode root = (P3DRootNode)getPipelineComponent().getRootNode(); + PipeRun nextPipeRun = new PipeRun(); + nextPipeRun.setName(root.getUniqueName("PipeRun")); + root.addChild(nextPipeRun); + + PipeRun previousRun = previous.getPipeRun(); + nextPipeRun.setPipeDiameter(previousRun.getPipeDiameter()); + nextPipeRun.setTurnRadius(previousRun.getTurnRadius()); + + PipelineComponent n = next.getPipelineComponent(); + while (n != null) { + if (! (n instanceof Nozzle)) { + n.deattach(); + nextPipeRun.addChild(n); + } else + n.setPipeRun(nextPipeRun); + n = n.getNext(); + } + } + _remove(false); + try { + if (currentNext != null) + PipingRules.requestUpdate(currentNext); + if (currentPrev != null) + PipingRules.requestUpdate(currentPrev); + } catch (Exception e) { + e.printStackTrace(); + } + } private void checkRemove(PipeRun pipeRun) { Collection points = pipeRun.getControlPoints();