QGIS API Documentation
2.18.21-Las Palmas (9fba24a)
|
A QgsMapMouseEvent is the result of a user interaction with the mouse on a QgsMapCanvas. More...
#include <qgsmapmouseevent.h>
Public Types | |
enum | SnappingMode { NoSnapping, SnapProjectConfig, SnapAllLayers } |
Public Member Functions | |
QgsMapMouseEvent (QgsMapCanvas *mapCanvas, QMouseEvent *event) | |
Creates a new QgsMapMouseEvent. More... | |
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... | |
bool | isSnapped () const |
Returns true if there is a snapped point cached. More... | |
QgsPoint | mapPoint () const |
mapPoint returns the point in coordinates More... | |
QgsPointLocator::Match | mapPointMatch () const |
Returns the matching data from the most recently snapped point. More... | |
QgsPoint | 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 QgsPoint &point) |
Set the (snapped) point this event points to in map coordinates. More... | |
QgsPoint | snapPoint (SnappingMode snappingMode) |
snapPoint will snap the points using the map canvas snapping utils configuration More... | |
QList< QgsPoint > | snapSegment (SnappingMode snappingMode, bool *snapped=nullptr, bool allLayers=false) const |
Returns the first snapped segment. More... | |
Public Member Functions inherited from QMouseEvent | |
QMouseEvent (Type type, const QPoint &position, Qt::MouseButton button, QFlags< Qt::MouseButton > buttons, QFlags< Qt::KeyboardModifier > modifiers) | |
QMouseEvent (Type type, const QPoint &pos, const QPoint &globalPos, Qt::MouseButton button, QFlags< Qt::MouseButton > buttons, QFlags< Qt::KeyboardModifier > modifiers) | |
QMouseEvent (Type type, const QPoint &pos, Qt::ButtonState button, int state) | |
QMouseEvent (Type type, const QPoint &pos, const QPoint &globalPos, Qt::ButtonState button, int state) | |
Qt::MouseButton | button () const |
Qt::MouseButtons | buttons () const |
const QPoint & | globalPos () const |
int | globalX () const |
int | globalY () const |
const QPoint & | pos () const |
QPointF | posF () const |
Qt::ButtonState | state () const |
Qt::ButtonState | stateAfter () const |
int | x () const |
int | y () const |
Public Member Functions inherited from QInputEvent | |
Qt::KeyboardModifiers | modifiers () const |
Public Member Functions inherited from QEvent | |
QEvent (Type type) | |
virtual | ~QEvent () |
void | accept () |
void | ignore () |
bool | isAccepted () const |
void | setAccepted (bool accepted) |
bool | spontaneous () const |
Type | type () const |
Additional Inherited Members | |
Static Public Member Functions inherited from QEvent | |
int | registerEventType (int hint) |
Properties inherited from QEvent | |
accepted | |
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 coordiantes in pixel space it also knows the coordinates in the mapcanvas' CRS as well as it knows the concept of snapping.
Definition at line 34 of file qgsmapmouseevent.h.
Enumerator | |
---|---|
NoSnapping | |
SnapProjectConfig | snap according to the configuration set in the snapping settings |
SnapAllLayers | snap to all rendered layers (tolerance and type from defaultSettings()) |
Definition at line 38 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 29 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 39 of file qgsmapmouseevent.cpp.
|
inline |
Returns true if there is a snapped point cached.
Will only be useful after snapPoint has previously been called.
Definition at line 88 of file qgsmapmouseevent.h.
|
inline |
mapPoint returns the point in coordinates
Definition at line 94 of file qgsmapmouseevent.h.
|
inline |
Returns the matching data from the most recently snapped point.
Definition at line 101 of file qgsmapmouseevent.h.
|
inline |
Returns the original, unmodified map point of the mouse cursor.
Definition at line 116 of file qgsmapmouseevent.h.
|
inline |
The unsnapped, real mouse cursor position in pixel coordinates.
Alias to pos()
Definition at line 131 of file qgsmapmouseevent.h.
|
inline |
The snapped mouse cursor in pixel coordinates.
Definition at line 123 of file qgsmapmouseevent.h.
void QgsMapMouseEvent::setMapPoint | ( | const QgsPoint & | 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 148 of file qgsmapmouseevent.cpp.
QgsPoint QgsMapMouseEvent::snapPoint | ( | SnappingMode | snappingMode | ) |
snapPoint will snap the points using the map canvas snapping utils configuration
Definition at line 49 of file qgsmapmouseevent.cpp.
QList< QgsPoint > QgsMapMouseEvent::snapSegment | ( | SnappingMode | snappingMode, |
bool * | snapped = nullptr , |
||
bool | allLayers = false |
||
) | const |
Returns the first snapped segment.
If the cached snapped match is a segment, it will simply return it. Otherwise it will try to snap a segment according to the event's snapping mode. In this case the cache will not be overwritten.
snappingMode | Specify if the default project settings or all layers should be used for snapping |
snapped | if given, determines if a segment has been snapped |
allLayers | if true, override snapping mode |
Definition at line 97 of file qgsmapmouseevent.cpp.