Exemple #1
0
 def restart_selector(self):
     """Function that ensures that only one type of restartfile can be selected
     at a given time in the restartfile window.
     Author
     ----------
     Jonathan Chico
     """
     from PyQt5.QtCore import QSignalBlocker
     if self.sender() == self.DWOptBox:
         if self.DWOptBox.isChecked():
             self.SkxOptBox.setChecked(False)
             QSignalBlocker(self.SkxOptBox)
             self.HLOptBox.setChecked(False)
             QSignalBlocker(self.HLOptBox)
     if self.sender() == self.SkxOptBox:
         if self.SkxOptBox.isChecked():
             self.DWOptBox.setChecked(False)
             QSignalBlocker(self.DWOptBox)
             self.HLOptBox.setChecked(False)
             QSignalBlocker(self.HLOptBox)
     if self.sender() == self.HLOptBox:
         if self.HLOptBox.isChecked():
             self.SkxOptBox.setChecked(False)
             QSignalBlocker(self.SkxOptBox)
             self.DWOptBox.setChecked(False)
             QSignalBlocker(self.DWOptBox)
     if self.sender() == self.InpDwTypeBox:
         if self.InpDwTypeBox.isChecked():
             self.InpDWVortex.setChecked(False)
             QSignalBlocker(self.InpDWVortex)
     if self.sender() == self.InpDWVortex:
         if self.InpDWVortex.isChecked():
             self.InpDwTypeBox.setChecked(False)
             QSignalBlocker(self.InpDwTypeBox)
     return
Exemple #2
0
 def saveUserText(self):
     blocker = QSignalBlocker(self.ui.textEdit)
     selected = self.getSelectedSampleTextId()
     if selected in self.userTextIds:
         self.user_texts.setValue("text" + str(selected),
                                  self.ui.textEdit.toPlainText())
     m = 1
Exemple #3
0
 def _on_checked(self, i):
     block_signals = QSignalBlocker(self)  # noqa
     _logger.debug("clicked --> %d " % (i + 1))
     for l in self.labels:
         l.is_active = False
     self.labels[i].is_active = not self.labels[i].is_active
     for j in range(self.rowCount()):
         self.item(j, 2).setCheckState(Qt.Unchecked)
     self.item(i, 2).setCheckState(Qt.Checked)
 def save_perspective(self):
     perspective_name, ok = QInputDialog.getText(self, 'Save perspective', 'Enter unique name:')
     if ok and perspective_name:
         self.dock_manager.addPerspective(perspective_name)
         _ = QSignalBlocker(self.perspective_combo_box)
         self.perspective_combo_box.clear()
         self.perspective_combo_box.addItems(self.dock_manager.perspectiveNames())
         self.perspective_combo_box.setCurrentText(perspective_name)
         self.save_perspectives()
Exemple #5
0
    def __set_current_scan(self, index: int):
        _ = QSignalBlocker(self)
        self.current_index = index

        name = self.__make_base_name()
        scan = Scan()
        scan.load_from(name)
        self.scan = scan
        self.ui.slide_line.setValue(0)
        self.__set_current_line(0)
 def save_perspective(self):
     perspective_name, ok = QInputDialog.getText(self, "Save Perspective", "Enter Unique name:")
     if not ok or not perspective_name:
         return
     
     self.dock_manager.addPerspective(perspective_name)
     blocker = QSignalBlocker(self.perspective_combobox)
     self.perspective_combobox.clear()
     self.perspective_combobox.addItems(self.dock_manager.perspectiveNames())
     self.perspective_combobox.setCurrentText(perspective_name)
Exemple #7
0
    def _set_combos_to_builtin(self):
        """Used when we switch to compute forward mode"""
        block_signals = QSignalBlocker(self._montages_combo)  # noqa
        self._montages_combo.setItems(self.builtin_montage_names)
        self.montage = self.default_montage
        self._spacings_combo.setItems(
            [k for k in self.spacings_desc if k != 'imported'])
        self.spacing = self.default_spacing  # uses spacing setter
        self._forwards_combo_widget.hide()
        self._set_hints()

        self._use_default_montage_radio.show()
        self._import_montage_radio.show()
        self._select_montage_dialog.show()
