2020-06-10 04:13:56 +02:00
|
|
|
#pragma once
|
|
|
|
#include <imgui.h>
|
|
|
|
#include <imgui_internal.h>
|
|
|
|
#include <vector>
|
|
|
|
#include <mutex>
|
|
|
|
#include <GL/glew.h>
|
2020-07-19 15:59:44 +02:00
|
|
|
#include <imutils.h>
|
2020-09-20 00:19:39 +02:00
|
|
|
#include <gui/bandplan.h>
|
2020-08-07 14:29:06 +02:00
|
|
|
#include <algorithm>
|
2020-06-10 04:13:56 +02:00
|
|
|
|
2020-07-11 21:15:10 +02:00
|
|
|
#define WATERFALL_RESOLUTION 1000000
|
|
|
|
|
2020-06-10 04:13:56 +02:00
|
|
|
namespace ImGui {
|
2020-07-11 21:15:10 +02:00
|
|
|
|
2020-08-10 02:30:25 +02:00
|
|
|
class WaterfallVFO {
|
|
|
|
public:
|
|
|
|
void setOffset(float offset);
|
|
|
|
void setCenterOffset(float offset);
|
|
|
|
void setBandwidth(float bw);
|
|
|
|
void setReference(int ref);
|
|
|
|
void updateDrawingVars(float viewBandwidth, float dataWidth, float viewOffset, ImVec2 widgetPos, int fftHeight);
|
|
|
|
void draw(ImGuiWindow* window, bool selected);
|
|
|
|
|
|
|
|
enum {
|
|
|
|
REF_LOWER,
|
|
|
|
REF_CENTER,
|
|
|
|
REF_UPPER,
|
|
|
|
_REF_COUNT
|
|
|
|
};
|
|
|
|
|
|
|
|
float generalOffset;
|
|
|
|
float centerOffset;
|
|
|
|
float lowerOffset;
|
|
|
|
float upperOffset;
|
|
|
|
float bandwidth;
|
2020-09-18 00:23:03 +02:00
|
|
|
float snapInterval;
|
2020-08-10 02:30:25 +02:00
|
|
|
int reference = REF_CENTER;
|
|
|
|
|
|
|
|
ImVec2 rectMin;
|
|
|
|
ImVec2 rectMax;
|
|
|
|
ImVec2 lineMin;
|
|
|
|
ImVec2 lineMax;
|
|
|
|
|
|
|
|
bool centerOffsetChanged = false;
|
|
|
|
bool lowerOffsetChanged = false;
|
|
|
|
bool upperOffsetChanged = false;
|
|
|
|
bool redrawRequired = true;
|
|
|
|
bool lineVisible = true;
|
|
|
|
};
|
|
|
|
|
2020-06-10 04:13:56 +02:00
|
|
|
class WaterFall {
|
|
|
|
public:
|
|
|
|
WaterFall();
|
|
|
|
|
2020-07-11 21:15:10 +02:00
|
|
|
void draw();
|
2020-06-10 04:13:56 +02:00
|
|
|
void pushFFT(std::vector<float> data, int n);
|
|
|
|
|
2020-07-11 21:15:10 +02:00
|
|
|
void updatePallette(float colors[][3], int colorCount);
|
|
|
|
|
|
|
|
void setCenterFrequency(float freq);
|
|
|
|
float getCenterFrequency();
|
|
|
|
|
|
|
|
void setBandwidth(float bandWidth);
|
|
|
|
float getBandwidth();
|
|
|
|
|
|
|
|
void setViewBandwidth(float bandWidth);
|
2020-07-19 15:59:44 +02:00
|
|
|
float getViewBandwidth();
|
|
|
|
|
2020-07-11 21:15:10 +02:00
|
|
|
void setViewOffset(float offset);
|
2020-07-19 15:59:44 +02:00
|
|
|
float getViewOffset();
|
2020-07-11 21:15:10 +02:00
|
|
|
|
|
|
|
void setFFTMin(float min);
|
|
|
|
float getFFTMin();
|
|
|
|
|
|
|
|
void setFFTMax(float max);
|
|
|
|
float getFFTMax();
|
|
|
|
|
|
|
|
void setWaterfallMin(float min);
|
|
|
|
float getWaterfallMin();
|
|
|
|
|
|
|
|
void setWaterfallMax(float max);
|
|
|
|
float getWaterfallMax();
|
|
|
|
|
|
|
|
void setZoom(float zoomLevel);
|
|
|
|
void setOffset(float zoomOffset);
|
|
|
|
|
|
|
|
void autoRange();
|
|
|
|
|
2020-08-11 18:33:42 +02:00
|
|
|
void selectFirstVFO();
|
|
|
|
|
2020-08-20 18:29:23 +02:00
|
|
|
void showWaterfall();
|
|
|
|
void hideWaterfall();
|
|
|
|
|
2020-09-25 14:25:36 +02:00
|
|
|
void showBandplan();
|
|
|
|
void hideBandplan();
|
|
|
|
|
2020-08-20 18:29:23 +02:00
|
|
|
void setFFTHeight(int height);
|
|
|
|
int getFFTHeight();
|
|
|
|
|
2020-07-19 15:59:44 +02:00
|
|
|
bool centerFreqMoved = false;
|
|
|
|
bool vfoFreqChanged = false;
|
2020-08-05 21:13:53 +02:00
|
|
|
bool bandplanEnabled = false;
|
|
|
|
bandplan::BandPlan_t* bandplan = NULL;
|
2020-07-19 15:59:44 +02:00
|
|
|
|
2020-08-10 02:30:25 +02:00
|
|
|
std::map<std::string, WaterfallVFO*> vfos;
|
|
|
|
std::string selectedVFO;
|
2020-08-11 18:33:42 +02:00
|
|
|
bool selectedVFOChanged = false;
|
2020-08-10 02:30:25 +02:00
|
|
|
|
2020-07-19 15:59:44 +02:00
|
|
|
enum {
|
|
|
|
REF_LOWER,
|
|
|
|
REF_CENTER,
|
|
|
|
REF_UPPER,
|
|
|
|
_REF_COUNT
|
|
|
|
};
|
|
|
|
|
2020-06-10 18:52:07 +02:00
|
|
|
|
2020-06-10 04:13:56 +02:00
|
|
|
private:
|
2020-07-11 21:15:10 +02:00
|
|
|
void drawWaterfall();
|
|
|
|
void drawFFT();
|
2020-08-10 02:30:25 +02:00
|
|
|
void drawVFOs();
|
2020-08-05 21:13:53 +02:00
|
|
|
void drawBandPlan();
|
2020-08-10 02:30:25 +02:00
|
|
|
void processInputs();
|
2020-07-11 21:15:10 +02:00
|
|
|
void onPositionChange();
|
|
|
|
void onResize();
|
|
|
|
void updateWaterfallFb();
|
|
|
|
void updateWaterfallTexture();
|
2020-08-10 02:30:25 +02:00
|
|
|
void updateAllVFOs();
|
2020-06-10 04:13:56 +02:00
|
|
|
|
2020-07-11 21:15:10 +02:00
|
|
|
bool waterfallUpdate = false;
|
|
|
|
|
|
|
|
uint32_t waterfallPallet[WATERFALL_RESOLUTION];
|
2020-06-10 18:52:07 +02:00
|
|
|
|
2020-07-11 21:15:10 +02:00
|
|
|
ImVec2 widgetPos;
|
|
|
|
ImVec2 widgetEndPos;
|
|
|
|
ImVec2 widgetSize;
|
|
|
|
|
|
|
|
ImVec2 lastWidgetPos;
|
|
|
|
ImVec2 lastWidgetSize;
|
|
|
|
|
2020-07-19 15:59:44 +02:00
|
|
|
ImVec2 fftAreaMin;
|
|
|
|
ImVec2 fftAreaMax;
|
|
|
|
ImVec2 freqAreaMin;
|
|
|
|
ImVec2 freqAreaMax;
|
|
|
|
ImVec2 waterfallAreaMin;
|
|
|
|
ImVec2 waterfallAreaMax;
|
|
|
|
|
2020-07-11 21:15:10 +02:00
|
|
|
ImGuiWindow* window;
|
|
|
|
|
|
|
|
GLuint textureId;
|
|
|
|
|
|
|
|
std::mutex buf_mtx;
|
|
|
|
|
2020-07-19 21:26:37 +02:00
|
|
|
float vRange;
|
|
|
|
|
|
|
|
int maxVSteps;
|
|
|
|
int maxHSteps;
|
|
|
|
|
2020-07-11 21:15:10 +02:00
|
|
|
int dataWidth; // Width of the FFT and waterfall
|
|
|
|
int fftHeight; // Height of the fft graph
|
|
|
|
int waterfallHeight; // Height of the waterfall
|
|
|
|
|
|
|
|
float viewBandwidth;
|
|
|
|
float viewOffset;
|
|
|
|
|
|
|
|
float lowerFreq;
|
|
|
|
float upperFreq;
|
|
|
|
float range;
|
|
|
|
|
2020-07-19 15:59:44 +02:00
|
|
|
float lastDrag;
|
|
|
|
|
|
|
|
int vfoRef = REF_CENTER;
|
|
|
|
|
2020-07-11 21:15:10 +02:00
|
|
|
// Absolute values
|
|
|
|
float centerFreq;
|
|
|
|
float wholeBandwidth;
|
|
|
|
|
|
|
|
// Ranges
|
|
|
|
float fftMin;
|
|
|
|
float fftMax;
|
|
|
|
float waterfallMin;
|
|
|
|
float waterfallMax;
|
|
|
|
|
|
|
|
std::vector<std::vector<float>> rawFFTs;
|
|
|
|
float* latestFFT;
|
|
|
|
|
|
|
|
uint32_t* waterfallFb;
|
|
|
|
|
2020-08-20 18:29:23 +02:00
|
|
|
bool draggingFW = false;
|
|
|
|
int FFTAreaHeight;
|
|
|
|
int newFFTAreaHeight;
|
|
|
|
|
|
|
|
bool waterfallVisible = true;
|
2020-09-25 14:25:36 +02:00
|
|
|
bool bandplanVisible = false;
|
2020-06-10 04:13:56 +02:00
|
|
|
};
|
|
|
|
};
|