QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
QgsElevationProfileCanvas Class Reference

A canvas for elevation profiles. More...

#include <qgselevationprofilecanvas.h>

Inheritance diagram for QgsElevationProfileCanvas:

Public Slots

void clear ()
 Clears the current profile.
void setSnappingEnabled (bool enabled)
 Sets whether snapping of cursor points is enabled.
void zoomFull ()
 Zooms to the full extent of the profile.

Signals

void activeJobCountChanged (int count)
 Emitted when the number of active background jobs changes.
void canvasPointHovered (const QgsPointXY &point, const QgsProfilePoint &profilePoint)
 Emitted when the mouse hovers over the specified point (in canvas coordinates).
void scaleChanged ()
 Emitted when the plot scale is changed.
Signals inherited from QgsPlotCanvas
void contextMenuAboutToShow (QMenu *menu, QgsPlotMouseEvent *event)
 Emitted before the canvas context menu will be shown.
void plotAreaChanged ()
 Emitted whenever the visible area of the plot is changed.
void toolChanged (QgsPlotTool *newTool)
 Emitted when the plot tool is changed.
void willBeDeleted ()
 Emitted in the destructor when the canvas is about to be deleted, but is still in a perfectly valid state.

Public Member Functions

 QgsElevationProfileCanvas (QWidget *parent=nullptr)
 Constructor for QgsElevationProfileCanvas, with the specified parent widget.
 ~QgsElevationProfileCanvas () override
double axisScaleRatio () const
 Returns the current ratio of horizontal (distance) to vertical (elevation) scale for the plot.
void cancelJobs () override
 Cancel any rendering job, in a blocking way.
QgsProfilePoint canvasPointToPlotPoint (QPointF point) const
 Converts a canvas point to the equivalent plot point.
void centerPlotOn (double x, double y) override
 Centers the plot on the plot point corresponding to x, y in canvas units.
QgsCoordinateReferenceSystem crs () const override
 Returns the coordinate reference system (CRS) for map coordinates used by the canvas.
Qgis::DistanceUnit distanceUnit () const
 Returns the distance unit used by the canvas.
QVector< QgsProfileIdentifyResultsidentify (const QRectF &rect)
 Identify results visible within the specified plot rect.
QVector< QgsProfileIdentifyResultsidentify (QPointF point)
 Identify results visible at the specified plot point.
void invalidateCurrentPlotExtent ()
 Invalidates the current plot extent, which means that the visible plot area will be recalculated and "zoom full" operation occur when the next profile generation completes.
QList< QgsMapLayer * > layers () const
 Returns the list of layers included in the profile.
bool lockAxisScales () const
 Returns true if the distance and elevation scales are locked to each other.
void mouseMoveEvent (QMouseEvent *e) override
void paintEvent (QPaintEvent *event) override
void panContentsBy (double dx, double dy) override
 Pans the plot contents by dx, dy in canvas units.
const Qgs2DXyPlotplot () const
 Returns a reference to the 2D plot used by the widget.
QRectF plotArea () const
 Returns the interior rectangle representing the surface of the plot, in canvas coordinates.
QgsPointXY plotPointToCanvasPoint (const QgsProfilePoint &point) const
 Converts a plot point to the equivalent canvas point.
QgsCurveprofileCurve () const
 Returns the profile curve.
void refresh () override
 Triggers a complete regeneration of the profile, causing the profile extraction to perform in the background.
void render (QgsRenderContext &context, double width, double height, const Qgs2DXyPlot &plotSettings)
 Renders a portion of the profile using the specified render context.
void resizeEvent (QResizeEvent *event) override
void scalePlot (double factor) override
 Scales the plot by a specified scale factor.
void scalePlot (double xFactor, double yFactor)
 Scales the plot axis by the given factors.
void setAxisScaleRatio (double scale)
 Sets the ratio of horizontal (distance) to vertical (elevation) scale for the plot.
