QGIS API Documentation 3.41.0-Master (3440c17df1d)
Loading...
Searching...
No Matches
qgsabstractprofilegenerator.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsabstractprofilegenerator.cpp
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 ***************************************************************************/
18#include "qgsprofilesnapping.h"
19
20
22 : mRenderContext( context )
23{
24
25}
26
28{
29 return mWorldTransform;
30}
31
32void QgsProfileRenderContext::setWorldTransform( const QTransform &transform )
33{
34 mWorldTransform = transform;
35}
36
38{
39 return mDistanceRange;
40}
41
43{
44 mDistanceRange = range;
45}
46
48{
49 return mElevationRange;
50}
51
53{
54 mElevationRange = range;
55}
56
57
59
61
62QVector< QgsAbstractProfileResults::Feature > QgsAbstractProfileResults::asFeatures( Qgis::ProfileExportType, QgsFeedback * ) const
63{
64 return {};
65}
66
71
72QVector<QgsProfileIdentifyResults> QgsAbstractProfileResults::identify( const QgsProfilePoint &, const QgsProfileIdentifyContext & )
73{
74 return {};
75}
76
77QVector<QgsProfileIdentifyResults> QgsAbstractProfileResults::identify( const QgsDoubleRange &, const QgsDoubleRange &, const QgsProfileIdentifyContext & )
78{
79 return {};
80}
81
86
87//
88// QgsProfileGenerationContext
89//
90
91#define POINTS_TO_MM 2.83464567
92#define INCH_TO_MM 25.4
93
95{
96 double conversionFactor = 1.0;
97 const double pixelsPerMillimeter = mDpi / 25.4;
98 switch ( unit )
99 {
101 conversionFactor = pixelsPerMillimeter;
102 break;
103
105 conversionFactor = pixelsPerMillimeter / POINTS_TO_MM;
106 break;
107
109 conversionFactor = pixelsPerMillimeter * INCH_TO_MM;
110 break;
111
113 {
114 conversionFactor = 1.0 / mMapUnitsPerDistancePixel;
115 break;
116 }
118 conversionFactor = 1.0;
119 break;
120
124 //not supported
125 conversionFactor = 1.0;
126 break;
127 }
128
129 return size * conversionFactor;
130}
131
133{
134 return qgsDoubleNear( mMaxErrorMapUnits, other.mMaxErrorMapUnits )
135 && qgsDoubleNear( mMapUnitsPerDistancePixel, other.mMapUnitsPerDistancePixel )
136 && qgsDoubleNear( mDpi, other.mDpi )
137 && mDistanceRange == other.mDistanceRange
138 && mElevationRange == other.mElevationRange;
139}
140
142{
143 return !( *this == other );
144}
145
150
151QgsProfileIdentifyResults::QgsProfileIdentifyResults( QgsMapLayer *layer, const QVector<QVariantMap> &results )
152 : mLayer( layer )
153 , mResults( results )
154{
155
156}
QFlags< ProfileGeneratorFlag > ProfileGeneratorFlags
Definition qgis.h:3928
RenderUnit
Rendering size units.
Definition qgis.h:4847
@ Percentage
Percentage of another measurement (e.g., canvas size, feature size)
@ Millimeters
Millimeters.
@ Points
Points (e.g., for font sizes)
@ Unknown
Mixed or unknown units.
@ MapUnits
Map units.
@ MetersInMapUnits
Meters value as Map units.
ProfileExportType
Types of export for elevation profiles.
Definition qgis.h:3937
Abstract base class for objects which generate elevation profiles.
virtual Qgis::ProfileGeneratorFlags flags() const
Returns flags which reflect how the profile generator operates.
virtual ~QgsAbstractProfileGenerator()
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 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 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:231
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition qgsfeedback.h:44
Base class for all map layer types.
Definition qgsmaplayer.h:76
Encapsulates the context in which an elevation profile is to be generated.
bool operator!=(const QgsProfileGenerationContext &other) const
double convertDistanceToPixels(double size, Qgis::RenderUnit unit) const
Converts a distance size from the specified units to pixels.
bool operator==(const QgsProfileGenerationContext &other) const
Encapsulates the context of identifying profile results.
QgsProfileIdentifyResults(QgsMapLayer *layer=nullptr, const QVector< QVariantMap > &results=QVector< QVariantMap >())
Constructor for QgsProfileIdentifyResult, with the associated map layer.
Encapsulates a point on a distance-elevation profile.
void setWorldTransform(const QTransform &transform)
Sets the transform from world coordinates to painter coordinates.
void setDistanceRange(const QgsDoubleRange &range)
Sets the range of distances to include in the render.
const QTransform & worldTransform() const
Returns the transform from world coordinates to painter coordinates.
QgsDoubleRange elevationRange() const
Returns the range of elevations to include in the render.
QgsDoubleRange distanceRange() const
Returns the range of distances to include in the render.
void setElevationRange(const QgsDoubleRange &range)
Sets the range of elevations to include in the render.
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.
Contains information about the context of a rendering operation.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
Definition qgis.h:5958
#define INCH_TO_MM
#define POINTS_TO_MM