Skip to content

Commit

Permalink
wip: project-externa- updatre
Browse files Browse the repository at this point in the history
  • Loading branch information
quesnel committed Jan 10, 2025
1 parent 5652cac commit 0c902aa
Show file tree
Hide file tree
Showing 4 changed files with 332 additions and 334 deletions.
56 changes: 29 additions & 27 deletions app/gui/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -993,35 +993,37 @@ void application::start_init_source(const project_id pj_id,
const u64 id,
const source::source_type type) noexcept
{
debug::ensure(any_equal(
type, source::source_type::constant, source::source_type::random));

add_gui_task([&, id, type]() noexcept {
if (auto* sim_ed = pjs.try_to_get(pj_id)) {
source src;
src.id = id;
src.type = type;

attempt_all(
[&]() noexcept -> status {
if (sim_ed->pj.sim.srcs.dispatch(
src, source::operation_type::initialize)) {
sim_ed->data_ed.fill_plot(src.buffer);

if (not sim_ed->pj.sim.srcs.prepare())
notifications.try_insert(
log_level::error,
[](auto& title, auto& msg) noexcept {
title = "Data error";
msg = "Fail to prepare data from source.";
});
}
return success();
},
[&]() {
notifications.try_insert(
log_level::error, [](auto& title, auto& msg) noexcept {
title = "Data error";
msg = "Fail to prepare data from source.";
});
});
if (type == source::source_type::constant) {
if (auto* c = sim_ed->pj.sim.srcs.constant_sources.try_to_get(
enum_cast<constant_source_id>(id))) {
(void)c->init();
sim_ed->data_ed.fill_plot(
std::span(c->buffer.data(), c->length));
}
} else {
if (auto* c = sim_ed->pj.sim.srcs.random_sources.try_to_get(
enum_cast<random_source_id>(id))) {
c->a = 0.0;
c->b = 0.0;
c->distribution = distribution_type::uniform_real;
c->max_clients = 1;
(void)c->init();

chunk_type tmp;
source src;
src.buffer = tmp;
src.id = id;
src.type = type;
(void)c->init(src);

sim_ed->data_ed.fill_plot(src.buffer);
}
}
}
});
}
Expand Down
4 changes: 2 additions & 2 deletions app/gui/application.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ struct graph_editor_dialog {
class project_external_source_editor
{
public:
enum class status {
enum class plot_status {
empty,
work_in_progress,
data_available,
Expand Down Expand Up @@ -595,7 +595,7 @@ class project_external_source_editor
private:
vector<ImVec2> plot;
ImPlotContext* context = nullptr;
status m_status = status::empty;
plot_status m_status = plot_status::empty;
bool show_file_dialog = false;

spin_mutex mutex;
Expand Down
Loading

0 comments on commit 0c902aa

Please sign in to comment.