22#include <QPainterPath>
48 QVector<QgsGeometry> res;
61 double prevDistance = std::numeric_limits< double >::max();
62 double prevElevation = 0;
68 const double dx = it.key() - prevDistance;
69 const double dy = it.value() - prevElevation;
70 const double snappedZ = ( dy / dx ) * ( point.
distance() - prevDistance ) + prevElevation;
79 prevDistance = it.key();
80 prevElevation = it.value();
88 std::optional< QgsProfileIdentifyResults > result;
90 double prevDistance = std::numeric_limits< double >::max();
91 double prevElevation = 0;
97 const double dx = it.key() - prevDistance;
98 const double dy = it.value() - prevElevation;
99 const double snappedZ = ( dy / dx ) * ( point.
distance() - prevDistance ) + prevElevation;
108 {QStringLiteral(
"distance" ), point.
distance() },
109 {QStringLiteral(
"elevation" ), snappedZ }
115 prevDistance = it.key();
116 prevElevation = it.value();
118 if ( result.has_value() )
119 return {result.value()};
132 painter->setBrush( Qt::NoBrush );
133 painter->setPen( Qt::NoPen );
140 const QRectF visibleRegion( minDistance,
minZ, maxDistance - minDistance,
maxZ -
minZ );
141 QPainterPath clipPath;
142 clipPath.addPolygon( context.
worldTransform().map( visibleRegion ) );
143 painter->setClipPath( clipPath, Qt::ClipOperation::IntersectClip );
155 QPolygonF currentLine;
156 double prevDistance = std::numeric_limits< double >::quiet_NaN();
157 double currentPartStartDistance = 0;
160 if ( std::isnan( prevDistance ) )
162 currentPartStartDistance = pointIt.key();
164 if ( std::isnan( pointIt.value() ) )
166 if ( currentLine.length() > 1 )
175 currentLine.append( context.
worldTransform().map( QPointF( currentPartStartDistance,
minZ ) ) );
176 currentLine.append( currentLine.at( 0 ) );
181 prevDistance = pointIt.key();
186 currentLine.append( context.
worldTransform().map( QPointF( pointIt.key(), pointIt.value() ) ) );
187 prevDistance = pointIt.key();
189 if ( currentLine.length() > 1 )
198 currentLine.append( context.
worldTransform().map( QPointF( currentPartStartDistance,
minZ ) ) );
199 currentLine.append( currentLine.at( 0 ) );
ProfileSurfaceSymbology
Surface symbology type for elevation profile plots.
@ Line
The elevation surface will be rendered using a line symbol.
@ FillBelow
The elevation surface will be rendered using a fill symbol below the surface level.
Abstract base class for objects which generate elevation profiles.
Abstract base class for objects which generate elevation profiles which represent a continuous surfac...
QgsLineSymbol * lineSymbol() const
Returns the line symbol to be used for rendering the results.
std::unique_ptr< QgsLineSymbol > mLineSymbol
Qgis::ProfileSurfaceSymbology symbology() const
Returns the symbology type for rendering the results.
Qgis::ProfileSurfaceSymbology mSymbology
QgsFillSymbol * fillSymbol() const
Returns the fill symbol to be used for rendering the results.
std::unique_ptr< QgsFillSymbol > mFillSymbol
~QgsAbstractProfileSurfaceGenerator() override
std::unique_ptr< QgsFillSymbol > mFillSymbol
QgsPointSequence mRawPoints
QMap< double, double > mDistanceToHeightMap
std::unique_ptr< QgsLineSymbol > mLineSymbol
Qgis::ProfileSurfaceSymbology symbology
QgsPointSequence sampledPoints() const override
Returns a list of sampled points, with their calculated elevation as the point z value.
void renderResults(QgsProfileRenderContext &context) override
Renders the results to the specified context.
void copyPropertiesFromGenerator(const QgsAbstractProfileGenerator *generator) override
Copies properties from specified generator to the results object.
QVector< QgsGeometry > asGeometries() const override
Returns a list of geometries representing the calculated elevation results.
QVector< QgsProfileIdentifyResults > identify(const QgsProfilePoint &point, const QgsProfileIdentifyContext &context) override
Identify results visible at the specified profile point.
QgsProfileSnapResult snapPoint(const QgsProfilePoint &point, const QgsProfileSnapContext &context) override
Snaps a point to the generated elevation profile.
QgsDoubleRange zRange() const override
Returns the range of the retrieved elevation values.
QMap< double, double > distanceToHeightMap() const override
Returns the map of distance (chainage) to height.
~QgsAbstractProfileSurfaceResults() override
QgsRange which stores a range of double values.
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
QgsFillSymbol * clone() const override
Returns a deep copy of this symbol.
A geometry is the spatial representation of a feature.
A line symbol type, for rendering LineString and MultiLineString geometries.
QgsLineSymbol * clone() const override
Returns a deep copy of this symbol.
Point geometry type, with support for z-dimension and m-values.
Encapsulates the context of identifying profile results.
double maximumSurfaceElevationDelta
Maximum allowed snapping delta for the elevation values when identifying a continuous elevation surfa...
Stores identify results generated by a QgsAbstractProfileResults object.
Encapsulates a point on a distance-elevation profile.
double elevation() const SIP_HOLDGIL
Returns the elevation of the point.
double distance() const SIP_HOLDGIL
Returns the distance of the point.
Abstract base class for storage of elevation profiles.
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.
QgsRenderContext & renderContext()
Returns a reference to the component QgsRenderContext.
Encapsulates the context of snapping a profile point.
double maximumSurfaceElevationDelta
Maximum allowed snapping delta for the elevation values when snapping to a continuous elevation surfa...
Encapsulates results of snapping a profile point.
QgsProfilePoint snappedPoint
Snapped point.
T lower() const
Returns the lower bound of the range.
T upper() const
Returns the upper bound of the range.
QPainter * painter()
Returns the destination QPainter for the render operation.
Scoped object for saving and restoring a QPainter object's state.
QVector< QgsPoint > QgsPointSequence