summaryrefslogtreecommitdiff
path: root/tikzit/src/gui/undocommands.h
blob: bb6a8e92f69f86851c0b524cbab2d03bc99596a8 (plain)
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
/**
  * These classes store the data required to undo/redo a single UI action.
  */

#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;
};

#endif // UNDOCOMMANDS_H