QGIS API Documentation 3.41.0-Master (cea29feecf2)
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:
64 explicit QgsQuickElevationProfileCanvas( QQuickItem *parent = nullptr );
66
67 QSGNode *updatePaintNode( QSGNode *oldNode, QQuickItem::UpdatePaintNodeData * ) override;
68
72 void cancelJobs();
73
75 bool isRendering() const;
76
81 Q_INVOKABLE void refresh();
82
86 QgsProject *project() const { return mProject; }
87
94 void setProject( QgsProject *project );
95
99 Q_INVOKABLE void populateLayersFromProject();
100
106 QList<QgsMapLayer *> layers() const;
107
111 QgsCoordinateReferenceSystem crs() const { return mCrs; }
112
118 void setCrs( const QgsCoordinateReferenceSystem &crs );
119
127 void setProfileCurve( QgsGeometry curve );
128
136 QgsGeometry profileCurve() const { return mProfileCurve; };
137
147 void setTolerance( double tolerance );
148
158 double tolerance() const { return mTolerance; }
159
166 void setVisiblePlotRange( double minimumDistance, double maximumDistance, double minimumElevation, double maximumElevation );
167
174 QgsDoubleRange visibleDistanceRange() const;
175
182 QgsDoubleRange visibleElevationRange() const;
183
184 signals:
185
187 void activeJobCountChanged( int count );
188
191
194
197
200
203
204 protected:
205#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
206 void geometryChanged( const QRectF &newGeometry, const QRectF &oldGeometry ) override;
207#else
208 void geometryChange( const QRectF &newGeometry, const QRectF &oldGeometry ) override;
209#endif
210
211 public slots:
212
216 Q_INVOKABLE void zoomFull();
217
222 Q_INVOKABLE void zoomFullInRatio();
223
227 Q_INVOKABLE void clear();
228
229 private slots:
230
231 void generationFinished();
232 void onLayerProfileGenerationPropertyChanged();
233 void onLayerProfileRendererPropertyChanged();
234 void regenerateResultsForLayer();
235 void scheduleDeferredRegeneration();
236 void scheduleDeferredRedraw();
237 void startDeferredRegeneration();
238 void startDeferredRedraw();
239 void refineResults();
240
241 private:
242 void setupLayerConnections( QgsMapLayer *layer, bool isDisconnect );
243
245 QgsProject *mProject = nullptr;
246
248
249 QImage mImage;
250
251 QgsElevationProfilePlotItem *mPlotItem = nullptr;
252 QgsProfilePlotRenderer *mCurrentJob = nullptr;
253
254 QTimer *mDeferredRegenerationTimer = nullptr;
255 bool mDeferredRegenerationScheduled = false;
256 QTimer *mDeferredRedrawTimer = nullptr;
257 bool mDeferredRedrawScheduled = false;
258
259 QgsGeometry mProfileCurve;
260 double mTolerance = 0;
261
262 bool mZoomFullWhenJobFinished = true;
263
264 bool mForceRegenerationAfterCurrentJobCompletes = false;
265
266 static constexpr double MAX_ERROR_PIXELS = 2;
267
268 bool mDirty = false;
269};
270
271#endif // QGSELEVATIONPROFILECANVAS_H
This class represents a coordinate reference system (CRS).
QgsRange which stores a range of double values.
Definition qgsrange.h:231
A geometry is the spatial representation of a feature.
Base class for all map layer types.
Definition qgsmaplayer.h:76
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