]> gerrit.simantics Code Review - simantics/3d.git/commitdiff
Added a length scaling factor for adding components 67/3867/1
authorReino Ruusu <reino.ruusu@semantum.fi>
Wed, 12 Feb 2020 14:12:57 +0000 (16:12 +0200)
committerReino Ruusu <reino.ruusu@semantum.fi>
Wed, 12 Feb 2020 14:13:16 +0000 (16:13 +0200)
gitlab #78

Change-Id: Ied89a7f8289aad1e0ca952c4fb51e40df93fc811

org.simantics.plant3d/src/org/simantics/plant3d/actions/AddComponentAction.java
org.simantics.plant3d/src/org/simantics/plant3d/dialog/ComponentSelectionDialog.java

index d9ee9d70849188f7f50e7ba0bc2b58513609c3ac..0ee0f6bc2bbcfbf137148357f50f47e70edba792 100644 (file)
@@ -50,6 +50,8 @@ public class AddComponentAction extends vtkSwtAction {
        
        private String libUri;
        
+       private double lengthFactor = 1.0;
+       
        public AddComponentAction(InteractiveVtkComposite panel, P3DRootNode root, String libUri) {
                super(panel);
                this.root = root;
@@ -60,6 +62,10 @@ public class AddComponentAction extends vtkSwtAction {
                this.libUri = libUri;
        }
        
+       public void setLengthFactor(double lengthFactor) {
+               this.lengthFactor = lengthFactor;
+       }
+
        public void setComponent(PipelineComponent component) {
                this.component = component;
                
@@ -97,6 +103,7 @@ public class AddComponentAction extends vtkSwtAction {
                
                // Set list of already reserved component names
                dialog.addUsedNames(ComponentUtils.getPipelineComponentNames(root));
+               dialog.setLengthFactor(lengthFactor);
                
                if (dialog.open() == ComponentSelectionDialog.CANCEL)
                        return;
index 720d88cec826729ba748870ace5a4acb7472b02a..35e761ccfa6eb436071352e6721b192e67255f76 100644 (file)
@@ -53,6 +53,8 @@ public class ComponentSelectionDialog extends Dialog implements ISelectionChange
        private static final String DIALOG = "ComponentSelectionDialog"; //$NON-NLS-1$
 
        private IDialogSettings dialogSettings;
+       
+       private double lengthFactor = 1.0;
 
        private ResourceManager resourceManager;
 
@@ -126,6 +128,10 @@ public class ComponentSelectionDialog extends Dialog implements ISelectionChange
                if (dialogSettings == null)
                        dialogSettings = settings.addNewSection(DIALOG);
        }
+       
+       public void setLengthFactor(double lengthFactor) {
+               this.lengthFactor = lengthFactor;
+       }
 
        @Override
        protected IDialogSettings getDialogBoundsSettings() {
@@ -317,7 +323,7 @@ public class ComponentSelectionDialog extends Dialog implements ISelectionChange
                        @Override
                        public void keyReleased(KeyEvent e) {
                                try {
-                                       length = Double.parseDouble(lengthText.getText());
+                                       length = Double.parseDouble(lengthText.getText()) / lengthFactor;
                                } catch (NumberFormatException err) {
                                        length = null;
                                }
@@ -353,7 +359,7 @@ public class ComponentSelectionDialog extends Dialog implements ISelectionChange
                        @Override
                        public void keyReleased(KeyEvent e) {
                                try {
-                                       diameter = Double.parseDouble(diameterText.getText());
+                                       diameter = Double.parseDouble(diameterText.getText()) / lengthFactor;
                                } catch (NumberFormatException err) {
                                        diameter = null;
                                }
@@ -365,7 +371,7 @@ public class ComponentSelectionDialog extends Dialog implements ISelectionChange
                        @Override
                        public void keyReleased(KeyEvent e) {
                                try {
-                                       turnRadius = Double.parseDouble(turnRadiusText.getText());
+                                       turnRadius = Double.parseDouble(turnRadiusText.getText()) / lengthFactor;
                                } catch (NumberFormatException err) {
                                        turnRadius = null;
                                }