QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
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. More...
 

Signals

void contextMenuAboutToShow (QMenu *menu, QgsPlotMouseEvent *event)
 Emitted before the canvas context menu will be shown. More...
 
void plotAreaChanged ()
 Emitted whenever the visible area of the plot is changed. More...
 
void toolChanged (QgsPlotTool *newTool)
 Emitted when the plot tool is changed. More...
 
void willBeDeleted ()
 Emitted in the destructor when the canvas is about to be deleted, but is still in a perfectly valid state. More...
 

Public Member Functions

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

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. More...
 

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 30 of file qgsplotcanvas.cpp.

◆ ~QgsPlotCanvas()

QgsPlotCanvas::~QgsPlotCanvas ( )
override

Definition at line 51 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 79 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 282 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 262 of file qgsplotcanvas.cpp.

◆ event()

bool QgsPlotCanvas::event ( QEvent *  e)
overrideprotected

Definition at line 316 of file qgsplotcanvas.cpp.

◆ keyPressEvent()

void QgsPlotCanvas::keyPressEvent ( QKeyEvent *  e)
overrideprotected

Definition at line 104 of file qgsplotcanvas.cpp.

◆ keyReleaseEvent()

void QgsPlotCanvas::keyReleaseEvent ( QKeyEvent *  e)
overrideprotected

Definition at line 129 of file qgsplotcanvas.cpp.

◆ mouseDoubleClickEvent()

void QgsPlotCanvas::mouseDoubleClickEvent ( QMouseEvent *  e)
overrideprotected

Definition at line 140 of file qgsplotcanvas.cpp.

◆ mouseMoveEvent()

void QgsPlotCanvas::mouseMoveEvent ( QMouseEvent *  e)
overrideprotected

Definition at line 216 of file qgsplotcanvas.cpp.

◆ mousePressEvent()

void QgsPlotCanvas::mousePressEvent ( QMouseEvent *  e)
overrideprotected

Definition at line 153 of file qgsplotcanvas.cpp.

◆ mouseReleaseEvent()

void QgsPlotCanvas::mouseReleaseEvent ( QMouseEvent *  e)
overrideprotected

Definition at line 184 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 277 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 197 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 287 of file qgsplotcanvas.cpp.

◆ setTool()

void QgsPlotCanvas::setTool ( QgsPlotTool tool)

Sets the interactive tool currently being used on the canvas.

Definition at line 229 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 297 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 272 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 267 of file qgsplotcanvas.cpp.

◆ tool()

QgsPlotTool * QgsPlotCanvas::tool ( )

Returns the currently active tool.

Definition at line 257 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 247 of file qgsplotcanvas.cpp.

◆ viewportEvent()

bool QgsPlotCanvas::viewportEvent ( QEvent *  event)
overrideprotected

Definition at line 302 of file qgsplotcanvas.cpp.

◆ wheelEvent()

void QgsPlotCanvas::wheelEvent ( QWheelEvent *  e)
overrideprotected

Definition at line 202 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 311 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 292 of file qgsplotcanvas.cpp.


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