QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
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
89 void cancelGeneration();
90
96 void cancelGenerationWithoutBlocking();
97
99 void waitForFinished();
100
102 bool isActive() const;
103
109 void setContext( const QgsProfileGenerationContext &context );
110
114 void invalidateAllRefinableSources();
115
121 void replaceSource( QgsAbstractProfileSource *source );
122
132 bool invalidateResults( QgsAbstractProfileSource *source );
133
141 void regenerateInvalidatedResults();
142
146 QgsDoubleRange zRange() const;
147
153 QImage renderToImage( int width, int height, double distanceMin, double distanceMax, double zMin, double zMax, const QString &sourceId = QString() );
154
160 void render( QgsRenderContext &context, double width, double height, double distanceMin, double distanceMax, double zMin, double zMax, const QString &sourceId = QString() );
161
165 QgsProfileSnapResult snapPoint( const QgsProfilePoint &point, const QgsProfileSnapContext &context );
166
170 QVector<QgsProfileIdentifyResults> identify( const QgsProfilePoint &point, const QgsProfileIdentifyContext &context );
171
175 QVector<QgsProfileIdentifyResults> identify( const QgsDoubleRange &distanceRange, const QgsDoubleRange &elevationRange, const QgsProfileIdentifyContext &context );
176
177 signals:
178
181
182 private slots:
183
184 void onGeneratingFinished();
185
186 private:
187
188 struct ProfileJob
189 {
190 QgsAbstractProfileGenerator *generator = nullptr;
192 std::unique_ptr< QgsAbstractProfileResults > results;
193 std::unique_ptr< QgsAbstractProfileResults > invalidatedResults;
194 bool complete = false;
195 QMutex mutex;
196 };
197
198 static void generateProfileStatic( std::unique_ptr< ProfileJob > &job );
199 bool replaceSourceInternal( QgsAbstractProfileSource *source, bool clearPreviousResults );
200
201 std::vector< std::unique_ptr< QgsAbstractProfileGenerator > > mGenerators;
202 QgsProfileRequest mRequest;
204
205 std::vector< std::unique_ptr< ProfileJob > > mJobs;
206
207 QFuture<void> mFuture;
208 QFutureWatcher<void> mFutureWatcher;
209
210 enum { Idle, Generating } mStatus = Idle;
211
212};
213
214#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.