1 package org.simantics.plant3d.scenegraph;
3 import java.util.Collection;
4 import java.util.HashSet;
8 import javax.vecmath.Quat4d;
9 import javax.vecmath.Vector3d;
11 import org.simantics.g3d.math.MathTools;
12 import org.simantics.g3d.property.annotations.CompoundGetPropertyValue;
13 import org.simantics.g3d.property.annotations.CompoundSetPropertyValue;
14 import org.simantics.objmap.graph.annotations.CompoundRelatedGetValue;
15 import org.simantics.objmap.graph.annotations.CompoundRelatedSetValue;
16 import org.simantics.objmap.graph.annotations.DynamicGraphType;
17 import org.simantics.objmap.graph.annotations.GetType;
18 import org.simantics.objmap.graph.annotations.RelatedElementsAdd;
19 import org.simantics.objmap.graph.annotations.RelatedElementsGet;
20 import org.simantics.objmap.graph.annotations.RelatedElementsRem;
21 import org.simantics.objmap.graph.annotations.SetType;
22 import org.simantics.plant3d.ontology.Plant3D;
23 import org.simantics.plant3d.scenegraph.controlpoint.PipingRules;
26 @DynamicGraphType(Plant3D.URIs.Equipment)
27 public class Equipment extends P3DParentGeometryNode<Nozzle> {
31 @GetType(Plant3D.URIs.Equipment)
32 public String getType() {
36 @SetType(Plant3D.URIs.Equipment)
37 public void setType(String type) {
42 @RelatedElementsAdd(Plant3D.URIs.HasNozzle)
43 public void addChild(Nozzle node) {
44 Set<Integer> ids = new HashSet<Integer>();
45 for (Nozzle n : getChild()) {
46 ids.add(n.getNozzleId());
49 while (ids.contains(newId))
51 addNode(Plant3D.URIs.HasNozzle,node);
52 node.setNozzleId(newId);
55 @RelatedElementsGet(Plant3D.URIs.HasNozzle)
56 public Collection<Nozzle> getChild() {
57 return getNodes(Plant3D.URIs.HasNozzle);
60 @RelatedElementsRem(Plant3D.URIs.HasNozzle)
61 public void remChild(Nozzle node) {
62 removeNode(Plant3D.URIs.HasNozzle, node);
66 @CompoundRelatedGetValue(objRelation=Plant3D.URIs.hasParameter,objType=Plant3D.URIs.Parameter,valRelation=Plant3D.URIs.hasParameterValue)
67 @CompoundGetPropertyValue(name="Parameters",tabId="Parameters",value="parameters")
68 public Map<String, Object> getParameterMap() {
69 return super.getParameterMap();
73 @CompoundRelatedSetValue(Plant3D.URIs.hasParameter)
74 @CompoundSetPropertyValue(value="parameters")
75 public void setParameterMap(Map<String, Object> parameters) {
76 super.setParameterMap(parameters);
80 protected double[] getColor() {
81 return new double[]{1,0,0};
85 protected double[] getSelectedColor() {
86 return new double[]{0.5,0,0.5};
90 public void setPosition(Vector3d position) {
91 if (MathTools.equals(position, getPosition()))
93 super.setPosition(position);
94 for (Nozzle n : getChild()) {
95 n.getControlPoint()._setWorldPosition(n.getWorldPosition());
96 n.getControlPoint()._setWorldOrientation(n.getWorldOrientation());
98 for (Nozzle n : getChild()) {
100 PipingRules.requestUpdate(n.getControlPoint());
101 } catch (Exception e) {
108 public void setOrientation(Quat4d orientation) {
109 if (MathTools.equals(orientation, getOrientation()))
111 super.setOrientation(orientation);
112 for (Nozzle n : getChild()) {
113 n.getControlPoint()._setWorldPosition(n.getWorldPosition());
114 n.getControlPoint()._setWorldOrientation(n.getWorldOrientation());
116 for (Nozzle n : getChild()) {
118 PipingRules.requestUpdate(n.getControlPoint());
119 } catch (Exception e) {