wiRedPanda
Logic Circuit Simulator
Loading...
Searching...
No Matches
GraphicsView.h
Go to the documentation of this file.
1// Copyright 2015 - 2026, GIBIS-UNIFESP and the wiRedPanda contributors
2// SPDX-License-Identifier: GPL-3.0-or-later
3
7
8#pragma once
9
10#include <QGraphicsView>
11
21class GraphicsView : public QGraphicsView
22{
23 Q_OBJECT
24
25public:
26 // --- Lifecycle ---
27
29 explicit GraphicsView(QWidget *parent = nullptr);
30
31 // --- Zoom ---
32
34 bool canZoomIn() const;
35
37 bool canZoomOut() const;
38
40 void resetZoom();
41
45 void zoomToFit();
46
48 void zoomIn();
49
51 void zoomOut();
52
53 // --- Settings ---
54
59 void setFastMode(const bool fastMode);
60
61signals:
64
65protected:
66 // --- Event handlers ---
67
71 void paintEvent(QPaintEvent *event) override;
72
73 void keyPressEvent(QKeyEvent *event) override;
75 void keyReleaseEvent(QKeyEvent *event) override;
77 void mouseMoveEvent(QMouseEvent *event) override;
79 void mousePressEvent(QMouseEvent *event) override;
81 void mouseReleaseEvent(QMouseEvent *event) override;
83 void wheelEvent(QWheelEvent *event) override;
84
85 // --- Members ---
86
87 int m_zoomLevel = 0;
88
89private:
90 // --- Members ---
91
92 bool m_pan = false;
93 bool m_space = false;
94 int m_panStartX = 0;
95 int m_panStartY = 0;
96};
void zoomOut()
Decreases the view magnification by one zoom step.
void paintEvent(QPaintEvent *event) override
void mousePressEvent(QMouseEvent *event) override
void keyPressEvent(QKeyEvent *event) override
int m_zoomLevel
Current zoom step (0 = 1:1, positive = zoomed in).
void mouseReleaseEvent(QMouseEvent *event) override
bool canZoomOut() const
Returns true if zooming out further is possible.
GraphicsView(QWidget *parent=nullptr)
Constructs the view with optional parent.
void zoomIn()
Increases the view magnification by one zoom step.
void zoomChanged()
Emitted whenever the zoom level changes.
void keyReleaseEvent(QKeyEvent *event) override
void resetZoom()
Resets the view scale to 1:1.
bool canZoomIn() const
Returns true if zooming in further is possible.
void wheelEvent(QWheelEvent *event) override
void mouseMoveEvent(QMouseEvent *event) override
void setFastMode(const bool fastMode)
Enables or disables fast rendering mode (disables antialiasing).