From: Marko Luukkainen Date: Fri, 25 Oct 2019 14:31:00 +0000 (+0300) Subject: Adjustable length inline components X-Git-Tag: v1.43.0~166^2 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=0a0e6285c47fea669cf580c57682cc8f473db411;p=simantics%2F3d.git Adjustable length inline components gitlab #29 Change-Id: I41122a7dcf2ad4d04441b6eb44abf5f4c9118a8a --- diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/GeometryComponent.java b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/GeometryComponent.java index 9b2b750f..0e53c1b6 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/GeometryComponent.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/GeometryComponent.java @@ -42,8 +42,8 @@ public class GeometryComponent { private GeometryProvider geometryProvider; public GeometryComponent() { - currentParameters = new HashMap(); - calculatedParameters = new HashMap(); + currentParameters = new HashMap<>(); + calculatedParameters = new HashMap<>(); } public void visualize(VtkView panel) { @@ -117,6 +117,13 @@ public class GeometryComponent { return calculatedParameters; } + public Map getTotalParameters() { + Map params = new HashMap<>(); + params.putAll(currentParameters); + params.putAll(calculatedParameters); + return params; + } + public void setParametersUpdated(boolean parametersUpdated) { this.parametersUpdated = parametersUpdated; } diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/GeometryNode.java b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/GeometryNode.java index cda89cb4..585c244c 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/GeometryNode.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/GeometryNode.java @@ -53,6 +53,11 @@ public abstract class GeometryNode extends P3DNode implements ParameterizedNode, return component.getCalculatedParameters(); } + + public Map getTotalParameters() { + return component.getTotalParameters(); + } + public void setParametersUpdated(boolean parametersUpdated) { component.setParametersUpdated(parametersUpdated); } diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/InlineComponent.java b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/InlineComponent.java index eb5c1a28..3ec6b354 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/InlineComponent.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/InlineComponent.java @@ -120,7 +120,7 @@ public class InlineComponent extends PipelineComponent { public void updateParameters() { super.updateParameters(); if (!isVariableLength()) { - Map calculated = getCalculatedParameters(); + Map 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 updateParameterMap() { Map map = new HashMap(); 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); diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/PipelineComponent.java b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/PipelineComponent.java index 90dba91d..35df6121 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/PipelineComponent.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/PipelineComponent.java @@ -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 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 map = new HashMap(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(); } diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/TurnComponent.java b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/TurnComponent.java index ff12143b..9a124349 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/TurnComponent.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/TurnComponent.java @@ -75,6 +75,7 @@ public class TurnComponent extends PipelineComponent { if (calculated.containsKey("length")) { controlPoint.setLength((Double)calculated.get("length")); } + PipingRules.requestUpdate(getControlPoint()); } }