QGIS API Documentation 3.41.0-Master (cea29feecf2)
Loading...
Searching...
No Matches
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#ifdef SIP_RUN
57 if ( qobject_cast<QgsElevationProfileCanvas *>( sipCpp ) != nullptr )
58 sipType = sipType_QgsElevationProfileCanvas;
59 else if ( qobject_cast<QgsPlotCanvas *>( sipCpp ) != nullptr )
60 sipType = sipType_QgsPlotCanvas;
61 else
62 sipType = nullptr;
64#endif
65
66 Q_OBJECT
67
68 public:
72 QgsPlotCanvas( QWidget *parent SIP_TRANSFERTHIS = nullptr );
73
74 ~QgsPlotCanvas() override;
75
80 virtual void cancelJobs() SIP_SKIP;
81
85 void setTool( QgsPlotTool *tool );
86
95 void unsetTool( QgsPlotTool *tool );
96
100 QgsPlotTool *tool();
101
107 virtual QgsCoordinateReferenceSystem crs() const;
108
114 virtual QgsPoint toMapCoordinates( const QgsPointXY &point ) const;
115
121 virtual QgsPointXY toCanvasCoordinates( const QgsPoint &point ) const;
122
128 virtual void panContentsBy( double dx, double dy );
129
135 virtual void centerPlotOn( double x, double y );
136
142 virtual void scalePlot( double factor );
143
149 virtual void zoomToRect( const QRectF &rect );
150
158 virtual QgsPointXY snapToPlot( QPoint point );
159
160 public slots:
161
165 virtual void refresh();
166
167 signals:
168
172 void toolChanged( QgsPlotTool *newTool );
173
178
183 void contextMenuAboutToShow( QMenu *menu, QgsPlotMouseEvent *event );
184
190
191 protected:
192 bool event( QEvent *e ) override;
193 void keyPressEvent( QKeyEvent *e ) override;
194 void keyReleaseEvent( QKeyEvent *e ) override;
195 void mouseDoubleClickEvent( QMouseEvent *e ) override;
196 void mouseMoveEvent( QMouseEvent *e ) override;
197 void mousePressEvent( QMouseEvent *e ) override;
198 void mouseReleaseEvent( QMouseEvent *e ) override;
199 void wheelEvent( QWheelEvent *e ) override;
200 void resizeEvent( QResizeEvent *e ) override;
201 bool viewportEvent( QEvent *event ) override;
202
208 virtual void wheelZoom( QWheelEvent *event );
209
210 private:
212 QGraphicsScene *mScene = nullptr;
213
215 QPointer<QgsPlotTool> mTool;
216
217 QgsPlotToolTemporaryKeyPan *mSpacePanTool = nullptr;
218 QgsPlotToolTemporaryMousePan *mMidMouseButtonPanTool = nullptr;
219 QgsPlotToolTemporaryKeyZoom *mSpaceZoomTool = nullptr;
220
221 void showContextMenu( QgsPlotMouseEvent *event );
222};
223
224#endif // QGSPLOTCANVAS_H
This class represents a coordinate reference system (CRS).
Plot canvas is a class for displaying interactive 2d charts and plots.
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:60
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:191
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53
#define SIP_SKIP
Definition qgis_sip.h:126
#define SIP_END
Definition qgis_sip.h:208
const QgsCoordinateReferenceSystem & crs