2024-10-15 21:59:48 -04:00
|
|
|
#include "core/style.h"
|
2021-07-26 11:11:49 +02:00
|
|
|
#include <array>
|
|
|
|
|
#include <cstring>
|
|
|
|
|
#include "snr_plot.h"
|
2024-01-24 13:09:24 -05:00
|
|
|
#include "themed_widgets.h"
|
2021-07-26 11:11:49 +02:00
|
|
|
|
2021-07-26 11:25:36 +02:00
|
|
|
namespace widgets
|
|
|
|
|
{
|
|
|
|
|
void SNRPlotViewer::draw(float snr, float peak_snr)
|
|
|
|
|
{
|
|
|
|
|
ImGui::Text("SNR (dB) : ");
|
|
|
|
|
ImGui::SameLine();
|
2024-01-21 14:57:41 -05:00
|
|
|
ImGui::TextColored(snr > 2 ? snr > 10 ? style::theme.green : style::theme.orange : style::theme.red, "%0.3f", snr);
|
2021-07-26 11:25:36 +02:00
|
|
|
|
|
|
|
|
ImGui::Text("Peak SNR (dB) : ");
|
|
|
|
|
ImGui::SameLine();
|
2024-01-21 14:57:41 -05:00
|
|
|
ImGui::TextColored(peak_snr > 2 ? peak_snr > 10 ? style::theme.green : style::theme.orange : style::theme.red, "%0.3f", peak_snr);
|
2021-07-26 11:25:36 +02:00
|
|
|
|
|
|
|
|
std::memmove(&snr_history[0], &snr_history[1], (200 - 1) * sizeof(float));
|
|
|
|
|
snr_history[200 - 1] = snr;
|
|
|
|
|
|
2023-02-23 19:20:14 +00:00
|
|
|
// Average of the snr_history
|
|
|
|
|
float avg_snr = 0.0f;
|
|
|
|
|
for (int i = 0; i < 200; i++)
|
|
|
|
|
{
|
2023-03-19 19:53:26 +00:00
|
|
|
if (snr_history[i] >= 0 && snr_history[i] <= peak_snr){
|
|
|
|
|
avg_snr += snr_history[i];
|
|
|
|
|
}
|
2023-02-23 19:20:14 +00:00
|
|
|
}
|
|
|
|
|
avg_snr = avg_snr / 200;
|
|
|
|
|
|
|
|
|
|
ImGui::Text("Avg SNR (dB) : ");
|
|
|
|
|
ImGui::SameLine();
|
2024-01-21 14:57:41 -05:00
|
|
|
ImGui::TextColored(avg_snr > 2 ? avg_snr > 10 ? style::theme.green : style::theme.orange : style::theme.red, "%0.3f", avg_snr);
|
2023-02-23 19:20:14 +00:00
|
|
|
|
2024-01-24 13:09:24 -05:00
|
|
|
widgets::ThemedPlotLines(style::theme.plot_bg.Value, "", snr_history, IM_ARRAYSIZE(snr_history), 0, "", 0.0f, 25.0f,
|
|
|
|
|
ImVec2(200 * ui_scale, 50 * ui_scale));
|
2021-07-26 11:11:49 +02:00
|
|
|
}
|
|
|
|
|
}
|