|
wiRedPanda
Logic Circuit Simulator
|
Manages interactive wire creation, deletion, validation and hover feedback. More...
#include <ConnectionManager.h>
Public Member Functions | |
| void | cancel () |
| Cancels and deletes the in-progress wire, if any. | |
| void | clearHover () |
| Clears the current hover state (unhighlights the port, resets cursor). | |
| ConnectionManager (Scene *scene) | |
| void | detach (InputPort *endPort) |
| Detaches the existing wire on endPort and starts a new one from the same output. | |
| Connection * | editedConnection () const |
| Returns the in-progress wire, or nullptr. | |
| bool | hasEditedConnection () const |
| Returns true if a wire is currently being drawn. | |
| void | showHoverLabels (Port *port) |
| Shows in-situ label chips for port itself and every port connected to it. | |
| void | startFromInput (InputPort *endPort) |
| Begins a new in-progress wire anchored at endPort (input port). | |
| void | startFromOutput (OutputPort *startPort) |
| Begins a new in-progress wire anchored at startPort (output port). | |
| void | tryComplete (const QPointF &scenePos) |
| Attempts to complete the in-progress wire at the port under scenePos. | |
| void | updateEditedEnd (const QPointF &scenePos) |
| Updates the free end of the in-progress wire to follow scenePos. | |
| void | updateHover (const QPointF &scenePos) |
| Updates the hover state for the port under scenePos. | |
Static Public Member Functions | |
| static QString | connectionRejectionReason (OutputPort *startPort, InputPort *endPort) |
| static bool | isConnectionAllowed (OutputPort *startPort, InputPort *endPort) |
Returns true if a wire from startPort to endPort is permitted. | |
Friends | |
| class | TestConnectionManager |
Manages interactive wire creation, deletion, validation and hover feedback.
Extracted from Scene to decouple connection-editing concerns from the main circuit scene. Owns the in-progress connection state and hover-port tracking; delegates item addition/removal and undo commands back to the owning Scene.
Definition at line 32 of file ConnectionManager.h.
|
explicit |
Definition at line 73 of file ConnectionManager.cpp.
Referenced by TestConnectionManager.
| void ConnectionManager::cancel | ( | ) |
Cancels and deletes the in-progress wire, if any.
Definition at line 147 of file ConnectionManager.cpp.
References editedConnection(), and sentryBreadcrumb().
Referenced by TestConnectionManager.
| void ConnectionManager::clearHover | ( | ) |
Clears the current hover state (unhighlights the port, resets cursor).
Definition at line 242 of file ConnectionManager.cpp.
Referenced by TestConnectionManager.
|
static |
Returns a short, user-facing explanation of why the connection from startPort to endPort is disallowed, or an empty string if it is allowed. Single source of truth for isConnectionAllowed() and the status-bar feedback shown when a wire is rejected.
Definition at line 254 of file ConnectionManager.cpp.
References Port::graphicElement(), Port::isConnected(), and GraphicElement::wirelessMode().
Referenced by isConnectionAllowed(), TestConnectionManager, and tryComplete().
| void ConnectionManager::detach | ( | InputPort * | endPort | ) |
Detaches the existing wire on endPort and starts a new one from the same output.
Lets the user "grab" an existing wire and re-route it to a different input.
Definition at line 155 of file ConnectionManager.cpp.
References Port::connections(), sentryBreadcrumb(), and startFromOutput().
Referenced by TestConnectionManager.
|
nodiscard |
Returns the in-progress wire, or nullptr.
Definition at line 181 of file ConnectionManager.cpp.
Referenced by cancel(), hasEditedConnection(), TestConnectionManager, tryComplete(), updateEditedEnd(), and updateHover().
|
nodiscard |
Returns true if a wire is currently being drawn.
Definition at line 176 of file ConnectionManager.cpp.
References editedConnection().
Referenced by TestConnectionManager.
|
static |
Returns true if a wire from startPort to endPort is permitted.
A connection is rejected when:
Definition at line 249 of file ConnectionManager.cpp.
References connectionRejectionReason().
Referenced by Scene::isConnectionAllowed(), and TestConnectionManager.
| void ConnectionManager::showHoverLabels | ( | Port * | port | ) |
Shows in-situ label chips for port itself and every port connected to it.
Called from Scene::helpEvent in place of the native tooltip, so the chips appear and disappear at the same wake-up delay a tooltip would. Replaces any chips already shown.
Definition at line 335 of file ConnectionManager.cpp.
Referenced by TestConnectionManager.
| void ConnectionManager::startFromInput | ( | InputPort * | endPort | ) |
Begins a new in-progress wire anchored at endPort (input port).
Definition at line 92 of file ConnectionManager.cpp.
Referenced by TestConnectionManager.
| void ConnectionManager::startFromOutput | ( | OutputPort * | startPort | ) |
Begins a new in-progress wire anchored at startPort (output port).
Definition at line 80 of file ConnectionManager.cpp.
References sentryBreadcrumb().
Referenced by detach(), and TestConnectionManager.
| void ConnectionManager::tryComplete | ( | const QPointF & | scenePos | ) |
Attempts to complete the in-progress wire at the port under scenePos.
If the port is compatible the wire is committed via an AddItemsCommand; otherwise the in-progress wire is deleted.
Definition at line 103 of file ConnectionManager.cpp.
References connectionRejectionReason(), editedConnection(), and sentryBreadcrumb().
Referenced by TestConnectionManager.
| void ConnectionManager::updateEditedEnd | ( | const QPointF & | scenePos | ) |
Updates the free end of the in-progress wire to follow scenePos.
Definition at line 186 of file ConnectionManager.cpp.
References editedConnection().
Referenced by TestConnectionManager.
| void ConnectionManager::updateHover | ( | const QPointF & | scenePos | ) |
Updates the hover state for the port under scenePos.
Definition at line 213 of file ConnectionManager.cpp.
References editedConnection(), and Port::isOutput().
Referenced by TestConnectionManager.
|
friend |
Definition at line 35 of file ConnectionManager.h.
References cancel(), clearHover(), ConnectionManager(), connectionRejectionReason(), detach(), editedConnection(), hasEditedConnection(), isConnectionAllowed(), showHoverLabels(), startFromInput(), startFromOutput(), TestConnectionManager, tryComplete(), updateEditedEnd(), and updateHover().
Referenced by TestConnectionManager.