QGIS API Documentation 3.99.0-Master (e9821da5c6b)
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
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 void geometryChange( const QRectF &newGeometry, const QRectF &oldGeometry ) override;
206
207 public slots:
208
212 Q_INVOKABLE void zoomFull();
213
218 Q_INVOKABLE void zoomFullInRatio();
219
223 Q_INVOKABLE void clear();
224
225 private slots:
226
227 void generationFinished();
228 void onLayerProfileGenerationPropertyChanged();
229 void onLayerProfileRendererPropertyChanged();
230 void regenerateResultsForLayer();
231 void scheduleDeferredRegeneration();
232 void scheduleDeferredRedraw();
233 void startDeferredRegeneration();
234 void startDeferredRedraw();
235 void refineResults();
236
237 private:
238 void setupLayerConnections( QgsMapLayer *layer, bool isDisconnect );
239
241 QgsProject *mProject = nullptr;
242
244
245 QImage mImage;
246
247 QgsElevationProfilePlotItem *mPlotItem = nullptr;
248 QgsProfilePlotRenderer *mCurrentJob = nullptr;
249
250 QTimer *mDeferredRegenerationTimer = nullptr;
251 bool mDeferredRegenerationScheduled = false;
252 QTimer *mDeferredRedrawTimer = nullptr;
253 bool mDeferredRedrawScheduled = false;
254
255 QgsGeometry mProfileCurve;
256 double mTolerance = 0;
257
258 bool mZoomFullWhenJobFinished = true;
259
260 bool mForceRegenerationAfterCurrentJobCompletes = false;
261
262 static constexpr double MAX_ERROR_PIXELS = 2;
263
264 bool mDirty = false;
265};
266
267#endif // QGSELEVATIONPROFILECANVAS_H
Represents a coordinate reference system (CRS).
QgsRange which stores a range of double values.
Definition qgsrange.h:236
A geometry is the spatial representation of a feature.
Base class for all map layer types.
Definition qgsmaplayer.h:83
Generates and renders elevation profile plots.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition qgsproject.h:113
void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override
QgsGeometry profileCurve() const
Returns the profile curve geometry.
void cancelJobs()
Cancel any rendering job in a blocking way.
void setTolerance(double tolerance)
Sets the profile tolerance (in crs() units).
QgsQuickElevationProfileCanvas(QQuickItem *parent=nullptr)
Constructor for QgsElevationProfileCanvas, with the specified parent widget.
void activeJobCountChanged(int count)
Emitted when the number of active background jobs changes.
void setProfileCurve(QgsGeometry curve)
Sets the profile curve geometry.
void crsChanged()
Emitted when the CRS linked to the profile curve geometry changes.
QgsCoordinateReferenceSystem crs() const
Returns the crs associated with map coordinates.
bool isRendering
The isRendering property is set to true while a rendering job is pending for this elevation profile c...
void setProject(QgsProject *project)
Sets the project associated with the profile.
void profileCurveChanged()
Emitted when the profile curve geometry changes.
Q_INVOKABLE void refresh()
Triggers a complete regeneration of the profile, causing the profile extraction to perform in the bac...
QSGNode * updatePaintNode(QSGNode *oldNode, QQuickItem::UpdatePaintNodeData *) override
void setCrs(const QgsCoordinateReferenceSystem &crs)
Sets the crs associated with the map coordinates.
Q_INVOKABLE void clear()
Clears the current profile.
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.
Q_INVOKABLE void zoomFull()
Zooms to the full extent of the profile.
void isRenderingChanged()
The isRendering property is set to true while a rendering job is pending for this elevation profile c...
Q_INVOKABLE void zoomFullInRatio()
Zooms to the full extent of the profile while maintaining X and Y axes' length ratio.
QList< QgsWeakMapLayerPointer > QgsWeakMapLayerPointerList
A list of weak pointers to QgsMapLayers.