QGIS API Documentation 3.29.0-Master (ade4f0cf0f)
qgsplotcanvas.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsplotcanvas.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
18#ifndef QGSPLOTCANVAS_H
19#define QGSPLOTCANVAS_H
20
21#include "qgsconfig.h"
22#include "qgis_sip.h"
23#include "qgis_gui.h"
24
25#include <QGraphicsView>
26#include <QPointer>
27
29class QgsPlotTool;
31class QgsPoint;
32class QgsPointXY;
36
37class QMenu;
38
39
40#ifdef SIP_RUN
41% ModuleHeaderCode
42#include "qgsplotcanvas.h"
44% End
45#endif
46
53class GUI_EXPORT QgsPlotCanvas : public QGraphicsView
54{
55
56#ifdef SIP_RUN
58 if ( qobject_cast<QgsElevationProfileCanvas *>( sipCpp ) != nullptr )
59 sipType = sipType_QgsElevationProfileCanvas;
60 else if ( qobject_cast<QgsPlotCanvas *>( sipCpp ) != nullptr )
61 sipType = sipType_QgsPlotCanvas;
62 else
63 sipType = nullptr;
65#endif
66
67 Q_OBJECT
68
69 public:
70
74 QgsPlotCanvas( QWidget *parent SIP_TRANSFERTHIS = nullptr );
75
76 ~QgsPlotCanvas() override;
77
82 virtual void cancelJobs() SIP_SKIP;
83
87 void setTool( QgsPlotTool *tool );
88
97 void unsetTool( QgsPlotTool *tool );
98
102 QgsPlotTool *tool();
103
109 virtual QgsCoordinateReferenceSystem crs() const;
110
116 virtual QgsPoint toMapCoordinates( const QgsPointXY &point ) const;
117
123 virtual QgsPointXY toCanvasCoordinates( const QgsPoint &point ) const;
124
130 virtual void panContentsBy( double dx, double dy );
131
137 virtual void centerPlotOn( double x, double y );
138
144 virtual void scalePlot( double factor );
145
151 virtual void zoomToRect( const QRectF &rect );
152
160 virtual QgsPointXY snapToPlot( QPoint point );
161
162 public slots:
163
167 virtual void refresh();
168
169 signals:
170
174 void toolChanged( QgsPlotTool *newTool );
175
180
185 void contextMenuAboutToShow( QMenu *menu, QgsPlotMouseEvent *event );
186
192
193 protected:
194
195 bool event( QEvent *e ) override;
196 void keyPressEvent( QKeyEvent *e ) override;
197 void keyReleaseEvent( QKeyEvent *e ) override;
198 void mouseDoubleClickEvent( QMouseEvent *e ) override;
199 void mouseMoveEvent( QMouseEvent *e ) override;
200 void mousePressEvent( QMouseEvent *e ) override;
201 void mouseReleaseEvent( QMouseEvent *e ) override;
202 void wheelEvent( QWheelEvent *e ) override;
203 void resizeEvent( QResizeEvent *e ) override;
204 bool viewportEvent( QEvent *event ) override;
205
211 virtual void wheelZoom( QWheelEvent *event );
212
213 private:
214
216 QGraphicsScene *mScene = nullptr;
217
219 QPointer< QgsPlotTool > mTool;
220
221 QgsPlotToolTemporaryKeyPan *mSpacePanTool = nullptr;
222 QgsPlotToolTemporaryMousePan *mMidMouseButtonPanTool = nullptr;
223 QgsPlotToolTemporaryKeyZoom *mSpaceZoomTool = nullptr;
224
225 void showContextMenu( QgsPlotMouseEvent *event );
226
227};
228
229#endif // QGSPLOTCANVAS_H
This class represents a coordinate reference system (CRS).
Plot canvas is a class for displaying interactive 2d charts and plots.
Definition: qgsplotcanvas.h:54
void plotAreaChanged()
Emitted whenever the visible area of the plot is changed.
void toolChanged(QgsPlotTool *newTool)
Emitted when the plot tool is changed.
void contextMenuAboutToShow(QMenu *menu, QgsPlotMouseEvent *event)
Emitted before the canvas context menu will be shown.
void willBeDeleted()
Emitted in the destructor when the canvas is about to be deleted, but is still in a perfectly valid s...
A QgsPlotMouseEvent is the result of a user interaction with the mouse on a QgsPlotCanvas.
Plot tool for temporarily panning a plot while a key is depressed.
Plot tool for temporarily zooming a plot while a key is depressed.
Plot tool for temporarily panning a plot while a mouse button is depressed.
Abstract base class for all interactive plot tools.
Definition: qgsplottool.h:58
A class to represent a 2D point.
Definition: qgspointxy.h:59
Point geometry type, with support for z-dimension and m-values.
Definition: qgspoint.h:49
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition: qgis_sip.h:186
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
#define SIP_SKIP
Definition: qgis_sip.h:126
#define SIP_END
Definition: qgis_sip.h:203
const QgsCoordinateReferenceSystem & crs