Skip to content

Commit

Permalink
wip core: move parameters from dynamics into simulation vector
Browse files Browse the repository at this point in the history
  • Loading branch information
quesnel committed Jan 9, 2025
1 parent a1cebf6 commit f93e68b
Show file tree
Hide file tree
Showing 13 changed files with 1,264 additions and 2,290 deletions.
425 changes: 3 additions & 422 deletions app/gui/editor.cpp

Large diffs are not rendered by default.

25 changes: 15 additions & 10 deletions app/gui/generic/simulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,21 +165,21 @@ static void show_dynamics_values(project_window& /*sim*/,
const qss1_integrator& dyn)
{
ImGui::TextFormat("X {}", dyn.X);
ImGui::TextFormat("dQ {}", dyn.default_dQ);
ImGui::TextFormat("dQ {}", dyn.dQ);
}

static void show_dynamics_values(project_window& /*sim*/,
const qss2_integrator& dyn)
{
ImGui::TextFormat("X {}", dyn.X);
ImGui::TextFormat("dQ {}", dyn.default_dQ);
ImGui::TextFormat("dQ {}", dyn.dQ);
}

static void show_dynamics_values(project_window& /*sim*/,
const qss3_integrator& dyn)
{
ImGui::TextFormat("X {}", dyn.X);
ImGui::TextFormat("dQ {}", dyn.default_dQ);
ImGui::TextFormat("dQ {}", dyn.dQ);
}

static void show_dynamics_values(project_window& /*sim*/, const qss1_sum_2& dyn)
Expand Down Expand Up @@ -519,7 +519,9 @@ static void show_dynamics_values(project_window& /*sim*/,
ImGui::TextFormat("sigma={}", dyn.exec.timer);
}

static void show_model_dynamics(project_window& ed, model& mdl) noexcept
static void show_model_dynamics(application& app,
project_window& ed,
model& mdl) noexcept
{
dispatch(mdl, [&]<typename Dynamics>(Dynamics& dyn) {
add_input_attribute(ed, dyn);
Expand All @@ -534,7 +536,11 @@ static void show_model_dynamics(project_window& ed, model& mdl) noexcept
if (ed.allow_user_changes) {
ImGui::PushID(1);
ImGui::PushItemWidth(120.0f);
show_dynamics_inputs(ed, dyn);
show_parameter_editor(
app,
ed,
mdl.type,
ed.pj.sim.parameters[get_index(ed.pj.sim.models.get_id(mdl))]);
ImGui::PopItemWidth();
ImGui::PopID();
}
Expand All @@ -543,7 +549,7 @@ static void show_model_dynamics(project_window& ed, model& mdl) noexcept
});
}

void show_top_with_identifier(application& /*app*/, project_window& ed) noexcept
void show_top_with_identifier(application& app, project_window& ed) noexcept
{
for_each_data(ed.pj.sim.models, [&](model& mdl) noexcept -> void {
const auto mdl_id = ed.pj.sim.models.get_id(mdl);
Expand All @@ -556,13 +562,12 @@ void show_top_with_identifier(application& /*app*/, project_window& ed) noexcept
"{}\n{}", mdl_index, dynamics_type_names[ordinal(mdl.type)]);

ImNodes::EndNodeTitleBar();
show_model_dynamics(ed, mdl);
show_model_dynamics(app, ed, mdl);
ImNodes::EndNode();
});
}

void show_top_without_identifier(application& /*app*/,
project_window& ed) noexcept
void show_top_without_identifier(application& app, project_window& ed) noexcept
{
for_each_data(ed.pj.sim.models, [&](model& mdl) noexcept -> void {
const auto mdl_id = ed.pj.sim.models.get_id(mdl);
Expand All @@ -572,7 +577,7 @@ void show_top_without_identifier(application& /*app*/,
ImNodes::BeginNodeTitleBar();
ImGui::TextUnformatted(dynamics_type_names[ordinal(mdl.type)]);
ImNodes::EndNodeTitleBar();
show_model_dynamics(ed, mdl);
show_model_dynamics(app, ed, mdl);
ImNodes::EndNode();
});
}
Expand Down
Loading

0 comments on commit f93e68b

Please sign in to comment.