Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
quesnel committed Jan 15, 2025
1 parent a7da40c commit 2a5ab5c
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 19 deletions.
1 change: 1 addition & 0 deletions app/gui/application.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,7 @@ struct project_editor {
bool show_identifiers = false;

bool is_dock_init = false;
bool disable_access = true;

/** Return true if a simulation is currently running.
*
Expand Down
39 changes: 35 additions & 4 deletions app/gui/library-window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,39 @@ static void open_component(application& app, component_id id) noexcept
static bool is_component_open(const application& app,
const component_id id) noexcept
{
for (const auto& pj : app.pjs)
if (pj.pj.head() == id)
return true;
if (const auto* compo = app.mod.components.try_to_get(id)) {
switch (compo->type) {
case component_type::graph:
for (const auto& g : app.graphs)
if (g.get_id() == id)
return true;
break;

case component_type::grid:
for (const auto& g : app.grids)
if (g.get_id() == id)
return true;
break;

case component_type::hsm:
for (const auto& g : app.hsms)
if (g.get_id() == id)
return true;
break;

case component_type::internal:
break;

case component_type::none:
break;

case component_type::simple:
for (const auto& g : app.generics)
if (g.get_id() == id)
return true;
break;
}
}

return false;
}
Expand Down Expand Up @@ -520,7 +550,8 @@ void library_window::try_set_component_as_project(
auto& pj = app.pjs.get(id);

if (auto* c = app.mod.components.try_to_get(compo_id); c) {
return pj.pj.set(app.mod, *c);
irt_check(pj.pj.set(app.mod, *c));
pj.disable_access = false;
}
}

Expand Down
3 changes: 3 additions & 0 deletions app/gui/project-editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1166,6 +1166,9 @@ static void show_simulation_editor_treenode(application& app,

auto project_editor::show(application& app) noexcept -> show_result_t
{
if (disable_access)
return show_result_t::success;

if (not is_dock_init) {
ImGui::SetNextWindowDockID(app.main_dock_id);
is_dock_init = true;
Expand Down
2 changes: 1 addition & 1 deletion lib/include/irritator/core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6597,7 +6597,7 @@ inline status priority_queue::transition(simulation& sim,
inline constexpr simulation_memory_requirement::simulation_memory_requirement(
unsigned model_nb) noexcept
{
model_nb = model_nb == 0 ? 256u : model_nb;
models = model_nb < 256u ? 256u : model_nb;
connections = models * 10;
hsms = models / 10;
dated_messages = models / 20;
Expand Down
19 changes: 10 additions & 9 deletions lib/include/irritator/modeling.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,14 +201,15 @@ struct connection {
}
};

/// A wrapper to the simulation @c hierarchical_state_machine class.
///
/// This component is different from others. It does not have any child nor
/// connection. @c project class during import, the @c
/// hierarchical_state_machine is copied into the simulation HSM data array. The
/// parameter @c a and @c b are store into the @c children_parameters of the @c
/// generic_component.

/**
A wrapper to the simulation @c hierarchical_state_machine class.
This component is different from others. It does not have any child nor
connection. @c project class during import, the @c
hierarchical_state_machine is copied into the simulation HSM data array. The
parameter @c a and @c b are store into the @c children_parameters of the @c
generic_component.
*/
class hsm_component
{
public:
Expand Down Expand Up @@ -1601,7 +1602,7 @@ class project
};

project() noexcept
: sim{ simulation_memory_requirement(1024 * 1024 * 8),
: sim{ simulation_memory_requirement(1u << 16u),
irt::external_source_memory_requirement{} }
{}

Expand Down
9 changes: 4 additions & 5 deletions lib/src/project.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1312,9 +1312,8 @@ status project::set(modeling& mod, component& compo) noexcept

irt_check(make_component_cache(*this, mod));

simulation_memory_requirement smr(numbers.model_nb);
// smr.hsms = std::max(numbers.hsm_nb, smr.hsms);
smr.hsms = numbers.hsm_nb;
simulation_memory_requirement smr(std::bit_ceil(numbers.model_nb));
smr.hsms = std::bit_ceil(std::max(numbers.hsm_nb, smr.hsms));
sim.destroy();
sim.realloc(smr, external_source_memory_requirement{});

Expand Down Expand Up @@ -1662,8 +1661,8 @@ auto project::tree_nodes_size() const noexcept -> std::pair<int, int>
}

template<typename T>
static auto already_name_exists(const T& obs, std::string_view str) noexcept
-> bool
static auto already_name_exists(const T& obs,
std::string_view str) noexcept -> bool
{
return std::any_of(
obs.begin(), obs.end(), [str](const auto& o) noexcept -> bool {
Expand Down

0 comments on commit 2a5ab5c

Please sign in to comment.