def initialize_content(self):
        # Constraints
        for widget in [
                self._content.median_test_high_edit,
                self._content.median_test_low_edit,
                self._content.median_test_out_high_edit,
                self._content.median_test_out_low_edit,
                self._content.errorbar_crit_edit,
                self._content.ratio_var_crit_edit,
                self._content.sambkg_median_test_high_edit,
                self._content.sambkg_median_test_low_edit,
                self._content.sambkg_errorbar_crit_edit
        ]:

            dvp = QDoubleValidator(widget)
            dvp.setBottom(0.0)
            widget.setValidator(dvp)

        for widget in [self._content.tof_start_edit,
                       self._content.tof_end_edit]:
            ivp = QIntValidator(widget)
            ivp.setBottom(0)
            widget.setValidator(ivp)

        # Connections
        self._content.det_van2_browse.clicked.connect(self._det_van2_browse)
Exemple #2
0
    def initialize_content(self):
        # Constraints
        for widget in [
                self._content.median_test_high_edit,
                self._content.median_test_low_edit,
                self._content.median_test_out_high_edit,
                self._content.median_test_out_low_edit,
                self._content.errorbar_crit_edit,
                self._content.ratio_var_crit_edit,
                self._content.sambkg_median_test_high_edit,
                self._content.sambkg_median_test_low_edit,
                self._content.sambkg_errorbar_crit_edit
        ]:

            dvp = QDoubleValidator(widget)
            dvp.setBottom(0.0)
            widget.setValidator(dvp)

        for widget in [
                self._content.tof_start_edit, self._content.tof_end_edit
        ]:
            ivp = QIntValidator(widget)
            ivp.setBottom(0)
            widget.setValidator(ivp)

        # Connections
        self._content.det_van2_browse.clicked.connect(self._det_van2_browse)
Exemple #3
0
    def initialize_content(self):
        """ Initialize content/UI
        """
        # Constraints/Validator
        iv4 = QIntValidator(self._content.maxchunksize_edit)
        iv4.setBottom(0)
        self._content.maxchunksize_edit.setValidator(iv4)

        dv0 = QDoubleValidator(self._content.unwrap_edit)
        self._content.unwrap_edit.setValidator(dv0)

        dv2 = QDoubleValidator(self._content.lowres_edit)
        self._content.lowres_edit.setValidator(dv2)

        dv3 = QDoubleValidator(self._content.cropwavelengthmin_edit)
        dv3.setBottom(0.0)
        self._content.cropwavelengthmin_edit.setValidator(dv3)

        dv3b = QDoubleValidator(self._content.lineEdit_croppedWavelengthMax)
        dv3b.setBottom(0.1)
        self._content.lineEdit_croppedWavelengthMax.setValidator(dv3b)

        dv4 = QDoubleValidator(self._content.removepromptwidth_edit)
        dv4.setBottom(0.0)
        self._content.removepromptwidth_edit.setValidator(dv4)
        self._content.removepromptwidth_edit.setText("50.0")

        dv5 = QDoubleValidator(self._content.vanpeakfwhm_edit)
        dv5.setBottom(0.0)
        self._content.vanpeakfwhm_edit.setValidator(dv5)

        dv6 = QDoubleValidator(self._content.vanpeaktol_edit)
        dv6.setBottom(0.0)
        self._content.vanpeaktol_edit.setValidator(dv6)

        dv7 = QDoubleValidator(self._content.scaledata_edit)
        dv7.setBottom(0.0)
        self._content.scaledata_edit.setValidator(dv7)

        # Default states
        self._content.stripvanpeaks_chkbox.setChecked(True)
        self._syncStripVanPeakWidgets(True)

        self._content.preserveevents_checkbox.setChecked(True)

        dv8 = QDoubleValidator(self._content.filterbadpulses_edit)
        dv8.setBottom(0.0)
        self._content.filterbadpulses_edit.setValidator(dv8)
        self._content.filterbadpulses_edit.setText("95.")

        # Connections from action/event to function to handle
        self._content.stripvanpeaks_chkbox.clicked.connect(self._stripvanpeaks_clicked)

        self._content.help_button.clicked.connect(self._show_help)
        # Handler for events
        # TODO - Need to add an event handler for the change of instrument and facility

        # Validated widgets

        return
Exemple #4
0
    def createIntegerLineEdit(self, minimum=None, maximum=None, placeholder=""):
        line_edit = ClearableLineEdit(placeholder=placeholder)
        validator = QIntValidator()

        if minimum is not None:
            validator.setBottom(minimum)

        if maximum is not None:
            validator.setTop(maximum)

        line_edit.setValidator(validator)
        return line_edit
Exemple #5
0
    def __init__(self, parent=None):
        super(RedisItemEditor, self).__init__(parent)
        self.load_ui()
        self.__original_item = None
        self.__item = None
        ui = self.ui
        layout = QStackedLayout(ui.type_editor)
        layout.setContentsMargins(3, 3, 3, 3)
        self.none_editor = QWidget()
        self.simple_editor = SimpleEditor()
        self.hash_editor = MultiEditor()
        self.seq_editor = MultiEditor()
        self.seq_editor.ui.table.horizontalHeader().setVisible(False)
        self.set_editor = MultiEditor()
        self.set_editor.ui.table.horizontalHeader().setVisible(False)
        layout.addWidget(self.none_editor)
        layout.addWidget(self.simple_editor)
        layout.addWidget(self.hash_editor)
        layout.addWidget(self.seq_editor)
        layout.addWidget(self.set_editor)
        self.type_editor_map = {
            "none": self.none_editor,
            "string": self.simple_editor,
            "hash": self.hash_editor,
            "list": self.seq_editor,
            "set": self.set_editor,
        }
        ttl_validator = QIntValidator()
        ttl_validator.setBottom(-1)
        ui.ttl_value.setValidator(ttl_validator)

        ui.key_name.textChanged.connect(self.__on_key_name_changed)
        ui.key_name.returnPressed.connect(self.__on_key_name_applied)
        ui.ttl_value.textChanged.connect(self.__on_ttl_changed)
        ui.ttl_value.returnPressed.connect(self.__on_ttl_applied)
        ui.apply_button.clicked.connect(self.__on_apply)
        ui.refresh_button.clicked.connect(self.__on_refresh)
        ui.undo_button.clicked.connect(self.__on_undo)
        ui.persist_button.clicked.connect(self.__on_persist)
        ui.delete_button.clicked.connect(self.__on_delete)
