-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCommand.h
More file actions
106 lines (85 loc) · 2.64 KB
/
Copy pathCommand.h
File metadata and controls
106 lines (85 loc) · 2.64 KB
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
94
95
96
97
98
99
100
101
102
103
104
105
106
#pragma once
#include <afxwin.h>
#include <memory>
#include <vector>
class CShapeManager;
class CLine;
// 命令接口 / command interface
class ICadCommand {
public:
virtual ~ICadCommand() = default;
//执行命令
virtual void Execute() = 0;
//undo
virtual void Undo() = 0;
};
// 添加线条命令 / add line command
class CAddLineCommand : public ICadCommand {
private:
CShapeManager* m_pManager;
std::shared_ptr<CLine> m_pLine;
public:
CAddLineCommand(CShapeManager* mgr, std::shared_ptr<CLine> line);
void Execute() override;
void Undo() override;
};
// 平移线条命令 / move lines command
class CMoveLinesCommand : public ICadCommand {
private:
CShapeManager* m_pManager;
std::vector<std::shared_ptr<CLine>> m_lines;
double m_dx;
double m_dy;
bool m_hasExecuted;
public:
CMoveLinesCommand(CShapeManager* mgr, std::vector<std::shared_ptr<CLine>> lines, double dx, double dy, bool alreadyApplied = false);
void Execute() override;
void Undo() override;
};
// 修改填充命令 / change fill command
class CChangeLineFillCommand : public ICadCommand {
private:
CShapeManager* m_pManager;
std::shared_ptr<CLine> m_line;
bool m_oldHasFill;
COLORREF m_oldFillColor;
bool m_newHasFill;
COLORREF m_newFillColor;
public:
CChangeLineFillCommand(CShapeManager* mgr, std::shared_ptr<CLine> line, bool newHasFill, COLORREF newFillColor);
void Execute() override;
void Undo() override;
};
// 修改颜色命令 / change color command
class CChangeLineColorCommand : public ICadCommand {
private:
CShapeManager* m_pManager;
std::vector<std::shared_ptr<CLine>> m_lines;
std::vector<COLORREF> m_oldColors;
COLORREF m_newColor;
public:
CChangeLineColorCommand(CShapeManager* mgr, std::vector<std::shared_ptr<CLine>> lines, COLORREF newColor);
void Execute() override;
void Undo() override;
};
// 删除线条命令 / delete lines command
class CDeleteLinesCommand : public ICadCommand {
private:
CShapeManager* m_pManager;
std::vector<std::shared_ptr<CLine>> m_lines;
public:
CDeleteLinesCommand(CShapeManager* mgr, std::vector<std::shared_ptr<CLine>> lines);
void Execute() override;
void Undo() override;
};
// 替换线条命令 / replace line command
class CReplaceLineCommand : public ICadCommand {
private:
CShapeManager* m_pManager;
std::shared_ptr<CLine> m_original;
std::vector<std::shared_ptr<CLine>> m_replacements;
public:
CReplaceLineCommand(CShapeManager* mgr, std::shared_ptr<CLine> original, std::vector<std::shared_ptr<CLine>> replacements);
void Execute() override;
void Undo() override;
};