SILICON
Toggle main menu visibility
Loading...
Searching...
No Matches
diagramView.hpp
Go to the documentation of this file.
1
/*
2
Copyright (c) 2026. Giulio Cocconi
3
4
This program is free software: you can redistribute it and/or modify
5
it under the terms of the GNU General Public License as published by
6
the Free Software Foundation, either version 3 of the License, or
7
(at your option) any later version.
8
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
13
14
You should have received a copy of the GNU General Public License
15
along with this program. If not, see <http://www.gnu.org/licenses/>.
16
*/
17
18
#pragma once
19
20
#include <algorithm>
21
22
#include <QGraphicsView>
23
#include <QWheelEvent>
24
25
#include <
ui/circuit/diagram/scene/diagramScene.hpp
>
26
27
28
namespace
SILICON::ui
{
29
class
DiagramView
:
public
QGraphicsView {
30
Q_OBJECT
31
public
:
32
explicit
DiagramView
(QWidget* parent =
nullptr
);
33
void
setScene
(
DiagramScene
* scene);
34
35
protected
:
36
void
wheelEvent
(QWheelEvent* event)
override
;
37
38
public
slots:
40
void
zoomIn
();
42
void
zoomOut
();
48
void
zoomToRect
(
const
QRectF& rect);
50
void
centerCircuit
();
51
void
modeChanged
(
InteractionMode
mode);
52
53
private
:
54
static
constexpr
int
MIN_ZOOM_LEVEL
= 60;
55
static
constexpr
int
MAX_ZOOM_LEVEL
= 200;
56
int
zoomLevel
= 100;
57
qreal
wheelZoomRemainder
= 0;
58
59
bool
zoom
(
int
level);
60
void
updateZoom
();
61
};
62
63
}
// namespace SILICON::ui
SILICON::ui::DiagramScene
Graphics scene for the circuit diagram editor.
Definition
diagramScene.hpp:118
SILICON::ui::DiagramView::zoom
bool zoom(int level)
Definition
diagramView.cpp:109
SILICON::ui::DiagramView::DiagramView
DiagramView(QWidget *parent=nullptr)
Definition
diagramView.cpp:25
SILICON::ui::DiagramView::MAX_ZOOM_LEVEL
static constexpr int MAX_ZOOM_LEVEL
Definition
diagramView.hpp:55
SILICON::ui::DiagramView::zoomLevel
int zoomLevel
Definition
diagramView.hpp:56
SILICON::ui::DiagramView::updateZoom
void updateZoom()
Definition
diagramView.cpp:121
SILICON::ui::DiagramView::modeChanged
void modeChanged(InteractionMode mode)
Definition
diagramView.cpp:133
SILICON::ui::DiagramView::zoomOut
void zoomOut()
Decreases the circuit zoom by one step.
Definition
diagramView.cpp:90
SILICON::ui::DiagramView::setScene
void setScene(DiagramScene *scene)
Definition
diagramView.cpp:32
SILICON::ui::DiagramView::zoomIn
void zoomIn()
Increases the circuit zoom by one step.
Definition
diagramView.cpp:85
SILICON::ui::DiagramView::wheelZoomRemainder
qreal wheelZoomRemainder
Definition
diagramView.hpp:57
SILICON::ui::DiagramView::MIN_ZOOM_LEVEL
static constexpr int MIN_ZOOM_LEVEL
Definition
diagramView.hpp:54
SILICON::ui::DiagramView::zoomToRect
void zoomToRect(const QRectF &rect)
Centers a scene rectangle and fits it within the existing zoom limits.
Definition
diagramView.cpp:95
SILICON::ui::DiagramView::wheelEvent
void wheelEvent(QWheelEvent *event) override
Definition
diagramView.cpp:47
SILICON::ui::DiagramView::centerCircuit
void centerCircuit()
Pans the viewport so the circuit's bounds are centered.
Definition
diagramView.cpp:127
diagramScene.hpp
SILICON::ui
Definition
actionGroups.hpp:14
SILICON::ui::InteractionMode
DiagramScene::InteractionMode InteractionMode
Alias for DiagramScene::InteractionMode.
Definition
diagramScene.hpp:751
src
ui
circuit
diagram
diagramView.hpp
Generated by
1.17.0