@@ 3396-3456 (lines=61) @@ | ||
3393 | self._cfg_param_seq = cfg_param_seq |
|
3394 | ||
3395 | ||
3396 | def _set_sequence_editor_columns(self): |
|
3397 | """ Depending on the sequence parameters a table witll be created. """ |
|
3398 | ||
3399 | seq_param = self._seq_param |
|
3400 | ||
3401 | # Erase the delegate from the column, pass a None reference: |
|
3402 | for column in range(self._mw.seq_editor_TableWidget.columnCount()): |
|
3403 | self._mw.seq_editor_TableWidget.setItemDelegateForColumn(column, None) |
|
3404 | ||
3405 | # clear the number of columns: |
|
3406 | self._mw.seq_editor_TableWidget.setColumnCount(0) |
|
3407 | ||
3408 | # set the count to the desired length: |
|
3409 | self._mw.seq_editor_TableWidget.setColumnCount(len(seq_param)+1) |
|
3410 | ||
3411 | column = 0 |
|
3412 | # set the name for the column: |
|
3413 | self._mw.seq_editor_TableWidget.setHorizontalHeaderItem(column, QtWidgets.QTableWidgetItem()) |
|
3414 | self._mw.seq_editor_TableWidget.horizontalHeaderItem(column).setText('ensemble') |
|
3415 | self._mw.seq_editor_TableWidget.setColumnWidth(column, 100) |
|
3416 | ||
3417 | # give the delegated object the reference to the method: |
|
3418 | item_dict = {} |
|
3419 | item_dict['get_list_method'] = self.get_current_ensemble_list |
|
3420 | ||
3421 | comboDelegate = ComboBoxDelegate(self._mw.seq_editor_TableWidget, item_dict) |
|
3422 | self._mw.seq_editor_TableWidget.setItemDelegateForColumn(column, comboDelegate) |
|
3423 | ||
3424 | # the first element was the ensemble combobox. |
|
3425 | column = 1 |
|
3426 | for seq_param_name in seq_param: |
|
3427 | ||
3428 | param = seq_param[seq_param_name] |
|
3429 | ||
3430 | # self._mw.seq_editor_TableWidget.insertColumn(column) |
|
3431 | self._mw.seq_editor_TableWidget.setHorizontalHeaderItem(column, QtWidgets.QTableWidgetItem()) |
|
3432 | header_name = seq_param_name.replace('_',' ') |
|
3433 | self._mw.seq_editor_TableWidget.horizontalHeaderItem(column).setText(header_name) |
|
3434 | self._mw.seq_editor_TableWidget.setColumnWidth(column, 80) |
|
3435 | ||
3436 | # choose the proper delegate function: |
|
3437 | if param['type'] == bool: |
|
3438 | item_dict = param |
|
3439 | delegate = CheckBoxDelegate(self._mw.seq_editor_TableWidget, item_dict) |
|
3440 | elif param['type'] == int: |
|
3441 | item_dict = param |
|
3442 | delegate = SpinBoxDelegate(self._mw.seq_editor_TableWidget, item_dict) |
|
3443 | elif param['type'] == float: |
|
3444 | item_dict = param |
|
3445 | delegate = DoubleSpinBoxDelegate(self._mw.seq_editor_TableWidget, item_dict) |
|
3446 | ||
3447 | self._mw.seq_editor_TableWidget.setItemDelegateForColumn(column, delegate) |
|
3448 | ||
3449 | column += 1 |
|
3450 | ||
3451 | # at the end, initialize all the cells with the proper value: |
|
3452 | self.initialize_cells_sequence_editor(start_row=0, |
|
3453 | stop_row=self._mw.seq_editor_TableWidget.rowCount()) |
|
3454 | ||
3455 | self.set_cfg_param_seq() |
|
3456 | self._update_current_pulse_sequence() |
|
3457 | ||
3458 | def initialize_cells_sequence_editor(self, start_row, stop_row=None, |
|
3459 | start_col=None, stop_col=None): |
|
@@ 2093-2146 (lines=54) @@ | ||
2090 | raise NotImplementedError |
|
2091 | self._cfg_param_pb = cfg_param_pb |
|
2092 | ||
2093 | def _set_organizer_columns(self): |
|
2094 | ||
2095 | # Erase the delegate from the column, i.e. pass a None reference: |
|
2096 | for column in range(self._mw.block_organizer_TableWidget.columnCount()): |
|
2097 | self._mw.block_organizer_TableWidget.setItemDelegateForColumn(column, None) |
|
2098 | ||
2099 | # clear the number of columns: |
|
2100 | self._mw.block_organizer_TableWidget.setColumnCount(0) |
|
2101 | ||
2102 | # total number columns in block organizer: |
|
2103 | num_column = 1 |
|
2104 | self._mw.block_organizer_TableWidget.setColumnCount(num_column) |
|
2105 | ||
2106 | column = 0 |
|
2107 | self._mw.block_organizer_TableWidget.setHorizontalHeaderItem(column, QtWidgets.QTableWidgetItem()) |
|
2108 | self._mw.block_organizer_TableWidget.horizontalHeaderItem(column).setText('Pulse Block') |
|
2109 | self._mw.block_organizer_TableWidget.setColumnWidth(column, 100) |
|
2110 | ||
2111 | item_dict = {} |
|
2112 | item_dict['get_list_method'] = self.get_current_pulse_block_list |
|
2113 | ||
2114 | comboDelegate = ComboBoxDelegate(self._mw.block_organizer_TableWidget, item_dict) |
|
2115 | self._mw.block_organizer_TableWidget.setItemDelegateForColumn(column, comboDelegate) |
|
2116 | ||
2117 | column = 1 |
|
2118 | insert_at_col_pos = column |
|
2119 | for column, parameter in enumerate(self._add_pb_param): |
|
2120 | ||
2121 | # add the new properties to the whole column through delegate: |
|
2122 | item_dict = self._add_pb_param[parameter] |
|
2123 | ||
2124 | unit_text = item_dict['unit_prefix'] + item_dict['unit'] |
|
2125 | ||
2126 | self._mw.block_organizer_TableWidget.insertColumn(insert_at_col_pos+column) |
|
2127 | self._mw.block_organizer_TableWidget.setHorizontalHeaderItem(insert_at_col_pos+column, QtWidgets.QTableWidgetItem()) |
|
2128 | self._mw.block_organizer_TableWidget.horizontalHeaderItem(insert_at_col_pos+column).setText('{0} ({1})'.format(parameter,unit_text)) |
|
2129 | self._mw.block_organizer_TableWidget.setColumnWidth(insert_at_col_pos+column, 80) |
|
2130 | ||
2131 | # Use only DoubleSpinBox as delegate: |
|
2132 | if item_dict['unit'] == 'bool': |
|
2133 | delegate = CheckBoxDelegate(self._mw.block_organizer_TableWidget, item_dict) |
|
2134 | elif parameter == 'repetition': |
|
2135 | delegate = SpinBoxDelegate(self._mw.block_organizer_TableWidget, item_dict) |
|
2136 | else: |
|
2137 | delegate = DoubleSpinBoxDelegate(self._mw.block_organizer_TableWidget, item_dict) |
|
2138 | self._mw.block_organizer_TableWidget.setItemDelegateForColumn(insert_at_col_pos+column, delegate) |
|
2139 | ||
2140 | column += 1 |
|
2141 | ||
2142 | self.initialize_cells_block_organizer(start_row=0, |
|
2143 | stop_row=self._mw.block_organizer_TableWidget.rowCount()) |
|
2144 | ||
2145 | self.set_cfg_param_pb() |
|
2146 | self._update_current_pulse_block_ensemble() |
|
2147 | ||
2148 | ||
2149 | def initialize_cells_block_organizer(self, start_row, stop_row=None, |
@@ 1616-1669 (lines=54) @@ | ||
1613 | raise NotImplementedError |
|
1614 | self._cfg_param_pb = cfg_param_pb |
|
1615 | ||
1616 | def _set_organizer_columns(self): |
|
1617 | ||
1618 | # Erase the delegate from the column, i.e. pass a None reference: |
|
1619 | for column in range(self._pe.block_organizer_TableWidget.columnCount()): |
|
1620 | self._pe.block_organizer_TableWidget.setItemDelegateForColumn(column, None) |
|
1621 | ||
1622 | # clear the number of columns: |
|
1623 | self._pe.block_organizer_TableWidget.setColumnCount(0) |
|
1624 | ||
1625 | # total number columns in block organizer: |
|
1626 | num_column = 1 |
|
1627 | self._pe.block_organizer_TableWidget.setColumnCount(num_column) |
|
1628 | ||
1629 | column = 0 |
|
1630 | self._pe.block_organizer_TableWidget.setHorizontalHeaderItem(column, QtWidgets.QTableWidgetItem()) |
|
1631 | self._pe.block_organizer_TableWidget.horizontalHeaderItem(column).setText('Pulse Block') |
|
1632 | self._pe.block_organizer_TableWidget.setColumnWidth(column, 100) |
|
1633 | ||
1634 | item_dict = {} |
|
1635 | item_dict['get_list_method'] = self.get_current_pulse_block_list |
|
1636 | ||
1637 | comboDelegate = ComboBoxDelegate(self._pe.block_organizer_TableWidget, item_dict) |
|
1638 | self._pe.block_organizer_TableWidget.setItemDelegateForColumn(column, comboDelegate) |
|
1639 | ||
1640 | column = 1 |
|
1641 | insert_at_col_pos = column |
|
1642 | for column, parameter in enumerate(self._add_pb_param): |
|
1643 | ||
1644 | # add the new properties to the whole column through delegate: |
|
1645 | item_dict = self._add_pb_param[parameter] |
|
1646 | ||
1647 | unit_text = item_dict['unit_prefix'] + item_dict['unit'] |
|
1648 | ||
1649 | self._pe.block_organizer_TableWidget.insertColumn(insert_at_col_pos+column) |
|
1650 | self._pe.block_organizer_TableWidget.setHorizontalHeaderItem(insert_at_col_pos+column, QtWidgets.QTableWidgetItem()) |
|
1651 | self._pe.block_organizer_TableWidget.horizontalHeaderItem(insert_at_col_pos+column).setText('{0} ({1})'.format(parameter,unit_text)) |
|
1652 | self._pe.block_organizer_TableWidget.setColumnWidth(insert_at_col_pos+column, 80) |
|
1653 | ||
1654 | # Use only DoubleSpinBox as delegate: |
|
1655 | if item_dict['unit'] == 'bool': |
|
1656 | delegate = CheckBoxDelegate(self._pe.block_organizer_TableWidget, item_dict) |
|
1657 | elif parameter == 'repetition': |
|
1658 | delegate = SpinBoxDelegate(self._pe.block_organizer_TableWidget, item_dict) |
|
1659 | else: |
|
1660 | delegate = DoubleSpinBoxDelegate(self._pe.block_organizer_TableWidget, item_dict) |
|
1661 | self._pe.block_organizer_TableWidget.setItemDelegateForColumn(insert_at_col_pos+column, delegate) |
|
1662 | ||
1663 | column += 1 |
|
1664 | ||
1665 | self.initialize_cells_block_organizer(start_row=0, |
|
1666 | stop_row=self._pe.block_organizer_TableWidget.rowCount()) |
|
1667 | ||
1668 | self.set_cfg_param_pb() |
|
1669 | self._update_current_pulse_block_ensemble() |
|
1670 | ||
1671 | ||
1672 | def initialize_cells_block_organizer(self, start_row, stop_row=None, |