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

#include <wireManager.hpp>

Classes

struct  PortReference
struct  TopologyVertex
struct  TopologyEdge
struct  SegmentTopology
struct  PortAnchor
struct  ExplicitContact
class  Edit
class  Batch

Public Types

enum class  Change : uint8_t { None = 0 , Geometry = 1 , Connectivity = 2 , Electrical = 4 }
enum class  VertexKind : uint8_t { FreeEndpoint , Junction , Port }
using ChangeCallback = std::function<void(Change)>
using TopologyVertexMap = std::map<uint64_t, TopologyVertex>
using TopologyEdgeMap = std::map<uint64_t, TopologyEdge>
using PortAnchorProvider = std::function<std::vector<PortAnchor>()>

Public Member Functions

const TopologyVertexMap & topologyVertices () const
 Borrows the topology vertex map until the topology is modified.
const TopologyEdgeMap & topologyEdges () const
 Borrows the topology edge map until the topology is modified.
const SegmentTopology & topologyFor (uint64_t segmentId) const
 Borrows segment topology until rebuilt; missing segments return an empty topology.
void setPortAnchors (PortAnchorProvider anchors)
 Sets the provider of current component port anchors in scene coordinates.
void refreshPortAnchors ()
 Refreshes port references after components enter or leave the scene.
void rebuildFromGeometry ()
 Derives electrical groups, junctions, and port vertices from segment geometry.
 WireManager ()=default
 ~WireManager ()
 WireManager (const WireManager &)=delete
WireManager & operator= (const WireManager &)=delete
 WireManager (WireManager &&)=delete
WireManager & operator= (WireManager &&)=delete
std::shared_ptr< GraphicalWire > createWire (unsigned int busSize=1)
void removeWire (GraphicalWire *wire)
const std::vector< std::shared_ptr< GraphicalWire > > & wires () const
void addSegment (GraphicalWireSegment *segment, bool updateTopology=true)
void removeSegment (GraphicalWireSegment *segment)
void updateSegmentTopology (GraphicalWireSegment *segment)
bool commitSegmentTranslations (std::span< const std::pair< uint64_t, QPointF > > translations)
 Rebuilds connectivity after segment positions have been translated.
void calculateJunctions (GraphicalWireSegment *segment, bool includeNeighborhood=true) const
void calculateJunctions () const
GraphicalWireSegment * segmentAtPoint (QPointF scenePoint, const GraphicalWireSegment *ignoredSegment=nullptr) const
const std::vector< GraphicalWireSegment * > & getSegments () const
void clearSegments (QGraphicsScene &scene)
 Deletes all managed graphical wire segments from scene.
void replaceSegments (QGraphicsScene &scene, std::span< const RoutedWire > routedSegments)
 Replaces all managed graphical wire segments with routed segments.
void setChangedCallback (ChangeCallback cb)
 Sets the callback for geometry, connectivity, and electrical changes.
void notifyTopologyChanged () const
 Force execute the callback natively mapped to topological splits, merges, or drags.
void notifyElectricalChanged () const
 Notifies listeners of an electrical change, deferring delivery within a batch.
void clear ()

Static Public Member Functions

static std::vector< GraphicalWireSegment * > segmentNeighbors (GraphicalWireSegment *segment)
static bool segmentsTouching (const GraphicalWireSegment *segment, const GraphicalWireSegment *other)

Private Types

using TopologyGraph
using VertexDescriptor = boost::graph_traits<TopologyGraph>::vertex_descriptor

Private Member Functions

void calculateJunctionsFor (std::span< GraphicalWireSegment *const > segments) const
 Updates endpoint junction flags for the supplied registered segments.
void finishBatch ()
 Finishes one batch level and flushes pending edits and changes at the outermost level.
void discardBatch () noexcept
 Drops one batch level and clears pending work when no batch remains.
void notify (Change change) const
 Delivers change flags to the callback or accumulates them in an active batch.
GraphicalWireSegment * registeredSegment (uint64_t id) const
 Returns the registered segment with the given identifier, or nullptr.
uint64_t createVertex (QPointF position, VertexKind kind=VertexKind::FreeEndpoint)
 Creates a topology vertex and attaches matching port anchors.
void rebuildTopologyEdges ()
 Rebuilds graph edges by splitting each segment route at its electrical vertices.

Private Attributes

TopologyGraph topologyGraph
std::map< uint64_t, VertexDescriptor > vertexDescriptors
std::vector< std::shared_ptr< GraphicalWire > > managedWires
std::vector< GraphicalWireSegment * > allSegments
ChangeCallback onChanged
 Callback invoked when wire topology changes (splits, merges, drags).
unsigned int batchDepth = 0
bool rebuildPending = false
uint8_t pendingChanges = 0
std::vector< uint64_t > pendingEdits
TopologyVertexMap vertices
TopologyEdgeMap edges
std::map< uint64_t, SegmentTopology > segmentTopology
uint64_t nextVertexId = 1
uint64_t nextEdgeId = 1
PortAnchorProvider portAnchors

Detailed Description

Definition at line 58 of file wireManager.hpp.

Member Typedef Documentation

◆ ChangeCallback

using ChangeCallback = std::function<void(Change)>

Definition at line 61 of file wireManager.hpp.

◆ PortAnchorProvider

using PortAnchorProvider = std::function<std::vector<PortAnchor>()>

Definition at line 97 of file wireManager.hpp.

◆ TopologyEdgeMap

using TopologyEdgeMap = std::map<uint64_t, TopologyEdge>

Definition at line 84 of file wireManager.hpp.

◆ TopologyGraph

using TopologyGraph
private
Initial value:
boost::adjacency_list<boost::vecS, boost::vecS,
boost::undirectedS, uint64_t, uint64_t>

Definition at line 266 of file wireManager.hpp.

◆ TopologyVertexMap

using TopologyVertexMap = std::map<uint64_t, TopologyVertex>

Definition at line 83 of file wireManager.hpp.

◆ VertexDescriptor

using VertexDescriptor = boost::graph_traits<TopologyGraph>::vertex_descriptor
private

Definition at line 268 of file wireManager.hpp.

Member Enumeration Documentation

◆ Change

enum class Change : uint8_t
strong
Enumerator
None 
Geometry 
Connectivity 
Electrical 

Definition at line 60 of file wireManager.hpp.

◆ VertexKind

enum class VertexKind : uint8_t
strong
Enumerator
FreeEndpoint 
Junction 
Port 

Definition at line 62 of file wireManager.hpp.

Constructor & Destructor Documentation

◆ WireManager() [1/3]

WireManager ( )
default

◆ ~WireManager()

~WireManager ( )
inline

Definition at line 176 of file wireManager.hpp.

◆ WireManager() [2/3]

WireManager ( const WireManager & )
delete

◆ WireManager() [3/3]

WireManager ( WireManager && )
delete

Member Function Documentation

◆ addSegment()

void addSegment ( GraphicalWireSegment * segment,
bool updateTopology = true )

Definition at line 479 of file wireManager.cpp.

◆ calculateJunctions() [1/2]

void calculateJunctions ( ) const

Definition at line 518 of file wireManager.cpp.

◆ calculateJunctions() [2/2]

void calculateJunctions ( GraphicalWireSegment * segment,
bool includeNeighborhood = true ) const

Definition at line 523 of file wireManager.cpp.

◆ calculateJunctionsFor()

void calculateJunctionsFor ( std::span< GraphicalWireSegment *const > segments) const
private

Updates endpoint junction flags for the supplied registered segments.

Definition at line 537 of file wireManager.cpp.

◆ clear()

void clear ( )

Definition at line 370 of file wireManager.cpp.

◆ clearSegments()

void clearSegments ( QGraphicsScene & scene)

Deletes all managed graphical wire segments from scene.

Definition at line 395 of file wireManager.cpp.

◆ commitSegmentTranslations()

bool commitSegmentTranslations ( std::span< const std::pair< uint64_t, QPointF > > translations)
nodiscard

Rebuilds connectivity after segment positions have been translated.

Parameters
translationsSegment identifiers and applied scene displacements.
Returns
True after processing the translations.

Definition at line 360 of file wireManager.cpp.

◆ createVertex()

uint64_t createVertex ( QPointF position,
VertexKind kind = VertexKind::FreeEndpoint )
private

Creates a topology vertex and attaches matching port anchors.

Definition at line 135 of file wireManager.cpp.

◆ createWire()

std::shared_ptr< GraphicalWire > createWire ( unsigned int busSize = 1)

Definition at line 460 of file wireManager.cpp.

◆ discardBatch()

void discardBatch ( )
privatenoexcept

Drops one batch level and clears pending work when no batch remains.

Definition at line 116 of file wireManager.cpp.

◆ finishBatch()

void finishBatch ( )
private

Finishes one batch level and flushes pending edits and changes at the outermost level.

Definition at line 85 of file wireManager.cpp.

◆ getSegments()

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

Borrowed until segments are registered or removed. Copy for mutation loops.

Definition at line 225 of file wireManager.hpp.

◆ notify()

void notify ( Change change) const
private

Delivers change flags to the callback or accumulates them in an active batch.

Definition at line 104 of file wireManager.cpp.

◆ notifyElectricalChanged()

void notifyElectricalChanged ( ) const
inline

Notifies listeners of an electrical change, deferring delivery within a batch.

Definition at line 260 of file wireManager.hpp.

◆ notifyTopologyChanged()

void notifyTopologyChanged ( ) const
inline

Force execute the callback natively mapped to topological splits, merges, or drags.

Definition at line 254 of file wireManager.hpp.

◆ operator=() [1/2]

WireManager & operator= ( const WireManager & )
delete

◆ operator=() [2/2]

WireManager & operator= ( WireManager && )
delete

◆ rebuildFromGeometry()

void rebuildFromGeometry ( )

Derives electrical groups, junctions, and port vertices from segment geometry.

Definition at line 242 of file wireManager.cpp.

◆ rebuildTopologyEdges()

