Skip to content

Commit 3a92162

Browse files
committed
Fix: enable ROI editing for multiple selected signals or images
Fix #135
1 parent cd0da18 commit 3a92162

File tree

4 files changed

+23
-5
lines changed

4 files changed

+23
-5
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ See DataLab [roadmap page](https://datalab-platform.com/en/contributing/roadmap.
1515
* This is now fixed: the "One curve per result title" mode now takes into account the ROI defined on the objects, and plots the selected result for each object (signal or image) and for each ROI defined on the object
1616
* Fixed [Issue #128](https://github.com/DataLab-Platform/DataLab/issues/128) - Support long object titles in Signal and Image panels
1717
* Fixed [Issue #133](https://github.com/DataLab-Platform/DataLab/issues/133) - Remove specific analysis results from metadata clipboard during copy operation
18+
* Fixed [Issue #135](https://github.com/DataLab-Platform/DataLab/issues/135) - Allow to edit ROI on multiple signals or images at once
19+
* Before this fix, the ROI editor was disabled when multiple signals or images were selected
20+
* This is now fixed: the ROI editor is now enabled when multiple signals or images are selected, and the ROI is applied to all selected signals or images (only the ROI of the first selected signal or image is taken into account)
21+
* This new behavior is consistent with the ROI extraction feature, which allows to extract the ROI on multiple signals or images at once, based on the ROI defined on the first selected signal or image
1822
* Image ROI features:
1923
* Fixed [Issue #120](https://github.com/DataLab-Platform/DataLab/issues/120) - ROI extraction on multiple images: defined ROI should not be saved in the first selected object. The design choice is to save the defined ROI neither in the first nor in any of the selected objects: the ROI is only used for the extraction, and is not saved in any object
2024
* Fixed [Issue #121](https://github.com/DataLab-Platform/DataLab/issues/121) - `AttributeError` when extracting multiple ROIs on a single image, if more than one image is selected

cdl/core/gui/actionhandler.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,6 @@ def create_first_actions(self):
548548
separator=True,
549549
triggered=self.panel.processor.edit_regions_of_interest,
550550
icon_name="roi.svg",
551-
select_condition=SelectCond.exactly_one,
552551
context_menu_pos=-1,
553552
context_menu_sep=True,
554553
toolbar_pos=-1,

cdl/core/gui/panel/base.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1088,6 +1088,7 @@ def get_roi_editor_output(self, extract: bool) -> tuple[TypeROI, bool] | None:
10881088
obj = self.objview.get_sel_objects(include_groups=True)[0]
10891089

10901090
# Create a new dialog
1091+
10911092
dlg = self.create_new_dialog(
10921093
edit=True,
10931094
toolbar=True,
@@ -1099,9 +1100,20 @@ def get_roi_editor_output(self, extract: bool) -> tuple[TypeROI, bool] | None:
10991100
return None
11001101

11011102
# Create ROI editor (and add it to the dialog)
1102-
# pylint: disable=not-callable
1103+
1104+
if obj.uuid not in self.plothandler:
1105+
# This happens for example when opening an already saved workspace with
1106+
# multiple images, and if the user tries to edit the ROI of a group of
1107+
# images without having selected any object yet. In this case, only the
1108+
# last image is actually plotted (because if the other have the same size
1109+
# and position, they are hidden), and the plot item of the first image is
1110+
# not created yet. The `obj.uuid` is precisely the uuid of the first image.
1111+
self.plothandler.refresh_plot("selected", True, True)
11031112
item = obj.make_item(update_from=self.plothandler[obj.uuid])
1113+
1114+
# pylint: disable=not-callable
11041115
roi_editor = self.get_roieditor_class()(dlg, obj, extract, item=item)
1116+
11051117
dlg.button_layout.insertWidget(0, roi_editor)
11061118

11071119
if exec_dialog(dlg):

cdl/core/gui/processor/base.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,7 +1045,8 @@ def edit_regions_of_interest(
10451045
if results is None:
10461046
return None
10471047
edited_roi, modified = results
1048-
obj = self.panel.objview.get_sel_objects(include_groups=True)[0]
1048+
objs = self.panel.objview.get_sel_objects(include_groups=True)
1049+
obj = objs[0]
10491050
group = edited_roi.to_params(obj)
10501051
if (
10511052
env.execenv.unattended # Unattended mode (automated unit tests)
@@ -1059,9 +1060,11 @@ def edit_regions_of_interest(
10591060
else:
10601061
edited_roi = edited_roi.from_params(obj, group)
10611062
if not extract:
1062-
obj.roi = edited_roi
1063+
for obj_i in objs:
1064+
obj_i.roi = edited_roi
10631065
self.SIG_ADD_SHAPE.emit(obj.uuid)
1064-
self.panel.selection_changed(update_items=True)
1066+
# self.panel.selection_changed(update_items=True)
1067+
self.panel.manual_refresh()
10651068
return edited_roi
10661069

10671070
def delete_regions_of_interest(self) -> None:

0 commit comments

Comments
 (0)