X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.plant3d%2Fsrc%2Forg%2Fsimantics%2Fplant3d%2Fscenegraph%2FP3DRootNode.java;h=7a5ce551a7c317c16df776455125398213378934;hb=2d305501b9c97504537828b044fefcaf924b95c2;hp=0fb7ed4f8d1fa9b990cb9ea54f14f5713d9038bc;hpb=9070983be64f9f107e0a6388549aad475fcd9d76;p=simantics%2F3d.git diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/P3DRootNode.java b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/P3DRootNode.java index 0fb7ed4f..7a5ce551 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/P3DRootNode.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/P3DRootNode.java @@ -15,19 +15,21 @@ import org.simantics.g3d.scenegraph.NodeMapProvider; import org.simantics.g3d.scenegraph.base.INode; import org.simantics.g3d.scenegraph.base.NodeException; import org.simantics.g3d.scenegraph.base.ParentNode; +import org.simantics.objmap.graph.IMapping; import org.simantics.objmap.graph.annotations.GraphType; import org.simantics.objmap.graph.annotations.RelatedElementsAdd; import org.simantics.objmap.graph.annotations.RelatedElementsGet; import org.simantics.objmap.graph.annotations.RelatedElementsRem; -import org.simantics.plant3d.editor.P3DNodeMap; import org.simantics.plant3d.ontology.Plant3D; import vtk.vtkProp; @GraphType(Plant3D.URIs.Plant) -public class P3DRootNode extends ParentNode implements IG3DNode, NodeMapProvider { - +public class P3DRootNode extends ParentNode implements IG3DNode, NodeMapProvider { + // Vertical direction that determines the interpretation of rotation angle origin + protected Vector3d upVector = new Vector3d(0.0, 1.0, 0.0); + @RelatedElementsAdd(Plant3D.URIs.children) public void addChild(INode node) { //public void addChild(IP3DVisualNode node) { @@ -45,17 +47,31 @@ public class P3DRootNode extends ParentNode implements IG3DNode, NodeMapP removeNode(Plant3D.URIs.children, node); } - private P3DNodeMap nodeMap; + private NodeMap nodeMap; + private IMapping mapping; - public void setNodeMap(P3DNodeMap nodeMap) { + public void setNodeMap(NodeMap nodeMap) { this.nodeMap = nodeMap; + this.mapping = nodeMap.getMapping(); + } + + public void setMapping(IMapping mapping) { + this.mapping = mapping; } @Override - public NodeMap getNodeMap() { + public NodeMap getNodeMap() { return nodeMap; } + public Resource getNodeResource(INode node) { + return mapping.inverseGet(node); + } + + public INode getResourceNode(Resource r) { + return mapping.get(r); + } + @Override public ParentNode getParent() { return null; @@ -143,11 +159,10 @@ public class P3DRootNode extends ParentNode implements IG3DNode, NodeMapP } - @SuppressWarnings("rawtypes") @Override - public Object getAdapter(Class adapter) { - if (NodeMap.class == adapter) - return nodeMap; + public T getAdapter(Class adapter) { + if (adapter.isAssignableFrom(NodeMap.class)) + return adapter.cast(nodeMap); return null; } @@ -170,4 +185,8 @@ public class P3DRootNode extends ParentNode implements IG3DNode, NodeMapP public TurnComponent createTurn() { return new TurnComponent(); } + + public Vector3d getUpVector() { + return upVector; + } }