]> gerrit.simantics Code Review - simantics/3d.git/commitdiff
Tag user modifiable length 28/3528/1
authorMarko Luukkainen <marko.luukkainen@semantum.fi>
Fri, 15 Nov 2019 11:49:33 +0000 (13:49 +0200)
committerMarko Luukkainen <marko.luukkainen@semantum.fi>
Fri, 15 Nov 2019 11:54:19 +0000 (11:54 +0000)
With modifiable tag, we can ask for length parameter when we insert new
components

gitlab #26

Change-Id: Ic98a1b491bb8223d28bdca570af5fc792df3fe6c
(cherry picked from commit daa07327bd3222487742965d433ea2f041e5ae73)

org.simantics.plant3d.ontology/graph/plant3d.pgraph
org.simantics.plant3d/src/org/simantics/plant3d/dialog/ComponentSelectionDialog.java
org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/InlineComponent.java
org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/PipelineComponent.java
org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/ControlPointFactory.java
org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipeControlPoint.java
org.simantics.plant3d/src/org/simantics/plant3d/utils/ComponentUtils.java
org.simantics.plant3d/src/org/simantics/plant3d/utils/Item.java
org.simantics.plant3d/src/org/simantics/plant3d/utils/P3DUtil.java

index 5621443ec380e1dc77feb9f8f956dd524e17d15b..d6029cc68af39fdf57d6f3b1649534bbdf00b119 100644 (file)
@@ -56,15 +56,14 @@ P3D.TurnComponent <T P3D.PipelineComponent
     
 P3D.FixedLengthInlineComponent <R P3D.PipelineComponentTag
     L0.HasDescription "Inline component that has fixed length" : L0.String
-    //[HasRotationAngle card "1"]
+P3D.AdjustableLengthInlineComponent <R P3D.PipelineComponentTag
+    L0.HasDescription "Inline component whose length can be changed manually" : L0.String
 P3D.VariableLengthInlineComponent <R P3D.PipelineComponentTag
-    L0.HasDescription "Inline component whose length can be changed" : L0.String
+    L0.HasDescription "Inline component whose length can be changed automatically" : L0.String
 P3D.FixedAngleTurnComponent <R P3D.PipelineComponentTag
     L0.HasDescription "Turn Component that has specific turning angle that cannot be changed" : L0.String
-    //[HasRotationAngle card "1"]
 P3D.VariableAngleTurnComponent <R P3D.PipelineComponentTag
     L0.HasDescription "Turn Component whose turning angle can be modified Contains always one control point (there are no contradictory cases / how to calculate?)" : L0.String
-    //[HasTurnRadius card "1"]
 P3D.SizeChangeComponent <R P3D.PipelineComponentTag
     L0.HasDescription "Component that changes pipe run along main pipeline. (Spec change)" : L0.String
 P3D.OffsetComponent<R P3D.PipelineComponentTag