void setBackgroundColor (const QColor &color)
 Sets the background color to use for the profile canvas.
void setCrs (const QgsCoordinateReferenceSystem &crs)
 Sets the crs associated with the canvas' map coordinates.
void setDistanceUnit (Qgis::DistanceUnit unit)
 Sets the distance unit used by the canvas.
void setLayers (const QList< QgsMapLayer * > &layers)
 Sets the list of layers to include in the profile.
void setLockAxisScales (bool lock)
 Sets whether the distance and elevation scales are locked to each other.
void setProfileCurve (QgsCurve *curve)
 Sets the profile curve.
void setProject (QgsProject *project)
 Sets the project associated with the profile.
void setSources (const QList< QgsAbstractProfileSource * > &sources)
 Sets the list of sources to include in the profile.
void setSubsectionsSymbol (QgsLineSymbol *symbol)
 Sets the symbol used to draw the subsections.
void setTolerance (double tolerance)
 Sets the profile tolerance (in crs() units).
void setVisiblePlotRange (double minimumDistance, double maximumDistance, double minimumElevation, double maximumElevation)
 Sets the visible area of the plot.
QgsPointXY snapToPlot (QPoint point) override
 Snap a canvas point to the plot.
QList< QgsAbstractProfileSource * > sources () const
 Returns the list of sources included in the profile.
QgsLineSymbolsubsectionsSymbol ()
 Returns the symbol used to draw the subsections.
QgsPointXY toCanvasCoordinates (const QgsPoint &point) const override
 Converts a point in map coordinates to the associated canvas point.
double tolerance () const
 Returns the tolerance of the profile (in crs() units).
QgsPoint toMapCoordinates (const QgsPointXY &point) const override
 Converts a point on the canvas to the associated map coordinate.
QgsDoubleRange visibleDistanceRange () const
 Returns the distance range currently visible in the plot.
QgsDoubleRange visibleElevationRange () const
 Returns the elevation range currently visible in the plot.
void wheelZoom (QWheelEvent *event) override
 Zoom plot from a mouse wheel event.
void zoomToRect (const QRectF &rect) override
 Zooms the plot to the specified rect in canvas units.
Public Member Functions inherited from QgsPlotCanvas
 QgsPlotCanvas (QWidget *parent=nullptr)
 Constructor for QgsPlotCanvas, with the specified parent widget.
 ~QgsPlotCanvas () override
void setTool (QgsPlotTool *tool)
 Sets the interactive tool currently being used on the canvas.
QgsPlotTooltool ()
 Returns the currently active tool.
void unsetTool (QgsPlotTool *tool)
 Unset the current tool.

Additional Inherited Members

Protected Member Functions inherited from QgsPlotCanvas
bool event (QEvent *e) override
void keyPressEvent (QKeyEvent *e) override
void keyReleaseEvent (QKeyEvent *e) override
void mouseDoubleClickEvent (QMouseEvent *e) override
void mouseMoveEvent (QMouseEvent *e) override
void mousePressEvent (QMouseEvent *e) override
void mouseReleaseEvent (QMouseEvent *e) override
void resizeEvent (QResizeEvent *e) override
bool viewportEvent (QEvent *event) override
void wheelEvent (QWheelEvent *e) override

Detailed Description

A canvas for elevation profiles.

Since
QGIS 3.26

Definition at line 48 of file qgselevationprofilecanvas.h.

Constructor & Destructor Documentation

◆ QgsElevationProfileCanvas()

PRIVATE QgsElevationProfileCanvas::QgsElevationProfileCanvas ( QWidget * parent = nullptr)

Constructor for QgsElevationProfileCanvas, with the specified parent widget.

Definition at line 425 of file qgselevationprofilecanvas.cpp.

◆ ~QgsElevationProfileCanvas()

QgsElevationProfileCanvas::~QgsElevationProfileCanvas ( )
override

Definition at line 456 of file qgselevationprofilecanvas.cpp.

Member Function Documentation

◆ activeJobCountChanged

void QgsElevationProfileCanvas::activeJobCountChanged ( int count)
signal

Emitted when the number of active background jobs changes.

◆ axisScaleRatio()

double QgsElevationProfileCanvas::axisScaleRatio ( ) const

Returns the current ratio of horizontal (distance) to vertical (elevation) scale for the plot.

See also
setAxisScaleRatio()
Since
QGIS 4.0

Definition at line 717 of file qgselevationprofilecanvas.cpp.

◆ cancelJobs()

void QgsElevationProfileCanvas::cancelJobs ( )
overridevirtual

Cancel any rendering job, in a blocking way.

Used for application closing.

Note
not available in Python bindings

Reimplemented from QgsPlotCanvas.

Definition at line 466 of file qgselevationprofilecanvas.cpp.

◆ canvasPointHovered

void QgsElevationProfileCanvas::canvasPointHovered ( const QgsPointXY & point,
const QgsProfilePoint & profilePoint )
signal

Emitted when the mouse hovers over the specified point (in canvas coordinates).

The profilePoint argument gives the hovered profile point, which may be snapped.

◆ canvasPointToPlotPoint()

QgsProfilePoint QgsElevationProfileCanvas::canvasPointToPlotPoint ( QPointF point) const

Converts a canvas point to the equivalent plot point.

See also
plotPointToCanvasPoint()

Definition at line 1146 of file qgselevationprofilecanvas.cpp.

◆ centerPlotOn()

void QgsElevationProfileCanvas::centerPlotOn ( double x,
double y )
overridevirtual

Centers the plot on the plot point corresponding to x, y in canvas units.

The default implementation does nothing.

Reimplemented from QgsPlotCanvas.

Definition at line 499 of file qgselevationprofilecanvas.cpp.

◆ clear

void QgsElevationProfileCanvas::clear ( )
slot

Clears the current profile.

Definition at line 1506 of file qgselevationprofilecanvas.cpp.

◆ crs()

QgsCoordinateReferenceSystem QgsElevationProfileCanvas::crs ( ) const
overridevirtual

Returns the coordinate reference system (CRS) for map coordinates used by the canvas.

May return an invalid CRS if no CRS is associated with the canvas.

Reimplemented from QgsPlotCanvas.

Definition at line 1185 of file qgselevationprofilecanvas.cpp.

◆ distanceUnit()

Qgis::DistanceUnit QgsElevationProfileCanvas::distanceUnit ( ) const

Returns the distance unit used by the canvas.

See also
setDistanceUnit()
Since
QGIS 3.32

Definition at line 636 of file qgselevationprofilecanvas.cpp.

◆ identify() [1/2]

QVector< QgsProfileIdentifyResults > QgsElevationProfileCanvas::identify ( const QRectF & rect)

Identify results visible within the specified plot rect.

Definition at line 1485 of file qgselevationprofilecanvas.cpp.

◆ identify() [2/2]

QVector< QgsProfileIdentifyResults > QgsElevationProfileCanvas::identify ( QPointF point)

Identify results visible at the specified plot point.

Definition at line 1475 of file qgselevationprofilecanvas.cpp.

◆ invalidateCurrentPlotExtent()

void QgsElevationProfileCanvas::invalidateCurrentPlotExtent ( )

Invalidates the current plot extent, which means that the visible plot area will be recalculated and "zoom full" operation occur when the next profile generation completes.

Definition at line 948 of file qgselevationprofilecanvas.cpp.

◆ layers()

QList< QgsMapLayer * > QgsElevationProfileCanvas::layers ( ) const

Returns the list of layers included in the profile.

See also
setLayers()

Definition at line 1211 of file qgselevationprofilecanvas.cpp.

◆ lockAxisScales()

bool QgsElevationProfileCanvas::lockAxisScales ( ) const

Returns true if the distance and elevation scales are locked to each other.

See also
setLockAxisScales()
Since
QGIS 3.32

Definition at line 690 of file qgselevationprofilecanvas.cpp.

◆ mouseMoveEvent()

void QgsElevationProfileCanvas::mouseMoveEvent ( QMouseEvent * e)
override

Definition at line 874 of file qgselevationprofilecanvas.cpp.

◆ paintEvent()

void QgsElevationProfileCanvas::paintEvent ( QPaintEvent * event)
override

Definition at line 1272 of file qgselevationprofilecanvas.cpp.

◆ panContentsBy()

void QgsElevationProfileCanvas::panContentsBy ( double dx,
double dy )
overridevirtual

Pans the plot contents by dx, dy in canvas units.

The default implementation does nothing.

Reimplemented from QgsPlotCanvas.

Definition at line 478 of file qgselevationprofilecanvas.cpp.

◆ plot()

const Qgs2DXyPlot & QgsElevationProfileCanvas::plot ( ) const

Returns a reference to the 2D plot used by the widget.

Note
Not available in Python bindings

Definition at line 1418 of file qgselevationprofilecanvas.cpp.

◆ plotArea()

QRectF QgsElevationProfileCanvas::plotArea ( ) const

Returns the interior rectangle representing the surface of the plot, in canvas coordinates.

Definition at line 903 of file qgselevationprofilecanvas.cpp.

◆ plotPointToCanvasPoint()

QgsPointXY QgsElevationProfileCanvas::plotPointToCanvasPoint ( const QgsProfilePoint & point) const

Converts a plot point to the equivalent canvas point.

See also
canvasPointToPlotPoint()

Definition at line 1154 of file qgselevationprofilecanvas.cpp.

◆ profileCurve()

QgsCurve * QgsElevationProfileCanvas::profileCurve ( ) const

Returns the profile curve.

The CRS associated with the curve is retrieved via crs().

See also
setProfileCurve()

Definition at line 1175 of file qgselevationprofilecanvas.cpp.

◆ refresh()

void QgsElevationProfileCanvas::refresh ( )
overridevirtual

Triggers a complete regeneration of the profile, causing the profile extraction to perform in the background.

Reimplemented from QgsPlotCanvas.

Definition at line 908 of file qgselevationprofilecanvas.cpp.

◆ render()

PRIVATE void QgsElevationProfileCanvas::render ( QgsRenderContext & context,
double width,
double height,
const Qgs2DXyPlot & plotSettings )

Renders a portion of the profile using the specified render context.

Definition at line 1449 of file qgselevationprofilecanvas.cpp.

◆ resizeEvent()

void QgsElevationProfileCanvas::resizeEvent ( QResizeEvent * event)
override

Definition at line 1249 of file qgselevationprofilecanvas.cpp.

◆ scaleChanged

void QgsElevationProfileCanvas::scaleChanged ( )
signal

Emitted when the plot scale is changed.

Since
QGIS 4.0

◆ scalePlot() [1/2]

void QgsElevationProfileCanvas::scalePlot ( double factor)
overridevirtual

Scales the plot by a specified scale factor.

The default implementation does nothing.

Reimplemented from QgsPlotCanvas.

Definition at line 522 of file qgselevationprofilecanvas.cpp.

◆ scalePlot() [2/2]

void QgsElevationProfileCanvas::scalePlot ( double xFactor,
double yFactor )

Scales the plot axis by the given factors.

Definition at line 758 of file qgselevationprofilecanvas.cpp.

◆ setAxisScaleRatio()

void QgsElevationProfileCanvas::setAxisScaleRatio ( double scale)

Sets the ratio of horizontal (distance) to vertical (elevation) scale for the plot.

E.g. a scale of 3 indicates a ratio of 3:1 for distance vs elevation, whereas a scale of 0.3333 indicates a ratio of 1:3 for distance vs elevation.

This will immediately update the visible plot area to match the specified scale.

See also
axisScaleRatio()
setLockAxisScales()
Since
QGIS 4.0

Definition at line 724 of file qgselevationprofilecanvas.cpp.

◆ setBackgroundColor()

void QgsElevationProfileCanvas::setBackgroundColor ( const QColor & color)

Sets the background color to use for the profile canvas.

The chart text, border and axis color will be automatically updated to ensure readability with the new background color.

Since
QGIS 3.34

Definition at line 654 of file qgselevationprofilecanvas.cpp.

◆ setCrs()

void QgsElevationProfileCanvas::setCrs ( const QgsCoordinateReferenceSystem & crs)

Sets the crs associated with the canvas' map coordinates.

See also
crs()

Definition at line 1165 of file qgselevationprofilecanvas.cpp.

◆ setDistanceUnit()

void QgsElevationProfileCanvas::setDistanceUnit ( Qgis::DistanceUnit unit)

Sets the distance unit used by the canvas.

See also
distanceUnit()
Since
QGIS 3.32

Definition at line 641 of file qgselevationprofilecanvas.cpp.

◆ setLayers()

void QgsElevationProfileCanvas::setLayers ( const QList< QgsMapLayer * > & layers)

Sets the list of layers to include in the profile.

See also
layers()

Definition at line 1190 of file qgselevationprofilecanvas.cpp.

◆ setLockAxisScales()

void QgsElevationProfileCanvas::setLockAxisScales ( bool lock)

Sets whether the distance and elevation scales are locked to each other.

See also
lockAxisScales()
Since
QGIS 3.32

Definition at line 695 of file qgselevationprofilecanvas.cpp.

◆ setProfileCurve()

void QgsElevationProfileCanvas::setProfileCurve ( QgsCurve * curve)

Sets the profile curve.

The CRS associated with curve is set via setCrs().

Ownership is transferred to the plot canvas.

See also
profileCurve()

Definition at line 1170 of file qgselevationprofilecanvas.cpp.

◆ setProject()

void QgsElevationProfileCanvas::setProject ( QgsProject * project)

Sets the project associated with the profile.

This must be set before any layers which utilize terrain based elevation settings can be included in the canvas.

Definition at line 1159 of file qgselevationprofilecanvas.cpp.

◆ setSnappingEnabled

void QgsElevationProfileCanvas::setSnappingEnabled ( bool enabled)
slot

Sets whether snapping of cursor points is enabled.

Definition at line 1513 of file qgselevationprofilecanvas.cpp.

◆ setSources()

void QgsElevationProfileCanvas::setSources ( const QList< QgsAbstractProfileSource * > & sources)

Sets the list of sources to include in the profile.

See also
sources()

Definition at line 1216 of file qgselevationprofilecanvas.cpp.

◆ setSubsectionsSymbol()

void QgsElevationProfileCanvas::setSubsectionsSymbol ( QgsLineSymbol * symbol)

Sets the symbol used to draw the subsections.

If symbol is nullptr, the subsections are not drawn. Ownership of symbol is transferred.

See also
subsectionsSymbol()
Since
QGIS 3.44

Definition at line 1518 of file qgselevationprofilecanvas.cpp.

◆ setTolerance()

void QgsElevationProfileCanvas::setTolerance ( double tolerance)

Sets the profile tolerance (in crs() units).

This value determines how far from the profileCurve() is appropriate for inclusion of results. For instance, when a profile is generated for a point vector layer this tolerance distance will dictate how far from the actual profile curve a point can reside within to be included in the results.

See also
tolerance()

Definition at line 1180 of file qgselevationprofilecanvas.cpp.

◆ setVisiblePlotRange()

void QgsElevationProfileCanvas::setVisiblePlotRange ( double minimumDistance,
double maximumDistance,
double minimumElevation,
double maximumElevation )

Sets the visible area of the plot.

See also
visibleDistanceRange()
visibleElevationRange()

Definition at line 1391 of file qgselevationprofilecanvas.cpp.

◆ snapToPlot()

QgsPointXY QgsElevationProfileCanvas::snapToPlot ( QPoint point)
overridevirtual

Snap a canvas point to the plot.

Returns an empty point if snapping was not possible.

Parameters
pointpoint in canvas coordinates

Reimplemented from QgsPlotCanvas.

Definition at line 744 of file qgselevationprofilecanvas.cpp.

◆ sources()

QList< QgsAbstractProfileSource * > QgsElevationProfileCanvas::sources ( ) const

Returns the list of sources included in the profile.

It includes both layer profile sources and custom sources from the profile source registry.

See also
setSources()

Definition at line 1221 of file qgselevationprofilecanvas.cpp.

◆ subsectionsSymbol()

QgsLineSymbol * QgsElevationProfileCanvas::subsectionsSymbol ( )
inline

Returns the symbol used to draw the subsections.

See also
setSubsectionsSymbol()
Since
QGIS 3.44

Definition at line 314 of file qgselevationprofilecanvas.h.

◆ toCanvasCoordinates()

QgsPointXY QgsElevationProfileCanvas::toCanvasCoordinates ( const QgsPoint & point) const
overridevirtual

Converts a point in map coordinates to the associated canvas point.

May return an empty point if the map point cannot be converted to a canvas point.

Reimplemented from QgsPlotCanvas.

Definition at line 1307 of file qgselevationprofilecanvas.cpp.

◆ tolerance()

double QgsElevationProfileCanvas::tolerance ( ) const
inline

Returns the tolerance of the profile (in crs() units).

This value determines how far from the profileCurve() is appropriate for inclusion of results. For instance, when a profile is generated for a point vector layer this tolerance distance will dictate how far from the actual profile curve a point can reside within to be included in the results.

See also
setTolerance()

Definition at line 181 of file qgselevationprofilecanvas.h.

◆ toMapCoordinates()

QgsPoint QgsElevationProfileCanvas::toMapCoordinates ( const QgsPointXY & point) const
overridevirtual

Converts a point on the canvas to the associated map coordinate.

May return an empty point if the canvas point cannot be converted to a map point.

Reimplemented from QgsPlotCanvas.

Definition at line 1285 of file qgselevationprofilecanvas.cpp.

◆ visibleDistanceRange()

QgsDoubleRange QgsElevationProfileCanvas::visibleDistanceRange ( ) const

Returns the distance range currently visible in the plot.

See also
visibleElevationRange()
setVisiblePlotRange()

Definition at line 1408 of file qgselevationprofilecanvas.cpp.

◆ visibleElevationRange()

QgsDoubleRange QgsElevationProfileCanvas::visibleElevationRange ( ) const

Returns the elevation range currently visible in the plot.

See also
visibleDistanceRange()
setVisiblePlotRange()

Definition at line 1413 of file qgselevationprofilecanvas.cpp.

◆ wheelZoom()

void QgsElevationProfileCanvas::wheelZoom ( QWheelEvent * event)
overridevirtual

Zoom plot from a mouse wheel event.

The default implementation does nothing.

Reimplemented from QgsPlotCanvas.

Definition at line 817 of file qgselevationprofilecanvas.cpp.

◆ zoomFull

void QgsElevationProfileCanvas::zoomFull ( )
slot

Zooms to the full extent of the profile.

Definition at line 1340 of file qgselevationprofilecanvas.cpp.

◆ zoomToRect()

void QgsElevationProfileCanvas::zoomToRect ( const QRectF & rect)
overridevirtual

Zooms the plot to the specified rect in canvas units.

The default implementation does nothing.

Reimplemented from QgsPlotCanvas.

Definition at line 792 of file qgselevationprofilecanvas.cpp.


The documentation for this class was generated from the following files: