QGIS API Documentation 3.30.0-'s-Hertogenbosch (f186b8efe0)
qgsprofilerenderer.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsprofilerenderer.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#ifndef QGSPROFILERENDERER_H
18#define QGSPROFILERENDERER_H
19
20#include "qgis_core.h"
21#include "qgis_sip.h"
22#include "qgsprofilerequest.h"
24#include "qgsrange.h"
25
26#include <QObject>
27#include <QFutureWatcher>
28
32class QgsFeedback;
36class QgsProfilePoint;
37
58class CORE_EXPORT QgsProfilePlotRenderer : public QObject
59{
60
61 Q_OBJECT
62
63 public:
64
69 QgsProfilePlotRenderer( const QList< QgsAbstractProfileSource * > &sources,
70 const QgsProfileRequest &request );
71
72 ~QgsProfilePlotRenderer() override;
73
77 QStringList sourceIds() const;
78
83 void startGeneration();
84
96 void generateSynchronously();
97
102 void cancelGeneration();
103
109 void cancelGenerationWithoutBlocking();
110
112 void waitForFinished();
113
115 bool isActive() const;
116
122 void setContext( const QgsProfileGenerationContext &context );
123
127 void invalidateAllRefinableSources();
128
134 void replaceSource( QgsAbstractProfileSource *source );
135
145 bool invalidateResults( QgsAbstractProfileSource *source );
146
154 void regenerateInvalidatedResults();
155
159 QgsDoubleRange zRange() const;
160
166 QImage renderToImage( int width, int height, double distanceMin, double distanceMax, double zMin, double zMax, const QString &sourceId = QString() );
167
173 void render( QgsRenderContext &context, double width, double height, double distanceMin, double distanceMax, double zMin, double zMax, const QString &sourceId = QString() );
174
178 QgsProfileSnapResult snapPoint( const QgsProfilePoint &point, const QgsProfileSnapContext &context );
179
183 QVector<QgsProfileIdentifyResults> identify( const QgsProfilePoint &point, const QgsProfileIdentifyContext &context );
184
188 QVector<QgsProfileIdentifyResults> identify( const QgsDoubleRange &distanceRange, const QgsDoubleRange &elevationRange, const QgsProfileIdentifyContext &context );
189
190 signals:
191
194
195 private slots:
196
197 void onGeneratingFinished();
198
199 private:
200
201 struct ProfileJob
202 {
203 QgsAbstractProfileGenerator *generator = nullptr;
205 std::unique_ptr< QgsAbstractProfileResults > results;
206 std::unique_ptr< QgsAbstractProfileResults > invalidatedResults;
207 bool complete = false;
208 QMutex mutex;
209 };
210
211 static void generateProfileStatic( std::unique_ptr< ProfileJob > &job );
212 bool replaceSourceInternal( QgsAbstractProfileSource *source, bool clearPreviousResults );
213
214 std::vector< std::unique_ptr< QgsAbstractProfileGenerator > > mGenerators;
215 QgsProfileRequest mRequest;
217
218 std::vector< std::unique_ptr< ProfileJob > > mJobs;
219
220 QFuture<void> mFuture;
221 QFutureWatcher<void> mFutureWatcher;
222
223 enum { Idle, Generating } mStatus = Idle;
224
225};
226
227#endif // QGSPROFILERENDERER_H
Abstract base class for objects which generate elevation profiles.
Abstract base class for storage of elevation profiles.
Interface for classes which can generate elevation profiles.
QgsRange which stores a range of double values.
Definition: qgsrange.h:203
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition: qgsfeedback.h:45
Encapsulates the context in which an elevation profile is to be generated.
Encapsulates the context of identifying profile results.
Generates and renders elevation profile plots.
void generationFinished()
Emitted when the profile generation is finished (or canceled).
Encapsulates a point on a distance-elevation profile.
Encapsulates properties and constraints relating to fetching elevation profiles from different source...
Encapsulates the context of snapping a profile point.
Encapsulates results of snapping a profile point.
Contains information about the context of a rendering operation.