Skip to content

Commit 9e916e0

Browse files
committed
ROI menu: rename "Edit" to "Edit graphically", add "Edit numerically"
1 parent b419413 commit 9e916e0

11 files changed

Lines changed: 86 additions & 25 deletions

File tree

datalab/gui/actionhandler.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -631,13 +631,20 @@ def create_first_actions(self):
631631

632632
with self.new_category(ActionCategory.ROI):
633633
self.new_action(
634-
_("Edit") + "...",
635-
triggered=self.panel.processor.edit_regions_of_interest,
634+
_("Edit graphically") + "...",
635+
triggered=self.panel.processor.edit_roi_graphically,
636636
icon_name="roi.svg",
637637
context_menu_pos=-1,
638638
context_menu_sep=True,
639639
toolbar_pos=-1,
640640
toolbar_category=ActionCategory.VIEW_TOOLBAR,
641+
tip=_("Edit regions of interest graphically"),
642+
)
643+
self.new_action(
644+
_("Edit numerically") + "...",
645+
triggered=self.panel.processor.edit_roi_numerically,
646+
select_condition=SelectCond.exactly_one_with_roi,
647+
tip=_("Edit regions of interest numerically"),
641648
)
642649
self.new_action(
643650
_("Extract") + "...",

datalab/gui/processor/base.py

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1321,7 +1321,7 @@ def compute_roi_extraction(self, roi: TypeROI | None = None) -> None:
13211321
# ROI Editor dialog anyway
13221322
# * If multiple objs are selected, then apply the first obj ROI to all
13231323
if roi is None or roi.is_empty():
1324-
roi = self.edit_regions_of_interest(mode="extract")
1324+
roi = self.edit_roi_graphically(mode="extract")
13251325
if roi is None or roi.is_empty():
13261326
return
13271327
obj = self.panel.objview.get_sel_objects(include_groups=True)[0]
@@ -1346,7 +1346,7 @@ def _extract_multiple_roi_in_single_object(
13461346

13471347
# ------Analysis-------------------------------------------------------------------
13481348

1349-
def edit_regions_of_interest(
1349+
def edit_roi_graphically(
13501350
self, mode: Literal["apply", "extract", "define"] = "apply"
13511351
) -> TypeROI | None:
13521352
"""Define Region Of Interest (ROI).
@@ -1407,6 +1407,34 @@ def edit_regions_of_interest(
14071407
)
14081408
return edited_roi
14091409

1410+
def edit_roi_numerically(self) -> TypeROI:
1411+
"""Edit Regions Of Interest (ROIs) numerically.
1412+
1413+
Opens a dialog to edit the parameters of the selected ROIs.
1414+
If no ROIs are selected, it will prompt the user to select ROIs.
1415+
1416+
Returns:
1417+
The edited ROI object if the dialog is accepted, otherwise the original ROI.
1418+
"""
1419+
obj = self.panel.objview.get_sel_objects()[0]
1420+
assert obj.roi is not None, _("No ROI selected for editing.")
1421+
params = obj.roi.to_params(obj)
1422+
group = gds.DataSetGroup(params, title=_("Regions of Interest"))
1423+
if group.edit(parent=self.panel.parent()):
1424+
edited_roi = obj.roi.__class__.from_params(
1425+
obj, params, singleobj=obj.roi.singleobj
1426+
)
1427+
obj.roi = edited_roi
1428+
self.SIG_ADD_SHAPE.emit(get_uuid(obj))
1429+
self.panel.refresh_plot(
1430+
"selected",
1431+
update_items=True,
1432+
only_visible=False,
1433+
only_existing=True,
1434+
)
1435+
return edited_roi
1436+
return obj.roi
1437+
14101438
def delete_regions_of_interest(self) -> None:
14111439
"""Delete Regions Of Interest"""
14121440
if (

datalab/gui/processor/image.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ def compute_erase(self, roi: ImageROI | None = None) -> None:
712712
roi: Region of interest to erase
713713
"""
714714
if roi is None or roi.is_empty():
715-
roi = self.edit_regions_of_interest(mode="define")
715+
roi = self.edit_roi_graphically(mode="define")
716716
if roi is None or roi.is_empty():
717717
return
718718
obj = self.panel.objview.get_sel_objects(include_groups=True)[0]

datalab/locale/fr/LC_MESSAGES/datalab.po

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ msgid ""
66
msgstr ""
77
"Project-Id-Version: datalab\n"
88
"Report-Msgid-Bugs-To: p.raybaut@codra.fr\n"
9-
"POT-Creation-Date: 2025-08-03 17:48+0200\n"
9+
"POT-Creation-Date: 2025-08-07 17:06+0200\n"
1010
"PO-Revision-Date: 2025-05-22 15:46+0200\n"
1111
"Last-Translator: Christophe Debonnel <c.debonnel@codra.fr>\n"
1212
"Language: fr\n"
@@ -141,8 +141,21 @@ msgstr "Copier les titres dans le presse-papier"
141141
msgid "Copy titles of selected objects to clipboard"
142142
msgstr "Copier les titres des objets sélectionnés dans le presse-papier"
143143

144-
msgid "Edit"
145-
msgstr "Modifier"
144+
#, fuzzy
145+
msgid "Edit graphically"
146+
msgstr "ROI graphique"
147+
148+
#, fuzzy
149+
msgid "Edit regions of interest graphically"
150+
msgstr "Régions d'intérêt"
151+
152+
#, fuzzy
153+
msgid "Edit numerically"
154+
msgstr "Symétrie verticale"
155+
156+
#, fuzzy
157+
msgid "Edit regions of interest numerically"
158+
msgstr "Régions d'intérêt"
146159

147160
msgid "Extract"
148161
msgstr "Extraire"
@@ -979,6 +992,9 @@ msgstr "Second opérande"
979992
msgid "Regions of Interest"
980993
msgstr "Régions d'intérêt"
981994

995+
msgid "No ROI selected for editing."
996+
msgstr ""
997+
982998
msgid "Sum"
983999
msgstr "Addition"
9841000

datalab/tests/features/image/contour_app_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def test_contour_app():
3131
ima2 = create_test_image_with_roi(newparam)
3232
ima2.set_metadata_option("colormap", "gray")
3333
panel.add_object(ima2)
34-
panel.processor.edit_regions_of_interest()
34+
panel.processor.edit_roi_graphically()
3535
panel.processor.run_feature("contour_shape", param)
3636
if not execenv.unattended:
3737
break

datalab/tests/features/image/roi_app_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def test_image_roi_app(screenshots: bool = False):
160160
ima2_i = ima2.copy()
161161
panel.add_object(ima2_i)
162162
print_obj_data_dimensions(ima2_i)
163-
panel.processor.edit_regions_of_interest()
163+
panel.processor.edit_roi_graphically()
164164
if screenshots:
165165
win.statusBar().hide()
166166
win.take_screenshot("i_roi_image")
@@ -175,7 +175,7 @@ def test_image_roi_basic_app():
175175
param = NewImageParam.create(height=SIZE, width=SIZE)
176176
ima1 = create_multigaussian_image(param)
177177
panel.add_object(ima1)
178-
panel.processor.edit_regions_of_interest()
178+
panel.processor.edit_roi_graphically()
179179

180180

181181
if __name__ == "__main__":

datalab/tests/features/signal/roi_app_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def test_signal_roi_app(screenshots: bool = False) -> None:
115115
sig2_i = sig2.copy()
116116
panel.add_object(sig2_i)
117117
print_obj_data_dimensions(sig2_i, indent=1)
118-
panel.processor.edit_regions_of_interest()
118+
panel.processor.edit_roi_graphically()
119119
if screenshots:
120120
win.statusBar().hide()
121121
win.take_screenshot("s_roi_signal")
@@ -129,7 +129,7 @@ def test_signal_roi_basic_app():
129129
panel = win.signalpanel
130130
sig1 = create_paracetamol_signal(SIZE)
131131
panel.add_object(sig1)
132-
panel.processor.edit_regions_of_interest()
132+
panel.processor.edit_roi_graphically()
133133

134134

135135
if __name__ == "__main__":

doc/features/image/menu_roi.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,14 @@ ROI are taken into account almost in all computing features in DataLab:
3131

3232
The "ROI" menu allows you to:
3333

34-
- "Edit" |roi|: open a dialog box to manage ROI associated with the selected image (add, remove, move, resize, etc.). The ROI definition dialog is exactly the same as ROI extraction (see below).
34+
- "Edit graphically" |edit_roi|: open a dialog box to manage ROI associated with the selected image (add, remove, move, resize, etc.). The ROI definition dialog is exactly the same as ROI extraction (see below).
3535

3636
.. figure:: /images/shots/i_roi_editor.png
3737

3838
An image with an ROI.
3939

40+
- "Edit numerically": open a dialog box to edit the parameters of the selected ROIs numerically (i.e. using a simple form). This allows you to define or modify ROIs based on numerical values.
41+
4042
- "Extract" |image_roi|: extract the defined ROI from the selected images. This will create a new image for each ROI (or a single image, if the "Extract all ROIs into a single image" option is selected in the dialog), with the same metadata as the original image, but with the data corresponding to the ROI only. The new images will be added to the current workspace.
4143

4244
- "Copy" |roi_copy|: copy the defined ROI from the selected images to the clipboard. This allows you to paste the ROI into another image or use it in other operations.
@@ -53,7 +55,7 @@ The "ROI" menu allows you to:
5355

5456
ROI extraction dialog: the ROI is defined by moving the position and adjusting the size of a rectangle shape.
5557

56-
.. |roi| image:: ../../../datalab/data/icons/roi/roi.svg
58+
.. |edit_roi| image:: ../../../datalab/data/icons/roi/roi.svg
5759
:width: 24px
5860
:height: 24px
5961
:class: dark-light

doc/features/signal/menu_roi.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,14 @@ ROI are taken into account almost in all computing features in DataLab:
3131

3232
The "ROI" menu allows you to:
3333

34-
- "Edit" |roi|: open a dialog box to manage ROI associated with the selected signal (add, remove, move, resize, etc.). The ROI definition dialog is exactly the same as ROI extraction (see below): the ROI is defined by moving the position and adjusting the width of an horizontal range.
34+
- "Edit graphically" |edit_roi|: open a dialog box to manage ROI associated with the selected signal (add, remove, move, resize, etc.). The ROI definition dialog is exactly the same as ROI extraction (see below): the ROI is defined by moving the position and adjusting the width of an horizontal range.
3535

3636
.. figure:: /images/shots/s_roi_editor.png
3737

3838
A signal with an ROI.
3939

40+
- "Edit numerically": open a dialog box to edit the parameters of the selected ROIs numerically (i.e. using a simple form). This allows you to define or modify ROIs based on numerical values.
41+
4042
- "Extract" |signal_roi|: extract the defined ROI from the selected signals. This will create a new signal for each ROI (or a single signal, if the "Extract all ROIs into a single signal" option is selected in the dialog), with the same metadata as the original signal, but with the data corresponding to the ROI only. The new signals will be added to the current workspace.
4143

4244
- "Copy" |roi_copy|: copy the defined ROI from the selected signals to the clipboard. This allows you to paste the ROI into another signal or use it in other operations.
@@ -53,7 +55,7 @@ The "ROI" menu allows you to:
5355

5456
ROI extraction dialog: the ROI is defined by moving the position and adjusting the width of an horizontal range.
5557

56-
.. |roi| image:: ../../../datalab/data/icons/roi/roi.svg
58+
.. |edit_roi| image:: ../../../datalab/data/icons/roi/roi.svg
5759
:width: 24px
5860
:height: 24px
5961
:class: dark-light

doc/locale/fr/LC_MESSAGES/features/image/menu_roi.po

Lines changed: 7 additions & 4 deletions
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-08-03 18:05+0200\n"
11+
"POT-Creation-Date: 2025-08-07 17:06+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"
@@ -55,15 +55,18 @@ msgstr "Les ROI sont stockées en tant que métadonnées et sont donc attachées
5555
msgid "The \"ROI\" menu allows you to:"
5656
msgstr "Le menu \"ROI\" vous permet de :"
5757

58-
msgid "\"Edit\" |roi|: open a dialog box to manage ROI associated with the selected image (add, remove, move, resize, etc.). The ROI definition dialog is exactly the same as ROI extraction (see below)."
59-
msgstr "\"Modifier\" |roi| : ouvrir une boîte de dialogue pour gérer les ROI associées à l'image sélectionnée (ajouter, supprimer, déplacer, redimensionner, etc.). La boîte de dialogue de définition des ROI est exactement la même que celle de l'extraction des ROI (voir ci-dessous)."
58+
msgid "\"Edit graphically\" |edit_roi|: open a dialog box to manage ROI associated with the selected image (add, remove, move, resize, etc.). The ROI definition dialog is exactly the same as ROI extraction (see below)."
59+
msgstr "\"Édition graphique\" |edit_roi| : ouvrir une boîte de dialogue pour gérer les ROI associées à l'image sélectionnée (ajouter, supprimer, déplacer, redimensionner, etc.). La boîte de dialogue de définition des ROI est exactement la même que celle de l'extraction des ROI (voir ci-dessous)."
6060

61-
msgid "roi"
61+
msgid "edit_roi"
6262
msgstr ""
6363

6464
msgid "An image with an ROI."
6565
msgstr "Une image avec une ROI."
6666

67+
msgid "\"Edit numerically\": open a dialog box to edit the parameters of the selected ROIs numerically (i.e. using a simple form). This allows you to define or modify ROIs based on numerical values."
68+
msgstr "\"Édition numérique\" : ouvrir une boîte de dialogue pour modifier les paramètres des ROI sélectionnées numériquement (c'est-à-dire à l'aide d'un formulaire simple). Cela vous permet de définir ou de modifier des ROI en fonction de valeurs numériques."
69+
6770
msgid "\"Extract\" |image_roi|: extract the defined ROI from the selected images. This will create a new image for each ROI (or a single image, if the \"Extract all ROIs into a single image\" option is selected in the dialog), with the same metadata as the original image, but with the data corresponding to the ROI only. The new images will be added to the current workspace."
6871
msgstr "\"Extraire\" |image_roi| : extraire la ROI définie des images sélectionnées. Cela créera une nouvelle image pour chaque ROI (ou une seule image, si l'option \"Extraire toutes les ROIs dans une seule image\" est sélectionnée dans la boîte de dialogue), avec les mêmes métadonnées que l'image d'origine, mais avec les données correspondant uniquement à la ROI. Les nouvelles images seront ajoutées à l'espace de travail actuel."
6972

0 commit comments

Comments
 (0)