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<INode> implements IG3DNode, NodeMapProvider<Resource, vtkProp , INode> {
+public class P3DRootNode extends ParentNode<INode> implements IG3DNode, NodeMapProvider<Resource, vtkProp, INode> {
@RelatedElementsAdd(Plant3D.URIs.children)
removeNode(Plant3D.URIs.children, node);
}
- private P3DNodeMap nodeMap;
+ private NodeMap<Resource, vtkProp, INode> nodeMap;
+ private IMapping<Resource, INode> mapping;
- public void setNodeMap(P3DNodeMap nodeMap) {
+ public void setNodeMap(NodeMap<Resource, vtkProp, INode> nodeMap) {
this.nodeMap = nodeMap;
+ this.mapping = nodeMap.getMapping();
+ }
+
+ public void setMapping(IMapping<Resource, INode> mapping) {
+ this.mapping = mapping;
}
@Override
- public NodeMap<Resource,vtkProp, INode> getNodeMap() {
+ public NodeMap<Resource, vtkProp, INode> 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;
import org.simantics.g3d.scenegraph.base.INode;
import org.simantics.g3d.scenegraph.base.ParentNode;
import org.simantics.g3d.scl.ScriptNodeMap;
-import org.simantics.g3d.vtk.common.VtkView;
import org.simantics.objmap.graph.IMapping;
import org.simantics.plant3d.ontology.Plant3D;
import org.simantics.plant3d.scenegraph.IP3DNode;
import org.simantics.plant3d.scenegraph.controlpoint.PipeControlPoint;
import org.simantics.plant3d.scenegraph.controlpoint.PipingRules;
-import vtk.vtkProp3D;
-
-public class P3DScriptNodeMap extends ScriptNodeMap<Resource,INode>{
+public class P3DScriptNodeMap extends ScriptNodeMap<Resource,INode> {
private static final boolean DEBUG = false;
public P3DScriptNodeMap(Session session, IMapping mapping, P3DRootNode rootNode) {
super(session,mapping,rootNode);
- //rootNode.setNodeMap(this);
+ rootNode.setMapping(mapping);
}
@Override
if (node instanceof ParentNode<?>) {
+ @SuppressWarnings("unchecked")
ParentNode<IP3DNode> p = (ParentNode<IP3DNode>)node;
for (IP3DNode n : p.getNodes())
updateTransform(n);
IMappingSchema<Resource, Object> schema = schemaProvider.get(graph);
IMapping<Resource, Object> mapping = Mappings.createWithListening(schema);
P3DRootNode rootNode = (P3DRootNode) mapping.map(graph, root);
+ rootNode.setMapping((IMapping)mapping);
try {
P3DUtil.finalizeDBLoad(rootNode);
// FIXME: Something needs to be done here...
IMapping<Resource, Object> mapping = Mappings.createWithoutListening(schema);
@SuppressWarnings("unchecked")
Root rootNode = (Root) mapping.map(graph, root);
+ rootNode.setMapping((IMapping)mapping);
try {
P3DUtil.finalizeDBLoad(rootNode);
P3DUtil.finalizeDBLoad2(rootNode);
} catch (Exception e) {
throw new DatabaseException(e);
}
+
return rootNode;
}
});