QGIS API Documentation 3.41.0-Master (25ec5511245)
Loading...
Searching...
No Matches
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 "qgsrendercontext.h"
25
26#include <QTransform>
27
30class QgsProfilePoint;
31class QgsGeometry;
32
39class CORE_EXPORT QgsProfileRenderContext
40{
41 public:
42
47
51 QgsRenderContext &renderContext() { return mRenderContext; }
52
60 const QTransform &worldTransform() const;
61
69 void setWorldTransform( const QTransform &transform );
70
78 QgsDoubleRange distanceRange() const;
79
87 void setDistanceRange( const QgsDoubleRange &range );
88
96 QgsDoubleRange elevationRange() const;
97
105 void setElevationRange( const QgsDoubleRange &range );
106
107 private:
108
109 QgsRenderContext mRenderContext;
110
111 QTransform mWorldTransform;
112
113 QgsDoubleRange mDistanceRange;
114 QgsDoubleRange mElevationRange;
115
116};
117
118
125{
126 public:
127
129 double maximumSurfaceDistanceDelta = 0;
130
132 double maximumSurfaceElevationDelta = 0;
133
135 double maximumPointDistanceDelta = 0;
136
138 double maximumPointElevationDelta = 0;
139
141 double displayRatioElevationVsDistance = 1;
142
144 QgsProject *project = nullptr;
145
146};
147
148
150
158{
159 public:
160
164 QgsProfileIdentifyResults( QgsMapLayer *layer = nullptr, const QVector< QVariantMap> &results = QVector< QVariantMap>() );
165
169 QgsMapLayer *layer() const { return mLayer; }
170
176 QVector<QVariantMap> results() const { return mResults; }
177
178 private:
179
180 QPointer< QgsMapLayer > mLayer = nullptr;
181
182 QVector<QVariantMap> mResults;
183
184};
185
193{
194 public:
195
201 struct Feature
202 {
208 QVariantMap attributes;
209 };
210
212
216 virtual QString type() const = 0;
217
221 virtual QMap< double, double > distanceToHeightMap() const = 0;
222
227 virtual QgsPointSequence sampledPoints() const = 0;
228
232 virtual QVector< QgsGeometry > asGeometries() const = 0;
233
241 virtual QVector< QgsAbstractProfileResults::Feature > asFeatures( Qgis::ProfileExportType type, QgsFeedback *feedback = nullptr ) const;
242
246 virtual void renderResults( QgsProfileRenderContext &context ) = 0;
247
251 virtual QgsDoubleRange zRange() const = 0;
252
256 virtual QgsProfileSnapResult snapPoint( const QgsProfilePoint &point, const QgsProfileSnapContext &context );
257
261 virtual QVector<QgsProfileIdentifyResults> identify( const QgsProfilePoint &point, const QgsProfileIdentifyContext &context );
262
266 virtual QVector<QgsProfileIdentifyResults> identify( const QgsDoubleRange &distanceRange, const QgsDoubleRange &elevationRange, const QgsProfileIdentifyContext &context );
267
276 virtual void copyPropertiesFromGenerator( const QgsAbstractProfileGenerator *generator );
277};
278
286{
287 public:
288
297 double maximumErrorMapUnits() const { return mMaxErrorMapUnits; }
298
307 void setMaximumErrorMapUnits( double error ) { mMaxErrorMapUnits = error; }
308
314 double mapUnitsPerDistancePixel() const { return mMapUnitsPerDistancePixel; }
315
321 void setMapUnitsPerDistancePixel( double units ) { mMapUnitsPerDistancePixel = units; }
322
330 QgsDoubleRange distanceRange() const { return mDistanceRange; }
331
339 void setDistanceRange( const QgsDoubleRange &range ) { mDistanceRange = range; }
340
348 QgsDoubleRange elevationRange() const { return mElevationRange; }
349
357 void setElevationRange( const QgsDoubleRange &range ) { mElevationRange = range; }
358
364 void setDpi( double dpi ) { mDpi = dpi; }
365
371 double dpi() const { return mDpi; }
372
376 double convertDistanceToPixels( double size, Qgis::RenderUnit unit ) const;
377
378 bool operator==( const QgsProfileGenerationContext &other ) const;
379 bool operator!=( const QgsProfileGenerationContext &other ) const;
380
381 private:
382
383 double mMaxErrorMapUnits = std::numeric_limits< double >::quiet_NaN();
384 double mMapUnitsPerDistancePixel = 1;
385 QgsDoubleRange mDistanceRange;
386 QgsDoubleRange mElevationRange;
387 double mDpi = 96;
388};
389
416{
417
418 public:
419
421
428 virtual QString sourceId() const = 0;
429
433 virtual Qgis::ProfileGeneratorFlags flags() const;
434
442
446 virtual QgsFeedback *feedback() const = 0;
447
454
455};
456
457#endif // QGSABSTRACTPROFILEGENERATOR_H
QFlags< ProfileGeneratorFlag > ProfileGeneratorFlags
Definition qgis.h:3920
RenderUnit
Rendering size units.
Definition qgis.h:4839
ProfileExportType
Types of export for elevation profiles.
Definition qgis.h:3929
Abstract base class for objects which generate elevation profiles.
virtual QgsAbstractProfileResults * takeResults()=0
Takes results from the generator.
virtual QgsFeedback * feedback() const =0
Access to feedback object of the generator (may be nullptr)
virtual QString sourceId() const =0
Returns a unique identifier representing the source of the profile.
virtual ~QgsAbstractProfileGenerator()
virtual bool generateProfile(const QgsProfileGenerationContext &context=QgsProfileGenerationContext())=0
Generate the profile (based on data stored in the class).
Abstract base class for storage of elevation profiles.
virtual QgsDoubleRange zRange() const =0
Returns the range of the retrieved elevation values.
virtual void renderResults(QgsProfileRenderContext &context)=0
Renders the results to the specified context.
virtual QMap< double, double > distanceToHeightMap() const =0
Returns the map of distance (chainage) to height.
virtual QString type() const =0
Returns the unique string identifier for the results type.
virtual ~QgsAbstractProfileResults()
virtual QgsPointSequence sampledPoints() const =0
Returns a list of sampled points, with their calculated elevation as the point z value.
virtual QVector< QgsGeometry > asGeometries() const =0
Returns a list of geometries representing the calculated elevation results.
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
A geometry is the spatial representation of a feature.
Base class for all map layer types.
Definition qgsmaplayer.h:76
Encapsulates the context in which an elevation profile is to be generated.
double maximumErrorMapUnits() const
Returns the maximum allowed error in the generated result, in profile curve map units.
double dpi() const
Returns the DPI (dots per inch) for the profie, to be used in size conversions.
double mapUnitsPerDistancePixel() const
Returns the number of map units per pixel in the distance dimension.
void setDpi(double dpi)
Sets the dpi (dots per inch) for the profie, to be used in size conversions.
void setMaximumErrorMapUnits(double error)
Sets the maximum allowed error in the generated result, in profile curve map units.
QgsDoubleRange elevationRange() const
Returns the range of elevations to include in the generation.
void setDistanceRange(const QgsDoubleRange &range)
Sets the range of distances to include in the generation.
QgsDoubleRange distanceRange() const
Returns the range of distances to include in the generation.
void setElevationRange(const QgsDoubleRange &range)
Sets the range of elevations to include in the generation.
void setMapUnitsPerDistancePixel(double units)
Sets the number of map units per pixel in the distance dimension.
Encapsulates the context of identifying profile results.
Stores identify results generated by a QgsAbstractProfileResults object.
QVector< QVariantMap > results() const
Returns a list of custom attributes representing the identify results.
QgsMapLayer * layer() const
Returns the associated map layer.
Encapsulates a point on a distance-elevation profile.
Abstract base class for storage of elevation profiles.
QgsRenderContext & renderContext()
Returns a reference to the component QgsRenderContext.
Encapsulates the context of snapping a profile point.
Encapsulates results of snapping a profile point.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition qgsproject.h:107
Contains information about the context of a rendering operation.
#define SIP_TRANSFERBACK
Definition qgis_sip.h:48
QVector< QgsPoint > QgsPointSequence
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
bool operator!=(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
Encapsulates information about a feature exported from the profile results.
QString layerIdentifier
Identifier for grouping output features.
QVariantMap attributes
Exported attributes.