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
18076b9b
Verified
Commit
18076b9b
authored
Jun 12, 2021
by
Romain De Laage De Bellefaye
🌳
Browse files
Add control on border behaviour
parent
8650fa0a
Changes
5
Hide whitespace changes
Inline
Side-by-side
includes/Automate.h
View file @
18076b9b
...
...
@@ -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 @
18076b9b
...
...
@@ -64,6 +64,7 @@ class AutoCell : public QWidget
QGridLayout
*
grid_run_control
;
QCheckBox
*
matriceTorique
;
QLabel
*
lab_time_step
;
QLineEdit
*
edit_time_step
;
QPushButton
*
button_valider_delai
;
...
...
@@ -135,6 +136,7 @@ class AutoCell : public QWidget
void
previous
();
/// Aller en avant dans la simulation
void
next
();
void
setMatriceTorique
(
int
val
);
};
#endif // AUTOCELL_H
includes/voisinage.h
View file @
18076b9b
...
...
@@ -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 @
18076b9b
...
...
@@ -141,6 +141,9 @@ 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)"
);
...
...
@@ -166,13 +169,14 @@ 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
(
edit_time_step
,
2
,
1
);
grid_run_control
->
addWidget
(
button_valider_delai
,
2
,
2
);
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
;
...
...
@@ -396,6 +400,8 @@ void AutoCell::initAutomate(const QString& name) {
QString
msg
(
m
);
afficherErreur
(
msg
);
}
Automate
::
getInstance
().
setMatriceTorique
(
true
);
matriceTorique
->
setCheckState
(
Qt
::
Checked
);
}
void
AutoCell
::
changeDelai
()
{
...
...
@@ -422,3 +428,10 @@ void AutoCell::previous() {
afficherErreur
(
msg
);
}
}
void
AutoCell
::
setMatriceTorique
(
int
val
)
{
if
(
val
==
0
)
Automate
::
getInstance
().
setMatriceTorique
(
false
);
else
Automate
::
getInstance
().
setMatriceTorique
(
true
);
}
src/voisinage.cpp
View file @
18076b9b
...
...
@@ -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