]> gerrit.simantics Code Review - simantics/3d.git/commitdiff
Adjustable length inline components 12/3412/1
authorMarko Luukkainen <marko.luukkainen@semantum.fi>
Fri, 25 Oct 2019 14:31:00 +0000 (17:31 +0300)
committerMarko Luukkainen <marko.luukkainen@semantum.fi>
Fri, 25 Oct 2019 14:31:00 +0000 (17:31 +0300)
gitlab #29

Change-Id: I41122a7dcf2ad4d04441b6eb44abf5f4c9118a8a

org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/GeometryComponent.java
org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/GeometryNode.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/TurnComponent.java

index 9b2b750fde45a5a812f90eac25e2f47ea030cc07..0e53c1b6402860f002ef301b8b0ccadd706392c5 100644 (file)
@@ -42,8 +42,8 @@ public class GeometryComponent {
        private GeometryProvider geometryProvider;
        
        public GeometryComponent() {
-               currentParameters = new HashMap<String, Object>();
-               calculatedParameters = new HashMap<String, Object>();
+               currentParameters = new HashMap<>();
+               calculatedParameters = new HashMap<>();
        }
        
        public void visualize(VtkView panel) {
@@ -117,6 +117,13 @@ public class GeometryComponent {
                return calculatedParameters;
        }
        
+       public Map<String, Object> getTotalParameters() {
+        Map<String,Object> params = new HashMap<>();
+        params.putAll(currentParameters);
+        params.putAll(calculatedParameters);
+        return params;
+    }
+       
        public void setParametersUpdated(boolean parametersUpdated) {
                this.parametersUpdated = parametersUpdated;
        }
index cda89cb40afb4caf79fc6dbfb0393474bd5ee758..585c244c4ca98fb3d67ebde9b6675535d7fa8c43 100644 (file)
@@ -53,6 +53,11 @@ public abstract class GeometryNode extends P3DNode implements ParameterizedNode,
                return component.getCalculatedParameters();
        }
        
+       
+       public Map<String, Object> getTotalParameters() {
+        return component.getTotalParameters();
+    }
+       
        public void setParametersUpdated(boolean parametersUpdated) {
                component.setParametersUpdated(parametersUpdated);
        }
index eb5c1a288492326fea3daef4a4a4f8a86aea953e..3ec6b3547c317c5022a5bac7804e4288eef7e096 100644 (file)
@@ -120,7 +120,7 @@ public class InlineComponent extends PipelineComponent {
        public void updateParameters() {
                super.updateParameters();
                if (!isVariableLength()) {
-                       Map<String,Object> calculated = getCalculatedParameters();
+                       Map<String,Object> calculated = getTotalParameters();
                        if (calculated.containsKey("length")) {
                                controlPoint.setLength((Double)calculated.get("length"));
                        }
@@ -130,6 +130,7 @@ public class InlineComponent extends PipelineComponent {
                        } else {
                                componentCalculatedOffset = false;
                        }
+                       PipingRules.requestUpdate(getControlPoint());
                }
        }
        
@@ -161,7 +162,7 @@ public class InlineComponent extends PipelineComponent {
        public Map<String, Object> updateParameterMap() {
                Map<String,Object> map = new HashMap<String, Object>();
                if (controlPoint != null) {
-                       if (!Double.isNaN(controlPoint.getLength()))
+                       if (!Double.isNaN(controlPoint.getLength()) && controlPoint.isVariableLength())
                                map.put("length", controlPoint.getLength());
                        if (controlPoint.isDualInline()) {
                                PipeControlPoint sub = controlPoint.getSubPoint().get(0);
index 90dba91d0282b748ec0c0c8be196a6651af102ea..35df6121bb9575b30375619cad1b83f228ebbb49 100644 (file)
@@ -93,7 +93,6 @@ public abstract class PipelineComponent extends GeometryNode {
        
        @Override
     @CompoundRelatedGetValue(objRelation=Plant3D.URIs.hasParameter,objType=Plant3D.URIs.Parameter,valRelation=Plant3D.URIs.hasParameterValue)
-    @CompoundGetPropertyValue(name="Parameters",tabId="Parameters",value="parameters")
     public Map<String, Object> getParameterMap() {
         return super.getParameterMap();
     }
@@ -109,6 +108,8 @@ public abstract class PipelineComponent extends GeometryNode {
         // TODO : how to filter parameters that are calculated by geometry provider?
         Map<String,Object> map = new HashMap<String, Object>(getParameterMap());
         map.remove("radius");
+        map.remove("radius2");
+        map.remove("offset");
         return map;
     }
     
@@ -265,16 +266,19 @@ public abstract class PipelineComponent extends GeometryNode {
                if (next == comp) {
                        next = null;
                        syncnext = false;
+                       if (DEBUG) System.out.println(this + " remove next " + comp);
                        firePropertyChanged(Plant3D.URIs.HasNext);
                        syncNext();
                } else if (previous == comp) {
                        previous = null;
                        syncprev = false;
+                       if (DEBUG) System.out.println(this + " remove prev " + comp);
                        firePropertyChanged(Plant3D.URIs.HasPrevious);
                        syncPrevious();
                } else if (branch0 == comp) {
                        branch0 = null;
                        syncbr0 = false;
+                       if (DEBUG) System.out.println(this + " remove br0 " + comp);
                        firePropertyChanged(Plant3D.URIs.HasBranch0);
                        syncBranch0();
                }
index ff12143bcf01dd4497299aad442e42bdd1319ff7..9a124349e7f7b950af3cf9b1423285a188fb1332 100644 (file)
@@ -75,6 +75,7 @@ public class TurnComponent extends PipelineComponent {
                        if (calculated.containsKey("length")) {
                                controlPoint.setLength((Double)calculated.get("length"));
                        }
+                       PipingRules.requestUpdate(getControlPoint());
                }
        }