Commit 1ccfe45f authored by Leon Do Castelo's avatar Leon Do Castelo
Browse files

Update parametragemodele.cpp

parent 89065203
Pipeline #79800 passed with stage
in 15 seconds
...@@ -219,9 +219,6 @@ void NouveauModele::changerVoisinage(){ ...@@ -219,9 +219,6 @@ void NouveauModele::changerVoisinage(){
liste_voisinage = new QComboBox(); liste_voisinage = new QComboBox();
layoutvalid = new QHBoxLayout; layoutvalid = new QHBoxLayout;
liste_voisinage->addItem("Voisinage de Moore"); liste_voisinage->addItem("Voisinage de Moore");
liste_voisinage->addItem("Voisinage de von Neumann"); liste_voisinage->addItem("Voisinage de von Neumann");
liste_voisinage->addItem("Voisinage arbitraire"); liste_voisinage->addItem("Voisinage arbitraire");
...@@ -406,8 +403,25 @@ void NouveauModele::paramRegle() { ...@@ -406,8 +403,25 @@ void NouveauModele::paramRegle() {
void NouveauModele::addRegle(){ void NouveauModele::addRegle(){
if(valid_Etat->currentIndex()==(-1));
else
{
int min[8], max[8];
for(int i = 0; i<8; i++)
{
min[i] = numSeuilMin[i]->text().toInt();
max[i] = numSeuilMax[i]->text().toInt();
}
if(valid_Etat->currentIndex()==1)
Automate::getInstance().getFonction().ajouterRegle(Automate::getInstance().getEnsemble().getEtat(etatDest->value()), min, max);
else
Automate::getInstance().getFonction().ajouterRegle(Automate::getInstance().getEnsemble().getEtat(etatDest->value()), min, max, numEtatCourant->value());
paramRegle(); paramRegle();
}
} }
void NouveauModele::validerParametrage(){ void NouveauModele::validerParametrage(){
...@@ -417,33 +431,46 @@ void NouveauModele::validerParametrage(){ ...@@ -417,33 +431,46 @@ void NouveauModele::validerParametrage(){
Automate::getInstance().setDesc(description->text().toStdString()); Automate::getInstance().setDesc(description->text().toStdString());
Automate::getInstance().setYear(annee->text().toInt()); Automate::getInstance().setYear(annee->text().toInt());
Fonction* automateFonction = new Fonction(Automate::getInstance().getEnsemble().getEtat(etat_default->value())); Automate::getInstance().getFonction().setEtatDefaut(Automate::getInstance().getEnsemble().getEtat(etat_default->value()));
/* if(liste_voisinage->currentIndex()==-1);
Automate::getInstance().setTitle(nom_automate->value().toStdString()); else
Automate::getInstance().setAuthor(auteur->value().toStdString()); if(liste_voisinage->currentIndex()==0) //moore
Automate::getInstance().setYear(anneee->value().toInt()); {
Automate::getInstance().setDescription(description->value().toStdString()); RegleVoisinageMoore *regle_voisins = new RegleVoisinageMoore;
Automate::getInstance().setFonction(fonction.get()); regle_voisins->setr(rayon->value());
if (liste_voisinage->currentText().toStdString() == "Voisinage de von Neumann") { Automate::getInstance().setRegleVoisinage(regle_voisins);
Database::getInstance().saveAutomaton(Automate::getInstance());
this->close();
}
else
if(liste_voisinage->currentIndex()==1) //von neumann
{
RegleVoisinageNeumann *regle_voisins = new RegleVoisinageNeumann; RegleVoisinageNeumann *regle_voisins = new RegleVoisinageNeumann;
regle_voisins->setr(rayon.value()); regle_voisins->setr(rayon->value());
Automate::getInstance().setRegleVoisinage(rayon_voisins); Automate::getInstance().setRegleVoisinage(regle_voisins);
Database::getInstance().saveAutomaton(Automate::getInstance());
this->close();
} }
else if (liste_voisinage->currentText().toStdString() == "Voisinage de Moore") { else //arbitraire
RegleVoisinageMoore *regle_voisins = new RegleVoisinageMoore; {
regle_voisins->setr(rayon.value()); RegleVoisinageArbitraire *regle_voisins = new RegleVoisinageArbitraire;
Automate::getInstance().setRegleVoisinage(rayon_voisins); Coordonnees c;
for(unsigned int i=0; i<5; i++){
for(unsigned int j=0; j<5; j++)
{
if(grid->item(i,j)->background().color()==Qt::red)
{
c.x = i;
c.y = j;
regle_voisins->coordonnees.push_back(c);
} }
else if (liste_voisinage->currentText().toStdString() == "Voisinage arbitraire") {
//todo
} }
Database::saveAutomaton(Automate::getInstance()); }
if(nvAutocell != nullptr) delete nvAutocell; Automate::getInstance().setRegleVoisinage(regle_voisins);
Database::getInstance().saveAutomaton(Automate::getInstance());
nvAutocell = new AutoCell; this->close();
}
nvAutocell->show();*/
} }
...@@ -462,6 +489,24 @@ void NouveauModele::changerEtatDefault(){ ...@@ -462,6 +489,24 @@ void NouveauModele::changerEtatDefault(){
} }
void NouveauModele::validation(){ void NouveauModele::validation(){
bouton_valide = new QPushButton("Valider"); if(valid_Etat->currentIndex()==(-1));
else
{
int min[8], max[8];
for(int i = 0; i<8; i++)
{
min[i] = numSeuilMin[i]->text().toInt();
max[i] = numSeuilMax[i]->text().toInt();
}
if(valid_Etat->currentIndex()==1)
Automate::getInstance().getFonction().ajouterRegle(Automate::getInstance().getEnsemble().getEtat(etatDest->value()), min, max);
else
Automate::getInstance().getFonction().ajouterRegle(Automate::getInstance().getEnsemble().getEtat(etatDest->value()), min, max, numEtatCourant->value());
}
//bouton_valide = new QPushButton("Valider");
form_choix->addRow(bouton_valide); form_choix->addRow(bouton_valide);
} }
Markdown is supported
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