25#include <QGraphicsItem>
38using namespace SILICON::core;
74 [[nodiscard]]
virtual bool
78 [[nodiscard]]
virtual unsigned int
79 inputPortSize(
size_t portIndex,
const std::vector<Bus>& componentInputs)
const;
83 QGraphicsItem* shape, QGraphicsItem* parent,
96 QGraphicsItem* parent,
bool scanShape =
false);
106 void setPorts(
const std::vector<PortPair>& busToPortInputs,
107 const std::vector<PortPair>& busToPortOutputs)
override;
130 [[nodiscard]] std::optional<std::reference_wrapper<const StringPropertyOptions>>
GraphicalComponent(ItemCategory category, QGraphicsItem *shape, QGraphicsItem *parent=nullptr, bool scanShape=false)
bool scanShape
Whether to scan shape alpha for port placement.
~GraphicalLogicComponent() override
Component_ptr getComponent() const
Gets the associated logical component.
virtual void updatePortSizes()
Copies associated component bus sizes into graphical ports.
void setPorts(const std::vector< PortPair > &busToPortInputs, const std::vector< PortPair > &busToPortOutputs) override
Sets ports and validates against component I/O.
void applyProperty(std::string_view key, const PropertyValue &value) override
Applies a component property while notifying Qt about possible geometry changes.
std::optional< std::reference_wrapper< const StringPropertyOptions > > getStringPropertyOptions(std::string_view key) const override
bool isEditable
Whether the component allows property editing.
virtual unsigned int inputPortSize(size_t portIndex, const std::vector< Bus > &componentInputs) const
Returns the visible size for an input port.
GraphicalLogicComponent(ItemCategory category, const Component_ptr &component, QGraphicsItem *shape, QGraphicsItem *parent, bool scanShape=false)
virtual void assignInputPortBus(unsigned int portIndex, const Bus &bus) const
Assigns a bus connected to a visible input port.
virtual void setComponent(const Component_ptr &component)
Sets the associated logical component.
virtual bool acceptsInputPortCount(size_t portCount, const std::vector< Bus > &componentInputs) const
Checks whether a visible input port count is valid for this component.
uint64_t componentIOListenerId
Listener id for associated component I/O changes.
std::string getTypeName() const override
Gets the component type name for serialization.
void refreshComponentIOListener()
Installs the listener that keeps graphical ports synced to bus sizes.
const PropertyMap & getProperties() const override
Properties exposed by graphical and simulation components alike.
Component_ptr associatedComponent
The logical component this graphical component represents.
std::shared_ptr< Component > Component_ptr
std::variant< int, bool, std::string, BusValue > PropertyValue
Variant type for component properties.
std::unordered_map< std::string, PropertyValue, TransparentStringHash, TransparentStringEqual > PropertyMap
Map from property names to their values.