QGIS API Documentation 3.41.0-Master (fda2aa46e9a)
Loading...
Searching...
No Matches
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
80 QgsProfilePlotRenderer( std::vector<std::unique_ptr<QgsAbstractProfileGenerator> > generators,
81 const QgsProfileRequest &request ) SIP_SKIP;
82
83 ~QgsProfilePlotRenderer() override;
84
88 QStringList sourceIds() const;
89
94 void startGeneration();
95
107 void generateSynchronously();
108
113 void cancelGeneration();
114
120 void cancelGenerationWithoutBlocking();
121
123 void waitForFinished();
124
126 bool isActive() const;
127
133 void setContext( const QgsProfileGenerationContext &context );
134
138 void invalidateAllRefinableSources();
139
145 void replaceSource( QgsAbstractProfileSource *source );
146
156 bool invalidateResults( QgsAbstractProfileSource *source );
157
165 void regenerateInvalidatedResults();
166
170 QgsDoubleRange zRange() const;
171
177 QImage renderToImage( int width, int height, double distanceMin, double distanceMax, double zMin, double zMax, const QString &sourceId = QString(), double devicePixelRatio = 1.0 );
178
184 void render( QgsRenderContext &context, double width, double height, double distanceMin, double distanceMax, double zMin, double zMax, const QString &sourceId = QString() );
185
189 QgsProfileSnapResult snapPoint( const QgsProfilePoint &point, const QgsProfileSnapContext &context );
190
194 QVector<QgsProfileIdentifyResults> identify( const QgsProfilePoint &point, const QgsProfileIdentifyContext &context );
195
199 QVector<QgsProfileIdentifyResults> identify( const QgsDoubleRange &distanceRange, const QgsDoubleRange &elevationRange, const QgsProfileIdentifyContext &context );
200
206 QVector< QgsAbstractProfileResults::Feature > asFeatures( Qgis::ProfileExportType type, QgsFeedback *feedback = nullptr );
207
208 signals:
209
212
213 private slots:
214
215 void onGeneratingFinished();
216
217 private:
218
219 struct ProfileJob
220 {
221 QgsAbstractProfileGenerator *generator = nullptr;
223 std::unique_ptr< QgsAbstractProfileResults > results;
224 std::unique_ptr< QgsAbstractProfileResults > invalidatedResults;
225 bool complete = false;
226 QMutex mutex;
227 };
228
229 static void generateProfileStatic( std::unique_ptr< ProfileJob > &job );
230 bool replaceSourceInternal( QgsAbstractProfileSource *source, bool clearPreviousResults );
231
232 std::vector< std::unique_ptr< QgsAbstractProfileGenerator > > mGenerators;
233 QgsProfileRequest mRequest;
235
236 std::vector< std::unique_ptr< ProfileJob > > mJobs;
237
238 QFuture<void> mFuture;
239 QFutureWatcher<void> mFutureWatcher;
240
241 enum { Idle, Generating } mStatus = Idle;
242
243};
244
245#endif // QGSPROFILERENDERER_H
ProfileExportType
Types of export for elevation profiles.
Definition qgis.h:3929
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:231
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition qgsfeedback.h:44
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.
#define SIP_SKIP
Definition qgis_sip.h:126