]> gerrit.simantics Code Review - simantics/3d.git/commitdiff
Add a wall thickness property to pipe runs. 76/3976/1
authorReino Ruusu <reino.ruusu@semantum.fi>
Mon, 9 Mar 2020 09:03:21 +0000 (11:03 +0200)
committerReino Ruusu <reino.ruusu@semantum.fi>
Mon, 9 Mar 2020 09:03:21 +0000 (11:03 +0200)
gitlab #104

Change-Id: Ib21da6f7aee8c2bb1aa74b9a43cdf72264e9f689

org.simantics.plant3d.ontology/graph/plant3d.pgraph
org.simantics.plant3d.ontology/src/org/simantics/plant3d/ontology/Plant3D.java
org.simantics.plant3d/src/org/simantics/plant3d/actions/AddComponentAction.java
org.simantics.plant3d/src/org/simantics/plant3d/dialog/ComponentSelectionDialog.java
org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/PipeRun.java
org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipeControlPoint.java
org.simantics.plant3d/src/org/simantics/plant3d/utils/ComponentUtils.java

index d6029cc68af39fdf57d6f3b1649534bbdf00b119..1fe9540b2c2f85148bf748f2258212f9eed06b22 100644 (file)
@@ -105,6 +105,8 @@ P3D.HasBranch9 <R P3D.Connects
     
 P3D.HasPipeDiameter <R G3D.hasNonTransformation
     L0.HasRange L0.Double
+P3D.HasPipeThickness <R G3D.hasNonTransformation
+    L0.HasRange L0.Double
 P3D.HasRotationAngle <R G3D.hasTransformation
     L0.HasRange L0.Double
 P3D.HasLength <R G3D.hasNonTransformation
