Verified Commit 22e8a3dc authored by Romain De Laage De Bellefaye's avatar Romain De Laage De Bellefaye 🌳
Browse files

Merge branch 'master' of gitlab.utc.fr:rdelaage/lo21-projet

parents 90367177 3e0dbade
This diff is collapsed.
......@@ -49,28 +49,39 @@ class NouveauModele : public QWidget {
QLabel* seuilMin;
QLabel* destination;
QLabel* etatCourant;
QLabel* etatCourant2;
QLabel* etatCourant2 = nullptr;
QComboBox* valid_Etat;
QSpinBox* numEtatCourant;
QSpinBox* etatDest;
QPushButton* fin, next;
QPushButton* fin;
QPushButton* next;
QIntValidator* seuilValidator;
QLineEdit* numSeuilMin[8];
QLineEdit* numSeuilMax[8];
QVBoxLayout* layoutv = nullptr;
QHBoxLayout* layouth1 = nullptr;
QHBoxLayout* layouth2 = nullptr;
QHBoxLayout* layouth3 = nullptr;
QHBoxLayout* layouth4 = nullptr;
QVBoxLayout* layoutv2 = nullptr;
QHBoxLayout* layouth5 = nullptr;
QHBoxLayout* layouth6 = nullptr;
//définition de la frame paramétrage du choix
QWidget* fenetre_param;
QGridLayout* form_param;
QLabel* label_param;
//Voisiange non arbitraire
QFormLayout* form_rayon;
QFormLayout* form_rayon = nullptr;
QSpinBox* rayon;
//définition de la frame contenant la grille de sélection du voisinage
QTableWidget* grid;
QTableWidget* grid = nullptr;
std::unique_ptr<ParamAlpha> paramAlpha;
QPushButton* boutonEtat;
......
......@@ -12,7 +12,7 @@ NouveauModele::NouveauModele(QWidget* parent) : QWidget() {
fenetre_init = new QWidget;
fenetre_init->setStyleSheet("background-color: rgb(204, 209, 209)");
fenetre_init->setFixedWidth(300);
fenetre_init->setFixedWidth(410);
label_init = new QLabel("Configuration du modèle :");
form_init = new QGridLayout(fenetre_init);
......@@ -29,33 +29,26 @@ NouveauModele::NouveauModele(QWidget* parent) : QWidget() {
//choisir un voisinage
liste_voisinage = new QComboBox;
liste_voisinage->addItem("--- select ---");
/*
liste_voisinage->addItem("Voisinage de Moore");
liste_voisinage->addItem("Voisinage de von Neumann");
liste_voisinage->addItem("Voisinage arbitraire");
//liste_voisinage->setPlaceholderText("--- select ---");
liste_voisinage->setPlaceholderText("--- select ---");
liste_voisinage->setCurrentIndex(-1);
*/
connect(liste_voisinage, SIGNAL(currentTextChanged(const QString&)), this, SLOT(paramVoisinage(const QString&)));
//choisir une règle de transition
liste_regle_transition = new QComboBox;
//liste_regle_transition->setPlaceholderText("--- select ---");
liste_regle_transition->setPlaceholderText("--- select ---");
//liste_regle_transition->addItem("--- select ---");
liste_regle_transition->addItem("Life Game");
liste_regle_transition->addItem("Langston's Loop");
liste_regle_transition->addItem("Brian's brain");
liste_regle_transition->addItem("Circulaire de Griffeath");
liste_regle_transition->addItem("Langston's Loop");
liste_regle_transition->addItem("Nouvelle fonction de transition");
liste_regle_transition->setCurrentIndex(-1);
//connect(liste_regle_transition, SIGNAL(currentIndexChanged(int)), liste_voisinage, SLOT(setCurrentIndex(int)));
......@@ -66,15 +59,8 @@ NouveauModele::NouveauModele(QWidget* parent) : QWidget() {
bouton_valide->setFixedWidth(50);
//connect(bouton_valide, SIGNAL(clicked()), SLOT(affParametrage()));
//ajout regle :
form_choix->addRow("Nombre d'états :", nb_etats);
form_choix->addRow("Règle de transition :", liste_regle_transition);
form_choix->addRow("Voisinage :", liste_voisinage);
......@@ -106,6 +92,7 @@ NouveauModele::NouveauModele(QWidget* parent) : QWidget() {
connect(boutonEtat, SIGNAL(clicked()), this, SLOT(parametrerEtats()));
form_choix->addWidget(boutonEtat);
}
void NouveauModele::parametrerEtats() {
......@@ -115,8 +102,9 @@ void NouveauModele::parametrerEtats() {
void NouveauModele::paramVoisinage(const QString& choix_voisinage){
if(choix_voisinage == "Voisinage de von Neumann" || choix_voisinage == "Voisinage de Moore"){
delete form_rayon;
delete grid;
if (form_rayon != nullptr)delete form_rayon;
if (grid != nullptr) delete grid;
form_rayon = new QFormLayout;
rayon = new QSpinBox;
......@@ -146,21 +134,38 @@ void NouveauModele::paramRegle(const QString& choix_regle) {
valid_Etat->addItem("Non");
valid_Etat->setCurrentIndex(-1);
if (choix_regle == "Nouvelle fonction de transition") {
seuilValidator=new QIntValidator;
seuilValidator->setRange(0,1);
QVBoxLayout* layoutv = new QVBoxLayout;
QHBoxLayout* layouth1 = new QHBoxLayout;
QHBoxLayout* layouth2 = new QHBoxLayout;
QHBoxLayout* layouth3 = new QHBoxLayout;
QHBoxLayout* layouth4 = new QHBoxLayout;
if(layouth1 != nullptr) delete layouth1;
if(layouth2 != nullptr) delete layouth2;
if(layouth3 != nullptr) delete layouth3;
if(layouth4 != nullptr) delete layouth4;
if(layoutv != nullptr) delete layoutv;
if(layouth5 != nullptr) delete layouth5;
if(layouth6 != nullptr) delete layouth6;
if(layoutv2 != nullptr) delete layoutv2;
layouth1 = new QHBoxLayout;
layouth2 = new QHBoxLayout;
layouth3 = new QHBoxLayout;
layouth4 = new QHBoxLayout;
layoutv = new QVBoxLayout;
layouth6 = new QHBoxLayout;
layouth5 = new QHBoxLayout;
layoutv2 = new QVBoxLayout;
form_choix->addRow(layoutv);
layoutv->addLayout(layouth1);
layoutv->addLayout(layouth2);
layoutv->addLayout(layouth3);
layoutv->addLayout(layouth4);
seuilValidator->setRange(0,1);
layouth1->addWidget(seuilMin);
for(unsigned int i=0; i<8; i++) {
numSeuilMin[i]=new QLineEdit;
......@@ -168,10 +173,12 @@ void NouveauModele::paramRegle(const QString& choix_regle) {
numSeuilMin[i]->setMaxLength(2);
numSeuilMin[i]->setText("-1");
numSeuilMin[i]->setValidator(seuilValidator);
if (i<nb_etats->value()){
layouth1->addWidget(numSeuilMin[i]);
}
}
layoutv->addLayout(layouth2);
layouth2->addWidget(seuilMax);
for(unsigned int i=0; i<8; i++) {
numSeuilMax[i]=new QLineEdit;
......@@ -179,12 +186,13 @@ void NouveauModele::paramRegle(const QString& choix_regle) {
numSeuilMax[i]->setMaxLength(2);
numSeuilMax[i]->setText("-1");
numSeuilMax[i]->setValidator(seuilValidator);
if (i<nb_etats->value()){
layouth2->addWidget(numSeuilMax[i]);
}
layoutv->addLayout(layouth3);
}
layouth3->addWidget(destination);
layouth3->addWidget(etatDest);
layoutv->addLayout(layouth4);
layouth4->addWidget(etatCourant);
layouth4->addWidget(valid_Etat);
connect(valid_Etat, SIGNAL(currentTextChanged(const QString&)), this, SLOT(choisirEtatCourant(const QString&)));
......@@ -192,28 +200,71 @@ void NouveauModele::paramRegle(const QString& choix_regle) {
}
void NouveauModele::choisirEtatCourant(const QString& validEtat){
etatCourant2 = new QLabel("Etat Courant : ");
QHBoxLayout* layout = new QHBoxLayout;
form_choix->addRow(layout);
fin = new QPushButton("Terminer");
next = new QPushButton("Règle suivante");
if (validEtat == "Oui"){
if(layouth5 != nullptr) delete layouth5;
if(layouth6 != nullptr) delete layouth6;
if(layoutv2 != nullptr) delete layoutv2;
if(etatCourant2 != nullptr) delete etatCourant2;
layouth6 = new QHBoxLayout;
layouth5 = new QHBoxLayout;
layoutv2 = new QVBoxLayout;
form_choix->addRow(layoutv2);
layoutv2->addLayout(layouth5);
layoutv2->addLayout(layouth6);
etatCourant2 = new QLabel("Etat Courant : ");
numEtatCourant = new QSpinBox;
numEtatCourant->setRange(1,8);
layout->addWidget(etatCourant);
layout->addWidget(numEtatCourant);
layouth5->addWidget(etatCourant2);
layouth5->addWidget(numEtatCourant);
layouth6->addWidget(fin);
layouth6->addWidget(next);
}else{
delete layout;
if(layouth5 != nullptr) delete layouth5;
if(layouth6 != nullptr) delete layouth6;
if(layoutv2 != nullptr) delete layoutv2;
if(etatCourant2 != nullptr) delete etatCourant2;
etatCourant2 = new QLabel("Etat Courant non pris en compte ");
layouth6 = new QHBoxLayout;
layouth5 = new QHBoxLayout;
layoutv2 = new QVBoxLayout;
form_choix->addRow(layoutv2);
layoutv2->addLayout(layouth5);
layoutv2->addLayout(layouth6);
layouth5->addWidget(etatCourant2);
layouth6->addWidget(fin);
layouth6->addWidget(next);
}
}
void NouveauModele::affGrille() {
delete grid;
grid = new QTableWidget(5, 5);
form_param->addWidget(grid, 0, 0, 8, 1);
if (grid != nullptr) delete grid;
grid = new QTableWidget(5,5);
form_param->addWidget(grid, 0, 0, 7, 3);
grid->horizontalHeader()->setVisible(false); //Pas de nom pour les colonnes.
grid->verticalHeader()->setVisible(false);
......@@ -224,7 +275,7 @@ void NouveauModele::affGrille() {
for(unsigned int j=0; j<5; j++)
{
grid->setRowHeight(j,80);
grid->setColumnWidth(j, 80);
grid->setColumnWidth(j,80);
/*
int x = i-3;
......@@ -270,7 +321,7 @@ void NouveauModele::modifGrille(const QModelIndex& index){
void NouveauModele::changerVoisinage(const QString& choix_regle){
delete liste_voisinage;
//delete liste_voisinage;
form_choix->removeRow(2);
liste_voisinage = new QComboBox();
......
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