X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.plant3d%2Fsrc%2Forg%2Fsimantics%2Fplant3d%2Factions%2FAddComponentAction.java;h=f87e63f70aa216639bc947d8e3dc9f5bf3f53f09;hb=refs%2Fchanges%2F87%2F4287%2F1;hp=dae8c629b4335a7bfacb88503086d7d34285311b;hpb=47a78f85f52d380243f8138a8104f79299c3c86c;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 dae8c629..f87e63f7 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/actions/AddComponentAction.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/actions/AddComponentAction.java @@ -52,6 +52,7 @@ public class AddComponentAction extends vtkSwtAction { private String libUri; private double lengthFactor = 1.0; + private String lengthUnit = "m"; public AddComponentAction(InteractiveVtkComposite panel, P3DRootNode root, String libUri) { super(panel); @@ -67,6 +68,10 @@ public class AddComponentAction extends vtkSwtAction { this.lengthFactor = lengthFactor; } + public void setLengthUnit(String lengthUnit) { + this.lengthUnit = lengthUnit; + } + public void setComponent(PipelineComponent component) { this.component = component; @@ -106,6 +111,7 @@ public class AddComponentAction extends vtkSwtAction { // Set list of already reserved component names dialog.addUsedNames(ComponentUtils.getPipelineComponentNames(root)); dialog.setLengthFactor(lengthFactor); + dialog.setLengthUnit(lengthUnit); if (dialog.open() == ComponentSelectionDialog.CANCEL) return; @@ -206,12 +212,23 @@ public class AddComponentAction extends vtkSwtAction { 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();