SILICON
Loading...
Searching...
No Matches
diagramScene.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 <map>
22#include <memory>
23#include <optional>
24#include <span>
25#include <string>
26#include <string_view>
27#include <unordered_map>
28#include <unordered_set>
29#include <vector>
30
31#include <QCursor>
32#include <QGraphicsScene>
33#include <QGraphicsSceneMouseEvent>
34#include <QGraphicsView>
35#include <QKeyEvent>
36#include <QList>
37#include <QPainter>
38#include <QPair>
39#include <QRect>
40#include <QStringList>
41#include <QUndoStack>
42#include <algorithm>
43#include <ranges>
44
45#include <nlohmann/json.hpp>
46
47#include <core/circuit.hpp>
48#include <core/component.hpp>
50
56
57namespace SILICON::project {
58class DocumentStore;
59}
60
61namespace SILICON::ui {
62using namespace SILICON::core;
63using namespace SILICON::waveform;
64
69class Port;
70class GraphicalWire;
71class GraphicalItem;
74struct RoutedSegment;
76class SceneLoadPlan;
77
79 unsigned int width = 1;
80 std::vector<Port*> affectedPorts;
81 std::optional<QString> error;
82
84 [[nodiscard]] bool isValid() const
85 {
86 return !error.has_value();
87 }
88};
89
91 std::vector<NetConnection> nets;
93 [[nodiscard]] bool valid() const {
94 return std::ranges::all_of(nets, [](const auto& net) { return net.isValid(); });
95 }
96};
97
118class DiagramScene : public QGraphicsScene {
119 Q_OBJECT
120public:
132
137 explicit DiagramScene(QObject* parent = nullptr);
138
140 void expandSceneBounds(const QRectF& bounds);
141
143 [[nodiscard]] const SILICON::project::DocumentStore* documentStore() const noexcept;
144 void setCircuitResolver(const CircuitResolver* resolver) noexcept;
145 [[nodiscard]] const CircuitResolver* circuitResolver() const noexcept;
146 void setUndoStack(QUndoStack* stack) noexcept { undoStack = stack; }
147 void setDocumentNavigator(DocumentNavigator* navigator) noexcept
148 {
149 documentNavigator = navigator;
150 }
151 [[nodiscard]] DocumentNavigator* getDocumentNavigator() const noexcept
152 {
153 return documentNavigator;
154 }
155
161
167
170 QPointF scenePos);
171 void updateComponentResize(QPointF scenePos);
174 [[nodiscard]] bool isResizingComponent() const { return componentResize.uiId != 0; }
175
181 {
183 }
184
189 [[nodiscard]] GraphicalComponent* getComponentToBeDrawn() const;
190
195 [[nodiscard]] bool isWireCreationInProgress() const
196 {
197 return wireSegmentToBeDrawn != nullptr;
198 }
199
204 void showCSB(QPointF pos);
205
209 void clearWireShadow();
210
214 void setComponentShadow();
215
220
226 void addComponent(GraphicalComponent* component, QPointF pos);
227
234 void placeComponent(std::string_view typeName, bool showSearchBox = true,
235 const PropertyMap& initialProperties = {});
236
242 static QPoint snapToGrid(QPointF point);
243
245 void rememberIoPlacementOrientation(const Component& component);
246
248 static int snapToGrid(qreal value);
249
251 static constexpr int GRID_SIZE = SILICON::ui::GRID_SIZE;
252
253 [[nodiscard]] QUndoStack* getUndoStack() const { return undoStack; }
254 [[nodiscard]] WireManager& getWireManager() { return wireManager; }
255 [[nodiscard]] const WireManager& getWireManager() const { return wireManager; }
263 bool beginWireDrag(GraphicalWireSegment* segment, QPointF scenePos, QPointF localPos);
265 void updateWireDrag(GraphicalWireSegment* segment, QPointF scenePos);
269 void cancelWireDrag();
271 [[nodiscard]] bool isDraggingWire(const GraphicalWireSegment* segment) const;
273 [[nodiscard]] std::vector<WireRouteChange> finishComponentDrag();
280 void applyWireRouteChanges(std::span<const WireRouteChange> changes, bool useAfter,
281 const WireEndpointEdit& endpointEdit = {});
289 void applyItemMoves(std::span<const ItemPositionChange> moves,
290 std::span<const WireRouteChange> wires, bool useAfter,
291 const WireEndpointEdit& topology = {});
292 [[nodiscard]] std::shared_ptr<Circuit> getCircuit() const { return circuit; }
293
295 void setCircuit(std::shared_ptr<Circuit> newCircuit)
296 {
297 circuit = std::move(newCircuit);
298 }
299
301 void setDocumentCircuit(std::shared_ptr<Circuit> newCircuit)
302 {
303 circuit = std::move(newCircuit);
304 }
305
310 void setIoInteractionsEnabled(bool enabled) { ioInteractionsEnabled = enabled; }
311
313 void setSubcircuitDocumentMode(bool enabled) { subcircuitDocumentMode = enabled; }
314
316 [[nodiscard]] bool isSubcircuitDocumentMode() const { return subcircuitDocumentMode; }
317
342 [[nodiscard]] std::string serialize() const;
343
361 [[nodiscard]] nlohmann::ordered_json serializeSelection() const;
362
374 [[nodiscard]] nlohmann::ordered_json
375 serializeItems(const std::vector<QGraphicsItem*>& sceneItems) const;
376
377 [[nodiscard]] GraphicalItem* findGraphicalItemByUiId(uint64_t uiId) const;
380 [[nodiscard]] bool itemCollisionChecksEnabled() const { return isItemCollisionEnabled; }
383 [[nodiscard]] bool isDraggingComponent(const GraphicalComponent* component) const;
385 [[nodiscard]] bool isWireAttachedToDraggedComponent(
386 const GraphicalComponent* component, const GraphicalWire* wire) const;
388 [[nodiscard]] bool hasWireGroupSelection() const;
390 [[nodiscard]] WireEndpointEdit finishMixedDrag();
391
401 void deserialize(const std::string& jsonStr, GUIComponentFactory& guiFactory,
402 const ComponentRegistry& coreRegistry);
403
415 [[nodiscard]] std::shared_ptr<SceneLoadPlan>
416 prepareDeserialize(const std::string& jsonStr, GUIComponentFactory& guiFactory,
417 const ComponentRegistry& coreRegistry);
418
424 void applyDeserialize(std::shared_ptr<SceneLoadPlan> plan);
425
427 void loadCircuit(std::shared_ptr<Circuit> circuit, GUIComponentFactory& guiFactory,
428 bool resolveSubcircuitMetadata = true);
429
446 bool insertSelection(const nlohmann::json& payload, GUIComponentFactory& guiFactory,
447 const ComponentRegistry& coreRegistry, QPointF targetOrigin,
448 bool isPaste = false);
449
455 void removeItems(const std::vector<QGraphicsItem*>& sceneItems);
456
465 void autoPlaceCircuit();
466
477 bool removeSelection(const nlohmann::json& payload);
478
479 void clear(bool clearUndoStack = true, bool clearLogs = true);
481
489 void setFstTraceFile(std::optional<std::string> fileName);
490
491 [[nodiscard]] bool isFstTracingEnabled() const;
492
498 void simulateEditedWaveform(qulonglong duration, std::vector<Sample> inputSnapshots);
499
500 ~DiagramScene() override;
501
502public slots:
506 void hideCSB();
507
514 void handleInputToggled(Bus targetBus, BusValue value, Component_weakPtr source);
515
517 [[nodiscard]] bool calculateWiresForComponents();
523 void refreshConnections();
524
525signals:
533
540 void waveformTraceReset(QStringList signalNames, int inputCount,
541 QList<int> signalWidths);
542
547 void waveformTraceSnapshots(QList<QPair<qulonglong, std::vector<BusValue>>> snapshots);
548
549private:
553 void drawBackground(QPainter* painter, const QRectF& rect) override;
554
558 void drawForeground(QPainter* painter, const QRectF& rect) override;
559
560 void initializeSceneBounds(qreal expansionStep);
562
566 void setInteractionMode(InteractionMode newMode, bool force);
567
571 [[nodiscard]] bool isWireCompletionPoint(QPointF scenePoint) const;
573 void updateWirePreview(QPointF scenePoint);
577 bool enterSimulationMode();
578 void exitSimulationMode();
579
583 void mouseMoveEvent(QGraphicsSceneMouseEvent* mouseEvent) override;
584
588 void mousePressEvent(QGraphicsSceneMouseEvent* mouseEvent) override;
589
591 void mouseReleaseEvent(QGraphicsSceneMouseEvent* mouseEvent) override;
592
596 void keyPressEvent(QKeyEvent* event) override;
597
599 InteractionMode currentInteractionMode = InteractionMode::NORMAL_MODE;
600
603
606
608 const CircuitResolver* resolver = nullptr;
609 QUndoStack* undoStack = nullptr;
611
621
624
626 std::string lastInputOrientation = "RIGHT";
627 std::string lastOutputOrientation = "LEFT";
628
631
635
638
646 [[nodiscard]] NetConnection inspectConnection(const std::vector<GraphicalWire*>& wires) const;
647
649 [[nodiscard]] std::unique_ptr<InteractiveWireRouter> makeInteractiveRouter() const;
651 [[nodiscard]] QPointF resolveWireTarget(QPointF scenePoint) const;
653 void beginComponentDrag();
655 void updateComponentDrag();
657 void cancelComponentDrag();
659 void beginMixedDrag();
661 void updateMixedDrag();
663 void cancelMixedDrag();
664 struct RouteEditState;
666 void applyRoutingPreview(const std::vector<RoutedSegment>& routes,
667 RouteEditState& state);
668
670 struct Contact {
671 uint64_t segmentId;
672 bool first;
673 uint64_t neighborId = 0;
675 Port* port = nullptr;
676 };
677 std::vector<std::pair<uint64_t, std::vector<QPointF>>> originals;
679 std::vector<std::unique_ptr<WireManager::Edit>> edits;
680 std::vector<Contact> contacts;
681 std::map<uint64_t, WireManager::SegmentTopology> topologyBefore;
682 std::map<uint64_t, WireEndpointEdit::NetState> netBefore;
684 void captureContacts(const DiagramScene& scene);
688 void cancel();
692 [[nodiscard]] std::vector<WireRouteChange> changes(const DiagramScene& scene) const;
693 };
694
696 std::unique_ptr<InteractiveWireRouter> router;
697 std::vector<std::pair<GraphicalComponent*, QPointF>> initialPositions;
698 std::vector<std::pair<GraphicalComponent*, QPointF>> validPositions;
699 std::unordered_map<const GraphicalComponent*,
700 std::unordered_set<const GraphicalWire*>> attachedWires;
703
705 GraphicalItem* item = nullptr;
708 };
709 std::vector<MixedDragItem> mixedDrag;
710 std::unordered_map<const GraphicalComponent*,
711 std::unordered_set<const GraphicalWire*>> mixedDragAttachedWires;
712 std::map<uint64_t, WireManager::SegmentTopology> mixedDragTopologyBefore;
713 std::map<uint64_t, WireEndpointEdit::NetState> mixedDragNetBefore;
714
718 size_t index = 0;
719 QPointF start;
720 std::vector<QPointF> originalPoints;
721 std::unique_ptr<InteractiveWireRouter> router;
724
727
730
732 std::shared_ptr<Circuit> circuit;
733
735 std::unordered_map<uint64_t, GraphicalItem*> itemsByUiId;
736
738 std::unique_ptr<DiagramSceneSimulationController> simulationController;
739
741 std::unique_ptr<DiagramSceneSerializer> serializer;
742
746};
747
752
753} // namespace SILICON::ui
Base class for all digital circuit components.
Handles DiagramScene persistence, clipboard payloads, and reconstruction.
Manages simulation lifecycle and waveform tracing for DiagramScene.
bool hasWireGroupSelection() const
Returns whether the selection includes a wire and a component, or multiple wires.
void registerGraphicalItem(GraphicalItem *item)
struct SILICON::ui::DiagramScene::WireDragState wireDrag
std::shared_ptr< Circuit > circuit
Underlying logic circuit model.
void placeComponent(std::string_view typeName, bool showSearchBox=true, const PropertyMap &initialProperties={})
Begins placing a component and applies its initial properties first.
void clear(bool clearUndoStack=true, bool clearLogs=true)
const CircuitResolver * circuitResolver() const noexcept
std::map< uint64_t, WireEndpointEdit::NetState > mixedDragNetBefore
void showCSB(QPointF pos)
Shows the component search box at a position.
static constexpr int GRID_SIZE
Grid cell size in scene units.
bool itemCollisionChecksEnabled() const
WireManager wireManager
Wire manager for wire topology.
QUndoStack * getUndoStack() const
const SILICON::project::DocumentStore * documents
void clearWireShadow()
Clears the wire being drawn.
void setUndoStack(QUndoStack *stack) noexcept
std::unique_ptr< DiagramSceneSimulationController > simulationController
Simulation lifecycle and trace management.
void updateWirePreview(QPointF scenePoint)
Updates the route preview for the wire being drawn toward a scene position.
const ConnectionReport & currentConnectionReport()
Returns the cached connection report, refreshing it first when dirty.
GraphicalComponent * componentToBeDrawn
Component being placed (shadow).
void handleInputToggled(Bus targetBus, BusValue value, Component_weakPtr source)
Handles input toggle events from GraphicalInput components.
void setIoInteractionsEnabled(bool enabled)
Enables or disables user-triggered IO interactions in simulation mode.
void loadCircuit(std::shared_ptr< Circuit > circuit, GUIComponentFactory &guiFactory, bool resolveSubcircuitMetadata=true)
void setFstTraceFile(std::optional< std::string > fileName)
Enables or disables simulation FST tracing.
void addComponent(GraphicalComponent *component, QPointF pos)
Adds a component to the scene.
bool isWireCompletionPoint(QPointF scenePoint) const
Lifecycle helper methods for interaction modes.
bool cancelCurrentInteraction()
Cancels the active transient interaction, returning to normal editing.
NetConnection inspectConnection(const std::vector< GraphicalWire * > &wires) const
Inspects the combined wire group for width and driver compatibility.
bool beginWireDrag(GraphicalWireSegment *segment, QPointF scenePos, QPointF localPos)
Starts dragging the wire handle hit at a local position.
std::unique_ptr< InteractiveWireRouter > makeInteractiveRouter() const
Creates a router snapshot from current components, routes, and electrical vertices.
std::unique_ptr< DiagramSceneSerializer > serializer
Persistence and clipboard payload handling.
WireManager & getWireManager()
const WireManager & getWireManager() const
void hideCSB()
Hides the component search box.
nlohmann::ordered_json serializeItems(const std::vector< QGraphicsItem * > &sceneItems) const
Serializes arbitrary scene items using the internal selection payload format.
std::vector< WireRouteChange > finishComponentDrag()
Commits the component gesture and returns its before and after wire routes.
void setDocumentNavigator(DocumentNavigator *navigator) noexcept
void updateMixedDrag()
Validates mixed selection movement and retains the last valid positions.
void applyItemMoves(std::span< const ItemPositionChange > moves, std::span< const WireRouteChange > wires, bool useAfter, const WireEndpointEdit &topology={})
Applies recorded item positions and wire routes and rebuilds connectivity.
void applyDeserialize(std::shared_ptr< SceneLoadPlan > plan)
Replaces the scene contents with a prepared plan.
bool suppressNextComponentSearch
Suppresses the quick search popup for catalog-driven placement.
void setCircuit(std::shared_ptr< Circuit > newCircuit)
Replaces the derived topology cache.
std::map< uint64_t, WireManager::SegmentTopology > mixedDragTopologyBefore
void applyWireRouteChanges(std::span< const WireRouteChange > changes, bool useAfter, const WireEndpointEdit &endpointEdit={})
Applies recorded wire routes and rebuilds connectivity.
void removeItems(const std::vector< QGraphicsItem * > &sceneItems)
Removes the given scene items and refreshes the logical topology.
void setDocumentStore(const SILICON::project::DocumentStore *documents) noexcept
DocumentNavigator * documentNavigator
void updateComponentDrag()
Previews component moves and restores the last valid positions if routing fails.
InteractionMode currentInteractionMode
Current interaction mode.
std::string lastPlacedComponentType
Last placed component type for repeat placement.
void requestConnectionsRefresh()
Marks connections dirty and schedules one refresh on the event loop.
struct SILICON::ui::DiagramScene::ComponentDragState componentDrag
void keyPressEvent(QKeyEvent *event) override
Handles key presses for mode changes.
std::shared_ptr< SceneLoadPlan > prepareDeserialize(const std::string &jsonStr, GUIComponentFactory &guiFactory, const ComponentRegistry &coreRegistry)
Deserializes a scene payload into a detached plan.
void setSubcircuitDocumentMode(bool enabled)
Enables reusable-circuit boundary I/O editing for the scene.
bool removeSelection(const nlohmann::json &payload)
Removes items matching a serialized selection payload from the current scene.
void refreshConnections()
Rebuilds the connection report, logical bindings, and visual error markers.
void updateWireDrag(GraphicalWireSegment *segment, QPointF scenePos)
Previews the active segment drag at the given scene position.
void modeChanged(InteractionMode mode)
Emitted when the interaction mode changes.
std::string serialize() const
Serializes the full editor scene to JSON.
void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent) override
Handles mouse movement for wire/component dragging.
void unregisterGraphicalItem(GraphicalItem *item)
struct SILICON::ui::DiagramScene::ComponentResizeTransaction componentResize
std::vector< MixedDragItem > mixedDrag
void cancelComponentDrag()
Restores original component positions and wire geometry.
std::string lastInputOrientation
Last user-edited orientations, kept only for this editor session.
GraphicalComponent * getComponentToBeDrawn() const
Gets the component currently being placed.
DocumentNavigator * getDocumentNavigator() const noexcept
std::unordered_map< uint64_t, GraphicalItem * > itemsByUiId
O(1) lookup table for runtime graphical items by stable UI id.
void updateComponentResize(QPointF scenePos)
void waveformTraceReset(QStringList signalNames, int inputCount, QList< int > signalWidths)
Emitted when interactive waveform signals should be rebuilt.
bool isDraggingComponent(const GraphicalComponent *component) const
Returns whether the component participates in an active component or mixed drag.
void applyRoutingPreview(const std::vector< RoutedSegment > &routes, RouteEditState &state)
Applies preview routes while recording original geometry in the edit state.
void setComponentShadow()
Shows the component shadow at cursor position.
void deserialize(const std::string &jsonStr, GUIComponentFactory &guiFactory, const ComponentRegistry &coreRegistry)
Deserializes a full scene from JSON.
void initializeSceneBounds(qreal expansionStep)
const CircuitResolver * resolver
bool ioInteractionsEnabled
Whether simulation-mode IO clicks may mutate input state.
void clearComponentShadow()
Clears the component shadow.
bool isSubcircuitDocumentMode() const
Returns true when subcircuit-only graphical tools may be placed.
void setItemCollisionChecksEnabled(bool enabled)
nlohmann::ordered_json serializeSelection() const
Serializes the selected components and wire segments for clipboard use.
std::unordered_map< const GraphicalComponent *, std::unordered_set< const GraphicalWire * > > mixedDragAttachedWires
WireEndpointEdit finishMixedDrag()
Commits a mixed selection drag and returns topology and net changes for undo.
GraphicalWireSegment * wireSegmentToBeDrawn
Wire segment being drawn.
void drawForeground(QPainter *painter, const QRectF &rect) override
Draws helper items on the scene foreground.
void rememberIoPlacementOrientation(const Component &component)
Remembers a user IO orientation edit for subsequent placements.
GraphicalItem * findGraphicalItemByUiId(uint64_t uiId) const
void setDocumentCircuit(std::shared_ptr< Circuit > newCircuit)
Installs an authoritative circuit.
bool beginComponentResize(GraphicalComponent *component, ResizeHandle handle, QPointF scenePos)
void finishWireDrag(GraphicalWireSegment *segment)
Commits the active segment drag and records its undo command.
bool isWireCreationInProgress() const
Returns whether a wire currently has a starting endpoint and is being routed.
DiagramScene(QObject *parent=nullptr)
Constructs a diagram scene.
const SILICON::project::DocumentStore * documentStore() const noexcept
void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent) override
Handles mouse press for wire drawing and component placement.
ComponentSearchBox * csb
Component search box.
ConnectionReport connectionReport
InteractionMode getInteractionMode() const
Gets the current interaction mode.
void expandSceneBounds(const QRectF &bounds)
Grows the workspace in quantized steps to include scene coordinates.
std::shared_ptr< Circuit > getCircuit() const
QPointF resolveWireTarget(QPointF scenePoint) const
Resolves a scene position to a nearby port, wire, or grid point.
InteractionMode
Operating modes for the diagram scene.
void cancelMixedDrag()
Restores original item positions and clears the mixed drag state.
void mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent) override
bool isWireAttachedToDraggedComponent(const GraphicalComponent *component, const GraphicalWire *wire) const
Returns whether a wire was attached to the component when its drag began.
void simulateEditedWaveform(qulonglong duration, std::vector< Sample > inputSnapshots)
Simulates the circuit using an edited input waveform.
bool subcircuitDocumentMode
Whether reusable-circuit boundary I/O editing is enabled.
PropertyMap lastPlacedComponentProperties
Initial properties used when repeating placement of the last type.
bool isItemCollisionEnabled
Disabled while applying batch layouts that must not be rejected mid-move.
bool insertSelection(const nlohmann::json &payload, GUIComponentFactory &guiFactory, const ComponentRegistry &coreRegistry, QPointF targetOrigin, bool isPaste=false)
Inserts a clipboard selection payload into the current scene.
void drawBackground(QPainter *painter, const QRectF &rect) override
Draws the background grid.
static QPoint snapToGrid(QPointF point)
Snaps a point to the grid.
void beginMixedDrag()
Captures item positions, attached wires, and topology for a mixed selection drag.
void beginComponentDrag()
Captures selected component positions, attached wires, and routing geometry.
void cancelWireDrag()
Restores original wire routes and clears the active wire drag.
void autoPlaceCircuit()
Automatically places components and reroutes wires.
void waveformTraceSnapshots(QList< QPair< qulonglong, std::vector< BusValue > > > snapshots)
Emitted when a completed simulation job produced multiple waveform states.
void setInteractionMode(InteractionMode mode)
Sets the interaction mode.
bool isDraggingWire(const GraphicalWireSegment *segment) const
Returns whether the segment owns the active wire drag.
void setCircuitResolver(const CircuitResolver *resolver) noexcept
Factory for creating graphical circuit components.
Base class for graphical circuit components.
Base class for all graphical items in the diagram.
The visible, selectable polyline wire on the diagram scene.
Logical wire entity that groups segments sharing the same bus.
Represents a connection point on a component.
Scene payload deserialized ahead of time, detached from the host scene.
std::unordered_map< std::string, PropertyValue, TransparentStringHash, TransparentStringEqual > PropertyMap
Map from property names to their values.
std::weak_ptr< Component > Component_weakPtr
Definition wire.hpp:52
std::vector< State > BusValue
Definition wire.hpp:120
constexpr int GRID_SIZE
Definition grid.hpp:27
DiagramScene::InteractionMode InteractionMode
Alias for DiagramScene::InteractionMode.
bool valid() const
Returns whether every net in the report has no connection error.
std::vector< NetConnection > nets
std::unique_ptr< InteractiveWireRouter > router
std::vector< std::pair< GraphicalComponent *, QPointF > > initialPositions
std::unordered_map< const GraphicalComponent *, std::unordered_set< const GraphicalWire * > > attachedWires
std::vector< std::pair< GraphicalComponent *, QPointF > > validPositions
void cancel()
Cancels pending edits and restores original segment routes.
void commit(WireManager &manager)
Commits pending segment edits as a batch and rebuilds changed topology.
std::vector< WireRouteChange > changes(const DiagramScene &scene) const
Returns before and after snapshots for routes changed during the gesture.
std::vector< std::pair< uint64_t, std::vector< QPointF > > > originals
std::map< uint64_t, WireEndpointEdit::NetState > netBefore
void remember(WireManager &manager, GraphicalWireSegment *segment)
Records a segment's original route and creates its preview edit once.
void captureContacts(const DiagramScene &scene)
Captures existing endpoint contacts, topology, and net identities for the gesture.
std::map< uint64_t, WireManager::SegmentTopology > topologyBefore
std::vector< std::unique_ptr< WireManager::Edit > > edits
std::unique_ptr< InteractiveWireRouter > router
bool isValid() const
Returns whether this net has no connection error.
std::optional< QString > error
std::vector< Port * > affectedPorts