QGIS API Documentation 4.1.0-Master (60fea48833c)
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 "qgsrendercontext.h"
23
24#include <QList>
25#include <QTransform>
26
29class QgsProfilePoint;
30class QgsGeometry;
31
38class CORE_EXPORT QgsProfileRenderContext
39{
40 public:
45
49 QgsRenderContext &renderContext() { return mRenderContext; }
50
58 const QTransform &worldTransform() const;
59
67 void setWorldTransform( const QTransform &transform );
68
76 QgsDoubleRange distanceRange() const;
77
85 void setDistanceRange( const QgsDoubleRange &range );
86
94 QgsDoubleRange elevationRange() const;
95
103 void setElevationRange( const QgsDoubleRange &range );
104
105 private:
106 QgsRenderContext mRenderContext;
107
108 QTransform mWorldTransform;
109
110 QgsDoubleRange mDistanceRange;
111 QgsDoubleRange mElevationRange;
112};
113
114
121{
122 public:
125
128
131
134
137
139 QgsProject *project = nullptr;
140};
141
142
144
152{
153 public:
157 QgsProfileIdentifyResults( QgsMapLayer *layer = nullptr, const QVector< QVariantMap> &results = QVector< QVariantMap>() );
158
162 QgsMapLayer *layer() const { return mLayer; }
163
169 QVector<QVariantMap> results() const { return mResults; }
170
171 private:
172 QPointer< QgsMapLayer > mLayer = nullptr;
173
174 QVector<QVariantMap> mResults;
175};
176
184{
185 public:
191 struct Feature
192 {
198 QVariantMap attributes;
199 };
200
202
206 virtual QString type() const = 0;
207
211 virtual QMap< double, double > distanceToHeightMap() const = 0;
212
217 virtual QgsPointSequence sampledPoints() const = 0;
218
222 virtual QVector< QgsGeometry > asGeometries() const = 0;
223
231 virtual QVector< QgsAbstractProfileResults::Feature > asFeatures( Qgis::ProfileExportType type, QgsFeedback *feedback = nullptr ) const;
232
236 virtual void renderResults( QgsProfileRenderContext &context ) = 0;
237
241 virtual QgsDoubleRange zRange() const = 0;
242
246 virtual QgsProfileSnapResult snapPoint( const QgsProfilePoint &point, const QgsProfileSnapContext &context );
247
251 virtual QVector<QgsProfileIdentifyResults> identify( const QgsProfilePoint &point, const QgsProfileIdentifyContext &context );
252
256 virtual QVector<QgsProfileIdentifyResults> identify( const QgsDoubleRange &distanceRange, const QgsDoubleRange &elevationRange, const QgsProfileIdentifyContext &context );
257
266 virtual void copyPropertiesFromGenerator( const QgsAbstractProfileGenerator *generator );
267};
268
276{
277 public:
286 double maximumErrorMapUnits() const { return mMaxErrorMapUnits; }
287
296 void setMaximumErrorMapUnits( double error ) { mMaxErrorMapUnits = error; }
297
303 double mapUnitsPerDistancePixel() const { return mMapUnitsPerDistancePixel; }
304
310 void setMapUnitsPerDistancePixel( double units ) { mMapUnitsPerDistancePixel = units; }
311
319 QgsDoubleRange distanceRange() const { return mDistanceRange; }
320
328 void setDistanceRange( const QgsDoubleRange &range ) { mDistanceRange = range; }
329
337 QgsDoubleRange elevationRange() const { return mElevationRange; }
338
346 void setElevationRange( const QgsDoubleRange &range ) { mElevationRange = range; }
347
353 void setDpi( double dpi ) { mDpi = dpi; }
354
360 double dpi() const { return mDpi; }
361
365 double convertDistanceToPixels( double size, Qgis::RenderUnit unit ) const;
366
367 bool operator==( const QgsProfileGenerationContext &other ) const;
368 bool operator!=( const QgsProfileGenerationContext &other ) const;
369
370 private:
371 double mMaxErrorMapUnits = std::numeric_limits< double >::quiet_NaN();
372 double mMapUnitsPerDistancePixel = 1;
373 QgsDoubleRange mDistanceRange;
374 QgsDoubleRange mElevationRange;
375 double mDpi = 96;
376};
377
404{
405 public:
407
414 virtual QString sourceId() const = 0;
415
419 virtual Qgis::ProfileGeneratorFlags flags() const;
420
428
432 virtual QgsFeedback *feedback() const = 0;
433
440
444 virtual QString type() const = 0;
445};
446
447#endif // QGSABSTRACTPROFILEGENERATOR_H
QFlags< ProfileGeneratorFlag > ProfileGeneratorFlags
Definition qgis.h:4365
RenderUnit
Rendering size units.
Definition qgis.h:5340
ProfileExportType
Types of export for elevation profiles.
Definition qgis.h:4374
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 QString type() const =0
Returns the unique string identifier for the results type.
virtual Qgis::ProfileGeneratorFlags flags() const
Returns flags which reflect how the profile generator operates.
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 QVector< QgsAbstractProfileResults::Feature > asFeatures(Qgis::ProfileExportType type, QgsFeedback *feedback=nullptr) const
Returns a list of features representing the calculated elevation results.
virtual QgsPointSequence sampledPoints() const =0
Returns a list of sampled points, with their calculated elevation as the point z value.
virtual QgsProfileSnapResult snapPoint(const QgsProfilePoint &point, const QgsProfileSnapContext &context)
Snaps a point to the generated elevation profile.
virtual QVector< QgsProfileIdentifyResults > identify(const QgsProfilePoint &point, const QgsProfileIdentifyContext &context)
Identify results visible at the specified profile point.
virtual QVector< QgsGeometry > asGeometries() const =0
Returns a list of geometries representing the calculated elevation results.
virtual void copyPropertiesFromGenerator(const QgsAbstractProfileGenerator *generator)
Copies properties from specified generator to the results object.
QgsRange which stores a range of double values.
Definition qgsrange.h:217
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:83
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.
double maximumPointElevationDelta
Maximum allowed snapping delta for the elevation values when identifying a point.
double maximumPointDistanceDelta
Maximum allowed snapping delta for the distance values when identifying a point.
QgsProject * project
Associated project.
double displayRatioElevationVsDistance
Display ratio of elevation vs distance units.
double maximumSurfaceDistanceDelta
Maximum allowed snapping delta for the distance values when identifying a continuous elevation surfac...
double maximumSurfaceElevationDelta
Maximum allowed snapping delta for the elevation values when identifying a continuous elevation surfa...
QgsProfileIdentifyResults(QgsMapLayer *layer=nullptr, const QVector< QVariantMap > &results=QVector< QVariantMap >())
Constructor for QgsProfileIdentifyResult, with the associated map layer.
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.
QgsProfileRenderContext(QgsRenderContext &context)
Constructor for QgsProfileRenderContext, with the specified embedded render context.
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:113
Contains information about the context of a rendering operation.
#define SIP_TRANSFERBACK
Definition qgis_sip.h:47
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.