SILICON
Toggle main menu visibility
Loading...
Searching...
No Matches
localWireEditor.hpp
Go to the documentation of this file.
1
/*
2
Copyright (c) 2026. Giulio Cocconi
3
4
This program is free software: you can redistribute it and/or modify
5
it under the terms of the GNU General Public License as published by
6
the Free Software Foundation, either version 3 of the License, or
7
(at your option) any later version.
8
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
13
14
You should have received a copy of the GNU General Public License
15
along with this program. If not, see <http://www.gnu.org/licenses/>.
16
*/
17
18
#pragma once
19
20
#include <cstdint>
21
#include <optional>
22
#include <span>
23
#include <vector>
24
25
#include "
interactiveWireRouter.hpp
"
26
27
namespace
SILICON::ui
{
28
30
class
LocalWireEditor
{
31
public
:
39
LocalWireEditor
(std::span<const RoutingComponent>
components
,
40
std::span<const RoutingSegment>
segments
, qreal
gridSize
);
41
47
[[nodiscard]]
RoutePreview
48
moveComponents
(std::span<const ComponentRouteMove> moves)
const
;
49
57
[[nodiscard]]
RoutePreview
58
moveBend
(uint64_t segmentId, std::size_t index, QPointF position)
const
;
59
67
[[nodiscard]]
RoutePreview
68
moveEdge
(uint64_t segmentId, std::size_t index, QPointF displacement)
const
;
69
76
[[nodiscard]]
bool
valid
(std::span<const RoutedSegment> routes,
77
uint64_t editedSegment)
const
;
78
79
private
:
81
[[nodiscard]] QPointF
snap
(QPointF point)
const
;
83
[[nodiscard]]
const
RoutingSegment
*
find
(uint64_t
id
)
const
;
91
[[nodiscard]]
static
std::optional<std::vector<QPointF>>
92
moveAttachedEndpoint
(
const
RoutingSegment
& segment,
bool
first,
93
QPointF destination);
100
[[nodiscard]]
RoutePreview
101
finish
(uint64_t editedId, std::vector<RoutedSegment> routes)
const
;
102
103
std::span<const RoutingComponent>
components
;
104
std::span<const RoutingSegment>
segments
;
105
qreal
gridSize
;
106
};
107
108
}
// namespace SILICON::ui
SILICON::ui::LocalWireEditor::find
const RoutingSegment * find(uint64_t id) const
Returns the borrowed segment with the given identifier, or nullptr.
Definition
localWireEditor.cpp:55
SILICON::ui::LocalWireEditor::gridSize
qreal gridSize
Definition
localWireEditor.hpp:105
SILICON::ui::LocalWireEditor::segments
std::span< const RoutingSegment > segments
Definition
localWireEditor.hpp:104
SILICON::ui::LocalWireEditor::snap
QPointF snap(QPointF point) const
Snaps a scene point to the grid when the grid spacing is positive.
Definition
localWireEditor.cpp:46
SILICON::ui::LocalWireEditor::moveBend
RoutePreview moveBend(uint64_t segmentId, std::size_t index, QPointF position) const
Moves an interior bend and adjusts electrically attached branches.
Definition
localWireEditor.cpp:150
SILICON::ui::LocalWireEditor::LocalWireEditor
LocalWireEditor(std::span< const RoutingComponent > components, std::span< const RoutingSegment > segments, qreal gridSize)
Borrows the original geometry for local wire edits.
Definition
localWireEditor.cpp:40
SILICON::ui::LocalWireEditor::moveEdge
RoutePreview moveEdge(uint64_t segmentId, std::size_t index, QPointF displacement) const
Offsets an edge perpendicular to its direction, preserving endpoints.
Definition
localWireEditor.cpp:189
SILICON::ui::LocalWireEditor::components
std::span< const RoutingComponent > components
Definition
localWireEditor.hpp:103
SILICON::ui::LocalWireEditor::moveComponents
RoutePreview moveComponents(std::span< const ComponentRouteMove > moves) const
Adjusts wire endpoints attached to moved component ports.
Definition
localWireEditor.cpp:61
SILICON::ui::LocalWireEditor::finish
RoutePreview finish(uint64_t editedId, std::vector< RoutedSegment > routes) const
Canonicalizes and validates edits, then fills in unchanged snapshot routes.
Definition
localWireEditor.cpp:244
SILICON::ui::LocalWireEditor::valid
bool valid(std::span< const RoutedSegment > routes, uint64_t editedSegment) const
Checks route geometry, obstacles, and preservation of electrical contacts.
Definition
localWireEditor.cpp:261
SILICON::ui::LocalWireEditor::moveAttachedEndpoint
static std::optional< std::vector< QPointF > > moveAttachedEndpoint(const RoutingSegment &segment, bool first, QPointF destination)
Adjusts one endpoint while keeping its route orthogonal.
Definition
localWireEditor.cpp:126
interactiveWireRouter.hpp
SILICON::ui
Definition
actionGroups.hpp:14
SILICON::ui::RoutePreview
std::optional< std::vector< RoutedSegment > > RoutePreview
Definition
interactiveWireRouter.hpp:36
SILICON::ui::RoutingSegment
Definition
interactiveWireRouter.hpp:24
src
ui
circuit
diagram
localWireEditor.hpp
Generated by
1.17.0