5#include "ChannelMappingPanel.hpp"
9#include "../objects/Project.hpp"
10#include "../objects/Sensor.hpp"
18 const Project*
const initial_project
20 panel_name(
std::string(
"Channel Mapping") + get_imgui_stable_name()),
22 active_project(initial_project)
28 return panel_name.c_str();
33 if (ImGui::Begin(panel_name.c_str())) {
34 if (active_project ==
nullptr)
35 ImGui::Text(
"No project is loaded.");
37 ImGui::SeparatorText(
"Create Channel Mapping");
38 draw_new_channel_mapping();
41 if (new_entry_cache.signal !=
nullptr && new_entry_cache.sensor !=
nullptr) {
43 active_project->get_id(),
44 new_entry_cache.signal->get_id(),
45 new_entry_cache.sensor->get_id()
48 new_entry_cache.signal =
nullptr;
49 new_entry_cache.sensor =
nullptr;
52 ImGui::SeparatorText(
"Existing Channel Mapping");
53 draw_existing_channel_mapping();
61 const Project*
const new_project
64 active_project = new_project;
67const char* ChannelMappingPanel::get_imgui_stable_name() noexcept
69 return "###ChannelMappingPanel";
72void ChannelMappingPanel::draw_new_channel_mapping() noexcept
76 if (ImGui::BeginTable(
"##NewChannelMapping", 2, table_flags)) {
77 ImGui::TableSetupColumn(
"Signal", ImGuiTableColumnFlags_WidthStretch);
78 ImGui::TableSetupColumn(
"Sensor", ImGuiTableColumnFlags_WidthStretch);
79 ImGui::TableHeadersRow();
80 ImGui::TableNextRow();
81 ImGui::TableNextColumn();
83 bool need_to_force =
false;
87 if (ImGui::BeginCombo(
88 "##NewAssociationSignal",
89 new_entry_cache.signal ==
nullptr ?
"Select signal..." : new_entry_cache.signal->get_imgui_name(),
93 const bool is_selected = new_entry_cache.signal ==
nullptr ? false : signal == *new_entry_cache.signal;
96 if (ImGui::Selectable(signal.get_imgui_name(), is_selected))
97 new_entry_cache.signal = &signal;
101 ImGui::SetItemDefaultFocus();
105 need_to_force =
true;
108 ImGui::TableNextColumn();
112 if (ImGui::BeginCombo(
113 "##NewAssociationSensor",
114 new_entry_cache.sensor ==
nullptr ?
"Select sensor..." : new_entry_cache.sensor->get_imgui_name(),
117 for (
const auto& sensor : active_project->observe_sensors()) {
118 const bool is_selected = new_entry_cache.sensor ==
nullptr ? false : sensor == *new_entry_cache.sensor;
120 if (ImGui::Selectable(sensor.get_imgui_name(), is_selected))
121 new_entry_cache.sensor = &sensor;
124 ImGui::SetItemDefaultFocus();
128 need_to_force =
true;
134 app->increment_forced_frames();
138void ChannelMappingPanel::draw_existing_channel_mapping() const noexcept
140 if (ImGui::BeginTable(
"##ExistingChannelMapping", 2, table_flags)) {
141 ImGui::TableSetupColumn(
"Signal", ImGuiTableColumnFlags_WidthStretch);
142 ImGui::TableSetupColumn(
"Sensor", ImGuiTableColumnFlags_WidthStretch);
143 ImGui::TableHeadersRow();
146 for (
const auto& [signal, sensor] : active_project->observe_associations()) {
147 ImGui::TableNextRow();
148 ImGui::TableNextColumn();
150 ImGui::TextUnformatted(
signal.get_imgui_name());
151 ImGui::TableNextColumn();
153 ImGui::TextUnformatted(sensor.get_imgui_name());
AllNotifications specification.
EchoMap class specification.
Audio signal class specification.
const char * get_imgui_name() const noexcept override
Retrieves the name of the IPanel for Dear ImGui API functions.
void draw() noexcept override
Draw the panel to the active rendering context.
void change_active_project(const Project *new_project) override
Updates the active Project being described by the IPanel.
ChannelMappingPanel(EchoMap *app, const Project *initial_project=nullptr)
Create a new ChannelMappingPanel to describe and configure Signal-Sensor mappings.
The EchoMap maintains state for the application including WebGPU and Dear ImGui context,...
auto observe_signals() const noexcept
Provides a transformed view for stored Signal objects in the Project.
The main EchoMap outermost namespace for all non-exported symbols.
A notification indicating that a new channel mapping should be established.