QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
qgsabstractprofilegenerator.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsabstractprofilegenerator.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 QGSABSTRACTPROFILEGENERATOR_H
18 #define QGSABSTRACTPROFILEGENERATOR_H
19 
20 #include "qgis_core.h"
21 #include "qgis_sip.h"
22 #include <QList>
23 
24 #include "qgspoint.h"
25 #include "qgsrendercontext.h"
26 
27 #include <QTransform>
28 
31 class QgsProfilePoint;
32 class QgsGeometry;
33 
40 class CORE_EXPORT QgsProfileRenderContext
41 {
42  public:
43 
48 
52  QgsRenderContext &renderContext() { return mRenderContext; }
53 
61  const QTransform &worldTransform() const;
62 
70  void setWorldTransform( const QTransform &transform );
71 
79  QgsDoubleRange distanceRange() const;
80 
88  void setDistanceRange( const QgsDoubleRange &range );
89 
97  QgsDoubleRange elevationRange() const;
98 
106  void setElevationRange( const QgsDoubleRange &range );
107 
108  private:
109 
110  QgsRenderContext mRenderContext;
111 
112  QTransform mWorldTransform;
113 
114  QgsDoubleRange mDistanceRange;
115  QgsDoubleRange mElevationRange;
116 
117 };
118 
119 
125 class CORE_EXPORT QgsProfileIdentifyContext
126 {
127  public:
128 
130  double maximumSurfaceDistanceDelta = 0;
131 
133  double maximumSurfaceElevationDelta = 0;
134 
136  double maximumPointDistanceDelta = 0;
137 
139  double maximumPointElevationDelta = 0;
140 
142  double displayRatioElevationVsDistance = 1;
143 
145  QgsProject *project = nullptr;
146 
147 };
148 
149 
151 
158 class CORE_EXPORT QgsProfileIdentifyResults
159 {
160  public:
161 
165  QgsProfileIdentifyResults( QgsMapLayer *layer = nullptr, const QVector< QVariantMap> &results = QVector< QVariantMap>() );
166 
170  QgsMapLayer *layer() const { return mLayer; }
171 
177  QVector<QVariantMap> results() const { return mResults; }
178 
179  private:
180 
181  QPointer< QgsMapLayer > mLayer = nullptr;
182 
183  QVector<QVariantMap> mResults;
184 
185 };
186 
193 class CORE_EXPORT QgsAbstractProfileResults
194 {
195  public:
196 
197  virtual ~QgsAbstractProfileResults();
198 
202  virtual QString type() const = 0;
203 
207  virtual QMap< double, double > distanceToHeightMap() const = 0;
208 
213  virtual QgsPointSequence sampledPoints() const = 0;
214 
218  virtual QVector< QgsGeometry > asGeometries() const = 0;
219 
223  virtual void renderResults( QgsProfileRenderContext &context ) = 0;
224 
228  virtual QgsDoubleRange zRange() const = 0;
229 
233  virtual QgsProfileSnapResult snapPoint( const QgsProfilePoint &point, const QgsProfileSnapContext &context );
234 
238  virtual QVector<QgsProfileIdentifyResults> identify( const QgsProfilePoint &point, const QgsProfileIdentifyContext &context );
239 
243  virtual QVector<QgsProfileIdentifyResults> identify( const QgsDoubleRange &distanceRange, const QgsDoubleRange &elevationRange, const QgsProfileIdentifyContext &context );
244 
253  virtual void copyPropertiesFromGenerator( const QgsAbstractProfileGenerator *generator );
254 };
255 
263 {
264  public:
265 
274  double maximumErrorMapUnits() const { return mMaxErrorMapUnits; }
275 
284  void setMaximumErrorMapUnits( double error ) { mMaxErrorMapUnits = error; }
285 
291  double mapUnitsPerDistancePixel() const { return mMapUnitsPerDistancePixel; }
292 
298  void setMapUnitsPerDistancePixel( double units ) { mMapUnitsPerDistancePixel = units; }
299 
307  QgsDoubleRange distanceRange() const { return mDistanceRange; }
308 
316  void setDistanceRange( const QgsDoubleRange &range ) { mDistanceRange = range; }
317 
325  QgsDoubleRange elevationRange() const { return mElevationRange; }
326 
334  void setElevationRange( const QgsDoubleRange &range ) { mElevationRange = range; }
335 
341  void setDpi( double dpi ) { mDpi = dpi; }
342 
348  double dpi() const { return mDpi; }
349 
353  double convertDistanceToPixels( double size, QgsUnitTypes::RenderUnit unit ) const;
354 
355  bool operator==( const QgsProfileGenerationContext &other ) const;
356  bool operator!=( const QgsProfileGenerationContext &other ) const;
357 
358  private:
359 
360  double mMaxErrorMapUnits = std::numeric_limits< double >::quiet_NaN();
361  double mMapUnitsPerDistancePixel = 1;
362  QgsDoubleRange mDistanceRange;
363  QgsDoubleRange mElevationRange;
364  double mDpi = 96;
365 };
366 
393 {
394 
395  public:
396 
397  virtual ~QgsAbstractProfileGenerator();
398 
405  virtual QString sourceId() const = 0;
406 
410  virtual Qgis::ProfileGeneratorFlags flags() const;
411 
418  virtual bool generateProfile( const QgsProfileGenerationContext &context = QgsProfileGenerationContext() ) = 0;
419 
423  virtual QgsFeedback *feedback() const = 0;
424 
430  virtual QgsAbstractProfileResults *takeResults() = 0 SIP_TRANSFERBACK;
431 
432 };
433 
434 #endif // QGSABSTRACTPROFILEGENERATOR_H
QgsProfileIdentifyContext
Encapsulates the context of identifying profile results.
Definition: qgsabstractprofilegenerator.h:125
QgsUnitTypes::RenderUnit
RenderUnit
Rendering size units.
Definition: qgsunittypes.h:167
operator==
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
Definition: qgsfeatureiterator.h:425
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
QgsProfileRenderContext
Abstract base class for storage of elevation profiles.
Definition: qgsabstractprofilegenerator.h:40
QgsProfileGenerationContext::setMaximumErrorMapUnits
void setMaximumErrorMapUnits(double error)
Sets the maximum allowed error in the generated result, in profile curve map units.
Definition: qgsabstractprofilegenerator.h:284
QgsProfileGenerationContext::setDpi
void setDpi(double dpi)
Sets the dpi (dots per inch) for the profie, to be used in size conversions.
Definition: qgsabstractprofilegenerator.h:341
qgspoint.h
QgsProfileSnapContext
Encapsulates the context of snapping a profile point.
Definition: qgsprofilesnapping.h:30
QgsProfileGenerationContext::elevationRange
QgsDoubleRange elevationRange() const
Returns the range of elevations to include in the generation.
Definition: qgsabstractprofilegenerator.h:325
operator!=
bool operator!=(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
Definition: qgsfeatureiterator.h:430
QgsProfileGenerationContext::setMapUnitsPerDistancePixel
void setMapUnitsPerDistancePixel(double units)
Sets the number of map units per pixel in the distance dimension.
Definition: qgsabstractprofilegenerator.h:298
QgsProject
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition: qgsproject.h:103
SIP_TRANSFERBACK
#define SIP_TRANSFERBACK
Definition: qgis_sip.h:48
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
QgsProfileIdentifyResults
Stores identify results generated by a QgsAbstractProfileResults object.
Definition: qgsabstractprofilegenerator.h:158
QgsProfileRenderContext::renderContext
QgsRenderContext & renderContext()
Returns a reference to the component QgsRenderContext.
Definition: qgsabstractprofilegenerator.h:52
QgsProfileGenerationContext::setDistanceRange
void setDistanceRange(const QgsDoubleRange &range)
Sets the range of distances to include in the generation.
Definition: qgsabstractprofilegenerator.h:316
QgsFeedback
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition: qgsfeedback.h:44
QgsProfileGenerationContext::distanceRange
QgsDoubleRange distanceRange() const
Returns the range of distances to include in the generation.
Definition: qgsabstractprofilegenerator.h:307
qgis_sip.h
qgsrendercontext.h
QgsProfileGenerationContext::mapUnitsPerDistancePixel
double mapUnitsPerDistancePixel() const
Returns the number of map units per pixel in the distance dimension.
Definition: qgsabstractprofilegenerator.h:291
QgsProfileIdentifyResults::layer
QgsMapLayer * layer() const
Returns the associated map layer.
Definition: qgsabstractprofilegenerator.h:170
QgsDoubleRange
QgsRange which stores a range of double values.
Definition: qgsrange.h:202
QgsPointSequence
QVector< QgsPoint > QgsPointSequence
Definition: qgsabstractgeometry.h:52
QgsGeometry
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:124
QgsProfileIdentifyResults::results
QVector< QVariantMap > results() const
Returns a list of custom attributes representing the identify results.
Definition: qgsabstractprofilegenerator.h:177
QgsMapLayer
Base class for all map layer types. This is the base class for all map layer types (vector,...
Definition: qgsmaplayer.h:72
QgsProfileGenerationContext::maximumErrorMapUnits
double maximumErrorMapUnits() const
Returns the maximum allowed error in the generated result, in profile curve map units.
Definition: qgsabstractprofilegenerator.h:274
QgsProfileGenerationContext::setElevationRange
void setElevationRange(const QgsDoubleRange &range)
Sets the range of elevations to include in the generation.
Definition: qgsabstractprofilegenerator.h:334
QgsAbstractProfileResults
Abstract base class for storage of elevation profiles.
Definition: qgsabstractprofilegenerator.h:193
QgsProfileGenerationContext::dpi
double dpi() const
Returns the DPI (dots per inch) for the profie, to be used in size conversions.
Definition: qgsabstractprofilegenerator.h:348