def activate(self): cursor = QCursor() cursor.setShape(Qt.ArrowCursor) self.iface.mapCanvas().setCursor(cursor) myLayers = [] # Editing layers = self.getLayers() for layer in layers: openedLayerPath = self.getLayerPath(layer) for name in self.ownMainLayers: layerPath = self.generatePath(self.ProjectDirectory, self.NetworkName + "_" + name + ".shp") if openedLayerPath == layerPath: myLayers.append(layer) if not layer.isEditable(): layer.startEditing() # Snapping self.snapper = QgsMapCanvasSnappingUtils(self.iface.mapCanvas()) self.snapper.setMapSettings(self.iface.mapCanvas().mapSettings()) config = QgsSnappingConfig(QgsProject.instance()) config.setType(2) # Vertex config.setMode(2) # All layers config.setTolerance(1) config.setUnits(2) # Pixels config.setEnabled(True) self.snapper.setConfig(config)
def prepare_identify_plot(self): """ Custom Identify tool was activated, prepare everything for identifying plots """ self.active_map_tool_before_custom = self.canvas.mapTool() self.selection_color = self.canvas.selectionColor( ) # Probably QColor('#ffff00') self.btn_identify_plot.setChecked(True) self.canvas.mapToolSet.connect(self.initialize_tools) self.canvas.setSelectionColor(QColor("red")) if self._plot_layer is None: self.add_layers() self.maptool_identify.setLayer(self._plot_layer) cursor = QCursor() cursor.setShape(Qt.PointingHandCursor) self.maptool_identify.setCursor(cursor) self.canvas.setMapTool(self.maptool_identify) try: self.maptool_identify.featureIdentified.disconnect() except TypeError as e: pass self.maptool_identify.featureIdentified.connect(self.get_info_by_plot)
def __init__(self, parent=None): """Initialize the components of the viewer widget.""" super(MainWidget, self).__init__(parent) self.frame = parent self.status_bar = self.frame.status_bar # set cursor # cursor_img = pkg_resources.resource_filename('foct_viewer.images', # 'cursor-cross.png') # pixmap = QPixmap(cursor_img) # crosshair = QCursor(pixmap) crosshair = QCursor() crosshair.setShape(4) self.view.setCursor(Qt.CrossCursor) self.toggle_histogram(ev=None, hide=True) self.ui.roiBtn.hide() self.ui.menuBtn.hide() self.view.invertY(False) # plot items for seg data num_lines = 8 self.line_plots = [pg.PlotCurveItem() for i in range(num_lines)] self.line2_plots = [pg.PlotCurveItem() for i in range(num_lines)] for line in self.line_plots: self.view.addItem(line) for line in self.line2_plots: self.view.addItem(line) # attributes self.foct_path = None self.foct_data = None self.ssada_data = None self.seg_data = None self.seg2_data = None self.play_stop = None self.lims = None self.path_label = None self.step = 24 self.line_drawing = 0 self.sigTimeChanged.connect(self.draw_lines) self.sig_data_changed.connect(self.on_data_changed) self.sig_lines_changed.connect(self.on_lines_changed) # monkey patch wheelevent from viewbox self.view.wheelEvent = self.wheelEvent # moneky patch mouseclick event while keeping old self.view_old_mouseClickEvent = self.view.mouseClickEvent self.view.mouseClickEvent = self.mouseClickEvent # moneky patch mouseclick event while keeping old self.view_old_mouseDragEvent = self.view.mouseDragEvent self.view.mouseDragEvent = self.mouseDragEvent
def __init__(self, parent=None): QLabel.__init__(self, parent) self.minSquareSide = 256 self.rubberBand = ResizableRubberBand(self) self.rubberBand.setGeometry(0, 0, self.minSquareSide, self.minSquareSide) dragCursor = QCursor() dragCursor.setShape(Qt.SizeAllCursor) self.rubberBand.setCursor(dragCursor) self.rubberBand.setMinimumSize(self.minSquareSide, self.minSquareSide) self.rubberBand.show()
def GetMousePress(self, event): self.FixOverlays() self.mouseX0 = event.x() self.mouseY0 = event.y() self.mouseX = self.mouseX0 self.mouseY = self.mouseY0 if event.button() == 1 and self.drawing and self.camOpen: self.mouseDrawingDown = True self.DrawMeasOverlay() elif event.button() == 1 and self.marking and self.camOpen: self.mouseMarkingDown = True self.DrawMarkerOverlay(self.markersizeSpin.value()) if event.button() == 2: self.mouseGoDown = True self.mouseX0 = int(self.camView.width() / 2) self.mouseY0 = int(self.camView.height() / 2) self.mouseX = self.mouseX0 self.mouseY = self.mouseY0 dx = self.mouseX - self.mouseX0 dy = self.mouseY - self.mouseY0 self.motors.CalculateContParams( 1, 2 * dx / self.camView.width(), 0.008875 * np.exp(0.04721 * self.multiDial.value())) self.motors.CalculateContParams( 2, 2 * dy / self.camView.height(), 0.008875 * np.exp(0.04721 * self.multiDial.value())) self.movXTimer.setInterval(self.motors.xWait * 1000) self.movYTimer.setInterval(self.motors.yWait * 1000) self.movXTimer.start() self.movYTimer.start() if self.motors.xOK: self.xOK.setPixmap(QPixmap("yellow_led.png")) if self.motors.yOK: self.yOK.setPixmap(QPixmap("yellow_led.png")) self.getcontposTimer.start() self.DrawGoOverlay() cursor = QCursor() cursor.setShape(Qt.SizeAllCursor) cursor.setPos( self.camOverlay.mapToGlobal(QPoint(self.mouseX, self.mouseY))) QApplication.setOverrideCursor(cursor)
def __init__(self, canvas, layer, multi=True): self.canvas = canvas QgsMapToolEmitPoint.__init__(self, self.canvas) self._multi = multi self._layer = layer # Cursor cursor = QCursor() cursor.setShape(Qt.CrossCursor) self.setCursor(cursor) # RubberBand Style self.rubberBand = QgsRubberBand(self.canvas, True) self.rubberBand.setBrushStyle(Qt.Dense4Pattern) self.rubberBand.setColor(QColor(255, 181, 92)) self.rubberBand.setStrokeColor(QColor(232, 137, 72)) self.rubberBand.setWidth(0.2) self.reset()
def setCursorStyle(self): cursor = QCursor() cursor.setShape(self.cursorStyle) self.setCursor(cursor)
def set_cursor(self, reset): cursor = QCursor() if reset: cursor.setShape(Qt.SizeAllCursor) else: if self.resize_orientation == ResizeUtilities.ResizeOrientation.Left: cursor.setShape(Qt.SizeHorCursor) elif self.resize_orientation == ResizeUtilities.ResizeOrientation.TopLeft: cursor.setShape(Qt.SizeFDiagCursor) elif self.resize_orientation == ResizeUtilities.ResizeOrientation.Top: cursor.setShape(Qt.SizeVerCursor) elif self.resize_orientation == ResizeUtilities.ResizeOrientation.TopRight: cursor.setShape(Qt.SizeBDiagCursor) elif self.resize_orientation == ResizeUtilities.ResizeOrientation.Right: cursor.setShape(Qt.SizeHorCursor) elif self.resize_orientation == ResizeUtilities.ResizeOrientation.BottomRight: cursor.setShape(Qt.SizeFDiagCursor) elif self.resize_orientation == ResizeUtilities.ResizeOrientation.Bottom: cursor.setShape(Qt.SizeVerCursor) else: cursor.setShape(Qt.SizeBDiagCursor) QWidget.setCursor (self, cursor)