use of qupath.lib.objects.hierarchy.events.PathObjectHierarchyEvent in project qupath by qupath.
the class PathObjectHierarchy method fireObjectClassificationsChangedEvent.
/**
* Fire a hierarchy update indicating object classifications have changed.
* @param source
* @param pathObjects
*/
public void fireObjectClassificationsChangedEvent(Object source, Collection<? extends PathObject> pathObjects) {
PathObjectHierarchyEvent event = PathObjectHierarchyEvent.createObjectsChangedEvent(source, this, HierarchyEventType.CHANGE_CLASSIFICATION, pathObjects, false);
fireEvent(event);
}
use of qupath.lib.objects.hierarchy.events.PathObjectHierarchyEvent in project qupath by qupath.
the class PathObjectHierarchy method fireObjectRemovedEvent.
void fireObjectRemovedEvent(Object source, PathObject pathObject, PathObject previousParent) {
PathObjectHierarchyEvent event = PathObjectHierarchyEvent.createObjectRemovedEvent(source, this, previousParent, pathObject);
fireEvent(event);
}
use of qupath.lib.objects.hierarchy.events.PathObjectHierarchyEvent in project qupath by qupath.
the class UndoRedoManager method hierarchyChanged.
@Override
public void hierarchyChanged(PathObjectHierarchyEvent event) {
// Try to avoid calling too often
if (undoingOrRedoing || event.isChanging() || maxUndoHierarchySize.get() <= 0 || event.getChangedObjects().stream().allMatch(p -> p instanceof ParallelTileObject))
return;
// *Potentially* we might have the same hierarchy in multiple viewers
// Since we don't have the viewer stored in the event, check to see what viewers are impacted
QuPathViewer[] viewers = map.keySet().toArray(new QuPathViewer[map.size()]);
PathObjectHierarchy hierarchy = event.getHierarchy();
int maxSize = maxUndoHierarchySize.get();
boolean sizeOK = hierarchy.nObjects() <= maxSize;
for (QuPathViewer viewer : viewers) {
if (viewer.getHierarchy() == hierarchy) {
SerializableUndoRedoStack<PathObjectHierarchy> undoRedo = map.get(viewer);
// If the size is ok, register the change for potential undo-ing
if (sizeOK) {
if (undoRedo == null)
map.put(viewer, new SerializableUndoRedoStack<>(hierarchy));
else
undoRedo.addLatest(hierarchy, maxUndoLevels.get());
} else {
// If the hierarchy is too big turn off undo/redo
map.put(viewer, (SerializableUndoRedoStack<PathObjectHierarchy>) null);
}
}
}
refreshProperties();
}
Aggregations