From 9fa645efb9a21bac3c10e7694ed1704ccf8be571 Mon Sep 17 00:00:00 2001 From: Louie Lu Date: Thu, 2 Nov 2023 18:46:36 -0400 Subject: [PATCH 1/3] Add clickable label widget --- NeuroRuler/GUI/qclickablelabel.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 NeuroRuler/GUI/qclickablelabel.py diff --git a/NeuroRuler/GUI/qclickablelabel.py b/NeuroRuler/GUI/qclickablelabel.py new file mode 100644 index 0000000..d432c2e --- /dev/null +++ b/NeuroRuler/GUI/qclickablelabel.py @@ -0,0 +1,27 @@ +from PyQt6.QtCore import Qt +from PyQt6.QtWidgets import QLabel + + +class QClickableLabel(QLabel): + """Clickable QLabel + + When double clicked, the binded slider will be set to 0. + """ + + def __init__(self, parent=None): + super().__init__(parent) + + self._binded_slider = None + + @property + def binded_slider(self): + return self._binded_slider + + @binded_slider.setter + def binded_slider(self, slider): + self._binded_slider = slider + + def mouseDoubleClickEvent(self, event): + if event.buttons() == Qt.MouseButton.LeftButton: + if self.binded_slider: + self.binded_slider.setValue(0) From 8a669305fc599a49fdd8fe9c59a37a99a5c6b203 Mon Sep 17 00:00:00 2001 From: Louie Lu Date: Thu, 2 Nov 2023 18:49:58 -0400 Subject: [PATCH 2/3] Update x/y/z rotation label from QLabel to QClickableLabel 1. Add custom widget definition to UI design file 1. Promote them from QLabel to QClickableLable --- NeuroRuler/GUI/mainwindow.ui | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/NeuroRuler/GUI/mainwindow.ui b/NeuroRuler/GUI/mainwindow.ui index d513134..130377a 100644 --- a/NeuroRuler/GUI/mainwindow.ui +++ b/NeuroRuler/GUI/mainwindow.ui @@ -114,7 +114,7 @@ - + false @@ -165,7 +165,7 @@ - + false @@ -216,7 +216,7 @@ - + false @@ -1171,7 +1171,7 @@ In Slicer, the images are 3D and the default (.0625) time step will provide a st 0 0 1308 - 24 + 22 @@ -1514,6 +1514,13 @@ In Slicer, the images are 3D and the default (.0625) time step will provide a st + + + QClickableLabel + QLabel +
NeuroRuler.GUI.qclickablelabel
+
+
From 37fc202f9d82e5a7e1b22363d8dcbcc831d7ccc4 Mon Sep 17 00:00:00 2001 From: Louie Lu Date: Thu, 2 Nov 2023 18:52:16 -0400 Subject: [PATCH 3/3] Add corresponded slider to x/y/z rotation label --- NeuroRuler/GUI/main.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/NeuroRuler/GUI/main.py b/NeuroRuler/GUI/main.py index 3075812..29854f3 100644 --- a/NeuroRuler/GUI/main.py +++ b/NeuroRuler/GUI/main.py @@ -85,7 +85,9 @@ PATH_TO_NR_LOGO: Path = Path("NeuroRuler") / "GUI" / "static" / "nr_logo.png" if not PATH_TO_NR_LOGO.exists(): PATH_TO_NR_LOGO = Path( - pkg_resources.resource_filename("NeuroRuler.GUI", "static/nr_logo.png") # TODO: pkg_resources is deprecated + pkg_resources.resource_filename( + "NeuroRuler.GUI", "static/nr_logo.png" + ) # TODO: pkg_resources is deprecated ) SETTINGS_VIEW_ENABLED: bool = True @@ -166,10 +168,19 @@ def __init__(self): self.next_button.clicked.connect(self.next_img) self.previous_button.clicked.connect(self.previous_img) self.apply_button.clicked.connect(self.settings_export_view_toggle) + self.x_slider.valueChanged.connect(self.rotate_x) + self.x_rotation_label.binded_slider = self.x_slider + self.y_slider.valueChanged.connect(self.rotate_y) + self.y_rotation_label.binded_slider = self.y_slider + self.z_slider.valueChanged.connect(self.rotate_z) + self.z_rotation_label.binded_slider = self.z_slider + self.slice_slider.valueChanged.connect(self.slice_update) + self.slice_num_label.binded_slider = self.slice_slider + self.reset_button.clicked.connect(self.reset_settings) self.smoothing_preview_button.clicked.connect(self.render_smooth_slice) self.otsu_radio_button.clicked.connect(self.disable_binary_threshold_inputs)