X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.g3d.vtk%2Fsrc%2Forg%2Fsimantics%2Fg3d%2Fvtk%2Fcommon%2FAbstractVTKNodeMap.java;h=bb5493f6b7a76ee806d712d402691f5b862cdc8d;hb=refs%2Fchanges%2F51%2F3451%2F1;hp=953ef198b2d43cbbd18c7f7285596fffaf88935c;hpb=9070983be64f9f107e0a6388549aad475fcd9d76;p=simantics%2F3d.git diff --git a/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/common/AbstractVTKNodeMap.java b/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/common/AbstractVTKNodeMap.java index 953ef198..bb5493f6 100644 --- a/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/common/AbstractVTKNodeMap.java +++ b/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/common/AbstractVTKNodeMap.java @@ -56,8 +56,8 @@ public abstract class AbstractVTKNodeMap implements VT protected IMapping mapping; protected VtkView view; - protected MapList nodeToActor = new MapList(); - protected Map actorToNode = new HashMap(); + private MapList nodeToActor = new MapList(); + private Map actorToNode = new HashMap(); protected ParentNode rootNode; @@ -85,9 +85,7 @@ public abstract class AbstractVTKNodeMap implements VT e.printStackTrace(); } } - - - + protected abstract void addActor(E node); protected abstract void removeActor(E node); protected abstract void updateActor(E node,Set ids); @@ -114,6 +112,21 @@ public abstract class AbstractVTKNodeMap implements VT return nodeToActor.getValues((E)node); } + protected void map(E node, Collection props) { + for (vtkProp p : props) { + nodeToActor.add(node, p); + actorToNode.put(p, node); + } + } + + protected void removeMap(E node) { + Collection coll = nodeToActor.getValuesUnsafe(node); + for (vtkProp p : coll) { + actorToNode.remove(p); + } + nodeToActor.remove(node); + } + @SuppressWarnings("unchecked") @Override public ParentNode getRootNode() { @@ -214,11 +227,12 @@ public abstract class AbstractVTKNodeMap implements VT } if (changeTracking) { mapping.rangeModified((E)node.getParent()); + mapping.rangeModified((E)node); } added.add(new Pair(node, id)); rangeModified = true; } - view.refresh(); + repaint(); } @SuppressWarnings("unchecked") @@ -229,8 +243,10 @@ public abstract class AbstractVTKNodeMap implements VT if (n.first.equals(node)) return; } - if (changeTracking && !db) + if (changeTracking && !db) { + mapping.rangeModified((E)node); mapping.rangeModified((E)node.getParent()); + } removed.add(new Pair(node, id)); rangeModified = true; } @@ -394,7 +410,7 @@ public abstract class AbstractVTKNodeMap 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). * @@ -425,6 +441,7 @@ public abstract class AbstractVTKNodeMap implements VT for (E n : delete) { if (DEBUG) System.out.println(debugString(n)); mapping.getRange().remove(n); + stopListening(n); } delete.clear(); } @@ -610,7 +627,6 @@ public abstract class AbstractVTKNodeMap implements VT if (DEBUG) System.out.println("Node added " + child + " parent " + node); //receiveAdd((E)child, rel ,graphUpdates); receiveAdd((E)child, rel ,graphModified.contains(node)); - } @SuppressWarnings("unchecked") @@ -621,9 +637,10 @@ public abstract class AbstractVTKNodeMap implements VT //receiveRemove((E)child, rel, graphUpdates); receiveRemove((E)child, rel, graphModified.contains(node)); - //FIXME : sometimes removed structural models cause ObjMap to add their children again. - // removing the listener here prevents corruption of visual model, but better fix is needed. - stopListening(child); + //FIXME : 1. sometimes removed structural models cause ObjMap to add their children again. + // removing the listener here prevents corruption of visual model, but better fix is needed. + // 2. detach causes nodeRemoved event, which then causes other critical events to be missed. Took out th + //stopListening(child); } @Override