QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
qgsplotmouseevent.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsplotmouseevent.h
3  ---------------
4  begin : March 2022
5  copyright : (C) 2022 by Nyall Dawson
6  email : nyall dot dawson at gmail dot com
7 ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 #ifndef QGSPLOTMOUSEEVENT_H
18 #define QGSPLOTMOUSEEVENT_H
19 
20 #include <QMouseEvent>
21 
22 #include "qgspointxy.h"
23 #include "qgspointlocator.h"
24 #include "qgis_gui.h"
25 
26 class QgsPlotCanvas;
27 
39 class GUI_EXPORT QgsPlotMouseEvent : public QMouseEvent
40 {
41 
42 #ifdef SIP_RUN
44  if ( dynamic_cast<QgsPlotMouseEvent *>( sipCpp ) )
45  sipType = sipType_QgsPlotMouseEvent;
46  else
47  sipType = 0;
48  SIP_END
49 #endif
50 
51  public:
52 
59  QgsPlotMouseEvent( QgsPlotCanvas *canvas, QMouseEvent *event );
60 
71  QgsPlotMouseEvent( QgsPlotCanvas *canvas, QEvent::Type type, QPoint pos, Qt::MouseButton button = Qt::NoButton,
72  Qt::MouseButtons buttons = Qt::NoButton, Qt::KeyboardModifiers modifiers = Qt::NoModifier );
73 
79  QgsPoint mapPoint() const;
80 
86  QgsPointXY snappedPoint();
87 
91  bool isSnapped();
92 
93  private:
94 
96  QgsPlotCanvas *mCanvas = nullptr;
97 
99  QgsPoint mMapPoint;
100 
101  bool mHasCachedSnapResult = false;
102  QgsPointXY mSnappedPoint;
103  bool mIsSnapped = false;
104 
105  void snapPoint();
106 
107 };
108 
109 #endif // QGSPLOTMOUSEEVENT_H
QgsPoint
Point geometry type, with support for z-dimension and m-values.
Definition: qgspoint.h:48
SIP_CONVERT_TO_SUBCLASS_CODE
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition: qgis_sip.h:186
QgsPlotCanvas
Plot canvas is a class for displaying interactive 2d charts and plots.
Definition: qgsplotcanvas.h:53
QgsPointXY
A class to represent a 2D point.
Definition: qgspointxy.h:58
QgsPlotMouseEvent
A QgsPlotMouseEvent is the result of a user interaction with the mouse on a QgsPlotCanvas.
Definition: qgsplotmouseevent.h:39
qgspointlocator.h
SIP_END
#define SIP_END
Definition: qgis_sip.h:203
qgspointxy.h