From a82b52a886d3f0285cad1a58e49bcd7412fe9540 Mon Sep 17 00:00:00 2001 From: polarbean <harry.carey95@gmail.com> Date: Mon, 24 Mar 2025 16:51:05 +0100 Subject: [PATCH] add damage marker checkbox to pnt gui --- gui/PyNutilGUI.py | 23 ++++++++++++++++++++++- gui/ui_components.py | 5 ++--- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/gui/PyNutilGUI.py b/gui/PyNutilGUI.py index c362cdd..d63dea5 100644 --- a/gui/PyNutilGUI.py +++ b/gui/PyNutilGUI.py @@ -29,6 +29,7 @@ from PyQt6.QtWidgets import ( QGridLayout, QGroupBox, QProgressDialog, + QCheckBox, ) from PyQt6.QtGui import QAction, QColor, QIcon, QDesktopServices from PyQt6.QtCore import ( @@ -200,7 +201,7 @@ class AnalysisWorker(QThread): print("Analysis cancelled") return - pnt.get_coordinates(object_cutoff=0) + pnt.get_coordinates(object_cutoff=0, apply_damage_mask=self.arguments["apply_damage_mask"]) # Check if cancelled before continuing if self.cancelled: @@ -299,6 +300,7 @@ class PyNutilGUI(QMainWindow): "label_path": None, # Added for custom atlases "atlas_path": None, # Added for custom atlases "custom_region_path": None, # Added for custom region file (optional) + "apply_damage_mask": False, # <-- ADDED default field } self.recent_files_path = os.path.join( os.path.expanduser("~"), ".pynutil_recent_files.json" @@ -470,6 +472,16 @@ class PyNutilGUI(QMainWindow): ) left_layout.addLayout(output_layout) + damage_markers_layout = QHBoxLayout() + damage_markers_label = QLabel("Include Damage Quantification:") + self.include_damage_markers_checkbox = QCheckBox() + self.include_damage_markers_checkbox.setChecked(False) + self.include_damage_markers_checkbox.stateChanged.connect(self.update_damage_markers_flag) + + damage_markers_layout.addWidget(damage_markers_label) + damage_markers_layout.addWidget(self.include_damage_markers_checkbox) + left_layout.addLayout(damage_markers_layout) + # Run and cancel buttons left_layout.addWidget(QLabel("Start analysis:")) run_buttons_layout, self.run_button, self.cancel_button = ( @@ -520,6 +532,7 @@ For more information about the QUINT workflow: <a href="https://quint-workflow.r def set_registration_json(self, index): if index >= 0: + # Retrieve the full path from userData value = ( self.registration_json_dropdown.itemData(index) or self.registration_json_dropdown.currentText() @@ -778,6 +791,11 @@ For more information about the QUINT workflow: <a href="https://quint-workflow.r if index >= 0: self.atlas_combo.setCurrentIndex(index) + if "include_damage_markers" in settings: + dmg_markers = bool(settings["include_damage_markers"]) + self.arguments["apply_damage_mask"] = dmg_markers + self.include_damage_markers_checkbox.setChecked(dmg_markers) + self.output_box.setHtml(f"Settings loaded from: {file_path}") except Exception as e: @@ -1063,6 +1081,9 @@ For more information about the QUINT workflow: <a href="https://quint-workflow.r self.populate_atlas_dropdown() self.append_text_to_output(f"Custom atlas '{atlas_name}' added successfully.") + def update_damage_markers_flag(self, state): + self.arguments["apply_damage_mask"] = bool(state) + if __name__ == "__main__": app = QApplication(sys.argv) diff --git a/gui/ui_components.py b/gui/ui_components.py index b31743f..1d3a776 100644 --- a/gui/ui_components.py +++ b/gui/ui_components.py @@ -232,9 +232,8 @@ def populate_dropdown(dropdown, recents, clear_first=True): else: # Handle string items display_text = get_path_display_name(item) - dropdown.addItem(display_text) - # Store the full path as user data in the item - # dropdown.setItemData(dropdown.count() - 1, item) + # Store the full path as user data + dropdown.addItem(display_text, userData=item) dropdown.setEditable(False) # dropdown.setCurrentIndex(-1) -- GitLab