index 93a305bb9d74ea67fddb1ed35c088c09044d12e4..75b124119830199167eb827c1618b666a44b8161 100644 (file)
@@ -334,7 +334,7 @@ public class ComponentSelectionDialog extends Dialog implements ISelectionChange
                } else if (selected.isCode()) {// TODO : instead of disabling the button, we should filter the content.
                        ok = false;
                } else {
-                       lenghtAdjustable = ((selected.getType() == Type.INLINE) && selected.isVariable());
+                       lenghtAdjustable = ((selected.getType() == Type.INLINE) && (selected.isVariable() || selected.isModifiable()));
                        if (insertAdjustable) {
                                switch (selected.getType()) {
                                case END:
@@ -393,7 +393,7 @@ public class ComponentSelectionDialog extends Dialog implements ISelectionChange
                                middleButton.setEnabled(false);
                                endButton.setEnabled(true);
                        }
-                       if (selected.isVariable()) {
+                       if (selected.isVariable() || selected.isModifiable()) {
                                if (selected.getType() == Type.INLINE) {
                                        filterAllowed.add(PositionType.NEXT);
                                        filterAllowed.add(PositionType.PREVIOUS);
index d3e8742c9db93019bc3fe8d087d146a8fa5c2bb8..aa51073a5a0f9665748d887b05a928118b061bce 100644 (file)
@@ -54,6 +54,10 @@ public class InlineComponent extends PipelineComponent {
                return !controlPoint.isFixed();
        }
        
+       public boolean isModifialble() {
+        return controlPoint.isMod();
+    }
+       
        public boolean isSizeChange() {
                return controlPoint.isSizeChange();
        }
index b052bae435d2a25d8061e29881717b007656f237..61e48585336fb7749ba30c021fd42f549f40a027 100644 (file)
@@ -129,6 +129,12 @@ public abstract class PipelineComponent extends GeometryNode {
         }
         setParameterMap(parameters);
     }
+    
+    public void setParameter(String name, Object value) {
+        Map<String, Object> parameters = new HashMap<>(getParameterMap());
+        parameters.put(name, value);
+        setParameterMap(parameters);
+    }
        
        public abstract void setType(String typeURI) throws Exception;
        
index 6b92e4479aa1a8fe34cb7681bcd94255a83055d7..ff49b93a74404adf1b5164e7bcbfb2a54ba00518 100644 (file)
@@ -45,6 +45,7 @@ public class ControlPointFactory {
                PipeControlPoint pcp = new PipeControlPoint(component);
                pcp.setType(inst.type);
                pcp.setFixed(inst.fixed);
+               pcp.setMod(inst.mod);
                pcp.setRotate(inst.isRotate);
                pcp.setReverse(inst.isReverse);
                switch(inst.type) {
@@ -58,6 +59,7 @@ public class ControlPointFactory {
                                sub.parent = pcp;
                                sub.setType(inst.type);
                                sub.setFixed(inst.fixed);
+                               sub.setMod(inst.mod);
                                sub.setSub(true);
                                sub.setDeletable(false);
                                if (inst.isOffset)
@@ -78,6 +80,7 @@ public class ControlPointFactory {
        private static class Instruction {
                PointType type;
                boolean fixed;
+               boolean mod;
                boolean isOffset;
                boolean isSizeChange;
                boolean isRotate;
@@ -98,6 +101,7 @@ public class ControlPointFactory {
                                i.isRotate = false;
                                i.isReverse = false;
                                i.type = PointType.INLINE;
+                               i.mod = false;
                                if (graph.isInheritedFrom(res, p3d.Nozzle)) {
                                        i.fixed = true;
                                        i.isOffset = false;
@@ -110,6 +114,11 @@ public class ControlPointFactory {
                                                i.fixed = false;
                                        } else if (graph.hasStatement(res,p3d.FixedLengthInlineComponent)) {
                                                i.fixed = true;
+                                       } else if (graph.hasStatement(res,p3d.AdjustableLengthInlineComponent)) {
+                                           i.fixed = true;
+                                           i.mod = true;
+                                       } else {
+                                           throw new DatabaseException("Inline component type " + res + " does not have length configuration.");
                                        }
                                        
                                        if (graph.hasStatement(res,p3d.SizeChangeComponent)) {
@@ -133,6 +142,8 @@ public class ControlPointFactory {
                                                i.fixed = false;
                                        } else if (graph.hasStatement(res,p3d.FixedAngleTurnComponent)) {
                                                i.fixed = true; 
+                                       } else {
+                                           throw new DatabaseException("Turn component type " + res + " does not have angle configuration.");
                                        }
                                } else if (graph.isInheritedFrom(res, p3d.EndComponent)) {
                                        i.fixed = false;
index 20386b5408c11ca4477e4fb6a67a4bb4e4209ff5..232b8ab45dfdf46b2321f95398bc05dbd3fd3e47 100644 (file)
@@ -36,6 +36,7 @@ public class PipeControlPoint extends G3DNode implements IP3DNode {
 
        private PointType type;
        private boolean isFixed = true;        // In-line: fixed-length Turn: fixed-angle
+       private boolean isMod = false;         // Can user modify fixed value manually 
        private boolean isRotate = false;      // rotates around path leg axis.
        private boolean isReverse = false;     // definition direction can be swapped
        private boolean isDeletable = true;    // can be removed by rules
@@ -88,6 +89,15 @@ public class PipeControlPoint extends G3DNode implements IP3DNode {
        public void setFixed(boolean fixed) {
                this.isFixed = fixed;
        }
+       
+       @GetPropertyValue(name="Mod",tabId="Debug",value="mod")
+       public boolean isMod() {
+        return isMod;
+    }
+    
+    public void setMod(boolean isMod) {
+        this.isMod = isMod;
+    }
 
        @GetPropertyValue(name="Rotate",tabId="Debug",value="rotate")
        public boolean isRotate() {
index 14dce68dc351c71c913141c27f3aeb2239280eb7..50ede807e6dac4039e2aee555174a088df24c80a 100644 (file)
@@ -329,7 +329,7 @@ public class ComponentUtils {
                PositionType insertPosition = inst.insertPosition;
                boolean lengthAdjustable = false;
                if (newComponent instanceof InlineComponent) {
-                       lengthAdjustable = ((InlineComponent)newComponent).isVariableLength(); 
+                       lengthAdjustable = ((InlineComponent)newComponent).isVariableLength() || ((InlineComponent)newComponent).isModifialble()
                }
                boolean insertAdjustable = false;
                if (component instanceof InlineComponent) {
@@ -407,11 +407,13 @@ public class ComponentUtils {
                        newComponent.setName(name);
 
                        pipeRun.addChild(newComponent);
-                       // TODO: these options are not stored into DB. Should they?!
-                       if (newComponent instanceof InlineComponent && ((InlineComponent)newComponent).isVariableLength()) {
+
+                       if (newComponent instanceof InlineComponent && ((InlineComponent)newComponent).isVariableLength() ||((InlineComponent)newComponent).isModifialble()) {
                                newPcp.setLength(inst.length);
+                               newComponent.setParameter("length", inst.length);
                        } else if (newComponent instanceof TurnComponent && ((TurnComponent)newComponent).isVariableAngle()) {
                                newPcp.setTurnAngle(inst.angle);
+                               newComponent.setParameter("turnAngle", inst.angle);
                        }
                        
                        newComponent.updateParameters();
index e1faef342b377138a3612a0a8faade7af17a1ecd..799d072702c830e5077d6c2aab414eff838b66b9 100644 (file)
@@ -10,6 +10,7 @@ public class Item {
        private Type type;
        private boolean code = false;
        private boolean variable = false;
+       private boolean modifiable = false;
        private boolean sizeChange = false;
 
        
@@ -52,6 +53,14 @@ public class Item {
                this.variable = variable;
        }
        
+       public boolean isModifiable() {
+        return modifiable;
+    }
+    
+    public void setModifiable(boolean modifiable) {
+        this.modifiable = modifiable;
+    }
+       
        public boolean isSizeChange() {
                return sizeChange;
        }
index cb46546ed1371a133eb866fb527036cf035dc001..55cfead45ea55259972c62eaf65592e62b98006a 100644 (file)
@@ -207,6 +207,8 @@ public class P3DUtil {
                if (graph.hasStatement(r, p3d.VariableAngleTurnComponent) ||
                        graph.hasStatement(r, p3d.VariableLengthInlineComponent))
                        item.setVariable(true);
+               if (graph.hasStatement(r, p3d.AdjustableLengthInlineComponent))
+                   item.setModifiable(true);
                if (graph.hasStatement(r, p3d.SizeChangeComponent))
                        item.setSizeChange(true);
                return item;