diff --git a/src/hyperctui/autonomous_reconstruction/select_tof_regions.py b/src/hyperctui/autonomous_reconstruction/select_tof_regions.py index 34b6448..6edf547 100644 --- a/src/hyperctui/autonomous_reconstruction/select_tof_regions.py +++ b/src/hyperctui/autonomous_reconstruction/select_tof_regions.py @@ -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 @@ -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() @@ -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]) diff --git a/src/hyperctui/hyperctui.py b/src/hyperctui/hyperctui.py index cd4e778..b495ccc 100644 --- a/src/hyperctui/hyperctui.py +++ b/src/hyperctui/hyperctui.py @@ -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() @@ -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, diff --git a/src/hyperctui/ui/select_tof_regions.ui b/src/hyperctui/ui/select_tof_regions.ui index 074f67f..84a9d6f 100644 --- a/src/hyperctui/ui/select_tof_regions.ui +++ b/src/hyperctui/ui/select_tof_regions.ui @@ -261,6 +261,13 @@ + + + + Cancel + + + @@ -306,8 +313,8 @@ projections_changed() - 570 - 76 + 546 + 87 734 @@ -338,8 +345,8 @@ instrument_settings_changed() - 284 - 443 + 319 + 562 730 @@ -354,8 +361,8 @@ instrument_settings_changed() - 581 - 441 + 587 + 562 729 @@ -370,8 +377,8 @@ table_changed() - 386 - 617 + 526 + 940 719 @@ -386,8 +393,8 @@ accept() - 673 - 794 + 666 + 1030 569 @@ -395,11 +402,28 @@ + + pushButton_2 + clicked() + MainWindow + cancel() + + + 56 + 1008 + + + 151 + 1010 + + + table_changed() projections_changed() instrument_settings_changed() accept() + cancel()