Skip to content

Commit

Permalink
Impoving ux. this refs #58
Browse files Browse the repository at this point in the history
  • Loading branch information
JeanBilheux committed Apr 10, 2023
1 parent 35d5011 commit 73c9659
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 212 deletions.
4 changes: 4 additions & 0 deletions src/hyperctui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@

UI_TITLE = "Ai Svmbir UI"

interact_me_style = "background-color: lime"
error_style = "background-color: red"
normal_style = ""

SOURCE_DETECTOR_DISTANCE = 19.855 # m, at SNAP
DETECTOR_OFFSET = 0 # micros

Expand Down
50 changes: 45 additions & 5 deletions src/hyperctui/autonomous_reconstruction/event_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import inflect

from hyperctui import EvaluationRegionKeys
from hyperctui import interact_me_style, normal_style, error_style

from hyperctui.autonomous_reconstruction.help_golden_angle import HelpGoldenAngle
from hyperctui.autonomous_reconstruction.help_automatic_angles import HelpAutomaticAngles
from hyperctui.autonomous_reconstruction.select_evaluation_regions import SelectEvaluationRegions
from hyperctui.autonomous_reconstruction.select_tof_regions import SelectTofRegions

Expand All @@ -17,6 +17,7 @@ def __init__(self, parent=None):
def projections_angles_radioButton_changed(self):
fixed_state = self.parent.ui.fixed_projections_angles_radioButton.isChecked()
self.parent.ui.automatic_projections_angles_pushButton.setEnabled(not fixed_state)
self.update_widgets()

def projections_angles_automatic_button_clicked(self):
o_ui = SelectEvaluationRegions(parent=self.parent)
Expand All @@ -26,10 +27,6 @@ def projections_fixed_help_clicked(self):
o_ui = HelpGoldenAngle(parent=self.parent)
o_ui.show()

def projections_automatic_help_clicked(self):
o_ui = HelpAutomaticAngles(parent=self.parent)
o_ui.show()

def evaluation_frequency_help_clicked(self):
pass

Expand All @@ -54,5 +51,48 @@ def update_widgets(self):

if nbr_regions_selected > 0:
self.parent.ui.tof_region_of_interest_error_label.setVisible(False)
self.parent.ui.tof_region_of_interest_pushButton.setText("Edit TOF regions ...")
else:
self.parent.ui.tof_region_of_interest_error_label.setVisible(True)
self.parent.ui.tof_region_of_interest_pushButton.setText("Select TOF regions ...")

self.check_state_of_start_pre_acquisition_button()

def is_start_pre_acquisition_button_ready(self):
"""
return True if all the conditions are met to enable the pre-acquisition button
"""
tof_regions = self.parent.tof_regions
nbr_regions_selected = 0
for _key in tof_regions.keys():
if tof_regions[_key][EvaluationRegionKeys.state]:
nbr_regions_selected += 1

if nbr_regions_selected == 0:
self.parent.ui.tof_region_of_interest_pushButton.setStyleSheet(error_style)
return False
else:
self.parent.ui.tof_region_of_interest_pushButton.setStyleSheet(normal_style)

if self.parent.ui.automatic_projections_angles_radioButton.isChecked():
evaluation_regions = self.parent.evaluation_regions
nbr_regions_selected = 0
for _key in evaluation_regions.keys():
if evaluation_regions[_key][EvaluationRegionKeys.state]:
nbr_regions_selected += 1

if nbr_regions_selected == 0:
self.parent.ui.automatic_projections_angles_pushButton.setStyleSheet(error_style)
return False
else:
self.parent.ui.automatic_projections_angles_pushButton.setStyleSheet(normal_style)

return True

def check_state_of_start_pre_acquisition_button(self):
is_button_ready = self.is_start_pre_acquisition_button_ready()
self.parent.ui.start_first_reconstruction_pushButton.setEnabled(is_button_ready)
if is_button_ready:
self.parent.ui.start_first_reconstruction_pushButton.setStyleSheet(interact_me_style)
else:
self.parent.ui.start_first_reconstruction_pushButton.setStyleSheet(normal_style)
23 changes: 0 additions & 23 deletions src/hyperctui/autonomous_reconstruction/help_automatic_angles.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def __init__(self, parent=None):

self.initialization()
self.update_display_regions()
self.check_state_ok_button()

def initialization(self):
o_init = InitializationSelectEvaluationRegions(parent=self, grand_parent=self.parent)
Expand Down Expand Up @@ -154,6 +155,7 @@ def checkButton_clicked(self):
self.save_table()
self.update_display_regions()
self.check_table_state()
self.check_state_ok_button()

def check_table_content(self):
"""
Expand Down Expand Up @@ -211,6 +213,25 @@ def check_table_state(self):
o_table.set_item_state(row=_row, column=ColumnIndex.to_value, editable=_state)
o_table.unblock_signals()

def is_ok_button_ready(self):
evaluation_regions = self.parent.evaluation_regions
nbr_region_enabled = 0
for _key in evaluation_regions.keys():
if evaluation_regions[_key][EvaluationRegionKeys.state]:
nbr_region_enabled += 1

if nbr_region_enabled > 0:
return True

return False

def check_state_ok_button(self):
if self.is_ok_button_ready():
self.ui.pushButton.setEnabled(True)
else:
self.ui.pushButton.setEnabled(False)

def accept(self):
self.save_table()
self.parent.update_autonomous_widgets()
self.close()
4 changes: 0 additions & 4 deletions src/hyperctui/hyperctui.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,10 +367,6 @@ def projections_angles_automatic_button_clicked(self):
o_event = AutonomousReconstructionHandler(parent=self)
o_event.projections_angles_automatic_button_clicked()

def projections_automatic_help_clicked(self):
o_event = AutonomousReconstructionHandler(parent=self)
o_event.projections_automatic_help_clicked()

def evaluation_frequency_help_clicked(self):
o_event = AutonomousReconstructionHandler(parent=self)
o_event.evaluation_frequency_help_clicked()
Expand Down
52 changes: 0 additions & 52 deletions src/hyperctui/ui/help_automatic_angle.ui

This file was deleted.

Loading

0 comments on commit 73c9659

Please sign in to comment.