QGIS API Documentation  2.12.0-Lyon
qgsmapmouseevent.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsmapmouseevent.h - mouse event in map coordinates and ability to snap
3  ----------------------
4  begin : October 2014
5  copyright : (C) Denis Rouzaud
6  email : [email protected]
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #ifndef QGSMAPMOUSEEVENT_H
17 #define QGSMAPMOUSEEVENT_H
18 
19 #include <QMouseEvent>
20 
21 #include "qgspoint.h"
22 #include "qgspointlocator.h"
23 #include "qgssnappingutils.h"
24 
25 class QgsMapCanvas;
27 
34 class GUI_EXPORT QgsMapMouseEvent : public QMouseEvent
35 {
36  public:
37 
39  {
43  };
44 
51  QgsMapMouseEvent( QgsMapCanvas* mapCanvas, QMouseEvent* event );
52 
63  QgsMapMouseEvent( QgsMapCanvas* mapCanvas, QEvent::Type type, const QPoint &pos, Qt::MouseButton button = Qt::NoButton,
64  Qt::MouseButtons buttons = Qt::NoButton, Qt::KeyboardModifiers modifiers = Qt::NoModifier );
65 
70  QgsPoint snapPoint( SnappingMode snappingMode );
71 
80  QList<QgsPoint> snapSegment( SnappingMode snappingMode, bool* snapped = 0, bool allLayers = false ) const;
81 
88  bool isSnapped() const { return mSnapMatch.isValid(); }
89 
94  inline QgsPoint mapPoint() const { return mMapPoint; }
95 
102  void setMapPoint( const QgsPoint& point );
103 
109  QgsPoint originalMapPoint() const { return mMapPoint; }
110 
116  QPoint pixelPoint() const { return mPixelPoint; }
117 
124  QPoint originalPixelPoint() const { return pos(); }
125 
126  private:
127 
128  QPoint mapToPixelCoordinates( const QgsPoint& point );
129 
130  SnappingMode mSnappingMode;
131 
133  QgsPoint mOriginalMapPoint;
134 
136  QgsPoint mMapPoint;
137 
140  QPoint mPixelPoint;
141 
143  QgsMapCanvas* mMapCanvas;
144 
145  QgsPointLocator::Match mSnapMatch;
146 };
147 
148 #endif // QGSMAPMOUSEEVENT_H
QgsPoint mapPoint() const
mapPoint returns the point in coordinates
QgsPoint originalMapPoint() const
Returns the original, unmodified map point of the mouse cursor.
snap to all rendered layers (tolerance and type from defaultSettings())
A QgsMapMouseEvent is the result of a user interaction with the mouse on a QgsMapCanvas.
The QgsMapToolAdvancedDigitizing class is a QgsMapTool whcih gives event directly in map coordinates ...
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:107
QPoint originalPixelPoint() const
The unsnapped, real mouse cursor position in pixel coordinates.
snap according to the configuration set in the snapping settings
A class to represent a point.
Definition: qgspoint.h:63
typedef MouseButtons
bool isSnapped() const
Returns true if there is a snapped point cached.
const QPoint & pos() const
QPoint pixelPoint() const
The snapped mouse cursor in pixel coordinates.
typedef KeyboardModifiers