def __init__(self): super().__init__(show_automatic_box=True) line_profiles_box = gui.widgetBox(self.controlArea, "Line Profiles", orientation="vertical", width=self.CONTROL_AREA_WIDTH - 10, height=600) button_box = gui.widgetBox(line_profiles_box, "", orientation="horizontal", width=self.CONTROL_AREA_WIDTH-25) gui.button(button_box, self, "Send Line Profiles", height=40, callback=self.send_line_profiles) self.line_profiles_tabs = gui.tabWidget(line_profiles_box) self.line_profiles_box_array = [] for index in range(len(self.reflections_of_phases)): line_profiles_tab = gui.createTabPage(self.line_profiles_tabs, DiffractionPattern.get_default_name(index)) line_profiles_box = LineProfileBox(widget=self, parent=line_profiles_tab, diffraction_pattern_index = index, reflections_of_phases = self.reflections_of_phases[index], limits = self.limits[index], limit_types = self.limit_types[index]) self.line_profiles_box_array.append(line_profiles_box) runaction = OWAction("Send Line Profiles", self) runaction.triggered.connect(self.send_line_profiles) self.addAction(runaction) orangegui.rubber(self.controlArea)
def __init__(self): super().__init__(show_automatic_box=True) self.main_box = gui.widgetBox(self.controlArea, self.get_parameter_name(), orientation="vertical", width=self.CONTROL_AREA_WIDTH - 10, height=self.get_height()) self.button_box = gui.widgetBox(self.main_box, "", orientation="horizontal", width=self.CONTROL_AREA_WIDTH - 25) gui.button(self.button_box, self, "Send " + self.get_parameter_name(), height=40, callback=self.send_parameter) self.build_main_box() orangegui.separator(self.main_box) self.parameter_tabs = gui.tabWidget(self.main_box) self.parameter_box_array = [] self.build_parameter_box_array() runaction = OWAction("Send " + self.get_parameter_name(), self) runaction.triggered.connect(self.send_parameter) self.addAction(runaction) orangegui.rubber(self.controlArea)
def __init__(self): super().__init__(show_automatic_box=True) main_box = gui.widgetBox(self.controlArea, "Phases", orientation="vertical", width=self.CONTROL_AREA_WIDTH - 5, height=self.get_height()) button_box = gui.widgetBox(main_box, "", orientation="horizontal", width=self.CONTROL_AREA_WIDTH - 25) gui.button(button_box, self, "Send Phases", height=50, callback=self.send_phases) tabs_button_box = gui.widgetBox(main_box, "", addSpace=False, orientation="horizontal") btns = [ gui.button(tabs_button_box, self, "Insert Phase Before", callback=self.insert_before), gui.button(tabs_button_box, self, "Insert Phase After", callback=self.insert_after), gui.button(tabs_button_box, self, "Remove Phase", callback=self.remove) ] for btn in btns: btn.setFixedHeight(35) self.phases_tabs = gui.tabWidget(main_box) self.phases_box_array = [] for index in range(len(self.a)): phase_tab = gui.createTabPage(self.phases_tabs, "Phase " + str(index + 1)) phase_box = self.get_phase_box_instance(index, phase_tab) self.phases_box_array.append(phase_box) runaction = OWAction("Send Phases", self) runaction.triggered.connect(self.send_phases) self.addAction(runaction) orangegui.rubber(self.controlArea)
def __init__(self): super().__init__(show_automatic_box=True) self.setFixedHeight(310) main_box = gui.widgetBox(self.controlArea, "Fit Initialization", orientation="vertical", width=self.CONTROL_AREA_WIDTH - 10, height=210) button_box = gui.widgetBox(main_box, "", orientation="horizontal", width=self.CONTROL_AREA_WIDTH - 25) gui.button(button_box, self, "Send Fit Initialization", height=40, callback=self.send_fit_initialization) fft_box = gui.widgetBox(main_box, "FFT", orientation="vertical", width=self.CONTROL_AREA_WIDTH - 30) gui.lineEdit(fft_box, self, "s_max", "S_max [nm-1]", labelWidth=250, valueType=float, validator=QDoubleValidator()) self.cb_n_step = orangegui.comboBox( fft_box, self, "n_step", label="FFT Steps", labelWidth=350, items=["1024", "2048", "4096", "8192", "16384", "32768", "65536"], sendSelectedValue=True, orientation="horizontal") orangegui.comboBox(fft_box, self, "fft_type", label="FFT Type", items=FFTTypes.tuple(), orientation="horizontal") orangegui.rubber(self.controlArea) runaction = OWAction("Send Fit Initialization", self) runaction.triggered.connect(self.send_fit_initialization) self.addAction(runaction)
def insert_after(self): current_index = self.phases_tabs.currentIndex() if ConfirmDialog.confirmed( parent=self, message="Confirm Insertion of a new element after " + self.phases_tabs.tabText(current_index) + "?"): phase_tab = gui.widgetBox(self.phases_tabs, addToLayout=0, margin=4) phase_box = self.get_empty_phase_box_instance( current_index + 1, phase_tab) phase_box.after_change_workspace_units() if current_index == self.phases_tabs.count() - 1: # LAST self.phases_tabs.addTab(phase_tab, "TEMP") self.phases_box_array.append(phase_box) else: self.phases_tabs.insertTab(current_index + 1, phase_tab, "TEMP") self.phases_box_array.insert(current_index + 1, phase_box) for index in range(current_index, self.phases_tabs.count()): self.phases_tabs.setTabText(index, Phase.get_default_name(index)) self.phases_box_array[index].index = index self.dumpSettings() self.phases_tabs.setCurrentIndex(current_index + 1)
def __init__(self): super().__init__(show_automatic_box=True) main_box = gui.widgetBox(self.controlArea, "", orientation="vertical", width=self.CONTROL_AREA_WIDTH - 10, height=500) button_box = gui.widgetBox(main_box, "", orientation="horizontal", width=self.CONTROL_AREA_WIDTH - 25) gui.button(button_box, self, "Send Free Input Parameters", height=40, 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(160) self.text_area_free_in = gui.textArea(height=400, 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) runaction = OWAction("Send Free Input Parameters", self) runaction.triggered.connect(self.send_free_input_parameters) self.addAction(runaction) orangegui.rubber(self.controlArea)
def __init__(self): super().__init__(show_automatic_box=True) self.setFixedHeight(410) main_box = gui.widgetBox(self.controlArea, "Line Profiles", orientation="vertical", width=self.CONTROL_AREA_WIDTH - 10, height=300) button_box = gui.widgetBox(main_box, "", orientation="horizontal", width=self.CONTROL_AREA_WIDTH - 25) gui.button(button_box, self, "Debye-Waller Parameters", height=40, callback=self.send_debye_waller) orangegui.comboBox(main_box, self, "use_single_parameter_set", label="Use single set of Parameters", labelWidth=350, orientation="horizontal", items=["No", "Yes"], callback=self.set_use_single_parameter_set, sendSelectedValue=False) orangegui.separator(main_box) self.debye_wallers_tabs = gui.tabWidget(main_box) self.set_use_single_parameter_set(on_init=True) runaction = OWAction("Send Debye-Waller Parameters", self) runaction.triggered.connect(self.send_debye_waller) self.addAction(runaction) orangegui.rubber(self.controlArea)
def init_main_box(self): contrast_factor_box = gui.widgetBox(self.main_box, "Elastic Constants", orientation="vertical", height=120, width=self.CONTROL_AREA_WIDTH - 10) gui.lineEdit(contrast_factor_box, self, "c11", "c11", labelWidth=90, valueType=float, callback=self.widget.dump_c11) gui.lineEdit(contrast_factor_box, self, "c12", "c12", labelWidth=90, valueType=float, callback=self.widget.dump_c12) gui.lineEdit(contrast_factor_box, self, "c44", "c44", labelWidth=90, valueType=float, callback=self.widget.dump_c44) text_area_box = gui.widgetBox(self.main_box, "Calculation Result", orientation="vertical", height=160, width=self.CONTROL_AREA_WIDTH - 10) self.text_area = gui.textArea(height=120, width=self.CONTROL_AREA_WIDTH - 40, readOnly=True) self.text_area.setText("") text_area_box.layout().addWidget(self.text_area)
def init_gui(self, container): caglioti_box_1 = gui.widgetBox(container, "Caglioti's FWHM", orientation="vertical", width=self.CONTROL_AREA_WIDTH - 20) caglioti_box_2 = gui.widgetBox(container, "Caglioti's \u03b7", orientation="vertical", width=self.CONTROL_AREA_WIDTH - 20) OWGenericWidget.create_box_in_widget(self, caglioti_box_1, "U", add_callback=True, trim=35) OWGenericWidget.create_box_in_widget(self, caglioti_box_1, "V", add_callback=True, trim=35) OWGenericWidget.create_box_in_widget(self, caglioti_box_1, "W", add_callback=True, trim=35) OWGenericWidget.create_box_in_widget(self, caglioti_box_2, "a", add_callback=True, trim=35) OWGenericWidget.create_box_in_widget(self, caglioti_box_2, "b", add_callback=True, trim=35) OWGenericWidget.create_box_in_widget(self, caglioti_box_2, "c", add_callback=True, trim=35)
def init_gui(self, container): gui.lineEdit(container, self, "phase_name", "Phase Name (will appear in tabs and plots)", labelWidth=260, valueType=str, callback=self.widget.dump_phase_name) self.cb_symmetry = orangegui.comboBox(container, self, "symmetry", label="Symmetry", items=Symmetry.tuple(), callback=self.set_symmetry, orientation="horizontal") OWGenericWidget.create_box_in_widget(self, container, "a", "a [nm]", add_callback=True, min_value=0.0, min_accepted=False, trim=5) orangegui.separator(container) structure_box = gui.widgetBox(container, "", orientation="vertical", width=self.CONTROL_AREA_WIDTH) self.structure_box_1 = gui.widgetBox(structure_box, "", orientation="vertical", width=self.CONTROL_AREA_WIDTH - 5, height=90) file_box = gui.widgetBox(self.structure_box_1, "", orientation="horizontal", width=self.CONTROL_AREA_WIDTH-10) self.le_cif_file = gui.lineEdit(file_box, self, value="cif_file", valueType=str, label="CIF File", labelWidth=50, callback=self.widget.dump_cif_file) orangegui.button(file_box, self, "...", callback=self.open_folders) gui.lineEdit(self.structure_box_1, self, "formula", "Chemical Formula", labelWidth=110, valueType=str, callback=self.widget.dump_formula) OWGenericWidget.create_box_in_widget(self, self.structure_box_1, "intensity_scale_factor", "I0", add_callback=True, min_value=0.0, min_accepted=False, trim=5) text_area_box = gui.widgetBox(structure_box, "Calculation Result", orientation="vertical", height=165, width=self.CONTROL_AREA_WIDTH - 10) self.text_area = gui.textArea(height=125, width=self.CONTROL_AREA_WIDTH - 30, readOnly=True) self.text_area.setText("") text_area_box.layout().addWidget(self.text_area) self.is_on_init = False
def init_gui(self, container): gui.lineEdit(container, self, "phase_name", "Phase Name (will appear in tabs and plots)", labelWidth=260, valueType=str, callback=self.widget.dump_phase_name) self.cb_symmetry = orangegui.comboBox(container, self, "symmetry", label="Symmetry", items=Symmetry.tuple(), callback=self.set_symmetry, orientation="horizontal") OWGenericWidget.create_box_in_widget(self, container, "a", "a [nm]", add_callback=True, min_value=0.0, min_accepted=False, trim=5) orangegui.separator(container) structure_box = gui.widgetBox(container, "", orientation="vertical", width=self.CONTROL_AREA_WIDTH) gui.lineEdit(structure_box, self, "formula", "Chemical Formula", labelWidth=110, valueType=str, callback=self.widget.dump_formula) OWGenericWidget.create_box_in_widget(self, structure_box, "intensity_scale_factor", "I0", add_callback=True, min_value=0.0, min_accepted=False, trim=5)
def init_gui(self, container): self.cb_active = orangegui.comboBox(container, self, "active", label="Active", items=["No", "Yes"], callback=self.set_active, orientation="horizontal") orangegui.separator(container) self.main_box = gui.widgetBox(container, "", orientation="vertical", width=self.CONTROL_AREA_WIDTH - 10) self.init_main_box()
def __init__(self, show_automatic_box=True): super().__init__() geom = QApplication.desktop().availableGeometry() if self.want_main_area: max_width = self.MAX_WIDTH_MAIN self.CONTROL_AREA_WIDTH = self.CONTROL_AREA_WIDTH_MAIN else: max_width = self.MAX_WIDTH_NO_MAIN self.CONTROL_AREA_WIDTH = self.CONTROL_AREA_WIDTH_NO_MAIN self.setGeometry( QRect(round(geom.width() * 0.01), round(geom.height() * 0.01), round(min(geom.width() * 0.95, max_width)), round(min(geom.height() * 0.95, self.get_max_height())))) self.setMinimumWidth(self.geometry().width() / 2) self.setMinimumHeight(self.geometry().height() / 2) self.setMaximumHeight(self.geometry().height()) self.setMaximumWidth(self.geometry().width()) self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.controlArea.setFixedWidth(self.CONTROL_AREA_WIDTH) self.general_options_box = gui.widgetBox(self.controlArea, "General Options", addSpace=True, orientation="horizontal") if show_automatic_box: orangegui.checkBox(self.general_options_box, self, 'is_automatic_run', 'Automatic') gui.button(self.general_options_box, self, "Reset Fields", callback=self.callResetSettings) gui.button(self.general_options_box, self, "Show Available Parameters", callback=self.show_available_parameters)
def create_wavelength_boxes(self): self.secondary_wavelengths_boxes = {} for key in wavelengths_data.keys(): self.secondary_wavelengths_boxes[key] = gui.widgetBox( self.secondary_box_2, key + " Secondary Wavelengths", orientation="vertical", width=self.CONTROL_AREA_WIDTH - 5, height=240) secondary_index = 2 for wavelenght in wavelengths_data[key]: if not wavelenght.is_principal: var_wl = "wavelength_" + str(secondary_index) var_we = "weight_" + str(secondary_index) label_wl = "\u03BB" + " " + str(secondary_index) + " [nm]" label_we = "weight " + str(secondary_index) OWGenericWidget.create_box_in_widget( self, self.secondary_wavelengths_boxes[key], var_wl, label=label_wl, label_width=50, add_callback=True, min_value=0.0, min_accepted=False, trim=25) OWGenericWidget.create_box_in_widget( self, self.secondary_wavelengths_boxes[key], var_we, label=label_we, label_width=50, add_callback=True, min_value=0.0, min_accepted=True, trim=25) secondary_index += 1 self.secondary_wavelengths_boxes[key].setVisible(False)
def init_main_box(self): OWGenericWidget.create_box_in_widget(self, self.main_box, "aa", add_callback=True, min_value=0.0, min_accepted=True, trim=25) OWGenericWidget.create_box_in_widget(self, self.main_box, "bb", add_callback=True, min_value=0.0, min_accepted=True, trim=25) invariant_box = gui.widgetBox(self.main_box, "Invariant Parameters", orientation="vertical", width=self.CONTROL_AREA_WIDTH - 10) self.cb_laue_id = orangegui.comboBox(invariant_box, self, "laue_id", label="Laue Group", items=LaueGroup.tuple(), callback=self.set_laue_id, orientation="horizontal") OWGenericWidget.create_box_in_widget(self, invariant_box, "e1", add_callback=True, trim=25) OWGenericWidget.create_box_in_widget(self, invariant_box, "e4", add_callback=True, trim=25)
def init_gui(self, container): orangegui.comboBox(container, self, "use_lorentz_factor", label="Add Lorentz Factor", items=["No", "Yes"], labelWidth=300, orientation="horizontal", callback=self.set_LorentzFactor) self.lorentz_box = gui.widgetBox(container, "", orientation="vertical", width=self.CONTROL_AREA_WIDTH - 20, height=30) self.lorentz_box_empty = gui.widgetBox(container, "", orientation="vertical", width=self.CONTROL_AREA_WIDTH - 20, height=30) orangegui.comboBox(self.lorentz_box, self, "lorentz_formula", label="Formula", items=LorentzFormula.tuple(), labelWidth=300, orientation="horizontal", callback=self.widget.dump_lorentz_formula) self.set_LorentzFactor() orangegui.separator(container) orangegui.comboBox(container, self, "use_polarization_factor", label="Add Polarization Factor", items=["No", "Yes"], labelWidth=300, orientation="horizontal", callback=self.set_Polarization) self.polarization_box = gui.widgetBox(container, "", orientation="vertical", width=self.CONTROL_AREA_WIDTH - 20, height=200) self.polarization_box_empty = gui.widgetBox( container, "", orientation="vertical", width=self.CONTROL_AREA_WIDTH - 20, height=200) gui.lineEdit(self.polarization_box, self, "degree_of_polarization", "Deg. Pol. (0\u2264Q\u22641)", labelWidth=300, valueType=float, callback=self.widget.dump_degree_of_polarization) orangegui.comboBox(self.polarization_box, self, "use_twotheta_mono", label="Use Monochromator", items=["No", "Yes"], labelWidth=300, orientation="horizontal", callback=self.set_Monochromator) self.monochromator_box = gui.widgetBox(self.polarization_box, "", orientation="vertical", width=self.CONTROL_AREA_WIDTH - 20, height=95) self.monochromator_box_empty = gui.widgetBox( self.polarization_box, "", orientation="vertical", width=self.CONTROL_AREA_WIDTH - 20, height=95) orangegui.comboBox(self.monochromator_box, self, "beampath", label="Beampath", items=Beampath.tuple(), labelWidth=300, orientation="horizontal", callback=self.widget.dump_beampath) gui.lineEdit(self.monochromator_box, self, "twotheta_mono", "2\u03B8 Monochromator [deg]", labelWidth=300, valueType=float, callback=self.widget.dump_twotheta_mono) self.set_Polarization()
def __init__(self, widget=None, widget_container=None, parent=None, diffraction_pattern_index=0, phase_index=0, use_debye_waller_factor=1, debye_waller_factor=0.1, debye_waller_factor_fixed=0, debye_waller_factor_has_min=0, debye_waller_factor_min=0.0, debye_waller_factor_has_max=0, debye_waller_factor_max=0.0, debye_waller_factor_function=0, debye_waller_factor_function_value=""): super(DebyeWallerOfPhaseBox, self).__init__() self.setLayout(QVBoxLayout()) self.layout().setAlignment(Qt.AlignTop) self.setFixedWidth(widget.CONTROL_AREA_WIDTH - 35) self.setFixedHeight(200) self.widget = widget self.widget_container = widget_container self.diffraction_pattern_index = diffraction_pattern_index self.phase_index = phase_index self.use_debye_waller_factor = use_debye_waller_factor self.debye_waller_factor = debye_waller_factor self.debye_waller_factor_fixed = debye_waller_factor_fixed self.debye_waller_factor_has_min = debye_waller_factor_has_min self.debye_waller_factor_min = debye_waller_factor_min self.debye_waller_factor_has_max = debye_waller_factor_has_max self.debye_waller_factor_max = debye_waller_factor_max self.debye_waller_factor_function = debye_waller_factor_function self.debye_waller_factor_function_value = debye_waller_factor_function_value self.CONTROL_AREA_WIDTH = widget.CONTROL_AREA_WIDTH - 65 parent.layout().addWidget(self) container = self orangegui.comboBox(container, self, "use_debye_waller_factor", label="Calculate", items=["No", "Yes"], labelWidth=250, orientation="horizontal", callback=self.set_dw) self.box_dw = gui.widgetBox(container, "", orientation="vertical", width=self.CONTROL_AREA_WIDTH - 10, height=30) self.box_dw_empty = gui.widgetBox(container, "", orientation="vertical", width=self.CONTROL_AREA_WIDTH - 10, height=30) OWGenericWidget.create_box_in_widget(self, self.box_dw, "debye_waller_factor", label="B [Å-2]", min_value=0.0, max_value=1.0, min_accepted=True, max_accepted=True, add_callback=True, trim=25) self.is_on_init = False
def init_main_box(self): self.cb_shape = orangegui.comboBox(self.main_box, self, "shape", label="Shape", items=Shape.tuple(), callback=self.set_shape, orientation="horizontal") self.cb_distribution = orangegui.comboBox( self.main_box, self, "distribution", label="Distribution", items=Distribution.tuple(), callback=self.set_distribution, orientation="horizontal") orangegui.separator(self.main_box) size_box = gui.widgetBox(self.main_box, "", orientation="vertical", width=self.CONTROL_AREA_WIDTH - 10) self.sigma_box = gui.widgetBox(size_box, "", orientation="vertical") OWGenericWidget.create_box_in_widget(self, self.sigma_box, "mu", label="\u03bc or D", add_callback=True, min_value=0.0, min_accepted=False, trim=25) OWGenericWidget.create_box_in_widget(self, self.sigma_box, "sigma", label="\u03c3", add_callback=True, min_value=0.0, min_accepted=False, trim=25) self.truncation_box = gui.widgetBox(size_box, "", orientation="vertical") OWGenericWidget.create_box_in_widget(self, self.truncation_box, "truncation", label="trunc.", add_callback=True, min_value=0.0, max_value=1.0, min_accepted=True, trim=25) self.cb_cube_face = orangegui.comboBox( self.truncation_box, self, "cube_face", label="Cube Face", items=WulffCubeFace.tuple(), callback=self.callback_cube_face, labelWidth=300, orientation="horizontal") self.saxs_box = gui.widgetBox(size_box, "", orientation="vertical") orangegui.comboBox(self.saxs_box, self, "add_saxs", label="Add SAXS", items=["No", "Yes"], labelWidth=300, orientation="horizontal", callback=self.set_add_saxs) self.normalize_box = gui.widgetBox(self.saxs_box, "", orientation="vertical") orangegui.comboBox(self.normalize_box, self, "normalize_to", label="Normalize to", items=Normalization.tuple(), callback=self.callback_normalize_to, labelWidth=300, orientation="horizontal") self.set_shape()
def insert_after(self): current_index = self.diffraction_pattern_tabs.currentIndex() if ConfirmDialog.confirmed( parent=self, message="Confirm Insertion of a new element after " + self.diffraction_pattern_tabs.tabText(current_index) + "?"): diffraction_pattern_tab = gui.widgetBox( self.diffraction_pattern_tabs, addToLayout=0, margin=4) diffraction_pattern_box = DiffractionPatternBox( widget=self, parent=diffraction_pattern_tab, index=current_index + 1) diffraction_pattern_box.after_change_workspace_units() diffraction_pattern_pd_tab = gui.widgetBox(self.tabs, addToLayout=0, margin=4) if current_index == self.diffraction_pattern_tabs.count( ) - 1: # LAST self.diffraction_pattern_tabs.addTab(diffraction_pattern_tab, "TEMP") self.diffraction_pattern_box_array.append( diffraction_pattern_box) self.tabs.addTab(diffraction_pattern_pd_tab, "TEMP") self.tab_diff.append(diffraction_pattern_pd_tab) self.tabs_data_plot.append( gui.tabWidget(self.tab_diff[current_index + 1])) self.tab_data.append( gui.createTabPage(self.tabs_data_plot[current_index + 1], "Data")) self.tab_plot.append( gui.createTabPage(self.tabs_data_plot[current_index + 1], "Plot")) self.plot.append(PlotWindow()) self.plot[current_index + 1].setDefaultPlotLines(True) self.plot[current_index + 1].setActiveCurveColor(color="#00008B") self.plot[current_index + 1].setGraphXLabel(r"2$\theta$") self.plot[current_index + 1].setGraphYLabel("Intensity") self.tab_plot[current_index + 1].layout().addWidget( self.plot[current_index + 1]) scrollarea = QScrollArea(self.tab_data[current_index]) scrollarea.setMinimumWidth(805) scrollarea.setMinimumHeight(605) self.table_data.append(self.create_table_widget()) scrollarea.setWidget(self.table_data[current_index + 1]) scrollarea.setWidgetResizable(1) self.tab_data[current_index + 1].layout().addWidget( scrollarea, alignment=Qt.AlignHCenter) else: self.diffraction_pattern_tabs.insertTab( current_index + 1, diffraction_pattern_tab, "TEMP") self.diffraction_pattern_box_array.insert( current_index + 1, diffraction_pattern_box) self.tabs.insertTab(current_index + 1, diffraction_pattern_pd_tab, "TEMP") self.tab_diff.insert(current_index + 1, diffraction_pattern_pd_tab) self.tabs_data_plot.insert( current_index + 1, gui.tabWidget(self.tab_diff[current_index + 1])) self.tab_data.insert( current_index + 1, gui.createTabPage(self.tabs_data_plot[current_index + 1], "Data")) self.tab_plot.insert( current_index + 1, gui.createTabPage(self.tabs_data_plot[current_index + 1], "Plot")) self.plot.insert(current_index + 1, PlotWindow()) self.plot[current_index + 1].setDefaultPlotLines(True) self.plot[current_index + 1].setActiveCurveColor(color="#00008B") self.plot[current_index + 1].setGraphXLabel(r"2$\theta$") self.plot[current_index + 1].setGraphYLabel("Intensity") self.tab_plot[current_index + 1].layout().addWidget( self.plot[current_index + 1]) scrollarea = QScrollArea(self.tab_data[current_index + 1]) scrollarea.setMinimumWidth(805) scrollarea.setMinimumHeight(605) self.table_data.insert(current_index + 1, self.create_table_widget()) scrollarea.setWidget(self.table_data[current_index + 1]) scrollarea.setWidgetResizable(1) self.tab_data[current_index + 1].layout().addWidget( scrollarea, alignment=Qt.AlignHCenter) for index in range(current_index, self.diffraction_pattern_tabs.count()): self.diffraction_pattern_tabs.setTabText( index, DiffractionPattern.get_default_name(index)) self.diffraction_pattern_box_array[index].index = index self.tabs.setTabText( index, DiffractionPattern.get_default_name(index)) self.dumpSettings() self.diffraction_pattern_tabs.setCurrentIndex(current_index + 1) self.tabs.setCurrentIndex(current_index + 1)
def __init__(self, widget=None, widget_container=None, parent=None, diffraction_pattern_index = 0, phase_index = 0, reflections_of_phase = "", limit = 0.0, limit_type = 0): super(ReflectionsOfPhaseBox, self).__init__() self.setLayout(QVBoxLayout()) self.layout().setAlignment(Qt.AlignTop) self.setFixedWidth(widget.CONTROL_AREA_WIDTH - 55) self.setFixedHeight(430) self.widget = widget self.diffraction_pattern_index = diffraction_pattern_index self.phase_index = phase_index self.reflections_of_phase = reflections_of_phase self.limit = limit self.limit_type = limit_type self.CONTROL_AREA_WIDTH = widget.CONTROL_AREA_WIDTH-65 parent.layout().addWidget(self) container = self gen_box = gui.widgetBox(container, "Generate Reflections", orientation="horizontal") le_limit = gui.lineEdit(gen_box, self, "limit", "Limit", labelWidth=90, valueType=float, validator=QDoubleValidator(), callback=widget_container.dump_limits) cb_limit = orangegui.comboBox(gen_box, self, "limit_type", label="Kind", items=["None", "Nr. Peaks", "2Theta Max"], orientation="horizontal") def set_limit(limit_type): if limit_type == 0: le_limit.setText("-1") le_limit.setEnabled(False) else: le_limit.setEnabled(True) if not self.is_on_init: widget_container.dump_limits() widget_container.dump_limit_types() cb_limit.currentIndexChanged.connect(set_limit) set_limit(self.limit_type) gui.button(gen_box, self, "Generate Reflections", callback=self.generate_reflections) reflection_box = gui.widgetBox(container, "Reflections", orientation="vertical", width=self.CONTROL_AREA_WIDTH - 10) orangegui.label(reflection_box, self, "h, k, l, <name> value <min minimum> <max maximum> or < fixed> or <name := function>") scrollarea = QScrollArea(reflection_box) scrollarea.setMaximumWidth(self.CONTROL_AREA_WIDTH - 40) scrollarea.setMinimumWidth(self.CONTROL_AREA_WIDTH - 40) def write_text(): self.reflections_of_phase = self.text_area.toPlainText() if not self.is_on_init: widget_container.dump_reflections_of_phases() self.text_area = gui.textArea(height=500, width=5000, readOnly=False) self.text_area.setText(self.reflections_of_phase) self.text_area.textChanged.connect(write_text) scrollarea.setWidget(self.text_area) scrollarea.setWidgetResizable(1) reflection_box.layout().addWidget(scrollarea, alignment=Qt.AlignHCenter) self.is_on_init = False
def create_box_in_widget(cls, widget, parent_box, var, label=None, disable_function=False, add_callback=False, label_width=40, min_value=None, min_accepted=True, max_value=None, max_accepted=True, trim=50): box = gui.widgetBox(parent_box, "", orientation="horizontal", width=widget.CONTROL_AREA_WIDTH - trim, height=25) box_value_width = 100 - (label_width - 40) box_label = gui.widgetBox(box, "", orientation="horizontal", width=label_width, height=25) box_value = gui.widgetBox(box, "", orientation="horizontal", width=box_value_width, height=25) box_fixed = gui.widgetBox(box, "", orientation="horizontal", height=25) box_min_max = gui.widgetBox(box, "", orientation="horizontal", height=30) box_function = gui.widgetBox(box, "", orientation="horizontal", height=25) box_function_value = gui.widgetBox(box, "", orientation="horizontal", height=25) gui.widgetLabel(box_label, var if label is None else label) if add_callback: le_var = gui.lineEdit(box_value, widget, var, " ", labelWidth=0, valueType=float, validator=QDoubleValidator(), callback=getattr(widget, "callback_" + var)) else: le_var = gui.lineEdit(box_value, widget, var, " ", labelWidth=0, valueType=float, validator=QDoubleValidator()) def set_flags(): fixed = getattr(widget, var + "_fixed") == 1 function = getattr(widget, var + "_function") == 1 if disable_function: function = False setattr(widget, var + "_function", 0) if function: setattr(widget, var + "_fixed", 0) box_min_max.setVisible(False) box_fixed.setVisible(False) le_var.setVisible(False) box_value.setFixedWidth(5) box_function.setVisible(True) box_function_value.setVisible(True) elif fixed: setattr(widget, var + "_function", 0) box_min_max.setVisible(False) box_fixed.setVisible(True) le_var.setVisible(True) box_value.setFixedWidth(box_value_width) box_function.setVisible(False) box_function_value.setVisible(False) else: setattr(widget, var + "_fixed", 0) setattr(widget, var + "_function", 0) box_min_max.setVisible(True) box_fixed.setVisible(True) le_var.setVisible(True) box_value.setFixedWidth(box_value_width) box_function.setVisible(True) box_function_value.setVisible(False) if add_callback: getattr(widget, "callback_" + var)() widget.parameter_functions[var] = set_flags orangegui.checkBox(box_fixed, widget, var + "_fixed", "fix", callback=set_flags) def set_min(): setattr(widget, var + "_has_min", 1) if add_callback: getattr(widget, "callback_" + var)() def set_max(): setattr(widget, var + "_has_max", 1) if add_callback: getattr(widget, "callback_" + var)() min_validator = QMinValueValidator( min_value, max_value, min_accepted) if not min_value is None else ( QDoubleValidator() if max_value is None else QMaxValueValidator(max_value, min_value, True)) max_validator = QMaxValueValidator( max_value, min_value, max_accepted) if not max_value is None else ( QDoubleValidator() if min_value is None else QMinValueValidator(min_value, max_value, True)) if add_callback: cb_min = orangegui.checkBox(box_min_max, widget, var + "_has_min", "min", callback=getattr( widget, "callback_" + var)) gui.lineEdit(box_min_max, widget, var + "_min", " ", labelWidth=0, valueType=float, validator=min_validator, callback=set_min) cb_max = orangegui.checkBox(box_min_max, widget, var + "_has_max", "max", callback=getattr( widget, "callback_" + var)) gui.lineEdit(box_min_max, widget, var + "_max", " ", labelWidth=0, valueType=float, validator=max_validator, callback=set_max) cb = orangegui.checkBox(box_function, widget, var + "_function", "f(x)", callback=set_flags) cb.setEnabled(not disable_function) gui.lineEdit(box_function_value, widget, var + "_function_value", "expression", valueType=str, callback=getattr(widget, "callback_" + var)) else: cb_min = orangegui.checkBox(box_min_max, widget, var + "_has_min", "min") gui.lineEdit(box_min_max, widget, var + "_min", " ", labelWidth=0, valueType=float, validator=min_validator, callback=set_min) cb_max = orangegui.checkBox(box_min_max, widget, var + "_has_max", "max") gui.lineEdit(box_min_max, widget, var + "_max", " ", labelWidth=0, valueType=float, validator=max_validator, callback=set_max) cb = orangegui.checkBox(box_function, widget, var + "_function", "f(x)", callback=set_flags) cb.setEnabled(not disable_function) gui.lineEdit(box_function_value, widget, var + "_function_value", "expression", valueType=str) if not min_value is None: setattr(widget, var + "_has_min", 1) setattr(widget, var + "_min", min_value) cb_min.setEnabled(False) if not max_value is None: setattr(widget, var + "_has_max", 1) setattr(widget, var + "_max", max_value) cb_max.setEnabled(False) set_flags()
def init_gui(self, container): box = gui.widgetBox(container, "", orientation="vertical", width=self.CONTROL_AREA_WIDTH - 5, spacing=0) orangegui.comboBox(box, self, "is_multiple_wavelength", label="Incident Radiation", items=["Single Wavelenght", "X-ray Tube"], orientation="horizontal", callback=self.set_is_multiple_wavelength) self.secondary_box = gui.widgetBox(container, "", orientation="horizontal", width=self.CONTROL_AREA_WIDTH - 5, spacing=0) orangegui.comboBox(self.secondary_box, self, "xray_tube_key", label="X-ray Tube Dataset", items=self.get_xray_tube_keys(), sendSelectedValue=True, orientation="horizontal", callback=self.set_xray_tube_key) orangegui.separator(self.secondary_box) gui.button(self.secondary_box, self, "Reset", width=70, callback=self.set_xray_tube_key) self.secondary_box_empty = gui.widgetBox( container, "", orientation="vertical", width=self.CONTROL_AREA_WIDTH - 5, spacing=0) OWGenericWidget.create_box_in_widget(self, container, "wavelength", label="\u03BB [nm]", disable_function=True, add_callback=True, min_value=0.0, min_accepted=False, trim=25) self.secondary_box_2 = gui.widgetBox(container, "", orientation="vertical", width=self.CONTROL_AREA_WIDTH) self.secondary_box_2_empty = gui.widgetBox( container, "", orientation="vertical", width=self.CONTROL_AREA_WIDTH) self.create_wavelength_boxes() self.set_is_multiple_wavelength()
def __init__(self, widget=None, parent=None, index=0, filename="<input file>", twotheta_min=0.0, twotheta_has_min=0, twotheta_max=0.0, twotheta_has_max=0, diffraction_pattern_name=""): super(DiffractionPatternBox, self).__init__() self.setLayout(QVBoxLayout()) self.layout().setAlignment(Qt.AlignTop) self.setFixedWidth(widget.CONTROL_AREA_WIDTH - 35) self.setFixedHeight(500) self.widget = widget self.index = index self.filename = filename self.twotheta_min = twotheta_min self.twotheta_has_min = twotheta_has_min self.twotheta_max = twotheta_max self.twotheta_has_max = twotheta_has_max self.diffraction_pattern_name = diffraction_pattern_name self.CONTROL_AREA_WIDTH = widget.CONTROL_AREA_WIDTH - 45 parent.layout().addWidget(self) container = self gui.lineEdit(container, self, "diffraction_pattern_name", "Sample Name\n(will appear in tabs and plots)", labelWidth=180, valueType=str, callback=widget.dump_diffraction_pattern_name) file_box = gui.widgetBox(container, "", orientation="horizontal", width=self.CONTROL_AREA_WIDTH) self.le_filename = gui.lineEdit(file_box, self, value="filename", valueType=str, label="File", labelWidth=50, callback=widget.dump_filename, orientation="horizontal") orangegui.button(file_box, self, "...", callback=self.open_folders) box = gui.widgetBox(container, "", orientation="horizontal", width=self.CONTROL_AREA_WIDTH) orangegui.checkBox(box, self, "twotheta_has_min", "2\u03b8 min [deg]", labelWidth=350, callback=widget.dump_twotheta_has_min) gui.lineEdit(box, self, "twotheta_min", " ", labelWidth=5, valueType=float, validator=QDoubleValidator(), callback=self.set_twotheta_min, orientation="horizontal") box = gui.widgetBox(container, "", orientation="horizontal", width=self.CONTROL_AREA_WIDTH) orangegui.checkBox(box, self, "twotheta_has_max", "2\u03b8 max [deg]", labelWidth=350, callback=widget.dump_twotheta_has_max) gui.lineEdit(box, self, "twotheta_max", " ", labelWidth=5, valueType=float, validator=QDoubleValidator(), callback=self.set_twotheta_max, orientation="horizontal") self.is_on_init = False
def __init__(self): super().__init__(show_automatic_box=False) main_box = gui.widgetBox(self.controlArea, "Load Diffraction Pattern", orientation="vertical", width=self.CONTROL_AREA_WIDTH - 5, height=600) button_box = gui.widgetBox(main_box, "", orientation="horizontal", width=self.CONTROL_AREA_WIDTH - 25) gui.button(button_box, self, "Load Data", height=50, callback=self.load_diffraction_patterns) tabs_button_box = gui.widgetBox(main_box, "", addSpace=False, orientation="horizontal") btns = [ gui.button(tabs_button_box, self, "Insert Before", callback=self.insert_before), gui.button(tabs_button_box, self, "Insert After", callback=self.insert_after), gui.button(tabs_button_box, self, "Remove", callback=self.remove), gui.button(tabs_button_box, self, "Remove All", callback=self.remove_all) ] for btn in btns: btn.setFixedHeight(40) btns[3].setStyleSheet("color: red") font = QFont(btns[3].font()) font.setItalic(True) btns[3].setFont(font) self.diffraction_pattern_tabs = gui.tabWidget(main_box) self.diffraction_pattern_box_array = [] for index in range(len(self.filename)): diffraction_pattern_tab = gui.createTabPage( self.diffraction_pattern_tabs, DiffractionPattern.get_default_name(index)) diffraction_pattern_box = DiffractionPatternBox( widget=self, parent=diffraction_pattern_tab, index=index, filename=self.filename[index], twotheta_min=self.twotheta_min[index], twotheta_has_min=self.twotheta_has_min[index], twotheta_max=self.twotheta_max[index], twotheta_has_max=self.twotheta_has_max[index], diffraction_pattern_name=self.diffraction_pattern_name[index]) self.diffraction_pattern_box_array.append(diffraction_pattern_box) self.tabs = gui.tabWidget(self.mainArea) self.tab_diff = [] self.tabs_data_plot = [] self.tab_data = [] self.tab_plot = [] self.plot = [] self.table_data = [] for index in range(len(self.filename)): self.tab_diff.append( gui.createTabPage(self.tabs, DiffractionPattern.get_default_name(index))) self.tabs_data_plot.append(gui.tabWidget(self.tab_diff[index])) self.tab_data.append( gui.createTabPage(self.tabs_data_plot[index], "Data")) self.tab_plot.append( gui.createTabPage(self.tabs_data_plot[index], "Plot")) self.plot.append(PlotWindow()) self.plot[index].setDefaultPlotLines(True) self.plot[index].setActiveCurveColor(color="#00008B") self.plot[index].setGraphXLabel(r"2$\theta$") self.plot[index].setGraphYLabel("Intensity") self.tab_plot[index].layout().addWidget(self.plot[index]) table_widget = self.create_table_widget() self.table_data.append(table_widget) self.tab_data[index].layout().addWidget(table_widget, alignment=Qt.AlignHCenter) runaction = OWAction("Load Diffraction Patterns", self) runaction.triggered.connect(self.load_diffraction_patterns) self.addAction(runaction)