QGIS API Documentation
3.20.0-Odense (decaadbb31)
|
A QgsMapMouseEvent is the result of a user interaction with the mouse on a QgsMapCanvas. More...
#include <qgsmapmouseevent.h>
Public Member Functions | |
QgsMapMouseEvent (QgsMapCanvas *mapCanvas, QEvent::Type type, QPoint pos, Qt::MouseButton button=Qt::NoButton, Qt::MouseButtons buttons=Qt::NoButton, Qt::KeyboardModifiers modifiers=Qt::NoModifier) | |
Creates a new QgsMapMouseEvent. More... | |
QgsMapMouseEvent (QgsMapCanvas *mapCanvas, QMouseEvent *event) | |
Creates a new QgsMapMouseEvent. More... | |
bool | isSnapped () const |
Returns true if there is a snapped point cached. More... | |
QgsPointXY | mapPoint () const |
mapPoint returns the point in coordinates More... | |
QgsPointLocator::Match | mapPointMatch () const |
Returns the matching data from the most recently snapped point. More... | |
QgsPointXY | originalMapPoint () const |
Returns the original, unmodified map point of the mouse cursor. More... | |
QPoint | originalPixelPoint () const |
The unsnapped, real mouse cursor position in pixel coordinates. More... | |
QPoint | pixelPoint () const |
The snapped mouse cursor in pixel coordinates. More... | |
void | setMapPoint (const QgsPointXY &point) |
Set the (snapped) point this event points to in map coordinates. More... | |
QgsPointXY | snapPoint () |
snapPoint will snap the points using the map canvas snapping utils configuration More... | |
void | snapToGrid (double precision, const QgsCoordinateReferenceSystem &crs) |
Snaps the mapPoint to a grid with the given precision. More... | |
A QgsMapMouseEvent is the result of a user interaction with the mouse on a QgsMapCanvas.
It is sent whenever the user moves, clicks, releases or double clicks the mouse. In addition to the coordinates in pixel space it also knows the coordinates in the mapcanvas' CRS as well as it knows the concept of snapping.
Definition at line 35 of file qgsmapmouseevent.h.
QgsMapMouseEvent::QgsMapMouseEvent | ( | QgsMapCanvas * | mapCanvas, |
QMouseEvent * | event | ||
) |
Creates a new QgsMapMouseEvent.
Should only be required to be called from the QgsMapCanvas.
mapCanvas | The map canvas on which the event occurred |
event | The original mouse event |
Definition at line 23 of file qgsmapmouseevent.cpp.
QgsMapMouseEvent::QgsMapMouseEvent | ( | QgsMapCanvas * | mapCanvas, |
QEvent::Type | type, | ||
QPoint | pos, | ||
Qt::MouseButton | button = Qt::NoButton , |
||
Qt::MouseButtons | buttons = Qt::NoButton , |
||
Qt::KeyboardModifiers | modifiers = Qt::NoModifier |
||
) |
Creates a new QgsMapMouseEvent.
Should only be required to be called from the QgsMapCanvas.
mapCanvas | The map canvas on which the event occurred |
type | The type of the event |
pos | The pixel position of the mouse |
button | The pressed button |
buttons | Further buttons that are pressed |
modifiers | Keyboard modifiers |
Definition at line 33 of file qgsmapmouseevent.cpp.
|
inline |
Returns true
if there is a snapped point cached.
Will only be useful after snapPoint has previously been called.
true
if there is a snapped point cached. Definition at line 82 of file qgsmapmouseevent.h.
|
inline |
mapPoint returns the point in coordinates
Definition at line 88 of file qgsmapmouseevent.h.
|
inline |
Returns the matching data from the most recently snapped point.
Definition at line 97 of file qgsmapmouseevent.h.
|
inline |
Returns the original, unmodified map point of the mouse cursor.
Definition at line 112 of file qgsmapmouseevent.h.
|
inline |
The unsnapped, real mouse cursor position in pixel coordinates.
Alias to pos()
Definition at line 127 of file qgsmapmouseevent.h.
|
inline |
The snapped mouse cursor in pixel coordinates.
Definition at line 119 of file qgsmapmouseevent.h.
void QgsMapMouseEvent::setMapPoint | ( | const QgsPointXY & | point | ) |
Set the (snapped) point this event points to in map coordinates.
The point in pixel coordinates will be calculated accordingly.
point | The point in map coordinates |
Definition at line 68 of file qgsmapmouseevent.cpp.
QgsPointXY QgsMapMouseEvent::snapPoint | ( | ) |
snapPoint will snap the points using the map canvas snapping utils configuration
Definition at line 43 of file qgsmapmouseevent.cpp.
void QgsMapMouseEvent::snapToGrid | ( | double | precision, |
const QgsCoordinateReferenceSystem & | crs | ||
) |
Snaps the mapPoint to a grid with the given precision.
The snapping will be done in the specified crs. If this crs is different from the mapCanvas crs, it will be reprojected on the fly.
Definition at line 74 of file qgsmapmouseevent.cpp.