X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.plant3d%2Fsrc%2Forg%2Fsimantics%2Fplant3d%2Fscenegraph%2FInlineComponent.java;h=3ec6b3547c317c5022a5bac7804e4288eef7e096;hb=0a0e6285c47fea669cf580c57682cc8f473db411;hp=fe30c29c3e2a7d82aca29bead0289ecac8ec9597;hpb=b63b50f907c318cd999ff8cdc0ca3f1bf93dc6fe;p=simantics%2F3d.git 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 fe30c29c..3ec6b354 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/InlineComponent.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/InlineComponent.java @@ -3,6 +3,9 @@ package org.simantics.plant3d.scenegraph; import java.util.HashMap; import java.util.Map; +import javax.vecmath.Point3d; +import javax.vecmath.Vector3d; + import org.simantics.g3d.math.MathTools; import org.simantics.g3d.property.annotations.GetPropertyValue; import org.simantics.g3d.property.annotations.SetPropertyValue; @@ -52,7 +55,7 @@ public class InlineComponent extends PipelineComponent { } public boolean isSizeChange() { - return controlPoint.isSizeChange(); + return controlPoint.isSizeChange(); } @RelatedGetValue(Plant3D.URIs.HasRotationAngle) @@ -65,6 +68,7 @@ public class InlineComponent extends PipelineComponent { return 0.0; return MathTools.radToDeg(d); } + @RelatedSetValue(Plant3D.URIs.HasRotationAngle) @SetPropertyValue(value=Plant3D.URIs.HasRotationAngle) public void setRotationAngle(Double angle) { @@ -116,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")); } @@ -126,6 +130,7 @@ public class InlineComponent extends PipelineComponent { } else { componentCalculatedOffset = false; } + PipingRules.requestUpdate(getControlPoint()); } } @@ -157,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); @@ -178,5 +183,21 @@ public class InlineComponent extends PipelineComponent { return map; } - + @SetPropertyValue("flowlength") + public void setFlowLength(double l) { + // Not allowed, if not at the end of a run + if (getNext() != null) + throw new IllegalStateException("Cannot edit length of a connected component"); + + double length = getFlowLength(); + Point3d p1 = new Point3d(), p2 = new Point3d(); + controlPoint.getControlPointEnds(p1, p2); + Vector3d dir = new Vector3d(); + dir.sub(p2, p1); + dir.normalize(); + dir.scale((l - length)/2); + Vector3d pos = new Vector3d(getPosition()); + pos.add(dir); + setPosition(pos); + } }