mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2024-11-26 05:38:39 -05:00
Improve visual frequency / new demod indicator
This commit is contained in:
parent
6f7234b35a
commit
416cb54fb9
@ -83,6 +83,26 @@ std::vector<DemodulatorInstance *> *DemodulatorMgr::getDemodulatorsAt(long long
|
||||
return foundDemods;
|
||||
}
|
||||
|
||||
bool DemodulatorMgr::anyDemodulatorsAt(long long freq, int bandwidth) {
|
||||
|
||||
for (int i = 0, iMax = demods.size(); i < iMax; i++) {
|
||||
DemodulatorInstance *testDemod = demods[i];
|
||||
|
||||
long long freqTest = testDemod->getFrequency();
|
||||
long long bandwidthTest = testDemod->getBandwidth();
|
||||
long long halfBandwidthTest = bandwidthTest / 2;
|
||||
|
||||
long long halfBuffer = bandwidth / 2;
|
||||
|
||||
if ((freq <= (freqTest + ((testDemod->getDemodulatorType() != "LSB")?halfBandwidthTest:0) + halfBuffer)) && (freq >= (freqTest - ((testDemod->getDemodulatorType() != "USB")?halfBandwidthTest:0) - halfBuffer))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void DemodulatorMgr::setActiveDemodulator(DemodulatorInstance *demod, bool temporary) {
|
||||
if (!temporary) {
|
||||
if (activeDemodulator != NULL) {
|
||||
|
@ -14,6 +14,7 @@ public:
|
||||
DemodulatorInstance *newThread();
|
||||
std::vector<DemodulatorInstance *> &getDemodulators();
|
||||
std::vector<DemodulatorInstance *> *getDemodulatorsAt(long long freq, int bandwidth);
|
||||
bool anyDemodulatorsAt(long long freq, int bandwidth);
|
||||
void deleteThread(DemodulatorInstance *);
|
||||
|
||||
void terminateAll();
|
||||
|
@ -151,7 +151,7 @@ void PrimaryGLContext::DrawDemodInfo(DemodulatorInstance *demod, RGBA4f color, l
|
||||
|
||||
}
|
||||
|
||||
void PrimaryGLContext::DrawFreqBwInfo(long long freq, int bw, RGBA4f color, long long center_freq, long long srate) {
|
||||
void PrimaryGLContext::DrawFreqBwInfo(long long freq, int bw, RGBA4f color, long long center_freq, long long srate, bool stack) {
|
||||
if (!srate) {
|
||||
srate = wxGetApp().getSampleRate();
|
||||
}
|
||||
@ -168,34 +168,32 @@ void PrimaryGLContext::DrawFreqBwInfo(long long freq, int bw, RGBA4f color, long
|
||||
|
||||
float uxPos = (float) (freq - (center_freq - srate / 2)) / (float) srate;
|
||||
uxPos = (uxPos - 0.5) * 2.0;
|
||||
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
// glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
// glColor4f(color.r, color.g, color.b, 0.6);
|
||||
//
|
||||
std::string lastType = wxGetApp().getDemodMgr().getLastDemodulatorType();
|
||||
|
||||
float ofs = (float) bw / (float) srate;
|
||||
float ofsLeft = (lastType!="USB")?ofs:0, ofsRight = (lastType!="LSB")?ofs:0;
|
||||
//
|
||||
|
||||
float labelHeight = 20.0 / viewHeight;
|
||||
float hPos = -1.0 + labelHeight;
|
||||
float hPos = -1.0 + (stack?(labelHeight*3.0):labelHeight);
|
||||
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
glColor4f(0, 0, 0, 0.35);
|
||||
|
||||
// glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
//
|
||||
// glBegin(GL_QUADS);
|
||||
// glVertex3f(uxPos - ofsLeft, hPos + labelHeight, 0.0);
|
||||
// glVertex3f(uxPos - ofsLeft, -1.0, 0.0);
|
||||
//
|
||||
// glVertex3f(uxPos + ofsRight, -1.0, 0.0);
|
||||
// glVertex3f(uxPos + ofsRight, hPos + labelHeight, 0.0);
|
||||
// glEnd();
|
||||
glBegin(GL_QUADS);
|
||||
glVertex3f(uxPos - ofsLeft, hPos + labelHeight, 0.0);
|
||||
glVertex3f(uxPos - ofsLeft, -1.0, 0.0);
|
||||
|
||||
glVertex3f(uxPos + ofsRight, -1.0, 0.0);
|
||||
glVertex3f(uxPos + ofsRight, hPos + labelHeight, 0.0);
|
||||
glEnd();
|
||||
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||
|
||||
glColor4f(color.r, color.g, color.b, 0.2);
|
||||
glColor4f(color.r, color.g, color.b, 0.1);
|
||||
glBegin(GL_QUADS);
|
||||
glVertex3f(uxPos - ofsLeft, 1.0, 0.0);
|
||||
glVertex3f(uxPos - ofsLeft, -1.0, 0.0);
|
||||
@ -205,7 +203,7 @@ void PrimaryGLContext::DrawFreqBwInfo(long long freq, int bw, RGBA4f color, long
|
||||
glEnd();
|
||||
|
||||
if (ofs * 2.0 < 16.0 / viewWidth) {
|
||||
glColor4f(color.r, color.g, color.b, 0.2);
|
||||
glColor4f(color.r, color.g, color.b, 0.1);
|
||||
glBegin(GL_QUADS);
|
||||
glVertex3f(uxPos - ofsLeft, hPos + labelHeight, 0.0);
|
||||
glVertex3f(uxPos - ofsLeft, -1.0, 0.0);
|
||||
@ -215,16 +213,26 @@ void PrimaryGLContext::DrawFreqBwInfo(long long freq, int bw, RGBA4f color, long
|
||||
glEnd();
|
||||
}
|
||||
|
||||
|
||||
glColor4f(1.0, 1.0, 1.0, 0.8);
|
||||
|
||||
std::string demodLabel = std::to_string((double)freq/1000000.0);
|
||||
|
||||
double shadowOfsX = 0.5 / viewWidth, shadowOfsY = 0.5 / viewHeight;
|
||||
|
||||
if (lastType == "USB") {
|
||||
glColor4f(0,0,0, 1.0);
|
||||
GLFont::getFont(GLFont::GLFONT_SIZE16).drawString(demodLabel, uxPos+shadowOfsX, hPos-shadowOfsY, 16, GLFont::GLFONT_ALIGN_LEFT, GLFont::GLFONT_ALIGN_CENTER);
|
||||
glColor4f(color.r, color.g, color.b, 1.0);
|
||||
GLFont::getFont(GLFont::GLFONT_SIZE16).drawString(demodLabel, uxPos, hPos, 16, GLFont::GLFONT_ALIGN_LEFT, GLFont::GLFONT_ALIGN_CENTER);
|
||||
} else if (lastType == "LSB") {
|
||||
glColor4f(0,0,0, 1.0);
|
||||
GLFont::getFont(GLFont::GLFONT_SIZE16).drawString(demodLabel, uxPos+shadowOfsX, hPos-shadowOfsY, 16, GLFont::GLFONT_ALIGN_RIGHT, GLFont::GLFONT_ALIGN_CENTER);
|
||||
glColor4f(color.r, color.g, color.b, 1.0);
|
||||
GLFont::getFont(GLFont::GLFONT_SIZE16).drawString(demodLabel, uxPos, hPos, 16, GLFont::GLFONT_ALIGN_RIGHT, GLFont::GLFONT_ALIGN_CENTER);
|
||||
} else {
|
||||
glColor4f(0,0,0, 1.0);
|
||||
GLFont::getFont(GLFont::GLFONT_SIZE16).drawString(demodLabel, uxPos+shadowOfsX, hPos-shadowOfsY, 16, GLFont::GLFONT_ALIGN_CENTER, GLFont::GLFONT_ALIGN_CENTER);
|
||||
glColor4f(color.r, color.g, color.b, 1.0);
|
||||
GLFont::getFont(GLFont::GLFONT_SIZE16).drawString(demodLabel, uxPos, hPos, 16, GLFont::GLFONT_ALIGN_CENTER, GLFont::GLFONT_ALIGN_CENTER);
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ public:
|
||||
void DrawRangeSelector(float uxPos1, float uxPos2, RGBA4f color);
|
||||
void DrawDemod(DemodulatorInstance *demod, RGBA4f color, long long center_freq = -1, long long srate = 0);
|
||||
void DrawDemodInfo(DemodulatorInstance *demod, RGBA4f color, long long center_freq = -1, long long srate = 0);
|
||||
void DrawFreqBwInfo(long long freq, int bw, RGBA4f color, long long center_freq = - 1, long long srate = 0);
|
||||
void DrawFreqBwInfo(long long freq, int bw, RGBA4f color, long long center_freq = - 1, long long srate = 0, bool stack = false);
|
||||
|
||||
void setHoverAlpha(float hoverAlpha);
|
||||
|
||||
|
@ -107,7 +107,11 @@ void SpectrumCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
|
||||
freq = roundf((float)freq/(float)snap)*snap;
|
||||
}
|
||||
|
||||
glContext->DrawFreqBwInfo(freq, wxGetApp().getDemodMgr().getLastBandwidth(), ThemeMgr::mgr.currentTheme->fftHighlight*0.35, getCenterFrequency(), getBandwidth());
|
||||
DemodulatorInstance *lastActiveDemodulator = wxGetApp().getDemodMgr().getLastActiveDemodulator();
|
||||
|
||||
bool isNew = (((waterfallCanvas->isShiftDown() || (lastActiveDemodulator && !lastActiveDemodulator->isActive())) && lastActiveDemodulator) || (!lastActiveDemodulator));
|
||||
|
||||
glContext->DrawFreqBwInfo(freq, wxGetApp().getDemodMgr().getLastBandwidth(), isNew?ThemeMgr::mgr.currentTheme->waterfallNew:ThemeMgr::mgr.currentTheme->waterfallHover, getCenterFrequency(), getBandwidth(), true);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user