Skip to content

Commit

Permalink
app: move data-window into project-window
Browse files Browse the repository at this point in the history
  • Loading branch information
quesnel committed Jan 9, 2025
1 parent 23894a2 commit a8875e9
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 88 deletions.
12 changes: 5 additions & 7 deletions app/gui/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,6 @@ static void application_show_menu(application& app) noexcept
"Show modeling editor", nullptr, &app.component_ed.is_open);
ImGui::MenuItem(
"Show output editor", nullptr, &app.output_ed.is_open);
ImGui::MenuItem("Show data editor", nullptr, &app.data_ed.is_open);

ImGui::MenuItem(
"Show component hierarchy", nullptr, &app.library_wnd.is_open);
Expand Down Expand Up @@ -391,7 +390,6 @@ static void application_show_windows(application& app) noexcept

ImGui::DockBuilderDockWindow(component_editor::name, app.main_dock_id);
ImGui::DockBuilderDockWindow(output_editor::name, app.main_dock_id);
ImGui::DockBuilderDockWindow(data_window::name, app.main_dock_id);

ImGui::DockBuilderDockWindow(app.library_wnd.name, app.right_dock_id);

Expand Down Expand Up @@ -554,8 +552,8 @@ static void show_select_model_box_recursive(application& app,
show_select_model_box_recursive(app, ed, *sibling, access);
}

auto build_unique_component_vector(application& app,
tree_node& tn) -> vector<component_id>
auto build_unique_component_vector(application& app, tree_node& tn)
-> vector<component_id>
{
vector<component_id> ret;
vector<tree_node*> stack;
Expand Down Expand Up @@ -1008,12 +1006,12 @@ void application::start_init_source(const project_id pj_id,
[&]() noexcept -> status {
if (sim_ed->pj.sim.srcs.dispatch(
src, source::operation_type::initialize)) {
data_ed.plot.clear();
sim_ed->data_ed.plot.clear();
for (sz i = 0, e = src.buffer.size(); i != e; ++i)
data_ed.plot.push_back(
sim_ed->data_ed.plot.push_back(
ImVec2{ static_cast<float>(i),
static_cast<float>(src.buffer[i]) });
data_ed.plot_available = true;
sim_ed->data_ed.plot_available = true;

if (!sim_ed->pj.sim.srcs.prepare())
notifications.try_insert(
Expand Down
71 changes: 36 additions & 35 deletions app/gui/application.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,40 @@ struct graph_editor_dialog {
void show() noexcept;
};

struct data_window {
constexpr static inline const char* name = "Data";

data_window() noexcept;
~data_window() noexcept;

void show(application& app) noexcept;

ImVector<ImVec2> plot;

ImPlotContext* context = nullptr;

struct selection {
void clear() noexcept;

void select(constant_source_id id) noexcept;
void select(text_file_source_id id) noexcept;
void select(binary_file_source_id id) noexcept;
void select(random_source_id id) noexcept;

bool is(constant_source_id id) const noexcept;
bool is(text_file_source_id id) const noexcept;
bool is(binary_file_source_id id) const noexcept;
bool is(random_source_id id) const noexcept;

std::optional<source::source_type> type_sel;
u64 id_sel = 0;
} sel;

bool show_file_dialog = false;
bool plot_available = false;
bool is_open = true;
};

struct project_window {
enum class visualization_mode { flat, tree };

Expand Down Expand Up @@ -731,6 +765,8 @@ struct project_window {

tree_node_id m_selected_tree_node = undefined<tree_node_id>();
child_id m_selected_child = undefined<child_id>();

data_window data_ed;
};

inline bool project_window::is_simulation_running() const noexcept
Expand All @@ -741,40 +777,6 @@ inline bool project_window::is_simulation_running() const noexcept
simulation_status::run_requiring);
}

struct data_window {
constexpr static inline const char* name = "Data";

data_window() noexcept;
~data_window() noexcept;

void show(project_window& ed) noexcept;

ImVector<ImVec2> plot;

ImPlotContext* context = nullptr;

struct selection {
void clear() noexcept;

void select(constant_source_id id) noexcept;
void select(text_file_source_id id) noexcept;
void select(binary_file_source_id id) noexcept;
void select(random_source_id id) noexcept;

bool is(constant_source_id id) const noexcept;
bool is(text_file_source_id id) const noexcept;
bool is(binary_file_source_id id) const noexcept;
bool is(random_source_id id) const noexcept;

std::optional<source::source_type> type_sel;
u64 id_sel = 0;
} sel;

bool show_file_dialog = false;
bool plot_available = false;
bool is_open = true;
};

class component_editor
{
public:
Expand Down Expand Up @@ -1047,7 +1049,6 @@ struct application {

component_editor component_ed;
output_editor output_ed;
data_window data_ed;

grid_editor_dialog grid_dlg;
graph_editor_dialog graph_dlg;
Expand Down
Loading

0 comments on commit a8875e9

Please sign in to comment.