SILICON
Toggle main menu visibility
Loading...
Searching...
No Matches
graphicalGates.hpp
Go to the documentation of this file.
1
/*
2
Copyright (c) 2025. 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 <
core/gates.hpp
>
21
#include <
ui/circuit/components/graphicalLogicComponent.hpp
>
22
#include <
ui/shell/themedSvgItem.hpp
>
23
24
namespace
SILICON::ui
{
25
using namespace
SILICON::core;
26
27
class
GraphicalGate
:
public
GraphicalLogicComponent
{
28
Q_OBJECT
29
public
:
30
void
setComponent
(
const
Component_ptr
& component)
override
;
31
32
protected
:
33
GraphicalGate
(
const
std::shared_ptr<Gate> gate, QGraphicsItem* shape,
34
QGraphicsItem* parent =
nullptr
,
bool
scanShape
=
false
);
35
36
void
updateGatePorts
();
37
void
updatePortSizes
()
override
;
38
39
int
type
()
const override
{
return
SiliconTypes::UNKNOWN
; }
40
};
41
42
class
GraphicalAnd
:
public
GraphicalGate
{
43
Q_OBJECT
44
public
:
45
explicit
GraphicalAnd
(QGraphicsItem* parent =
nullptr
)
46
:
GraphicalGate
(
47
std::make_shared<
AndGate
>(std::vector<
Wire_ptr
>{
nullptr
,
nullptr
},
nullptr
),
48
new
ThemedSvgItem
(
":/gates/AND_ANSI.svg"
), parent)
49
{
50
}
51
52
int
type
()
const override
{
return
SiliconTypes::AND_GATE
; }
53
};
54
55
class
GraphicalOr
:
public
GraphicalGate
{
56
Q_OBJECT
57
public
:
58
explicit
GraphicalOr
(QGraphicsItem* parent =
nullptr
)
59
:
GraphicalGate
(
60
std::make_shared<
OrGate
>(std::vector<
Wire_ptr
>{
nullptr
,
nullptr
},
nullptr
),
61
new
ThemedSvgItem
(
":/gates/OR_ANSI.svg"
), parent)
62
{
63
}
64
65
int
type
()
const override
{
return
SiliconTypes::OR_GATE
; }
66
};
67
68
class
GraphicalNot
:
public
GraphicalLogicComponent
{
69
Q_OBJECT
70
public
:
71
explicit
GraphicalNot
(QGraphicsItem* parent =
nullptr
);
72
int
type
()
const override
{
return
SiliconTypes::NOT_GATE
; }
73
};
74
75
class
GraphicalNand
:
public
GraphicalGate
{
76
Q_OBJECT
77
public
:
78
explicit
GraphicalNand
(QGraphicsItem* parent =
nullptr
)
79
:
GraphicalGate
(
80
std::make_shared<
NandGate
>(std::vector<
Wire_ptr
>{
nullptr
,
nullptr
},
nullptr
),
81
new
ThemedSvgItem
(
":/gates/NAND_ANSI.svg"
), parent)
82
{
83
}
84
85
int
type
()
const override
{
return
SiliconTypes::NAND_GATE
; }
86
};
87
88
class
GraphicalNor
:
public
GraphicalGate
{
89
Q_OBJECT
90
public
:
91
explicit
GraphicalNor
(QGraphicsItem* parent =
nullptr
)
92
:
GraphicalGate
(
93
std::make_shared<
NorGate
>(std::vector<
Wire_ptr
>{
nullptr
,
nullptr
},
nullptr
),
94
new
ThemedSvgItem
(
":/gates/NOR_ANSI.svg"
), parent)
95
{
96
}
97
98
int
type
()
const override
{
return
SiliconTypes::NOR_GATE
; }
99
};
100
101
class
GraphicalXor
:
public
GraphicalGate
{
102
Q_OBJECT
103
public
:
104
explicit
GraphicalXor
(QGraphicsItem* parent =
nullptr
)
105
106
:
GraphicalGate
(
107
std::make_shared<
XorGate
>(std::array<
Wire_ptr
, 2>{
nullptr
,
nullptr
},
nullptr
),
108
new
ThemedSvgItem
(
":/gates/XOR_ANSI.svg"
), parent,
true
)
109
{
110
}
111
112
int
type
()
const override
{
return
SiliconTypes::XOR_GATE
; }
113
};
114
115
}
// namespace SILICON::ui
SILICON::core::AndGate
Definition
gates.hpp:80
SILICON::core::NandGate
Definition
gates.hpp:130
SILICON::core::NorGate
Definition
gates.hpp:146
SILICON::core::OrGate
Definition
gates.hpp:96
SILICON::core::XorGate
Definition
gates.hpp:162
SILICON::ui::GraphicalAnd::type
int type() const override
Definition
graphicalGates.hpp:52
SILICON::ui::GraphicalAnd::GraphicalAnd
GraphicalAnd(QGraphicsItem *parent=nullptr)
Definition
graphicalGates.hpp:45
SILICON::ui::GraphicalComponent::scanShape
bool scanShape
Whether to scan shape alpha for port placement.
Definition
graphicalComponent.hpp:256
SILICON::ui::GraphicalGate::type
int type() const override
Definition
graphicalGates.hpp:39
SILICON::ui::GraphicalGate::GraphicalGate
GraphicalGate(const std::shared_ptr< Gate > gate, QGraphicsItem *shape, QGraphicsItem *parent=nullptr, bool scanShape=false)
Definition
graphicalGates.cpp:24
SILICON::ui::GraphicalGate::setComponent
void setComponent(const Component_ptr &component) override
Sets the associated logical component.
Definition
graphicalGates.cpp:32
SILICON::ui::GraphicalGate::updateGatePorts
void updateGatePorts()
Definition
graphicalGates.cpp:38
SILICON::ui::GraphicalGate::updatePortSizes
void updatePortSizes() override
Copies associated component bus sizes into graphical ports.
Definition
graphicalGates.cpp:65
SILICON::ui::GraphicalLogicComponent::GraphicalLogicComponent
GraphicalLogicComponent(ItemCategory category, const Component_ptr &component, QGraphicsItem *shape, QGraphicsItem *parent, bool scanShape=false)
Definition
graphicalLogicComponent.cpp:26
SILICON::ui::GraphicalNand::type
int type() const override
Definition
graphicalGates.hpp:85
SILICON::ui::GraphicalNand::GraphicalNand
GraphicalNand(QGraphicsItem *parent=nullptr)
Definition
graphicalGates.hpp:78
SILICON::ui::GraphicalNor::GraphicalNor
GraphicalNor(QGraphicsItem *parent=nullptr)
Definition
graphicalGates.hpp:91
SILICON::ui::GraphicalNor::type
int type() const override
Definition
graphicalGates.hpp:98
SILICON::ui::GraphicalNot::type
int type() const override
Definition
graphicalGates.hpp:72
SILICON::ui::GraphicalNot::GraphicalNot
GraphicalNot(QGraphicsItem *parent=nullptr)
Definition
graphicalGates.cpp:71
SILICON::ui::GraphicalOr::GraphicalOr
GraphicalOr(QGraphicsItem *parent=nullptr)
Definition
graphicalGates.hpp:58
SILICON::ui::GraphicalOr::type
int type() const override
Definition
graphicalGates.hpp:65
SILICON::ui::GraphicalXor::type
int type() const override
Definition
graphicalGates.hpp:112
SILICON::ui::GraphicalXor::GraphicalXor
GraphicalXor(QGraphicsItem *parent=nullptr)
Definition
graphicalGates.hpp:104
SILICON::ui::ThemedSvgItem
Definition
themedSvgItem.hpp:18
gates.hpp
graphicalLogicComponent.hpp
SILICON::core::Component_ptr
std::shared_ptr< Component > Component_ptr
Definition
component_registry.hpp:33
SILICON::core::Wire_ptr
std::shared_ptr< Wire > Wire_ptr
Definition
wire.hpp:116
SILICON::ui
Definition
actionGroups.hpp:14
SILICON::ui::AND_GATE
@ AND_GATE
Definition
enums.hpp:90
SILICON::ui::NOR_GATE
@ NOR_GATE
Definition
enums.hpp:93
SILICON::ui::UNKNOWN
@ UNKNOWN
Definition
enums.hpp:73
SILICON::ui::NAND_GATE
@ NAND_GATE
Definition
enums.hpp:91
SILICON::ui::XOR_GATE
@ XOR_GATE
Definition
enums.hpp:95
SILICON::ui::NOT_GATE
@ NOT_GATE
Definition
enums.hpp:94
SILICON::ui::OR_GATE
@ OR_GATE
Definition
enums.hpp:92
themedSvgItem.hpp
src
ui
circuit
components
graphicalGates.hpp
Generated by
1.17.0