wiRedPanda
Logic Circuit Simulator
Loading...
Searching...
No Matches
OutputPort Class Reference

A port that drives a signal (the source end of a wire). More...

#include <Port.h>

Inheritance diagram for OutputPort:
[legend]

Public Member Functions

bool isInput () const override
bool isOutput () const override
bool isValid () const override
 OutputPort (QGraphicsItem *parent=nullptr)
 Constructs an output port attached to parent.
void setStatus (const Status status) override
 ~OutputPort () override
Public Member Functions inherited from Port
void attachConnection (Connection *conn)
 Registers conn as a connection attached to this port.
QRectF boundingRect () const override
const QList< Connection * > & connections () const
 Returns the list of wires attached to this port.
QPen currentPen () const
 Returns the pen paint() draws the port outline with for its current status.
Status defaultValue () const
 Returns the default status applied when the port is unconnected.
void detachConnection (Connection *conn)
 Removes conn from this port's connection list.
int globalIndex () const
GraphicElementgraphicElement ()
 Returns the graphic element that owns this port.
const GraphicElementgraphicElement () const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void hoverEnter ()
 Applies hover-enter visual feedback.
void hoverLeave ()
 Reverts hover-enter visual feedback.
int index () const
 Returns the port's visual/logical index within the element.
bool isConnected (Port *otherPort)
 Returns true if this port is connected to otherPort via any wire.
bool isRequired () const
 Returns true if a connection to this port is mandatory.
QString name () const
 Returns the port's label text.
void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override
 Port (QGraphicsItem *parent=nullptr)
 Constructs the port with optional parent item.
void setCurrentBrush (const QBrush &currentBrush)
 Sets the brush used to fill the port shape.
void setDefaultStatus (const Status defaultStatus)
 Sets the status applied when the port has no connection.
void setGraphicElement (GraphicElement *graphicElement)
 Binds this port to graphicElement.
void setIndex (const int index)
 Sets the port's visual index within the element.
void setName (const QString &name)
 Sets the label text shown next to the port.
void setRequired (const bool required)
 Marks whether a wire to this port is mandatory.
QPainterPath shape () const override
Status status () const
 Returns the current logical status (Active/Inactive/Unknown/Error).
int type () const override
void updateConnections ()
 Triggers a path update on all attached connections.
void updateTheme ()
 Reapplies the status-based pen and brush from the current ThemeManager palette.
virtual ~Port ()=default

Additional Inherited Members

Public Types inherited from Port
enum  { Type = QGraphicsItem::UserType + 1 }
Static Public Member Functions inherited from Port
static quint64 makeSerialId (quint64 elementBase, int globalIndex)
Protected Member Functions inherited from Port
void drainConnections (bool isInput)
 Drains all attached connections, breaking back-references before deletion.
QVariant itemChange (GraphicsItemChange change, const QVariant &value) override
Protected Attributes inherited from Port
QList< Connection * > m_connections
QBrush m_currentBrush
QPen m_currentPen
Status m_defaultStatus = Status::Unknown
GraphicElementm_graphicElement = nullptr
int m_index = 0
QString m_name
bool m_required = true
Status m_status = Status::Unknown
Static Protected Attributes inherited from Port
static constexpr int kRadius = 5

Detailed Description

A port that drives a signal (the source end of a wire).

Output ports can fan out to multiple input ports. They are always considered valid regardless of connection count.

Definition at line 260 of file Port.h.

Constructor & Destructor Documentation

◆ OutputPort()

OutputPort::OutputPort ( QGraphicsItem * parent = nullptr)
explicit

Constructs an output port attached to parent.

Definition at line 338 of file Port.cpp.

References Port::kRadius, Port::Port(), and Port::updateTheme().

◆ ~OutputPort()

OutputPort::~OutputPort ( )
override

Definition at line 354 of file Port.cpp.

References Port::drainConnections().

Member Function Documentation

◆ isInput()

bool OutputPort::isInput ( ) const
overridevirtual
Reimplemented from base class.

Implements Port.

Definition at line 377 of file Port.cpp.

◆ isOutput()

bool OutputPort::isOutput ( ) const
overridevirtual
Reimplemented from base class.

Implements Port.

Definition at line 382 of file Port.cpp.

◆ isValid()

bool OutputPort::isValid ( ) const
overridevirtual
Reimplemented from base class.

Implements Port.

Definition at line 387 of file Port.cpp.

◆ setStatus()

void OutputPort::setStatus ( const Status status)
overridevirtual
Reimplemented from base class.

Implements Port.

Definition at line 361 of file Port.cpp.

References Port::connections(), Port::m_status, Port::status(), and Port::updateTheme().

Referenced by InputRotary::setOn().


The documentation for this class was generated from the following files: