diff options
author | Benjamin Chausse <benjamin@chausse.xyz> | 2023-01-13 19:31:33 -0500 |
---|---|---|
committer | Benjamin Chausse <benjamin@chausse.xyz> | 2023-01-13 19:31:33 -0500 |
commit | 267868847b0885f60aaae43afd4f54ce028181d8 (patch) | |
tree | 1cce415f624760481f2f4cc49d42c65fbd857e55 /canevas.cpp | |
parent | 82539db317b616b41b6e16629f19ddb4a49f6cc7 (diff) | |
parent | 86fbed0811fc4ef36ffb66b3f774df61eb87c24b (diff) |
Merge branch 'development'
Diffstat (limited to 'canevas.cpp')
-rw-r--r-- | canevas.cpp | 81 |
1 files changed, 67 insertions, 14 deletions
diff --git a/canevas.cpp b/canevas.cpp index bc7a0e5..0c203fc 100644 --- a/canevas.cpp +++ b/canevas.cpp @@ -9,38 +9,91 @@ #include "canevas.h" Canevas::Canevas() { + Couche couches[MAX_COUCHES]; + /* for (int i = 0; i < MAX_COUCHES; i++) { */ + /* couches[i] = Couche(); */ + /* }; */ + couches[0].changerEtat(STATE_ACTIVE); } Canevas::~Canevas() { + reinitialiser(); } bool Canevas::reinitialiser() { - return true; + for (int i = 0; i < MAX_COUCHES; i++) { + if (!couches[i].reinitialiser()) { + return false; + } + } + return true; } bool Canevas::activerCouche(int index) { - return true; -} + if (index < 0 || index >= MAX_COUCHES) + return false; + for (int i = 0; i < MAX_COUCHES; i++) { + if (couches[i].getEtat() == STATE_ACTIVE) { + couches[i].changerEtat(STATE_INACTIVE); + }; + }; + return couches[index].changerEtat(STATE_ACTIVE); +}; bool Canevas::cacherCouche(int index) { - return true; -} + if (index < 0 || index >= MAX_COUCHES) + return false; + couches[index].changerEtat(STATE_INACTIVE); + return true; +}; bool Canevas::ajouterForme(Forme *p_forme) { - return true; -} + int active = -1; + for (int i = 0; i < MAX_COUCHES; i++) + active = (couches[i].getEtat() == STATE_ACTIVE) ? i : active; + if (active == -1) + return false; + return couches[active].ajouterForme(p_forme); +}; bool Canevas::retirerForme(int index) { - return true; -} + int active = -1; + for (int i = 0; i < MAX_COUCHES; i++) + active = (couches[i].getEtat() == STATE_ACTIVE) ? i : active; + if (active == -1) + return false; + if (couches[active].supprimerForme(index)==NULL) + return false; + return true; +}; double Canevas::aire() { - return 0.0; -} + double aire = 0; + for (int i = 0; i < MAX_COUCHES; i++) { + aire += couches[i].aire(); + }; + return aire; +}; bool Canevas::translater(int deltaX, int deltaY) { - return true; -} + int active = -1; + for (int i = 0; i < MAX_COUCHES; i++) + active = (couches[i].getEtat() == STATE_ACTIVE) ? i : active; + if (active == -1) + return false; + return couches[active].translater(deltaX, deltaY); +}; void Canevas::afficher(ostream & s) { -} + for (int i = 0; i < MAX_COUCHES; i++) { + s << "----- Couche " << i << "\n"; + couches[i].afficher(s); + }; +}; + +bool Canevas::reinitialiserCouche(int index) { + if (index < 0 || index >= MAX_COUCHES){ + return false; + }; + return couches[index].reinitialiser(); +}; |