-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommandes.h
More file actions
149 lines (130 loc) · 3.46 KB
/
commandes.h
File metadata and controls
149 lines (130 loc) · 3.46 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#pragma once
#include <map>
#include <stack>
#include <memory>
#include <string>
#include <vector>
#include "Domaine.h"
#include "Surfaces.h"
class ICommand {
public:
virtual ~ICommand() = default;
virtual void executer() = 0;
virtual void annuler() = 0;
};
class Historique {
public:
void pushExec(std::unique_ptr<ICommand> cmd);
void undo();
void redo();
private:
std::stack<std::unique_ptr<ICommand>> pileUndo_;
std::stack<std::unique_ptr<ICommand>> pileRedo_;
};
class ControleurCommandes {
public:
ControleurCommandes(NuageDePoints& nuage,
AfficheurO1& aff1,
AfficheurO2& aff2,
GestionnaireSurface& gest);
void executerCommande(const std::string& nom);
void undo();
void redo();
private:
NuageDePoints& nuage_;
AfficheurO1& aff1_;
AfficheurO2& aff2_;
GestionnaireSurface& gest_;
Historique hist_;
void creerEtExecuter(const std::string& nom);
};
class CmdAfficherListe : public ICommand {
public:
CmdAfficherListe(NuageDePoints& n) : nuage_(n) {}
void executer() override;
void annuler() override {}
private:
NuageDePoints& nuage_;
};
class CmdAfficherO1 : public ICommand {
public:
CmdAfficherO1(AfficheurO1& a, const NuageDePoints& n, const GestionnaireSurface& g)
: aff_(a), nuage_(n), gest_(g) {}
void executer() override;
void annuler() override {}
private:
AfficheurO1& aff_;
const NuageDePoints& nuage_;
const GestionnaireSurface& gest_;
};
class CmdAfficherO2 : public ICommand {
public:
CmdAfficherO2(AfficheurO2& a, const NuageDePoints& n, const GestionnaireSurface& g)
: aff_(a), nuage_(n), gest_(g) {}
void executer() override;
void annuler() override {}
private:
AfficheurO2& aff_;
const NuageDePoints& nuage_;
const GestionnaireSurface& gest_;
};
class CmdFusion : public ICommand {
public:
CmdFusion(NuageDePoints& n, AfficheurO1& a1, AfficheurO2& a2);
void executer() override;
void annuler() override {}
private:
NuageDePoints& nuage_;
AfficheurO1& a1_;
AfficheurO2& a2_;
std::vector<int> ids_;
int idNuageCree_ = -1;
};
class CmdDeplacer : public ICommand {
public:
CmdDeplacer(NuageDePoints& nuage, AfficheurO1& a1, AfficheurO2& a2);
void executer() override;
void annuler() override;
private:
NuageDePoints& nuage_;
AfficheurO1& aff1_;
AfficheurO2& aff2_;
int id_ = -1;
int ancienX_ = 0, ancienY_ = 0;
int nouvX_ = 0, nouvY_ = 0;
bool configure_ = false;
};
class CmdSupprimer : public ICommand {
public:
CmdSupprimer(NuageDePoints& nuage, AfficheurO1& a1, AfficheurO2& a2);
void executer() override;
void annuler() override;
private:
NuageDePoints& nuage_;
AfficheurO1& aff1_;
AfficheurO2& aff2_;
int id_ = -1;
std::unique_ptr<IElement> sauvegarde_;
int index_ = -1;
bool aEteExecute_ = false;
};
class CmdSurfaceC1 : public ICommand {
public:
CmdSurfaceC1(GestionnaireSurface& g, const NuageDePoints& n)
: gest_(g), nuage_(n) {}
void executer() override;
void annuler() override {}
private:
GestionnaireSurface& gest_;
const NuageDePoints& nuage_;
};
class CmdSurfaceC2 : public ICommand {
public:
CmdSurfaceC2(GestionnaireSurface& g, const NuageDePoints& n)
: gest_(g), nuage_(n) {}
void executer() override;
void annuler() override {}
private:
GestionnaireSurface& gest_;
const NuageDePoints& nuage_;
};