mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2024-11-26 21:58:37 -05:00
Tuner index up/down debug visual test
This commit is contained in:
parent
d7784a393d
commit
2893a1ab17
@ -49,17 +49,49 @@ void TuningCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
|
||||
|
||||
DemodulatorInstance *activeDemod = wxGetApp().getDemodMgr().getLastActiveDemodulator();
|
||||
|
||||
long long freq = 0;
|
||||
if (activeDemod != NULL) {
|
||||
glContext->DrawDemodFreqBw(activeDemod->getFrequency(), activeDemod->getBandwidth(), wxGetApp().getFrequency());
|
||||
} else {
|
||||
glContext->DrawDemodFreqBw(0, wxGetApp().getDemodMgr().getLastBandwidth(), wxGetApp().getFrequency());
|
||||
freq = activeDemod->getFrequency();
|
||||
}
|
||||
long long bw = wxGetApp().getDemodMgr().getLastBandwidth();
|
||||
long long center = wxGetApp().getFrequency();
|
||||
|
||||
float freqDP = -1.0;
|
||||
float freqW = (1.0 / 3.0) * 2.0;
|
||||
|
||||
float bwDP = -1.0 + (2.25 / 3.0);
|
||||
float bwW = (1.0 / 4.0) * 2.0;
|
||||
|
||||
float centerDP = -1.0 + (2.0 / 3.0) * 2.0;
|
||||
float centerW = (1.0 / 3.0) * 2.0;
|
||||
|
||||
glContext->DrawTuner(freq, 11, freqDP, freqW);
|
||||
glContext->DrawTuner(bw, 7, bwDP, bwW);
|
||||
glContext->DrawTuner(center, 11, centerDP, centerW);
|
||||
|
||||
if (mouseTracker.mouseDown()) {
|
||||
glContext->Draw(ThemeMgr::mgr.currentTheme->tuningBar.r, ThemeMgr::mgr.currentTheme->tuningBar.g, ThemeMgr::mgr.currentTheme->tuningBar.b,
|
||||
0.6, mouseTracker.getOriginMouseX(), mouseTracker.getMouseX());
|
||||
}
|
||||
|
||||
int index;
|
||||
bool top = mouseTracker.getMouseY()>=0.5;
|
||||
bool bottom = mouseTracker.getMouseY()<=0.5;
|
||||
index = glContext->GetTunerDigitIndex(mouseTracker.getMouseX(), 11, freqDP, freqW); // freq
|
||||
if (index > 0) {
|
||||
glContext->DrawTunerBarIndexed(1, index, 11, freqDP, freqW, ThemeMgr::mgr.currentTheme->tuningBar, 0.6, top, bottom); // freq
|
||||
}
|
||||
|
||||
index = glContext->GetTunerDigitIndex(mouseTracker.getMouseX(), 7, bwDP, bwW); // bw
|
||||
if (index > 0) {
|
||||
glContext->DrawTunerBarIndexed(1, index, 7, bwDP, bwW, ThemeMgr::mgr.currentTheme->tuningBar, 0.6, top, bottom); // bw
|
||||
}
|
||||
|
||||
index = glContext->GetTunerDigitIndex(mouseTracker.getMouseX(), 11, centerDP, centerW); // center
|
||||
if (index > 0) {
|
||||
glContext->DrawTunerBarIndexed(1, index, 11, centerDP, centerW, ThemeMgr::mgr.currentTheme->tuningBar, 0.6, top, bottom); // center
|
||||
}
|
||||
|
||||
glContext->DrawEnd();
|
||||
|
||||
SwapBuffers();
|
||||
@ -110,23 +142,6 @@ void TuningCanvas::OnIdle(wxIdleEvent &event) {
|
||||
|
||||
void TuningCanvas::OnMouseMoved(wxMouseEvent& event) {
|
||||
InteractiveCanvas::OnMouseMoved(event);
|
||||
int index;
|
||||
|
||||
index = glContext->GetTunerDigitIndex(mouseTracker.getMouseX(),11,-1.0,(1.0/3.0)*2.0); // freq
|
||||
if (index > 0) {
|
||||
std::cout << "freq " << index << std::endl;
|
||||
}
|
||||
|
||||
index = glContext->GetTunerDigitIndex(mouseTracker.getMouseX(),7,-1.0+(2.25/3.0),(1.0/4.0)*2.0); // bw
|
||||
if (index > 0) {
|
||||
std::cout << "bw " << index << std::endl;
|
||||
}
|
||||
|
||||
index = glContext->GetTunerDigitIndex(mouseTracker.getMouseX(),11,-1.0+(2.0/3.0)*2.0,(1.0/3.0)*2.0); // center
|
||||
if (index > 0) {
|
||||
std::cout << "ctr " << index << std::endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void TuningCanvas::OnMouseDown(wxMouseEvent& event) {
|
||||
|
@ -28,7 +28,8 @@ TuningContext::TuningContext(TuningCanvas *canvas, wxGLContext *sharedContext) :
|
||||
}
|
||||
|
||||
void TuningContext::DrawBegin() {
|
||||
glClearColor(ThemeMgr::mgr.currentTheme->generalBackground.r, ThemeMgr::mgr.currentTheme->generalBackground.g, ThemeMgr::mgr.currentTheme->generalBackground.b, 1.0);
|
||||
glClearColor(ThemeMgr::mgr.currentTheme->generalBackground.r, ThemeMgr::mgr.currentTheme->generalBackground.g,
|
||||
ThemeMgr::mgr.currentTheme->generalBackground.b, 1.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
@ -41,18 +42,18 @@ void TuningContext::Draw(float r, float g, float b, float a, float p1, float p2)
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_ONE, GL_ONE);
|
||||
glBegin(GL_QUADS);
|
||||
glColor4f(r*0.5, g*0.5, b*0.5, a);
|
||||
glVertex2f(-1.0+p2*2.0, 1.0);
|
||||
glVertex2f(-1.0+p1*2.0, 1.0);
|
||||
glColor4f(r * 0.5, g * 0.5, b * 0.5, a);
|
||||
glVertex2f(-1.0 + p2 * 2.0, 1.0);
|
||||
glVertex2f(-1.0 + p1 * 2.0, 1.0);
|
||||
glColor4f(r, g, b, a);
|
||||
glVertex2f(-1.0+p1*2.0, 0.0);
|
||||
glVertex2f(-1.0+p2*2.0, 0.0);
|
||||
glVertex2f(-1.0 + p1 * 2.0, 0.0);
|
||||
glVertex2f(-1.0 + p2 * 2.0, 0.0);
|
||||
|
||||
glVertex2f(-1.0+p2*2.0, 0.0);
|
||||
glVertex2f(-1.0+p1*2.0, 0.0);
|
||||
glColor4f(r*0.5, g*0.5, b*0.5, a);
|
||||
glVertex2f(-1.0+p1*2.0, -1.0);
|
||||
glVertex2f(-1.0+p2*2.0, -1.0);
|
||||
glVertex2f(-1.0 + p2 * 2.0, 0.0);
|
||||
glVertex2f(-1.0 + p1 * 2.0, 0.0);
|
||||
glColor4f(r * 0.5, g * 0.5, b * 0.5, a);
|
||||
glVertex2f(-1.0 + p1 * 2.0, -1.0);
|
||||
glVertex2f(-1.0 + p2 * 2.0, -1.0);
|
||||
glEnd();
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
@ -92,16 +93,16 @@ void TuningContext::DrawTuner(long long freq, int count, float displayPos, float
|
||||
|
||||
glColor3f(ThemeMgr::mgr.currentTheme->text.r, ThemeMgr::mgr.currentTheme->text.g, ThemeMgr::mgr.currentTheme->text.b);
|
||||
int numChars = freqChars.length();
|
||||
int ofs = count-numChars;
|
||||
int ofs = count - numChars;
|
||||
for (int i = ofs; i < count; i++) {
|
||||
float xpos = displayPos + (displayWidth/(float)count)*(float)i+((displayWidth/2.0)/(float)count);
|
||||
getFont(fontSize).drawString(freqStr.str().substr(i-ofs,1), xpos, 0, fontHeight, GLFont::GLFONT_ALIGN_CENTER, GLFont::GLFONT_ALIGN_CENTER);
|
||||
float xpos = displayPos + (displayWidth / (float) count) * (float) i + ((displayWidth / 2.0) / (float) count);
|
||||
getFont(fontSize).drawString(freqStr.str().substr(i - ofs, 1), xpos, 0, fontHeight, GLFont::GLFONT_ALIGN_CENTER, GLFont::GLFONT_ALIGN_CENTER);
|
||||
}
|
||||
|
||||
glColor3f(0.65, 0.65, 0.65);
|
||||
glBegin(GL_LINES);
|
||||
for (int i = count; i >= 0; i--) {
|
||||
float xpos = displayPos + (displayWidth/(float)count)*(float)i;
|
||||
float xpos = displayPos + (displayWidth / (float) count) * (float) i;
|
||||
glVertex2f(xpos, -1.0);
|
||||
glVertex2f(xpos, 1.0);
|
||||
}
|
||||
@ -112,15 +113,46 @@ int TuningContext::GetTunerDigitIndex(float mPos, int count, float displayPos, f
|
||||
mPos -= 0.5;
|
||||
mPos *= 2.0;
|
||||
|
||||
float delta = mPos-displayPos;
|
||||
float delta = mPos - displayPos;
|
||||
|
||||
if (delta < 0 || delta > displayWidth) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int index = floor((delta/displayWidth)*(count));
|
||||
int index = floor((delta / displayWidth) * (count));
|
||||
|
||||
return count-index;
|
||||
return count - index;
|
||||
}
|
||||
|
||||
void TuningContext::DrawTunerBarIndexed(int start, int end, int count, float displayPos, float displayWidth, RGBColor color, float alpha, bool top,
|
||||
bool bottom) {
|
||||
float ofs = (displayWidth / (float) count);
|
||||
float p2 = displayPos + ofs * (float) (count - start + 1);
|
||||
float p1 = displayPos + ofs * (float) (count - end);
|
||||
|
||||
float r = color.r, g = color.g, b = color.b, a = 0.6;
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_ONE, GL_ONE);
|
||||
glBegin(GL_QUADS);
|
||||
if (top) {
|
||||
glColor4f(r * 0.5, g * 0.5, b * 0.5, a);
|
||||
glVertex2f(p2, 1.0);
|
||||
glVertex2f(p1, 1.0);
|
||||
glColor4f(r, g, b, a);
|
||||
glVertex2f(p1, 0.0);
|
||||
glVertex2f(p2, 0.0);
|
||||
}
|
||||
if (bottom) {
|
||||
glColor4f(r, g, b, a);
|
||||
glVertex2f(p2, 0.0);
|
||||
glVertex2f(p1, 0.0);
|
||||
glColor4f(r * 0.5, g * 0.5, b * 0.5, a);
|
||||
glVertex2f(p1, -1.0);
|
||||
glVertex2f(p2, -1.0);
|
||||
}
|
||||
glEnd();
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
void TuningContext::DrawDemodFreqBw(long long freq, unsigned int bw, long long center) {
|
||||
@ -130,59 +162,59 @@ void TuningContext::DrawDemodFreqBw(long long freq, unsigned int bw, long long c
|
||||
float viewHeight = (float) vp[3];
|
||||
float viewWidth = (float) vp[2];
|
||||
|
||||
DrawTuner(freq,11,-1.0,(1.0/3.0)*2.0);
|
||||
DrawTuner(bw,7,-1.0+(2.25/3.0),(1.0/4.0)*2.0);
|
||||
DrawTuner(center,11,-1.0+(2.0/3.0)*2.0,(1.0/3.0)*2.0);
|
||||
DrawTuner(freq, 11, -1.0, (1.0 / 3.0) * 2.0);
|
||||
DrawTuner(bw, 7, -1.0 + (2.25 / 3.0), (1.0 / 4.0) * 2.0);
|
||||
DrawTuner(center, 11, -1.0 + (2.0 / 3.0) * 2.0, (1.0 / 3.0) * 2.0);
|
||||
|
||||
/*
|
||||
PrimaryGLContext::GLFontSize fontSize = GLFONT_SIZE16;
|
||||
PrimaryGLContext::GLFontSize fontSize = GLFONT_SIZE16;
|
||||
|
||||
int fontHeight = 16;
|
||||
int fontHeight = 16;
|
||||
|
||||
if (viewWidth < 400) {
|
||||
fontSize = GLFONT_SIZE12;
|
||||
fontHeight = 12;
|
||||
}
|
||||
if (viewWidth < 400) {
|
||||
fontSize = GLFONT_SIZE12;
|
||||
fontHeight = 12;
|
||||
}
|
||||
|
||||
glColor3f(ThemeMgr::mgr.currentTheme->text.r, ThemeMgr::mgr.currentTheme->text.g, ThemeMgr::mgr.currentTheme->text.b);
|
||||
glColor3f(ThemeMgr::mgr.currentTheme->text.r, ThemeMgr::mgr.currentTheme->text.g, ThemeMgr::mgr.currentTheme->text.b);
|
||||
|
||||
getFont(fontSize).drawString("Freq: ", -0.75, 0, fontHeight, GLFont::GLFONT_ALIGN_RIGHT, GLFont::GLFONT_ALIGN_CENTER);
|
||||
if (freq) {
|
||||
freqStr.str("");
|
||||
freqStr << std::fixed << freq << " Hz";
|
||||
} else {
|
||||
freqStr.str("---");
|
||||
}
|
||||
getFont(fontSize).drawString(freqStr.str(), -0.75, 0, fontHeight, GLFont::GLFONT_ALIGN_LEFT, GLFont::GLFONT_ALIGN_CENTER);
|
||||
getFont(fontSize).drawString("Freq: ", -0.75, 0, fontHeight, GLFont::GLFONT_ALIGN_RIGHT, GLFont::GLFONT_ALIGN_CENTER);
|
||||
if (freq) {
|
||||
freqStr.str("");
|
||||
freqStr << std::fixed << freq << " Hz";
|
||||
} else {
|
||||
freqStr.str("---");
|
||||
}
|
||||
getFont(fontSize).drawString(freqStr.str(), -0.75, 0, fontHeight, GLFont::GLFONT_ALIGN_LEFT, GLFont::GLFONT_ALIGN_CENTER);
|
||||
|
||||
|
||||
getFont(fontSize).drawString("BW: ", -0.10, 0, fontHeight, GLFont::GLFONT_ALIGN_RIGHT, GLFont::GLFONT_ALIGN_CENTER);
|
||||
if (bw) {
|
||||
freqStr.str("");
|
||||
freqStr << std::fixed << bw << " Hz";
|
||||
} else {
|
||||
freqStr.str("---");
|
||||
}
|
||||
getFont(fontSize).drawString(freqStr.str(), -0.10, 0, fontHeight, GLFont::GLFONT_ALIGN_LEFT, GLFont::GLFONT_ALIGN_CENTER);
|
||||
getFont(fontSize).drawString("BW: ", -0.10, 0, fontHeight, GLFont::GLFONT_ALIGN_RIGHT, GLFont::GLFONT_ALIGN_CENTER);
|
||||
if (bw) {
|
||||
freqStr.str("");
|
||||
freqStr << std::fixed << bw << " Hz";
|
||||
} else {
|
||||
freqStr.str("---");
|
||||
}
|
||||
getFont(fontSize).drawString(freqStr.str(), -0.10, 0, fontHeight, GLFont::GLFONT_ALIGN_LEFT, GLFont::GLFONT_ALIGN_CENTER);
|
||||
|
||||
|
||||
getFont(fontSize).drawString("CTR: ", 0.50, 0, fontHeight, GLFont::GLFONT_ALIGN_RIGHT, GLFont::GLFONT_ALIGN_CENTER);
|
||||
if (center) {
|
||||
freqStr.str("");
|
||||
freqStr << std::fixed << center << " Hz";
|
||||
} else {
|
||||
freqStr.str("---");
|
||||
}
|
||||
getFont(fontSize).drawString(freqStr.str(), 0.50, 0, fontHeight, GLFont::GLFONT_ALIGN_LEFT, GLFont::GLFONT_ALIGN_CENTER);
|
||||
getFont(fontSize).drawString("CTR: ", 0.50, 0, fontHeight, GLFont::GLFONT_ALIGN_RIGHT, GLFont::GLFONT_ALIGN_CENTER);
|
||||
if (center) {
|
||||
freqStr.str("");
|
||||
freqStr << std::fixed << center << " Hz";
|
||||
} else {
|
||||
freqStr.str("---");
|
||||
}
|
||||
getFont(fontSize).drawString(freqStr.str(), 0.50, 0, fontHeight, GLFont::GLFONT_ALIGN_LEFT, GLFont::GLFONT_ALIGN_CENTER);
|
||||
|
||||
|
||||
glColor3f(0.65, 0.65, 0.65);
|
||||
glBegin(GL_LINES);
|
||||
glVertex2f(-0.275, -1.0);
|
||||
glVertex2f(-0.275, 1.0);
|
||||
glVertex2f(0.275, -1.0);
|
||||
glVertex2f(0.275, 1.0);
|
||||
glEnd();
|
||||
glColor3f(0.65, 0.65, 0.65);
|
||||
glBegin(GL_LINES);
|
||||
glVertex2f(-0.275, -1.0);
|
||||
glVertex2f(-0.275, 1.0);
|
||||
glVertex2f(0.275, -1.0);
|
||||
glVertex2f(0.275, 1.0);
|
||||
glEnd();
|
||||
*/
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@ public:
|
||||
void Draw(float r, float g, float b, float a, float p1, float p2);
|
||||
void DrawTuner(long long freq, int count, float displayPos, float displayWidth);
|
||||
int GetTunerDigitIndex(float mPos, int count, float displayPos, float displayWidth);
|
||||
void DrawTunerBarIndexed(int start, int end, int count, float displayPos, float displayWidth, RGBColor color, float alpha, bool top, bool bottom);
|
||||
|
||||
void DrawDemodFreqBw(long long freq, unsigned int bw, long long center);
|
||||
void DrawEnd();
|
||||
|
Loading…
Reference in New Issue
Block a user