SILICON
Toggle main menu visibility
Loading...
Searching...
No Matches
interactiveWireRouter.hpp
Go to the documentation of this file.
1
/*
2
Copyright (c) 2026. Giulio Cocconi
3
... (license omitted for brevity) ...
4
*/
5
6
#pragma once
7
8
#include <cstdint>
9
#include <optional>
10
#include <span>
11
#include <vector>
12
13
#include <QPointF>
14
#include <QRectF>
15
16
namespace
SILICON::ui
{
17
18
struct
RoutingComponent
{
19
uint64_t
id
;
20
QRectF
bounds
;
21
std::vector<QPointF>
ports
;
22
};
23
24
struct
RoutingSegment
{
25
uint64_t
id
;
26
uint64_t
net
;
27
std::vector<QPointF>
points
;
28
std::vector<std::pair<uint64_t, QPointF>>
electricalVertices
{};
29
};
30
31
struct
RoutedSegment
{
32
uint64_t
id
;
33
std::vector<QPointF>
points
;
34
};
35
36
using
RoutePreview
= std::optional<std::vector<RoutedSegment>>;
37
38
struct
ComponentRouteMove
{
39
uint64_t
id
;
40
QRectF
bounds
;
41
};
42
44
class
InteractiveWireRouter
{
45
public
:
52
InteractiveWireRouter
(std::vector<RoutingComponent>
components
,
53
std::vector<RoutingSegment>
segments
,
54
qreal
gridSize
);
55
61
[[nodiscard]]
RoutePreview
62
routeComponents
(std::span<const ComponentRouteMove> moves)
const
;
63
71
[[nodiscard]]
RoutePreview
72
routeWireBend
(uint64_t segmentId, std::size_t bendIndex, QPointF position)
const
;
73
81
[[nodiscard]]
RoutePreview
82
routeWireEndpoint
(uint64_t segmentId, std::size_t endpointIndex, QPointF position)
const
;
83
91
[[nodiscard]]
RoutePreview
92
routeWireEdge
(uint64_t segmentId, std::size_t edgeIndex, QPointF displacement)
const
;
93
94
private
:
95
enum class
Handle
{
None
,
Bend
,
Edge
,
Endpoint
};
96
97
struct
Request
{
98
Handle
handle
=
Handle::None
;
99
uint64_t
segmentId
= 0;
100
std::size_t
index
= 0;
101
QPointF
value
;
102
std::span<const ComponentRouteMove>
moves
;
103
};
104
110
[[nodiscard]]
RoutePreview
routeWithLibavoid
(
Request
request)
const
;
111
112
std::vector<RoutingComponent>
components
;
113
std::vector<RoutingSegment>
segments
;
114
qreal
gridSize
;
115
};
116
117
}
// namespace SILICON::ui
SILICON::ui::InteractiveWireRouter::gridSize
qreal gridSize
Definition
interactiveWireRouter.hpp:114
SILICON::ui::InteractiveWireRouter::routeWithLibavoid
RoutePreview routeWithLibavoid(Request request) const
Routes a validated request with libavoid and checks the resulting geometry.
Definition
interactiveWireRouter.cpp:248
SILICON::ui::InteractiveWireRouter::routeWireEdge
RoutePreview routeWireEdge(uint64_t segmentId, std::size_t edgeIndex, QPointF displacement) const
Moves an edge perpendicular to its original direction.
Definition
interactiveWireRouter.cpp:232
SILICON::ui::InteractiveWireRouter::components
std::vector< RoutingComponent > components
Definition
interactiveWireRouter.hpp:112
SILICON::ui::InteractiveWireRouter::segments
std::vector< RoutingSegment > segments
Definition
interactiveWireRouter.hpp:113
SILICON::ui::InteractiveWireRouter::routeWireEndpoint
RoutePreview routeWireEndpoint(uint64_t segmentId, std::size_t endpointIndex, QPointF position) const
Routes a wire with one endpoint moved to a new position.
Definition
interactiveWireRouter.cpp:219
SILICON::ui::InteractiveWireRouter::routeComponents
RoutePreview routeComponents(std::span< const ComponentRouteMove > moves) const
Routes wires around moved components while preserving their connections.
Definition
interactiveWireRouter.cpp:194
SILICON::ui::InteractiveWireRouter::InteractiveWireRouter
InteractiveWireRouter(std::vector< RoutingComponent > components, std::vector< RoutingSegment > segments, qreal gridSize)
Owns a snapshot used as the starting geometry for every routing preview.
Definition
interactiveWireRouter.cpp:187
SILICON::ui::InteractiveWireRouter::Handle
Handle
Definition
interactiveWireRouter.hpp:95
SILICON::ui::InteractiveWireRouter::Handle::Endpoint
@ Endpoint
Definition
interactiveWireRouter.hpp:95
SILICON::ui::InteractiveWireRouter::Handle::None
@ None
Definition
interactiveWireRouter.hpp:95
SILICON::ui::InteractiveWireRouter::Handle::Bend
@ Bend
Definition
interactiveWireRouter.hpp:95
SILICON::ui::InteractiveWireRouter::Handle::Edge
@ Edge
Definition
interactiveWireRouter.hpp:95
SILICON::ui::InteractiveWireRouter::routeWireBend
RoutePreview routeWireBend(uint64_t segmentId, std::size_t bendIndex, QPointF position) const
Moves an interior bend and routes electrically attached branches.
Definition
interactiveWireRouter.cpp:204
SILICON::ui
Definition
actionGroups.hpp:14
SILICON::ui::RoutePreview
std::optional< std::vector< RoutedSegment > > RoutePreview
Definition
interactiveWireRouter.hpp:36
SILICON::ui::ComponentRouteMove
Definition
interactiveWireRouter.hpp:38
SILICON::ui::ComponentRouteMove::id
uint64_t id
Definition
interactiveWireRouter.hpp:39
SILICON::ui::ComponentRouteMove::bounds
QRectF bounds
Definition
interactiveWireRouter.hpp:40
SILICON::ui::InteractiveWireRouter::Request
Definition
interactiveWireRouter.hpp:97
SILICON::ui::InteractiveWireRouter::Request::segmentId
uint64_t segmentId
Definition
interactiveWireRouter.hpp:99
SILICON::ui::InteractiveWireRouter::Request::handle
Handle handle
Definition
interactiveWireRouter.hpp:98
SILICON::ui::InteractiveWireRouter::Request::moves
std::span< const ComponentRouteMove > moves
Definition
interactiveWireRouter.hpp:102
SILICON::ui::InteractiveWireRouter::Request::index
std::size_t index
Definition
interactiveWireRouter.hpp:100
SILICON::ui::InteractiveWireRouter::Request::value
QPointF value
Definition
interactiveWireRouter.hpp:101
SILICON::ui::RoutedSegment
Definition
interactiveWireRouter.hpp:31
SILICON::ui::RoutedSegment::id
uint64_t id
Definition
interactiveWireRouter.hpp:32
SILICON::ui::RoutedSegment::points
std::vector< QPointF > points
Definition
interactiveWireRouter.hpp:33
SILICON::ui::RoutingComponent
Definition
interactiveWireRouter.hpp:18
SILICON::ui::RoutingComponent::ports
std::vector< QPointF > ports
Definition
interactiveWireRouter.hpp:21
SILICON::ui::RoutingComponent::id
uint64_t id
Definition
interactiveWireRouter.hpp:19
SILICON::ui::RoutingComponent::bounds
QRectF bounds
Definition
interactiveWireRouter.hpp:20
SILICON::ui::RoutingSegment
Definition
interactiveWireRouter.hpp:24
SILICON::ui::RoutingSegment::id
uint64_t id
Definition
interactiveWireRouter.hpp:25
SILICON::ui::RoutingSegment::points
std::vector< QPointF > points
Definition
interactiveWireRouter.hpp:27
SILICON::ui::RoutingSegment::net
uint64_t net
Definition
interactiveWireRouter.hpp:26
SILICON::ui::RoutingSegment::electricalVertices
std::vector< std::pair< uint64_t, QPointF > > electricalVertices
Definition
interactiveWireRouter.hpp:28
src
ui
circuit
diagram
interactiveWireRouter.hpp
Generated by
1.17.0