]> gerrit.simantics Code Review - simantics/3d.git/blobdiff - org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/common/AbstractVTKNodeMap.java
Allow multiple radii for turns.
[simantics/3d.git] / org.simantics.g3d.vtk / src / org / simantics / g3d / vtk / common / AbstractVTKNodeMap.java
index 953ef198b2d43cbbd18c7f7285596fffaf88935c..2c37521b8367b751451d3a73c5b02cbca60977cd 100644 (file)
@@ -56,8 +56,8 @@ public abstract class AbstractVTKNodeMap<DBObject,E extends INode> implements VT
        protected IMapping<DBObject,E> mapping;
        protected VtkView view;
        
-       protected MapList<E, vtkProp> nodeToActor = new MapList<E, vtkProp>();
-       protected Map<vtkProp,E> actorToNode = new HashMap<vtkProp, E>();
+       private MapList<E, vtkProp> nodeToActor = new MapList<E, vtkProp>();
+       private Map<vtkProp,E> actorToNode = new HashMap<vtkProp, E>();
 
        protected ParentNode<E> rootNode;
        
@@ -85,9 +85,7 @@ public abstract class AbstractVTKNodeMap<DBObject,E extends INode> implements VT
                        e.printStackTrace();
                }
        }
-       
-       
-       
+
        protected abstract void addActor(E node);
        protected abstract void removeActor(E node);
        protected abstract void updateActor(E node,Set<String> ids);
@@ -114,6 +112,21 @@ public abstract class AbstractVTKNodeMap<DBObject,E extends INode> implements VT
                return nodeToActor.getValues((E)node);
        }
        
+       protected <T extends vtkProp> void map(E node, Collection<T> props) {
+           for (vtkProp p : props) {
+               nodeToActor.add(node, p);
+               actorToNode.put(p, node);
+           }
+       }
+       
+       protected void removeMap(E node) {
+           Collection<vtkProp> coll = nodeToActor.getValuesUnsafe(node);
+           for (vtkProp p : coll) {
+               actorToNode.remove(p);
+           }
+           nodeToActor.remove(node);
+       }
+       
        @SuppressWarnings("unchecked")
        @Override
        public ParentNode<E> getRootNode() {
@@ -218,7 +231,7 @@ public abstract class AbstractVTKNodeMap<DBObject,E extends INode> implements VT
                        added.add(new Pair<E, String>(node, id));
                        rangeModified = true;
                }
-               view.refresh();
+               repaint();
        }
        
        @SuppressWarnings("unchecked")
@@ -394,7 +407,7 @@ public abstract class AbstractVTKNodeMap<DBObject,E extends INode> implements VT
        
        /**
         * When objects are removed (either from Java or Graph), after remove processing the Java objects remain in mapping cache.
-        * This causes problems with Undo and Redo, whcih the end up re-using the removed objects from mapping cache.
+        * This causes problems with Undo and Redo, which cause re-using the removed objects from mapping cache.
         * 
         * This code here synchronizes removed and added objects to collect deletable objects. (a deletable object is one which is removed but not added).  
         *