Exemple #6
0
    def _init_ui(self):
        # Widgets
        validator = QIntValidator()
        validator.setBottom(0)

        self._txt_start_channel = QLineEdit()
        self._txt_start_channel.setValidator(validator)
        self._txt_start_channel.setAccessibleName('Start channel')

        self._txt_end_channel = QLineEdit()
        self._txt_end_channel.setValidator(validator)
        self._txt_end_channel.setAccessibleName("End channel")

        # Layouts
        layout = _ConditionWidget._init_ui(self)
        layout.addRow('<i>Start channel</i>', self._txt_start_channel)
        layout.addRow('<i>End channel</i>', self._txt_end_channel)

        # Signals
        self._txt_start_channel.textEdited.connect(self.edited)
        self._txt_end_channel.textEdited.connect(self.edited)

        return layout
Exemple #7
0
    def __init__(self, appdata: CnaData):
        QDialog.__init__(self)
        self.setWindowTitle("Configure COBRApy")

        self.appdata = appdata
        self.layout = QVBoxLayout()

        # allow MILP solvers only?
        avail_solvers = list(set(solvers.keys()) - {'scipy'}) # SCIPY currently not even usable for FBA

        h2 = QHBoxLayout()
        label = QLabel("Default solver:\n(set when loading a model)")
        h2.addWidget(label)
        self.default_solver = QComboBox()
        self.default_solver.addItems(avail_solvers)
        self.default_solver.setCurrentIndex(avail_solvers.index(interface_to_str(cobra.Configuration().solver)))
        h2.addWidget(self.default_solver)
        self.layout.addItem(h2)

        h9 = QHBoxLayout()
        label = QLabel("Solver for current model:")
        h9.addWidget(label)
        self.current_solver = QComboBox()
        self.current_solver.addItems(avail_solvers)
        self.current_solver.setCurrentIndex(avail_solvers.index(interface_to_str(appdata.project.cobra_py_model.problem)))
        h9.addWidget(self.current_solver)
        self.layout.addItem(h9)

        h7 = QHBoxLayout()
        label = QLabel(
            "Number of processes for multiprocessing (e.g. FVA):")
        h7.addWidget(label)
        self.num_processes = QLineEdit()
        self.num_processes.setFixedWidth(100)
        self.num_processes.setText(str(cobra.Configuration().processes))
        validator = QIntValidator(1, cpu_count(), self)
        self.num_processes.setValidator(validator)
        h7.addWidget(self.num_processes)
        self.layout.addItem(h7)

        h8 = QHBoxLayout()
        label = QLabel(
            "Default tolerance:\n(set when loading a model)")
        h8.addWidget(label)
        self.default_tolerance = QLineEdit()
        self.default_tolerance.setFixedWidth(100)
        self.default_tolerance.setText(str(cobra.Configuration().tolerance))
        validator = QDoubleValidator(self)
        validator.setBottom(1e-9) # probably a reasonable consensus value
        self.default_tolerance.setValidator(validator)
        h8.addWidget(self.default_tolerance)
        self.layout.addItem(h8)

        h10 = QHBoxLayout()
        label = QLabel(
            "Tolerance for current model:")
        h10.addWidget(label)
        self.current_tolerance = QLineEdit()
        self.current_tolerance.setFixedWidth(100)
        self.current_tolerance.setText(str(self.appdata.project.cobra_py_model.tolerance))
        validator = QDoubleValidator(self)
        validator.setBottom(0)
        self.current_tolerance.setValidator(validator)
        h10.addWidget(self.current_tolerance)
        self.layout.addItem(h10)

        l2 = QHBoxLayout()
        self.button = QPushButton("Apply Changes")
        self.cancel = QPushButton("Close")
        l2.addWidget(self.button)
        l2.addWidget(self.cancel)
        self.layout.addItem(l2)
        self.setLayout(self.layout)

        self.cancel.clicked.connect(self.reject)
        self.button.clicked.connect(self.apply)
