Exemple #1
0
    def __init__(self, parent):
        # Initialize inherited QTableView
        super().__init__(parent)

        # Create custom data model and hand it to the QTableView.
        # (essentially it's a PulseSequence instance with QAbstractTableModel interface)
        model = SequenceEditorTableModel()
        self.setModel(model)

        # Set item selection and editing behaviour
        self.setEditTriggers(
            QtGui.QAbstractItemView.CurrentChanged | QtGui.QAbstractItemView.SelectedClicked)
        self.setSelectionBehavior(QtGui.QAbstractItemView.SelectItems)
        self.setSelectionMode(QtGui.QAbstractItemView.SingleSelection)

        # Set item delegate (ComboBox) for PulseBlockEnsemble column
        self.setItemDelegateForColumn(0, ComboBoxItemDelegate(self, list(),
                                                              self.model().ensembleNameRole,
                                                              QtCore.QSize(100, 50)))
        # Set item delegate (SpinBoxes) for repetition column
        self.setItemDelegateForColumn(1, SpinBoxItemDelegate(self, {'init_val': 1, 'min': -1},
                                                             self.model().repetitionsRole))
        # Set item delegate (SpinBoxes) for go_to column
        self.setItemDelegateForColumn(2, SpinBoxItemDelegate(self, {'init_val': -1, 'min': -1},
                                                             self.model().goToRole))
        # Set item delegate (SpinBoxes) for event_jump_to column
        self.setItemDelegateForColumn(3, SpinBoxItemDelegate(self, {'init_val': -1, 'min': -1},
                                                             self.model().eventJumpToRole))
        # Set item delegate (ComboBox) for event_trigger column
        self.setItemDelegateForColumn(4, ComboBoxItemDelegate(self, ['OFF'],
                                                              self.model().eventTriggerRole))
        # Set item delegate (ComboBox) for wait_for column
        self.setItemDelegateForColumn(5, ComboBoxItemDelegate(self, ['OFF'],
                                                              self.model().waitForRole))
        # Set item delegate (ComboBox) for flag_trigger column
        self.setItemDelegateForColumn(6, ComboBoxItemDelegate(self, ['OFF'],
                                                              self.model().flagTriggerRole))
        # Set item delegate (ComboBox) for flag_high column
        self.setItemDelegateForColumn(7, ComboBoxItemDelegate(self, ['OFF'],
                                                              self.model().flagHighRole))

        # Set header sizes
        self.horizontalHeader().setSectionResizeMode(QtWidgets.QHeaderView.Fixed)
        # self.horizontalHeader().setDefaultSectionSize(100)
        # self.horizontalHeader().setStyleSheet('QHeaderView { font-weight: 400; }')
        self.verticalHeader().setSectionResizeMode(QtWidgets.QHeaderView.Fixed)
        self.verticalHeader().setDefaultSectionSize(50)
        for col in range(self.columnCount()):
            width = self.itemDelegateForColumn(col).sizeHint().width()
            self.setColumnWidth(col, width)
        return
Exemple #2
0
    def __init__(self, parent):
        # Initialize inherited QTableView
        super().__init__(parent)

        # Create custom data model and hand it to the QTableView.
        # (essentially it's a PulseBlockEnsemble instance with QAbstractTableModel interface)
        model = EnsembleEditorTableModel()
        self.setModel(model)

        # Set item selection and editing behaviour
        self.setEditTriggers(
            QtGui.QAbstractItemView.CurrentChanged | QtGui.QAbstractItemView.SelectedClicked)
        self.setSelectionBehavior(QtGui.QAbstractItemView.SelectItems)
        self.setSelectionMode(QtGui.QAbstractItemView.SingleSelection)

        # Set item delegate (ComboBox) for PulseBlock column
        self.setItemDelegateForColumn(0, ComboBoxItemDelegate(self, list(),
                                                              self.model().blockNameRole,
                                                              QtCore.QSize(100, 50)))
        # Set item delegate (SpinBoxes) for repetition column
        repetition_item_dict = {'init_val': 0, 'min': 0, 'max': (2**31)-1}
        self.setItemDelegateForColumn(1, SpinBoxItemDelegate(self, repetition_item_dict,
                                                             self.model().repetitionsRole))

        # Set header sizes
        self.horizontalHeader().setSectionResizeMode(QtWidgets.QHeaderView.Fixed)
        # self.horizontalHeader().setDefaultSectionSize(100)
        # self.horizontalHeader().setStyleSheet('QHeaderView { font-weight: 400; }')
        self.verticalHeader().setSectionResizeMode(QtWidgets.QHeaderView.Fixed)
        self.verticalHeader().setDefaultSectionSize(50)
        for col in range(self.columnCount()):
            width = self.itemDelegateForColumn(col).sizeHint().width()
            self.setColumnWidth(col, width)
        return