Exemple #8
0
 def select_security(self, selection):
     if isinstance(selection, QItemSelection):
         if not selection.indexes():  # no selection
             return
     idx = self.ui.endpointsView.currentIndex()
     transport_profile_uri = self.endpoints_model.data(
         idx.siblingAtColumn(3))
     if transport_profile_uri != "http://opcfoundation.org/UA-Profile/Transport/uatcp-uasc-uabinary":
         blocker = QSignalBlocker(self.ui.endpointsView.selectionModel())
         self.ui.endpointsView.selectionModel().clearSelection()
     else:
         security_mode = self.endpoints_model.data(idx.siblingAtColumn(1))
         security_policy = self.endpoints_model.data(idx.siblingAtColumn(2))
         self.ui.modeComboBox.setCurrentText(security_mode)
         self.ui.policyComboBox.setCurrentText(security_policy)
Exemple #9
0
    def _set_hints(self):
        """Set popup description messages to comboboxes"""
        block_signals = QSignalBlocker(self._montages_combo)  # noqa

        for i, key in enumerate(self._montages_combo.getItems()):
            try:
                self._montages_combo.setItemData(i, self.montages_desc[key],
                                                 Qt.ToolTipRole)
            except KeyError:
                pass

        for i, key in enumerate(self._spacings_combo.getItems()):
            try:
                self._spacings_combo.setItemData(i, self.spacings_desc[key],
                                                 Qt.ToolTipRole)
            except KeyError:
                pass
Exemple #10
0
    def update_projection(self, image_data, preview_slice_index: int,
                          tilt_angle: Optional[Degrees]):
        """
        Updates the preview projection image and associated annotations.

        Region of interest sets the bounds of the image axes, it does not
        resize the data itself. The advantage of this is that the coordinates
        do not change.

        :param image_data: Projection image data (single/2D image)
        :param preview_slice_index: Y coordinate at which to draw the preview
                                    slice indicator
        :param tilt_angle: Angle of the tilt line
        """

        with QSignalBlocker(self.previewSliceIndex):
            self.previewSliceIndex.setValue(preview_slice_index)

        self.image_view.update_projection(image_data, preview_slice_index,
                                          tilt_angle)
Exemple #11
0
    def __init__(self, parent=None):
        QTreeWidget.__init__(self, parent)
        

        self.setItemsExpandable(True)
        self.setAnimated(True)
        self.setDragEnabled(True)
        self.setHeaderHidden(True)
        self.setDropIndicatorShown(True)
        self.setDragDropMode(QAbstractItemView.InternalMove)
        self.blocker = QSignalBlocker(self)
        self.blocker.unblock()
        

        # only one by on for now
        #self.setSelectionMode(QAbstractItemView.ExtendedSelection)
        self.settings=SETTINGS

        root=self.invisibleRootItem()
        root.setData(0,Qt.ToolTipRole,"root")
