QGIS API Documentation
3.26.3-Buenos Aires (65e4edfdad)
|
Go to the documentation of this file.
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 ) );
Encapsulates the context of identifying profile results.
void copyPropertiesFromGenerator(const QgsAbstractProfileGenerator *generator) override
Copies properties from specified generator to the results object.
QgsDoubleRange distanceRange() const
Returns the range of distances to include in the render.
Point geometry type, with support for z-dimension and m-values.
void renderResults(QgsProfileRenderContext &context) override
Renders the results to the specified context.
Encapsulates results of snapping a profile point.
QMap< double, double > distanceToHeightMap() const override
Returns the map of distance (chainage) to height.
std::unique_ptr< QgsFillSymbol > mFillSymbol
Qgis::ProfileSurfaceSymbology symbology
ProfileSurfaceSymbology
Surface symbology type for elevation profile plots.
QgsLineSymbol * clone() const override
Returns a deep copy of this 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 storage of elevation profiles.
std::unique_ptr< QgsLineSymbol > mLineSymbol
QgsFillSymbol * fillSymbol() const
Returns the fill symbol to be used for rendering the results.
Encapsulates the context of snapping a profile point.
double maximumSurfaceElevationDelta
Maximum allowed snapping delta for the elevation values when identifying a continuous elevation surfa...
Encapsulates a point on a distance-elevation profile.
@ Line
The elevation surface will be rendered using a line symbol.
QVector< QgsGeometry > asGeometries() const override
Returns a list of geometries representing the calculated elevation results.
Stores identify results generated by a QgsAbstractProfileResults object.
QgsRenderContext & renderContext()
Returns a reference to the component QgsRenderContext.
Qgis::ProfileSurfaceSymbology mSymbology
T lower() const
Returns the lower bound of the range.
QgsProfileSnapResult snapPoint(const QgsProfilePoint &point, const QgsProfileSnapContext &context) override
Snaps a point to the generated elevation profile.
std::unique_ptr< QgsLineSymbol > mLineSymbol
QgsPointSequence mRawPoints
T upper() const
Returns the upper bound of the range.
double maximumSurfaceElevationDelta
Maximum allowed snapping delta for the elevation values when snapping to a continuous elevation surfa...
~QgsAbstractProfileSurfaceResults() override
A line symbol type, for rendering LineString and MultiLineString geometries.
Qgis::ProfileSurfaceSymbology symbology() const
Returns the symbology type for rendering the results.
std::unique_ptr< QgsFillSymbol > mFillSymbol
QVector< QgsProfileIdentifyResults > identify(const QgsProfilePoint &point, const QgsProfileIdentifyContext &context) override
Identify results visible at the specified profile point.
QgsProfilePoint snappedPoint
Snapped point.
double distance() const SIP_HOLDGIL
Returns the distance of the point.
Scoped object for saving and restoring a QPainter object's state.
Abstract base class for objects which generate elevation profiles which represent a continuous surfac...
QMap< double, double > mDistanceToHeightMap
~QgsAbstractProfileSurfaceGenerator() override
QgsRange which stores a range of double values.
QVector< QgsPoint > QgsPointSequence
A geometry is the spatial representation of a feature.
const QTransform & worldTransform() const
Returns the transform from world coordinates to painter coordinates.
QgsFillSymbol * clone() const override
Returns a deep copy of this symbol.
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
QgsDoubleRange elevationRange() const
Returns the range of elevations to include in the render.
QgsPointSequence sampledPoints() const override
Returns a list of sampled points, with their calculated elevation as the point z value.
QPainter * painter()
Returns the destination QPainter for the render operation.
QgsDoubleRange zRange() const override
Returns the range of the retrieved elevation values.
double elevation() const SIP_HOLDGIL
Returns the elevation of the point.
QgsLineSymbol * lineSymbol() const
Returns the line symbol to be used for rendering the results.