Skip to content

Commit 8eb0998

Browse files
committed
Fix aspect ratio not propagated to separate plot windows
Closes #287
1 parent 59d299e commit 8eb0998

File tree

5 files changed

+49
-8
lines changed

5 files changed

+49
-8
lines changed

datalab/gui/plothandler.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -810,4 +810,9 @@ def get_plot_options(self) -> PlotOptions:
810810
options = super().get_plot_options()
811811
options.zlabel = self.plot.get_axis_title("right")
812812
options.zunit = self.plot.get_axis_unit("right")
813+
# Include aspect ratio configuration so that separate plot dialogs
814+
# (e.g. "View in a new window", ROI editors, profile dialogs) use the same
815+
# settings as the integrated plot handler:
816+
options.aspect_ratio = self.plot.get_aspect_ratio()
817+
options.lock_aspect_ratio = self.plot.lock_aspect_ratio
813818
return options

datalab/gui/processor/image.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,8 @@ def create_roi_grid(self) -> None:
779779
== QW.QMessageBox.No
780780
):
781781
return
782-
editor = ImageGridROIEditor(parent=self.parent(), obj=obj0)
782+
options = self.panel.plothandler.get_plot_options()
783+
editor = ImageGridROIEditor(parent=self.parent(), obj=obj0, options=options)
783784
if exec_dialog(editor):
784785
for obj in self.panel.objview.get_sel_objects():
785786
obj.roi = editor.get_roi()
@@ -1014,7 +1015,10 @@ def compute_offset_correction(self, param: ROI2DParam | None = None) -> None:
10141015
with :py:func:`sigima.proc.image.offset_correction`"""
10151016
obj = self.panel.objview.get_sel_objects(include_groups=True)[0]
10161017
if param is None:
1017-
dlg = imagebackground.ImageBackgroundDialog(obj, parent=self.mainwindow)
1018+
options = self.panel.plothandler.get_plot_options()
1019+
dlg = imagebackground.ImageBackgroundDialog(
1020+
obj, parent=self.mainwindow, options=options
1021+
)
10181022
if exec_dialog(dlg):
10191023
x0, y0, x1, y1 = dlg.get_rect_coords()
10201024
param = ROI2DParam.create(

datalab/widgets/imagebackground.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66

77
from __future__ import annotations
88

9-
from typing import TYPE_CHECKING
9+
from typing import TYPE_CHECKING, Any
1010

1111
import numpy as np
1212
from guidata.configtools import get_icon
1313
from plotpy.builder import make
14-
from plotpy.plot import PlotDialog
14+
from plotpy.plot import PlotDialog, PlotOptions
1515

1616
from datalab.adapters_plotpy import create_adapter_from_object
1717
from datalab.config import _
@@ -29,16 +29,25 @@ class ImageBackgroundDialog(PlotDialog):
2929
Args:
3030
image: image object
3131
parent: parent widget. Defaults to None.
32+
options: plot options. Defaults to None.
3233
"""
3334

34-
def __init__(self, image: ImageObj, parent: QWidget | None = None) -> None:
35+
def __init__(
36+
self,
37+
image: ImageObj,
38+
parent: QWidget | None = None,
39+
options: PlotOptions | dict[str, Any] | None = None,
40+
) -> None:
3541
self.__background: float | None = None
3642
self.__rect_coords: tuple[float, float, float, float] | None = None
3743
self.imageitem: MaskedXYImageItem | None = None
3844
self.rectarea: RectangleShape | None = None
3945
self.comput2d: RangeComputation2d | None = None
4046
super().__init__(
41-
title=_("Image background selection"), edit=True, parent=parent
47+
title=_("Image background selection"),
48+
edit=True,
49+
parent=parent,
50+
options=options,
4251
)
4352
self.setObjectName("backgroundselection")
4453
if parent is None:

doc/locale/fr/LC_MESSAGES/release_notes/release_1.00.po

Lines changed: 18 additions & 2 deletions
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-12-16 12:43+0100\n"
10+
"POT-Creation-Date: 2025-12-16 14:35+0100\n"
1111
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1212
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1313
"Language: fr\n"
@@ -27,6 +27,21 @@ msgstr ""
2727
msgid "🛠️ Bug Fixes since version 1.0.2"
2828
msgstr "🛠️ Correctifs depuis la version 1.0.2"
2929

