Some operations can move Components between PipeRuns. If we create a
PipeRun within such operation, and the undo the modification, removal of
the created PipeRun may remove Components before they are attached to
their original PipeRuns.
1. Now PipeRun removal detaches Components, so that Component structure
remains intact.
2. PipeCOntrolPoint removal work without PipeRun.
3. AbstractVTKNodeMap calls INode.remove() all removed nodes.
gitlab #35
Change-Id: I37ec56302581ab176fe630c91b3cddb301ad1210
protected void removeMap(E node) {
Collection<vtkProp> coll = nodeToActor.getValuesUnsafe(node);
protected void removeMap(E node) {
Collection<vtkProp> 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);
}
}
nodeToActor.remove(node);
}
if (runUndo && useFullSyncWithUndo) {
reset(graph);
} else {
if (runUndo && useFullSyncWithUndo) {
reset(graph);
} else {
- synchronized (syncMutex) {
+ synchronized (syncMutex) {
graphUpdates = true;
for (DBObject domainObject : mapping.getDomainModified()) {
@SuppressWarnings("unchecked")
graphUpdates = true;
for (DBObject domainObject : mapping.getDomainModified()) {
@SuppressWarnings("unchecked")
syncDeletes();
clearDeletes();
graphUpdates = false;
syncDeletes();
clearDeletes();
graphUpdates = false;
}
if (mapping.isRangeModified() && !runUndo && !runRedo)
}
if (mapping.isRangeModified() && !runUndo && !runRedo)
E n = stack.pop();
boolean conflict = filterChange(removed, n);
if (conflict) {
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))
//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<INode> pn = (ParentNode<INode>)n;
}
if (n instanceof ParentNode) {
ParentNode<INode> pn = (ParentNode<INode>)n;
for (Pair<E, String> n : rem) {
stopListening(n.first);
removeActor(n.first);
for (Pair<E, String> n : rem) {
stopListening(n.first);
removeActor(n.first);
- for (Pair<E, String> n : add) {
- addActor(n.first);
- listen(n.first);
- }
+ for (Pair<E, String> n : add) {
+ addActor(n.first);
+ listen(n.first);
+ }
for (E e : mod.getKeys()) {
Set<String> ids = mod.getValues(e);
for (E e : mod.getKeys()) {
Set<String> ids = mod.getValues(e);
-// 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<String> ids = mod.getValues(e);
updateActor(e,ids);
}
for (E e : mod.getKeys()) {
Set<String> ids = mod.getValues(e);
updateActor(e,ids);
}
for (Pair<E, String> n : rem) {
for (NodeListener l : nodeListeners)
l.nodeRemoved(null, n.first, n.second);
for (Pair<E, String> n : rem) {
for (NodeListener l : nodeListeners)
l.nodeRemoved(null, n.first, n.second);
//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.
//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);
}
//stopListening(child);
}
}
@RelatedElementsRem(Plant3D.URIs.children)
}
@RelatedElementsRem(Plant3D.URIs.children)
+ public void _remChild(PipelineComponent node) {
+ //since we do not now, if DB remove is actually remove or detach, we have to use detach. NodeMap will handle Component removals.
+ deattachNode(Plant3D.URIs.children, node);
+ }
+
public void remChild(PipelineComponent node) {
public void remChild(PipelineComponent node) {
- removeNode(Plant3D.URIs.children, node);
+ removeNode(Plant3D.URIs.children, node);
+ }
+
+ @Override
+ public void remove() {
+ // since we do not now, if DB remove is actually remove or detach, we have to use detach. NodeMap will handle Component removals.
+ Collection<PipelineComponent> comps = getChild();
+ for (PipelineComponent c : comps)
+ c.deattach();
+ super.remove();
if (pcp != null && pcp.getPipelineComponent() != null) {
pcp.remove();
}
if (pcp != null && pcp.getPipelineComponent() != null) {
pcp.remove();
}
if (pcp != null && pcp.getPipelineComponent() != null) {
pcp.removeAndSplit();
}
if (pcp != null && pcp.getPipelineComponent() != null) {
pcp.removeAndSplit();
}
private boolean isSizeChange = false; // changes size of the pipe. The next control point / component is on different PipeRun
private boolean isSub = false; // child point for offset / size change
private boolean isSizeChange = false; // changes size of the pipe. The next control point / component is on different PipeRun
private boolean isSub = false; // child point for offset / size change
+ private boolean disposed = false;
+
public PipeControlPoint(PipelineComponent component) {
this.component = component;
if (component.getPipeRun() != null)
public PipeControlPoint(PipelineComponent component) {
this.component = component;
if (component.getPipeRun() != null)
public void _remove(boolean renconnect) {
public void _remove(boolean renconnect) {
- if (component == null && next == null && previous == null)
- return;
- if (DEBUG) System.out.println(this + " Remove " + renconnect);
+ if (disposed)
+ return;
+
+ if (DEBUG) System.out.println(this + " Remove " + renconnect);
if (getParentPoint() != null) {
getParentPoint()._remove(renconnect);
return;
}
PipeRun pipeRun = getPipeRun();
if (getParentPoint() != null) {
getParentPoint()._remove(renconnect);
return;
}
PipeRun pipeRun = getPipeRun();
- if (pipeRun == null)
- return;
+// PipeRUn removal has been changed, so pipeRun may be null.
+// if (pipeRun == null)
+// return;
PipeControlPoint additionalRemove = null;
if (!PipingRules.isEnabled()) {
PipeControlPoint additionalRemove = null;
if (!PipingRules.isEnabled()) {
PipeControlPoint currentNext = next;
if (currentNext == null && currentPrev == null) {
removeComponent();
PipeControlPoint currentNext = next;
if (currentNext == null && currentPrev == null) {
removeComponent();
- pipeRun.remChild(this);
- checkRemove(pipeRun);
+ if (pipeRun != null) {
+ pipeRun.remChild(this);
+ checkRemove(pipeRun);
+ }
return;
}
if (currentNext != null && currentPrev != null) {
return;
}
if (currentNext != null && currentPrev != null) {
- pipeRun.remChild(this);
- checkRemove(pipeRun);
- if (PipingRules.isEnabled() && pipeRun.getParent() != null && pipeRun.getControlPoints().size() > 0)
- PipingRules.validate(pipeRun);
+ if (pipeRun != null) {
+ pipeRun.remChild(this);
+ checkRemove(pipeRun);
+ if (PipingRules.isEnabled() && pipeRun.getParent() != null && pipeRun.getControlPoints().size() > 0)
+ PipingRules.validate(pipeRun);
+ }
if (additionalRemove != null)
additionalRemove.remove();
if (additionalRemove != null)
additionalRemove.remove();
}
private boolean checkRemove(PipeRun pipeRun) {
}
private boolean checkRemove(PipeRun pipeRun) {
+ if (pipeRun == null)
+ return false;
Collection<PipeControlPoint> points = pipeRun.getControlPoints();
if (points.size() == 0) {
pipeRun.remove();
Collection<PipeControlPoint> points = pipeRun.getControlPoints();
if (points.size() == 0) {
pipeRun.remove();