SILICON
Loading...
Searching...
No Matches
Port Class Reference

Represents a connection point on a component. More...

#include <graphicalComponent.hpp>

Inheritance diagram for Port:
Collaboration diagram for Port:

Public Member Functions

 Port (unsigned int index, QPoint position, QString name, bool printName=false, QGraphicsItem *parent=nullptr)
 Constructs a port.
void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override
 Paints port names, bus markers, and input assignment errors.
QRectF boundingRect () const override
 Gets visual bounds, including port labels and stroked markers.
unsigned int getIndex () const
 Gets the port index.
QPoint getPosition () const
 Gets the port position.
QString getName () const
 Gets the port name.
unsigned int getSize () const
 Gets the port bus size.
PortSide getDirection () const
 Gets the port line direction.
void setSize (unsigned int newSize)
 Sets the port bus size.
void setInputAssignmentError (bool failed)
 Marks whether this port failed input assignment during simulation setup.
void setLine (QGraphicsLineItem *line)
 Sets the connecting line.
QRectF collisionRect () const
 Gets the collision rectangle for wire detection.

Private Member Functions

QLineF connectionLine () const
QTransform labelTransform (const QRectF &rect, bool insideShape) const
void prepareBoundsChange ()

Private Attributes

unsigned int index
 Port index in the port list.
QPoint position
 Position relative to component center.
QGraphicsLineItem * line = nullptr
 Visual line connecting to component.
QString name
 Port name.
unsigned int size = 1
 Number of wires represented by this port.
PortSide side = PortSide::RIGHT
 Direction of the connecting line from port to component.
bool printName = false
 Whether to write the port name on the component.
bool inputAssignmentError = false
 Whether the net associated with this port has an error.

Friends

class GraphicalComponent

Detailed Description

Represents a connection point on a component.

Port is a QGraphicsItem that represents an input or output connection point on a graphical component. It connects to its parent component via a visible line and provides collision detection for wire connections.

Definition at line 55 of file graphicalComponent.hpp.

Constructor & Destructor Documentation

◆ Port()

Port ( unsigned int index,
QPoint position,
QString name,
bool printName = false,
QGraphicsItem * parent = nullptr )

Constructs a port.

Parameters
indexThe port index
positionPosition relative to component
nameThe port/bus name
printNameWhether to print the port name on the component
parentOptional parent graphics item

Definition at line 584 of file graphicalComponent.cpp.

Member Function Documentation

◆ boundingRect()

QRectF boundingRect ( ) const
override

Gets visual bounds, including port labels and stroked markers.

Definition at line 637 of file graphicalComponent.cpp.

◆ collisionRect()

QRectF collisionRect ( ) const
nodiscard

Gets the collision rectangle for wire detection.

Returns
Physical line bounds with clearance around the connection point

Definition at line 796 of file graphicalComponent.cpp.

◆ connectionLine()

QLineF connectionLine ( ) const
nodiscardprivate

Definition at line 594 of file graphicalComponent.cpp.

◆ getDirection()

PortSide getDirection ( ) const
inline

Gets the port line direction.

Definition at line 119 of file graphicalComponent.hpp.

◆ getIndex()

unsigned int getIndex ( ) const
inline

Gets the port index.

Definition at line 107 of file graphicalComponent.hpp.

◆ getName()

QString getName ( ) const
inlinenodiscard

Gets the port name.

Definition at line 113 of file graphicalComponent.hpp.

◆ getPosition()

QPoint getPosition ( ) const
inline

Gets the port position.

Definition at line 110 of file graphicalComponent.hpp.

◆ getSize()

unsigned int getSize ( ) const
inline

Gets the port bus size.

Definition at line 116 of file graphicalComponent.hpp.

◆ labelTransform()

QTransform labelTransform ( const QRectF & rect,
bool insideShape ) const
nodiscardprivate

Definition at line 600 of file graphicalComponent.cpp.

◆ paint()

void paint ( QPainter * painter,
const QStyleOptionGraphicsItem * option,
QWidget * widget )
override

Paints port names, bus markers, and input assignment errors.

Definition at line 715 of file graphicalComponent.cpp.

◆ prepareBoundsChange()

void prepareBoundsChange ( )
private

Definition at line 629 of file graphicalComponent.cpp.

◆ setInputAssignmentError()

void setInputAssignmentError ( bool failed)

Marks whether this port failed input assignment during simulation setup.

Definition at line 704 of file graphicalComponent.cpp.

◆ setLine()

void setLine ( QGraphicsLineItem * line)

Sets the connecting line.

Parameters
lineThe line item

Definition at line 677 of file graphicalComponent.cpp.

◆ setSize()

void setSize ( unsigned int newSize)

Sets the port bus size.

Definition at line 691 of file graphicalComponent.cpp.

◆ GraphicalComponent

friend class GraphicalComponent
friend

Definition at line 56 of file graphicalComponent.hpp.

Member Data Documentation

◆ index

unsigned int index
private

Port index in the port list.

Definition at line 60 of file graphicalComponent.hpp.

◆ inputAssignmentError

bool inputAssignmentError = false
private

Whether the net associated with this port has an error.

Definition at line 81 of file graphicalComponent.hpp.

◆ line

QGraphicsLineItem* line = nullptr
private

Visual line connecting to component.

Definition at line 66 of file graphicalComponent.hpp.

◆ name

QString name
private

Port name.

Definition at line 69 of file graphicalComponent.hpp.

◆ position

QPoint position
private

Position relative to component center.

Definition at line 63 of file graphicalComponent.hpp.

◆ printName

bool printName = false
private

Whether to write the port name on the component.

Definition at line 78 of file graphicalComponent.hpp.

◆ side

PortSide side = PortSide::RIGHT
private

Direction of the connecting line from port to component.

Definition at line 75 of file graphicalComponent.hpp.

◆ size

unsigned int size = 1
private

Number of wires represented by this port.

Definition at line 72 of file graphicalComponent.hpp.


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