QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
Loading...
Searching...
No Matches
qgsquickelevationprofilecanvas.h
Go to the documentation of this file.
1/***************************************************************************
2 qgselevationprofilecanvas.h
3 ---------------
4 begin : October 2022
5 copyright : (C) 2022 by Mathieu Pellerin
6 email : mathieu at opengis dot ch
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 QGSELEVATIONPROFILECANVAS_H
19#define QGSELEVATIONPROFILECANVAS_H
20
21#include "qgis_quick.h"
23#include "qgsgeometry.h"
24#include "qgsmaplayer.h"
25#include "qgsproject.h"
26
27#include <QQuickItem>
28
30class QgsElevationProfilePlotItem;
31
40class QUICK_EXPORT QgsQuickElevationProfileCanvas : public QQuickItem
41{
42 Q_OBJECT
43
44 Q_PROPERTY( QgsProject *project READ project WRITE setProject NOTIFY projectChanged )
45
46 Q_PROPERTY( QgsCoordinateReferenceSystem crs READ crs WRITE setCrs NOTIFY crsChanged )
47
48 Q_PROPERTY( QgsGeometry profileCurve READ profileCurve WRITE setProfileCurve NOTIFY profileCurveChanged )
49
50 Q_PROPERTY( double tolerance READ tolerance WRITE setTolerance NOTIFY toleranceChanged )
51
58 Q_PROPERTY( bool isRendering READ isRendering NOTIFY isRenderingChanged )
59
60 public:
61
65 explicit QgsQuickElevationProfileCanvas( QQuickItem *parent = nullptr );
67
68 QSGNode *updatePaintNode( QSGNode *oldNode, QQuickItem::UpdatePaintNodeData * ) override;
69
73 void cancelJobs();
74
76 bool isRendering() const;
77
82 Q_INVOKABLE void refresh();
83
87 QgsProject *project() const { return mProject; }
88
95 void setProject( QgsProject *project );
96
100 Q_INVOKABLE void populateLayersFromProject();
101
107 QList<QgsMapLayer *> layers() const;
108
112 QgsCoordinateReferenceSystem crs() const { return mCrs; }
113
119 void setCrs( const QgsCoordinateReferenceSystem &crs );
120
128 void setProfileCurve( QgsGeometry curve );
129
137 QgsGeometry profileCurve() const { return mProfileCurve; };
138
148 void setTolerance( double tolerance );
149
159 double tolerance() const { return mTolerance; }
160
167 void setVisiblePlotRange( double minimumDistance, double maximumDistance, double minimumElevation, double maximumElevation );
168
175 QgsDoubleRange visibleDistanceRange() const;
176
183 QgsDoubleRange visibleElevationRange() const;
184
185 signals:
186
188 void activeJobCountChanged( int count );
189
192
195
198
201
204
205 protected:
206#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
207 void geometryChanged( const QRectF &newGeometry, const QRectF &oldGeometry ) override;
208#else
209 void geometryChange( const QRectF &newGeometry, const QRectF &oldGeometry ) override;
210#endif
211
212 public slots:
213
217 Q_INVOKABLE void zoomFull();
218
223 Q_INVOKABLE void zoomFullInRatio();
224
228 Q_INVOKABLE void clear();
229
230 private slots:
231
232 void generationFinished();
233 void onLayerProfileGenerationPropertyChanged();
234 void onLayerProfileRendererPropertyChanged();
235 void regenerateResultsForLayer();
236 void scheduleDeferredRegeneration();
237 void scheduleDeferredRedraw();
238 void startDeferredRegeneration();
239 void startDeferredRedraw();
240 void refineResults();
241
242 private:
243 void setupLayerConnections( QgsMapLayer *layer, bool isDisconnect );
244
246 QgsProject *mProject = nullptr;
247
249
250 QImage mImage;
251
252 QgsElevationProfilePlotItem *mPlotItem = nullptr;
253 QgsProfilePlotRenderer *mCurrentJob = nullptr;
254
255 QTimer *mDeferredRegenerationTimer = nullptr;
256 bool mDeferredRegenerationScheduled = false;
257 QTimer *mDeferredRedrawTimer = nullptr;
258 bool mDeferredRedrawScheduled = false;
259
260 QgsGeometry mProfileCurve;
261 double mTolerance = 0;
262
263 bool mFirstDrawOccurred = false;
264
265 bool mZoomFullWhenJobFinished = true;
266
267 bool mForceRegenerationAfterCurrentJobCompletes = false;
268
269 static constexpr double MAX_ERROR_PIXELS = 2;
270
271 bool mDirty = false;
272};
273
274#endif // QGSELEVATIONPROFILECANVAS_H
This class represents a coordinate reference system (CRS).
QgsRange which stores a range of double values.
Definition qgsrange.h:203
A geometry is the spatial representation of a feature.
Base class for all map layer types.
Definition qgsmaplayer.h:74
Generates and renders elevation profile plots.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition qgsproject.h:107
This class implements a visual Qt Quick Item that does elevation profile rendering according to the c...
QgsGeometry profileCurve() const
Returns the profile curve geometry.
void activeJobCountChanged(int count)
Emitted when the number of active background jobs changes.
void crsChanged()
Emitted when the CRS linked to the profile curve geometry changes.
QgsCoordinateReferenceSystem crs() const
Returns the crs associated with map coordinates.
void profileCurveChanged()
Emitted when the profile curve geometry changes.
void projectChanged()
Emitted when the associated project changes.
double tolerance() const
Returns the tolerance of the profile (in crs() units).
void toleranceChanged()
Emitted when the tolerance changes.
void isRenderingChanged()
The isRendering property is set to true while a rendering job is pending for this elevation profile c...
QList< QgsWeakMapLayerPointer > QgsWeakMapLayerPointerList
A list of weak pointers to QgsMapLayers.
const QgsCoordinateReferenceSystem & crs