Skip to content
Snippets Groups Projects
Commit 34d72aaf authored by mhby1g21's avatar mhby1g21
Browse files

refactored material tab (much more managable file size/lines now)

parent 2248f5aa
No related branches found
No related tags found
1 merge request!4GDP 4.2.10 - Adding Debug mode to GUI.py to run individual modules
...@@ -5,6 +5,7 @@ import os ...@@ -5,6 +5,7 @@ import os
from tabs.config_tab import ConfigTab from tabs.config_tab import ConfigTab
from tabs.shifter_tab import ShifterTab from tabs.shifter_tab import ShifterTab
from tabs.depth_tab import DepthTab from tabs.depth_tab import DepthTab
from tabs.material_tab import MaterialTab
from utils.config_reader import ConfigReader from utils.config_reader import ConfigReader
class ModuleDebugGUI(QMainWindow): class ModuleDebugGUI(QMainWindow):
...@@ -38,6 +39,7 @@ class ModuleDebugGUI(QMainWindow): ...@@ -38,6 +39,7 @@ class ModuleDebugGUI(QMainWindow):
self.tabs.addTab(ConfigTab(self.config_reader), "Configuration") self.tabs.addTab(ConfigTab(self.config_reader), "Configuration")
self.tabs.addTab(ShifterTab(self.config_reader), "Image Shifter") self.tabs.addTab(ShifterTab(self.config_reader), "Image Shifter")
self.tabs.addTab(DepthTab(self.config_reader), "MonoDepth Estimation") self.tabs.addTab(DepthTab(self.config_reader), "MonoDepth Estimation")
self.tabs.addTab(MaterialTab(self.config_reader), "Material Recognition")
def main(): def main():
app = QApplication(sys.argv) app = QApplication(sys.argv)
......
This diff is collapsed.
...@@ -74,4 +74,32 @@ def update_preview(preview_label, image_path, max_size=300, error_callback=None) ...@@ -74,4 +74,32 @@ def update_preview(preview_label, image_path, max_size=300, error_callback=None)
else: else:
preview_label.clear() preview_label.clear()
if error_callback: if error_callback:
error_callback(f"Image not found: {image_path}") error_callback(f"Image not found: {image_path}")
\ No newline at end of file
def update_face_previews(preview_dict, src_dir, suffix='', error_callback=None):
"""
Updates a dictionary of face preview labels with images from directory.
Args:
preview_dict: Dictionary of face preview labels
src_dir: Directory containing face images
suffix: Suffix for face image filenames
error_callback: Optional callback function for error handling
"""
for face, preview in preview_dict.items():
face_path = os.path.join(src_dir, face + suffix)
update_preview(preview, face_path, error_callback=error_callback)
def clear_previews(*preview_widgets):
"""
Clears multiple preview widgets.
Args:
preview_widgets: List of preview widgets to clear
"""
for widget in preview_widgets:
if isinstance(widget, dict):
for preview in widget.values():
preview.clear()
else:
widget.clear()
\ No newline at end of file
...@@ -99,4 +99,87 @@ def create_preview_group(title): ...@@ -99,4 +99,87 @@ def create_preview_group(title):
preview = QLabel() preview = QLabel()
preview.setAlignment(Qt.AlignmentFlag.AlignCenter) preview.setAlignment(Qt.AlignmentFlag.AlignCenter)
layout.addWidget(preview) layout.addWidget(preview)
return group, preview return group, preview
\ No newline at end of file
def create_status_label(label_text, initial_status="Not started"):
"""
Creates a status indicator layout with label and status.
Args:
label_text: Text for the label
initial_status: Initial status text
Returns:
QHBoxLayout layout with label and status
"""
layout = QHBoxLayout()
label = QLabel(label_text)
status = QLabel(initial_status)
layout.addWidget(label)
layout.addWidget(status, stretch=1)
return layout
def create_preview_grid(face_names, preview_dict, cols=3):
"""
Creates a grid layout of preview groups for cubemap faces.
Args:
face_names: List of face names
preview_dict: Dictionary to store preview widgets
cols: Number of columns
Returns:
QVBoxLayout layout with preview groups in grids for cubemap faces
"""
grid = QVBoxLayout()
row_layout = QHBoxLayout()
count = 0
for face in face_names:
group, preview = create_preview_group(face)
preview_dict[face] = preview
row_layout.addWidget(group)
count += 1
if count % cols == 0:
grid.addLayout(row_layout)
row_layout = QHBoxLayout()
if count % cols != 0:
grid.addLayout(row_layout)
return grid
def update_status_indicator(status_layout, state):
"""
Updates a status indicator with new state and color.
Args:
status_layout: QHBoxLayout layout with label and status
state: New status text
"""
label = status_layout.itemAt(1).widget()
states = {
"Running": ("Running...", "orange"),
"Complete": ("✓ Complete", "green"),
"Failed": ("✗ Failed", "red"),
"Not started": ("Not started", "black")
}
if state in states:
text, color = states[state]
label.setText(text)
label.setStyleSheet(f"color: {color}")
else:
label.setText(state)
label.setStyleSheet("")
def get_status_text(status_layout):
"""
Gets the current status text without markers.
Args:
status_layout: QHBoxLayout layout with label and status
Returns:
str: Current status text
"""
text = status_layout.itemAt(1).widget().text()
return text.replace("", "").replace("", "")
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment