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

Logical wire entity that groups segments sharing the same bus. More...

#include <graphicalWire.hpp>

Collaboration diagram for GraphicalWire:

Public Member Functions

 GraphicalWire ()
 Creates a wire with a unique route identifier.
 ~GraphicalWire ()=default
 GraphicalWire (unsigned int busSize)
 Constructs a wire with a specified bus size.
uint64_t getRouteId () const
 Returns the persistent identifier of this logical wire group.
void restoreRouteId (uint64_t id)
 Restores a saved identifier and advances the identifier allocator.
void setConnectionError (std::optional< QString > reason)
 Updates the connection error and refreshes segment tooltips and painting.
std::optional< QString > getConnectionError () const
 Returns the connection error, or no value when the net has no error.
void addSegment (GraphicalWireSegment *segment)
 Adds a segment to this wire.
void removeSegment (GraphicalWireSegment *segment)
 Removes a segment from this wire.
const std::unordered_set< GraphicalWireSegment * > & getSegments () const
 Gets all segments belonging to this wire.
bool empty () const
 Checks if this wire has no segments.
void setBus (Bus bus)
 Sets the logical bus for this wire.
void setBusSize (unsigned int size)
 Sets the bus size.
Bus getBus () const
 Gets the logical bus.
size_t getBusSize () const
 Gets the bus size.
void clearBusState ()
 Clears the state of all wires in the bus.
std::vector< QPointF > getVertices () const
 Gets vertices at wire endpoints that are not junctions.
QPainterPath shape () const
 Gets the combined shape of all segments.
QColor getColor () const
 Gets the color for this wire based on bus size.
void setManager (WireManager *manager)
 Sets the wire manager.
WireManager * getManager () const
 Gets the wire manager.

Static Public Member Functions

static QColor getColor (const GraphicalWire *w)
 Gets the color for a wire pointer (null-safe).

Private Attributes

uint64_t routeId
std::optional< QString > connectionError
Bus bus
 The logical bus.
std::unordered_set< GraphicalWireSegment * > segments
 Set of segments belonging to this wire.
WireManager * manager = nullptr
 Wire manager for this wire.

Detailed Description

Logical wire entity that groups segments sharing the same bus.

GraphicalWire is an abstract logical entity representing a single logical bus in the circuit diagram. It manages one or more GraphicalWireSegment objects that are visually connected and share the same logical Bus and bus size.

This class is not a QGraphicsItem itself - it is managed by WireManager and tracks the logical connectivity independent of the visual representation.

See also
GraphicalWireSegment
WireManager

Definition at line 58 of file graphicalWire.hpp.

Constructor & Destructor Documentation

◆ GraphicalWire() [1/2]

GraphicalWire ( )

Creates a wire with a unique route identifier.

Definition at line 49 of file graphicalWire.cpp.

◆ ~GraphicalWire()

~GraphicalWire ( )
default

◆ GraphicalWire() [2/2]

GraphicalWire ( unsigned int busSize)
explicit

Constructs a wire with a specified bus size.

Parameters
busSizeThe number of wires in the bus

Definition at line 59 of file graphicalWire.cpp.

Member Function Documentation

◆ addSegment()

void addSegment ( GraphicalWireSegment * segment)

Adds a segment to this wire.

Parameters
segmentThe segment to add

Definition at line 65 of file graphicalWire.cpp.

◆ clearBusState()

void clearBusState ( )

Clears the state of all wires in the bus.

Sets all wires to UNKNOWN state, used during simulation initialization.

Definition at line 83 of file graphicalWire.cpp.

◆ empty()

bool empty ( ) const
inlinenodiscard

Checks if this wire has no segments.

Returns
True if empty

Definition at line 111 of file graphicalWire.hpp.

◆ getBus()

Bus getBus ( ) const
inlinenodiscard

Gets the logical bus.

Returns
Reference to the bus

Definition at line 129 of file graphicalWire.hpp.

◆ getBusSize()

size_t getBusSize ( ) const
inlinenodiscard

Gets the bus size.

Returns
Number of wires in the bus

Definition at line 135 of file graphicalWire.hpp.

◆ getColor() [1/2]

QColor getColor ( ) const

Gets the color for this wire based on bus size.

Returns
QColor for rendering

Definition at line 102 of file graphicalWire.cpp.

◆ getColor() [2/2]

QColor getColor ( const GraphicalWire * w)
static

Gets the color for a wire pointer (null-safe).

Parameters
wThe wire pointer
Returns
QColor for rendering

Definition at line 121 of file graphicalWire.cpp.

◆ getConnectionError()

std::optional< QString > getConnectionError ( ) const
inlinenodiscard

Returns the connection error, or no value when the net has no error.

Definition at line 84 of file graphicalWire.hpp.

◆ getManager()

WireManager * getManager ( ) const
inline

Gets the wire manager.

Returns
Pointer to the manager

Definition at line 188 of file graphicalWire.hpp.

◆ getRouteId()

uint64_t getRouteId ( ) const
inlinenodiscard

Returns the persistent identifier of this logical wire group.

Definition at line 70 of file graphicalWire.hpp.

◆ getSegments()

const std::unordered_set< GraphicalWireSegment * > & getSegments ( ) const
inlinenodiscard

Gets all segments belonging to this wire.

Returns
Set of segment pointers

Definition at line 103 of file graphicalWire.hpp.

◆ getVertices()

std::vector< QPointF > getVertices ( ) const
nodiscard

Gets vertices at wire endpoints that are not junctions.

Returns segment endpoints that are free tips (not connected to other wires), representing connection points to components.

Returns
Vector of endpoint positions in scene coordinates

Definition at line 128 of file graphicalWire.cpp.

◆ removeSegment()

void removeSegment ( GraphicalWireSegment * segment)

Removes a segment from this wire.

Parameters
segmentThe segment to remove

Definition at line 73 of file graphicalWire.cpp.

◆ restoreRouteId()

void restoreRouteId ( uint64_t id)

Restores a saved identifier and advances the identifier allocator.

Parameters
idRoute identifier from serialization or an undo snapshot.

Definition at line 51 of file graphicalWire.cpp.

◆ setBus()

void setBus ( Bus bus)
inline

Sets the logical bus for this wire.

Parameters
busThe bus to set

Definition at line 117 of file graphicalWire.hpp.

◆ setBusSize()

void setBusSize ( unsigned int size)

Sets the bus size.

Parameters
sizeThe new size

Definition at line 78 of file graphicalWire.cpp.

◆ setConnectionError()

void setConnectionError ( std::optional< QString > reason)

Updates the connection error and refreshes segment tooltips and painting.

Parameters
reasonError message, or no value to clear the error.

Definition at line 90 of file graphicalWire.cpp.

◆ setManager()

void setManager ( WireManager * manager)
inline

Sets the wire manager.

Parameters
managerThe manager instance

Definition at line 182 of file graphicalWire.hpp.

◆ shape()

QPainterPath shape ( ) const
nodiscard

Gets the combined shape of all segments.

Returns
Painter path in scene coordinates

Definition at line 146 of file graphicalWire.cpp.

Member Data Documentation

◆ bus

Bus bus
private

The logical bus.

Definition at line 194 of file graphicalWire.hpp.

◆ connectionError

std::optional<QString> connectionError
private

Definition at line 192 of file graphicalWire.hpp.

◆ manager

WireManager* manager = nullptr
private

Wire manager for this wire.

Definition at line 200 of file graphicalWire.hpp.

◆ routeId

uint64_t routeId
private

Definition at line 191 of file graphicalWire.hpp.

◆ segments

std::unordered_set<GraphicalWireSegment*> segments
private

Set of segments belonging to this wire.

Definition at line 197 of file graphicalWire.hpp.


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