mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2024-11-15 15:02:52 +01:00
214 lines
5.0 KiB
C++
214 lines
5.0 KiB
C++
#pragma once
|
|
#include <vector>
|
|
#include <mutex>
|
|
#include <gui/widgets/bandplan.h>
|
|
#include <imgui/imgui.h>
|
|
#include <imgui/imgui_internal.h>
|
|
#include <GL/glew.h>
|
|
|
|
#define WATERFALL_RESOLUTION 1000000
|
|
|
|
namespace ImGui {
|
|
class WaterfallVFO {
|
|
public:
|
|
void setOffset(double offset);
|
|
void setCenterOffset(double offset);
|
|
void setBandwidth(double bw);
|
|
void setReference(int ref);
|
|
void setSnapInterval(double interval);
|
|
void updateDrawingVars(double viewBandwidth, float dataWidth, double viewOffset, ImVec2 widgetPos, int fftHeight); // NOTE: Datawidth double???
|
|
void draw(ImGuiWindow* window, bool selected);
|
|
|
|
enum {
|
|
REF_LOWER,
|
|
REF_CENTER,
|
|
REF_UPPER,
|
|
_REF_COUNT
|
|
};
|
|
|
|
double generalOffset;
|
|
double centerOffset;
|
|
double lowerOffset;
|
|
double upperOffset;
|
|
double bandwidth;
|
|
double snapInterval = 5000;
|
|
int reference = REF_CENTER;
|
|
|
|
ImVec2 rectMin;
|
|
ImVec2 rectMax;
|
|
ImVec2 lineMin;
|
|
ImVec2 lineMax;
|
|
ImVec2 wfRectMin;
|
|
ImVec2 wfRectMax;
|
|
ImVec2 wfLineMin;
|
|
ImVec2 wfLineMax;
|
|
|
|
bool centerOffsetChanged = false;
|
|
bool lowerOffsetChanged = false;
|
|
bool upperOffsetChanged = false;
|
|
bool redrawRequired = true;
|
|
bool lineVisible = true;
|
|
};
|
|
|
|
class WaterFall {
|
|
public:
|
|
WaterFall();
|
|
|
|
void init();
|
|
|
|
void draw();
|
|
float* getFFTBuffer();
|
|
void pushFFT();
|
|
|
|
void updatePallette(float colors[][3], int colorCount);
|
|
void updatePalletteFromArray(float* colors, int colorCount);
|
|
|
|
void setCenterFrequency(double freq);
|
|
double getCenterFrequency();
|
|
|
|
void setBandwidth(double bandWidth);
|
|
double getBandwidth();
|
|
|
|
void setViewBandwidth(double bandWidth);
|
|
double getViewBandwidth();
|
|
|
|
void setViewOffset(double offset);
|
|
double getViewOffset();
|
|
|
|
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(double zoomLevel);
|
|
void setOffset(double zoomOffset);
|
|
|
|
void autoRange();
|
|
|
|
void selectFirstVFO();
|
|
|
|
void showWaterfall();
|
|
void hideWaterfall();
|
|
|
|
void showBandplan();
|
|
void hideBandplan();
|
|
|
|
void setFFTHeight(int height);
|
|
int getFFTHeight();
|
|
|
|
void setRawFFTSize(int size, bool lock = true);
|
|
|
|
void setFastFFT(bool fastFFT);
|
|
|
|
void setFullWaterfallUpdate(bool fullUpdate);
|
|
|
|
bool centerFreqMoved = false;
|
|
bool vfoFreqChanged = false;
|
|
bool bandplanEnabled = false;
|
|
bandplan::BandPlan_t* bandplan = NULL;
|
|
|
|
std::map<std::string, WaterfallVFO*> vfos;
|
|
std::string selectedVFO = "";
|
|
bool selectedVFOChanged = false;
|
|
|
|
enum {
|
|
REF_LOWER,
|
|
REF_CENTER,
|
|
REF_UPPER,
|
|
_REF_COUNT
|
|
};
|
|
|
|
|
|
private:
|
|
void drawWaterfall();
|
|
void drawFFT();
|
|
void drawVFOs();
|
|
void drawBandPlan();
|
|
void processInputs();
|
|
void onPositionChange();
|
|
void onResize();
|
|
void updateWaterfallFb();
|
|
void updateWaterfallTexture();
|
|
void updateAllVFOs();
|
|
|
|
bool waterfallUpdate = false;
|
|
|
|
uint32_t waterfallPallet[WATERFALL_RESOLUTION];
|
|
|
|
ImVec2 widgetPos;
|
|
ImVec2 widgetEndPos;
|
|
ImVec2 widgetSize;
|
|
|
|
ImVec2 lastWidgetPos;
|
|
ImVec2 lastWidgetSize;
|
|
|
|
ImVec2 fftAreaMin;
|
|
ImVec2 fftAreaMax;
|
|
ImVec2 freqAreaMin;
|
|
ImVec2 freqAreaMax;
|
|
ImVec2 wfMin;
|
|
ImVec2 wfMax;
|
|
|
|
ImGuiWindow* window;
|
|
|
|
GLuint textureId;
|
|
|
|
std::mutex buf_mtx;
|
|
|
|
float vRange;
|
|
|
|
int maxVSteps;
|
|
int maxHSteps;
|
|
|
|
int dataWidth; // Width of the FFT and waterfall
|
|
int fftHeight; // Height of the fft graph
|
|
int waterfallHeight = 0; // Height of the waterfall
|
|
|
|
double viewBandwidth;
|
|
double viewOffset;
|
|
|
|
double lowerFreq;
|
|
double upperFreq;
|
|
double range;
|
|
|
|
float lastDrag;
|
|
|
|
int vfoRef = REF_CENTER;
|
|
|
|
// Absolute values
|
|
double centerFreq;
|
|
double wholeBandwidth;
|
|
|
|
// Ranges
|
|
float fftMin;
|
|
float fftMax;
|
|
float waterfallMin;
|
|
float waterfallMax;
|
|
|
|
//std::vector<std::vector<float>> rawFFTs;
|
|
int rawFFTSize;
|
|
float* rawFFTs = NULL;
|
|
float* latestFFT;
|
|
int currentFFTLine = 0;
|
|
int fftLines = 0;
|
|
|
|
uint32_t* waterfallFb;
|
|
|
|
bool draggingFW = false;
|
|
int FFTAreaHeight;
|
|
int newFFTAreaHeight;
|
|
|
|
bool waterfallVisible = true;
|
|
bool bandplanVisible = false;
|
|
|
|
bool _fastFFT = true;
|
|
bool _fullUpdate = true;
|
|
};
|
|
}; |