Exemple #3
0
    def set_available_flags(self, flag_list):
        """

        @param list flag_list: List of strings describing the available pulse generator flag output
                               channels.
        """
        if not isinstance(flag_list, list):
            return
        flag_list.insert(0, 'OFF')
        # Set item delegate (ComboBox) for event_trigger column
        self.setItemDelegateForColumn(6, ComboBoxItemDelegate(self, flag_list,
                                                              self.model().flagTriggerRole))
        # Set item delegate (ComboBox) for wait_for column
        self.setItemDelegateForColumn(7, ComboBoxItemDelegate(self, flag_list,
                                                              self.model().flagHighRole))
        return
Exemple #4
0
    def set_available_triggers(self, trigger_list):
        """

        @param list trigger_list: List of strings describing the available pulse generator trigger
                                  input channels.
        """
        if not isinstance(trigger_list, list):
            return
        trigger_list.insert(0, 'OFF')
        # Set item delegate (ComboBox) for event_trigger column
        self.setItemDelegateForColumn(4, ComboBoxItemDelegate(self, trigger_list,
                                                              self.model().eventTriggerRole))
        # Set item delegate (ComboBox) for wait_for column
        self.setItemDelegateForColumn(5, ComboBoxItemDelegate(self, trigger_list,
                                                              self.model().waitForRole))
        return
Exemple #5
0
    def _set_item_delegates(self):
        """

        @return:
        """
        # Set item delegates (scientific SpinBoxes) for length and increment column
        length_item_dict = {
            'unit': 's',
            'init_val': '10.0e-9',
            'min': 0,
            'max': np.inf,
            'dec': 6
        }
        self.setItemDelegateForColumn(
            0,
            ScienDSpinBoxItemDelegate(self, length_item_dict,
                                      self.model().lengthRole))
        increment_item_dict = {
            'unit': 's',
            'init_val': 0,
            'min': -np.inf,
            'max': np.inf,
            'dec': 6
        }
        self.setItemDelegateForColumn(
            1,
            ScienDSpinBoxItemDelegate(self, increment_item_dict,
                                      self.model().incrementRole))

        # If any digital channels are present, set item delegate (custom multi-CheckBox widget)
        # for digital channels column.
        if len(self.model().digital_channels) > 0:
            self.setItemDelegateForColumn(
                2,
                DigitalStatesItemDelegate(self,
                                          self.model().digitalStateRole))
            offset_index = 3  # to indicate which column comes next.
        else:
            offset_index = 2  # to indicate which column comes next.

        # loop through all analog channels and set two item delegates for each channel.
        # First a ComboBox delegate for the analog shape column and second a custom
        # composite widget widget for the analog parameters column.
        for num, chnl in enumerate(self.model().analog_channels):
            self.setItemDelegateForColumn(
                offset_index + 2 * num,
                ComboBoxItemDelegate(self,
                                     sorted(SamplingFunctions.parameters),
                                     self.model().analogShapeRole))
            self.setItemDelegateForColumn(
                offset_index + 2 * num + 1,
                AnalogParametersItemDelegate(self, [
                    self.model().analogFunctionRole,
                    self.model().analogParameterRole
                ]))
        return
Exemple #6
0
    def set_available_block_ensembles(self, ensembles):
        """

        @param ensembles:
        @return: int, error code (>=0: OK, <0: ERR)
        """
        err_code = self.model().set_available_block_ensembles(ensembles)
        if err_code >= 0:
            delegate = ComboBoxItemDelegate(
                self, sorted(self.model().available_block_ensembles), self.model().ensembleNameRole)
            self.setItemDelegateForColumn(0, delegate)
        return err_code
Exemple #7
0
    def set_available_pulse_blocks(self, blocks):
        """

        @param list|set blocks:
        @return: int, error code (>=0: OK, <0: ERR)
        """
        if isinstance(blocks, (list, dict, set)):
            blocks = sorted(blocks)
        else:
            return -1

        err_code = self.model().set_available_pulse_blocks(blocks)
        self.setItemDelegateForColumn(
            0,
            ComboBoxItemDelegate(self, blocks, self.model().blockNameRole))
        return err_code