17#include <QGraphicsPathItem>
40 enum {
Type = QGraphicsItem::UserType + 2 };
44 explicit Connection(QGraphicsItem *parent =
nullptr);
88 QPainterPath
shape()
const override;
100 void paint(QPainter *painter,
const QStyleOptionGraphicsItem *option, QWidget *widget)
override;
110 void save(QDataStream &stream)
const;
116 QVariant
itemChange(GraphicsItemChange change,
const QVariant &value)
override;
124 void changePortAttachment(
Port *oldPort,
Port *newPort);
127 void applyStatusPen();
131 QColor m_activeColor;
132 QColor m_inactiveColor;
133 QColor m_unknownColor;
135 QColor m_selectedColor;
146 Status m_status = Status::Unknown;
147 bool m_highLight =
false;
155 mutable QPainterPath m_cachedShape;
156 mutable bool m_shapeDirty =
true;
Central enumeration types for element types, groups, and signal status.
Defines ItemWithId, the base class for all uniquely identified circuit items.
A bezier-curve wire connecting an output port to an input port in the scene.
Connection(QGraphicsItem *parent=nullptr)
Constructs an unconnected wire.
QPen statusPen() const
Returns the pen paint() draws the wire with for its current status.
OutputPort * startPort() const
Returns the output port this connection originates from.
void updateTheme()
Refreshes wire colours from the current ThemeManager palette.
void setHighLight(const bool highLight)
Enables or disables connection highlighting.
Status status() const
Returns the current four-state signal status (Active/Inactive/Unknown/Error).
void setEndPos(const QPointF point)
Sets the visual end position to point (used when dragging).
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override
void updatePath()
Recomputes the bezier control points from the current start/end positions.
InputPort * endPort() const
Returns the input port this connection leads to.
QRectF boundingRect() const override
bool highLight()
Returns true if this connection is highlighted.
void setStatus(const Status status)
Sets the connection status and triggers a visual refresh.
double angle()
Returns the current angle of the bezier midpoint in radians.
void save(QDataStream &stream) const
Serializes the connection endpoints to stream.
int type() const override
QPainterPath shape() const override
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override
void updatePosFromPorts()
Moves the wire endpoints to match the current port positions.
void load(QDataStream &stream, SerializationContext &context)
Deserializes the connection from stream, resolving ports via context.
void setEndPort(InputPort *port)
Sets the input port this connection leads to.
Port * otherPort(const Port *port) const
Returns the port at the other end of this connection from port.
void setStartPort(OutputPort *port)
Sets the output port this connection originates from.
bool sceneEvent(QEvent *event) override
void setStartPos(const QPointF point)
Sets the visual start position to point (used when dragging).
ItemWithId()=default
Constructs a new ItemWithId with an unassigned ID of -1.
A port that drives a signal (the source end of a wire).
Abstract base class for circuit element ports (connection endpoints).
Bundles all per-deserialization state so that load() overrides receive it through one explicit parame...