X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.plant3d%2Fsrc%2Forg%2Fsimantics%2Fplant3d%2Fscenegraph%2FInlineComponent.java;h=e098de63a637303a787aca53f85db0259380f845;hb=refs%2Fchanges%2F22%2F3022%2F1;hp=a1558c8642f4f527abc13cda702c8484db441aa1;hpb=8204a7a5250e06c7afc114d4bfedf5af1f4b0ba9;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 a1558c86..e098de63 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/InlineComponent.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/InlineComponent.java @@ -3,13 +3,19 @@ package org.simantics.plant3d.scenegraph; import java.util.HashMap; import java.util.Map; +import org.simantics.g3d.math.MathTools; +import org.simantics.g3d.property.annotations.GetPropertyValue; +import org.simantics.g3d.property.annotations.SetPropertyValue; import org.simantics.g3d.scenegraph.base.ParentNode; import org.simantics.objmap.graph.annotations.DynamicGraphType; import org.simantics.objmap.graph.annotations.GetType; +import org.simantics.objmap.graph.annotations.RelatedGetValue; +import org.simantics.objmap.graph.annotations.RelatedSetValue; import org.simantics.objmap.graph.annotations.SetType; import org.simantics.plant3d.ontology.Plant3D; import org.simantics.plant3d.scenegraph.controlpoint.ControlPointFactory; import org.simantics.plant3d.scenegraph.controlpoint.PipeControlPoint; +import org.simantics.plant3d.scenegraph.controlpoint.PipingRules; @DynamicGraphType(Plant3D.URIs.InlineComponent) public class InlineComponent extends PipelineComponent { @@ -45,6 +51,37 @@ public class InlineComponent extends PipelineComponent { return !controlPoint.isFixed(); } + @RelatedGetValue(Plant3D.URIs.HasRotationAngle) + @GetPropertyValue(name="Rotation Angle", value=Plant3D.URIs.HasRotationAngle, tabId = "Default") + public Double getRotationAngle() { + if (!controlPoint.isRotate()) + return null; + Double d = controlPoint.getRotationAngle(); + if (d == null) + return 0.0; + return MathTools.radToDeg(d); + } + @RelatedSetValue(Plant3D.URIs.HasRotationAngle) + @SetPropertyValue(value=Plant3D.URIs.HasRotationAngle) + public void setRotationAngle(Double angle) { + if (!controlPoint.isRotate()) + return; + + if (angle == null || Double.isInfinite(angle) || Double.isNaN(angle)) { + return; + } + angle = MathTools.degToRad(angle); + 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(); + } + } + @Override public void updateParameters() { super.updateParameters();