SILICON
Toggle main menu visibility
Loading...
Searching...
No Matches
graphicalSubcircuit.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 <string>
21
22
#include <QGraphicsItem>
23
24
#include <
core/subcircuit.hpp
>
25
#include <
ui/circuit/components/graphicalLogicComponent.hpp
>
26
#include <
ui/circuit/components/subcircuit/metadata.hpp
>
27
28
namespace
SILICON::project
{
29
class
DocumentStore
;
30
}
31
32
namespace
SILICON::ui
{
33
using namespace
SILICON::core;
34
41
class
GraphicalSubcircuitComponent
:
public
GraphicalLogicComponent
{
42
Q_OBJECT
43
public
:
45
explicit
GraphicalSubcircuitComponent
(
46
QGraphicsItem* parent =
nullptr
,
47
const
SILICON::project::DocumentStore
*
documents
=
nullptr
,
48
const
CircuitResolver
* resolver =
nullptr
);
49
57
explicit
GraphicalSubcircuitComponent
(
58
std::string slug, QGraphicsItem* parent =
nullptr
,
59
const
SILICON::project::DocumentStore
*
documents
=
nullptr
,
60
const
CircuitResolver
* resolver =
nullptr
);
61
63
~GraphicalSubcircuitComponent
()
override
;
64
66
void
setComponent
(
const
Component_ptr
& component)
override
;
67
70
void
applyProperty
(std::string_view key,
const
PropertyValue
& value)
override
;
71
73
void
refreshFromMetadata
();
75
void
setProjectContext
(
const
SILICON::project::DocumentStore
*
documents
,
76
const
CircuitResolver
* resolver);
77
79
void
useAttachedInterfaceMetadata
();
80
81
int
type
()
const override
{
return
SiliconTypes::SUBCIRCUIT
; }
82
83
protected
:
84
void
mouseDoubleClickEvent
(QGraphicsSceneMouseEvent* event)
override
;
85
86
private
:
87
std::uint64_t
registryListenerId
= 0;
88
const
SILICON::project::DocumentStore
*
documents
=
nullptr
;
89
bool
refreshSuppressed
=
false
;
90
91
void
subscribeToDocuments
();
92
void
unsubscribeFromDocuments
();
93
95
[[nodiscard]] std::string
currentSlug
()
const
;
96
98
void
applyMetadata
(
const
GraphicalSubcircuitMetadata
& metadata);
99
101
void
updatePortSizes
()
override
;
102
};
103
104
}
// namespace SILICON::ui
SILICON::core::CircuitResolver
Definition
circuitDocument.hpp:52
SILICON::project::DocumentStore
Definition
projectDocument.hpp:137
SILICON::ui::GraphicalLogicComponent::GraphicalLogicComponent
GraphicalLogicComponent(ItemCategory category, const Component_ptr &component, QGraphicsItem *shape, QGraphicsItem *parent, bool scanShape=false)
Definition
graphicalLogicComponent.cpp:26
SILICON::ui::GraphicalSubcircuitComponent::setProjectContext
void setProjectContext(const SILICON::project::DocumentStore *documents, const CircuitResolver *resolver)
Attaches project metadata and resolver in one refresh.
Definition
graphicalSubcircuit.cpp:117
SILICON::ui::GraphicalSubcircuitComponent::~GraphicalSubcircuitComponent
~GraphicalSubcircuitComponent() override
Unregisters the subcircuit registry listener.
Definition
graphicalSubcircuit.cpp:103
SILICON::ui::GraphicalSubcircuitComponent::documents
const SILICON::project::DocumentStore * documents
Definition
graphicalSubcircuit.hpp:88
SILICON::ui::GraphicalSubcircuitComponent::refreshSuppressed
bool refreshSuppressed
Definition
graphicalSubcircuit.hpp:89
SILICON::ui::GraphicalSubcircuitComponent::applyProperty
void applyProperty(std::string_view key, const PropertyValue &value) override
Applies a component property and refreshes metadata when the slug changes.
Definition
graphicalSubcircuit.cpp:135
SILICON::ui::GraphicalSubcircuitComponent::useAttachedInterfaceMetadata
void useAttachedInterfaceMetadata()
Uses default metadata derived only from the attached imported buses.
Definition
graphicalSubcircuit.cpp:239
SILICON::ui::GraphicalSubcircuitComponent::applyMetadata
void applyMetadata(const GraphicalSubcircuitMetadata &metadata)
Applies parsed metadata to the rendered shape and ports.
Definition
graphicalSubcircuit.cpp:168
SILICON::ui::GraphicalSubcircuitComponent::type
int type() const override
Definition
graphicalSubcircuit.hpp:81
SILICON::ui::GraphicalSubcircuitComponent::unsubscribeFromDocuments
void unsubscribeFromDocuments()
Definition
graphicalSubcircuit.cpp:87
SILICON::ui::GraphicalSubcircuitComponent::registryListenerId
std::uint64_t registryListenerId
Definition
graphicalSubcircuit.hpp:87
SILICON::ui::GraphicalSubcircuitComponent::setComponent
void setComponent(const Component_ptr &component) override
Replaces the associated core subcircuit component.
Definition
graphicalSubcircuit.cpp:108
SILICON::ui::GraphicalSubcircuitComponent::refreshFromMetadata
void refreshFromMetadata()
Reloads shape and ports from the active registry document.
Definition
graphicalSubcircuit.cpp:198
SILICON::ui::GraphicalSubcircuitComponent::mouseDoubleClickEvent
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override
Definition
graphicalSubcircuit.cpp:155
SILICON::ui::GraphicalSubcircuitComponent::subscribeToDocuments
void subscribeToDocuments()
Definition
graphicalSubcircuit.cpp:62
SILICON::ui::GraphicalSubcircuitComponent::updatePortSizes
void updatePortSizes() override
Rebuilds visible ports when subcircuit I/O shape changes.
Definition
graphicalSubcircuit.cpp:181
SILICON::ui::GraphicalSubcircuitComponent::GraphicalSubcircuitComponent
GraphicalSubcircuitComponent(QGraphicsItem *parent=nullptr, const SILICON::project::DocumentStore *documents=nullptr, const CircuitResolver *resolver=nullptr)
Creates a graphical subcircuit with an empty slug.
Definition
graphicalSubcircuit.cpp:47
SILICON::ui::GraphicalSubcircuitComponent::currentSlug
std::string currentSlug() const
Returns the slug stored by the associated core component.
Definition
graphicalSubcircuit.cpp:146
graphicalLogicComponent.hpp
metadata.hpp
SILICON::core::Component_ptr
std::shared_ptr< Component > Component_ptr
Definition
component_registry.hpp:33
SILICON::core::PropertyValue
std::variant< int, bool, std::string, BusValue > PropertyValue
Variant type for component properties.
Definition
component.hpp:142
SILICON::project
Definition
circuitDependencyGraph.cpp:30
SILICON::ui
Definition
actionGroups.hpp:14
SILICON::ui::SUBCIRCUIT
@ SUBCIRCUIT
Definition
enums.hpp:110
SILICON::ui::GraphicalSubcircuitMetadata
Visual metadata used to render a subcircuit as a reusable component.
Definition
metadata.hpp:74
subcircuit.hpp
src
ui
circuit
components
subcircuit
graphicalSubcircuit.hpp
Generated by
1.17.0