| 
    QGIS API Documentation
    3.26.3-Buenos Aires (65e4edfdad)
    
   | 
 
 
 
 
Go to the documentation of this file.
   28 #include <QGestureEvent> 
   31   : QGraphicsView( parent )
 
   33   setObjectName( QStringLiteral( 
"PlotCanvas" ) );
 
   34   mScene = 
new QGraphicsScene( 
this );
 
   37   setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
 
   38   setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
 
   39   setMouseTracking( 
true );
 
   40   viewport()->setMouseTracking( 
true );
 
   42   setFocusPolicy( Qt::StrongFocus );
 
   44   setRenderHints( QPainter::Antialiasing );
 
   73   qDeleteAll( mScene->items() );
 
   75   mScene->deleteLater();
 
   95     mTool->populateContextMenuWithEvent( &menu, 
event );
 
  100   if ( !menu.isEmpty() )
 
  101     menu.exec( 
event->globalPos() );
 
  108     mTool->keyPressEvent( 
event );
 
  110   if ( mTool && 
event->isAccepted() )
 
  113   if ( 
event->key() == Qt::Key_Space && ! 
event->isAutoRepeat() )
 
  115     if ( !( 
event->modifiers() & Qt::ControlModifier ) )
 
  133     mTool->keyReleaseEvent( 
event );
 
  136   if ( !mTool || !
event->isAccepted() )
 
  137     QGraphicsView::keyReleaseEvent( 
event );
 
  145     mTool->plotDoubleClickEvent( me.get() );
 
  146     event->setAccepted( me->isAccepted() );
 
  149   if ( !mTool || !
event->isAccepted() )
 
  150     QGraphicsView::mouseDoubleClickEvent( 
event );
 
  158     mTool->plotPressEvent( me.get() );
 
  159     event->setAccepted( me->isAccepted() );
 
  162   if ( !mTool || !
event->isAccepted() )
 
  164     if ( 
event->button() == Qt::MiddleButton )
 
  167       setTool( mMidMouseButtonPanTool );
 
  173       showContextMenu( me.get() );
 
  179       QGraphicsView::mousePressEvent( 
event );
 
  189     mTool->plotReleaseEvent( me.get() );
 
  190     event->setAccepted( me->isAccepted() );
 
  193   if ( !mTool || !
event->isAccepted() )
 
  194     QGraphicsView::mouseReleaseEvent( 
event );
 
  199   QGraphicsView::resizeEvent( e );
 
  206     mTool->wheelEvent( 
event );
 
  209   if ( !mTool || !
event->isAccepted() )
 
  221     mTool->plotMoveEvent( me.get() );
 
  222     event->setAccepted( me->isAccepted() );
 
  225   if ( !mTool || !
event->isAccepted() )
 
  226     QGraphicsView::mouseMoveEvent( 
event );
 
  249   if ( mTool && mTool == 
tool )
 
  253     setCursor( Qt::ArrowCursor );
 
  304   if ( 
event->type() == QEvent::ToolTip && mTool && mTool->canvasToolTipEvent( qgis::down_cast<QHelpEvent *>( 
event ) ) )
 
  308   return QGraphicsView::viewportEvent( 
event );
 
  318   if ( !QTouchDevice::devices().empty() )
 
  320     if ( e->type() == QEvent::Gesture )
 
  325         return mTool->gestureEvent( 
static_cast<QGestureEvent *
>( e ) );
 
  331   return QGraphicsView::event( e );
 
  
virtual void zoomToRect(const QRectF &rect)
Zooms the plot to the specified rect in canvas units.
 
void mousePressEvent(QMouseEvent *e) override
 
void resizeEvent(QResizeEvent *e) override
 
virtual void cancelJobs()
Cancel any rendering job, in a blocking way.
 
QgsPlotTool * tool()
Returns the currently active tool.
 
virtual QgsCoordinateReferenceSystem crs() const
Returns the coordinate reference system (CRS) for map coordinates used by the canvas.
 
Point geometry type, with support for z-dimension and m-values.
 
void toolChanged(QgsPlotTool *newTool)
Emitted when the plot tool is changed.
 
bool viewportEvent(QEvent *event) override
 
~QgsPlotCanvas() override
 
virtual QgsPointXY toCanvasCoordinates(const QgsPoint &point) const
Converts a point in map coordinates to the associated canvas point.
 
void willBeDeleted()
Emitted in the destructor when the canvas is about to be deleted, but is still in a perfectly valid s...
 
virtual void scalePlot(double factor)
Scales the plot by a specified scale factor.
 
virtual void centerPlotOn(double x, double y)
Centers the plot on the plot point corresponding to x, y in canvas units.
 
virtual void refresh()
Updates and redraws the plot.
 
void mouseMoveEvent(QMouseEvent *e) override
 
void mouseReleaseEvent(QMouseEvent *e) override
 
void wheelEvent(QWheelEvent *e) override
 
void setTool(QgsPlotTool *tool)
Sets the interactive tool currently being used on the canvas.
 
@ ShowContextMenu
Show a context menu when right-clicking with the tool.
 
This class represents a coordinate reference system (CRS).
 
bool event(QEvent *e) override
 
A class to represent a 2D point.
 
virtual QgsPointXY snapToPlot(QPoint point)
Snap a canvas point to the plot.
 
void unsetTool(QgsPlotTool *tool)
Unset the current tool.
 
QgsPlotCanvas(QWidget *parent=nullptr)
Constructor for QgsPlotCanvas, with the specified parent widget.
 
void keyPressEvent(QKeyEvent *e) override
 
virtual void panContentsBy(double dx, double dy)
Pans the plot contents by dx, dy in canvas units.
 
virtual QgsPoint toMapCoordinates(const QgsPointXY &point) const
Converts a point on the canvas to the associated map coordinate.
 
void mouseDoubleClickEvent(QMouseEvent *e) override
 
A QgsPlotMouseEvent is the result of a user interaction with the mouse on a QgsPlotCanvas.
 
void keyReleaseEvent(QKeyEvent *e) override
 
virtual void wheelZoom(QWheelEvent *event)
Zoom plot from a mouse wheel event.
 
void contextMenuAboutToShow(QMenu *menu, QgsPlotMouseEvent *event)
Emitted before the canvas context menu will be shown.