X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.plant3d%2Fsrc%2Forg%2Fsimantics%2Fplant3d%2Factions%2FAddComponentAction.java;h=119820178c8e9ff2b02275788608fe5937a12fba;hb=8d6ebee4afa4fbf205cc7e0b71596b7780a7dacd;hp=4f35291e88a8a7695171f43ddda2ec1b309e9baa;hpb=62fb6eb651ae640336d71746d7bfa79bcfa211df;p=simantics%2F3d.git diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/actions/AddComponentAction.java b/org.simantics.plant3d/src/org/simantics/plant3d/actions/AddComponentAction.java index 4f35291e..11982017 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/actions/AddComponentAction.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/actions/AddComponentAction.java @@ -195,31 +195,17 @@ public class AddComponentAction extends vtkSwtAction { dir = new Vector3d(); toPcp.getInlineControlPointEnds(start, end, dir); dir.normalize(); - if (!insertAdjustable || insertPosition == PositionType.NEXT) { - switch (position) { - case NEXT: - pos = new Vector3d(end); - break; - case PREVIOUS: - pos = new Vector3d(start); - break; - case SPLIT: - break; - } - } else if (insertPosition == PositionType.SPLIT) { - pos = new Vector3d(toPcp.getWorldPosition()); - } else { - switch (position) { - case NEXT: - pos = new Vector3d(start); - break; - case PREVIOUS: - pos = new Vector3d(end); - break; - case SPLIT: - break; - } - } + switch (position) { + case NEXT: + pos = new Vector3d(end); + break; + case PREVIOUS: + pos = new Vector3d(start); + break; + case SPLIT: + pos = new Vector3d(toPcp.getWorldPosition()); + break; + } } else if (toPcp.isDirected()) { dir = new Vector3d(toPcp.getDirection(Direction.NEXT)); @@ -227,10 +213,21 @@ public class AddComponentAction extends vtkSwtAction { } else if (toPcp.isTurn() && toPcp.isFixed()) { dir = new Vector3d(toPcp.getDirection(position == PositionType.NEXT ? Direction.NEXT : Direction.PREVIOUS)); pos = new Vector3d(toPcp.getWorldPosition()); - if (!lengthAdjustable || insertPosition == PositionType.NEXT) { + if (!lengthAdjustable) { Vector3d v = new Vector3d(dir); v.scale(toPcp.getInlineLength()); pos.add(v); + } else { + if (insertPosition == PositionType.NEXT) { + Vector3d v = new Vector3d(dir); + v.scale(toPcp.getInlineLength()); + pos.add(v); + } else if (insertPosition == PositionType.SPLIT) { + // scale 0.5*length so that we don't remove the length twice from the new component + Vector3d v = new Vector3d(dir); + v.scale(toPcp.getInlineLength()*0.5); + pos.add(v); + } } }