mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2024-11-26 13:48:38 -05:00
Mode selector visuals working
This commit is contained in:
parent
137116da9c
commit
082c8fbd12
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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() {
|
||||
|
@ -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();
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user