]> gerrit.simantics Code Review - simantics/3d.git/blobdiff - org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/InlineComponent.java
Processing DB changes could leave control points unsynchronized
[simantics/3d.git] / org.simantics.plant3d / src / org / simantics / plant3d / scenegraph / InlineComponent.java
index eb5c1a288492326fea3daef4a4a4f8a86aea953e..ca4ba8367259dd75eb864a253c57056d4491539a 100644 (file)
@@ -36,6 +36,9 @@ public class InlineComponent extends PipelineComponent {
        public void setType(String type) throws Exception{
                this.type = type;
                controlPoint = ControlPointFactory.create(this);
+               syncNext();
+        syncPrevious();
+        syncBranch0();
                
        }
        
@@ -54,6 +57,10 @@ public class InlineComponent extends PipelineComponent {
                return !controlPoint.isFixed();
        }
        
+       public boolean isModifialble() {
+        return controlPoint.isMod();
+    }
+       
        public boolean isSizeChange() {
                return controlPoint.isSizeChange();
        }
@@ -82,12 +89,8 @@ public class InlineComponent extends PipelineComponent {
                if (controlPoint.getRotationAngle() != null && Math.abs(controlPoint.getRotationAngle()-angle) < MathTools.NEAR_ZERO)
                        return;
                controlPoint.setRotationAngle(angle);
-               try {
-                       PipingRules.requestUpdate(getControlPoint());
-               } catch (Exception e) {
-                       // TODO Auto-generated catch block
-                       e.printStackTrace();
-               }       
+               PipingRules.requestUpdate(getControlPoint());
+
        }
        
        @RelatedGetValue(Plant3D.URIs.IsReversed)
@@ -108,12 +111,7 @@ public class InlineComponent extends PipelineComponent {
                        return;
                }
                controlPoint.setReversed(reverse);
-               try {
-                       PipingRules.requestUpdate(getControlPoint());
-               } catch (Exception e) {
-                       // TODO Auto-generated catch block
-                       e.printStackTrace();
-               }       
+               PipingRules.requestUpdate(getControlPoint());
        }
        
        @Override
@@ -121,15 +119,21 @@ public class InlineComponent extends PipelineComponent {
                super.updateParameters();
                if (!isVariableLength()) {
                        Map<String,Object> calculated = getCalculatedParameters();
-                       if (calculated.containsKey("length")) {
-                               controlPoint.setLength((Double)calculated.get("length"));
-                       }
+                       
                        if (calculated.containsKey("offset")) {
                                controlPoint.setOffset((Double)calculated.get("offset"));
                                componentCalculatedOffset = true;
                        } else {
                                componentCalculatedOffset = false;
                        }
+                       
+                       Map<String,Object> total = getTotalParameters();
+                       
+                       if (total.containsKey("length")) {
+                controlPoint.setLength((Double)total.get("length"));
+            }
+                       
+                       PipingRules.requestUpdate(getControlPoint());
                }
        }
        
@@ -161,10 +165,10 @@ 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);
+                               PipeControlPoint sub = controlPoint.getDualSub();
                                PipeRun pipeRun2 = sub.getPipeRun();
                                if (pipeRun2 != null) {
                                        map.put("radius2", pipeRun2.getPipeDiameter() * 0.5);