1 package org.simantics.plant3d.scenegraph;
3 import java.util.Collection;
4 import java.util.HashSet;
7 import javax.vecmath.Quat4d;
8 import javax.vecmath.Vector3d;
10 import org.simantics.g3d.math.MathTools;
11 import org.simantics.g3d.scenegraph.IG3DNode;
12 import org.simantics.g3d.scenegraph.NodeMap;
13 import org.simantics.g3d.scenegraph.NodeMapProvider;
14 import org.simantics.g3d.scenegraph.base.INode;
15 import org.simantics.g3d.scenegraph.base.NodeException;
16 import org.simantics.g3d.scenegraph.base.ParentNode;
17 import org.simantics.objmap.graph.annotations.GraphType;
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.plant3d.editor.P3DNodeMap;
22 import org.simantics.plant3d.ontology.Plant3D;
26 @GraphType(Plant3D.URIs.Plant)
27 public class P3DRootNode extends ParentNode<INode> implements IG3DNode, NodeMapProvider<vtkProp , INode> {
30 @RelatedElementsAdd(Plant3D.URIs.childen)
31 public void addChild(IP3DVisualNode node) {
32 addNode(Plant3D.URIs.childen,node);
35 @RelatedElementsGet(Plant3D.URIs.childen)
36 public Collection<INode> getChild() {
37 return getNodes(Plant3D.URIs.childen);
40 @RelatedElementsRem(Plant3D.URIs.childen)
41 public void remChild(IP3DNode node) {
42 removeNode(Plant3D.URIs.childen, node);
45 private P3DNodeMap nodeMap;
47 public void setNodeMap(P3DNodeMap nodeMap) {
48 this.nodeMap = nodeMap;
52 public NodeMap<vtkProp, INode> getNodeMap() {
57 public ParentNode<?> getParent() {
62 public ParentNode<?> getRootNode() {
66 public javax.vecmath.Quat4d getOrientation() {
67 return MathTools.getIdentityQuat();
71 public Vector3d getPosition() {
72 return new Vector3d();
76 public Quat4d getWorldOrientation() {
77 return MathTools.getIdentityQuat();
81 public Vector3d getWorldPosition() {
82 return new Vector3d();
86 public Quat4d getWorldOrientation(Quat4d localOrientation) {
87 return localOrientation;
91 public Vector3d getWorldPosition(Vector3d localPosition) {
96 public Quat4d getLocalOrientation(Quat4d worldOrientation) {
97 return worldOrientation;
101 public Vector3d getLocalPosition(Vector3d worldPosition) {
102 return worldPosition;
106 public void setPosition(Vector3d position) {
107 throw new NodeException("Cannot set root node position");
111 public void setOrientation(Quat4d orientation) {
112 throw new NodeException("Cannot set root node orientation");
116 public void setWorldOrientation(Quat4d orientation) {
117 throw new NodeException("Cannot set root node orientation");
121 public void setWorldPosition(Vector3d position) {
122 throw new NodeException("Cannot set root node orientation");
125 public String getUniqueName(String prefix) {
126 Set<String> names = new HashSet<String>();
127 for (INode node : getChild()) {
128 if (!(node instanceof IP3DVisualNode))
130 IP3DVisualNode n = (IP3DVisualNode)node;
131 names.add(n.getName());
135 String genName = prefix + "_" + i;
136 if (!names.contains(genName))
143 @SuppressWarnings("rawtypes")
145 public Object getAdapter(Class adapter) {
146 if (NodeMap.class == adapter)
151 public Nozzle createNozzle() {
155 public Equipment createEquipment() {
156 return new Equipment();
159 public InlineComponent createInline() {
160 return new InlineComponent();
163 public EndComponent createEnd() {
164 return new EndComponent();
167 public TurnComponent createTurn() {
168 return new TurnComponent();