Verified Commit 11625a21 authored by Romain De Laage De Bellefaye's avatar Romain De Laage De Bellefaye 🌳
Browse files

Resolve save grid and Grille attribute set

parent fb38fd85
No preview for this file type
...@@ -150,7 +150,7 @@ AutoCell::AutoCell(QWidget* parent):QWidget(parent) ...@@ -150,7 +150,7 @@ AutoCell::AutoCell(QWidget* parent):QWidget(parent)
spin_time_step->setFixedWidth(70); spin_time_step->setFixedWidth(70);
spin_time_step->setValue(1000); spin_time_step->setValue(1000);
spin_time_step->setRange(500,2500); spin_time_step->setRange(500,2500);
connect(spin_time_step, SIGNAL(valueChanged(int i)), this, SLOT(changeDelai(int i))); connect(spin_time_step, SIGNAL(valueChanged(int)), this, SLOT(changeDelai(int)));
button_prev = new QPushButton("<<"); button_prev = new QPushButton("<<");
button_prev->setStyleSheet("background-color: rgb(255,255,255)"); button_prev->setStyleSheet("background-color: rgb(255,255,255)");
button_prev->setFixedSize(40,40); button_prev->setFixedSize(40,40);
...@@ -167,7 +167,7 @@ AutoCell::AutoCell(QWidget* parent):QWidget(parent) ...@@ -167,7 +167,7 @@ AutoCell::AutoCell(QWidget* parent):QWidget(parent)
button_reinitialiser->setStyleSheet("background-color: rgb(255,255,255)"); button_reinitialiser->setStyleSheet("background-color: rgb(255,255,255)");
button_reinitialiser->setFixedWidth(200); button_reinitialiser->setFixedWidth(200);
grid_run_control->addWidget(matriceTorique, 1, 0, Qt::AlignCenter); grid_run_control->addWidget(matriceTorique, 1, 0, 1, 2);
grid_run_control->addWidget(spin_time_step, 2, 1); grid_run_control->addWidget(spin_time_step, 2, 1);
grid_run_control->addWidget(button_prev, 3, 0); grid_run_control->addWidget(button_prev, 3, 0);
grid_run_control->addWidget(button_run, 3, 1); grid_run_control->addWidget(button_run, 3, 1);
...@@ -208,8 +208,9 @@ AutoCell::AutoCell(QWidget* parent):QWidget(parent) ...@@ -208,8 +208,9 @@ AutoCell::AutoCell(QWidget* parent):QWidget(parent)
general->addWidget(win_notice,0,2,3,1); general->addWidget(win_notice,0,2,3,1);
}; };
void AutoCell::afficherGrille(Reseau* Grille) void AutoCell::afficherGrille(Reseau* grille)
{ {
Grille.reset(new Reseau(*grille));
win_grid = new QWidget; win_grid = new QWidget;
int l = Grille->getLargeur(); int l = Grille->getLargeur();
...@@ -279,28 +280,28 @@ void AutoCell::initialiserGrille(){ ...@@ -279,28 +280,28 @@ void AutoCell::initialiserGrille(){
return; return;
} }
this->Grille.reset(new Reseau(h,l)); Reseau grille = Reseau(h,l);
if (check_aleatoire->isChecked()) if (check_aleatoire->isChecked())
Grille->setAleatoire(); grille.setAleatoire();
QString nom_grille = list_grids->currentText(); QString nom_grille = list_grids->currentText();
if (check_load_grid->isChecked()) { if (check_load_grid->isChecked()) {
this->Grille.reset(new Reseau(Database::getInstance().getReseau(listeGrille[list_grids->currentIndex()*2].toInt()))); grille = Reseau(Database::getInstance().getReseau(listeGrille[list_grids->currentIndex()*2].toInt()));
QString str_largeur; QString str_largeur;
//str_largeur.setNum(listeGrille[list_grids->currentIndex()*2].toInt()); //str_largeur.setNum(listeGrille[list_grids->currentIndex()*2].toInt());
QString str_hauteur; QString str_hauteur;
//edit_largeur->setText(str_largeur); //edit_largeur->setText(str_largeur);
edit_largeur->setText(str_largeur.setNum(Grille->getLargeur(),10)); edit_largeur->setText(str_largeur.setNum(grille.getLargeur(),10));
edit_hauteur->setText(str_hauteur.setNum(Grille->getHauteur(),10)); edit_hauteur->setText(str_hauteur.setNum(grille.getHauteur(),10));
} }
//réinitialiser l'automate //réinitialiser l'automate
Automate::getInstance().reset(); Automate::getInstance().reset();
this->afficherGrille(this->Grille.get()); this->afficherGrille(&grille);
Automate::getInstance().setReseauInit(*Grille); Automate::getInstance().setReseauInit(grille);
Automate::getInstance().initialiserBuffer(); Automate::getInstance().initialiserBuffer();
}; };
void AutoCell::RAZ(){ void AutoCell::RAZ(){
......
...@@ -485,7 +485,7 @@ void Database::stockerReseau(const Reseau& reseau, const QString& nomReseau, con ...@@ -485,7 +485,7 @@ void Database::stockerReseau(const Reseau& reseau, const QString& nomReseau, con
int idReseau = query.value(0).toInt() + 1; int idReseau = query.value(0).toInt() + 1;
//Insertion du tuple dans reseaux //Insertion du tuple dans reseaux
query.prepare("INSERT INTO reseaux VALUES (:id, ':nom', :h, :l, ':automate')"); query.prepare("INSERT INTO reseaux VALUES (:id, :nom, :h, :l, :automate)");
query.bindValue(":id", idReseau); query.bindValue(":id", idReseau);
query.bindValue(":nom", nomReseau); query.bindValue(":nom", nomReseau);
query.bindValue(":h", reseau.getHauteur()); query.bindValue(":h", reseau.getHauteur());
...@@ -502,7 +502,7 @@ void Database::stockerReseau(const Reseau& reseau, const QString& nomReseau, con ...@@ -502,7 +502,7 @@ void Database::stockerReseau(const Reseau& reseau, const QString& nomReseau, con
query.bindValue(":reseau", idReseau); query.bindValue(":reseau", idReseau);
query.bindValue(":etat", reseau.getReseau()[i][j].getIndEtat()); query.bindValue(":etat", reseau.getReseau()[i][j].getIndEtat());
query.bindValue(":x", i); query.bindValue(":x", i);
query.bindValue(":x", j); query.bindValue(":y", j);
query.exec(); query.exec();
} }
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment