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.db.Resource;
11 import org.simantics.g3d.math.MathTools;
12 import org.simantics.g3d.scenegraph.IG3DNode;
13 import org.simantics.g3d.scenegraph.NodeMap;
14 import org.simantics.g3d.scenegraph.NodeMapProvider;
15 import org.simantics.g3d.scenegraph.base.INode;
16 import org.simantics.g3d.scenegraph.base.NodeException;
17 import org.simantics.g3d.scenegraph.base.ParentNode;
18 import org.simantics.objmap.graph.annotations.GraphType;
19 import org.simantics.objmap.graph.annotations.RelatedElementsAdd;
20 import org.simantics.objmap.graph.annotations.RelatedElementsGet;
21 import org.simantics.objmap.graph.annotations.RelatedElementsRem;
22 import org.simantics.plant3d.editor.P3DNodeMap;
23 import org.simantics.plant3d.ontology.Plant3D;
27 @GraphType(Plant3D.URIs.Plant)
28 public class P3DRootNode extends ParentNode<INode> implements IG3DNode, NodeMapProvider<Resource, vtkProp , INode> {
31 @RelatedElementsAdd(Plant3D.URIs.children)
32 public void addChild(INode node) {
33 //public void addChild(IP3DVisualNode node) {
34 addNode(Plant3D.URIs.children,node);
37 @RelatedElementsGet(Plant3D.URIs.children)
38 public Collection<INode> getChild() {
39 return getNodes(Plant3D.URIs.children);
42 @RelatedElementsRem(Plant3D.URIs.children)
43 public void remChild(INode node) {
44 //public void remChild(IP3DNode node) {
45 removeNode(Plant3D.URIs.children, node);
48 private P3DNodeMap nodeMap;
50 public void setNodeMap(P3DNodeMap nodeMap) {
51 this.nodeMap = nodeMap;
55 public NodeMap<Resource,vtkProp, INode> getNodeMap() {
60 public ParentNode<?> getParent() {
65 public ParentNode<?> getRootNode() {
69 public javax.vecmath.Quat4d getOrientation() {
70 return MathTools.getIdentityQuat();
74 public Vector3d getPosition() {
75 return new Vector3d();
79 public Quat4d getWorldOrientation() {
80 return MathTools.getIdentityQuat();
84 public Vector3d getWorldPosition() {
85 return new Vector3d();
89 public Quat4d getWorldOrientation(Quat4d localOrientation) {
90 return localOrientation;
94 public Vector3d getWorldPosition(Vector3d localPosition) {
99 public Quat4d getLocalOrientation(Quat4d worldOrientation) {
100 return worldOrientation;
104 public Vector3d getLocalPosition(Vector3d worldPosition) {
105 return worldPosition;
109 public void setPosition(Vector3d position) {
110 throw new NodeException("Cannot set root node position");
114 public void setOrientation(Quat4d orientation) {
115 throw new NodeException("Cannot set root node orientation");
119 public void setWorldOrientation(Quat4d orientation) {
120 throw new NodeException("Cannot set root node orientation");
124 public void setWorldPosition(Vector3d position) {
125 throw new NodeException("Cannot set root node orientation");
128 public String getUniqueName(String prefix) {
129 Set<String> names = new HashSet<String>();
130 for (INode node : getChild()) {
131 if (!(node instanceof IP3DVisualNode))
133 IP3DVisualNode n = (IP3DVisualNode)node;
134 names.add(n.getName());
138 String genName = prefix + "_" + i;
139 if (!names.contains(genName))
146 @SuppressWarnings("rawtypes")
148 public Object getAdapter(Class adapter) {
149 if (NodeMap.class == adapter)
154 public Nozzle createNozzle() {
158 public Equipment createEquipment() {
159 return new Equipment();
162 public InlineComponent createInline() {
163 return new InlineComponent();
166 public EndComponent createEnd() {
167 return new EndComponent();
170 public TurnComponent createTurn() {
171 return new TurnComponent();