QGIS API Documentation 3.43.0-Master (32433f7016e)
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 "qgslinesymbol.h"
23#include "qgsprofilerequest.h"
25#include "qgsrange.h"
26
27#include <QObject>
28#include <QFutureWatcher>
29
33class QgsFeedback;
37class QgsProfilePoint;
38
59class CORE_EXPORT QgsProfilePlotRenderer : public QObject
60{
61
62 Q_OBJECT
63
64 public:
65
70 QgsProfilePlotRenderer( const QList< QgsAbstractProfileSource * > &sources,
71 const QgsProfileRequest &request );
72
81 QgsProfilePlotRenderer( std::vector<std::unique_ptr<QgsAbstractProfileGenerator> > generators,
82 const QgsProfileRequest &request ) SIP_SKIP;
83
84 ~QgsProfilePlotRenderer() override;
85
89 QStringList sourceIds() const;
90
95 void startGeneration();
96
108 void generateSynchronously();
109
114 void cancelGeneration();
115
121 void cancelGenerationWithoutBlocking();
122
124 void waitForFinished();
125
127 bool isActive() const;
128
134 void setContext( const QgsProfileGenerationContext &context );
135
139 void invalidateAllRefinableSources();
140
146 void replaceSource( QgsAbstractProfileSource *source );
147
157 bool invalidateResults( QgsAbstractProfileSource *source );
158
166 void regenerateInvalidatedResults();
167
171 QgsDoubleRange zRange() const;
172
178 QImage renderToImage( int width, int height, double distanceMin, double distanceMax, double zMin, double zMax, const QString &sourceId = QString(), double devicePixelRatio = 1.0 );
179
185 void render( QgsRenderContext &context, double width, double height, double distanceMin, double distanceMax, double zMin, double zMax, const QString &sourceId = QString() );
186
193 static std::unique_ptr<QgsLineSymbol> defaultSubSectionsSymbol() SIP_FACTORY;
194
201 QgsLineSymbol *subsectionsSymbol();
202
210 void setSubsectionsSymbol( QgsLineSymbol *symbol SIP_TRANSFER );
211
219 void renderSubsectionsIndicator( QgsRenderContext &context, const QRectF &plotArea, double distanceMin, double distanceMax, double zMin, double zMax );
220
224 QgsProfileSnapResult snapPoint( const QgsProfilePoint &point, const QgsProfileSnapContext &context );
225
229 QVector<QgsProfileIdentifyResults> identify( const QgsProfilePoint &point, const QgsProfileIdentifyContext &context );
230
234 QVector<QgsProfileIdentifyResults> identify( const QgsDoubleRange &distanceRange, const QgsDoubleRange &elevationRange, const QgsProfileIdentifyContext &context );
235
241 QVector< QgsAbstractProfileResults::Feature > asFeatures( Qgis::ProfileExportType type, QgsFeedback *feedback = nullptr );
242
243 signals:
244
247
248 private slots:
249
250 void onGeneratingFinished();
251
252 private:
253
254 static QTransform computeRenderTransform( double width, double height, double distanceMin, double distanceMax, double zMin, double zMax );
255
256 struct ProfileJob
257 {
258 QgsAbstractProfileGenerator *generator = nullptr;
260 std::unique_ptr< QgsAbstractProfileResults > results;
261 std::unique_ptr< QgsAbstractProfileResults > invalidatedResults;
262 bool complete = false;
263 QMutex mutex;
264 };
265
266 static void generateProfileStatic( std::unique_ptr< ProfileJob > &job );
267 bool replaceSourceInternal( QgsAbstractProfileSource *source, bool clearPreviousResults );
268
269 std::vector< std::unique_ptr< QgsAbstractProfileGenerator > > mGenerators;
270 QgsProfileRequest mRequest;
272
273 std::vector< std::unique_ptr< ProfileJob > > mJobs;
274
275 QFuture<void> mFuture;
276 QFutureWatcher<void> mFutureWatcher;
277
278 enum { Idle, Generating } mStatus = Idle;
279
280 std::unique_ptr<QgsLineSymbol> mSubsectionsSymbol;
281
282};
283
284#endif // QGSPROFILERENDERER_H
ProfileExportType
Types of export for elevation profiles.
Definition qgis.h:4084
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:233
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition qgsfeedback.h:44
A line symbol type, for rendering LineString and MultiLineString geometries.
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
#define SIP_TRANSFER
Definition qgis_sip.h:36
#define SIP_FACTORY
Definition qgis_sip.h:76