2020-06-10 04:13:56 +02:00
|
|
|
#pragma once
|
|
|
|
#include <vector>
|
|
|
|
#include <mutex>
|
2020-12-05 22:42:12 +01:00
|
|
|
#include <gui/widgets/bandplan.h>
|
2020-10-07 22:44:54 +02:00
|
|
|
#include <imgui/imgui.h>
|
|
|
|
#include <imgui/imgui_internal.h>
|
|
|
|
#include <GL/glew.h>
|
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-08-10 02:30:25 +02:00
|
|
|
class WaterfallVFO {
|
|
|
|
public:
|
2020-10-15 16:09:01 +02:00
|
|
|
void setOffset(double offset);
|
|
|
|
void setCenterOffset(double offset);
|
|
|
|
void setBandwidth(double bw);
|
2020-08-10 02:30:25 +02:00
|
|
|
void setReference(int ref);
|
2020-10-20 14:59:42 +02:00
|
|
|
void setSnapInterval(double interval);
|
2020-10-15 16:09:01 +02:00
|
|
|
void updateDrawingVars(double viewBandwidth, float dataWidth, double viewOffset, ImVec2 widgetPos, int fftHeight); // NOTE: Datawidth double???
|
2020-08-10 02:30:25 +02:00
|
|
|
void draw(ImGuiWindow* window, bool selected);
|
|
|
|
|
|
|
|
enum {
|
|
|
|
REF_LOWER,
|
|
|
|
REF_CENTER,
|
|
|
|
REF_UPPER,
|
|
|
|
_REF_COUNT
|
|
|
|
};
|
|
|
|
|
2020-10-15 16:09:01 +02:00
|
|
|
double generalOffset;
|
|
|
|
double centerOffset;
|
|
|
|
double lowerOffset;
|
|
|
|
double upperOffset;
|
|
|
|
double bandwidth;
|
|
|
|
double snapInterval = 5000;
|
2020-08-10 02:30:25 +02:00
|
|
|
int reference = REF_CENTER;
|
|
|
|
|
|
|
|
ImVec2 rectMin;
|
|
|
|
ImVec2 rectMax;
|
|
|
|
ImVec2 lineMin;
|
|
|
|
ImVec2 lineMax;
|
2021-02-10 21:35:56 +01:00
|
|
|
ImVec2 wfRectMin;
|
|
|
|
ImVec2 wfRectMax;
|
|
|
|
ImVec2 wfLineMin;
|
|
|
|
ImVec2 wfLineMax;
|
2021-04-17 03:38:48 +02:00
|
|
|
ImVec2 lbwSelMin;
|
|
|
|
ImVec2 lbwSelMax;
|
|
|
|
ImVec2 rbwSelMin;
|
|
|
|
ImVec2 rbwSelMax;
|
|
|
|
ImVec2 wfLbwSelMin;
|
|
|
|
ImVec2 wfLbwSelMax;
|
|
|
|
ImVec2 wfRbwSelMin;
|
|
|
|
ImVec2 wfRbwSelMax;
|
2020-08-10 02:30:25 +02:00
|
|
|
|
|
|
|
bool centerOffsetChanged = false;
|
|
|
|
bool lowerOffsetChanged = false;
|
|
|
|
bool upperOffsetChanged = false;
|
|
|
|
bool redrawRequired = true;
|
|
|
|
bool lineVisible = true;
|
2021-04-17 22:37:50 +02:00
|
|
|
bool bandwidthChanged = false;
|
|
|
|
|
|
|
|
double minBandwidth;
|
|
|
|
double maxBandwidth;
|
|
|
|
bool bandwidthLocked;
|
2020-08-10 02:30:25 +02:00
|
|
|
};
|
|
|
|
|
2020-06-10 04:13:56 +02:00
|
|
|
class WaterFall {
|
|
|
|
public:
|
|
|
|
WaterFall();
|
|
|
|
|
2020-10-22 03:16:11 +02:00
|
|
|
void init();
|
|
|
|
|
2020-07-11 21:15:10 +02:00
|
|
|
void draw();
|
2020-12-12 05:34:58 +01:00
|
|
|
float* getFFTBuffer();
|
|
|
|
void pushFFT();
|
2020-06-10 04:13:56 +02:00
|
|
|
|
2020-07-11 21:15:10 +02:00
|
|
|
void updatePallette(float colors[][3], int colorCount);
|
2020-12-31 14:26:12 +01:00
|
|
|
void updatePalletteFromArray(float* colors, int colorCount);
|
2020-07-11 21:15:10 +02:00
|
|
|
|
2020-10-15 16:09:01 +02:00
|
|
|
void setCenterFrequency(double freq);
|
|
|
|
double getCenterFrequency();
|
2020-07-11 21:15:10 +02:00
|
|
|
|
2020-10-15 16:09:01 +02:00
|
|
|
void setBandwidth(double bandWidth);
|
|
|
|
double getBandwidth();
|
2020-07-11 21:15:10 +02:00
|
|
|
|
2020-10-15 16:09:01 +02:00
|
|
|
void setViewBandwidth(double bandWidth);
|
|
|
|
double getViewBandwidth();
|
2020-07-19 15:59:44 +02:00
|
|
|
|
2020-10-15 16:09:01 +02:00
|
|
|
void setViewOffset(double offset);
|
|
|
|
double 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();
|
|
|
|
|
2020-10-15 16:09:01 +02:00
|
|
|
void setZoom(double zoomLevel);
|
|
|
|
void setOffset(double zoomOffset);
|
2020-07-11 21:15:10 +02:00
|
|
|
|
|
|
|
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-12-12 05:34:58 +01:00
|
|
|
void setRawFFTSize(int size, bool lock = true);
|
|
|
|
|
2021-04-12 23:02:45 +02:00
|
|
|
void setFastFFT(bool fastFFT);
|
|
|
|
|
2021-04-13 04:54:47 +02:00
|
|
|
void setFullWaterfallUpdate(bool fullUpdate);
|
|
|
|
|
2021-04-14 01:45:21 +02:00
|
|
|
void setBandPlanPos(int pos);
|
|
|
|
|
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
|
|
|
|
2021-04-24 01:24:27 +02:00
|
|
|
bool mouseInFreq = false;
|
|
|
|
bool mouseInFFT = false;
|
|
|
|
bool mouseInWaterfall = false;
|
|
|
|
|
2020-08-10 02:30:25 +02:00
|
|
|
std::map<std::string, WaterfallVFO*> vfos;
|
2020-12-08 04:36:37 +01:00
|
|
|
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
|
|
|
|
};
|
|
|
|
|
2021-04-14 01:45:21 +02:00
|
|
|
enum {
|
|
|
|
BANDPLAN_POS_BOTTOM,
|
|
|
|
BANDPLAN_POS_TOP,
|
|
|
|
_BANDPLAN_POS_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;
|
2021-02-09 02:11:40 +01:00
|
|
|
ImVec2 wfMin;
|
|
|
|
ImVec2 wfMax;
|
2020-07-19 15:59:44 +02:00
|
|
|
|
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-12-12 05:34:58 +01:00
|
|
|
int dataWidth; // Width of the FFT and waterfall
|
|
|
|
int fftHeight; // Height of the fft graph
|
|
|
|
int waterfallHeight = 0; // Height of the waterfall
|
2020-07-11 21:15:10 +02:00
|
|
|
|
2020-10-15 16:09:01 +02:00
|
|
|
double viewBandwidth;
|
|
|
|
double viewOffset;
|
2020-07-11 21:15:10 +02:00
|
|
|
|
2020-10-15 16:09:01 +02:00
|
|
|
double lowerFreq;
|
|
|
|
double upperFreq;
|
|
|
|
double range;
|
2020-07-11 21:15:10 +02:00
|
|
|
|
2020-07-19 15:59:44 +02:00
|
|
|
float lastDrag;
|
|
|
|
|
|
|
|
int vfoRef = REF_CENTER;
|
|
|
|
|
2020-07-11 21:15:10 +02:00
|
|
|
// Absolute values
|
2020-10-15 16:09:01 +02:00
|
|
|
double centerFreq;
|
|
|
|
double wholeBandwidth;
|
2020-07-11 21:15:10 +02:00
|
|
|
|
|
|
|
// Ranges
|
|
|
|
float fftMin;
|
|
|
|
float fftMax;
|
|
|
|
float waterfallMin;
|
|
|
|
float waterfallMax;
|
|
|
|
|
2020-12-12 05:34:58 +01:00
|
|
|
//std::vector<std::vector<float>> rawFFTs;
|
|
|
|
int rawFFTSize;
|
|
|
|
float* rawFFTs = NULL;
|
2020-07-11 21:15:10 +02:00
|
|
|
float* latestFFT;
|
2020-12-12 05:34:58 +01:00
|
|
|
int currentFFTLine = 0;
|
|
|
|
int fftLines = 0;
|
2020-07-11 21:15:10 +02:00
|
|
|
|
|
|
|
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;
|
2021-04-12 23:02:45 +02:00
|
|
|
|
|
|
|
bool _fastFFT = true;
|
2021-04-13 04:54:47 +02:00
|
|
|
bool _fullUpdate = true;
|
2021-04-14 01:45:21 +02:00
|
|
|
|
|
|
|
int bandPlanPos = BANDPLAN_POS_BOTTOM;
|
2021-04-17 22:37:50 +02:00
|
|
|
|
|
|
|
// UI Select elements
|
|
|
|
bool freqScaleSelect = false;
|
|
|
|
bool vfoSelect = false;
|
|
|
|
bool vfoBorderSelect = false;
|
|
|
|
WaterfallVFO* relatedVfo = NULL;
|
|
|
|
ImVec2 mouseDownPos;
|
2020-06-10 04:13:56 +02:00
|
|
|
};
|
|
|
|
};
|