void rebuildTopologyEdges ( )
private

Rebuilds graph edges by splitting each segment route at its electrical vertices.

Definition at line 184 of file wireManager.cpp.

◆ refreshPortAnchors()

void refreshPortAnchors ( )

Refreshes port references after components enter or leave the scene.

Definition at line 152 of file wireManager.cpp.

◆ registeredSegment()

GraphicalWireSegment * registeredSegment ( uint64_t id) const
private

Returns the registered segment with the given identifier, or nullptr.

Definition at line 127 of file wireManager.cpp.

◆ removeSegment()

void removeSegment ( GraphicalWireSegment * segment)

Definition at line 498 of file wireManager.cpp.

◆ removeWire()

void removeWire ( GraphicalWire * wire)

Definition at line 468 of file wireManager.cpp.

◆ replaceSegments()

void replaceSegments ( QGraphicsScene & scene,
std::span< const RoutedWire > routedSegments )

Replaces all managed graphical wire segments with routed segments.

Definition at line 424 of file wireManager.cpp.

◆ segmentAtPoint()

GraphicalWireSegment * segmentAtPoint ( QPointF scenePoint,
const GraphicalWireSegment * ignoredSegment = nullptr ) const
nodiscard

Definition at line 554 of file wireManager.cpp.

◆ segmentNeighbors()

std::vector< GraphicalWireSegment * > segmentNeighbors ( GraphicalWireSegment * segment)
static

Definition at line 575 of file wireManager.cpp.

◆ segmentsTouching()

bool segmentsTouching ( const GraphicalWireSegment * segment,
const GraphicalWireSegment * other )
staticnodiscard

Definition at line 597 of file wireManager.cpp.

◆ setChangedCallback()

void setChangedCallback ( ChangeCallback cb)
inline

Sets the callback for geometry, connectivity, and electrical changes.

Parameters
cbCallback receiving combined change flags; an empty callback disables delivery.

Definition at line 245 of file wireManager.hpp.

◆ setPortAnchors()

void setPortAnchors ( PortAnchorProvider anchors)
inline

Sets the provider of current component port anchors in scene coordinates.

Definition at line 111 of file wireManager.hpp.

◆ topologyEdges()

const TopologyEdgeMap & topologyEdges ( ) const
inlinenodiscard

Borrows the topology edge map until the topology is modified.

Definition at line 107 of file wireManager.hpp.

◆ topologyFor()

const WireManager::SegmentTopology & topologyFor ( uint64_t segmentId) const
nodiscard

Borrows segment topology until rebuilt; missing segments return an empty topology.

Definition at line 145 of file wireManager.cpp.

◆ topologyVertices()

const TopologyVertexMap & topologyVertices ( ) const
inlinenodiscard

Borrows the topology vertex map until the topology is modified.

Definition at line 105 of file wireManager.hpp.

◆ updateSegmentTopology()

void updateSegmentTopology ( GraphicalWireSegment * segment)

Definition at line 510 of file wireManager.cpp.

◆ wires()

const std::vector< std::shared_ptr< GraphicalWire > > & wires ( ) const
inlinenodiscard

Definition at line 185 of file wireManager.hpp.

Member Data Documentation

◆ allSegments

std::vector<GraphicalWireSegment*> allSegments
private

Definition at line 273 of file wireManager.hpp.

◆ batchDepth

unsigned int batchDepth = 0
private

Definition at line 277 of file wireManager.hpp.

◆ edges

TopologyEdgeMap edges
private

Definition at line 282 of file wireManager.hpp.

◆ managedWires

std::vector<std::shared_ptr<GraphicalWire> > managedWires
private

Definition at line 272 of file wireManager.hpp.

◆ nextEdgeId

uint64_t nextEdgeId = 1
private

Definition at line 285 of file wireManager.hpp.

◆ nextVertexId

uint64_t nextVertexId = 1
private

Definition at line 284 of file wireManager.hpp.

◆ onChanged

ChangeCallback onChanged
private

Callback invoked when wire topology changes (splits, merges, drags).

Definition at line 276 of file wireManager.hpp.

◆ pendingChanges

uint8_t pendingChanges = 0
mutableprivate

Definition at line 279 of file wireManager.hpp.

◆ pendingEdits

std::vector<uint64_t> pendingEdits
private

Definition at line 280 of file wireManager.hpp.

◆ portAnchors

PortAnchorProvider portAnchors
private

Definition at line 286 of file wireManager.hpp.

◆ rebuildPending

bool rebuildPending = false
private

Definition at line 278 of file wireManager.hpp.

◆ segmentTopology

std::map<uint64_t, SegmentTopology> segmentTopology
private

Definition at line 283 of file wireManager.hpp.

◆ topologyGraph

TopologyGraph topologyGraph
private

Definition at line 269 of file wireManager.hpp.

◆ vertexDescriptors

std::map<uint64_t, VertexDescriptor> vertexDescriptors
private

Definition at line 270 of file wireManager.hpp.

◆ vertices

TopologyVertexMap vertices
private

Definition at line 281 of file wireManager.hpp.


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