import vtk.vtkProp;
import vtk.vtkProp3D;
-public class P3DNodeMap extends AbstractVTKNodeMap<INode> {
+public class P3DNodeMap extends AbstractVTKNodeMap<Resource,INode> {
private static final boolean DEBUG = false;
- public P3DNodeMap(Session session, IMapping mapping, VtkView panel, P3DRootNode rootNode) {
+ public P3DNodeMap(Session session, IMapping<Resource,INode> mapping, VtkView panel, P3DRootNode rootNode) {
super(session, mapping, panel, rootNode);
rootNode.setNodeMap(this);
}
if (ids.contains(id)) {
node.visualize(view);
updateRenderObjectsFor(node);
- updateTransform(node);
+ //updateTransform(node);
break;
}
}
} else if (n instanceof PipeRun) {
- // FIXME: may require rule based update!
PipeRun run = (PipeRun)n;
+
+ // Check for change to turn radii and update turn components
+ if (ids.contains(Plant3D.URIs.HasTurnRadiusArray) ||
+ ids.contains(Plant3D.URIs.HasTurnRadius)) {
+ requestTurnUpdates(run);
+ }
+
Set<String> ids2 = new HashSet<String>();
ids2.add(Plant3D.URIs.hasGeometry);
for (PipeControlPoint pcp : run.getControlPoints()) {
updateActor(pcp, ids2);
}
- }
+ }
if (ids.contains(G3D.URIs.hasPosition) ||
ids.contains(G3D.URIs.hasOrientation) ||
ids.contains(G3D.URIs.hasWorldOrientation)) {
updateTransform(node);
}
+ if (ids.contains(Plant3D.URIs.HasTurnRadiusIndex)) {
+ node.visualize(view);
+ updateRenderObjectsFor(node);
+ }
+ }
+
+ private void requestTurnUpdates(PipeRun run) {
+ for (PipeControlPoint pcp : run.getControlPoints()) {
+ if (pcp.isTurn())
+ PipingRules.requestUpdate(pcp);
+ }
}
private void updateTransform(IP3DNode node) {
node.update(view.getRenderer());
if (node instanceof ParentNode<?>) {
+ @SuppressWarnings("unchecked")
ParentNode<IP3DNode> p = (ParentNode<IP3DNode>)node;
for (IP3DNode n : p.getNodes())
updateTransform(n);
node.visualize(view);
- for (vtkProp3D act : node.getActors()) {
- nodeToActor.add(node, act);
- actorToNode.put(act, node);
- }
+ map(node, node.getActors());
+
if (DEBUG) System.out.println("Added " + node.getActors().size() + " actors");
if (node instanceof P3DParentNode<?>) {
private boolean hasActor(IP3DVisualNode node) {
- List<vtkProp> list = nodeToActor.getValues(node);
+ Collection<vtkProp> list = getRenderObjects(node);
if (list == null || list.size() == 0)
return false;
return true;
if (Thread.currentThread() != view.getThreadQueue().getThread())
throw new RuntimeException("Illegal thread.");
- List<vtkProp> list = nodeToActor.getValues(node);
- if (list != null) {
- for (vtkProp obj : list) {
- actorToNode.remove(obj);
- }
- nodeToActor.remove(node);
- view.lock();
-
- node.stopVisualize();
-
- view.unlock();
+ Collection<vtkProp> list = getRenderObjects(node);
+ if (list.size() > 0) {
+ removeMap(node);
+ view.lock();
+ node.stopVisualize();
+ view.unlock();
}
}