mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2025-08-04 06:32:25 -04:00
Faint spectrum grid lines
This commit is contained in:
parent
ef3a3ba594
commit
da5ef47fb2
@ -244,3 +244,6 @@ void SpectrumCanvas::attachWaterfallCanvas(WaterfallCanvas* canvas_in) {
|
|||||||
waterfallCanvas = canvas_in;
|
waterfallCanvas = canvas_in;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SpectrumContext* SpectrumCanvas::getSpectrumContext() {
|
||||||
|
return glContext;
|
||||||
|
}
|
||||||
|
@ -25,6 +25,8 @@ public:
|
|||||||
void setData(DemodulatorThreadIQData *input);
|
void setData(DemodulatorThreadIQData *input);
|
||||||
void attachWaterfallCanvas(WaterfallCanvas *canvas_in);
|
void attachWaterfallCanvas(WaterfallCanvas *canvas_in);
|
||||||
|
|
||||||
|
SpectrumContext* getSpectrumContext();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void OnPaint(wxPaintEvent& event);
|
void OnPaint(wxPaintEvent& event);
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#include "ColorTheme.h"
|
#include "ColorTheme.h"
|
||||||
|
|
||||||
SpectrumContext::SpectrumContext(SpectrumCanvas *canvas, wxGLContext *sharedContext) :
|
SpectrumContext::SpectrumContext(SpectrumCanvas *canvas, wxGLContext *sharedContext) :
|
||||||
PrimaryGLContext(canvas, sharedContext), fft_size(0) {
|
PrimaryGLContext(canvas, sharedContext), fft_size(0), floorValue(0), ceilValue(1) {
|
||||||
glDisable(GL_CULL_FACE);
|
glDisable(GL_CULL_FACE);
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
@ -16,6 +16,23 @@ SpectrumContext::SpectrumContext(SpectrumCanvas *canvas, wxGLContext *sharedCont
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
float SpectrumContext::getFloorValue() const {
|
||||||
|
return floorValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpectrumContext::setFloorValue(float floorValue) {
|
||||||
|
this->floorValue = floorValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
float SpectrumContext::getCeilValue() const {
|
||||||
|
return ceilValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpectrumContext::setCeilValue(float ceilValue) {
|
||||||
|
this->ceilValue = ceilValue;
|
||||||
|
}
|
||||||
|
|
||||||
void SpectrumContext::Draw(std::vector<float> &points, long long freq, int bandwidth) {
|
void SpectrumContext::Draw(std::vector<float> &points, long long freq, int bandwidth) {
|
||||||
|
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
@ -29,16 +46,76 @@ void SpectrumContext::Draw(std::vector<float> &points, long long freq, int bandw
|
|||||||
|
|
||||||
|
|
||||||
glDisable(GL_TEXTURE_2D);
|
glDisable(GL_TEXTURE_2D);
|
||||||
glColor3f(ThemeMgr::mgr.currentTheme->fftLine.r, ThemeMgr::mgr.currentTheme->fftLine.g, ThemeMgr::mgr.currentTheme->fftLine.b);
|
|
||||||
|
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glEnable(GL_LINE_SMOOTH);
|
glEnable(GL_LINE_SMOOTH);
|
||||||
glHint( GL_LINE_SMOOTH_HINT, GL_NICEST );
|
glHint( GL_LINE_SMOOTH_HINT, GL_NICEST );
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
||||||
if (points.size()) {
|
if (points.size()) {
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glTranslatef(-1.0f, -0.75f, 0.0f);
|
glTranslatef(-1.0f, -0.75f, 0.0f);
|
||||||
glScalef(2.0f, 1.5f, 1.0f);
|
glScalef(2.0f, 1.5f, 1.0f);
|
||||||
|
|
||||||
|
|
||||||
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||||
|
float p = 0;
|
||||||
|
float range = ceilValue-floorValue;
|
||||||
|
|
||||||
|
if (range > 80.0) {
|
||||||
|
float a = 0.5;
|
||||||
|
|
||||||
|
if (range < 100.0) {
|
||||||
|
a *= (20.0-(100.0-range))/20.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
glColor4f(0.2, 0.2, 0.2, a);
|
||||||
|
glBegin(GL_LINES);
|
||||||
|
for (float l = floorValue; l<=ceilValue+100.0; l+=100.0) {
|
||||||
|
p += 100.0/range;
|
||||||
|
glVertex2f(0,p); glVertex2f(1,p);
|
||||||
|
}
|
||||||
|
glEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
p = 0;
|
||||||
|
if (range > 20.0 && range < 100.0) {
|
||||||
|
float a = 0.5;
|
||||||
|
|
||||||
|
if (range <= 40.0) {
|
||||||
|
a *= ((range-20.0)/20.0);
|
||||||
|
}
|
||||||
|
if (range >= 80.0) {
|
||||||
|
a *= ((20.0-(range-80.0))/20.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
glColor4f(0.2, 0.2, 0.2, a);
|
||||||
|
glBegin(GL_LINES);
|
||||||
|
for (float l = floorValue; l<=ceilValue+10.0; l+=10.0) {
|
||||||
|
p += 10.0/range;
|
||||||
|
glVertex2f(0,p); glVertex2f(1,p);
|
||||||
|
}
|
||||||
|
glEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
p = 0;
|
||||||
|
if (range <= 40.0) {
|
||||||
|
float a = 0.5;
|
||||||
|
|
||||||
|
if (range >= 20.0) {
|
||||||
|
a *= ((20.0-(range-20.0))/20.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
glColor4f(0.2, 0.2, 0.2, a);
|
||||||
|
glBegin(GL_LINES);
|
||||||
|
for (float l = floorValue; l<=ceilValue+1.0; l+=1.0) {
|
||||||
|
p += 1.0/(ceilValue-floorValue);
|
||||||
|
glVertex2f(0,p); glVertex2f(1,p);
|
||||||
|
}
|
||||||
|
glEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
glColor3f(ThemeMgr::mgr.currentTheme->fftLine.r, ThemeMgr::mgr.currentTheme->fftLine.g, ThemeMgr::mgr.currentTheme->fftLine.b);
|
||||||
glEnableClientState(GL_VERTEX_ARRAY);
|
glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
glVertexPointer(2, GL_FLOAT, 0, &points[0]);
|
glVertexPointer(2, GL_FLOAT, 0, &points[0]);
|
||||||
glDrawArrays(GL_LINE_STRIP, 0, points.size() / 2);
|
glDrawArrays(GL_LINE_STRIP, 0, points.size() / 2);
|
||||||
|
@ -13,6 +13,12 @@ public:
|
|||||||
|
|
||||||
void Draw(std::vector<float> &points, long long freq, int bandwidth);
|
void Draw(std::vector<float> &points, long long freq, int bandwidth);
|
||||||
|
|
||||||
|
float getFloorValue() const;
|
||||||
|
void setFloorValue(float floorValue);
|
||||||
|
float getCeilValue() const;
|
||||||
|
void setCeilValue(float ceilValue);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int fft_size;
|
int fft_size;
|
||||||
|
float floorValue, ceilValue;
|
||||||
};
|
};
|
||||||
|
@ -586,6 +586,8 @@ void WaterfallCanvas::setData(DemodulatorThreadIQData *input) {
|
|||||||
|
|
||||||
if (spectrumCanvas) {
|
if (spectrumCanvas) {
|
||||||
spectrumCanvas->spectrum_points.assign(spectrum_points.begin(), spectrum_points.end());
|
spectrumCanvas->spectrum_points.assign(spectrum_points.begin(), spectrum_points.end());
|
||||||
|
spectrumCanvas->getSpectrumContext()->setCeilValue(fft_ceil_maa);
|
||||||
|
spectrumCanvas->getSpectrumContext()->setFloorValue(fft_floor_maa);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user