|
wiRedPanda
Logic Circuit Simulator
|
Owns the input and output Port vectors of a GraphicElement and the primitives that create, resize and trim them. More...
#include <ElementPorts.h>
Public Member Functions | |
| void | addInputPort (const QString &name={}) |
| Appends a new input port with optional name. | |
| void | addOutputPort (const QString &name={}) |
| Appends a new output port with optional name. | |
| void | addPort (const QString &name, bool isOutput) |
| Appends a new port (parented to the owner) with name; isOutput selects direction. | |
| QVector< Port * > | allPorts () const |
| Returns a combined list of all input and output ports as Port pointers. | |
| ElementPorts (GraphicElement *owner) | |
| Constructs the port store bound to its owning owner element. | |
| InputPort * | inputPort (int index) const |
| Returns the input port at index, or nullptr if out of range. | |
| const QVector< InputPort * > & | inputs () const |
| Returns the input port vector. | |
| int | inputSize () const |
| Returns the current number of input ports. | |
| OutputPort * | outputPort (int index) const |
| Returns the output port at index, or nullptr if out of range. | |
| const QVector< OutputPort * > & | outputs () const |
| Returns the output port vector. | |
| int | outputSize () const |
| Returns the current number of output ports. | |
| void | resizeInputs (int size) |
| void | resizeOutputs (int size) |
| Grows or shrinks the output list to exactly size. | |
| void | setInputs (const QVector< InputPort * > &inputs) |
| InputPort * | takeLastInput () |
| OutputPort * | takeLastOutput () |
| Removes and returns the last output port WITHOUT deleting it. Returns nullptr if empty. | |
Owns the input and output Port vectors of a GraphicElement and the primitives that create, resize and trim them.
Extracted from GraphicElement, mirroring the ElementAppearance / ElementSimState / ElementOrientation collaborators. Storage and port creation live here; the owning element keeps the polymorphic geometry layout (updatePortsProperties() is virtual and orientation- coupled) and the min/max size policy, driving this type's resize primitives through it. New ports are parented to the owner element so Qt's scene graph cleans them up with it.
Definition at line 29 of file ElementPorts.h.
|
inlineexplicit |
Constructs the port store bound to its owning owner element.
Definition at line 33 of file ElementPorts.h.
|
inline |
Appends a new input port with optional name.
Definition at line 72 of file ElementPorts.h.
Referenced by resizeInputs().
|
inline |
Appends a new output port with optional name.
Definition at line 75 of file ElementPorts.h.
Referenced by resizeOutputs().
| void ElementPorts::addPort | ( | const QString & | name, |
| bool | isOutput ) |
Appends a new port (parented to the owner) with name; isOutput selects direction.
Definition at line 52 of file ElementPorts.cpp.
References inputSize(), outputSize(), qCDebug, Port::setGraphicElement(), Port::setIndex(), and Port::setName().
| QVector< Port * > ElementPorts::allPorts | ( | ) | const |
Returns a combined list of all input and output ports as Port pointers.
Definition at line 26 of file ElementPorts.cpp.
| InputPort * ElementPorts::inputPort | ( | int | index | ) | const |
Returns the input port at index, or nullptr if out of range.
Definition at line 10 of file ElementPorts.cpp.
|
inline |
Returns the input port vector.
Definition at line 41 of file ElementPorts.h.
Referenced by GraphicElementSerializer::save(), and setInputs().
|
inline |
Returns the current number of input ports.
Definition at line 53 of file ElementPorts.h.
Referenced by addPort(), and resizeInputs().
| OutputPort * ElementPorts::outputPort | ( | int | index | ) | const |
Returns the output port at index, or nullptr if out of range.
Definition at line 18 of file ElementPorts.cpp.
|
inline |
Returns the output port vector.
Definition at line 44 of file ElementPorts.h.
Referenced by GraphicElementSerializer::save().
|
inline |
Returns the current number of output ports.
Definition at line 56 of file ElementPorts.h.
Referenced by addPort(), and resizeOutputs().
| void ElementPorts::resizeInputs | ( | int | size | ) |
Grows (with default-named ports) or shrinks (deleting the trailing ports) the input list to exactly size. The caller re-lays-out the ports afterwards.
Definition at line 75 of file ElementPorts.cpp.
References addInputPort(), and inputSize().
| void ElementPorts::resizeOutputs | ( | int | size | ) |
Grows or shrinks the output list to exactly size.
Definition at line 85 of file ElementPorts.cpp.
References addOutputPort(), and outputSize().
| void ElementPorts::setInputs | ( | const QVector< InputPort * > & | inputs | ) |
Replaces the input port vector with inputs, re-indexing each port to its new vector position (index() must track vector position — see the historical Display7 legacy pin remap, which permutes the vector and relies on this to keep save()/load() consistent).
Definition at line 35 of file ElementPorts.cpp.
References inputs().
| InputPort * ElementPorts::takeLastInput | ( | ) |
Removes and returns the last input port WITHOUT deleting it (the serializer deletes it after cleaning the deserialization port map). Returns nullptr if empty.
Definition at line 95 of file ElementPorts.cpp.
| OutputPort * ElementPorts::takeLastOutput | ( | ) |
Removes and returns the last output port WITHOUT deleting it. Returns nullptr if empty.
Definition at line 105 of file ElementPorts.cpp.