-
Notifications
You must be signed in to change notification settings - Fork 0
/
AddCommand.cpp
74 lines (67 loc) · 2.81 KB
/
AddCommand.cpp
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
#include "AddCommand.h"
AddCommand::AddCommand(cv::Mat *targetImage, cv::Mat imageBefore, cv::Mat imageAfter,
std::vector<EffectLayer> *targetState, std::vector<EffectLayer> previousStates,
std::vector<EffectLayer> currentStates, cv::Mat *targetNoise, cv::Mat noiseBefore,
cv::Mat noiseAfter, QString text, QUndoCommand *parent) : QUndoCommand(text, parent)
{
this->targetImage = targetImage;
this->imageBefore = imageBefore;
this->imageAfter = imageAfter;
this->targetState = targetState;
this->currentStates = currentStates;
this->previousStates = previousStates;
this->targetNoise = targetNoise;
this->noiseBefore = noiseBefore;
this->noiseAfter = noiseAfter;
}
AddCommand::AddCommand(cv::Mat *targetImage, cv::Mat imageBefore, cv::Mat imageAfter,
std::vector<EffectLayer> *targetState, cv::Mat *targetNoise, QString text,
QUndoCommand *parent) : QUndoCommand(text, parent)
{
this->targetImage = targetImage;
this->imageBefore = imageBefore;
this->imageAfter = imageAfter;
this->targetState = targetState;
this->currentStates = *targetState;
this->previousStates = *targetState;
this->targetNoise = targetNoise;
this->noiseBefore = *targetNoise;
this->noiseAfter = *targetNoise;
}
AddCommand::AddCommand(cv::Mat *targetImage, std::vector<EffectLayer> *targetState,
std::vector<EffectLayer> previousStates, std::vector<EffectLayer> currentStates,
cv::Mat *targetNoise, QString text, QUndoCommand *parent) : QUndoCommand(text, parent)
{
this->targetImage = targetImage;
this->imageBefore = *targetImage;
this->imageAfter = *targetImage;
this->targetState = targetState;
this->currentStates = currentStates;
this->previousStates = previousStates;
this->targetNoise = targetNoise;
this->noiseBefore = *targetNoise;
this->noiseAfter = *targetNoise;
}
AddCommand::AddCommand(cv::Mat *targetImage, std::vector<EffectLayer> *targetState, cv::Mat *targetNoise,
cv::Mat noiseBefore, cv::Mat noiseAfter, QString text, QUndoCommand *parent) : QUndoCommand(text, parent)
{
this->targetImage = targetImage;
this->imageBefore = *targetImage;
this->imageAfter = *targetImage;
this->targetState = targetState;
this->currentStates = *targetState;
this->previousStates = *targetState;
this->targetNoise = targetNoise;
this->noiseBefore = noiseBefore;
this->noiseAfter = noiseAfter;
}
void AddCommand::undo(){
*targetImage = imageBefore;
*targetState = previousStates;
*targetNoise = noiseBefore;
}
void AddCommand::redo(){
*targetImage = imageAfter;
*targetState = currentStates;
*targetNoise = noiseAfter;
}