def load_and_plot(self, hidra_file_name): try: o_load = Load(parent=self.parent) o_load.load(project_file=hidra_file_name) except RuntimeError as run_err: pop_message(self, 'Failed to load {}'.format(hidra_file_name), str(run_err), 'error') except KeyError as key_err: pop_message(self, 'Failed to load {}'.format(hidra_file_name), str(key_err), 'error') self.parent.current_root_statusbar_message = "Working with: {} " \ "\t\t\t\t Project Name: {}" \ "".format(hidra_file_name, self.parent._project_name) self.parent.ui.statusbar.showMessage( self.parent.current_root_statusbar_message) try: o_plot = Plot(parent=self.parent) o_plot.plot_diff_data(plot_model=False) o_plot.reset_fitting_plot() except RuntimeError as run_err: pop_message(self, 'Failed to plot {}'.format(hidra_file_name), str(run_err), 'error') try: o_fit = Fit(parent=self.parent) o_fit.initialize_fitting_table() # enabled all fitting widgets and main plot o_gui = GuiUtilities(parent=self.parent) o_gui.check_if_fitting_widgets_can_be_enabled() o_gui.enabled_sub_runs_interation_widgets(True) # o_gui.enabled_fitting_widgets(True) o_gui.enabled_data_fit_plot(True) o_gui.enabled_peak_ranges_widgets(True) o_gui.enabled_1dplot_widgets(True) except RuntimeError as run_err: pop_message( self, 'Failed to initialize widgets for {}'.format(hidra_file_name), str(run_err), 'error')
def setup_ui(self): """define the layout, widgets and signals""" # promote self.ui.graphicsView_fitResult = qt_util.promote_widget(self, self.ui.graphicsView_fitResult_frame, GeneralDiffDataView) self.ui.graphicsView_fitResult.setEnabled(False) self.ui.graphicsView_fitResult.set_subplots(1, 1) self.ui.graphicsView_plot2D = qt_util.promote_widget(self, self.ui.graphicsView_2dPlot_frame, MplGraphicsViewContourPlot) self.ui.tableView_fitSummary = qt_util.promote_widget(self, self.ui.tableView_fitSummary_frame, FitResultTable) self._promote_peak_fit_setup() self._init_widgets() # set up handling self.ui.pushButton_browseHDF.clicked.connect(self.browse_hdf) self.ui.lineEdit_listSubRuns.returnPressed.connect(self.plot_diff_data) self.ui.pushButton_FitPeaks.clicked.connect(self.fit_peaks) self.ui.horizontalScrollBar_SubRuns.valueChanged.connect(self.plot_scan) self.ui.radioButton_individualSubRuns.clicked.connect(self.individual_sub_runs) self.ui.radioButton_listSubRuns.clicked.connect(self.list_sub_runs) self.ui.actionQuit.triggered.connect(self.do_quit) self.ui.actionSave.triggered.connect(self.save) self.ui.actionSaveAs.triggered.connect(self.save_as) self.ui.actionAdvanced_Peak_Fit_Settings.triggered.connect(self.do_launch_adv_fit) self.ui.pushButton_exportCSV.clicked.connect(self.export_csv) self.ui.actionQuick_Fit_Result_Check.triggered.connect(self.do_make_movie) self.ui.lineEdit_subruns_2dplot.returnPressed.connect(self.list_subruns_2dplot_returned) self.ui.lineEdit_subruns_2dplot.textChanged.connect(self.list_subruns_2dplot_changed) self.ui.pushButton_save_peak_range.clicked.connect(self.clicked_save_peak_range) self.ui.pushButton_load_peak_range.clicked.connect(self.clicked_load_peak_range) self.ui.tableView_fitSummary.itemSelectionChanged.connect(self.fit_result_table_selection_changed) self.ui.radioButton_fit_value.clicked.connect(self.fit_table_radio_buttons) self.ui.radioButton_fit_error.clicked.connect(self.fit_table_radio_buttons) self.ui.spinBox_peak_index.valueChanged.connect(self.fit_table_radio_buttons) self.ui.comboBox_xaxisNames.currentIndexChanged.connect(self.axis_1d_changed) self.ui.comboBox_yaxisNames.currentIndexChanged.connect(self.axis_1d_changed) self.ui.plot1d_xaxis_peak_label_comboBox.currentIndexChanged.connect(self.axis_1d_changed) self.ui.plot1d_yaxis_peak_label_comboBox.currentIndexChanged.connect(self.axis_1d_changed) self.ui.comboBox_xaxisNames_2dplot.currentIndexChanged.connect(self.axis_2d_changed) self.ui.comboBox_yaxisNames_2dplot.currentIndexChanged.connect(self.axis_2d_changed) self.ui.comboBox_zaxisNames_2dplot.currentIndexChanged.connect(self.axis_2d_changed) self.ui.plot2d_xaxis_peak_label_comboBox.currentIndexChanged.connect(self.axis_2d_changed) self.ui.plot2d_yaxis_peak_label_comboBox.currentIndexChanged.connect(self.axis_2d_changed) self.ui.plot2d_zaxis_peak_label_comboBox.currentIndexChanged.connect(self.axis_2d_changed) self.ui.radioButton_contour.clicked.connect(self.axis_2d_changed) self.ui.radioButton_3dline.clicked.connect(self.axis_2d_changed) self.ui.radioButton_3dscatter.clicked.connect(self.axis_2d_changed) self.ui.peak_range_table.cellChanged.connect(self.peak_range_table_changed) # tracker for sample log names and peak parameter names self._sample_log_name_set = set() self._function_param_name_set = set() # mutexes self._sample_log_names_mutex = False # TODO - 20181124 - New GUI parameters (After FitPeaks) # checkBox_showFitError # checkBox_showFitValue # others # TODO - 20181124 - Make this table's column flexible! self.ui.tableView_fitSummary.setup(peak_param_names=list()) o_gui = GuiUtilities(parent=self) o_gui.enabled_fitting_widgets(False) o_gui.enabled_1dplot_widgets(False) o_gui.check_axis1d_status() o_gui.enabled_2dplot_widgets(False) o_gui.check_axis2d_status() o_gui.make_visible_listsubruns_warning(False) o_gui.enabled_export_csv_widgets(False) o_gui.enabled_peak_ranges_widgets(False) o_gui.enabled_save_peak_range_widget(False) o_gui.enabled_sub_runs_interation_widgets(False) # for debugging only self.ui.radioButton_contour.setEnabled(False) self.ui.radioButton_3dline.setEnabled(False)
def browse_load_plot_hdf(self): if self.parent._core is None: raise RuntimeError('Not set up yet!') # o_utility = Utilities(parent=self.parent) # hydra_file_name = o_utility.get_default_hdf() hidra_file_name = None if hidra_file_name is None: # No default Hidra file: browse the file file_filter = 'HDF (*.hdf);H5 (*.h5)' hidra_file_name = browse_file(self.parent, 'HIDRA Project File', os.getcwd(), file_filter, file_list=False, save_file=False) if hidra_file_name is None: return # user clicked cancel self.parent.current_hidra_file_name = hidra_file_name try: o_load = Load(parent=self.parent) o_load.load(project_file=hidra_file_name) except RuntimeError as run_err: pop_message(self, 'Failed to load {}'.format(hidra_file_name), str(run_err), 'error') except KeyError as key_err: pop_message(self, 'Failed to load {}'.format(hidra_file_name), str(key_err), 'error') self.parent.current_root_statusbar_message = "Working with: {} " \ "\t\t\t\t Project Name: {}" \ "".format(hidra_file_name, self.parent._project_name) self.parent.ui.statusbar.showMessage( self.parent.current_root_statusbar_message) try: o_plot = Plot(parent=self.parent) o_plot.plot_diff_data(plot_model=False) o_plot.reset_fitting_plot() except RuntimeError as run_err: pop_message(self, 'Failed to plot {}'.format(hidra_file_name), str(run_err), 'error') try: o_fit = Fit(parent=self.parent) o_fit.initialize_fitting_table() # enabled all fitting widgets and main plot o_gui = GuiUtilities(parent=self.parent) o_gui.check_if_fitting_widgets_can_be_enabled() o_gui.enabled_sub_runs_interation_widgets(True) # o_gui.enabled_fitting_widgets(True) o_gui.enabled_data_fit_plot(True) o_gui.enabled_peak_ranges_widgets(True) o_gui.enabled_1dplot_widgets(True) except RuntimeError as run_err: pop_message( self, 'Failed to initialize widgets for {}'.format(hidra_file_name), str(run_err), 'error')