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

#include <localWireEditor.hpp>

Public Member Functions

 LocalWireEditor (std::span< const RoutingComponent > components, std::span< const RoutingSegment > segments, qreal gridSize)
 Borrows the original geometry for local wire edits.
RoutePreview moveComponents (std::span< const ComponentRouteMove > moves) const
 Adjusts wire endpoints attached to moved component ports.
RoutePreview moveBend (uint64_t segmentId, std::size_t index, QPointF position) const
 Moves an interior bend and adjusts electrically attached branches.
RoutePreview moveEdge (uint64_t segmentId, std::size_t index, QPointF displacement) const
 Offsets an edge perpendicular to its direction, preserving endpoints.
bool valid (std::span< const RoutedSegment > routes, uint64_t editedSegment) const
 Checks route geometry, obstacles, and preservation of electrical contacts.

Private Member Functions

QPointF snap (QPointF point) const
 Snaps a scene point to the grid when the grid spacing is positive.
const RoutingSegment * find (uint64_t id) const
 Returns the borrowed segment with the given identifier, or nullptr.
RoutePreview finish (uint64_t editedId, std::vector< RoutedSegment > routes) const
 Canonicalizes and validates edits, then fills in unchanged snapshot routes.

Static Private Member Functions

static std::optional< std::vector< QPointF > > moveAttachedEndpoint (const RoutingSegment &segment, bool first, QPointF destination)
 Adjusts one endpoint while keeping its route orthogonal.

Private Attributes

std::span< const RoutingComponent > components
std::span< const RoutingSegment > segments
qreal gridSize

Detailed Description

Applies predictable, grid-aligned edits to an existing wire polyline.

Definition at line 30 of file localWireEditor.hpp.

Constructor & Destructor Documentation

◆ LocalWireEditor()

LocalWireEditor ( std::span< const RoutingComponent > components,
std::span< const RoutingSegment > segments,
qreal gridSize )

Borrows the original geometry for local wire edits.

Parameters
componentsComponent obstacles and ports in scene coordinates.
segmentsWire routes and electrical contacts in scene coordinates.
gridSizeGrid spacing; nonpositive values disable snapping.
Note
The referenced component and segment storage must outlive this editor.

Definition at line 40 of file localWireEditor.cpp.

Member Function Documentation

◆ find()

const RoutingSegment * find ( uint64_t id) const
nodiscardprivate

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

Definition at line 55 of file localWireEditor.cpp.

◆ finish()

RoutePreview finish ( uint64_t editedId,
std::vector< RoutedSegment > routes ) const
nodiscardprivate

Canonicalizes and validates edits, then fills in unchanged snapshot routes.

Parameters
editedIdEdited segment identifier, or zero for component moves.
routesCandidate route changes.
Returns
Complete snapshot routes, or no value if validation fails.

Definition at line 244 of file localWireEditor.cpp.

◆ moveAttachedEndpoint()

std::optional< std::vector< QPointF > > moveAttachedEndpoint ( const RoutingSegment & segment,
bool first,
QPointF destination )
staticnodiscardprivate

Adjusts one endpoint while keeping its route orthogonal.

Parameters
segmentOriginal route to edit.
firstWhether to move the first endpoint instead of the last.
destinationNew endpoint position in scene coordinates.
Returns
Adjusted points, or no value if the original route has fewer than two points.

Definition at line 126 of file localWireEditor.cpp.

◆ moveBend()

RoutePreview moveBend ( uint64_t segmentId,
std::size_t index,
QPointF position ) const
nodiscard

Moves an interior bend and adjusts electrically attached branches.

Parameters
segmentIdIdentifier of the segment to edit.
indexInterior point index in the original route.
positionDestination in scene coordinates, snapped to the grid.
Returns
Complete snapshot routes, or no value if the local edit is invalid.

Definition at line 150 of file localWireEditor.cpp.

◆ moveComponents()

RoutePreview moveComponents ( std::span< const ComponentRouteMove > moves) const
nodiscard

Adjusts wire endpoints attached to moved component ports.

Parameters
movesComponent identifiers and destination bounds in scene coordinates.
Returns
Complete snapshot routes, or no value if the local edit is invalid.

Definition at line 61 of file localWireEditor.cpp.

◆ moveEdge()

RoutePreview moveEdge ( uint64_t segmentId,
std::size_t index,
QPointF displacement ) const
nodiscard

Offsets an edge perpendicular to its direction, preserving endpoints.

Parameters
segmentIdIdentifier of the segment to edit.
indexIndex of the edge's first point.
displacementOffset in scene coordinates, snapped to the grid.
Returns
Complete snapshot routes, or no value if the local edit is invalid.

Definition at line 189 of file localWireEditor.cpp.

◆ snap()

QPointF snap ( QPointF point) const
nodiscardprivate

Snaps a scene point to the grid when the grid spacing is positive.

Definition at line 46 of file localWireEditor.cpp.

◆ valid()

bool valid ( std::span< const RoutedSegment > routes,
uint64_t editedSegment ) const
nodiscard

Checks route geometry, obstacles, and preservation of electrical contacts.

Parameters
routesCandidate routes; omitted segments retain their original geometry.
editedSegmentEdited segment identifier, or zero for component moves.
Returns
Whether the candidates satisfy the shared local and automatic routing checks.

Definition at line 261 of file localWireEditor.cpp.

Member Data Documentation

◆ components

std::span<const RoutingComponent> components
private

Definition at line 103 of file localWireEditor.hpp.

◆ gridSize

qreal gridSize
private

Definition at line 105 of file localWireEditor.hpp.

◆ segments

std::span<const RoutingSegment> segments
private

Definition at line 104 of file localWireEditor.hpp.


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