Skip to content
Snippets Groups Projects
Commit a5c029a2 authored by Anthony Noir's avatar Anthony Noir
Browse files

label frozen

parent ad5a1153
No related branches found
No related tags found
No related merge requests found
...@@ -93,6 +93,13 @@ ...@@ -93,6 +93,13 @@
<layout class="QVBoxLayout" name="simSpeedLayout_3"> <layout class="QVBoxLayout" name="simSpeedLayout_3">
<item> <item>
<layout class="QHBoxLayout" name="simSpeedLabLayout_2"> <layout class="QHBoxLayout" name="simSpeedLabLayout_2">
<item>
<widget class="QLabel" name="simStatusLabel">
<property name="text">
<string>Status :</string>
</property>
</widget>
</item>
<item> <item>
<widget class="QLabel" name="simSpeedLabel"> <widget class="QLabel" name="simSpeedLabel">
<property name="text"> <property name="text">
...@@ -601,7 +608,7 @@ pattern recorded :</string> ...@@ -601,7 +608,7 @@ pattern recorded :</string>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>1068</width> <width>1068</width>
<height>25</height> <height>21</height>
</rect> </rect>
</property> </property>
<widget class="QMenu" name="menuFichier"> <widget class="QMenu" name="menuFichier">
......
...@@ -13,6 +13,7 @@ Cette classe représente un automate cellulaire dans le temps. ...@@ -13,6 +13,7 @@ Cette classe représente un automate cellulaire dans le temps.
#include "grid.h" #include "grid.h"
#include "automaton.hpp" #include "automaton.hpp"
//! \brief Cette classe représente un automate cellulaire dans le temps.
class Simulation { class Simulation {
private: private:
bool canRun; bool canRun;
...@@ -81,6 +82,10 @@ public: ...@@ -81,6 +82,10 @@ public:
//! \return vrai si la simulation peut tourner //! \return vrai si la simulation peut tourner
bool runnable() {return canRun;} bool runnable() {return canRun;}
//! \brief Indique si la simulation est gelée
//! \return vrai si le nouvel état est le même que le dernier
bool frozen() {return hist.topGrid()==automaton.getGrid();}
//! \brief Donne la période de la simulation //! \brief Donne la période de la simulation
//! //!
//! Si elle n'est pas encore obtenue : vaut 0 //! Si elle n'est pas encore obtenue : vaut 0
......
...@@ -944,6 +944,9 @@ void MainWindow::on_nextButton_clicked() ...@@ -944,6 +944,9 @@ void MainWindow::on_nextButton_clicked()
ui->grid_view->copy_grid(simulation.getGrid()); ui->grid_view->copy_grid(simulation.getGrid());
ui->stepsPeriodLabel->setText(QString::number(simulation.getPeriod())+" steps"); ui->stepsPeriodLabel->setText(QString::number(simulation.getPeriod())+" steps");
ui->nbStepsLabel->setText(QString::number(simulation.getTime())+" steps"); ui->nbStepsLabel->setText(QString::number(simulation.getTime())+" steps");
if(simulation.frozen()) {
ui->simStatusLabel->setText("Status : frozen");
}
} }
void MainWindow::on_prevButton_clicked() void MainWindow::on_prevButton_clicked()
...@@ -960,10 +963,12 @@ void MainWindow::on_playPauseButton_clicked() ...@@ -960,10 +963,12 @@ void MainWindow::on_playPauseButton_clicked()
if(timer->isActive()) { if(timer->isActive()) {
//Pause //Pause
ui->playPauseButton->setText("Play"); ui->playPauseButton->setText("Play");
ui->simStatusLabel->setText("Status : inactive");
timer->stop(); timer->stop();
} else { } else {
//Play //Play
ui->playPauseButton->setText("Pause"); ui->playPauseButton->setText("Pause");
ui->simStatusLabel->setText("Status : active");
int frequence = ui->simSpeedSpinbox->value(); int frequence = ui->simSpeedSpinbox->value();
if(frequence == 0) { if(frequence == 0) {
QMessageBox::critical(this, "Unable to start", "Speed needs to be nonzero."); QMessageBox::critical(this, "Unable to start", "Speed needs to be nonzero.");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment