Skip to content
GitLab
Menu
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
a698a567
Verified
Commit
a698a567
authored
Jun 11, 2021
by
Romain De Laage De Bellefaye
🌳
Browse files
Merge branch 'master' of gitlab.utc.fr:rdelaage/lo21-projet
parents
9eac69c4
3416d4fa
Pipeline
#79654
passed with stage
in 15 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
includes/autosql.h
View file @
a698a567
...
...
@@ -39,7 +39,7 @@ class Database {
void
initEnsEtat
(
Automate
&
a
)
const
;
void
saveAutomaton
(
const
Automate
&
a
)
const
;
void
saveFunction
(
const
QString
&
name
,
const
Fonction
&
f
)
const
;
void
saveVoisinage
(
const
QString
&
name
,
const
RegleVoisinage
&
r
)
const
;
void
saveVoisinage
(
const
QString
&
name
,
RegleVoisinage
&
r
)
const
;
void
saveEnsemble
(
Automate
&
a
)
const
;
void
initSingletonAutomate
(
const
QString
&
modele
)
const
;
};
...
...
src/autocell.cpp
View file @
a698a567
...
...
@@ -59,6 +59,7 @@ AutoCell::AutoCell(QWidget* parent):QWidget(parent)
button_add_model
->
setFixedWidth
(
140
);
connect
(
button_add_model
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
defNouveauModele
()));
connect
(
button_add_model
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
reinitialiserAutomate
()));
liste
=
new
QComboBox
(
win_model_choice
);
liste
->
setPlaceholderText
(
"--- select ---"
);
...
...
src/autosql.cpp
View file @
a698a567
...
...
@@ -182,25 +182,30 @@ RegleVoisinage* Database::getRegleVoisinage(const QString& name) const {
regle
->
setr
(
query
.
value
(
"rayon"
).
toInt
());
return
regle
;
}
else
if
(
type
!=
3
)
// n'existe pas
throw
"Unknown type of rule"
;
query
.
prepare
(
"SELECT x, y FROM coord_voisinage WHERE id = :id"
);
query
.
bindValue
(
":id"
,
name
);
query
.
exec
();
if
(
!
query
.
first
())
throw
"There must be at least one coord in this rule"
;
RegleVoisinageArbitraire
*
regle
=
new
RegleVoisinageArbitraire
;
do
{
/// @todo voisinage arbitraire
///
/// dans l'attente de la possibilité de le faire
}
while
(
query
.
next
());
return
regle
;
}
else
if
(
type
!=
3
)
{
query
.
prepare
(
"SELECT x, y FROM coord_voisinage WHERE id = :id"
);
query
.
bindValue
(
":id"
,
name
);
query
.
exec
();
if
(
!
query
.
first
())
throw
"There must be at least one coord in this rule"
;
RegleVoisinageArbitraire
*
regle
=
new
RegleVoisinageArbitraire
;
Coordonnees
coord
;
do
{
coord
.
x
=
query
.
value
(
0
).
toUInt
();
coord
.
y
=
query
.
value
(
1
).
toUInt
();
regle
->
coordonnees
.
push_back
(
coord
);
}
while
(
query
.
next
());
query
.
prepare
(
"SELECT COUNT(*) FROM coord_voisinage WHERE id = :id"
);
query
.
bindValue
(
":id"
,
name
);
query
.
exec
();
regle
->
setNbVoisins
(
query
.
value
(
0
).
toUInt
());
return
regle
;
}
}
/// Retourne un descriptif des réseaux ("id", "nom", "id", "nom", etc.) liés à un automate
...
...
@@ -269,7 +274,7 @@ void Database::saveAutomaton(const Automate& a) const {
query
.
exec
();
saveFunction
(
a
.
getTitle
().
c_str
(),
a
.
getFonction
());
saveVoisinage
(
a
.
getTitle
().
c_str
(),
a
.
getRegleVoisinage
());
saveVoisinage
(
a
.
getTitle
().
c_str
(),
const_cast
<
RegleVoisinage
&>
(
a
.
getRegleVoisinage
())
)
;
stockerReseau
(
a
.
getReseauInit
(),
"To be determined"
,
a
.
getTitle
().
c_str
());
}
...
...
@@ -401,7 +406,21 @@ void Database::saveVoisinage(const QString& name, const RegleVoisinage& r) const
query
.
exec
();
}
else
if
(
type
==
3
)
{
//Arbitrary
throw
"Unimplemented!"
;
query
.
prepare
(
"INSERT INTO regles_voisinage (id, type, rayon) VALUES (:nom, :type, :rayon)"
);
query
.
bindValue
(
":nom"
,
name
);
query
.
bindValue
(
":type"
,
type
);
query
.
bindValue
(
":rayon"
,
r
.
getr
());
query
.
exec
();
RegleVoisinageArbitraire
&
new_r
=
dynamic_cast
<
RegleVoisinageArbitraire
&>
(
r
);
for
(
size_t
i
=
0
;
i
<
new_r
.
coordonnees
.
size
()
;
i
++
)
{
query
.
prepare
(
"INSERT INTO coord_voisinage VALUES (:nom, :x, :y)"
);
query
.
bindValue
(
":nom"
,
name
);
query
.
bindValue
(
":x"
,
new_r
.
coordonnees
[
i
].
x
);
query
.
bindValue
(
":y"
,
new_r
.
coordonnees
[
i
].
y
);
query
.
exec
();
}
}
else
{
throw
"Unknown type!"
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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