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=4bcb5df271b53f5c3b8f8651d5146b1096e54540;hb=09afb6fbe9c440b6768714373d95d581111b9993;hp=a03e89cbc8e1fc6273708686fa5fcc4174b95dde;hpb=ebfe6b0245b5cf9231cecedf0aaacd891eb5d344;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 a03e89cb..4bcb5df2 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 @@ -121,8 +121,16 @@ public abstract class AbstractVTKNodeMap implements VT protected void removeMap(E node) { Collection coll = nodeToActor.getValuesUnsafe(node); - for (vtkProp p : coll) { - actorToNode.remove(p); + if (coll.size() > 0) { + view.lock(); + for (vtkProp p : coll) { + actorToNode.remove(p); + if (p.GetVTKId() != 0) { + view.getRenderer().RemoveActor(p); + p.Delete(); + } + } + view.unlock(); } nodeToActor.remove(node); } @@ -352,7 +360,7 @@ public abstract class AbstractVTKNodeMap implements VT if (runUndo && useFullSyncWithUndo) { reset(graph); } else { - synchronized (syncMutex) { + synchronized (syncMutex) { graphUpdates = true; for (DBObject domainObject : mapping.getDomainModified()) { @SuppressWarnings("unchecked") @@ -365,7 +373,7 @@ public abstract class AbstractVTKNodeMap implements VT syncDeletes(); clearDeletes(); graphUpdates = false; - } + } } if (mapping.isRangeModified() && !runUndo && !runRedo) @@ -477,10 +485,10 @@ public abstract class AbstractVTKNodeMap implements VT E n = stack.pop(); boolean conflict = filterChange(removed, n); if (conflict) { - System.out.println("Prevent removing " + n); + if (DEBUG) System.out.println("Prevent removing " + n); //filterChange(added, n) if (filterChange(added, n)) - System.out.println("Prevent adding " + n); + if (DEBUG) System.out.println("Prevent adding " + n); } if (n instanceof ParentNode) { ParentNode pn = (ParentNode)n; @@ -489,7 +497,10 @@ public abstract class AbstractVTKNodeMap implements VT } } } - + // Do not process updates for removed nodes. + for (Pair r : removed) { + updated.removeValues(r.first); + } rem.addAll(removed); add.addAll(added); for (E e : updated.getKeys()) { @@ -504,16 +515,16 @@ public abstract class AbstractVTKNodeMap implements VT } - for (Pair n : rem) { stopListening(n.first); removeActor(n.first); + n.first.remove(); } - for (Pair n : add) { - addActor(n.first); - listen(n.first); - } + for (Pair n : add) { + addActor(n.first); + listen(n.first); + } for (E e : mod.getKeys()) { Set ids = mod.getValues(e); @@ -547,26 +558,11 @@ public abstract class AbstractVTKNodeMap implements VT } } -// synchronized (syncMutex) { -// rem.addAll(removed); -// add.addAll(added); -// //mod.addAll(updated); -// for (E e : updated.getKeys()) { -// for (String s : updated.getValues(e)) -// mod.add(e, s); -// } -// -// removed.clear(); -// added.clear(); -// updated.clear(); -// } - for (E e : mod.getKeys()) { Set ids = mod.getValues(e); updateActor(e,ids); } - - + for (Pair n : rem) { for (NodeListener l : nodeListeners) l.nodeRemoved(null, n.first, n.second); @@ -638,7 +634,7 @@ public abstract class AbstractVTKNodeMap implements VT //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 + // 2. detach causes nodeRemoved event, which then causes other critical events to be missed. Took out call: //stopListening(child); }