Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Maintenance - Mise à jour mensuelle Lundi 6 Février entre 7h00 et 9h00
Open sidebar
Gauthier Quesnel
irritator
Commits
37614c06
Commit
37614c06
authored
Jul 07, 2020
by
Gauthier Quesnel
Browse files
gui: add simulation-until feature
parent
33a61d41
Pipeline
#15105
passed with stage
in 1 minute and 11 seconds
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
app/gui/node-editor.cpp
View file @
37614c06
...
...
@@ -2539,6 +2539,65 @@ show_simulation_box(bool* show_simulation)
}
}
}
if
(
ed
->
st
==
simulation_status
::
running_step
)
{
ImGui
::
SameLine
();
if
(
ImGui
::
Button
(
"step x100"
))
{
for
(
int
i
=
0
;
i
<
100
;
++
i
)
{
if
(
ed
->
simulation_current
<
ed
->
simulation_end
)
{
if
(
auto
ret
=
ed
->
sim
.
run
(
ed
->
simulation_current
);
irt
::
is_bad
(
ret
))
{
log_w
.
log
(
3
,
"Simulation failure (%s)
\n
"
,
irt
::
status_string
(
ret
));
ed
->
st
=
simulation_status
::
success
;
}
}
}
}
}
}
if
(
ImGui
::
CollapsingHeader
(
"Simulation until"
))
{
if
(
ImGui
::
Button
(
"init"
))
{
ed
->
sim
.
clean
();
initialize_observation
(
ed
);
ed
->
simulation_current
=
ed
->
simulation_begin
;
ed
->
simulation_until
=
static_cast
<
float
>
(
ed
->
simulation_begin
);
if
(
auto
ret
=
ed
->
sim
.
initialize
(
ed
->
simulation_current
);
irt
::
is_bad
(
ret
))
{
log_w
.
log
(
3
,
"Simulation initialization failure (%s)
\n
"
,
irt
::
status_string
(
ret
));
ed
->
st
=
simulation_status
::
success
;
}
else
{
ed
->
st
=
simulation_status
::
running_step
;
}
}
if
(
ed
->
st
==
simulation_status
::
running_step
)
{
ImGui
::
SliderFloat
(
"date"
,
&
ed
->
simulation_until
,
static_cast
<
float
>
(
ed
->
simulation_current
),
static_cast
<
float
>
(
ed
->
simulation_end
));
if
(
ImGui
::
Button
(
"run until"
))
{
while
(
ed
->
simulation_current
<
static_cast
<
double
>
(
ed
->
simulation_until
))
{
if
(
auto
ret
=
ed
->
sim
.
run
(
ed
->
simulation_current
);
irt
::
is_bad
(
ret
))
{
log_w
.
log
(
3
,
"Simulation failure (%s)
\n
"
,
irt
::
status_string
(
ret
));
ed
->
st
=
simulation_status
::
success
;
}
}
}
}
}
}
...
...
@@ -2556,8 +2615,10 @@ show_simulation_box(bool* show_simulation)
ImGui
::
ProgressBar
(
static_cast
<
float
>
(
fraction
));
// for (const auto& obs : ed->observation_outputs) {
// if (obs.observation_type == observation_output::type::plot ||
// obs.observation_type == observation_output::type::both)
// if (obs.observation_type ==
// observation_output::type::plot ||
// obs.observation_type ==
// observation_output::type::both)
// ImGui::PlotLines(obs.name.c_str(),
// obs.ys.data(),
// static_cast<int>(obs.ys.size()),
...
...
@@ -2567,9 +2628,11 @@ show_simulation_box(bool* show_simulation)
// obs.max,
// ImVec2(0.f, 50.f));
// if (obs.observation_type == observation_output::type::file ||
// obs.observation_type == observation_output::type::both)
// ImGui::Text("%s: output file", obs.name);
// if (obs.observation_type ==
// observation_output::type::file ||
// obs.observation_type ==
// observation_output::type::both) ImGui::Text("%s:
// output file", obs.name);
//}
}
}
...
...
app/gui/node-editor.hpp
View file @
37614c06
...
...
@@ -257,6 +257,7 @@ struct editor
double
simulation_begin
=
0.0
;
double
simulation_end
=
10.0
;
double
simulation_current
=
10.0
;
float
simulation_until
;
std
::
thread
simulation_thread
;
simulation_status
st
=
simulation_status
::
success
;
bool
simulation_show_value
=
false
;
...
...
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