QGIS API Documentation  2.18.3-Las Palmas (77b8c3d)
Public Types | Public Member Functions | List of all members
QgsMapMouseEvent Class Reference

A QgsMapMouseEvent is the result of a user interaction with the mouse on a QgsMapCanvas. More...

#include <qgsmapmouseevent.h>

Inheritance diagram for QgsMapMouseEvent:
Inheritance graph
[legend]

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< QgsPointsnapSegment (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 QPointglobalPos () const
 
int globalX () const
 
int globalY () const
 
const QPointpos () 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
 

Detailed Description

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.

Member Enumeration Documentation

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.

Constructor & Destructor Documentation

QgsMapMouseEvent::QgsMapMouseEvent ( QgsMapCanvas mapCanvas,
QMouseEvent event 
)

Creates a new QgsMapMouseEvent.

Should only be required to be called from the QgsMapCanvas.

Parameters
mapCanvasThe map canvas on which the event occurred
eventThe 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.

Parameters
mapCanvasThe map canvas on which the event occurred
typeThe type of the event
posThe pixel position of the mouse
buttonThe pressed button
buttonsFurther buttons that are pressed
modifiersKeyboard modifiers

Definition at line 39 of file qgsmapmouseevent.cpp.

Member Function Documentation

bool QgsMapMouseEvent::isSnapped ( ) const
inline

Returns true if there is a snapped point cached.

Will only be useful after snapPoint has previously been called.

Returns
True if there is a snapped point cached.

Definition at line 88 of file qgsmapmouseevent.h.

QgsPoint QgsMapMouseEvent::mapPoint ( ) const
inline

mapPoint returns the point in coordinates

Returns
the point in map coordinates, after snapping if requested in the event.

Definition at line 94 of file qgsmapmouseevent.h.

QgsPointLocator::Match QgsMapMouseEvent::mapPointMatch ( ) const
inline

Returns the matching data from the most recently snapped point.

Returns
the snapping data structure
Note
added in 2.14

Definition at line 101 of file qgsmapmouseevent.h.

QgsPoint QgsMapMouseEvent::originalMapPoint ( ) const
inline

Returns the original, unmodified map point of the mouse cursor.

Returns
The cursor position in map coordinates.

Definition at line 116 of file qgsmapmouseevent.h.

QPoint QgsMapMouseEvent::originalPixelPoint ( ) const
inline

The unsnapped, real mouse cursor position in pixel coordinates.

Alias to pos()

Returns
Mouse position in pixel coordinates

Definition at line 131 of file qgsmapmouseevent.h.

QPoint QgsMapMouseEvent::pixelPoint ( ) const
inline

The snapped mouse cursor in pixel coordinates.

Returns
The snapped mouse cursor position 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.

Parameters
pointThe 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

Note
if snapping did not succeeded, the map point will be reset to its original position

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.

Parameters
snappingModeSpecify if the default project settings or all layers should be used for snapping
snappedif given, determines if a segment has been snapped
allLayersif true, override snapping mode

Definition at line 97 of file qgsmapmouseevent.cpp.


The documentation for this class was generated from the following files: