QGIS API Documentation 3.41.0-Master (af5edcb665c)
Loading...
Searching...
No Matches
Public Slots | Signals | Public Member Functions | Protected Member Functions | List of all members
QgsPlotCanvas Class Reference

Plot canvas is a class for displaying interactive 2d charts and plots. More...

#include <qgsplotcanvas.h>

Inheritance diagram for QgsPlotCanvas:
Inheritance graph
[legend]

Public Slots

virtual void refresh ()
 Updates and redraws the plot.
 

Signals

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

 QgsPlotCanvas (QWidget *parent=nullptr)
 Constructor for QgsPlotCanvas, with the specified parent widget.
 
 ~QgsPlotCanvas () override
 
virtual void cancelJobs ()
 Cancel any rendering job, in a blocking way.
 
virtual void centerPlotOn (double x, double y)
 Centers the plot on the plot point corresponding to x, y in canvas units.
 
virtual QgsCoordinateReferenceSystem crs () const
 Returns the coordinate reference system (CRS) for map coordinates used by the canvas.
 
virtual void panContentsBy (double dx, double dy)
 Pans the plot contents by dx, dy in canvas units.
 
virtual void scalePlot (double factor)
 Scales the plot by a specified scale factor.
 
void setTool (QgsPlotTool *tool)
 Sets the interactive tool currently being used on the canvas.
 
virtual QgsPointXY snapToPlot (QPoint point)
 Snap a canvas point to the plot.
 
virtual QgsPointXY toCanvasCoordinates (const QgsPoint &point) const
 Converts a point in map coordinates to the associated canvas point.
 
virtual QgsPoint toMapCoordinates (const QgsPointXY &point) const
 Converts a point on the canvas to the associated map coordinate.
 
QgsPlotTooltool ()
 Returns the currently active tool.
 
void unsetTool (QgsPlotTool *tool)
 Unset the current tool.
 
virtual void zoomToRect (const QRectF &rect)
 Zooms the plot to the specified rect in canvas units.
 

Protected Member Functions

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
 
virtual void wheelZoom (QWheelEvent *event)
 Zoom plot from a mouse wheel event.
 

Detailed Description

Plot canvas is a class for displaying interactive 2d charts and plots.

Since
QGIS 3.26

Definition at line 53 of file qgsplotcanvas.h.

Constructor & Destructor Documentation

◆ QgsPlotCanvas()

QgsPlotCanvas::QgsPlotCanvas ( QWidget *  parent = nullptr)

Constructor for QgsPlotCanvas, with the specified parent widget.

Definition at line 31 of file qgsplotcanvas.cpp.

◆ ~QgsPlotCanvas()

QgsPlotCanvas::~QgsPlotCanvas ( )
override

Definition at line 52 of file qgsplotcanvas.cpp.

Member Function Documentation

◆ cancelJobs()

void QgsPlotCanvas::cancelJobs ( )
virtual

Cancel any rendering job, in a blocking way.

Used for application closing.

Note
not available in Python bindings

Reimplemented in QgsElevationProfileCanvas.

Definition at line 80 of file qgsplotcanvas.cpp.

◆ centerPlotOn()

void QgsPlotCanvas::centerPlotOn ( double  x,
double  y 
)
virtual

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

The default implementation does nothing.

Reimplemented in QgsElevationProfileCanvas.

Definition at line 280 of file qgsplotcanvas.cpp.

◆ contextMenuAboutToShow

void QgsPlotCanvas::contextMenuAboutToShow ( QMenu *  menu,
QgsPlotMouseEvent event 
)
signal

Emitted before the canvas context menu will be shown.

Can be used to extend the context menu.

◆ crs()

QgsCoordinateReferenceSystem QgsPlotCanvas::crs ( ) const
virtual

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 in QgsElevationProfileCanvas.

Definition at line 261 of file qgsplotcanvas.cpp.

◆ event()

bool QgsPlotCanvas::event ( QEvent *  e)
overrideprotected

Definition at line 310 of file qgsplotcanvas.cpp.

◆ keyPressEvent()

void QgsPlotCanvas::keyPressEvent ( QKeyEvent *  e)
overrideprotected

Definition at line 103 of file qgsplotcanvas.cpp.

◆ keyReleaseEvent()

void QgsPlotCanvas::keyReleaseEvent ( QKeyEvent *  e)
overrideprotected

Definition at line 128 of file qgsplotcanvas.cpp.

◆ mouseDoubleClickEvent()

void QgsPlotCanvas::mouseDoubleClickEvent ( QMouseEvent *  e)
overrideprotected

Definition at line 139 of file qgsplotcanvas.cpp.

◆ mouseMoveEvent()

void QgsPlotCanvas::mouseMoveEvent ( QMouseEvent *  e)
overrideprotected

Definition at line 215 of file qgsplotcanvas.cpp.

◆ mousePressEvent()

void QgsPlotCanvas::mousePressEvent ( QMouseEvent *  e)
overrideprotected

Definition at line 152 of file qgsplotcanvas.cpp.

◆ mouseReleaseEvent()

void QgsPlotCanvas::mouseReleaseEvent ( QMouseEvent *  e)
overrideprotected

Definition at line 183 of file qgsplotcanvas.cpp.

◆ panContentsBy()

void QgsPlotCanvas::panContentsBy ( double  dx,
double  dy 
)
virtual

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

The default implementation does nothing.

Reimplemented in QgsElevationProfileCanvas.

Definition at line 276 of file qgsplotcanvas.cpp.

◆ plotAreaChanged

void QgsPlotCanvas::plotAreaChanged ( )
signal

Emitted whenever the visible area of the plot is changed.

◆ refresh

void QgsPlotCanvas::refresh ( )
virtualslot

Updates and redraws the plot.

Reimplemented in QgsElevationProfileCanvas.

Definition at line 84 of file qgsplotcanvas.cpp.

◆ resizeEvent()

void QgsPlotCanvas::resizeEvent ( QResizeEvent *  e)
overrideprotected

Definition at line 196 of file qgsplotcanvas.cpp.

◆ scalePlot()

void QgsPlotCanvas::scalePlot ( double  factor)
virtual

Scales the plot by a specified scale factor.

The default implementation does nothing.

Reimplemented in QgsElevationProfileCanvas.

Definition at line 284 of file qgsplotcanvas.cpp.

◆ setTool()

void QgsPlotCanvas::setTool ( QgsPlotTool tool)

Sets the interactive tool currently being used on the canvas.

Definition at line 228 of file qgsplotcanvas.cpp.

◆ snapToPlot()

QgsPointXY QgsPlotCanvas::snapToPlot ( QPoint  point)
virtual

Snap a canvas point to the plot.

Returns an empty point if snapping was not possible.

Parameters
pointpoint in canvas coordinates

Reimplemented in QgsElevationProfileCanvas.

Definition at line 292 of file qgsplotcanvas.cpp.

◆ toCanvasCoordinates()

QgsPointXY QgsPlotCanvas::toCanvasCoordinates ( const QgsPoint point) const
virtual

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 in QgsElevationProfileCanvas.

Definition at line 271 of file qgsplotcanvas.cpp.

◆ toMapCoordinates()

QgsPoint QgsPlotCanvas::toMapCoordinates ( const QgsPointXY point) const
virtual

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 in QgsElevationProfileCanvas.

Definition at line 266 of file qgsplotcanvas.cpp.

◆ tool()

QgsPlotTool * QgsPlotCanvas::tool ( )

Returns the currently active tool.

Definition at line 256 of file qgsplotcanvas.cpp.

◆ toolChanged

void QgsPlotCanvas::toolChanged ( QgsPlotTool newTool)
signal

Emitted when the plot tool is changed.

◆ unsetTool()

void QgsPlotCanvas::unsetTool ( QgsPlotTool tool)

Unset the current tool.

This is called from destructor of plot tools to make sure that this map tool won't be used any more.

You don't have to call it manually, QgsPlotTool takes care of it.

Definition at line 246 of file qgsplotcanvas.cpp.

◆ viewportEvent()

bool QgsPlotCanvas::viewportEvent ( QEvent *  event)
overrideprotected

Definition at line 297 of file qgsplotcanvas.cpp.

◆ wheelEvent()

void QgsPlotCanvas::wheelEvent ( QWheelEvent *  e)
overrideprotected

Definition at line 201 of file qgsplotcanvas.cpp.

◆ wheelZoom()

void QgsPlotCanvas::wheelZoom ( QWheelEvent *  event)
protectedvirtual

Zoom plot from a mouse wheel event.

The default implementation does nothing.

Reimplemented in QgsElevationProfileCanvas.

Definition at line 306 of file qgsplotcanvas.cpp.

◆ willBeDeleted

void QgsPlotCanvas::willBeDeleted ( )
signal

Emitted in the destructor when the canvas is about to be deleted, but is still in a perfectly valid state.

◆ zoomToRect()

void QgsPlotCanvas::zoomToRect ( const QRectF &  rect)
virtual

Zooms the plot to the specified rect in canvas units.

The default implementation does nothing.

Reimplemented in QgsElevationProfileCanvas.

Definition at line 288 of file qgsplotcanvas.cpp.


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