1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
/*!
* \file undocommands.h
*
* All changes to a TikzDocument are done via subclasses of QUndoCommand. When a controller
* (e.g. TikzScene) gets input from the user to change the document, it will push one of
* these commands onto the TikzDocument's undo stack, which automatically calls the redo()
* method of the command.
*/
#ifndef UNDOCOMMANDS_H
#define UNDOCOMMANDS_H
#include "tikzscene.h"
#include <QUndoCommand>
class MoveCommand : public QUndoCommand
{
public:
explicit MoveCommand(TikzScene *scene,
QMap<Node*,QPointF> oldNodePositions,
QMap<Node*,QPointF> newNodePositions,
QUndoCommand *parent = 0);
void undo() override;
void redo() override;
private:
TikzScene *_scene;
QMap<Node*,QPointF> _oldNodePositions;
QMap<Node*,QPointF> _newNodePositions;
};
class EdgeBendCommand : public QUndoCommand
{
public:
explicit EdgeBendCommand(TikzScene *scene, Edge *edge,
float oldWeight, int oldBend,
int oldInAngle, int oldOutAngle);
void undo() override;
void redo() override;
private:
TikzScene *_scene;
Edge *_edge;
float _oldWeight;
int _oldBend;
int _oldInAngle;
int _oldOutAngle;
float _newWeight;
int _newBend;
int _newInAngle;
int _newOutAngle;
};
class DeleteCommand : public QUndoCommand
{
public:
explicit DeleteCommand(TikzScene *scene,
QMap<int,Node*> deleteNodes,
QMap<int,Edge*> deleteEdges,
QSet<Edge*> selEdges);
void undo() override;
void redo() override;
private:
TikzScene *_scene;
QMap<int,Node*> _deleteNodes;
QMap<int,Edge*> _deleteEdges;
QSet<Edge*> _selEdges;
};
class AddNodeCommand : public QUndoCommand
{
public:
explicit AddNodeCommand(TikzScene *scene, Node *node, QRectF newBounds);
void undo() override;
void redo() override;
private:
TikzScene *_scene;
Node *_node;
QRectF _oldBounds;
QRectF _newBounds;
};
class AddEdgeCommand : public QUndoCommand
{
public:
explicit AddEdgeCommand(TikzScene *scene, Edge *edge);
void undo() override;
void redo() override;
private:
TikzScene *_scene;
Edge *_edge;
};
#endif // UNDOCOMMANDS_H
|