Skip to content

Commit eb6e0c7

Browse files
committed
Merge branch 'main' into develop
# Conflicts: # doc/locale/fr/LC_MESSAGES/api/core.gui/panel.po
2 parents 4b3eb71 + c684a48 commit eb6e0c7

File tree

7 files changed

+105
-33
lines changed

7 files changed

+105
-33
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ See DataLab [roadmap page](https://datalab-platform.com/en/contributing/roadmap.
3636
* Fixed [Issue #158](https://github.com./DataLab-Platform/DataLab/issues/158) - When editing ROI of a list of images, the first image of the selection is shown (instead of the last as in the image panel)
3737
* Fixed [Issue #159](https://github.com./DataLab-Platform/DataLab/issues/159) - When selecting multiple images just after opening an HDF5 file, the "View in a new window" feature does not work (`KeyError` exception)
3838
* Fixed [Issue #160](https://github.com./DataLab-Platform/DataLab/issues/160) - When selecting multiple images and clearing ROI in ROI editor, only the first image is affected
39+
* Fixed [Issue #161](https://github.com./DataLab-Platform/DataLab/issues/161) - Refresh image items only if necessary (when editing ROI, pasting/deleting metadata)
3940

4041
## DataLab Version 0.19.0 ##
4142

cdl/core/gui/panel/base.py

+30-13
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ class BaseDataPanel(AbstractPanel, Generic[TypeObj, TypeROI, TypeROIEditor]):
280280
IO_REGISTRY: SignalIORegistry | ImageIORegistry | None = None
281281
SIG_STATUS_MESSAGE = QC.Signal(str) # emitted by "qt_try_except" decorator
282282
SIG_REFRESH_PLOT = QC.Signal(
283-
str, bool, bool
283+
str, bool, bool, bool, bool
284284
) # Connected to PlotHandler.refresh_plot
285285
ROIDIALOGOPTIONS = {}
286286

@@ -476,10 +476,14 @@ def setup_panel(self) -> None:
476476
self.add_objprop_buttons()
477477

478478
def refresh_plot(
479-
self, what: str, update_items: bool = True, force: bool = False
479+
self,
480+
what: str,
481+
update_items: bool = True,
482+
force: bool = False,
483+
only_visible: bool = True,
484+
only_existing: bool = False,
480485
) -> None:
481-
"""Refresh plot. This method simply emits the signal SIG_REFRESH_PLOT which is
482-
connected to the method `PlotHandler.refresh_plot`.
486+
"""Refresh plot.
483487
484488
Args:
485489
what: string describing the objects to refresh.
@@ -490,17 +494,26 @@ def refresh_plot(
490494
If False, only show the items (do not update them, except if the
491495
option "Use reference item LUT range" is enabled and more than one
492496
item is selected). Defaults to True.
493-
force: if True, force refresh even if auto refresh is disabled,
494-
and refresh all items associated to objects (even the hidden ones, e.g.
495-
when selecting multiple images of the same size and position). Defaults
496-
to False.
497+
force: if True, force refresh even if auto refresh is disabled.
498+
Defaults to False.
499+
only_visible: if True, only refresh visible items. Defaults to True.
500+
Visible items are the ones that are not hidden by other items or the items
501+
except the first one if the option "Show first only" is enabled.
502+
This is useful for images, where the last image is the one that is shown.
503+
If False, all items are refreshed.
504+
only_existing: if True, only refresh existing items. Defaults to False.
505+
Existing items are the ones that have already been created and are
506+
associated to the object uuid. If False, create new items for the
507+
objects that do not have an item yet.
497508
498509
Raises:
499510
ValueError: if `what` is not a valid value
500511
"""
501512
if what not in ("selected", "all", "existing") and not isinstance(what, str):
502513
raise ValueError(f"Invalid value for 'what': {what}")
503-
self.SIG_REFRESH_PLOT.emit(what, update_items, force)
514+
self.SIG_REFRESH_PLOT.emit(
515+
what, update_items, force, only_visible, only_existing
516+
)
504517

505518
def manual_refresh(self) -> None:
506519
"""Manual refresh"""
@@ -623,10 +636,12 @@ def paste_metadata(self, param: PasteMetadataParam | None = None) -> None:
623636
sel_objects = self.objview.get_sel_objects(include_groups=True)
624637
for obj in sorted(sel_objects, key=lambda obj: obj.short_id, reverse=True):
625638
obj.update_metadata_from(metadata)
626-
# We have to do a manual refresh in order to force the plot handler to update
639+
# We have to do a special refresh in order to force the plot handler to update
627640
# all plot items, even the ones that are not visible (otherwise, image masks
628641
# would not be updated after pasting the metadata: see issue #123)
629-
self.manual_refresh()
642+
self.refresh_plot(
643+
"selected", update_items=True, only_visible=False, only_existing=True
644+
)
630645

631646
def remove_object(self, force: bool = False) -> None:
632647
"""Remove signal/image object
@@ -717,11 +732,13 @@ def delete_metadata(
717732
if index == 0:
718733
self.selection_changed()
719734
if refresh_plot:
720-
# We have to do a manual refresh in order to force the plot handler to
735+
# We have to do a special refresh in order to force the plot handler to
721736
# update all plot items, even the ones that are not visible (otherwise,
722737
# image masks would remained visible after deleting the ROI for example:
723738
# see issue #122)
724-
self.manual_refresh()
739+
self.refresh_plot(
740+
"selected", update_items=True, only_visible=False, only_existing=True
741+
)
725742

726743
def add_annotations_from_items(
727744
self, items: list, refresh_plot: bool = True

cdl/core/gui/plothandler.py

+46-13
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def __getitem__(self, oid: str) -> TypePlotItem:
9999
# (object has been added to model but the corresponding plot item has not
100100
# been created yet)
101101
if not self.__auto_refresh:
102-
self.refresh_plot("selected", True, force=True)
102+
self.refresh_plot(oid, True, force=True, only_visible=False)
103103
return self.__plotitems[oid]
104104
# Item does not exist and auto refresh is enabled: this should not happen
105105
raise exc
@@ -282,7 +282,12 @@ def reduce_shown_oids(self, oids: list[str]) -> list[str]:
282282
return oids
283283

284284
def refresh_plot(
285-
self, what: str, update_items: bool = True, force: bool = False
285+
self,
286+
what: str,
287+
update_items: bool = True,
288+
force: bool = False,
289+
only_visible: bool = True,
290+
only_existing: bool = False,
286291
) -> None:
287292
"""Refresh plot.
288293
@@ -295,10 +300,17 @@ def refresh_plot(
295300
If False, only show the items (do not update them, except if the
296301
option "Use reference item LUT range" is enabled and more than one
297302
item is selected). Defaults to True.
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.
303+
force: if True, force refresh even if auto refresh is disabled.
304+
Defaults to False.
305+
only_visible: if True, only refresh visible items. Defaults to True.
306+
Visible items are the ones that are not hidden by other items or the items
307+
except the first one if the option "Show first only" is enabled.
308+
This is useful for images, where the last image is the one that is shown.
309+
If False, all items are refreshed.
310+
only_existing: if True, only refresh existing items. Defaults to False.
311+
Existing items are the ones that have already been created and are
312+
associated to the object uuid. If False, create new items for the
313+
objects that do not have an item yet.
302314
303315
Raises:
304316
ValueError: if `what` is not a valid value
@@ -344,7 +356,8 @@ def refresh_plot(
344356
scales_dict = {}
345357

346358
if oids:
347-
if what != "existing" and not force:
359+
if what != "existing" and only_visible:
360+
# Remove hidden items from the list of objects to refresh
348361
oids = self.reduce_shown_oids(oids)
349362
ref_item = None
350363
with create_progress_bar(
@@ -377,6 +390,8 @@ def refresh_plot(
377390
# Update or add item to plot
378391
item = self.get(oid)
379392
if item is None:
393+
if only_existing:
394+
continue
380395
item = self.__add_item_to_plot(oid)
381396
else:
382397
self.__update_item_on_plot(
@@ -536,7 +551,12 @@ def reduce_shown_oids(self, oids: list[str]) -> list[str]:
536551
return oids
537552

538553
def refresh_plot(
539-
self, what: str, update_items: bool = True, force: bool = False
554+
self,
555+
what: str,
556+
update_items: bool = True,
557+
force: bool = False,
558+
only_visible: bool = True,
559+
only_existing: bool = False,
540560
) -> None:
541561
"""Refresh plot.
542562
@@ -549,15 +569,28 @@ def refresh_plot(
549569
If False, only show the items (do not update them, except if the
550570
option "Use reference item LUT range" is enabled and more than one
551571
item is selected). Defaults to True.
552-
force: if True, force refresh even if auto refresh is disabled,
553-
and refresh all items associated to objects (even the hidden ones, e.g.
554-
when selecting multiple images of the same size and position). Defaults
555-
to False.
572+
force: if True, force refresh even if auto refresh is disabled.
573+
Defaults to False.
574+
only_visible: if True, only refresh visible items. Defaults to True.
575+
Visible items are the ones that are not hidden by other items or the items
576+
except the first one if the option "Show first only" is enabled.
577+
This is useful for images, where the last image is the one that is shown.
578+
If False, all items are refreshed.
579+
only_existing: if True, only refresh existing items. Defaults to False.
580+
Existing items are the ones that have already been created and are
581+
associated to the object uuid. If False, create new items for the
582+
objects that do not have an item yet.
556583
557584
Raises:
558585
ValueError: if `what` is not a valid value
559586
"""
560-
super().refresh_plot(what=what, update_items=update_items, force=force)
587+
super().refresh_plot(
588+
what=what,
589+
update_items=update_items,
590+
force=force,
591+
only_visible=only_visible,
592+
only_existing=only_existing,
593+
)
561594
self.plotwidget.contrast.setVisible(Conf.view.show_contrast.get(True))
562595

563596
def cleanup_dataview(self) -> None:

cdl/core/gui/processor/base.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -1099,7 +1099,12 @@ def edit_regions_of_interest(
10991099
obj_i.roi = edited_roi
11001100
self.SIG_ADD_SHAPE.emit(obj.uuid)
11011101
# self.panel.selection_changed(update_items=True)
1102-
self.panel.manual_refresh()
1102+
self.panel.refresh_plot(
1103+
"selected",
1104+
update_items=True,
1105+
only_visible=False,
1106+
only_existing=True,
1107+
)
11031108
return edited_roi
11041109

11051110
def delete_regions_of_interest(self) -> None:

doc/locale/fr/LC_MESSAGES/api/core.gui/panel.po

+8-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ msgid ""
88
msgstr ""
99
"Project-Id-Version: DataLab \n"
1010
"Report-Msgid-Bugs-To: \n"
11-
"POT-Creation-Date: 2025-04-05 12:29+0200\n"
11+
"POT-Creation-Date: 2025-04-07 19:11+0200\n"
1212
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1313
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1414
"Language: fr\n"
@@ -211,7 +211,13 @@ msgstr ""
211211
msgid "if True, update the items. If False, only show the items (do not update them, except if the option \"Use reference item LUT range\" is enabled and more than one item is selected). Defaults to True."
212212
msgstr ""
213213

214-
msgid "if True, force refresh even if auto refresh is disabled, and refresh all items associated to objects (even the hidden ones, e.g. when selecting multiple images of the same size and position). Defaults to False."
214+
msgid "if True, force refresh even if auto refresh is disabled. Defaults to False."
215+
msgstr ""
216+
217+
msgid "if True, only refresh visible items. Defaults to True. Visible items are the ones that are not hidden by other items or the items except the first one if the option \"Show first only\" is enabled. This is useful for images, where the last image is the one that is shown. If False, all items are refreshed."
218+
msgstr ""
219+
220+
msgid "if True, only refresh existing items. Defaults to False. Existing items are the ones that have already been created and are associated to the object uuid. If False, create new items for the objects that do not have an item yet."
215221
msgstr ""
216222

217223
msgid "Raises"

doc/locale/fr/LC_MESSAGES/api/core.gui/plothandler.po

+10-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ msgid ""
88
msgstr ""
99
"Project-Id-Version: DataLab \n"
1010
"Report-Msgid-Bugs-To: \n"
11-
"POT-Creation-Date: 2025-03-20 14:15+0100\n"
11+
"POT-Creation-Date: 2025-04-07 19:11+0200\n"
1212
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1313
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1414
"Language: fr\n"
@@ -17,7 +17,7 @@ msgstr ""
1717
"MIME-Version: 1.0\n"
1818
"Content-Type: text/plain; charset=utf-8\n"
1919
"Content-Transfer-Encoding: 8bit\n"
20-
"Generated-By: Babel 2.17.0\n"
20+
"Generated-By: Babel 2.14.0\n"
2121

2222
msgid "Plot handler"
2323
msgstr "Gestionnaire de visualisation"
@@ -85,7 +85,13 @@ msgstr "chaîne décrivant les objets à actualiser. Les valeurs valides sont \"
8585
msgid "if True, update the items. If False, only show the items (do not update them, except if the option \"Use reference item LUT range\" is enabled and more than one item is selected). Defaults to True."
8686
msgstr "si True, mettre à jour les items. Si False, seulement afficher les items (ne pas les mettre à jour, sauf si l'option \"Utiliser la plage LUT de l'item de référence\" est activée et que plus d'un item est sélectionné). Par défaut à True."
8787

88-
msgid "if True, force refresh even if auto refresh is disabled, and refresh all items associated to objects (even the hidden ones, e.g. when selecting multiple images of the same size and position). Defaults to False."
88+
msgid "if True, force refresh even if auto refresh is disabled. Defaults to False."
89+
msgstr ""
90+
91+
msgid "if True, only refresh visible items. Defaults to True. Visible items are the ones that are not hidden by other items or the items except the first one if the option \"Show first only\" is enabled. This is useful for images, where the last image is the one that is shown. If False, all items are refreshed."
92+
msgstr ""
93+
94+
msgid "if True, only refresh existing items. Defaults to False. Existing items are the ones that have already been created and are associated to the object uuid. If False, create new items for the objects that do not have an item yet."
8995
msgstr ""
9096

9197
msgid "Raises"
@@ -123,3 +129,4 @@ msgstr "Gestionnaire de visualisation d'images"
123129

124130
msgid "Object handling image plot items, plot dialogs, plot options"
125131
msgstr "Objet gérant les items de visualisation d'images, les dialogues de visualisation et les options de visualisation"
132+

doc/locale/fr/LC_MESSAGES/contributing/changelog.po

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ msgid ""
77
msgstr ""
88
"Project-Id-Version: DataLab \n"
99
"Report-Msgid-Bugs-To: \n"
10-
"POT-Creation-Date: 2025-04-07 18:28+0200\n"
10+
"POT-Creation-Date: 2025-04-07 19:11+0200\n"
1111
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1212
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1313
"Language: fr\n"
@@ -111,6 +111,9 @@ msgstr "Correction de l'[Issue #159](https://github.com./DataLab-Platform/DataLab
111111
msgid "Fixed [Issue #160](https://github.com./DataLab-Platform/DataLab/issues/160) - When selecting multiple images and clearing ROI in ROI editor, only the first image is affected"
112112
msgstr "Correction de l'[Issue #160](https://github.com./DataLab-Platform/DataLab/issues/160) - Lors de la sélection de plusieurs images et de l'effacement de la ROI dans l'éditeur de ROI, seule la première image est affectée"
113113

114+
msgid "Fixed [Issue #161](https://github.com./DataLab-Platform/DataLab/issues/161) - Refresh image items only if necessary (when editing ROI, pasting/deleting metadata)"
115+
msgstr "Correction de l'[Issue #161](https://github.com./DataLab-Platform/DataLab/issues/161) - Rafraîchir les items d'image uniquement si nécessaire (lors de l'édition de la ROI, du collage/de la suppression de métadonnées)"
116+
114117
msgid "DataLab Version 0.19.0"
115118
msgstr "DataLab Version 0.19.0"
116119

0 commit comments

Comments
 (0)