wiRedPanda
Logic Circuit Simulator
Loading...
Searching...
No Matches
GraphicsView Class Reference

Extended QGraphicsView with enhanced navigation capabilities. More...

#include <GraphicsView.h>

Inheritance diagram for GraphicsView:
[legend]

Public Member Functions

bool canZoomIn () const
 Returns true if zooming in further is possible.
bool canZoomOut () const
 Returns true if zooming out further is possible.
 GraphicsView (QWidget *parent=nullptr)
 Constructs the view with optional parent.
void resetZoom ()
 Resets the view scale to 1:1.
void setFastMode (const bool fastMode)
 Enables or disables fast rendering mode (disables antialiasing).
void zoomChanged ()
 Emitted whenever the zoom level changes.
void zoomIn ()
 Increases the view magnification by one zoom step.
void zoomOut ()
 Decreases the view magnification by one zoom step.
void zoomToFit ()

Protected Member Functions

void keyPressEvent (QKeyEvent *event) override
void keyReleaseEvent (QKeyEvent *event) override
void mouseMoveEvent (QMouseEvent *event) override
void mousePressEvent (QMouseEvent *event) override
void mouseReleaseEvent (QMouseEvent *event) override
void paintEvent (QPaintEvent *event) override
void wheelEvent (QWheelEvent *event) override

Protected Attributes

int m_zoomLevel = 0
 Current zoom step (0 = 1:1, positive = zoomed in).

Detailed Description

Extended QGraphicsView with enhanced navigation capabilities.

GraphicsView extends the QGraphicsView class to provide additional functionality for zooming, panning, and keyboard navigation. It includes signals to notify when zoom operations occur and supports redirect zoom mode for delegating zoom operations to parent components.

Definition at line 21 of file GraphicsView.h.

Constructor & Destructor Documentation

◆ GraphicsView()

GraphicsView::GraphicsView ( QWidget * parent = nullptr)
explicit

Constructs the view with optional parent.

Definition at line 25 of file GraphicsView.cpp.

Member Function Documentation

◆ canZoomIn()

bool GraphicsView::canZoomIn ( ) const

Returns true if zooming in further is possible.

Definition at line 65 of file GraphicsView.cpp.

References m_zoomLevel.

Referenced by wheelEvent().

◆ canZoomOut()

bool GraphicsView::canZoomOut ( ) const

Returns true if zooming out further is possible.

Definition at line 70 of file GraphicsView.cpp.

References m_zoomLevel.

Referenced by wheelEvent().

◆ keyPressEvent()

void GraphicsView::keyPressEvent ( QKeyEvent * event)
overrideprotected

Definition at line 125 of file GraphicsView.cpp.

◆ keyReleaseEvent()

void GraphicsView::keyReleaseEvent ( QKeyEvent * event)
overrideprotected
Reimplemented from base class.

Definition at line 146 of file GraphicsView.cpp.

◆ mouseMoveEvent()

void GraphicsView::mouseMoveEvent ( QMouseEvent * event)
overrideprotected
Reimplemented from base class.

Definition at line 91 of file GraphicsView.cpp.

◆ mousePressEvent()

void GraphicsView::mousePressEvent ( QMouseEvent * event)
overrideprotected
Reimplemented from base class.

Definition at line 75 of file GraphicsView.cpp.

◆ mouseReleaseEvent()

void GraphicsView::mouseReleaseEvent ( QMouseEvent * event)
overrideprotected
Reimplemented from base class.

Definition at line 113 of file GraphicsView.cpp.

◆ paintEvent()

void GraphicsView::paintEvent ( QPaintEvent * event)
overrideprotected
Reimplemented from base class.
Reimplemented from base class. Times each pass and feeds Scene::recordWirePaintPass() so wire
antialiasing can adapt to the measured paint workload (see Scene).

Definition at line 51 of file GraphicsView.cpp.

◆ resetZoom()

void GraphicsView::resetZoom ( )

Resets the view scale to 1:1.

Definition at line 214 of file GraphicsView.cpp.

References m_zoomLevel, sentryBreadcrumb(), and zoomChanged().

◆ setFastMode()

void GraphicsView::setFastMode ( const bool fastMode)

Enables or disables fast rendering mode (disables antialiasing).

Parameters
fastModetrue to use fast (non-antialiased) rendering.

Definition at line 187 of file GraphicsView.cpp.

Referenced by MainWindow::setFastMode().

◆ wheelEvent()

void GraphicsView::wheelEvent ( QWheelEvent * event)
overrideprotected
Reimplemented from base class.

Definition at line 164 of file GraphicsView.cpp.

References canZoomIn(), canZoomOut(), zoomIn(), and zoomOut().

◆ zoomChanged()

void GraphicsView::zoomChanged ( )

◆ zoomIn()

void GraphicsView::zoomIn ( )

Increases the view magnification by one zoom step.

Definition at line 196 of file GraphicsView.cpp.

References m_zoomLevel, sentryBreadcrumb(), and zoomChanged().

Referenced by wheelEvent().

◆ zoomOut()

void GraphicsView::zoomOut ( )

Decreases the view magnification by one zoom step.

Definition at line 206 of file GraphicsView.cpp.

References m_zoomLevel, sentryBreadcrumb(), and zoomChanged().

Referenced by wheelEvent().

◆ zoomToFit()

void GraphicsView::zoomToFit ( )

Scales and centres the view so the whole circuit — or the current selection, if any — fits, snapping to the nearest discrete zoom step that still fits so the level ladder (canZoomIn()/zoomIn()/zoomOut()) stays consistent.

Definition at line 222 of file GraphicsView.cpp.

References m_zoomLevel, sentryBreadcrumb(), and zoomChanged().

Member Data Documentation

◆ m_zoomLevel

int GraphicsView::m_zoomLevel = 0
protected

Current zoom step (0 = 1:1, positive = zoomed in).

Definition at line 87 of file GraphicsView.h.

Referenced by canZoomIn(), canZoomOut(), resetZoom(), zoomIn(), zoomOut(), and zoomToFit().


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