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(INode node) {
32 //public void addChild(IP3DVisualNode node) {
33 addNode(Plant3D.URIs.childen,node);
36 @RelatedElementsGet(Plant3D.URIs.childen)
37 public Collection<INode> getChild() {
38 return getNodes(Plant3D.URIs.childen);
41 @RelatedElementsRem(Plant3D.URIs.childen)
42 public void remChild(INode node) {
43 //public void remChild(IP3DNode node) {
44 removeNode(Plant3D.URIs.childen, node);
47 private P3DNodeMap nodeMap;
49 public void setNodeMap(P3DNodeMap nodeMap) {
50 this.nodeMap = nodeMap;
54 public NodeMap<vtkProp, INode> getNodeMap() {
59 public ParentNode<?> getParent() {
64 public ParentNode<?> getRootNode() {
68 public javax.vecmath.Quat4d getOrientation() {
69 return MathTools.getIdentityQuat();
73 public Vector3d getPosition() {
74 return new Vector3d();
78 public Quat4d getWorldOrientation() {
79 return MathTools.getIdentityQuat();
83 public Vector3d getWorldPosition() {
84 return new Vector3d();
88 public Quat4d getWorldOrientation(Quat4d localOrientation) {
89 return localOrientation;
93 public Vector3d getWorldPosition(Vector3d localPosition) {
98 public Quat4d getLocalOrientation(Quat4d worldOrientation) {
99 return worldOrientation;
103 public Vector3d getLocalPosition(Vector3d worldPosition) {
104 return worldPosition;
108 public void setPosition(Vector3d position) {
109 throw new NodeException("Cannot set root node position");
113 public void setOrientation(Quat4d orientation) {
114 throw new NodeException("Cannot set root node orientation");
118 public void setWorldOrientation(Quat4d orientation) {
119 throw new NodeException("Cannot set root node orientation");
123 public void setWorldPosition(Vector3d position) {
124 throw new NodeException("Cannot set root node orientation");
127 public String getUniqueName(String prefix) {
128 Set<String> names = new HashSet<String>();
129 for (INode node : getChild()) {
130 if (!(node instanceof IP3DVisualNode))
132 IP3DVisualNode n = (IP3DVisualNode)node;
133 names.add(n.getName());
137 String genName = prefix + "_" + i;
138 if (!names.contains(genName))
145 @SuppressWarnings("rawtypes")
147 public Object getAdapter(Class adapter) {
148 if (NodeMap.class == adapter)
153 public Nozzle createNozzle() {
157 public Equipment createEquipment() {
158 return new Equipment();
161 public InlineComponent createInline() {
162 return new InlineComponent();
165 public EndComponent createEnd() {
166 return new EndComponent();
169 public TurnComponent createTurn() {
170 return new TurnComponent();