Mode selector visuals working

This commit is contained in:
Charles J. Cliffe 2015-01-05 19:12:16 -05:00
parent 137116da9c
commit 082c8fbd12
5 changed files with 47 additions and 11 deletions

View File

@ -38,6 +38,12 @@ AppFrame::AppFrame() :
wxBoxSizer *demodTray = new wxBoxSizer(wxHORIZONTAL);
wxBoxSizer *demodScopeTray = new wxBoxSizer(wxVERTICAL);
demodModeSelector = new ModeSelectorCanvas(this, NULL);
demodTray->Add(demodModeSelector, 2, wxEXPAND | wxALL, 0);
// demodTray->AddSpacer(2);
demodSpectrumCanvas = new SpectrumCanvas(this, NULL);
demodSpectrumCanvas->setup(1024);
demodSpectrumCanvas->setView(DEFAULT_FREQ, 300000);

View File

@ -8,6 +8,7 @@
#include "WaterfallCanvas.h"
#include "MeterCanvas.h"
#include "TuningCanvas.h"
#include "ModeSelectorCanvas.h"
#include <map>
@ -34,6 +35,7 @@ private:
ScopeCanvas *scopeCanvas;
SpectrumCanvas *spectrumCanvas;
WaterfallCanvas *waterfallCanvas;
ModeSelectorCanvas *demodModeSelector;
SpectrumCanvas *demodSpectrumCanvas;
WaterfallCanvas *demodWaterfallCanvas;
MeterCanvas *demodSignalMeter;

View File

@ -25,7 +25,7 @@ EVT_ENTER_WINDOW(ModeSelectorCanvas::OnMouseEnterWindow)
wxEND_EVENT_TABLE()
ModeSelectorCanvas::ModeSelectorCanvas(wxWindow *parent, int *attribList) :
InteractiveCanvas(parent, attribList), dragAccum(0) {
InteractiveCanvas(parent, attribList) {
glContext = new ModeSelectorContext(this, &wxGetApp().GetContext(this));
}
@ -43,6 +43,10 @@ void ModeSelectorCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
glContext->DrawBegin();
glContext->DrawSelector("FM", 1, 4, true, 0.75, 0.75, 0.75, 1.0);
glContext->DrawSelector("AM", 2, 4, true, 0.75, 0.75, 0.75, 1.0);
glContext->DrawSelector("LSB", 3, 4, true, 0.75, 0.75, 0.75, 1.0);
glContext->DrawSelector("USB", 4, 4, true, 0.75, 0.75, 0.75, 1.0);
glContext->DrawEnd();

View File

@ -19,17 +19,41 @@ void ModeSelectorContext::DrawBegin() {
glDisable(GL_TEXTURE_2D);
}
void ModeSelectorContext::Draw(float r, float g, float b, float a, float level) {
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE);
void ModeSelectorContext::DrawSelector(std::string label, int c, int cMax, bool on, float r, float g, float b, float a) {
GLint vp[4];
glGetIntegerv( GL_VIEWPORT, vp);
float viewHeight = (float) vp[3];
float viewWidth = (float) vp[2];
PrimaryGLContext::GLFontSize fontSize = GLFONT_SIZE16;
int fontHeight = 16;
if (viewWidth < 30) {
fontSize = GLFONT_SIZE12;
fontHeight = 12;
}
glColor4f(r, g, b, a);
glBegin(GL_QUADS);
glVertex2f(1.0, -1.0 + 2.0 * level);
glVertex2f(-1.0, -1.0 + 2.0 * level);
glVertex2f(-1.0, -1.0);
glVertex2f(1.0, -1.0);
float y = 1.0 - ((float) c / (float) cMax * 2.0);
float height = (2.0 / (float) cMax);
float padX = (4.0 / viewWidth);
float padY = (4.0 / viewHeight);
glBegin(GL_LINE_LOOP);
glVertex2f(-1.0 + padX, y + padY);
glVertex2f(1.0 - padX, y + padY);
glVertex2f(1.0 - padX, y + height - padY);
glVertex2f(-1.0 + padX, y + height - padY);
glEnd();
glDisable(GL_BLEND);
getFont(fontSize).drawString(label, 0.0, y + height / 2.0, fontHeight, GLFont::GLFONT_ALIGN_CENTER, GLFont::GLFONT_ALIGN_CENTER);
// glEnable(GL_BLEND);
// glBlendFunc(GL_ONE, GL_ONE);
// glColor4f(r, g, b, a);
}
void ModeSelectorContext::DrawEnd() {

View File

@ -12,6 +12,6 @@ public:
ModeSelectorContext(ModeSelectorCanvas *canvas, wxGLContext *sharedContext);
void DrawBegin();
void Draw(float r, float g, float b, float a, float level);
void DrawSelector(std::string label, int c, int cMax, bool on, float r, float g, float b, float a);
void DrawEnd();
};