Exemple #8
0
class DialogLoadMask(QDialog):
    """
    Dialog box for selecting spatial ROI and mask.

    Typical use:

    default_dir = "/home/user/data"
    n_rows, n_columns = 15, 20  # Some values

    # Values that are changed by the dialog box
    roi = (2, 3, 11, 9)
    use_roi = True
    mask_f_path = ""
    use_mask = False

    dlg = DialogLoadMask()
    dlg.set_image_size(n_rows=n_rows, n_columns=n_columns)
    dlg.set_roi(row_start=roi[0], column_start=roi[1], row_end=roi[2], column_end=roi[3])
    dlg.set_roi_active(use_roi)

    dlg.set_default_directory(default_dir)
    dlg.set_mask_file_path(mask_f_path)
    dlg.set_mask_file_active(use_mask)

    if dlg.exec() == QDialog.Accepted:
        # If success, then read the values back. Discard changes if rejected.
        roi = dlg.get_roi()
        use_roi = dlg.get_roi_active()
        mask_f_path = dlg.get_mask_file_path()
        use_mask = dlg.get_mask_file_active()
    """
    def __init__(self):

        super().__init__()

        self._validation_enabled = False

        self.resize(500, 300)
        self.setWindowTitle("Load Mask or Select ROI")

        # Initialize variables used with ROI selection group
        self._n_rows = 0
        self._n_columns = 0
        self._roi_active = False
        self._row_start = -1
        self._column_start = -1
        self._row_end = -1
        self._column_end = -1
        # ... with Mask group
        self._mask_active = False
        self._mask_file_path = ""
        self._default_directory = ""

        # Fields for entering spatial ROI coordinates
        self.validator_rows = QIntValidator()
        self.validator_rows.setBottom(1)
        self.validator_cols = QIntValidator()
        self.validator_cols.setBottom(1)

        self.le_roi_start_row = LineEditExtended()
        self.le_roi_start_row.setValidator(self.validator_rows)
        self.le_roi_start_row.editingFinished.connect(
            self.le_roi_start_row_editing_finished)
        self.le_roi_start_row.textChanged.connect(
            self.le_roi_start_row_text_changed)
        self.le_roi_start_col = LineEditExtended()
        self.le_roi_start_col.setValidator(self.validator_cols)
        self.le_roi_start_col.editingFinished.connect(
            self.le_roi_start_col_editing_finished)
        self.le_roi_start_col.textChanged.connect(
            self.le_roi_start_col_text_changed)
        self.le_roi_end_row = LineEditExtended()
        self.le_roi_end_row.setValidator(self.validator_rows)
        self.le_roi_end_row.editingFinished.connect(
            self.le_roi_end_row_editing_finished)
        self.le_roi_end_row.textChanged.connect(
            self.le_roi_end_row_text_changed)
        self.le_roi_end_col = LineEditExtended()
        self.le_roi_end_col.setValidator(self.validator_cols)
        self.le_roi_end_col.editingFinished.connect(
            self.le_roi_end_col_editing_finished)
        self.le_roi_end_col.textChanged.connect(
            self.le_roi_end_col_text_changed)
        self._text_map_size_base = "   * Map size: "
        self.label_map_size = QLabel(self._text_map_size_base + "not set")

        # Group box for spatial ROI selection
        self.gb_roi = QGroupBox("Select ROI (in pixels)")
        set_tooltip(
            self.gb_roi,
            "Select rectangular <b>spatial ROI</b>. If <b>mask</b> is "
            "loaded, then ROI is applied to the masked data.",
        )
        self.gb_roi.setCheckable(True)
        self.gb_roi.toggled.connect(self.gb_roi_toggled)
        self.gb_roi.setChecked(self._roi_active)
        vbox = QVBoxLayout()
        grid = QGridLayout()
        grid.addWidget(QLabel("Start position(*):"), 0, 0)
        grid.addWidget(QLabel("row"), 0, 1)
        grid.addWidget(self.le_roi_start_row, 0, 2)
        grid.addWidget(QLabel("column"), 0, 3)
        grid.addWidget(self.le_roi_start_col, 0, 4)
        grid.addWidget(QLabel("End position(*):"), 1, 0)
        grid.addWidget(QLabel("row"), 1, 1)
        grid.addWidget(self.le_roi_end_row, 1, 2)
        grid.addWidget(QLabel("column"), 1, 3)
        grid.addWidget(self.le_roi_end_col, 1, 4)
        vbox.addLayout(grid)
        vbox.addWidget(self.label_map_size)
        self.gb_roi.setLayout(vbox)

        # Widgets for loading mask
        self.pb_load_mask = QPushButton("Load Mask ...")
        self.pb_load_mask.clicked.connect(self.pb_load_mask_clicked)
        self._le_load_mask_default_text = "select 'mask' file"
        self.le_load_mask = LineEditReadOnly(self._le_load_mask_default_text)

        # Group box for setting mask
        self.gb_mask = QGroupBox("Set mask")
        set_tooltip(
            self.gb_mask,
            "Load <b>mask</b> from file. Active pixels in the mask are "
            "represented by positive integers. If <b>spatial ROI</b> is "
            "selected, then it is applied to the masked data.",
        )
        self.gb_mask.setCheckable(True)
        self.gb_mask.toggled.connect(self.gb_mask_toggled)
        self.gb_mask.setChecked(self._mask_active)
        hbox = QHBoxLayout()
        hbox.addWidget(self.pb_load_mask)
        hbox.addWidget(self.le_load_mask)
        self.gb_mask.setLayout(hbox)

        # Yes/No button box
        self.button_box = QDialogButtonBox(QDialogButtonBox.Ok
                                           | QDialogButtonBox.Cancel)
        self.button_ok = self.button_box.button(QDialogButtonBox.Ok)
        self.button_box.accepted.connect(self.accept)
        self.button_box.rejected.connect(self.reject)

        vbox = QVBoxLayout()
        vbox.addWidget(self.gb_roi)
        vbox.addStretch(1)
        vbox.addWidget(self.gb_mask)
        vbox.addStretch(2)
        vbox.addWidget(self.button_box)
        self.setLayout(vbox)

        self._validation_enabled = True
        self._validate_all_widgets()

    def _compute_home_directory(self):
        dir_name = "."
        if self._default_directory:
            dir_name = self._default_directory
        if self._mask_file_path:
            d, _ = os.path.split(self._mask_file_path)
            dir_name = d if d else dir_name
        return dir_name

    def pb_load_mask_clicked(self):
        dir_name = self._compute_home_directory()
        file_name = QFileDialog.getOpenFileName(self, "Load Mask From File",
                                                dir_name, "All (*)")
        file_name = file_name[0]
        if file_name:
            self._mask_file_path = file_name
            self._show_mask_file_path()
            logger.debug(f"Mask file is selected: '{file_name}'")

    def gb_roi_toggled(self, state):
        self._roi_activate(state)

    def _read_le_roi_value(self, line_edit, v_default):
        """
        Attempt to read value from line edit box as int, return `v_default` if not successful.

        Parameters
        ----------
        line_edit: QLineEdit
            reference to QLineEdit object
        v_default: int
            default value returned if the value read from edit box is incorrect
        """
        try:
            val = int(line_edit.text())
            if val < 1:
                raise Exception()
        except Exception:
            val = v_default
        return val

    def le_roi_start_row_editing_finished(self):
        self._row_start = self._read_le_roi_value(self.le_roi_start_row,
                                                  self._row_start + 1) - 1

    def le_roi_end_row_editing_finished(self):
        self._row_end = self._read_le_roi_value(self.le_roi_end_row,
                                                self._row_end)

    def le_roi_start_col_editing_finished(self):
        self._column_start = self._read_le_roi_value(
            self.le_roi_start_col, self._column_start + 1) - 1

    def le_roi_end_col_editing_finished(self):
        self._column_end = self._read_le_roi_value(self.le_roi_end_col,
                                                   self._column_end)

    def le_roi_start_row_text_changed(self):
        self._validate_all_widgets()

    def le_roi_end_row_text_changed(self):
        self._validate_all_widgets()

    def le_roi_start_col_text_changed(self):
        self._validate_all_widgets()

    def le_roi_end_col_text_changed(self):
        self._validate_all_widgets()

    def gb_mask_toggled(self, state):
        self._mask_file_activate(state)

    def _validate_all_widgets(self):
        """
        Validate the values and state of all widgets, update the 'valid' state
        of the widgets and enable/disable Ok button.
        """

        if not self._validation_enabled:
            return

        # Check if all fields have valid input values
        def _check_valid_input(line_edit, flag_valid):
            val = self._read_le_roi_value(line_edit, -1)
            state = val > 0
            line_edit.setValid(state)
            flag_valid = flag_valid if state else False
            return val, flag_valid

        # Set all line edits to 'valid' state
        self.le_roi_start_row.setValid(True)
        self.le_roi_end_row.setValid(True)
        self.le_roi_start_col.setValid(True)
        self.le_roi_end_col.setValid(True)
        self.le_load_mask.setValid(True)

        flag_valid = True

        if self._roi_active:
            # Perform the following checks only if ROI group is active
            rs, flag_valid = _check_valid_input(self.le_roi_start_row,
                                                flag_valid)
            re, flag_valid = _check_valid_input(self.le_roi_end_row,
                                                flag_valid)
            cs, flag_valid = _check_valid_input(self.le_roi_start_col,
                                                flag_valid)
            ce, flag_valid = _check_valid_input(self.le_roi_end_col,
                                                flag_valid)

            # Check if start
            if (rs > 0) and (re > 0) and (rs > re):
                self.le_roi_start_row.setValid(False)
                self.le_roi_end_row.setValid(False)
                flag_valid = False
            if (cs > 0) and (ce > 0) and (cs > ce):
                self.le_roi_start_col.setValid(False)
                self.le_roi_end_col.setValid(False)
                flag_valid = False

        if self._mask_active:
            if not self._mask_file_path:
                self.le_load_mask.setValid(False)
                flag_valid = False

        self.button_ok.setEnabled(flag_valid)

    def set_image_size(self, *, n_rows, n_columns):
        """
        Set the image size. Image size is used to for input validation. When image
        size is set, the selection is reset to cover the whole image.

        Parameters
        ----------
        n_rows: int
            The number of rows in the image: (1..)
        n_columns: int
            The number of columns in the image: (1..)
        """
        if n_rows < 1 or n_columns < 1:
            raise ValueError(
                "DialogLoadMask: image size have zero rows or zero columns: "
                f"n_rows={n_rows} n_columns={n_columns}. "
                "Report the error to the development team.")

        self._n_rows = n_rows
        self._n_columns = n_columns

        self._row_start = 0
        self._row_end = n_rows
        self._column_start = 0
        self._column_end = n_columns

        self._show_selection(True)
        self._validate_all_widgets()

        self.validator_rows.setTop(n_rows)
        self.validator_cols.setTop(n_columns)
        # Set label
        self.label_map_size.setText(
            f"{self._text_map_size_base}{self._n_rows} rows, {self._n_columns} columns."
        )

    def _show_selection(self, visible):
        """visible: True - show values, False - hide values"""
        def _show_number(l_edit, value):
            if value > 0:
                l_edit.setText(f"{value}")
            else:
                # This would typically mean incorrect initialization of the dialog box
                l_edit.setText("")

        _show_number(self.le_roi_start_row, self._row_start + 1)
        _show_number(self.le_roi_start_col, self._column_start + 1)
        _show_number(self.le_roi_end_row, self._row_end)
        _show_number(self.le_roi_end_col, self._column_end)

    def set_roi(self, *, row_start, column_start, row_end, column_end):
        """
        Set the values of fields that define selection of the image region. First set
        the image size (`set_image_size()`) and then set the selection.

        Parameters
        ----------
        row_start: int
            The row number of the first pixel in the selection (0..n_rows-1).
            Negative (-1) - resets value to 0.
        column_start: int
            The column number of the first pixel in the selection (0..n_columns-1).
            Negative (-1) - resets value to 0.
        row_end: int
            The row number following the last pixel in the selection (1..n_rows).
            This row is not included in the selection. Negative (-1) - resets value to n_rows.
        column_end: int
            The column number following the last pixel in the selection (1..n_columns).
            This column is not included in the selection. Negative (-1) - resets value to n_columns.
        """
        # The variables holding the selected region are following Python conventions for the
        #   selections: row_start, column_start are in the range 0..n_rows-1, 0..n_columns-1
        #   and row_end, column_end are in the range 1..n_rows, 1..n_columns.
        #   The values displayed in the dialog box are just pixels numbers in the range
        #   1..n_rows, 1..n_columns that define the rectangle in the way intuitive to the user.
        self._row_start = int(
            np.clip(row_start, a_min=0, a_max=self._n_rows - 1))
        self._column_start = int(
            np.clip(column_start, a_min=0, a_max=self._n_columns - 1))

        def _adjust_last_index(index, n_elements):
            if index < 0:
                index = n_elements
            index = int(np.clip(index, 1, n_elements))
            return index

        self._row_end = _adjust_last_index(row_end, self._n_rows)
        self._column_end = _adjust_last_index(column_end, self._n_columns)
        self._show_selection(self._roi_active)
        self._validate_all_widgets()

    def _roi_activate(self, state):
        self._roi_active = state
        self._show_selection(state)
        self._validate_all_widgets()

    def set_roi_active(self, state):
        self._roi_activate(state)
        self.gb_roi.setChecked(self._roi_active)

    def get_roi(self):
        return self._row_start, self._column_start, self._row_end, self._column_end

    def get_roi_active(self):
        return self._roi_active

    def _show_mask_file_path(self):
        fpath = self._mask_file_path if self._mask_file_path else self._le_load_mask_default_text
        self.le_load_mask.setText(fpath)
        self._validate_all_widgets()

    def _mask_file_activate(self, state):
        self._mask_active = state
        self._show_mask_file_path()
        self._validate_all_widgets()

    def set_mask_file_active(self, state):
        self._mask_file_activate(state)
        self.gb_mask.setChecked(self._mask_active)

    def get_mask_file_active(self):
        return self._mask_active

    def set_mask_file_path(self, fpath):
        self._mask_file_path = fpath
        self._show_mask_file_path()

    def get_mask_file_path(self):
        return self._mask_file_path

    def set_default_directory(self, dir_name):
        self._default_directory = dir_name

    def get_default_directory(self):
        return self._default_directory
    def initialize_content(self):
        """ Initialize content/UI
        """
        # Initial values for combo boxes
        # Combo boxes
        self._content.saveas_combo.setCurrentIndex(1)
        self._content.unit_combo.setCurrentIndex(1)
        self._content.bintype_combo.setCurrentIndex(1)

        # Radio buttons
        self._content.disablevancorr_chkbox.setChecked(False)

        # Check boxes
        self._content.usebin_button.setChecked(True)
        self._content.resamplex_button.setChecked(False)
        self._content.disablebkgdcorr_chkbox.setChecked(False)
        self._content.disablevancorr_chkbox.setChecked(False)
        self._content.disablevanbkgdcorr_chkbox.setChecked(False)

        # Label
        if self._instrument_name is not False:
            self._content.label.setText('Instrument: %s' %
                                        self._instrument_name.upper())
        else:
            self._content.label.setText(
                'Instrument has not been set up.  You may not launch correctly.'
            )

        # Enable disable
        if self._instrument_name.lower().startswith('nom') is False:
            self._content.lineEdit_expIniFile.setEnabled(False)
            self._content.pushButton_browseExpIniFile.setEnabled(False)
        else:
            self._content.lineEdit_expIniFile.setEnabled(True)
            self._content.pushButton_browseExpIniFile.setEnabled(True)

        # Line edit
        self._content.emptyrun_edit.setEnabled(True)
        self._content.vanrun_edit.setEnabled(True)
        self._content.vanbkgdrun_edit.setEnabled(True)
        self._content.resamplex_edit.setEnabled(False)

        # Constraints/Validator
        expression = r'[\d,-]*'
        iv0 = generateRegExpValidator(self._content.emptyrun_edit, expression)
        self._content.emptyrun_edit.setValidator(iv0)

        iv1 = generateRegExpValidator(self._content.vanrun_edit, expression)
        self._content.vanrun_edit.setValidator(iv1)

        iv3 = generateRegExpValidator(self._content.vanbkgdrun_edit,
                                      expression)
        self._content.vanbkgdrun_edit.setValidator(iv3)

        siv = QIntValidator(self._content.resamplex_edit)
        siv.setBottom(0)
        self._content.resamplex_edit.setValidator(siv)

        # Float/Double
        fiv = QDoubleValidator(self._content.binning_edit)
        self._content.binning_edit.setValidator(fiv)

        # Default states
        # self._handle_tzero_guess(self._content.use_ei_guess_chkbox.isChecked())

        # Connections from action/event to function to handle
        self._content.calfile_browse.clicked.connect(self._calfile_browse)
        self._content.charfile_browse.clicked.connect(self._charfile_browse)
        self._content.groupfile_browse.clicked.connect(self._groupfile_browse)
        self._content.pushButton_browseExpIniFile.clicked.connect(
            self.do_browse_ini_file)
        self._content.outputdir_browse.clicked.connect(self._outputdir_browse)
        self._content.binning_edit.textChanged.connect(self._binvalue_edit)
        self._content.bintype_combo.currentIndexChanged.connect(
            self._bintype_process)

        self._content.disablebkgdcorr_chkbox.clicked.connect(
            self._disablebkgdcorr_clicked)
        self._content.disablevancorr_chkbox.clicked.connect(
            self._disablevancorr_clicked)
        self._content.disablevanbkgdcorr_chkbox.clicked.connect(
            self._disablevanbkgdcorr_clicked)

        self._content.usebin_button.clicked.connect(self._usebin_clicked)
        self._content.resamplex_button.clicked.connect(self._resamplex_clicked)

        self._content.help_button.clicked.connect(self._show_help)

        # mutex for whether to update the linear/log drop-down
        self._content._binning_edit_mutex = False
