X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.plant3d%2Fsrc%2Forg%2Fsimantics%2Fplant3d%2Fscenegraph%2FInlineComponent.java;h=eb5c1a288492326fea3daef4a4a4f8a86aea953e;hb=c07ac416dfbe99201084e71c53dc95c9c41d906c;hp=6590c73d2cc3f34de38a24c1fc1e835fc086d34f;hpb=3b5c59eca31e9db10c1a1dc6d244d6fd4f3578a2;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 6590c73d..eb5c1a28 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; @@ -51,6 +54,10 @@ public class InlineComponent extends PipelineComponent { return !controlPoint.isFixed(); } + public boolean isSizeChange() { + return controlPoint.isSizeChange(); + } + @RelatedGetValue(Plant3D.URIs.HasRotationAngle) @GetPropertyValue(name="Rotation Angle", value=Plant3D.URIs.HasRotationAngle, tabId = "Default") public Double getRotationAngle() { @@ -61,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) { @@ -87,14 +95,12 @@ public class InlineComponent extends PipelineComponent { public Boolean isReversed() { if (!controlPoint.isReverse()) return null; - Boolean d = controlPoint.getReversed(); - if (d == null) - return false; + Boolean d = controlPoint._getReversed(); return d; } @RelatedSetValue(Plant3D.URIs.IsReversed) @SetPropertyValue(value=Plant3D.URIs.IsReversed) - public void setReverse(Boolean reverse) { + public void setReversed(Boolean reverse) { if (!controlPoint.isReverse()) return; @@ -176,5 +182,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); + } }