20#include <QGraphicsItem>
37using namespace SILICON::core;
74 QGraphicsItem* parent =
nullptr,
bool scanShape =
false);
102 static inline const QFont
UI_FONT{
"NovaMono", 12};
184 void paint(QPainter* painter,
const QStyleOptionGraphicsItem* option,
185 QWidget* widget)
override;
192 static const QString path =
":/other_components/input_on.svg";
198 static const QString path =
":/other_components/input_off.svg";
246 void paint(QPainter* painter,
const QStyleOptionGraphicsItem* option,
247 QWidget* widget)
override;
284 void paint(QPainter* painter,
const QStyleOptionGraphicsItem* option,
285 QWidget* widget)
override;
290 static const QString path =
":/other_components/output_unknown.svg";
295 static const QString path =
":/other_components/output_on.svg";
300 static const QString path =
":/other_components/output_off.svg";
339 void paint(QPainter* painter,
const QStyleOptionGraphicsItem* option,
340 QWidget* widget)
override;
int type() const override
void setBusState(const Bus &bus)
Updates the display shape based on the state of the incoming bus. Handles edge cases like Error/Unkno...
void applyStartValue() override
Applies the default starting value configured in the component's properties.
void setComponent(const Component_ptr &component) override
Sets the associated logical component.
void resetSimulationState() override
Resets the visual state to its initial simulation state.
void installPropertyCallbacks()
static constexpr std::string_view COMPONENT_TYPE
QRectF boundingRect() const override
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override
void refreshFromComponent()
std::string getTypeName() const override
Gets the component type name for serialization.
GraphicalBusOutput(QGraphicsItem *parent=nullptr)
void prepareSceneBoundsChange()
Prepares a geometry edit and checks its final bounds on the event loop.
bool scanShape
Whether to scan shape alpha for port placement.
int type() const override
void setComponent(const Component_ptr &component) override
Sets the associated logical component.
GraphicalConstant(QGraphicsItem *parent=nullptr)
QRectF componentNameRect(const QString &name) const
Returns the label rectangle for the current orientation.
bool isPortOrientationUp() const
Returns true when the IO port is currently placed above the shape.
virtual void handleSimulationClick()
Called when the user clicks on the component during a live simulation.
virtual void resetSimulationState()=0
Resets the visual state to its initial simulation state.
void updatePortOrientation()
Rebuilds the single IO port based on the current orientation property.
virtual void applyStartValue()=0
Applies the default starting value configured in the component's properties.
void setComponent(const Component_ptr &component) override
Sets the associated logical component.
static const QFont UI_FONT
Shared, highly-optimized UI font for all IO components. Using an inline static font prevents allocati...
void inputToggled(Bus targetBus, BusValue value, Component_weakPtr source)
Emitted when an input component changes its state.
QString getComponentName() const
Safely retrieves the user-defined name of this component.
GraphicalIO(ItemCategory category, const Component_ptr &component, QGraphicsItem *shape, QGraphicsItem *parent=nullptr, bool scanShape=false)
Constructs a GraphicalIO item.
QRectF collisionRectForPortSide(PortSide side) const
Returns local wire-obstacle bounds for a proposed port side.
void setPortOrientation(PortSide side)
Persists and applies a cardinal port orientation.
QPoint portPositionFor(PortSide side) const
Returns the local port position for a proposed cardinal side.
void installPortOrientationCallback()
Installs the callback that moves the IO port when orientation changes.
GraphicalLogicComponent(ItemCategory category, const Component_ptr &component, QGraphicsItem *shape, QGraphicsItem *parent, bool scanShape=false)
GraphicalOutputSingle(QGraphicsItem *parent=nullptr)
int type() const override
void setState(State state)
Updates the visual representation based on the wire state.
void applyStartValue() override
Applies the default starting value configured in the component's properties.
static const QString & getOnShapePath()
void resetSimulationState() override
Resets the visual state to its initial simulation state.
static constexpr std::string_view COMPONENT_TYPE
QRectF boundingRect() const override
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override
std::string getTypeName() const override
Gets the component type name for serialization.
static const QString & getOffShapePath()
static const QString & getUnknownShapePath()
std::shared_ptr< Component > Component_ptr
std::weak_ptr< Component > Component_weakPtr
std::vector< State > BusValue