Exemple #10
0
    def __init__(self,
                 parent,
                 new_size,
                 old_size,
                 text="",
                 keep_original_size=False):
        QDialog.__init__(self, parent)
        win32_fix_title_bar_background(self)

        intfunc = lambda tup: [int(val) for val in tup]
        if intfunc(new_size) == intfunc(old_size):
            self.keep_original_size = True
        else:
            self.keep_original_size = keep_original_size
        self.width, self.height = new_size
        self.old_width, self.old_height = old_size
        self.ratio = self.width / self.height

        layout = QVBoxLayout()
        self.setLayout(layout)

        formlayout = QFormLayout()
        layout.addLayout(formlayout)

        if text:
            label = QLabel(text)
            label.setAlignment(Qt.AlignHCenter)
            formlayout.addRow(label)

        self.w_edit = w_edit = QLineEdit(self)
        w_valid = QIntValidator(w_edit)
        w_valid.setBottom(1)
        w_edit.setValidator(w_valid)

        self.h_edit = h_edit = QLineEdit(self)
        h_valid = QIntValidator(h_edit)
        h_valid.setBottom(1)
        h_edit.setValidator(h_valid)

        zbox = QCheckBox(_("Original size"), self)

        formlayout.addRow(_("Width (pixels)"), w_edit)
        formlayout.addRow(_("Height (pixels)"), h_edit)
        formlayout.addRow("", zbox)

        formlayout.addRow(_("Original size:"), QLabel("%d x %d" % old_size))
        self.z_label = QLabel()
        formlayout.addRow(_("Zoom factor:"), self.z_label)

        # Button box
        self.bbox = bbox = QDialogButtonBox(QDialogButtonBox.Ok
                                            | QDialogButtonBox.Cancel)
        bbox.accepted.connect(self.accept)
        bbox.rejected.connect(self.reject)
        layout.addWidget(bbox)

        self.w_edit.setText(str(self.width))
        self.h_edit.setText(str(self.height))
        self.update_widgets()

        self.setWindowTitle(_("Resize"))

        w_edit.textChanged.connect(self.width_changed)
        h_edit.textChanged.connect(self.height_changed)
        zbox.toggled.connect(self.toggled_no_zoom)
        zbox.setChecked(self.keep_original_size)
