|
SILICON
|
Graphics scene for the circuit diagram editor. More...
#include <diagramScene.hpp>
Classes | |
| struct | ComponentResizeTransaction |
| struct | RouteEditState |
| struct | ComponentDragState |
| struct | MixedDragItem |
| struct | WireDragState |
Public Types | |
| enum class | InteractionMode { NORMAL_MODE , PAN_MODE , WIRE_CREATION_MODE , COMPONENT_PLACING_MODE , SIMULATION_MODE } |
| Operating modes for the diagram scene. More... | |
Public Slots | |
| void | hideCSB () |
| Hides the component search box. | |
| void | handleInputToggled (Bus targetBus, BusValue value, Component_weakPtr source) |
| Handles input toggle events from GraphicalInput components. | |
| bool | calculateWiresForComponents () |
| const ConnectionReport & | currentConnectionReport () |
| Returns the cached connection report, refreshing it first when dirty. | |
| void | requestConnectionsRefresh () |
| Marks connections dirty and schedules one refresh on the event loop. | |
| void | refreshConnections () |
| Rebuilds the connection report, logical bindings, and visual error markers. | |
Signals | |
| void | componentResized () |
| void | logsClearRequested () |
| void | modeChanged (InteractionMode mode) |
| Emitted when the interaction mode changes. | |
| void | waveformTraceReset (QStringList signalNames, int inputCount, QList< int > signalWidths) |
| Emitted when interactive waveform signals should be rebuilt. | |
| void | waveformTraceSnapshots (QList< QPair< qulonglong, std::vector< BusValue > > > snapshots) |
| Emitted when a completed simulation job produced multiple waveform states. | |
Public Member Functions | |
| DiagramScene (QObject *parent=nullptr) | |
| Constructs a diagram scene. | |
| void | expandSceneBounds (const QRectF &bounds) |
| Grows the workspace in quantized steps to include scene coordinates. | |
| void | setDocumentStore (const SILICON::project::DocumentStore *documents) noexcept |
| const SILICON::project::DocumentStore * | documentStore () const noexcept |
| void | setCircuitResolver (const CircuitResolver *resolver) noexcept |
| const CircuitResolver * | circuitResolver () const noexcept |
| void | setUndoStack (QUndoStack *stack) noexcept |
| void | setDocumentNavigator (DocumentNavigator *navigator) noexcept |
| DocumentNavigator * | getDocumentNavigator () const noexcept |
| void | setInteractionMode (InteractionMode mode) |
| Sets the interaction mode. | |
| bool | cancelCurrentInteraction () |
| Cancels the active transient interaction, returning to normal editing. | |
| bool | beginComponentResize (GraphicalComponent *component, ResizeHandle handle, QPointF scenePos) |
| void | updateComponentResize (QPointF scenePos) |
| void | finishComponentResize () |
| void | cancelComponentResize () |
| bool | isResizingComponent () const |
| InteractionMode | getInteractionMode () const |
| Gets the current interaction mode. | |
| GraphicalComponent * | getComponentToBeDrawn () const |
| Gets the component currently being placed. | |
| bool | isWireCreationInProgress () const |
| Returns whether a wire currently has a starting endpoint and is being routed. | |
| void | showCSB (QPointF pos) |
| Shows the component search box at a position. | |
| void | clearWireShadow () |
| Clears the wire being drawn. | |
| void | setComponentShadow () |
| Shows the component shadow at cursor position. | |
| void | clearComponentShadow () |
| Clears the component shadow. | |
| void | addComponent (GraphicalComponent *component, QPointF pos) |
| Adds a component to the scene. | |
| void | placeComponent (std::string_view typeName, bool showSearchBox=true, const PropertyMap &initialProperties={}) |
| Begins placing a component and applies its initial properties first. | |
| void | rememberIoPlacementOrientation (const Component &component) |
| Remembers a user IO orientation edit for subsequent placements. | |
| QUndoStack * | getUndoStack () const |
| WireManager & | getWireManager () |
| const WireManager & | getWireManager () const |
| bool | beginWireDrag (GraphicalWireSegment *segment, QPointF scenePos, QPointF localPos) |
| Starts dragging the wire handle hit at a local position. | |
| void | updateWireDrag (GraphicalWireSegment *segment, QPointF scenePos) |
| Previews the active segment drag at the given scene position. | |
| void | finishWireDrag (GraphicalWireSegment *segment) |
| Commits the active segment drag and records its undo command. | |
| void | cancelWireDrag () |
| Restores original wire routes and clears the active wire drag. | |
| bool | isDraggingWire (const GraphicalWireSegment *segment) const |
| Returns whether the segment owns the active wire drag. | |
| std::vector< WireRouteChange > | finishComponentDrag () |
| Commits the component gesture and returns its before and after wire routes. | |
| void | applyWireRouteChanges (std::span< const WireRouteChange > changes, bool useAfter, const WireEndpointEdit &endpointEdit={}) |
| Applies recorded wire routes and rebuilds connectivity. | |
| 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. | |
| std::shared_ptr< Circuit > | getCircuit () const |
| void | setCircuit (std::shared_ptr< Circuit > newCircuit) |
| Replaces the derived topology cache. | |
| void | setDocumentCircuit (std::shared_ptr< Circuit > newCircuit) |
| Installs an authoritative circuit. | |
| void | setIoInteractionsEnabled (bool enabled) |
| Enables or disables user-triggered IO interactions in simulation mode. | |
| void | setSubcircuitDocumentMode (bool enabled) |
| Enables reusable-circuit boundary I/O editing for the scene. | |
| bool | isSubcircuitDocumentMode () const |
| Returns true when subcircuit-only graphical tools may be placed. | |
| std::string | serialize () const |
| Serializes the full editor scene to JSON. | |
| nlohmann::ordered_json | serializeSelection () const |
| Serializes the selected components and wire segments for clipboard use. | |
| nlohmann::ordered_json | serializeItems (const std::vector< QGraphicsItem * > &sceneItems) const |
| Serializes arbitrary scene items using the internal selection payload format. | |
| GraphicalItem * | findGraphicalItemByUiId (uint64_t uiId) const |
| void | registerGraphicalItem (GraphicalItem *item) |
| void | unregisterGraphicalItem (GraphicalItem *item) |
| bool | itemCollisionChecksEnabled () const |
| void | setItemCollisionChecksEnabled (bool enabled) |
| bool | isDraggingComponent (const GraphicalComponent *component) const |
| Returns whether the component participates in an active component or mixed drag. | |
| bool | isWireAttachedToDraggedComponent (const GraphicalComponent *component, const GraphicalWire *wire) const |
| Returns whether a wire was attached to the component when its drag began. | |
| bool | hasWireGroupSelection () const |
| Returns whether the selection includes a wire and a component, or multiple wires. | |
| WireEndpointEdit | finishMixedDrag () |
| Commits a mixed selection drag and returns topology and net changes for undo. | |
| void | deserialize (const std::string &jsonStr, GUIComponentFactory &guiFactory, const ComponentRegistry &coreRegistry) |
| Deserializes a full scene from JSON. | |
| std::shared_ptr< SceneLoadPlan > | prepareDeserialize (const std::string &jsonStr, GUIComponentFactory &guiFactory, const ComponentRegistry &coreRegistry) |
| Deserializes a scene payload into a detached plan. | |
| void | applyDeserialize (std::shared_ptr< SceneLoadPlan > plan) |
| Replaces the scene contents with a prepared plan. | |
| void | loadCircuit (std::shared_ptr< Circuit > circuit, GUIComponentFactory &guiFactory, bool resolveSubcircuitMetadata=true) |
| 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 | removeItems (const std::vector< QGraphicsItem * > &sceneItems) |
| Removes the given scene items and refreshes the logical topology. | |
| void | autoPlaceCircuit () |
| Automatically places components and reroutes wires. | |
| bool | removeSelection (const nlohmann::json &payload) |
| Removes items matching a serialized selection payload from the current scene. | |
| void | clear (bool clearUndoStack=true, bool clearLogs=true) |
| void | updateSceneAfterEdit () |
| void | setFstTraceFile (std::optional< std::string > fileName) |
| Enables or disables simulation FST tracing. | |
| bool | isFstTracingEnabled () const |
| void | simulateEditedWaveform (qulonglong duration, std::vector< Sample > inputSnapshots) |
| Simulates the circuit using an edited input waveform. | |
| ~DiagramScene () override | |
Static Public Member Functions | |
| static QPoint | snapToGrid (QPointF point) |
| Snaps a point to the grid. | |
| static int | snapToGrid (qreal value) |
| Snaps one scene coordinate to the grid. | |
Static Public Attributes | |
| static constexpr int | GRID_SIZE = SILICON::ui::GRID_SIZE |
| Grid cell size in scene units. | |
Private Member Functions | |
| void | drawBackground (QPainter *painter, const QRectF &rect) override |
| Draws the background grid. | |
| void | drawForeground (QPainter *painter, const QRectF &rect) override |
| Draws helper items on the scene foreground. | |
| void | initializeSceneBounds (qreal expansionStep) |
| void | setInteractionMode (InteractionMode newMode, bool force) |
| Internal method to set mode with force option. | |
| bool | isWireCompletionPoint (QPointF scenePoint) const |
| Lifecycle helper methods for interaction modes. | |
| void | updateWirePreview (QPointF scenePoint) |
| Updates the route preview for the wire being drawn toward a scene position. | |
| void | finalizeWireCreation () |
| void | enterComponentPlacingMode () |
| void | exitComponentPlacingMode () |
| bool | enterSimulationMode () |
| void | exitSimulationMode () |
| void | mouseMoveEvent (QGraphicsSceneMouseEvent *mouseEvent) override |
| Handles mouse movement for wire/component dragging. | |
| void | mousePressEvent (QGraphicsSceneMouseEvent *mouseEvent) override |
| Handles mouse press for wire drawing and component placement. | |
| void | mouseReleaseEvent (QGraphicsSceneMouseEvent *mouseEvent) override |
| void | keyPressEvent (QKeyEvent *event) override |
| Handles key presses for mode changes. | |
| NetConnection | inspectConnection (const std::vector< GraphicalWire * > &wires) const |
| Inspects the combined wire group for width and driver compatibility. | |
| std::unique_ptr< InteractiveWireRouter > | makeInteractiveRouter () const |
| Creates a router snapshot from current components, routes, and electrical vertices. | |
| QPointF | resolveWireTarget (QPointF scenePoint) const |
| Resolves a scene position to a nearby port, wire, or grid point. | |
| void | beginComponentDrag () |
| Captures selected component positions, attached wires, and routing geometry. | |
| void | updateComponentDrag () |
| Previews component moves and restores the last valid positions if routing fails. | |
| void | cancelComponentDrag () |
| Restores original component positions and wire geometry. | |
| void | beginMixedDrag () |
| Captures item positions, attached wires, and topology for a mixed selection drag. | |
| void | updateMixedDrag () |
| Validates mixed selection movement and retains the last valid positions. | |
| void | cancelMixedDrag () |
| Restores original item positions and clears the mixed drag state. | |
| void | applyRoutingPreview (const std::vector< RoutedSegment > &routes, RouteEditState &state) |
| Applies preview routes while recording original geometry in the edit state. | |
Private Attributes | |
| qreal | sceneExpansionStep = 0 |
| InteractionMode | currentInteractionMode = InteractionMode::NORMAL_MODE |
| Current interaction mode. | |
| bool | ioInteractionsEnabled = true |
| Whether simulation-mode IO clicks may mutate input state. | |
| bool | subcircuitDocumentMode = false |
| Whether reusable-circuit boundary I/O editing is enabled. | |
| const SILICON::project::DocumentStore * | documents = nullptr |
| const CircuitResolver * | resolver = nullptr |
| QUndoStack * | undoStack = nullptr |
| DocumentNavigator * | documentNavigator = nullptr |
| struct SILICON::ui::DiagramScene::ComponentResizeTransaction | componentResize |
| GraphicalComponent * | componentToBeDrawn = nullptr |
| Component being placed (shadow). | |
| std::string | lastInputOrientation = "RIGHT" |
| Last user-edited orientations, kept only for this editor session. | |
| std::string | lastOutputOrientation = "LEFT" |
| bool | suppressNextComponentSearch = false |
| Suppresses the quick search popup for catalog-driven placement. | |
| GraphicalWireSegment * | wireSegmentToBeDrawn = nullptr |
| Wire segment being drawn. | |
| bool | wirePreviewRouteValid = true |
| ComponentSearchBox * | csb = nullptr |
| Component search box. | |
| WireManager | wireManager |
| Wire manager for wire topology. | |
| ConnectionReport | connectionReport |
| bool | connectionReportDirty = true |
| bool | refreshingConnections = false |
| bool | connectionRefreshScheduled = false |
| struct SILICON::ui::DiagramScene::ComponentDragState | componentDrag |
| std::vector< MixedDragItem > | mixedDrag |
| std::unordered_map< const GraphicalComponent *, std::unordered_set< const GraphicalWire * > > | mixedDragAttachedWires |
| std::map< uint64_t, WireManager::SegmentTopology > | mixedDragTopologyBefore |
| std::map< uint64_t, WireEndpointEdit::NetState > | mixedDragNetBefore |
| struct SILICON::ui::DiagramScene::WireDragState | wireDrag |
| std::string | lastPlacedComponentType |
| Last placed component type for repeat placement. | |
| PropertyMap | lastPlacedComponentProperties |
| Initial properties used when repeating placement of the last type. | |
| std::shared_ptr< Circuit > | circuit |
| Underlying logic circuit model. | |
| std::unordered_map< uint64_t, GraphicalItem * > | itemsByUiId |
| O(1) lookup table for runtime graphical items by stable UI id. | |
| std::unique_ptr< DiagramSceneSimulationController > | simulationController |
| Simulation lifecycle and trace management. | |
| std::unique_ptr< DiagramSceneSerializer > | serializer |
| Persistence and clipboard payload handling. | |
| bool | isItemCollisionEnabled = true |
| Disabled while applying batch layouts that must not be rejected mid-move. | |
Graphics scene for the circuit diagram editor.
DiagramScene extends QGraphicsScene to provide an interactive circuit diagram editor. It manages component placement, wire drawing, and various interaction modes for editing and simulation.
The scene integrates with WireManager for wire topology and uses ComponentSearchBox (CSB) for component selection. It maintains an underlying Circuit model and uses a Simulator for logic simulation.
Definition at line 118 of file diagramScene.hpp.
|
strong |
Operating modes for the diagram scene.
Definition at line 125 of file diagramScene.hpp.
|
explicit |
Constructs a diagram scene.
| parent | Optional parent object |
Definition at line 104 of file diagramScene.cpp.
|
override |
Definition at line 2086 of file diagramScene.cpp.
| void addComponent | ( | GraphicalComponent * | component, |
| QPointF | pos ) |
Adds a component to the scene.
| component | The component to add |
| pos | Position to place the component |
Definition at line 1810 of file diagramScene.cpp.
| void applyDeserialize | ( | std::shared_ptr< SceneLoadPlan > | plan | ) |
Replaces the scene contents with a prepared plan.
| plan | Plan produced by prepareDeserialize, consumed by this call |
Definition at line 1980 of file diagramScene.cpp.
| 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.
| moves | Before and after snapshots to apply. |
| wires | Wire route snapshots accompanying the item moves. |
| useAfter | True applies the after state; false applies the before state. |
| topology | Reserved topology snapshot; currently unused. |
Definition at line 940 of file diagramScene.cpp.
|
private |
Applies preview routes while recording original geometry in the edit state.
Definition at line 408 of file diagramScene.cpp.
| void applyWireRouteChanges | ( | std::span< const WireRouteChange > | changes, |
| bool | useAfter, | ||
| const WireEndpointEdit & | endpointEdit = {} ) |
Applies recorded wire routes and rebuilds connectivity.
| changes | Before and after snapshots to apply. |
| useAfter | True applies the after state; false applies the before state. |
| endpointEdit | Reserved topology snapshot; currently unused. |
Definition at line 922 of file diagramScene.cpp.
| void autoPlaceCircuit | ( | ) |
Automatically places components and reroutes wires.
The scene preserves its authoritative logical circuit when available, computes component positions with OGDF, and replaces WireManager's graphical wire segments with libavoid-routed paths carrying the original buses. The complete candidate set is compared while a cancellable progress dialog is shown.
Definition at line 1816 of file diagramScene.cpp.
|
private |
Captures selected component positions, attached wires, and routing geometry.
Definition at line 537 of file diagramScene.cpp.
| bool beginComponentResize | ( | GraphicalComponent * | component, |
| ResizeHandle | handle, | ||
| QPointF | scenePos ) |
Shared resize transaction; component hooks supply the property changes.
Definition at line 1043 of file diagramScene.cpp.
|
private |
Captures item positions, attached wires, and topology for a mixed selection drag.
Definition at line 664 of file diagramScene.cpp.
| bool beginWireDrag | ( | GraphicalWireSegment * | segment, |
| QPointF | scenePos, | ||
| QPointF | localPos ) |
Starts dragging the wire handle hit at a local position.
| segment | Segment whose handle is being dragged. |
| scenePos | Initial mouse position in scene coordinates. |
| localPos | Hit-test position in segment coordinates. |
Definition at line 785 of file diagramScene.cpp.
|
nodiscardslot |
Returns the validity of the live scene connection report.
Definition at line 1805 of file diagramScene.cpp.
|
private |
Restores original component positions and wire geometry.
Definition at line 638 of file diagramScene.cpp.
| void cancelComponentResize | ( | ) |
Definition at line 1115 of file diagramScene.cpp.
| bool cancelCurrentInteraction | ( | ) |
Cancels the active transient interaction, returning to normal editing.
Definition at line 1123 of file diagramScene.cpp.
|
private |
Restores original item positions and clears the mixed drag state.
Definition at line 770 of file diagramScene.cpp.
| void cancelWireDrag | ( | ) |
Restores original wire routes and clears the active wire drag.
Definition at line 916 of file diagramScene.cpp.
|
nodiscardnoexcept |
Definition at line 181 of file diagramScene.cpp.
| void clear | ( | bool | clearUndoStack = true, |
| bool | clearLogs = true ) |
Definition at line 2048 of file diagramScene.cpp.
| void clearComponentShadow | ( | ) |
Clears the component shadow.
Definition at line 1587 of file diagramScene.cpp.
| void clearWireShadow | ( | ) |
Clears the wire being drawn.
Definition at line 1561 of file diagramScene.cpp.
|
signal |
|
slot |
Returns the cached connection report, refreshing it first when dirty.
Definition at line 1701 of file diagramScene.cpp.
| void deserialize | ( | const std::string & | jsonStr, |
| GUIComponentFactory & | guiFactory, | ||
| const ComponentRegistry & | coreRegistry ) |
Deserializes a full scene from JSON.
Expects the payload documented in diagramscene_serialization_format.
| jsonStr | JSON string |
| guiFactory | Factory for creating graphical components |
| coreRegistry | Registry for creating core components |
Definition at line 1965 of file diagramScene.cpp.
|
nodiscardnoexcept |
Definition at line 171 of file diagramScene.cpp.
|
overrideprivate |
Draws the background grid.
Definition at line 973 of file diagramScene.cpp.
|
overrideprivate |
Draws helper items on the scene foreground.
Definition at line 992 of file diagramScene.cpp.
|
private |
Definition at line 1310 of file diagramScene.cpp.
|
private |
Definition at line 1338 of file diagramScene.cpp.
|
private |
Definition at line 1300 of file diagramScene.cpp.
|
private |
Definition at line 1343 of file diagramScene.cpp.
| void expandSceneBounds | ( | const QRectF & | bounds | ) |
Grows the workspace in quantized steps to include scene coordinates.
Definition at line 1022 of file diagramScene.cpp.
|
private |
Definition at line 1199 of file diagramScene.cpp.
|
nodiscard |
Definition at line 2001 of file diagramScene.cpp.
|
nodiscard |
Commits the component gesture and returns its before and after wire routes.
Definition at line 620 of file diagramScene.cpp.
| void finishComponentResize | ( | ) |
Definition at line 1101 of file diagramScene.cpp.
|
nodiscard |
Commits a mixed selection drag and returns topology and net changes for undo.
Definition at line 719 of file diagramScene.cpp.
| void finishWireDrag | ( | GraphicalWireSegment * | segment | ) |
Commits the active segment drag and records its undo command.
Definition at line 846 of file diagramScene.cpp.
|
inlinenodiscard |
Definition at line 292 of file diagramScene.hpp.
|
nodiscard |
Gets the component currently being placed.
Definition at line 1556 of file diagramScene.cpp.
|
inlinenodiscardnoexcept |
Definition at line 151 of file diagramScene.hpp.
|
inlinenodiscard |
Gets the current interaction mode.
Definition at line 180 of file diagramScene.hpp.
|
inlinenodiscard |
Definition at line 253 of file diagramScene.hpp.
|
inlinenodiscard |
Definition at line 254 of file diagramScene.hpp.
|
inlinenodiscard |
Definition at line 255 of file diagramScene.hpp.
|
slot |
Handles input toggle events from GraphicalInput components.
| targetBus | The bus to update |
| value | The value to set |
| source | The component that triggered the change |
Definition at line 1613 of file diagramScene.cpp.
|
nodiscard |
Returns whether the selection includes a wire and a component, or multiple wires.
Definition at line 653 of file diagramScene.cpp.
|
slot |
Hides the component search box.
Definition at line 1607 of file diagramScene.cpp.
|
private |
Definition at line 1016 of file diagramScene.cpp.
| 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.
The payload's top-left origin is mapped to targetOrigin. Inserted items are selected and reconnected through the scene's wire topology.
The payload format is the scene-fragment clipboard form documented in serializeSelection(), derived from diagramscene_serialization_format.
| payload | Decoded clipboard payload |
| guiFactory | Factory for creating graphical components |
| coreRegistry | Registry for creating core components |
| targetOrigin | Scene position where the payload origin should be placed |
| isPaste | True iff is called by a paste action, remaps items ids |
Definition at line 1992 of file diagramScene.cpp.
|
nodiscardprivate |
Inspects the combined wire group for width and driver compatibility.
Definition at line 1696 of file diagramScene.cpp.
|
nodiscard |
Returns whether the component participates in an active component or mixed drag.
Definition at line 573 of file diagramScene.cpp.
|
nodiscard |
Returns whether the segment owns the active wire drag.
Definition at line 811 of file diagramScene.cpp.
|
nodiscard |
Definition at line 1624 of file diagramScene.cpp.
|
inlinenodiscard |
Definition at line 174 of file diagramScene.hpp.
|
inlinenodiscard |
Returns true when subcircuit-only graphical tools may be placed.
Definition at line 316 of file diagramScene.hpp.
|
nodiscard |
Returns whether a wire was attached to the component when its drag began.
Definition at line 579 of file diagramScene.cpp.
|
nodiscardprivate |
Lifecycle helper methods for interaction modes.
Definition at line 1231 of file diagramScene.cpp.
|
inlinenodiscard |
Returns whether a wire currently has a starting endpoint and is being routed.
Definition at line 195 of file diagramScene.hpp.
|
inlinenodiscard |
Definition at line 380 of file diagramScene.hpp.
|
overrideprivate |
Handles key presses for mode changes.
Definition at line 1528 of file diagramScene.cpp.
| void loadCircuit | ( | std::shared_ptr< Circuit > | circuit, |
| GUIComponentFactory & | guiFactory, | ||
| bool | resolveSubcircuitMetadata = true ) |
Replaces the scene with an autoplaced view of an existing core circuit.
Definition at line 1985 of file diagramScene.cpp.
|
signal |
|
nodiscardprivate |
Creates a router snapshot from current components, routes, and electrical vertices.
Definition at line 365 of file diagramScene.cpp.
|
signal |
Emitted when the interaction mode changes.
| mode | The new mode |
|
overrideprivate |
Handles mouse movement for wire/component dragging.
Definition at line 1348 of file diagramScene.cpp.
|
overrideprivate |
Handles mouse press for wire drawing and component placement.
Definition at line 1388 of file diagramScene.cpp.
|
overrideprivate |
Select only the clicked component or wire after its drag handling finishes.
Definition at line 1492 of file diagramScene.cpp.
| void placeComponent | ( | std::string_view | typeName, |
| bool | showSearchBox = true, | ||
| const PropertyMap & | initialProperties = {} ) |
Begins placing a component and applies its initial properties first.
| typeName | The component type name |
| showSearchBox | Whether entering placement mode should show quick search |
| initialProperties | Properties to apply to the graphical component |
Definition at line 1863 of file diagramScene.cpp.
|
nodiscard |
Deserializes a scene payload into a detached plan.
Keeps the current drawing intact when the payload is malformed: nothing is cleared and no item is added to the scene until applyDeserialize runs.
| jsonStr | JSON string to load |
| guiFactory | Factory for graphical component construction |
| coreRegistry | Registry for core component construction |
Definition at line 1973 of file diagramScene.cpp.
|
slot |
Rebuilds the connection report, logical bindings, and visual error markers.
Definition at line 1723 of file diagramScene.cpp.
| void registerGraphicalItem | ( | GraphicalItem * | item | ) |
Definition at line 1923 of file diagramScene.cpp.
| void rememberIoPlacementOrientation | ( | const Component & | component | ) |
Remembers a user IO orientation edit for subsequent placements.
Definition at line 1910 of file diagramScene.cpp.
| void removeItems | ( | const std::vector< QGraphicsItem * > & | sceneItems | ) |
Removes the given scene items and refreshes the logical topology.
Callers should pass only top-level user-editable items.
Definition at line 2008 of file diagramScene.cpp.
| bool removeSelection | ( | const nlohmann::json & | payload | ) |
Removes items matching a serialized selection payload from the current scene.
Matching is performed against the same visual serialization used for clipboard and undo operations.
| payload | Serialized selection payload |
Definition at line 2037 of file diagramScene.cpp.
|
slot |
Marks connections dirty and schedules one refresh on the event loop.
Definition at line 1708 of file diagramScene.cpp.
|
nodiscardprivate |
Resolves a scene position to a nearby port, wire, or grid point.
Definition at line 302 of file diagramScene.cpp.
|
nodiscard |
Serializes the full editor scene to JSON.
This format wraps the core logical circuit serialization from core_serialization_format and adds the visual data needed to rebuild the editor scene exactly as drawn.
The payload contains:
vertexId links each graphical logic item back to the corresponding core component vertex inside circuit. wireId keeps multiple wire segments attached to the same logical wire/bus after deserialization.
Unlike clipboard payloads, the persisted scene format does not retain runtime uiId values because they are editor-local identifiers rather than stable file data.
Definition at line 1949 of file diagramScene.cpp.
|
nodiscard |
Serializes arbitrary scene items using the internal selection payload format.
The returned object follows the clipboard payload described in serializeSelection(), which in turn is a scene-fragment variant of diagramscene_serialization_format.
| sceneItems | Items to serialize |
Definition at line 1960 of file diagramScene.cpp.
|
nodiscard |
Serializes the selected components and wire segments for clipboard use.
The returned JSON is an intermediate representation: callers choose the transport encoding, such as BSON for clipboard operations.
This payload is derived from diagramscene_serialization_format rather than being a separate file format. It keeps the same circuit plus visual split, but limits the payload to the selected fragment, adds an origin used for paste placement, and retains uiId values because clipboard, undo, and delete flows match runtime scene items by those identifiers.
Definition at line 1954 of file diagramScene.cpp.
|
inline |
Replaces the derived topology cache.
Definition at line 295 of file diagramScene.hpp.
|
noexcept |
Definition at line 176 of file diagramScene.cpp.
| void setComponentShadow | ( | ) |
Shows the component shadow at cursor position.
Definition at line 1572 of file diagramScene.cpp.
|
inline |
Installs an authoritative circuit.
Definition at line 301 of file diagramScene.hpp.
|
inlinenoexcept |
Definition at line 147 of file diagramScene.hpp.
|
noexcept |
Definition at line 165 of file diagramScene.cpp.
| void setFstTraceFile | ( | std::optional< std::string > | fileName | ) |
Enables or disables simulation FST tracing.
When enabled during simulation mode, the active simulator immediately starts writing snapshots to the configured file. When enabled before entering simulation mode, the writer is attached during simulation initialization.
Definition at line 1619 of file diagramScene.cpp.
| void setInteractionMode | ( | InteractionMode | mode | ) |
Sets the interaction mode.
| mode | The new mode |
Definition at line 1038 of file diagramScene.cpp.
|
private |
Internal method to set mode with force option.
Definition at line 1155 of file diagramScene.cpp.
|
inline |
Enables or disables user-triggered IO interactions in simulation mode.
| enabled | True to allow clicks on interactive IO components |
Definition at line 310 of file diagramScene.hpp.
|
inline |
Definition at line 381 of file diagramScene.hpp.
|
inline |
Enables reusable-circuit boundary I/O editing for the scene.
Definition at line 313 of file diagramScene.hpp.
|
inlinenoexcept |
Definition at line 146 of file diagramScene.hpp.
| void showCSB | ( | QPointF | pos | ) |
Shows the component search box at a position.
| pos | Position to show the search box |
Definition at line 1597 of file diagramScene.cpp.
| void simulateEditedWaveform | ( | qulonglong | duration, |
| std::vector< Sample > | inputSnapshots ) |
Simulates the circuit using an edited input waveform.
| duration | Total waveform duration to simulate |
| inputSnapshots | Input-only timestamped values ordered like waveform inputs |
Definition at line 1629 of file diagramScene.cpp.
|
static |
Snaps a point to the grid.
| point | The point to snap |
Definition at line 297 of file diagramScene.cpp.
|
static |
Snaps one scene coordinate to the grid.
Definition at line 292 of file diagramScene.cpp.
| void unregisterGraphicalItem | ( | GraphicalItem * | item | ) |
Definition at line 1932 of file diagramScene.cpp.
|
private |
Previews component moves and restores the last valid positions if routing fails.
Definition at line 591 of file diagramScene.cpp.
| void updateComponentResize | ( | QPointF | scenePos | ) |
Definition at line 1068 of file diagramScene.cpp.
|
private |
Validates mixed selection movement and retains the last valid positions.
Definition at line 698 of file diagramScene.cpp.
| void updateSceneAfterEdit | ( | ) |
Definition at line 2042 of file diagramScene.cpp.
| void updateWireDrag | ( | GraphicalWireSegment * | segment, |
| QPointF | scenePos ) |
Previews the active segment drag at the given scene position.
Definition at line 816 of file diagramScene.cpp.
|
private |
Updates the route preview for the wire being drawn toward a scene position.
Definition at line 1255 of file diagramScene.cpp.
|
signal |
Emitted when interactive waveform signals should be rebuilt.
| signalNames | Ordered signal labels |
| inputCount | Number of leading signals belonging to the input group |
| signalWidths | Width of each signal in bits |
|
signal |
Emitted when a completed simulation job produced multiple waveform states.
| snapshots | Ordered timestamp and signal-value snapshots |
|
private |
Underlying logic circuit model.
Definition at line 732 of file diagramScene.hpp.
|
private |
|
private |
|
private |
Component being placed (shadow).
Definition at line 623 of file diagramScene.hpp.
|
private |
Definition at line 644 of file diagramScene.hpp.
|
private |
Definition at line 641 of file diagramScene.hpp.
|
private |
Definition at line 642 of file diagramScene.hpp.
|
private |
Component search box.
Definition at line 637 of file diagramScene.hpp.
|
private |
Current interaction mode.
Definition at line 599 of file diagramScene.hpp.
|
private |
Definition at line 610 of file diagramScene.hpp.
|
private |
Definition at line 607 of file diagramScene.hpp.
|
staticconstexpr |
Grid cell size in scene units.
Definition at line 251 of file diagramScene.hpp.
|
private |
Whether simulation-mode IO clicks may mutate input state.
Definition at line 602 of file diagramScene.hpp.
|
private |
Disabled while applying batch layouts that must not be rejected mid-move.
Definition at line 745 of file diagramScene.hpp.
|
private |
O(1) lookup table for runtime graphical items by stable UI id.
Definition at line 735 of file diagramScene.hpp.
|
private |
Last user-edited orientations, kept only for this editor session.
Definition at line 626 of file diagramScene.hpp.
|
private |
Definition at line 627 of file diagramScene.hpp.
|
private |
Initial properties used when repeating placement of the last type.
Definition at line 729 of file diagramScene.hpp.
|
private |
Last placed component type for repeat placement.
Definition at line 726 of file diagramScene.hpp.
|
private |
Definition at line 709 of file diagramScene.hpp.
|
private |
Definition at line 711 of file diagramScene.hpp.
|
private |
Definition at line 713 of file diagramScene.hpp.
|
private |
Definition at line 712 of file diagramScene.hpp.
|
private |
Definition at line 643 of file diagramScene.hpp.
|
private |
Definition at line 608 of file diagramScene.hpp.
|
private |
Definition at line 561 of file diagramScene.hpp.
|
private |
Persistence and clipboard payload handling.
Definition at line 741 of file diagramScene.hpp.
|
private |
Simulation lifecycle and trace management.
Definition at line 738 of file diagramScene.hpp.
|
private |
Whether reusable-circuit boundary I/O editing is enabled.
Definition at line 605 of file diagramScene.hpp.
|
private |
Suppresses the quick search popup for catalog-driven placement.
Definition at line 630 of file diagramScene.hpp.
|
private |
Definition at line 609 of file diagramScene.hpp.
|
private |
|
private |
Wire manager for wire topology.
Definition at line 640 of file diagramScene.hpp.
|
private |
Definition at line 634 of file diagramScene.hpp.
|
private |
Wire segment being drawn.
Definition at line 633 of file diagramScene.hpp.