]> gerrit.simantics Code Review - simantics/3d.git/blobdiff - org.simantics.plant3d/src/org/simantics/plant3d/actions/AddComponentAction.java
Simplified free ended variable length component update
[simantics/3d.git] / org.simantics.plant3d / src / org / simantics / plant3d / actions / AddComponentAction.java
index 4f35291e88a8a7695171f43ddda2ec1b309e9baa..174d6f1166eac0718aa4aa814bb491b34ae67c66 100644 (file)
@@ -227,10 +227,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);
+                    }
                 }
                        }