Exemple #11
0
    def initialize_content(self):
        """ Initialize content/UI
        """
        # Constraints/Validator
        iv4 = QIntValidator(self._content.maxchunksize_edit)
        iv4.setBottom(0)
        self._content.maxchunksize_edit.setValidator(iv4)

        dv0 = QDoubleValidator(self._content.unwrap_edit)
        self._content.unwrap_edit.setValidator(dv0)

        dv2 = QDoubleValidator(self._content.lowres_edit)
        self._content.lowres_edit.setValidator(dv2)

        dv3 = QDoubleValidator(self._content.cropwavelengthmin_edit)
        dv3.setBottom(0.0)
        self._content.cropwavelengthmin_edit.setValidator(dv3)

        dv3b = QDoubleValidator(self._content.lineEdit_croppedWavelengthMax)
        dv3b.setBottom(0.1)
        self._content.lineEdit_croppedWavelengthMax.setValidator(dv3b)

        dv4 = QDoubleValidator(self._content.removepromptwidth_edit)
        dv4.setBottom(0.0)
        self._content.removepromptwidth_edit.setValidator(dv4)
        self._content.removepromptwidth_edit.setText("50.0")

        dv5 = QDoubleValidator(self._content.vanpeakfwhm_edit)
        dv5.setBottom(0.0)
        self._content.vanpeakfwhm_edit.setValidator(dv5)

        dv6 = QDoubleValidator(self._content.vanpeaktol_edit)
        dv6.setBottom(0.0)
        self._content.vanpeaktol_edit.setValidator(dv6)

        dv7 = QDoubleValidator(self._content.scaledata_edit)
        dv7.setBottom(0.0)
        self._content.scaledata_edit.setValidator(dv7)

        dv8 = QDoubleValidator(self._content.numberdensity_edit)
        dv8.setBottom(0.0)
        self._content.numberdensity_edit.setValidator(dv8)
        self._content.numberdensity_edit.editingFinished.connect(
            self._calculate_packing_fraction)

        dv9 = QDoubleValidator(self._content.massdensity_edit)
        dv9.setBottom(0.0)
        self._content.massdensity_edit.setValidator(dv9)
        self._content.massdensity_edit.editingFinished.connect(
            self._calculate_packing_fraction)

        self._content.sampleformula_edit.textEdited.connect(
            self._validate_formula)
        self._content.sampleformula_edit.editingFinished.connect(
            self._calculate_packing_fraction)

        dv10 = QDoubleValidator(self._content.vanadiumradius_edit)
        dv10.setBottom(0.0)
        self._content.vanadiumradius_edit.setValidator(dv10)

        # Default states
        self._content.stripvanpeaks_chkbox.setChecked(True)
        self._syncStripVanPeakWidgets(True)

        self._content.preserveevents_checkbox.setChecked(True)

        dv8 = QDoubleValidator(self._content.filterbadpulses_edit)
        dv8.setBottom(0.0)
        self._content.filterbadpulses_edit.setValidator(dv8)
        self._content.filterbadpulses_edit.setText("95.")

        # Connections from action/event to function to handle
        self._content.stripvanpeaks_chkbox.clicked.connect(
            self._stripvanpeaks_clicked)

        self._content.help_button.clicked.connect(self._show_help)
        # Handler for events
        # TODO - Need to add an event handler for the change of instrument and facility

        self._content.material_help_button.clicked.connect(
            functools.partial(self._show_concept_help, "Materials"))
        self._content.absorption_help_button.clicked.connect(
            functools.partial(self._show_concept_help,
                              "AbsorptionAndMultipleScattering"))

        # Initialization for Caching options
        self._content.cache_dir_browse_1.clicked.connect(
            self._cache_dir_browse_1)
        self._content.cache_dir_browse_2.clicked.connect(
            self._cache_dir_browse_2)
        self._content.cache_dir_browse_3.clicked.connect(
            self._cache_dir_browse_3)

        # Validated widgets

        return
