diff --git a/forms/interface.ui b/forms/interface.ui index 4bcf62af41ea9c23add7fe8c6d85152f2b7ded16..a4f06a2b59760a354d8cc87be36d37747f2ffe54 100644 --- a/forms/interface.ui +++ b/forms/interface.ui @@ -380,6 +380,13 @@ pattern recorded :</string> </item> </layout> </item> + <item> + <widget class="QPushButton" name="pushButton"> + <property name="text"> + <string>Reset grid</string> + </property> + </widget> + </item> </layout> </widget> </item> @@ -556,7 +563,7 @@ pattern recorded :</string> <x>0</x> <y>0</y> <width>1068</width> - <height>25</height> + <height>22</height> </rect> </property> <widget class="QMenu" name="menuFichier"> diff --git a/include/interface.hpp b/include/interface.hpp index fbfe06f0f03d92cb86770cc008aabe38af72d280..98ca37b2bdd888dd3d43d763a8b28d203404a459 100644 --- a/include/interface.hpp +++ b/include/interface.hpp @@ -83,6 +83,11 @@ private slots: void on_recordSpinBox_valueChanged(int arg1); + + + + void on_pushButton_clicked(); + private: //! \brief Initialiser la liste des transitions et voisinages disponibles void init_transition_neighborhood_list(); diff --git a/src/interface.cpp b/src/interface.cpp index 099a176cbaf925d199add5d2b024c55d6468503b..d0356f9fc89353f202fd3073d89dd830c6bae548 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -676,3 +676,30 @@ void MainWindow::on_resetButton_clicked() { void MainWindow::on_recordSpinBox_valueChanged(int newSize) { simulation.setHistorySize(newSize); } + + + + + + +void MainWindow::on_pushButton_clicked() +{ + Grid oldGrid = ui->grid_view->get_grid(); + unsigned nbrRow = oldGrid.get_rows(); // rows = nbr de lignes => axe y + unsigned nbrCol = oldGrid.get_col(); // col = nbr de colonne => axe x + Grid newGrid(nbrRow, nbrCol); + + + for (unsigned y = 0; y < nbrRow; ++y) + { + for (unsigned x = 0; x < nbrCol; ++x) + { + unsigned state = 0; + Coord pos = {static_cast<int>(x), static_cast<int>(y)}; + newGrid.set_cell(pos, state); + } + } + + ui->grid_view->copy_grid(newGrid); +} +