X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.plant3d%2Fsrc%2Forg%2Fsimantics%2Fplant3d%2Futils%2FComponentUtils.java;h=a1ac7f82834a5a36551e93bebd42b7aa8e9fa45c;hb=1180e4e22c5935827272cdea27a1abb39c056ca2;hp=6bbabe1e251c9feaf3f10e1767a56ce827ec91f0;hpb=d515401dd50a89bb6f0f5c8d75e045a96db39f51;p=simantics%2F3d.git diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/utils/ComponentUtils.java b/org.simantics.plant3d/src/org/simantics/plant3d/utils/ComponentUtils.java index 6bbabe1e..a1ac7f82 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/utils/ComponentUtils.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/utils/ComponentUtils.java @@ -447,6 +447,8 @@ public class ComponentUtils { } else if (toPcp.isDirected()) { dir = new Vector3d(toPcp.getDirection(Direction.NEXT)); + if (position == PositionType.PREVIOUS) + dir.negate(); pos = new Vector3d(toPcp.getWorldPosition()); } else if (toPcp.isTurn() && toPcp.asFixedAngle()) { dir = new Vector3d(toPcp.getDirection(position == PositionType.NEXT ? Direction.NEXT : Direction.PREVIOUS)); @@ -499,6 +501,11 @@ public class ComponentUtils { Vector3d v = new Vector3d(dir); if (insertAdjustable) { + // Prevent moving of adjacent components - always insert at end of a connected variable length component + if (position == PositionType.NEXT && component.getNext() != null || + position == PositionType.PREVIOUS && component.getPrevious() != null) + insertPosition = PositionType.PREVIOUS; + if (insertPosition == PositionType.NEXT) v.scale(newComponent.getControlPoint().getInlineLength()); else if (insertPosition == PositionType.SPLIT) @@ -525,14 +532,20 @@ public class ComponentUtils { case NEXT: if (toPcp.isDualInline()) toPcp = toPcp.getDualSub(); - newPcp.insert(toPcp, Direction.NEXT); newPcp.setWorldPosition(pos); + if (toPcp.getNext() != null) + PipingRules.splitVariableLengthComponent(newComponent, (InlineComponent)component, false); + else + newPcp.insert(toPcp, Direction.NEXT); break; case PREVIOUS: if (toPcp.isDualSub()) toPcp = toPcp.parent; - newPcp.insert(toPcp, Direction.PREVIOUS); newPcp.setWorldPosition(pos); + if (toPcp.getPrevious() != null) + PipingRules.splitVariableLengthComponent(newComponent, (InlineComponent)component, false); + else + newPcp.insert(toPcp, Direction.PREVIOUS); break; case SPLIT: PipingRules.splitVariableLengthComponent(newComponent, (InlineComponent)component, true);