Exemple #12
0
    def initialize_content(self):
        """ Initialize content/UI
        """
        # Initial value
        #   combo-boxes
        self._content.timeunit_combo.setCurrentIndex(0)
        self._content.valuechange_combo.setCurrentIndex(0)
        self._content.logbound_combo.setCurrentIndex(0)

        self._content.log_name_combo.clear()

        #   check-boxes
        self._content.timefilter_checkBox.setChecked(False)
        self._content.logvaluefilter_checkBox.setChecked(False)

        #   disable some input
        self._content.logname_edit.setEnabled(False)
        self._content.logminvalue_edit.setEnabled(False)
        self._content.logmaxvalue_edit.setEnabled(False)
        self._content.logintervalvalue_edit.setEnabled(False)
        self._content.valuechange_combo.setEnabled(False)
        self._content.logtol_edit.setEnabled(False)
        self._content.timetol_edit.setEnabled(False)
        self._content.logbound_combo.setEnabled(False)

        boolvalue = False
        self._content.timintervallength_edit.setEnabled(boolvalue)
        self._content.timeunit_combo.setEnabled(boolvalue)

        #   radio buttons
        # self._content.usesize_radiob.setChecked(True)

        # Constraints/Validator
        #   integers
        # iv0 = QIntValidator(self._content.numtimeinterval_edit)
        # iv0.setBottom(0)
        # self._content.numtimeinterval_edit.setValidator(iv0)

        iv1 = QIntValidator(self._content.run_number_edit)
        iv1.setBottom(0)
        self._content.run_number_edit.setValidator(iv1)

        #   floats
        dv0 = QDoubleValidator(self._content.starttime_edit)
        dv0.setBottom(0.)
        self._content.starttime_edit.setValidator(dv0)

        dv1 = QDoubleValidator(self._content.stoptime_edit)
        dv1.setBottom(0.)
        self._content.stoptime_edit.setValidator(dv1)

        dv2 = QDoubleValidator(self._content.timintervallength_edit)
        dv2.setBottom(0.)
        self._content.timintervallength_edit.setValidator(dv2)

        # Default states

        # Connections from action/event to function to handle
        self._content.timefilter_checkBox.stateChanged.connect(
            self._filterbytime_statechanged)

        self._content.logvaluefilter_checkBox.stateChanged.connect(
            self._filterbylogvalue_statechanged)

        self._content.load_button.clicked.connect(self._run_number_changed)

        self._content.run_number_edit.returnPressed.connect(
            self._run_number_changed)

        self._content.plot_log_button.clicked.connect(self._plot_log_clicked)

        self._content.syn_logname_button.clicked.connect(
            self._sync_logname_clicked)

        self._content.help_button.clicked.connect(self._show_help)

        # Validated widgets
        # self._connect_validated_lineedit(self._content.sample_edit)

        return
