10#include <QCoreApplication>
19 GraphicElement *
findElm(Scene *scene,
const int id);
20 Connection *
findConn(Scene *scene,
const int id);
21 const QList<GraphicElement *>
findElements(Scene *scene,
const QList<int> &ids);
22 const QList<QGraphicsItem *>
findItems(Scene *scene,
const QList<int> &ids);
25 const QList<QGraphicsItem *>
loadItems(Scene *scene, QByteArray &itemData,
const QList<int> &ids, QList<int> &otherIds);
26 const QList<QGraphicsItem *>
loadList(
const QList<QGraphicsItem *> &items, QList<int> &ids, QList<int> &otherIds);
27 void saveItems(Scene *scene, QByteArray &itemData,
const QList<QGraphicsItem *> &items,
const QList<int> &otherIds);
30 void addItems(Scene *scene,
const QList<QGraphicsItem *> &items);
31 void deleteItems(Scene *scene,
const QList<QGraphicsItem *> &items);
35 bool isInput, QDataStream &stream, Scene *scene);
38 void storeIds(
const QList<QGraphicsItem *> &items, QList<int> &ids);
39 void storeOtherIds(
const QList<QGraphicsItem *> &connections,
const QList<int> &ids, QList<int> &otherIds);
56 QList<GraphicElement *>
elements()
const;
77 explicit AddItemsCommand(
const QList<QGraphicsItem *> &items,
Scene *scene, QUndoCommand *parent =
nullptr);
87 QByteArray m_itemData;
89 QList<int> m_otherIds;
108 explicit DeleteItemsCommand(
const QList<QGraphicsItem *> &items,
Scene *scene, QUndoCommand *parent =
nullptr);
111 void redo()
override;
114 void undo()
override;
118 QByteArray m_itemData;
120 QList<int> m_otherIds;
140 explicit RotateCommand(
const QList<GraphicElement *> &items,
const int angle,
Scene *scene, QUndoCommand *parent =
nullptr);
143 void redo()
override;
146 void undo()
override;
152 QList<QPointF> m_positions;
171 explicit MoveCommand(
const QList<GraphicElement *> &list,
const QList<QPointF> &oldPositions,
Scene *scene, QUndoCommand *parent =
nullptr);
174 void redo()
override;
177 void undo()
override;
181 QList<QPointF> m_newPositions;
182 QList<QPointF> m_oldPositions;
204 explicit UpdateCommand(
const QList<GraphicElement *> &
elements,
const QByteArray &oldData,
Scene *scene, QUndoCommand *parent =
nullptr);
207 void redo()
override;
210 void undo()
override;
214 void loadData(QByteArray &itemData);
218 struct WirelessState {
224 QVector<WirelessState> snapshotWirelessState()
const;
227 static bool wirelessStateDiffers(
const QVector<WirelessState> &before,
228 const QVector<WirelessState> &after);
233 void refreshRuntimeState();
236 QByteArray m_newData;
237 QByteArray m_oldData;
242 bool m_wirelessTopologyChange =
false;
264 void undo()
override;
267 void redo()
override;
300 void redo()
override;
303 void undo()
override;
309 struct DeletedConnectionInfo {
311 int morphedElementId;
322 void transferConnections(
const QList<GraphicElement *> &from,
const QList<GraphicElement *> &to,
323 QList<DeletedConnectionInfo> *deleted =
nullptr);
333 bool isInput, QList<DeletedConnectionInfo> *deleted);
338 void restoreDeletedConnections(
const QList<DeletedConnectionInfo> &deleted);
342 QList<ElementType> m_types;
343 QList<DeletedConnectionInfo> m_deletedConnections;
344 QList<DeletedConnectionInfo> m_deletedConnectionsOnUndo;
367 void redo()
override;
370 void undo()
override;
374 QByteArray m_oldData;
396 explicit FlipCommand(
const QList<GraphicElement *> &items,
const int axis,
Scene *scene, QUndoCommand *parent =
nullptr);
399 void redo()
override;
402 void undo()
override;
406 QList<QPointF> m_positions;
431 void redo()
override;
434 void undo()
override;
456 void redo()
override;
457 void undo()
override;
480 void redo()
override;
481 void undo()
override;
502 RenameBlobCommand(
const QString &oldName,
const QString &newName,
Scene *scene, QUndoCommand *parent =
nullptr);
504 void redo()
override;
505 void undo()
override;
535 const QList<ConnectionInfo> &connections,
Scene *scene, QUndoCommand *parent =
nullptr);
538 static QList<ConnectionInfo>
captureConnections(
const QList<GraphicElement *> &targets);
541 void setOldBlob(
const QByteArray &blob) { m_oldBlob = blob; }
546 void redo()
override;
547 void undo()
override;
550 void loadData(QByteArray &itemData);
551 void reconnectConnections();
553 QByteArray m_oldData;
554 QByteArray m_newData;
555 QByteArray m_oldBlob;
556 QByteArray m_newBlob;
558 QList<ConnectionInfo> m_connections;
Enums::ElementType ElementType
Enums::WirelessMode WirelessMode
Abstract base class for all graphical circuit elements.
Main circuit editing scene with undo/redo and user interaction.
void undo() override
Removes the items from the scene.
void redo() override
Adds the items to the scene.
AddItemsCommand(const QList< QGraphicsItem * > &items, Scene *scene, QUndoCommand *parent=nullptr)
Constructs the command for adding items.
void undo() override
Restores the old port count and connections.
void redo() override
Applies the new port count.
ChangePortSizeCommand(const QList< GraphicElement * > &elements, const int newPortSize, Scene *scene, const bool isInput, QUndoCommand *parent=nullptr)
Constructs the command.
A bezier-curve wire connecting an output port to an input port in the scene.
DeleteItemsCommand(const QList< QGraphicsItem * > &items, Scene *scene, QUndoCommand *parent=nullptr)
Constructs the command for deleting items.
void undo() override
Restores the items to the scene.
void redo() override
Removes the items from the scene.
ElementsCommand(const QList< GraphicElement * > &elements, Scene *scene, QUndoCommand *parent=nullptr)
QList< GraphicElement * > elements() const
Returns the live element pointers for this command's targets, looked up by stored ID.
FlipCommand(const QList< GraphicElement * > &items, const int axis, Scene *scene, QUndoCommand *parent=nullptr)
Constructs the flip command.
void redo() override
Applies the flip transformation.
void undo() override
Reverses the flip transformation (involution: flip twice = identity).
Abstract base class for all graphical circuit elements in wiRedPanda.
MorphCommand(const QList< GraphicElement * > &elements, ElementType type, Scene *scene, QUndoCommand *parent=nullptr)
Constructs the morph command.
void undo() override
Restores the original element types.
void redo() override
Replaces elements with instances of the new type.
MoveCommand(const QList< GraphicElement * > &list, const QList< QPointF > &oldPositions, Scene *scene, QUndoCommand *parent=nullptr)
Constructs the command capturing old and new positions.
void undo() override
Restores elements to their old positions.
void redo() override
Moves elements to their new positions.
RegisterBlobCommand(const QString &blobName, const QByteArray &data, Scene *scene, QUndoCommand *parent=nullptr)
RemoveBlobCommand(const QString &blobName, Scene *scene, QUndoCommand *parent=nullptr)
RenameBlobCommand(const QString &oldName, const QString &newName, Scene *scene, QUndoCommand *parent=nullptr)
void undo() override
Reverses the rotation.
void redo() override
Applies the rotation.
RotateCommand(const QList< GraphicElement * > &items, const int angle, Scene *scene, QUndoCommand *parent=nullptr)
Constructs the command.
Main circuit editing scene.
SplitCommand(Connection *conn, QPointF mousePos, Scene *scene, QUndoCommand *parent=nullptr)
Constructs the split command.
void undo() override
Removes the node and restores the original connection.
void redo() override
Inserts the node and splits the connection.
void undo() override
Toggles the bit again (involution).
void redo() override
Toggles the bit at pos.
ToggleTruthTableOutputCommand(GraphicElement *element, int pos, Scene *scene, QUndoCommand *parent=nullptr)
Constructs the toggle command.
void setBlobName(const QString &name)
Overrides the blob name (needed when elements are already file-backed at construction time).
UpdateBlobCommand(const QList< GraphicElement * > &elements, const QByteArray &oldData, const QList< ConnectionInfo > &connections, Scene *scene, QUndoCommand *parent=nullptr)
void setOldBlob(const QByteArray &blob)
Sets the old blob data for registry swap on undo.
static QList< ConnectionInfo > captureConnections(const QList< GraphicElement * > &targets)
Captures connection topology for all target elements before a blob operation.
UpdateCommand(const QList< GraphicElement * > &elements, const QByteArray &oldData, Scene *scene, QUndoCommand *parent=nullptr)
Constructs the command.
void undo() override
Restores the old property values.
void redo() override
Applies the new property values.
const QList< GraphicElement * > findElements(Scene *scene, const QList< int > &ids)
void addItems(Scene *scene, const QList< QGraphicsItem * > &items)
void saveItems(Scene *scene, QByteArray &itemData, const QList< QGraphicsItem * > &items, const QList< int > &otherIds)
GraphicElement * findElm(Scene *scene, const int id)
void storeIds(const QList< QGraphicsItem * > &items, QList< int > &ids)
const QList< QGraphicsItem * > findItems(Scene *scene, const QList< int > &ids)
Connection * findConn(Scene *scene, const int id)
const QList< QGraphicsItem * > loadItems(Scene *scene, QByteArray &itemData, const QList< int > &ids, QList< int > &otherIds)
void drainPortConnections(GraphicElement *elm, int fromPort, int toPort, bool isInput, QDataStream &stream, Scene *scene)
Saves and deletes connections on ports in range [fromPort, toPort).
const QList< QGraphicsItem * > loadList(const QList< QGraphicsItem * > &items, QList< int > &ids, QList< int > &otherIds)
void storeOtherIds(const QList< QGraphicsItem * > &connections, const QList< int > &ids, QList< int > &otherIds)
void deleteItems(Scene *scene, const QList< QGraphicsItem * > &items)