Skip to content

Commit

Permalink
working on providing option to cancel tof selection. this refs #58
Browse files Browse the repository at this point in the history
  • Loading branch information
JeanBilheux committed Apr 10, 2023
1 parent 73c9659 commit 03f4875
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 10 deletions.
13 changes: 13 additions & 0 deletions src/hyperctui/autonomous_reconstruction/select_tof_regions.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class SelectTofRegions(QMainWindow):

top_roi_id = None

ok_clicked = False

# used in case the value entered by the user are not valid
previous_distance_source_detector = None
previous_detector_offset = None
Expand All @@ -47,6 +49,7 @@ def __init__(self, parent=None):
self.ui = load_ui(ui_full_path, baseinstance=self)
self.setWindowTitle("Select TOF regions")

self.parent.backup_tof_regions = self.parent.tof_regions
self.initialization()
self.load_time_spectra()
self.calculate_lambda_axis()
Expand Down Expand Up @@ -370,10 +373,20 @@ def regions_manually_moved(self):
# self.update_evaluation_regions_dict()

def accept(self):
self.ok_clicked = True
self.save_table()
self.parent.update_autonomous_widgets()
self.close()

def cancel(self):
self.close()

def closeEvent(self, a0):
if self.ok_clicked:
pass
else:
self.parent.tof_regions = self.parent.backup_tof_regions

@staticmethod
def sort(value1: float, value2: float):
minimum_value = np.min([value1, value2])
Expand Down
6 changes: 6 additions & 0 deletions src/hyperctui/hyperctui.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ class HyperCTui(QMainWindow):
EvaluationRegionKeys.id: None,
EvaluationRegionKeys.label_id: None,
}
# this will be a copy of evaluation regions used when user exit the view without using OK button
backup_evaluation_regions = None

# tof selection regions
tof_regions = OrderedDict()
Expand All @@ -155,6 +157,10 @@ class HyperCTui(QMainWindow):
EvaluationRegionKeys.id: None,
EvaluationRegionKeys.label_id: None
}

# this will be a copy of evaluation regions used when user exit the view without using OK button
backup_tof_regions = None

# dictionary that will store the 3D images (used in the TOF region selection)

image_data = {SessionKeys.image_0_degree: None,
Expand Down
44 changes: 34 additions & 10 deletions src/hyperctui/ui/select_tof_regions.ui
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,13 @@
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="pushButton_2">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
Expand Down Expand Up @@ -306,8 +313,8 @@
<slot>projections_changed()</slot>
<hints>
<hint type="sourcelabel">
<x>570</x>
<y>76</y>
<x>546</x>
<y>87</y>
</hint>
<hint type="destinationlabel">
<x>734</x>
Expand Down Expand Up @@ -338,8 +345,8 @@
<slot>instrument_settings_changed()</slot>
<hints>
<hint type="sourcelabel">
<x>284</x>
<y>443</y>
<x>319</x>
<y>562</y>
</hint>
<hint type="destinationlabel">
<x>730</x>
Expand All @@ -354,8 +361,8 @@
<slot>instrument_settings_changed()</slot>
<hints>
<hint type="sourcelabel">
<x>581</x>
<y>441</y>
<x>587</x>
<y>562</y>
</hint>
<hint type="destinationlabel">
<x>729</x>
Expand All @@ -370,8 +377,8 @@
<slot>table_changed()</slot>
<hints>
<hint type="sourcelabel">
<x>386</x>
<y>617</y>
<x>526</x>
<y>940</y>
</hint>
<hint type="destinationlabel">
<x>719</x>
Expand All @@ -386,20 +393,37 @@
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>673</x>
<y>794</y>
<x>666</x>
<y>1030</y>
</hint>
<hint type="destinationlabel">
<x>569</x>
<y>783</y>
</hint>
</hints>
</connection>
<connection>
<sender>pushButton_2</sender>
<signal>clicked()</signal>
<receiver>MainWindow</receiver>
<slot>cancel()</slot>
<hints>
<hint type="sourcelabel">
<x>56</x>
<y>1008</y>
</hint>
<hint type="destinationlabel">
<x>151</x>
<y>1010</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>table_changed()</slot>
<slot>projections_changed()</slot>
<slot>instrument_settings_changed()</slot>
<slot>accept()</slot>
<slot>cancel()</slot>
</slots>
</ui>

0 comments on commit 03f4875

Please sign in to comment.