Class: QgsSnapToGridCanvasItem¶
- class qgis.gui.QgsSnapToGridCanvasItem¶
Bases:
QgsMapCanvasItem
Shows a grid on the map canvas given a spatial resolution.
Added in version 3.4.
QgsSnapToGridCanvasItem(mapCanvas: Optional[QgsMapCanvas]) Will automatically be added to the
mapCanvas
.Methods
The CRS in which the grid should be calculated.
Enable this item.
- param painter:
A point that will be highlighted on the map canvas.
The resolution of the grid in map units.
The CRS in which the grid should be calculated.
Enable this item.
A point that will be highlighted on the map canvas.
The resolution of the grid in map units.
Sets render context parameters
schedules map canvas for repaint
- contextMenuEvent(self, event: QGraphicsSceneContextMenuEvent | None)¶
- crs(self) QgsCoordinateReferenceSystem ¶
The CRS in which the grid should be calculated. By default will be an invalid
QgsCoordinateReferenceSystem
and as such equal to the CRS of the map canvas.- Return type:
- dragEnterEvent(self, event: QGraphicsSceneDragDropEvent | None)¶
- dragLeaveEvent(self, event: QGraphicsSceneDragDropEvent | None)¶
- dragMoveEvent(self, event: QGraphicsSceneDragDropEvent | None)¶
- dropEvent(self, event: QGraphicsSceneDragDropEvent | None)¶
- enabled(self) bool ¶
Enable this item. It will be hidden if disabled.
- Return type:
bool
- focusInEvent(self, event: QFocusEvent | None)¶
- focusOutEvent(self, event: QFocusEvent | None)¶
- hoverEnterEvent(self, event: QGraphicsSceneHoverEvent | None)¶
- hoverLeaveEvent(self, event: QGraphicsSceneHoverEvent | None)¶
- hoverMoveEvent(self, event: QGraphicsSceneHoverEvent | None)¶
- inputMethodEvent(self, event: QInputMethodEvent | None)¶
- inputMethodQuery(self, query: Qt.InputMethodQuery) Any ¶
- itemChange(self, change: QGraphicsItem.GraphicsItemChange, value: Any) Any ¶
- keyPressEvent(self, event: QKeyEvent | None)¶
- keyReleaseEvent(self, event: QKeyEvent | None)¶
- mouseDoubleClickEvent(self, event: QGraphicsSceneMouseEvent | None)¶
- mouseMoveEvent(self, event: QGraphicsSceneMouseEvent | None)¶
- mousePressEvent(self, event: QGraphicsSceneMouseEvent | None)¶
- mouseReleaseEvent(self, event: QGraphicsSceneMouseEvent | None)¶
- paint(self, painter: QPainter | None)¶
- Parameters:
painter (Optional[QPainter])
- point(self) QgsPointXY ¶
A point that will be highlighted on the map canvas. The point needs to be in map coordinates. The closest point on the grid will be highlighted.
- Return type:
- precision(self) float ¶
The resolution of the grid in map units. If a crs has been specified it will be in CRS units.
- Return type:
float
- prepareGeometryChange(self)¶
- sceneEvent(self, event: QEvent | None) bool ¶
- sceneEventFilter(self, watched: QGraphicsItem | None, event: QEvent | None) bool ¶
- setCrs(self, crs: QgsCoordinateReferenceSystem)¶
The CRS in which the grid should be calculated. By default will be an invalid
QgsCoordinateReferenceSystem
and as such equal to the CRS of the map canvas.- Parameters:
- setEnabled(self, enabled: bool)¶
Enable this item. It will be hidden if disabled.
- Parameters:
enabled (bool)
- setPoint(self, point: QgsPointXY)¶
A point that will be highlighted on the map canvas. The point needs to be in map coordinates. The closest point on the grid will be highlighted.
- Parameters:
point (QgsPointXY)
- setPrecision(self, precision: float)¶
The resolution of the grid in map units. If a crs has been specified it will be in CRS units.
- Parameters:
precision (float)
- setRenderContextVariables(self, p: QPainter | None, context: QgsRenderContext) bool ¶
Sets render context parameters
- Parameters:
p – painter for rendering
context – out: configured context
- Returns:
True
in case of success
- updateCanvas(self)¶
schedules map canvas for repaint
- updateMicroFocus(self)¶
- wheelEvent(self, event: QGraphicsSceneWheelEvent | None)¶