|
SILICON
|
Handles DiagramScene persistence, clipboard payloads, and reconstruction. More...
#include <diagramSceneSerializer.hpp>
Public Member Functions | |
| DiagramSceneSerializer (DiagramScene &scene) | |
| Constructs a serializer bound to a scene. | |
| std::string | serialize () const |
| Serializes the full editor scene to the persisted JSON format. | |
| nlohmann::ordered_json | serializeSelection () const |
| Serializes the current selection to the clipboard payload format. | |
| nlohmann::ordered_json | serializeItems (const std::vector< QGraphicsItem * > &sceneItems) const |
| Serializes arbitrary scene items using the selection payload format. | |
| void | deserialize (const std::string &jsonStr, GUIComponentFactory &guiFactory, const ComponentRegistry &coreRegistry) |
| Deserializes a full scene from persisted JSON. | |
| std::shared_ptr< SceneLoadPlan > | prepareDeserialize (const std::string &jsonStr, GUIComponentFactory &guiFactory, const ComponentRegistry &coreRegistry) |
| Parses a scene payload without touching the host scene. | |
| void | applyDeserialize (std::shared_ptr< SceneLoadPlan > plan) |
| Replaces the host scene with a plan built by prepareDeserialize. | |
| 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) |
| Inserts a serialized selection payload into the current scene. | |
| bool | removeSelection (const nlohmann::json &payload) |
| Removes items matching a serialized selection payload from the scene. | |
Private Attributes | |
| DiagramScene & | scene |
| Host scene whose items and lookup tables back serialization operations. | |
Handles DiagramScene persistence, clipboard payloads, and reconstruction.
This helper encapsulates the JSON formats used by the editor for full-scene saves, clipboard selections, undo payloads, and scene reconstruction. It keeps the payload semantics identical to the original DiagramScene implementation while moving the serialization concern out of the scene coordinator.
Definition at line 51 of file diagramSceneSerializer.hpp.
|
explicit |
Constructs a serializer bound to a scene.
| scene | Host scene whose items and topology are serialized |
Definition at line 352 of file diagramSceneSerializer.cpp.
| void applyDeserialize | ( | std::shared_ptr< SceneLoadPlan > | plan | ) |
Replaces the host scene with a plan built by prepareDeserialize.
This is the only step that clears the scene, so callers can validate a document before committing to it.
| plan | Plan produced by prepareDeserialize, consumed by this call |
Definition at line 535 of file diagramSceneSerializer.cpp.
| void deserialize | ( | const std::string & | jsonStr, |
| GUIComponentFactory & | guiFactory, | ||
| const ComponentRegistry & | coreRegistry ) |
Deserializes a full scene from persisted JSON.
| jsonStr | JSON string to load |
| guiFactory | Factory for graphical component construction |
| coreRegistry | Registry for core component construction |
Definition at line 499 of file diagramSceneSerializer.cpp.
| bool insertSelection | ( | const nlohmann::json & | payload, |
| GUIComponentFactory & | guiFactory, | ||
| const ComponentRegistry & | coreRegistry, | ||
| QPointF | targetOrigin, | ||
| bool | isPaste ) |
Inserts a serialized selection payload into the current scene.
| payload | Decoded clipboard or undo payload |
| guiFactory | Factory for graphical component construction |
| coreRegistry | Registry for core component construction |
| targetOrigin | Scene position where the payload origin should land |
| isPaste | True when the payload comes from paste and needs fresh runtime ids |
Definition at line 591 of file diagramSceneSerializer.cpp.
| void loadCircuit | ( | std::shared_ptr< Circuit > | circuit, |
| GUIComponentFactory & | guiFactory, | ||
| bool | resolveSubcircuitMetadata = true ) |
Builds an autoplaced graphical scene around an already-created core circuit.
Definition at line 566 of file diagramSceneSerializer.cpp.
|
nodiscard |
Parses a scene payload without touching the host scene.
Every operation that can fail on an invalid payload happens here: the JSON is parsed, the logical circuit is deserialized, and the graphical items are built detached from the scene. The returned plan can therefore be discarded, leaving the current drawing untouched.
| jsonStr | JSON string to load |
| guiFactory | Factory for graphical component construction |
| coreRegistry | Registry for core component construction |
| std::exception | when the payload cannot be deserialized |
Definition at line 507 of file diagramSceneSerializer.cpp.
| bool removeSelection | ( | const nlohmann::json & | payload | ) |
Removes items matching a serialized selection payload from the scene.
| payload | Serialized selection payload |
Definition at line 638 of file diagramSceneSerializer.cpp.
|
nodiscard |
Serializes the full editor scene to the persisted JSON format.
Definition at line 354 of file diagramSceneSerializer.cpp.
|
nodiscard |
Serializes arbitrary scene items using the selection payload format.
| sceneItems | Items to serialize |
Definition at line 415 of file diagramSceneSerializer.cpp.
|
nodiscard |
Serializes the current selection to the clipboard payload format.
Definition at line 410 of file diagramSceneSerializer.cpp.
|
private |
Host scene whose items and lookup tables back serialization operations.
Definition at line 142 of file diagramSceneSerializer.hpp.