QGIS API Documentation 3.29.0-Master (8c80f25a4f)
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
63{
64 return QgsProfileSnapResult();
65}
66
67QVector<QgsProfileIdentifyResults> QgsAbstractProfileResults::identify( const QgsProfilePoint &, const QgsProfileIdentifyContext & )
68{
69 return {};
70}
71
72QVector<QgsProfileIdentifyResults> QgsAbstractProfileResults::identify( const QgsDoubleRange &, const QgsDoubleRange &, const QgsProfileIdentifyContext & )
73{
74 return {};
75}
76
78{
79
80}
81
82//
83// QgsProfileGenerationContext
84//
85
86#define POINTS_TO_MM 2.83464567
87#define INCH_TO_MM 25.4
88
90{
91 double conversionFactor = 1.0;
92 const double pixelsPerMillimeter = mDpi / 25.4;
93 switch ( unit )
94 {
96 conversionFactor = pixelsPerMillimeter;
97 break;
98
100 conversionFactor = pixelsPerMillimeter / POINTS_TO_MM;
101 break;
102
104 conversionFactor = pixelsPerMillimeter * INCH_TO_MM;
105 break;
106
108 {
109 conversionFactor = 1.0 / mMapUnitsPerDistancePixel;
110 break;
111 }
113 conversionFactor = 1.0;
114 break;
115
119 //not supported
120 conversionFactor = 1.0;
121 break;
122 }
123
124 return size * conversionFactor;
125}
126
128{
129 return qgsDoubleNear( mMaxErrorMapUnits, other.mMaxErrorMapUnits )
130 && qgsDoubleNear( mMapUnitsPerDistancePixel, other.mMapUnitsPerDistancePixel )
131 && qgsDoubleNear( mDpi, other.mDpi )
132 && mDistanceRange == other.mDistanceRange
133 && mElevationRange == other.mElevationRange;
134}
135
137{
138 return !( *this == other );
139}
140
141Qgis::ProfileGeneratorFlags QgsAbstractProfileGenerator::flags() const
142{
143 return Qgis::ProfileGeneratorFlags();
144}
145
146QgsProfileIdentifyResults::QgsProfileIdentifyResults( QgsMapLayer *layer, const QVector<QVariantMap> &results )
147 : mLayer( layer )
148 , mResults( results )
149{
150
151}
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 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:203
Base class for all map layer types.
Definition: qgsmaplayer.h:73
Encapsulates the context in which an elevation profile is to be generated.
bool operator!=(const QgsProfileGenerationContext &other) const
bool operator==(const QgsProfileGenerationContext &other) const
double convertDistanceToPixels(double size, QgsUnitTypes::RenderUnit unit) const
Converts a distance size from the specified units to pixels.
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.
RenderUnit
Rendering size units.
Definition: qgsunittypes.h:168
@ RenderUnknownUnit
Mixed or unknown units.
Definition: qgsunittypes.h:175
@ RenderMetersInMapUnits
Meters value as Map units.
Definition: qgsunittypes.h:176
@ RenderPercentage
Percentage of another measurement (e.g., canvas size, feature size)
Definition: qgsunittypes.h:172
@ RenderPoints
Points (e.g., for font sizes)
Definition: qgsunittypes.h:173
@ RenderPixels
Pixels.
Definition: qgsunittypes.h:171
@ RenderInches
Inches.
Definition: qgsunittypes.h:174
@ RenderMillimeters
Millimeters.
Definition: qgsunittypes.h:169
@ RenderMapUnits
Map units.
Definition: qgsunittypes.h:170
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
Definition: qgis.h:2915
#define INCH_TO_MM
#define POINTS_TO_MM