22#include <QUndoCommand>
28#include <nlohmann/json.hpp>
37 using namespace SILICON::core;
56 const std::vector<GraphicalWireSegment*>& segments,
58 QUndoCommand* parent =
nullptr);
76 void apply(
bool restore);
90 QUndoCommand* parent =
nullptr);
102 using ApplyFn = std::function<void(
const std::string&)>;
106 void undo()
override;
107 void redo()
override;
119 setText(
"Move Item(s)");
131 void undo()
override;
132 void redo()
override;
136 std::vector<ItemPositionChange>
moves;
155 std::vector<WireRouteChange>
changes,
157 QUndoCommand* parent =
nullptr);
160 void undo()
override;
162 void redo()
override;
175 qreal
newRotation, QUndoCommand* parent =
nullptr);
177 void undo()
override;
178 void redo()
override;
193 void undo()
override;
194 void redo()
override;
214 void undo()
override;
215 void redo()
override;
225 void apply(
bool useNewValue);
238 QUndoCommand* parent =
nullptr);
240 void undo()
override;
241 void redo()
override;
244 [[nodiscard]] nlohmann::json
payload()
const;
CallbackUndoCommand(QString text, Callback undoCallback, Callback redoCallback, QUndoCommand *parent=nullptr)
std::function< void()> Callback
Graphics scene for the circuit diagram editor.
void undo() override
Restores the wire routes from before the gesture.
WireEndpointEdit endpointEdit
void redo() override
Restores the gesture's final routes, skipping the first invocation.
std::vector< WireRouteChange > changes
EditWireRouteCommand(GraphicalWireSegment *segment, std::vector< WireRouteChange > changes, WireDragKind kind, WireEndpointEdit endpointEdit={}, QUndoCommand *parent=nullptr)
Captures an already applied wire gesture for undo and redo.
Base class for graphical circuit components.
Base class for all graphical items in the diagram.
Base class for logic-gate graphical components.
The visible, selectable polyline wire on the diagram scene.
void apply(bool useNewValue)
ModifyPropertyCommand(std::string key, QUndoCommand *parent=nullptr)
std::vector< PropertyChange > changes
void addPropertyChange(GraphicalComponent *component, const PropertyValue &oldValue, const PropertyValue &newValue)
WireEndpointEdit topologyEdit
std::vector< WireRouteChange > wireMoves
MoveItemCommand(QUndoCommand *parent=nullptr)
void addItemMove(GraphicalItem *item, const QPointF &oldPos, const QPointF &newPos)
void setTopologyEdit(WireEndpointEdit edit)
Stores topology and net snapshots accompanying the item moves.
void setWireMoves(std::vector< WireRouteChange > changes)
Stores before and after wire routes accompanying the item moves.
std::vector< ItemPositionChange > moves
ComponentResizeState before
ResizeComponentCommand(GraphicalComponent *component, ComponentResizeState before, ComponentResizeState after)
ComponentResizeState after
void apply(const ComponentResizeState &state)
RotateItemCommand(GraphicalComponent *component, qreal oldRotation, qreal newRotation, QUndoCommand *parent=nullptr)
static QByteArray encodePayload(const nlohmann::json &payload)
SceneSelectionCommand(DiagramScene *scene, const nlohmann::json &payload, Operation operation, bool skipInitialRedo=false, QUndoCommand *parent=nullptr)
static nlohmann::json decodePayload(const QByteArray &payload)
nlohmann::json payload() const
static QPointF payloadOrigin(const nlohmann::json &payload)
WireTopologyCommand(DiagramScene *scene, const std::vector< GraphicalWireSegment * > &segments, Operation operation, bool skipInitialRedo=true, QUndoCommand *parent=nullptr)
Captures segments for undoing or redoing wire addition or removal.
void undo() override
Reverses the captured wire addition or removal.
std::vector< Snapshot > snapshots
void apply(bool restore)
Restores captured segments or removes them from their original document.
void redo() override
Reapplies the operation, optionally skipping the first invocation.
std::variant< int, bool, std::string, BusValue > PropertyValue
Variant type for component properties.
std::vector< QPointF > points