Exemple #13
0
    def __init__(self, appdata: CnaData, centralwidget):
        QDialog.__init__(self)
        self.setWindowTitle("Elementary Flux Mode Computation")

        self.appdata = appdata
        self.centralwidget = centralwidget
        self.eng = appdata.engine
        self.out = io.StringIO()
        self.err = io.StringIO()

        self.layout = QVBoxLayout()

        l1 = QHBoxLayout()
        self.constraints = QCheckBox("consider 0 in current scenario as off")
        self.constraints.setCheckState(Qt.Checked)
        l1.addWidget(self.constraints)
        self.layout.addItem(l1)

        l2 = QHBoxLayout()
        self.flux_bounds = QGroupBox(
            "use flux bounds to calculate elementary flux vectors")
        self.flux_bounds.setCheckable(True)
        self.flux_bounds.setChecked(False)

        vbox = QVBoxLayout()
        label = QLabel("Threshold for bounds to be unconstrained")
        vbox.addWidget(label)
        self.threshold = QLineEdit("100")
        validator = QIntValidator()
        validator.setBottom(0)
        self.threshold.setValidator(validator)
        vbox.addWidget(self.threshold)
        self.flux_bounds.setLayout(vbox)
        l2.addWidget(self.flux_bounds)
        self.layout.addItem(l2)

        l3 = QHBoxLayout()
        self.check_reversibility = QCheckBox("check reversibility")
        self.check_reversibility.setCheckState(Qt.Checked)
        l3.addWidget(self.check_reversibility)
        self.layout.addItem(l3)

        l4 = QHBoxLayout()
        self.convex_basis = QCheckBox("only convex basis")
        l4.addWidget(self.convex_basis)
        self.layout.addItem(l4)

        l5 = QHBoxLayout()
        self.isozymes = QCheckBox("consider isozymes only once")
        l5.addWidget(self.isozymes)
        self.layout.addItem(l5)

        # TODO: choose solver

        l7 = QHBoxLayout()
        self.rational_numbers = QCheckBox("use rational numbers")
        l7.addWidget(self.rational_numbers)
        self.layout.addItem(l7)

        lx = QHBoxLayout()
        self.button = QPushButton("Compute")
        self.cancel = QPushButton("Close")
        lx.addWidget(self.button)
        lx.addWidget(self.cancel)
        self.layout.addItem(lx)

        self.setLayout(self.layout)

        # Connecting the signal
        self.cancel.clicked.connect(self.reject)
        self.button.clicked.connect(self.compute)
    def initialize_content(self):
        """ Initialize content/UI
        """
        # Initial values for combo boxes
        # Combo boxes
        self._content.saveas_combo.setCurrentIndex(1)
        self._content.unit_combo.setCurrentIndex(1)
        self._content.bintype_combo.setCurrentIndex(1)

        # Radio buttons
        self._content.disablevancorr_chkbox.setChecked(False)

        # Check boxes
        self._content.usebin_button.setChecked(True)
        self._content.resamplex_button.setChecked(False)
        self._content.disablebkgdcorr_chkbox.setChecked(False)
        self._content.disablevancorr_chkbox.setChecked(False)
        self._content.disablevanbkgdcorr_chkbox.setChecked(False)

        # Label
        if self._instrument_name is not False:
            self._content.label.setText('Instrument: %s' % self._instrument_name.upper())
        else:
            self._content.label.setText('Instrument has not been set up.  You may not launch correctly.')

        # Enable disable
        if self._instrument_name.lower().startswith('nom') is False:
            self._content.lineEdit_expIniFile.setEnabled(False)
            self._content.pushButton_browseExpIniFile.setEnabled(False)
        else:
            self._content.lineEdit_expIniFile.setEnabled(True)
            self._content.pushButton_browseExpIniFile.setEnabled(True)

        # Line edit
        self._content.emptyrun_edit.setEnabled(True)
        self._content.vanrun_edit.setEnabled(True)
        self._content.vanbkgdrun_edit.setEnabled(True)
        self._content.resamplex_edit.setEnabled(False)

        # Constraints/Validator
        expression = r'[\d,-]*'
        iv0 = generateRegExpValidator(self._content.emptyrun_edit, expression)
        self._content.emptyrun_edit.setValidator(iv0)

        iv1 = generateRegExpValidator(self._content.vanrun_edit, expression)
        self._content.vanrun_edit.setValidator(iv1)

        iv3 = generateRegExpValidator(self._content.vanbkgdrun_edit, expression)
        self._content.vanbkgdrun_edit.setValidator(iv3)

        siv = QIntValidator(self._content.resamplex_edit)
        siv.setBottom(0)
        self._content.resamplex_edit.setValidator(siv)

        # Float/Double
        fiv = QDoubleValidator(self._content.binning_edit)
        self._content.binning_edit.setValidator(fiv)

        # Default states
        # self._handle_tzero_guess(self._content.use_ei_guess_chkbox.isChecked())

        # Connections from action/event to function to handle
        self._content.calfile_browse.clicked.connect(self._calfile_browse)
        self._content.charfile_browse.clicked.connect(self._charfile_browse)
        self._content.groupfile_browse.clicked.connect(self._groupfile_browse)
        self._content.pushButton_browseExpIniFile.clicked.connect(self.do_browse_ini_file)
        self._content.outputdir_browse.clicked.connect(self._outputdir_browse)
        self._content.binning_edit.textChanged.connect(self._binvalue_edit)
        self._content.bintype_combo.currentIndexChanged.connect(self._bintype_process)

        self._content.disablebkgdcorr_chkbox.clicked.connect(self._disablebkgdcorr_clicked)
        self._content.disablevancorr_chkbox.clicked.connect(self._disablevancorr_clicked)
        self._content.disablevanbkgdcorr_chkbox.clicked.connect(self._disablevanbkgdcorr_clicked)

        self._content.usebin_button.clicked.connect(self._usebin_clicked)
        self._content.resamplex_button.clicked.connect(self._resamplex_clicked)

        self._content.help_button.clicked.connect(self._show_help)

        # mutex for whether to update the linear/log drop-down
        self._content._binning_edit_mutex = False
    def initialize_content(self):
        """ Initialize content/UI
        """
        # Initial value
        #   combo-boxes
        self._content.timeunit_combo.setCurrentIndex(0)
        self._content.valuechange_combo.setCurrentIndex(0)
        self._content.logbound_combo.setCurrentIndex(0)

        self._content.log_name_combo.clear()

        #   check-boxes
        self._content.timefilter_checkBox.setChecked(False)
        self._content.logvaluefilter_checkBox.setChecked(False)

        #   disable some input
        self._content.logname_edit.setEnabled(False)
        self._content.logminvalue_edit.setEnabled(False)
        self._content.logmaxvalue_edit.setEnabled(False)
        self._content.logintervalvalue_edit.setEnabled(False)
        self._content.valuechange_combo.setEnabled(False)
        self._content.logtol_edit.setEnabled(False)
        self._content.timetol_edit.setEnabled(False)
        self._content.logbound_combo.setEnabled(False)

        boolvalue = False
        self._content.timintervallength_edit.setEnabled(boolvalue)
        self._content.timeunit_combo.setEnabled(boolvalue)

        #   radio buttons
        # self._content.usesize_radiob.setChecked(True)

        # Constraints/Validator
        #   integers
        # iv0 = QIntValidator(self._content.numtimeinterval_edit)
        # iv0.setBottom(0)
        # self._content.numtimeinterval_edit.setValidator(iv0)

        iv1 = QIntValidator(self._content.run_number_edit)
        iv1.setBottom(0)
        self._content.run_number_edit.setValidator(iv1)

        #   floats
        dv0 = QDoubleValidator(self._content.starttime_edit)
        dv0.setBottom(0.)
        self._content.starttime_edit.setValidator(dv0)

        dv1 = QDoubleValidator(self._content.stoptime_edit)
        dv1.setBottom(0.)
        self._content.stoptime_edit.setValidator(dv1)

        dv2 = QDoubleValidator(self._content.timintervallength_edit)
        dv2.setBottom(0.)
        self._content.timintervallength_edit.setValidator(dv2)

        # Default states

        # Connections from action/event to function to handle
        self._content.timefilter_checkBox.stateChanged.connect(self._filterbytime_statechanged)

        self._content.logvaluefilter_checkBox.stateChanged.connect(self._filterbylogvalue_statechanged)

        self._content.load_button.clicked.connect(self._run_number_changed)

        self._content.run_number_edit.returnPressed.connect(self._run_number_changed)

        self._content.plot_log_button.clicked.connect(self._plot_log_clicked)

        self._content.syn_logname_button.clicked.connect(self._sync_logname_clicked)

        self._content.help_button.clicked.connect(self._show_help)

        # Validated widgets
        # self._connect_validated_lineedit(self._content.sample_edit)

        return