Exemple #12
0
 def mousePressEvent(self, event: QMouseEvent) -> None:
     pos = self.mapToScene(event.localPos().toPoint())
     x = int(pos.x())
     y = int(pos.y())
     x = get_limit_pos(x, 1)
     y = get_limit_pos(y, 0)
     self.cur_id = ''
     
     # choose item by clicking canvas
     if self.status == 'choose':
         # item = g_canvas.scene().itemAt(x, y, g_transform)
         items = self.item_dict.values()
         pos = [x,y]
         # break_flg
         b_flg = False
         id = ''
         # select in canvas
         for item in items:
             if b_flg:
                 break
             for coor in item.pixels:
                 if is_close(coor, pos):
                     b_flg = True
                     self.selection_changed(item.id)
                     id = item.id
                     break
         # select in list_widget
         for i in range(1, g_list_widget.count()):
             widget_item = g_list_widget.item(i)
             strList = widget_item.text().split()
             if(strList[-1] == id):
                 g_list_widget.setCurrentRow(i)
                 QSignalBlocker(g_list_widget)
                 widget_item.setSelected(True)
                 break
     
     # 点击边界外附近时拖动画布
     self.is_image_scaling = 0
     if g_width-5 <= x <= g_width+5 and g_height-5 <= y <= g_height+5:
         self.is_image_scaling = 3  
     elif g_width-5 <= x <= g_width+5:  
         self.is_image_scaling = 1  
     elif g_height-5 <= y <= g_height+5:  
         self.is_image_scaling = 2
     
     def press_draw():
         global g_draw_status
         if self.status not in g_draw_status:
             return ''
         if self.temp_item.id != self.main_window.get_id():
             self.temp_item = MyItem(self.temp_id, self.status, \
                                     [[x, y], [x, y]], self.temp_algorithm)
             self.scene().addItem(self.temp_item)
         else:
             # needs more than two points
             if self.status == 'polygon':
                 self.temp_item.p_list.append([x,y])
             elif self.status == 'curve':
                 self.temp_item.p_list.insert(-1, [x,y])
         return self.temp_item.id
     
     def press_edit():
         if self.status not in g_edit_status:
             return ''
         if self.selected_id == '':
             print("请选择图元.")
             return
         sid = self.selected_id
         if self.status in ['translate','clip']:
             if self.status == 'clip' \
             and self.item_dict[sid].item_type != 'line':
                 g_window.statusBar().showMessage('不能裁剪非线段')
                 self.status = ''
             else:
                 self.item_dict[sid].edit_type = self.status
                 self.item_dict[sid].poi = [x,y]
                 self.item_dict[sid].poi1 = [x,y]
                 self.item_dict[sid].edit_algorithm = self.temp_algorithm
                 self.item_dict[sid].edit_over = 0
         elif self.status in ['rotate', 'scale']:
             if self.item_dict[sid].param_cnt == 0:
                 self.item_dict[sid].edit_type = self.status
                 self.item_dict[sid].center = [x,y]
                 self.item_dict[sid].edit_over = 0
                 self.item_dict[sid].param_cnt = 1
             elif self.item_dict[sid].param_cnt == 1:
                 self.item_dict[sid].poi = [x,y]
                 self.item_dict[sid].poi1 = [x,y]
                 self.item_dict[sid].param_cnt = 2
             else:
                 self.status = ''
                 self.item_dict[sid].edit_clear()
         else:
             print("Undefined Behavior: No such edit situation")
             return ''
         return sid
     
     # draw or edit
     if self.is_image_scaling == 0:
         dealing_id = press_draw()
         if dealing_id != '':
             self.cur_id = dealing_id
         dealing_id = press_edit()
         if dealing_id != '':
             self.cur_id = dealing_id
     self.updateScene([self.sceneRect()])
     #self.updateScene([self.temp_item.boundingRect()])
     super().mousePressEvent(event)
Exemple #13
0
 def __set_current_directory(self, directory):
     _ = QSignalBlocker(self)
     self.current_dir = directory
     self.ui.slide_file.setValue(0)
     self.__set_current_scan(0)
Exemple #14
0
 def reset(self):
     """Reset value back to initial value."""
     with QSignalBlocker(
             self):  # We do not want to re-run manipulate on reset
         self.value = self._init_value
Exemple #15
0
 def setItems(self, items):
     block_signals = QSignalBlocker(self)  # noqa
     for i in range(self.count()):
         self.removeItem(0)
     self.addItems(items)
Exemple #16
0
 def _set_montages_combo_to_available(self):
     block_signals = QSignalBlocker(self._montages_combo)  # noqa
     self._montages_combo.setItems(self._available_montages)
     self.montage = self.default_montage
     self._set_spacings_combo_to_available()
Exemple #17
0
 def setCustomSampleText(self, id=0):
     blocker = QSignalBlocker(self.ui.textEdit)
     vals = self.user_texts.value('text' + str(id),
                                  'Write your Text here ..')
     self.ui.textEdit.setText(vals)
     return True
Exemple #18
0
 def pixel_size(self, value: int):
     with QSignalBlocker(self.pixelSize):
         self.pixelSize.setValue(value)