]> gerrit.simantics Code Review - simantics/3d.git/blobdiff - org.simantics.plant3d/src/org/simantics/plant3d/actions/AddComponentAction.java
Merge "Remove static DEBUG flags and use slf4j.Logger.trace()" into release/1.43.0
[simantics/3d.git] / org.simantics.plant3d / src / org / simantics / plant3d / actions / AddComponentAction.java
index 9b3d90835e14a3961f5c9af0c48fd7ead86417dc..b82a097cb7b250b554588e942ad832c8f358ff21 100644 (file)
@@ -76,13 +76,13 @@ public class AddComponentAction extends vtkSwtAction {
                                allowed.add(PositionType.NEXT);
                        }  
                } else {
-                       if (component.getNext() == null) {
+                       if (component.getNext() == null || component.getControlPoint().isVariableLength()) {
                                allowed.add(PositionType.NEXT);
                        }
-                       if (component.getPrevious() == null) {
+                       if (component.getPrevious() == null || component.getControlPoint().isVariableLength()) {
                                allowed.add(PositionType.PREVIOUS);
                        }
-                       if (component instanceof InlineComponent && !component.getControlPoint().isFixedLength()){
+                       if (component instanceof InlineComponent && component.getControlPoint().isVariableLength()){
                                allowed.add(PositionType.SPLIT);
                        }
                }
@@ -95,6 +95,7 @@ public class AddComponentAction extends vtkSwtAction {
        private Double angle;
        private Double rotationAngle;
        private Double diameter;
+       private Double thickness;
        private Double turnRadius;
        
        @Override
@@ -119,6 +120,7 @@ public class AddComponentAction extends vtkSwtAction {
                this.angle = dialog.getAngle();
                this.rotationAngle = dialog.getRotationAngle();
                this.diameter = dialog.getDiameter();
+               this.thickness = dialog.getThickness();
                this.turnRadius = dialog.getTurnRadius();
                allowed = dialog.filterAllowed();
                gizmo.setComponent(component, allowed);
@@ -198,17 +200,29 @@ public class AddComponentAction extends vtkSwtAction {
                        inst.name = name;
                        inst.angle = angle != null ? MathTools.degToRad(angle) : null;
                        inst.diameter = diameter;
+                       inst.thickness = thickness;
                        inst.length = length;
                        inst.turnRadius = turnRadius;
                        inst.insertPosition = insertPosition;
                        inst.rotationAngle = rotationAngle;
                        inst.position = position;
-                       ComponentUtils.addComponent(root, component, inst);
+                       PipelineComponent newComponent = ComponentUtils.addComponent(root, component, inst);
+                       componentAdded(newComponent);
                } catch (Exception e) {
                        ExceptionUtils.logAndShowError("Cannot add component", e);
                }
        }
        
+       /**
+        * This method does nothing, but can be overridden by a subclass to do additional
+        * post-processing for a newly added component.
+        * 
+        * @param newComponent  A newly added pipeline component
+        */
+       protected void componentAdded(PipelineComponent newComponent) {
+               // Nothing to do here
+       }
+
        public boolean mouseClicked(MouseEvent e) {
                if (e.getClickCount() == 1 && e.getButton() == MouseEvent.BUTTON1) {
                        int type = panel.getPickType();