satdump/src-core/common/widgets/waterfall_plot.h

58 lines
1.2 KiB
C
Raw Normal View History

2022-04-28 13:38:07 +02:00
#pragma once
#include "imgui/imgui.h"
#include <cstdint>
#include <vector>
2022-11-29 00:01:26 +01:00
#include <mutex>
2022-11-29 20:15:06 +01:00
#include "common/colormaps.h"
2022-04-28 13:38:07 +02:00
namespace widgets
{
class WaterfallPlot
{
private:
2022-11-29 00:01:26 +01:00
int fft_max_size;
2022-04-28 13:38:07 +02:00
int fft_size;
int fft_lines;
const int resolution = 2000; // Number of colors
2023-02-11 01:07:39 +01:00
unsigned int texture_id = 0;
2023-02-10 23:10:24 +01:00
uint32_t *raw_img_buffer = nullptr;
2022-04-28 13:38:07 +02:00
std::vector<uint32_t> palette;
2022-11-29 00:01:26 +01:00
std::mutex work_mtx;
2023-02-10 23:10:24 +01:00
int last_curr_width = -1;
int last_curr_height = -1;
int curr_width;
int curr_height;
2023-11-06 11:23:20 -05:00
bool need_update = false;
2023-02-11 01:07:39 +01:00
int waterfall_i_mod = 0;
int waterfall_i = 0;
2022-04-28 13:38:07 +02:00
public:
float scale_min, scale_max;
public:
2023-02-11 01:07:39 +01:00
WaterfallPlot(int size, int lines);
2022-04-28 13:38:07 +02:00
~WaterfallPlot();
2022-05-08 13:01:05 +02:00
void draw(ImVec2 size, bool active = true);
2022-11-29 00:01:26 +01:00
void set_size(int size)
{
work_mtx.lock();
if (size <= fft_max_size)
fft_size = size;
work_mtx.unlock();
}
2022-11-29 20:15:06 +01:00
2023-02-11 01:07:39 +01:00
void push_fft(float *values);
void set_rate(int input_rate, int output_rate);
2022-11-29 20:15:06 +01:00
void set_palette(colormaps::Map palette, bool mtx = true);
2022-04-28 13:38:07 +02:00
};
}