示例#1
0
    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)
    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)
示例#3
0
    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):
        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
示例#5
0
    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)
示例#6
0
    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,
                 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
示例#8
0
    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()
示例#9
0
 def init_gui(self, container):
     gui.lineEdit(container, self, "goniometer_radius", "Goniometer Radius [m]", labelWidth=300, valueType=float, callback=self.widget.dump_goniometer_radius)
     orangegui.separator(container)
     OWGenericWidget.create_box_in_widget(self, container, "displacement", add_callback=True, label_width=75, trim=15)
示例#10
0
    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
示例#11
0
 def init_gui(self, container):
     gui.lineEdit(container, self, "reduction_factor", "Reduction Factor", labelWidth=300, valueType=int, callback=self.widget.dump_reduction_factor)