Skip to content

Commit 514ae05

Browse files
committed
Fix plot refresh behavior when pasting/deleting metadata to ensure all items are updated, including hidden ones
Fix #122 Fix #123
1 parent 375c87a commit 514ae05

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

cdl/core/gui/panel/base.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,10 @@ def paste_metadata(self) -> None:
524524
sel_objects = self.objview.get_sel_objects(include_groups=True)
525525
for obj in sorted(sel_objects, key=lambda obj: obj.short_id, reverse=True):
526526
obj.metadata.update(self.__metadata_clipboard)
527-
self.SIG_REFRESH_PLOT.emit("existing", True)
527+
# We have to do a manual refresh in order to force the plot handler to update
528+
# all plot items, even the ones that are not visible (otherwise, image masks
529+
# would not be updated after pasting the metadata: see issue #123)
530+
self.manual_refresh()
528531

529532
def remove_object(self, force: bool = False) -> None:
530533
"""Remove signal/image object
@@ -615,7 +618,11 @@ def delete_metadata(
615618
if index == 0:
616619
self.selection_changed()
617620
if refresh_plot:
618-
self.SIG_REFRESH_PLOT.emit("existing", True)
621+
# We have to do a manual refresh in order to force the plot handler to
622+
# update all plot items, even the ones that are not visible (otherwise,
623+
# image masks would remained visible after deleting the ROI for example:
624+
# see issue #122)
625+
self.manual_refresh()
619626

620627
def add_annotations_from_items(
621628
self, items: list, refresh_plot: bool = True

cdl/core/gui/plothandler.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,10 @@ def refresh_plot(
295295
If False, only show the items (do not update them, except if the
296296
option "Use reference item LUT range" is enabled and more than one
297297
item is selected). Defaults to True.
298-
force: if True, force refresh even if auto refresh is disabled.
298+
force: if True, force refresh even if auto refresh is disabled,
299+
and refresh all items associated to objects (even the hidden ones, e.g.
300+
when selecting multiple images of the same size and position). Defaults
301+
to False.
299302
300303
Raises:
301304
ValueError: if `what` is not a valid value
@@ -341,7 +344,7 @@ def refresh_plot(
341344
scales_dict = {}
342345

343346
if oids:
344-
if what != "existing":
347+
if what != "existing" and not force:
345348
oids = self.reduce_shown_oids(oids)
346349
ref_item = None
347350
with create_progress_bar(

0 commit comments

Comments
 (0)