mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2025-02-03 09:44:26 -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);
|
||||
@ -123,6 +124,37 @@ int TuningContext::GetTunerDigitIndex(float mPos, int count, float displayPos, f
|
||||
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) {
|
||||
GLint vp[4];
|
||||
glGetIntegerv( GL_VIEWPORT, vp);
|
||||
|
@ -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