def __init__(self): super().__init__(show_automatic_box=True) main_box = gui.widgetBox(self.controlArea, "", orientation="vertical", width=self.CONTROL_AREA_WIDTH - 10, height=600) button_box = gui.widgetBox(main_box, "", orientation="horizontal", width=self.CONTROL_AREA_WIDTH-25) gui.button(button_box, self, "Send Free Input Parameters", height=50, callback=self.send_free_input_parameters) tabs = gui.tabWidget(main_box) tab_free_in = gui.createTabPage(tabs, "Free Input Parameters") self.scrollarea_free_in = QScrollArea(tab_free_in) self.scrollarea_free_in.setMinimumWidth(self.CONTROL_AREA_WIDTH-45) self.scrollarea_free_in.setMinimumHeight(260) self.text_area_free_in = gui.textArea(height=500, width=self.CONTROL_AREA_WIDTH-65, readOnly=False) self.text_area_free_in.setText(self.free_input_parameters) self.scrollarea_free_in.setWidget(self.text_area_free_in) self.scrollarea_free_in.setWidgetResizable(1) tab_free_in.layout().addWidget(self.scrollarea_free_in, alignment=Qt.AlignHCenter)
def __init__(self): super().__init__(show_automatic_box=True) if self.IS_FIX: self.fix_input() crystal_box = gui.widgetBox(self.controlArea, "Crystal Structure", orientation="vertical", width=self.CONTROL_AREA_WIDTH - 10, height=600) button_box = gui.widgetBox(crystal_box, "", orientation="horizontal", width=self.CONTROL_AREA_WIDTH-25) gui.button(button_box, self, "Send Crystal Structure", height=50, callback=self.send_fit_initialization) self.crystal_structure_tabs = gui.tabWidget(crystal_box) self.crystal_structure_box_array = [] for index in range(len(self.a)): crystal_structure_tab = gui.createTabPage(self.crystal_structure_tabs, "Diff. Patt. " + str(index + 1)) crystal_structure_box = CrystalStructureBox(widget=self, parent=crystal_structure_tab, index = index, a = self.a[index], a_fixed = self.a_fixed[index], a_has_min = self.a_has_min[index], a_min = self.a_min[index], a_has_max = self.a_has_max[index], a_max = self.a_max[index], a_function = self.a_function[index], a_function_value = self.a_function_value[index], symmetry = self.symmetry[index], use_structure = self.use_structure[index], formula = self.formula[index], intensity_scale_factor = self.intensity_scale_factor[index], intensity_scale_factor_fixed = self.intensity_scale_factor_fixed[index], intensity_scale_factor_has_min = self.intensity_scale_factor_has_min[index], intensity_scale_factor_min = self.intensity_scale_factor_min[index], intensity_scale_factor_has_max = self.intensity_scale_factor_has_max[index], intensity_scale_factor_max = self.intensity_scale_factor_max[index], intensity_scale_factor_function = self.intensity_scale_factor_function[index], intensity_scale_factor_function_value= self.intensity_scale_factor_function_value[index], reflections = self.reflections[index], limit = self.limit[index], limit_type = self.limit_type[index]) self.crystal_structure_box_array.append(crystal_structure_box)
def build_plot_fit(self): fit_global_parameter = self.fit_global_parameters if self.fitted_fit_global_parameters is None else self.fitted_fit_global_parameters self.plot_fit = [] self.tabs_plot_fit_data.clear() for index in range(1 if fit_global_parameter is None else len(fit_global_parameter.fit_initialization.diffraction_patterns)): tab_plot_fit_data = gui.createTabPage(self.tabs_plot_fit_data, "Diff. Patt. " + str(index+1)) plot_fit = PlotWindow() plot_fit.setDefaultPlotLines(True) plot_fit.setActiveCurveColor(color="#00008B") plot_fit.setGraphXLabel(r"2$\theta$ (deg)") plot_fit.setGraphYLabel("Intensity") self.plot_fit.append(plot_fit) tab_plot_fit_data.layout().addWidget(plot_fit)
def __init__(self): super().__init__(show_automatic_box=True) main_box = gui.widgetBox(self.controlArea, "Fitter Setting", orientation="vertical", width=self.CONTROL_AREA_WIDTH) button_box = gui.widgetBox(main_box, "", orientation="vertical", width=self.CONTROL_AREA_WIDTH-15, height=70) button_box_1 = gui.widgetBox(button_box, "", orientation="horizontal") self.fit_button = gui.button(button_box_1, self, "Fit", height=40, callback=self.do_fit) self.fit_button.setStyleSheet("color: #252468") font = QFont(self.fit_button.font()) font.setBold(True) font.setPixelSize(18) self.fit_button.setFont(font) self.stop_fit_button = gui.button(button_box_1, self, "STOP", height=40, callback=self.stop_fit) self.stop_fit_button.setStyleSheet("color: red") font = QFont(self.stop_fit_button.font()) font.setBold(True) font.setItalic(True) self.stop_fit_button.setFont(font) button_box_2 = gui.widgetBox(button_box, "", orientation="horizontal") gui.button(button_box_2, self, "Send Current Fit", height=40, callback=self.send_current_fit) gui.button(button_box_2, self, "Save Data", height=40, callback=self.save_data) orangegui.separator(main_box) self.cb_fitter = orangegui.comboBox(main_box, self, "fitter_name", label="Fit algorithm", items=FitterName.tuple(), orientation="horizontal") iteration_box = gui.widgetBox(main_box, "", orientation="horizontal", width=250) gui.lineEdit(iteration_box, self, "n_iterations", "Nr. Iterations", labelWidth=80, valueType=int, validator=QIntValidator()) orangegui.checkBox(iteration_box, self, "is_incremental", "Incremental") iteration_box = gui.widgetBox(main_box, "", orientation="vertical", width=250) self.le_current_iteration = gui.lineEdit(iteration_box, self, "current_iteration", "Current Iteration", labelWidth=120, valueType=int, orientation="horizontal") self.le_current_iteration.setReadOnly(True) self.le_current_iteration.setStyleSheet("background-color: #FAFAB0; color: #252468") font = QFont(self.le_current_iteration.font()) font.setBold(True) self.le_current_iteration.setFont(font) orangegui.separator(main_box) self.plot_box = gui.widgetBox(main_box, "Plotting Options", orientation="vertical", width=self.CONTROL_AREA_WIDTH-20) self.cb_interactive = orangegui.checkBox(self.plot_box, self, "is_interactive", "Refresh Plots while fitting", callback=self.set_interactive) orangegui.separator(self.plot_box, height=8) self.cb_show_wss_gof = orangegui.checkBox(self.plot_box, self, "show_wss_gof", "Refresh W.S.S. and G.o.F. plots" ) orangegui.separator(self.plot_box) self.cb_show_ipf = orangegui.checkBox(self.plot_box, self, "show_ipf", "Refresh Instrumental Profile plots") orangegui.separator(self.plot_box) self.cb_show_shift = orangegui.checkBox(self.plot_box, self, "show_shift", "Refresh Calibration Shift plots") orangegui.separator(self.plot_box) self.cb_show_size = orangegui.checkBox(self.plot_box, self, "show_size", "Refresh Size Distribution plot") orangegui.separator(self.plot_box) self.cb_show_warren = orangegui.checkBox(self.plot_box, self, "show_warren", "Refresh Warren's plot") self.set_interactive() tab_free_out = gui.widgetBox(main_box, "Free Output Parameters", orientation="vertical") self.scrollarea_free_out = QScrollArea(tab_free_out) self.scrollarea_free_out.setMinimumWidth(self.CONTROL_AREA_WIDTH-55) self.scrollarea_free_out.setMaximumHeight(170) def write_text(): self.free_output_parameters_text = self.text_area_free_out.toPlainText() self.text_area_free_out = gui.textArea(height=1000, width=1000, readOnly=False) self.text_area_free_out.setText(self.free_output_parameters_text) self.text_area_free_out.textChanged.connect(write_text) self.scrollarea_free_out.setWidget(self.text_area_free_out) self.scrollarea_free_out.setWidgetResizable(1) tab_free_out.layout().addWidget(self.scrollarea_free_out, alignment=Qt.AlignHCenter) self.tabs = gui.tabWidget(self.mainArea) self.tab_fit_in = gui.createTabPage(self.tabs, "Fit Input Parameters") self.tab_plot = gui.createTabPage(self.tabs, "Plots") self.tab_fit_out = gui.createTabPage(self.tabs, "Fit Output Parameters") self.tabs_plot = gui.tabWidget(self.tab_plot) self.tab_plot_fit_data = gui.createTabPage(self.tabs_plot, "Fit") self.tab_plot_fit_wss = gui.createTabPage(self.tabs_plot, "W.S.S.") self.tab_plot_fit_gof = gui.createTabPage(self.tabs_plot, "G.o.F.") self.tab_plot_ipf = gui.createTabPage(self.tabs_plot, "Instrumental Profile") self.tab_plot_size = gui.createTabPage(self.tabs_plot, "Size Distribution") self.tab_plot_strain = gui.createTabPage(self.tabs_plot, "Warren's Plot") self.std_output = gui.textArea(height=100, width=800) self.std_output.setStyleSheet("font-family: Courier, monospace;") out_box = gui.widgetBox(self.mainArea, "System Output", addSpace=False, orientation="horizontal") out_box.layout().addWidget(self.std_output) self.tabs_plot_fit_data = gui.tabWidget(self.tab_plot_fit_data) self.tabs_plot_ipf = gui.tabWidget(self.tab_plot_ipf) self.tab_plot_fwhm = gui.createTabPage(self.tabs_plot_ipf, "Caglioti's FWHM") self.tab_plot_eta = gui.createTabPage(self.tabs_plot_ipf, "Caglioti's \u03b7") self.tab_plot_lab6 = gui.createTabPage(self.tabs_plot_ipf, "LaB6 Tan Correction") self.build_plot_fit() self.plot_fit_wss = PlotWindow() self.plot_fit_wss.setDefaultPlotLines(True) self.plot_fit_wss.setActiveCurveColor(color="#00008B") self.plot_fit_wss.setGraphXLabel("Iteration") self.plot_fit_wss.setGraphYLabel("WSS") self.tab_plot_fit_wss.layout().addWidget(self.plot_fit_wss) self.plot_fit_gof = PlotWindow() self.plot_fit_gof.setDefaultPlotLines(True) self.plot_fit_gof.setActiveCurveColor(color="#00008B") self.plot_fit_gof.setGraphXLabel("Iteration") self.plot_fit_gof.setGraphYLabel("GOF") self.tab_plot_fit_gof.layout().addWidget(self.plot_fit_gof) self.plot_size = PlotWindow() self.plot_size.setDefaultPlotLines(True) self.plot_size.setActiveCurveColor(color="#00008B") self.plot_size.setGraphTitle("Crystalline Domains Size Distribution") self.plot_size.setGraphXLabel(r"D [nm]") self.plot_size.setGraphYLabel("Frequency") self.tab_plot_size.layout().addWidget(self.plot_size) self.plot_strain = PlotWindow(control=True) legendsDockWidget = LegendsDockWidget(plot=self.plot_strain) self.plot_strain._legendsDockWidget = legendsDockWidget self.plot_strain._dockWidgets.append(legendsDockWidget) self.plot_strain.addDockWidget(qt.Qt.RightDockWidgetArea, legendsDockWidget) self.plot_strain._legendsDockWidget.setFixedWidth(120) self.plot_strain.getLegendsDockWidget().show() self.plot_strain.setDefaultPlotLines(True) self.plot_strain.setActiveCurveColor(color="#00008B") self.plot_strain.setGraphTitle("Warren's plot") self.plot_strain.setGraphXLabel(r"L [nm]") self.plot_strain.setGraphYLabel("$\sqrt{<{\Delta}L^{2}>}$ [nm]") self.tab_plot_strain.layout().addWidget(self.plot_strain) box = gui.widgetBox(self.tab_plot_fwhm, "", orientation="horizontal") boxl = gui.widgetBox(box, "", orientation="vertical") boxr = gui.widgetBox(box, "", orientation="vertical", width=150) def set_fwhm_autoscale(): self.le_fwhm_xmin.setEnabled(self.fwhm_autoscale==0) self.le_fwhm_xmax.setEnabled(self.fwhm_autoscale==0) self.le_fwhm_ymin.setEnabled(self.fwhm_autoscale==0) self.le_fwhm_ymax.setEnabled(self.fwhm_autoscale==0) orangegui.checkBox(boxr, self, "fwhm_autoscale", "Autoscale", callback=set_fwhm_autoscale) self.le_fwhm_xmin = gui.lineEdit(boxr, self, "fwhm_xmin", "2\u03b8 min", labelWidth=70, valueType=float) self.le_fwhm_xmax = gui.lineEdit(boxr, self, "fwhm_xmax", "2\u03b8 max", labelWidth=70, valueType=float) self.le_fwhm_ymin = gui.lineEdit(boxr, self, "fwhm_ymin", "FWHM min", labelWidth=70, valueType=float) self.le_fwhm_ymax = gui.lineEdit(boxr, self, "fwhm_ymax", "FWHM max", labelWidth=70, valueType=float) gui.button(boxr, self, "Refresh", height=40, callback=self.refresh_caglioti_fwhm) set_fwhm_autoscale() self.plot_ipf_fwhm = PlotWindow() self.plot_ipf_fwhm.setDefaultPlotLines(True) self.plot_ipf_fwhm.setActiveCurveColor(color="#00008B") self.plot_ipf_fwhm.setGraphXLabel("2\u03b8 (deg)") self.plot_ipf_fwhm.setGraphYLabel("FWHM (deg)") boxl.layout().addWidget(self.plot_ipf_fwhm) box = gui.widgetBox(self.tab_plot_eta, "", orientation="horizontal") boxl = gui.widgetBox(box, "", orientation="vertical") boxr = gui.widgetBox(box, "", orientation="vertical", width=150) def set_eta_autoscale(): self.le_eta_xmin.setEnabled(self.eta_autoscale==0) self.le_eta_xmax.setEnabled(self.eta_autoscale==0) self.le_eta_ymin.setEnabled(self.eta_autoscale==0) self.le_eta_ymax.setEnabled(self.eta_autoscale==0) orangegui.checkBox(boxr, self, "eta_autoscale", "Autoscale", callback=set_eta_autoscale) self.le_eta_xmin = gui.lineEdit(boxr, self, "eta_xmin", "2\u03b8 min", labelWidth=70, valueType=float) self.le_eta_xmax = gui.lineEdit(boxr, self, "eta_xmax", "2\u03b8 max", labelWidth=70, valueType=float) self.le_eta_ymin = gui.lineEdit(boxr, self, "eta_ymin", "\u03b7 min", labelWidth=70, valueType=float) self.le_eta_ymax = gui.lineEdit(boxr, self, "eta_ymax", "\u03b7 max", labelWidth=70, valueType=float) gui.button(boxr, self, "Refresh", height=40, callback=self.refresh_caglioti_eta) set_eta_autoscale() self.plot_ipf_eta = PlotWindow() self.plot_ipf_eta.setDefaultPlotLines(True) self.plot_ipf_eta.setActiveCurveColor(color="#00008B") self.plot_ipf_eta.setGraphXLabel("2\u03b8 (deg)") self.plot_ipf_eta.setGraphYLabel("\u03b7") boxl.layout().addWidget(self.plot_ipf_eta) box = gui.widgetBox(self.tab_plot_lab6, "", orientation="horizontal") boxl = gui.widgetBox(box, "", orientation="vertical") boxr = gui.widgetBox(box, "", orientation="vertical", width=150) def set_lab6_autoscale(): self.le_lab6_xmin.setEnabled(self.lab6_autoscale==0) self.le_lab6_xmax.setEnabled(self.lab6_autoscale==0) self.le_lab6_ymin.setEnabled(self.lab6_autoscale==0) self.le_lab6_ymax.setEnabled(self.lab6_autoscale==0) orangegui.checkBox(boxr, self, "lab6_autoscale", "Autoscale", callback=set_lab6_autoscale) self.le_lab6_xmin = gui.lineEdit(boxr, self, "lab6_xmin", "2\u03b8 min", labelWidth=70, valueType=float) self.le_lab6_xmax = gui.lineEdit(boxr, self, "lab6_xmax", "2\u03b8 max", labelWidth=70, valueType=float) self.le_lab6_ymin = gui.lineEdit(boxr, self, "lab6_ymin", "\u0394(2\u03b8) min", labelWidth=70, valueType=float) self.le_lab6_ymax = gui.lineEdit(boxr, self, "lab6_ymax", "\u0394(2\u03b8) max", labelWidth=70, valueType=float) gui.button(boxr, self, "Refresh", height=40, callback=self.refresh_lab6) set_lab6_autoscale() self.plot_ipf_lab6 = PlotWindow() self.plot_ipf_lab6.setDefaultPlotLines(True) self.plot_ipf_lab6.setActiveCurveColor(color="#00008B") self.plot_ipf_lab6.setGraphXLabel("2\u03b8 (deg)") self.plot_ipf_lab6.setGraphYLabel("\u0394(2\u03b8) (deg)") boxl.layout().addWidget(self.plot_ipf_lab6) # ------------------- self.table_fit_in = self.create_table_widget(is_output=False) self.tab_fit_in.layout().addWidget(self.table_fit_in, alignment=Qt.AlignHCenter) # ------------------- self.table_fit_out = self.create_table_widget() self.tab_fit_out.layout().addWidget(self.table_fit_out, alignment=Qt.AlignHCenter)
def set_data(self, data): if not data is None: try: self.fit_global_parameters = data.duplicate() diffraction_patterns = self.fit_global_parameters.fit_initialization.diffraction_patterns crystal_structures = self.fit_global_parameters.fit_initialization.crystal_structures if diffraction_patterns is None: raise ValueError("No Diffraction Pattern in input data!") if len(diffraction_patterns) != len(self.crystal_structure_box_array): recycle = ConfirmDialog.confirmed(message="Number of Diffraction Patterns changed:\ndo you want to use the existing structures where possible?\n\nIf yes, check for possible incongruences", title="Warning") self.crystal_structure_tabs.clear() self.crystal_structure_box_array = [] for index in range(len(diffraction_patterns)): crystal_structure_tab = gui.createTabPage(self.crystal_structure_tabs, "Diff. Patt. " + str(index + 1)) if recycle and index < len(self.a): #keep the existing crystal_structure_box = CrystalStructureBox(widget=self, parent=crystal_structure_tab, index = index, a = self.a[index], a_fixed = self.a_fixed[index], a_has_min = self.a_has_min[index], a_min = self.a_min[index], a_has_max = self.a_has_max[index], a_max = self.a_max[index], a_function = self.a_function[index], a_function_value = self.a_function_value[index], symmetry = self.symmetry[index], use_structure = self.use_structure[index], formula = self.formula[index], intensity_scale_factor = self.intensity_scale_factor[index], intensity_scale_factor_fixed = self.intensity_scale_factor_fixed[index], intensity_scale_factor_has_min = self.intensity_scale_factor_has_min[index], intensity_scale_factor_min = self.intensity_scale_factor_min[index], intensity_scale_factor_has_max = self.intensity_scale_factor_has_max[index], intensity_scale_factor_max = self.intensity_scale_factor_max[index], intensity_scale_factor_function = self.intensity_scale_factor_function[index], intensity_scale_factor_function_value= self.intensity_scale_factor_function_value[index], reflections = self.reflections[index], limit = self.limit[index], limit_type = self.limit_type[index]) else: crystal_structure_box = CrystalStructureBox(widget=self, parent=crystal_structure_tab, index = index) self.crystal_structure_box_array.append(crystal_structure_box) elif not crystal_structures is None: for index in range(len(crystal_structures)): self.crystal_structure_box_array[index].set_data(crystal_structures[index]) self.dumpSettings() if self.is_automatic_run: self.send_fit_initialization() except Exception as e: QMessageBox.critical(self, "Error", str(e), QMessageBox.Ok) if self.IS_DEVELOP: raise e