index c60908ba4ff8e85a4ce643da960dca9de973896e..950f840866d859370aa25c32a327ff0cc7c0f938 100644 (file)
@@ -74,6 +74,8 @@ public class Plant3D {
     public final Resource HasPipeDiameter;
     public final Resource HasPipeDiameter_Inverse;
     public final Resource HasPipeRun;
+    public final Resource HasPipeThickness;
+    public final Resource HasPipeThickness_Inverse;
     public final Resource HasPrevious;
     public final Resource HasRotationAngle;
     public final Resource HasRotationAngle_Inverse;
@@ -194,6 +196,8 @@ public class Plant3D {
         public static final String HasPipeDiameter = "http://www.simantics.org/Plant3D-0.1/HasPipeDiameter";
         public static final String HasPipeDiameter_Inverse = "http://www.simantics.org/Plant3D-0.1/HasPipeDiameter/Inverse";
         public static final String HasPipeRun = "http://www.simantics.org/Plant3D-0.1/HasPipeRun";
+        public static final String HasPipeThickness = "http://www.simantics.org/Plant3D-0.1/HasPipeThickness";
+        public static final String HasPipeThickness_Inverse = "http://www.simantics.org/Plant3D-0.1/HasPipeThickness/Inverse";
         public static final String HasPrevious = "http://www.simantics.org/Plant3D-0.1/HasPrevious";
         public static final String HasRotationAngle = "http://www.simantics.org/Plant3D-0.1/HasRotationAngle";
         public static final String HasRotationAngle_Inverse = "http://www.simantics.org/Plant3D-0.1/HasRotationAngle/Inverse";
@@ -324,6 +328,8 @@ public class Plant3D {
         HasPipeDiameter = getResourceOrNull(graph, URIs.HasPipeDiameter);
         HasPipeDiameter_Inverse = getResourceOrNull(graph, URIs.HasPipeDiameter_Inverse);
         HasPipeRun = getResourceOrNull(graph, URIs.HasPipeRun);
+        HasPipeThickness = getResourceOrNull(graph, URIs.HasPipeThickness);
+        HasPipeThickness_Inverse = getResourceOrNull(graph, URIs.HasPipeThickness_Inverse);
         HasPrevious = getResourceOrNull(graph, URIs.HasPrevious);
         HasRotationAngle = getResourceOrNull(graph, URIs.HasRotationAngle);
         HasRotationAngle_Inverse = getResourceOrNull(graph, URIs.HasRotationAngle_Inverse);
index 9b3d90835e14a3961f5c9af0c48fd7ead86417dc..8dcee92610f00f8fea6afc1a1114d949cc787e1f 100644 (file)
@@ -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,6 +200,7 @@ 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;
index 030cce9f12d47c89c8d5d12dcea1a716372c60fb..c0851fd25d19913b8ed4b114b34bfd8fc551633e 100644 (file)
@@ -88,9 +88,11 @@ public class ComponentSelectionDialog extends Dialog implements ISelectionChange
 
        // Input for new PipeRun
        private Double diameter;
+       private Double thickness;
        private Double turnRadius;
 
        private Text diameterText;
+       private Text thicknessText;
        private Text turnRadiusText;
 
        // Position selection
@@ -305,7 +307,10 @@ public class ComponentSelectionDialog extends Dialog implements ISelectionChange
                label.setText("Diameter");
                diameterText = new Text(composite, SWT.SINGLE | SWT.BORDER);
                label = new Label(composite, SWT.NONE);
-               label.setText("Turn Radius");
+               label.setText("Wall thickness");
+               thicknessText = new Text(composite, SWT.SINGLE | SWT.BORDER);
+               label = new Label(composite, SWT.NONE);
+               label.setText("Turn radius");
                turnRadiusText = new Text(composite, SWT.SINGLE | SWT.BORDER);
 
                lengthText.setEnabled(false);
@@ -313,6 +318,7 @@ public class ComponentSelectionDialog extends Dialog implements ISelectionChange
                rotationAngleText.setEnabled(false);
                turnRadiusText.setEnabled(false);
                diameterText.setEnabled(false);
+               thicknessText.setEnabled(false);
 
                nameText.addKeyListener(new KeyAdapter() {
                        @Override
@@ -369,6 +375,18 @@ public class ComponentSelectionDialog extends Dialog implements ISelectionChange
                                validate();
                        }
                });
+               
+               thicknessText.addKeyListener(new KeyAdapter() {
+                       @Override
+                       public void keyReleased(KeyEvent e) {
+                               try {
+                                       thickness = Double.parseDouble(thicknessText.getText()) / lengthFactor;
+                               } catch (NumberFormatException err) {
+                                       thickness = null;
+                               }
+                               validate();
+                       }
+               });
 
                turnRadiusText.addKeyListener(new KeyAdapter() {
                        @Override
@@ -387,6 +405,7 @@ public class ComponentSelectionDialog extends Dialog implements ISelectionChange
                horizFillData.applyTo(angleText);
                horizFillData.applyTo(rotationAngleText);
                horizFillData.applyTo(diameterText);
+               horizFillData.applyTo(thicknessText);
                horizFillData.applyTo(turnRadiusText);
 
                if (!allowed.contains(PositionType.NEXT) && !allowed.contains(PositionType.PREVIOUS)) {
@@ -542,7 +561,8 @@ public class ComponentSelectionDialog extends Dialog implements ISelectionChange
                        if (selected.isSizeChange()) {
                                turnRadiusText.setEnabled(true);
                                diameterText.setEnabled(true);
-                               if (diameter == null || turnRadius == null)
+                               thicknessText.setEnabled(true);
+                               if (diameter == null || turnRadius == null || thickness == null)
                                        ok = false;
                        } else {
                                turnRadiusText.setEnabled(false);
@@ -631,4 +651,8 @@ public class ComponentSelectionDialog extends Dialog implements ISelectionChange
                return lenghtAdjustable;
        }
 
+       public Double getThickness() {
+               return thickness;
+       }
+
 }
index 86f649aa136e49b6d0f7ac00cf956fb7de9e4392..0284d1c7b5e13a1a32d56cab5c9b54f544ebf5ab 100644 (file)
@@ -8,7 +8,6 @@ import java.util.Comparator;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Objects;
 
 import org.simantics.g3d.math.MathTools;
 import org.simantics.g3d.property.annotations.GetPropertyValue;
@@ -33,6 +32,7 @@ import vtk.vtkRenderer;
 public class PipeRun extends P3DParentNode<IP3DNode> {
        
        private double pipeDiameter = 0.1;
+       private double pipeThickness = 0.0;
        private double[] turnRadius = new double[] {0.2};
        
        @Override
@@ -97,13 +97,29 @@ public class PipeRun extends P3DParentNode<IP3DNode> {
        @RelatedSetValue(Plant3D.URIs.HasPipeDiameter)
        @SetPropertyValue(Plant3D.URIs.HasPipeDiameter)
        public void setPipeDiameter(double pipeDiameter) {
-               if (Objects.equals(this.pipeDiameter, pipeDiameter))
+               if (this.pipeDiameter == pipeDiameter)
                        return;
                
                this.pipeDiameter = pipeDiameter;
                firePropertyChanged(Plant3D.URIs.HasPipeDiameter);
        }
        
+       @RelatedGetValue(Plant3D.URIs.HasPipeThickness)
+       @GetPropertyValue(value=Plant3D.URIs.HasPipeThickness, name = "Wall Thickness")
+       public double getPipeThickness() {
+               return pipeThickness;
+       }
+       
+       @RelatedSetValue(Plant3D.URIs.HasPipeThickness)
+       @SetPropertyValue(Plant3D.URIs.HasPipeThickness)
+       public void setPipeThickness(double pipeThickness) {
+               if (this.pipeThickness == pipeThickness)
+                       return;
+               
+               this.pipeThickness = pipeThickness;
+               firePropertyChanged(Plant3D.URIs.HasPipeThickness);
+       }
+       
        @RelatedElementsAdd(Plant3D.URIs.children)
        public void addChild(PipelineComponent node) {
                addNode(Plant3D.URIs.children,node);
index 8f1b9a88bb6b7bf72ea20f866453deea1b76cc2b..08fa2622311cc3ed915f6c5f004e51f85f3e8a52 100644 (file)
@@ -1448,6 +1448,7 @@ public class PipeControlPoint extends G3DNode implements IP3DNode {
             
             PipeRun previousRun = previous.getPipeRun();
             nextPipeRun.setPipeDiameter(previousRun.getPipeDiameter());
+            nextPipeRun.setPipeThickness(previousRun.getPipeThickness());
             nextPipeRun.setTurnRadiusArray(previousRun.getTurnRadiusArray());
             
             PipelineComponent n = next.getPipelineComponent();
index 2cef7060c14ede3b748ddb821146d26d8bc6ecdb..6bbabe1e251c9feaf3f10e1767a56ce827ec91f0 100644 (file)
@@ -281,6 +281,7 @@ public class ComponentUtils {
                
                // Reducer requires pipe specs
                public Double diameter;
+               public Double thickness;
                public Double turnRadius;
                
                // Variable length 
@@ -331,6 +332,14 @@ public class ComponentUtils {
                public void setDiameter(Double diameter) {
                        this.diameter = diameter;
                }
+               
+               public double getThickness() {
+                       return thickness;
+               }
+               
+               public void setThickness(double thickness) {
+                       this.thickness = thickness;
+               }
 
                public Double getTurnRadius() {
                        return turnRadius;
@@ -537,6 +546,7 @@ public class ComponentUtils {
                        String n = root.getUniqueName("PipeRun");
                        other.setName(n);
                        other.setPipeDiameter(inst.diameter);
+                       other.setPipeThickness(inst.thickness);
                        other.setTurnRadius(inst.turnRadius);
                        root.addChild(other);