30+
msgid "**Separate plot windows - Incorrect aspect ratio for non-uniform coordinates:**"
31+
msgstr "**Fenêtres de tracé séparées - Rapport d'aspect incorrect pour les coordonnées non uniformes :**"
32+
33+
msgid "Fixed separate plot windows (e.g., \"View in a new window\", ROI editors, profile dialogs) not using the same aspect ratio configuration as the integrated plot handler"
34+
msgstr "Correction des fenêtres de tracé séparées (par ex. « Voir dans une nouvelle fenêtre », éditeurs de ROI, dialogues de profil) qui n'utilisaient pas la même configuration de rapport d'aspect que le gestionnaire de tracé intégré"
35+
36+
msgid "When displaying images with non-uniform coordinates, the main plot correctly unlocks the aspect ratio for proper display, but separate windows were not inheriting this setting"
37+
msgstr "Lors de l'affichage d'images avec des coordonnées non uniformes, le tracé principal déverrouille correctement le rapport d'aspect pour un affichage approprié, mais les fenêtres séparées n'héritaient pas de ce paramètre"
38+
39+
msgid "All image dialogs now properly inherit the aspect ratio settings, ensuring consistent display behavior across all plot windows"
40+
msgstr "Toutes les boîtes de dialogue d'image héritent désormais correctement des paramètres de rapport d'aspect, assurant un comportement d'affichage cohérent sur toutes les fenêtres de tracé"
41+
42+
msgid "This closes [Issue #287](https://github.com/DataLab-Platform/DataLab/issues/287) - Separate plot windows don't use same aspect ratio configuration as integrated plot"
43+
msgstr "Ceci clôture [Issue #287](https://github.com/datalab-platform/datalab/issues/287) - Separate plot windows don't use same aspect ratio configuration as integrated plot"
44+
3045
msgid "**Remove all results - AttributeError when ROI was removed:**"
3146
msgstr "**Supprimer tous les résultats - AttributeError lorsque la ROI a été supprimée :**"
3247

@@ -48,7 +63,8 @@ msgstr "Tentative de suppression de tous les résultats via « Analyse > Supprim
4863
msgid "The fix adds a proper None check before accessing the ROI's title"
4964
msgstr "Le correctif ajoute une vérification de valeur None appropriée avant d'accéder au titre de la ROI"
5065

51-
msgid "This closes [Issue #286](https://github.com/DataLab-Platform/DataLab/issues/286) - 'Remove all results' fails with AttributeError when ROI was removed"
66+
#, fuzzy
67+
msgid "This closes [Issue #286](https://github.com/DataLab-Platform/DataLab/issues/286) - \"Remove all results\" fails with AttributeError when ROI was removed"
5268
msgstr "Ceci clôture [Issue #286](https://github.com/datalab-platform/datalab/issues/286) - 'Remove all results' fails with AttributeError when ROI was removed"
5369

5470
msgid "**Analysis auto-recompute - Stale parameters after deleting results:**"

doc/release_notes/release_1.00.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@
44

55
### 🛠️ Bug Fixes since version 1.0.2 ###
66

7+
**Separate plot windows - Incorrect aspect ratio for non-uniform coordinates:**
8+
9+
* Fixed separate plot windows (e.g., "View in a new window", ROI editors, profile dialogs) not using the same aspect ratio configuration as the integrated plot handler
10+
* When displaying images with non-uniform coordinates, the main plot correctly unlocks the aspect ratio for proper display, but separate windows were not inheriting this setting
11+
* All image dialogs now properly inherit the aspect ratio settings, ensuring consistent display behavior across all plot windows
12+
* This closes [Issue #287](https://github.com/DataLab-Platform/DataLab/issues/287) - Separate plot windows don't use same aspect ratio configuration as integrated plot
13+
714
**Remove all results - AttributeError when ROI was removed:**
815

916
* Fixed "Remove all results" action failing with `AttributeError: 'NoneType' object has no attribute 'get_single_roi_title'` when results contain ROI information but the ROI was subsequently removed from the object

0 commit comments

Comments
 (0)