QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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 
32 class QgsFeedback;
33 class QgsRenderContext;
36 class QgsProfilePoint;
37 
58 class 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 
180  void generationFinished();
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
QgsProfileIdentifyContext
Encapsulates the context of identifying profile results.
Definition: qgsabstractprofilegenerator.h:125
QgsProfileSnapResult
Encapsulates results of snapping a profile point.
Definition: qgsprofilesnapping.h:56
QgsAbstractProfileGenerator
Abstract base class for objects which generate elevation profiles.
Definition: qgsabstractprofilegenerator.h:392
QgsRenderContext
Contains information about the context of a rendering operation.
Definition: qgsrendercontext.h:59
qgsrange.h
QgsProfileSnapContext
Encapsulates the context of snapping a profile point.
Definition: qgsprofilesnapping.h:30
QgsProfilePoint
Encapsulates a point on a distance-elevation profile.
Definition: qgsprofilepoint.h:30
QgsProfileGenerationContext
Encapsulates the context in which an elevation profile is to be generated.
Definition: qgsabstractprofilegenerator.h:262
QgsFeedback
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition: qgsfeedback.h:44
qgsprofilerequest.h
qgis_sip.h
QgsProfileRequest
Encapsulates properties and constraints relating to fetching elevation profiles from different source...
Definition: qgsprofilerequest.h:37
QgsDoubleRange
QgsRange which stores a range of double values.
Definition: qgsrange.h:202
QgsAbstractProfileResults
Abstract base class for storage of elevation profiles.
Definition: qgsabstractprofilegenerator.h:193
QgsAbstractProfileSource
Interface for classes which can generate elevation profiles.
Definition: qgsabstractprofilesource.h:33
qgsabstractprofilegenerator.h
QgsProfilePlotRenderer
Generates and renders elevation profile plots.
Definition: qgsprofilerenderer.h:58