16#include "../objects/Project.hpp"
26 const Project*
const initial_project
29 std::numeric_limits<double>::max(),
30 std::numeric_limits<double>::lowest(),
31 Signal::normalised_range.first,
32 Signal::normalised_range.second
34 panel_name(
std::string(
"Signal Waveform Preview") + get_imgui_stable_name()),
35 parent_worker(parent_worker),
36 active_project(initial_project)
39 sigc::mem_fun(*
this, &SignalWaveformPanel::handle_downsampled_result)
43SignalWaveformPanel::~SignalWaveformPanel() noexcept = default;
49 return panel_name.c_str();
54 if (ImGui::Begin(panel_name.c_str())) {
55 if (active_project ==
nullptr)
56 ImGui::Text(
"No project is loaded.");
57 else if (ImPlot::BeginAlignedPlots(
"##WaveformAlignedGroup")) {
58 ImPlot::PushStyleColor(ImPlotCol_FrameBg, ImVec4(0.0f, 0.0f, 0.0f, 0.0f));
59 bool drawn_any =
false;
61 for (
const auto& signal : active_project->share_signals()) {
65 ImGui::Text(
"Loading downsampled variant of %s...", signal->get_imgui_name());
66 else if (ImPlot::BeginPlot(downsampled->get_imgui_name())) {
68 ImPlot::SetupAxes(
"Time (seconds)",
"Amplitude");
75 &SignalWaveformPanel::get_indexed_signal_point,
77 static_cast<int>(downsampled->get_sample_count()),
85 ImPlot::EndAlignedPlots();
86 ImPlot::PopStyleColor();
89 ImGui::Text(
"No signals are available.");
97 const Project*
const new_project
100 active_project = new_project;
102 update_bounding_box();
105const char* SignalWaveformPanel::get_imgui_stable_name() noexcept
107 return "###SignalWaveformPanel";
110void SignalWaveformPanel::handle_downsampled_result(
111 DownsampleResult&& result
115 auto signal = std::move(result).take_downsampled();
118 LOG_F_WARN(
"Received an unexpected result for the downsampled Signal {}.", signal->get_name());
119 const auto signal_name_view = signal->get_name();
120 auto [it, success] =
downsample_cache.emplace(result.get_source_id(), std::move(signal));
123 LOG_F_ERROR(
"Could not store the downsampled Signal {} in the cache.", signal_name_view);
129 ds_slot_it->second = std::move(signal);
132 update_bounding_box(*ds_slot_it->second);
135ImPlotPoint SignalWaveformPanel::get_indexed_signal_point(
137 void*
const user_data
140 const auto*
const signal =
static_cast<CallbackData*
>(user_data)->signal;
141 return {
signal->get_time_at_index(index),
signal->begin()[index]};
144void SignalWaveformPanel::update_bounding_box(
148 if (
signal.get_sample_count() > 0) {
155void SignalWaveformPanel::update_bounding_box() noexcept
167 assert(signal !=
nullptr);
184 return downsampled_it->second.get();
DownsampleResult specification.
DownsampleTask specification.
EchoMap portable logger specification.
#define LOG_F_WARN(msg,...)
Logs a formatted warning-level message using echomap::Logger::log_f.
#define LOG_F_ERROR(msg,...)
Logs a formatted error-level message using echomap::Logger::log_f.
Audio signal class specification.
WorkerResultDespatcher specification.
A single channel of discretely sampled audio data.
static constexpr std::pair< Sample::AmplitudeT, Sample::AmplitudeT > normalised_range
The range within which the amplitude values are normalised.
Manages channels for WorkerResult message routing.
ResultChannel< DownsampleResult > downsample_finished_channel
Channel to indicate completion of DownsampleTask.
A Worker provides an encapsulated thread-safe despatch model for submitting work and reviewing result...
The main EchoMap outermost namespace for all non-exported symbols.