Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Romain De Laage De Bellefaye
LO21-projet
Commits
9fb59243
Commit
9fb59243
authored
Jun 12, 2021
by
Maxime Goret
Browse files
Merge
parents
5ca92d98
aa94038a
Pipeline
#79728
passed with stage
in 16 seconds
Changes
8
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
includes/Automate.h
View file @
9fb59243
...
...
@@ -156,6 +156,10 @@ class Automate {
/// Réinitialiser totalement la configuration de l'automate
void
reinitialiserAutomate
();
/// Définir le comportement aux frontières
void
setMatriceTorique
(
const
bool
val
)
{
regleVoisinage
->
setMatriceTorique
(
val
);
}
bool
getMatriceTorique
()
{
return
regleVoisinage
->
getMatriceTorique
();
}
};
#endif
includes/autocell.h
View file @
9fb59243
...
...
@@ -21,6 +21,7 @@
#include
<QPushButton>
#include
<QCheckBox>
#include
<QFormLayout>
#include
<QSpinBox>
using
namespace
std
;
...
...
@@ -64,9 +65,9 @@ class AutoCell : public QWidget
QGridLayout
*
grid_run_control
;
QCheckBox
*
matriceTorique
;
QLabel
*
lab_time_step
;
QLineEdit
*
edit_time_step
;
QPushButton
*
button_valider_delai
;
QSpinBox
*
spin_time_step
;
QPushButton
*
button_prev
;
QPushButton
*
button_run
;
QPushButton
*
button_next
;
...
...
@@ -130,11 +131,12 @@ class AutoCell : public QWidget
/// Initialiser un automate par son nom
void
initAutomate
(
const
QString
&
name
);
/// Changer le délai de l'automate
void
changeDelai
();
void
changeDelai
(
int
i
);
/// Aller en arrière dans la simulation
void
previous
();
/// Aller en avant dans la simulation
void
next
();
void
setMatriceTorique
(
int
val
);
};
#endif // AUTOCELL_H
includes/reseau_cellule_etats.h
View file @
9fb59243
...
...
@@ -77,4 +77,5 @@ public:
Reseau
(
const
Reseau
&
);
~
Reseau
();
Reseau
&
operator
=
(
const
Reseau
&
r
);
bool
operator
==
(
const
Reseau
&
r
);
};
includes/voisinage.h
View file @
9fb59243
...
...
@@ -67,12 +67,17 @@ public:
};
class
RegleVoisinage
{
private:
bool
matriceTorique
;
public
:
virtual
void
calculVoisinage
(
Voisinage
&
v
,
const
Reseau
&
r
)
const
=
0
;
virtual
int
getType
()
const
=
0
;
/// Renvoie le rayon d'une règle de voisinage, 0 si ce n'est pas pertinant pour ce voisinage (arbitraire, ...)
virtual
unsigned
int
getr
()
const
{
return
0
;
}
virtual
~
RegleVoisinage
()
=
default
;
void
setMatriceTorique
(
const
bool
val
)
{
matriceTorique
=
val
;
}
bool
getMatriceTorique
()
const
{
return
matriceTorique
;
}
};
class
RegleVoisinageNeumann
:
public
RegleVoisinage
{
...
...
src/autocell.cpp
View file @
9fb59243
...
...
@@ -141,15 +141,16 @@ AutoCell::AutoCell(QWidget* parent):QWidget(parent)
grid_run_control
->
addWidget
(
lab_run_crtl
,
0
,
0
,
1
,
3
,
Qt
::
AlignTop
);
matriceTorique
=
new
QCheckBox
(
"Matrice torique"
);
connect
(
matriceTorique
,
SIGNAL
(
stateChanged
(
int
)),
this
,
SLOT
(
setMatriceTorique
(
int
)));
lab_time_step
=
new
QLabel
(
"Pas de temps : "
);
edit_time_step
=
new
QLineEdit
;
edit_time_step
->
setStyleSheet
(
"background-color: rgb(255,255,255)"
);
edit_time_step
->
setFixedWidth
(
30
);
edit_time_step
->
setText
(
"1000"
);
//valeur par défaut pour le pas de temps
button_valider_delai
=
new
QPushButton
(
"valider"
);
button_valider_delai
->
setStyleSheet
(
"background-color: rgb(255,255,255)"
);
button_valider_delai
->
setFixedWidth
(
50
);
connect
(
button_valider_delai
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
changeDelai
()));
spin_time_step
=
new
QSpinBox
;
spin_time_step
->
setStyleSheet
(
"background-color: rgb(255,255,255)"
);
spin_time_step
->
setFixedWidth
(
70
);
spin_time_step
->
setValue
(
1000
);
spin_time_step
->
setRange
(
500
,
2500
);
connect
(
spin_time_step
,
SIGNAL
(
valueChanged
(
int
i
)),
this
,
SLOT
(
changeDelai
(
int
i
)));
button_prev
=
new
QPushButton
(
"<<"
);
button_prev
->
setStyleSheet
(
"background-color: rgb(255,255,255)"
);
button_prev
->
setFixedSize
(
40
,
40
);
...
...
@@ -166,13 +167,13 @@ AutoCell::AutoCell(QWidget* parent):QWidget(parent)
button_reinitialiser
->
setStyleSheet
(
"background-color: rgb(255,255,255)"
);
button_reinitialiser
->
setFixedWidth
(
200
);
grid_run_control
->
addWidget
(
lab_time_step
,
1
,
0
);
grid_run_control
->
addWidget
(
edit
_time_step
,
1
,
1
);
grid_run_control
->
addWidget
(
button_valider_delai
,
1
,
2
);
grid_run_control
->
addWidget
(
button_prev
,
2
,
0
);
grid_run_control
->
addWidget
(
button_run
,
2
,
1
);
grid_run_control
->
addWidget
(
button_next
,
2
,
2
);
grid_run_control
->
addWidget
(
button_reinitialiser
,
3
,
0
,
Qt
::
AlignCenter
);
grid_run_control
->
addWidget
(
matriceTorique
,
1
,
0
,
Qt
::
AlignCenter
);
grid_run_control
->
addWidget
(
lab
_time_step
,
2
,
0
);
grid_run_control
->
addWidget
(
spin_time_step
,
2
,
1
);
grid_run_control
->
addWidget
(
button_prev
,
3
,
0
);
grid_run_control
->
addWidget
(
button_run
,
3
,
1
);
grid_run_control
->
addWidget
(
button_next
,
3
,
2
);
grid_run_control
->
addWidget
(
button_reinitialiser
,
4
,
0
,
Qt
::
AlignCenter
);
lab_sauv_grille
=
new
QLabel
(
"Sauvegarder la grille courante"
);
edit_nom_grille
=
new
QLineEdit
;
...
...
@@ -308,7 +309,7 @@ void AutoCell::RAZ(){
grid
=
new
QTableWidget
(
0
,
0
,
win_grid
);
edit_largeur
->
setText
(
""
);
edit_hauteur
->
setText
(
""
);
edit
_time_step
->
set
Text
(
"
1000
"
);
spin
_time_step
->
set
Value
(
1000
);
check_aleatoire
->
setCheckState
(
Qt
::
Unchecked
);
check_load_grid
->
setCheckState
(
Qt
::
Unchecked
);
;}
...
...
@@ -354,6 +355,10 @@ void AutoCell::sauvegarderGrille(){
QString
nom_automate
;
nom_automate
=
liste
->
currentText
();
Database
::
getInstance
().
stockerReseau
(
*
Grille
,
nom_grille
,
nom_automate
);
edit_nom_grille
->
setText
(
""
);
QMessageBox
messageBox
;
messageBox
.
critical
(
0
,
"Confirmation"
,
"Grille enregistrée"
);
messageBox
.
setFixedSize
(
500
,
200
);
};
void
AutoCell
::
chargerGrilles
(){
...
...
@@ -363,6 +368,7 @@ void AutoCell::chargerGrilles(){
text
=
liste
->
currentText
();
list_grids
->
clear
();
list_grids
->
setFixedWidth
(
90
);
vector
<
QString
>
noms
=
Database
::
getInstance
().
getListeReseaux
(
text
);
nb
.
setNum
(
noms
.
size
());
...
...
@@ -396,16 +402,12 @@ void AutoCell::initAutomate(const QString& name) {
QString
msg
(
m
);
afficherErreur
(
msg
);
}
Automate
::
getInstance
().
setMatriceTorique
(
true
);
matriceTorique
->
setCheckState
(
Qt
::
Checked
);
}
void
AutoCell
::
changeDelai
()
{
if
(
edit_time_step
->
text
()
==
""
||
edit_time_step
->
text
().
toInt
()
<
500
||
edit_time_step
->
text
().
toInt
()
>
2500
){
QString
msg
(
"Veuillez indiquer un pas de temps entre 500 ms et 2500 ms"
);
afficherErreur
(
msg
);
edit_time_step
->
setText
(
"1000"
);
return
;
}
Automate
::
getInstance
().
setDelai
(
static_cast
<
unsigned
int
>
(
edit_time_step
->
text
().
toInt
()));
void
AutoCell
::
changeDelai
(
int
i
)
{
Automate
::
getInstance
().
setDelai
(
static_cast
<
unsigned
int
>
(
i
));
}
void
AutoCell
::
next
()
{
...
...
@@ -422,3 +424,10 @@ void AutoCell::previous() {
afficherErreur
(
msg
);
}
}
void
AutoCell
::
setMatriceTorique
(
int
val
)
{
if
(
val
==
0
)
Automate
::
getInstance
().
setMatriceTorique
(
false
);
else
Automate
::
getInstance
().
setMatriceTorique
(
true
);
}
src/parametragemodele.cpp
View file @
9fb59243
#include
"parametragemodele.h"
#include
<autocell.h>
#include
<Automate.h>
<<<<<<<
HEAD
#include
<autosql.h>
=======
#include
<autosql.h>
>>>>>>>
aa94038ad54c3aac4dd6ab4c2275b185fe3c1dfb
NouveauModele
::
NouveauModele
(
QWidget
*
parent
)
:
QWidget
()
{
...
...
@@ -66,6 +70,14 @@ NouveauModele::NouveauModele(QWidget* parent) : QWidget() {
//choisir une règle de transition
<<<<<<<
HEAD
=======
//liste_regle_transition->addItem("--- select ---");
std
::
vector
<
QString
>
automates
=
Database
::
getInstance
().
getAutomates
();
for
(
size_t
i
=
0
;
i
<
automates
.
size
();
i
++
)
liste_regle_transition
->
addItem
(
automates
[
i
]);
liste_regle_transition
->
addItem
(
"Nouvelle fonction de transition"
);
>>>>>>>
aa94038ad54c3aac4dd6ab4c2275b185fe3c1dfb
...
...
src/reseau_cellule_etats.cpp
View file @
9fb59243
...
...
@@ -132,3 +132,11 @@ Reseau& Reseau::operator=(const Reseau& init_grille) {
return
*
this
;
}
bool
Reseau
::
operator
==
(
const
Reseau
&
r
){
if
(
static_cast
<
int
>
(
hauteur
)
!=
r
.
getHauteur
()
||
static_cast
<
int
>
(
largeur
)
!=
r
.
getLargeur
())
return
false
;
for
(
unsigned
int
i
=
0
;
hauteur
;
i
++
)
for
(
unsigned
int
j
=
0
;
j
<
largeur
;
j
++
)
if
(
reseau
[
i
][
j
].
getIndEtat
()
!=
r
.
getReseau
()[
i
][
j
].
getIndEtat
())
return
false
;
return
true
;
};
src/voisinage.cpp
View file @
9fb59243
...
...
@@ -20,7 +20,10 @@ void RegleVoisinageNeumann::calculVoisinage(Voisinage& v, const Reseau& r) const
int
y
=
(
cellX
+
j
)
%
hauteur
;
if
(
y
<
0
)
y
=
hauteur
+
y
;
v
.
voisinage
.
push_back
(
new
Cellule
(
r
.
getReseau
()[
y
][
x
]));
if
(
this
->
getMatriceTorique
())
v
.
voisinage
.
push_back
(
new
Cellule
(
r
.
getReseau
()[
y
][
x
]));
else
if
(
x
==
cellY
+
i
&&
y
==
cellX
+
j
)
v
.
voisinage
.
push_back
(
new
Cellule
(
r
.
getReseau
()[
y
][
x
]));
}
}
...
...
@@ -41,7 +44,10 @@ void RegleVoisinageMoore::calculVoisinage(Voisinage& v, const Reseau& r) const {
int
y
=
(
cellX
+
j
)
%
hauteur
;
if
(
y
<
0
)
y
=
hauteur
+
y
;
v
.
voisinage
.
push_back
(
new
Cellule
(
r
.
getReseau
()[
y
][
x
]));
if
(
this
->
getMatriceTorique
())
v
.
voisinage
.
push_back
(
new
Cellule
(
r
.
getReseau
()[
y
][
x
]));
else
if
(
x
==
cellY
+
i
&&
y
==
cellX
+
j
)
v
.
voisinage
.
push_back
(
new
Cellule
(
r
.
getReseau
()[
y
][
x
]));
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment