X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=org.simantics.plant3d%2Fsrc%2Forg%2Fsimantics%2Fplant3d%2Fscenegraph%2FEquipment.java;h=27a76067be46d08f8db412f5dc61f2ef2229f170;hb=1c986f49dd51037e0a189df77a76abce890ae8ae;hp=3bac765c4a88754a7add24df614db98d70965280;hpb=bcf3a9c994d2bda45fa3d2738fda8a14bb34cdcd;p=simantics%2F3d.git diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/Equipment.java b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/Equipment.java index 3bac765c..27a76067 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/Equipment.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/Equipment.java @@ -2,6 +2,7 @@ package org.simantics.plant3d.scenegraph; import java.util.Collection; import java.util.HashSet; +import java.util.List; import java.util.Map; import java.util.Set; @@ -11,6 +12,7 @@ import javax.vecmath.Vector3d; import org.simantics.g3d.math.MathTools; import org.simantics.g3d.property.annotations.CompoundGetPropertyValue; import org.simantics.g3d.property.annotations.CompoundSetPropertyValue; +import org.simantics.g3d.scenegraph.GeometryProvider; import org.simantics.objmap.graph.annotations.CompoundRelatedGetValue; import org.simantics.objmap.graph.annotations.CompoundRelatedSetValue; import org.simantics.objmap.graph.annotations.DynamicGraphType; @@ -19,6 +21,7 @@ import org.simantics.objmap.graph.annotations.RelatedElementsAdd; import org.simantics.objmap.graph.annotations.RelatedElementsGet; import org.simantics.objmap.graph.annotations.RelatedElementsRem; import org.simantics.objmap.graph.annotations.SetType; +import org.simantics.plant3d.geometry.FixedNozzleProvider; import org.simantics.plant3d.ontology.Plant3D; import org.simantics.plant3d.scenegraph.controlpoint.PipingRules; @@ -27,6 +30,7 @@ import org.simantics.plant3d.scenegraph.controlpoint.PipingRules; public class Equipment extends P3DParentGeometryNode { private String type; + private FixedNozzleProvider fnp; @GetType(Plant3D.URIs.Equipment) public String getType() { @@ -50,6 +54,8 @@ public class Equipment extends P3DParentGeometryNode { newId++; addNode(Plant3D.URIs.HasNozzle,node); node.setNozzleId(newId); + if (fnp != null) + syncNozzles(); } @RelatedElementsGet(Plant3D.URIs.HasNozzle) @@ -76,6 +82,42 @@ public class Equipment extends P3DParentGeometryNode { super.setParameterMap(parameters); } + @Override + public void setGeometry(GeometryProvider provider) { + super.setGeometry(provider); + if (provider instanceof FixedNozzleProvider) { + fnp = (FixedNozzleProvider)provider; + syncNozzles(); + } + } + + public int numberOfFixedNozzles() { + if (fnp == null) + return 0; + return fnp.numberOfNozzles(); + } + + /** + * Synchronizes fixed nozzles. + * + * Note: this method does not create nozzles, just sets their positions and names. + */ + public void syncNozzles() { + if (fnp == null) + return; + + int count = fnp.numberOfNozzles(); + List currentNozzles = getNodes(); + for (int i = 0; i < count; i++) { + if (i < currentNozzles.size()) { + Nozzle nozzle = currentNozzles.get(i); + nozzle.setName(fnp.getNozzleName(i)); + fnp.updateNozzlePosition(i, nozzle); + nozzle.setFixed(true); + } + } + } + @Override protected double[] getColor() { return new double[]{1,0,0};