]> gerrit.simantics Code Review - simantics/3d.git/blobdiff - org.simantics.plant3d/src/org/simantics/plant3d/actions/AddComponentAction.java
Creating equipment with typeURI
[simantics/3d.git] / org.simantics.plant3d / src / org / simantics / plant3d / actions / AddComponentAction.java
index 4f35291e88a8a7695171f43ddda2ec1b309e9baa..119820178c8e9ff2b02275788608fe5937a12fba 100644 (file)
@@ -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);
+                    }
                 }
                        }