|
wiRedPanda
Logic Circuit Simulator
|
A bezier-curve wire connecting an output port to an input port in the scene. More...
#include <Connection.h>
Public Types | |
| enum | { Type = QGraphicsItem::UserType + 2 } |
Public Member Functions | |
| double | angle () |
| Returns the current angle of the bezier midpoint in radians. | |
| QRectF | boundingRect () const override |
| Connection (QGraphicsItem *parent=nullptr) | |
| Constructs an unconnected wire. | |
| InputPort * | endPort () const |
| Returns the input port this connection leads to. | |
| bool | highLight () |
Returns true if this connection is highlighted. | |
| void | load (QDataStream &stream, SerializationContext &context) |
| Deserializes the connection from stream, resolving ports via context. | |
| Port * | otherPort (const Port *port) const |
| Returns the port at the other end of this connection from port. | |
| void | paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override |
| void | save (QDataStream &stream) const |
| Serializes the connection endpoints to stream. | |
| void | setEndPort (InputPort *port) |
| Sets the input port this connection leads to. | |
| void | setEndPos (const QPointF point) |
| Sets the visual end position to point (used when dragging). | |
| void | setHighLight (const bool highLight) |
| Enables or disables connection highlighting. | |
| void | setStartPort (OutputPort *port) |
| Sets the output port this connection originates from. | |
| void | setStartPos (const QPointF point) |
| Sets the visual start position to point (used when dragging). | |
| void | setStatus (const Status status) |
| Sets the connection status and triggers a visual refresh. | |
| QPainterPath | shape () const override |
| OutputPort * | startPort () const |
| Returns the output port this connection originates from. | |
| Status | status () const |
| Returns the current four-state signal status (Active/Inactive/Unknown/Error). | |
| QPen | statusPen () const |
| Returns the pen paint() draws the wire with for its current status. | |
| int | type () const override |
| void | updatePath () |
| Recomputes the bezier control points from the current start/end positions. | |
| void | updatePosFromPorts () |
| Moves the wire endpoints to match the current port positions. | |
| void | updateTheme () |
| Refreshes wire colours from the current ThemeManager palette. | |
| ~Connection () override | |
| Public Member Functions inherited from ItemWithId | |
| int | id () const |
| Returns the unique integer identifier of this item, or -1 if unassigned. | |
| ItemWithId ()=default | |
| Constructs a new ItemWithId with an unassigned ID of -1. | |
| void | setId (const int id) |
| Sets the identifier to id. | |
| virtual | ~ItemWithId () |
| Self-unregisters from the current SceneItemRegistry, if any. | |
Protected Member Functions | |
| QVariant | itemChange (GraphicsItemChange change, const QVariant &value) override |
| bool | sceneEvent (QEvent *event) override |
A bezier-curve wire connecting an output port to an input port in the scene.
Connection draws a smooth path between its start (output) and end (input) ports. It is coloured according to its logical status (active/inactive/unknown/selected) and can be highlighted when the cursor hovers over it. Connections are serializable and participate in the undo/redo system.
Definition at line 37 of file Connection.h.
| anonymous enum |
| Enumerator | |
|---|---|
| Type | |
Definition at line 40 of file Connection.h.
|
explicit |
Constructs an unconnected wire.
Definition at line 22 of file Connection.cpp.
References updateTheme().
|
override |
Definition at line 38 of file Connection.cpp.
| double Connection::angle | ( | ) |
Returns the current angle of the bezier midpoint in radians.
Definition at line 156 of file Connection.cpp.
References Port::isOutput().
Referenced by SplitCommand::SplitCommand().
|
override |
Definition at line 322 of file Connection.cpp.
| InputPort * Connection::endPort | ( | ) | const |
Returns the input port this connection leads to.
Definition at line 151 of file Connection.cpp.
Referenced by Port::detachConnection(), itemChange(), ConnectionSerializer::save(), setStatus(), and SplitCommand::SplitCommand().
| bool Connection::highLight | ( | ) |
Returns true if this connection is highlighted.
Definition at line 311 of file Connection.cpp.
Referenced by setHighLight().
|
overrideprotected |
Definition at line 294 of file Connection.cpp.
References endPort(), Port::hoverEnter(), Port::hoverLeave(), and startPort().
| void Connection::load | ( | QDataStream & | stream, |
| SerializationContext & | context ) |
Deserializes the connection from stream, resolving ports via context.
Definition at line 180 of file Connection.cpp.
References ConnectionSerializer::load().
Returns the port at the other end of this connection from port.
Definition at line 185 of file Connection.cpp.
|
override |
Definition at line 265 of file Connection.cpp.
| void Connection::save | ( | QDataStream & | stream | ) | const |
Serializes the connection endpoints to stream.
Definition at line 175 of file Connection.cpp.
References ConnectionSerializer::save().
|
overrideprotected |
Definition at line 358 of file Connection.cpp.
| void Connection::setEndPort | ( | InputPort * | port | ) |
Sets the input port this connection leads to.
Definition at line 83 of file Connection.cpp.
References setEndPos(), InputPort::setStatus(), and status().
Referenced by Port::detachConnection(), and ConnectionSerializer::load().
| void Connection::setEndPos | ( | const QPointF | point | ) |
Sets the visual end position to point (used when dragging).
Definition at line 54 of file Connection.cpp.
Referenced by setEndPort().
| void Connection::setHighLight | ( | const bool | highLight | ) |
Enables or disables connection highlighting.
Definition at line 316 of file Connection.cpp.
References highLight().
| void Connection::setStartPort | ( | OutputPort * | port | ) |
Sets the output port this connection originates from.
Definition at line 71 of file Connection.cpp.
References setStartPos(), setStatus(), and Port::status().
Referenced by Port::detachConnection(), and ConnectionSerializer::load().
| void Connection::setStartPos | ( | const QPointF | point | ) |
Sets the visual start position to point (used when dragging).
Definition at line 49 of file Connection.cpp.
Referenced by setStartPort().
| void Connection::setStatus | ( | const Status | status | ) |
Sets the connection status and triggers a visual refresh.
Definition at line 199 of file Connection.cpp.
References endPort(), InputPort::setStatus(), and status().
Referenced by setStartPort().
|
override |
Definition at line 329 of file Connection.cpp.
| OutputPort * Connection::startPort | ( | ) | const |
Returns the output port this connection originates from.
Definition at line 146 of file Connection.cpp.
Referenced by Port::detachConnection(), itemChange(), ConnectionSerializer::save(), and SplitCommand::SplitCommand().
| Status Connection::status | ( | ) | const |
Returns the current four-state signal status (Active/Inactive/Unknown/Error).
Definition at line 194 of file Connection.cpp.
Referenced by setEndPort(), and setStatus().
|
inline |
Returns the pen paint() draws the wire with for its current status.
Definition at line 78 of file Connection.h.
|
inlineoverride |
Definition at line 41 of file Connection.h.
References Type.
| void Connection::updatePath | ( | ) |
Recomputes the bezier control points from the current start/end positions.
Definition at line 116 of file Connection.cpp.
References Application::renderingEnabled.
Referenced by updatePosFromPorts().
| void Connection::updatePosFromPorts | ( | ) |
Moves the wire endpoints to match the current port positions.
Definition at line 96 of file Connection.cpp.
References updatePath().
Referenced by ConnectionSerializer::load().
| void Connection::updateTheme | ( | ) |
Refreshes wire colours from the current ThemeManager palette.
Definition at line 249 of file Connection.cpp.
References ThemeManager::attributes().
Referenced by Connection().