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 *demodTray = new wxBoxSizer(wxHORIZONTAL);
|
||||||
wxBoxSizer *demodScopeTray = new wxBoxSizer(wxVERTICAL);
|
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 = new SpectrumCanvas(this, NULL);
|
||||||
demodSpectrumCanvas->setup(1024);
|
demodSpectrumCanvas->setup(1024);
|
||||||
demodSpectrumCanvas->setView(DEFAULT_FREQ, 300000);
|
demodSpectrumCanvas->setView(DEFAULT_FREQ, 300000);
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include "WaterfallCanvas.h"
|
#include "WaterfallCanvas.h"
|
||||||
#include "MeterCanvas.h"
|
#include "MeterCanvas.h"
|
||||||
#include "TuningCanvas.h"
|
#include "TuningCanvas.h"
|
||||||
|
#include "ModeSelectorCanvas.h"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
@ -34,6 +35,7 @@ private:
|
|||||||
ScopeCanvas *scopeCanvas;
|
ScopeCanvas *scopeCanvas;
|
||||||
SpectrumCanvas *spectrumCanvas;
|
SpectrumCanvas *spectrumCanvas;
|
||||||
WaterfallCanvas *waterfallCanvas;
|
WaterfallCanvas *waterfallCanvas;
|
||||||
|
ModeSelectorCanvas *demodModeSelector;
|
||||||
SpectrumCanvas *demodSpectrumCanvas;
|
SpectrumCanvas *demodSpectrumCanvas;
|
||||||
WaterfallCanvas *demodWaterfallCanvas;
|
WaterfallCanvas *demodWaterfallCanvas;
|
||||||
MeterCanvas *demodSignalMeter;
|
MeterCanvas *demodSignalMeter;
|
||||||
|
@ -25,7 +25,7 @@ EVT_ENTER_WINDOW(ModeSelectorCanvas::OnMouseEnterWindow)
|
|||||||
wxEND_EVENT_TABLE()
|
wxEND_EVENT_TABLE()
|
||||||
|
|
||||||
ModeSelectorCanvas::ModeSelectorCanvas(wxWindow *parent, int *attribList) :
|
ModeSelectorCanvas::ModeSelectorCanvas(wxWindow *parent, int *attribList) :
|
||||||
InteractiveCanvas(parent, attribList), dragAccum(0) {
|
InteractiveCanvas(parent, attribList) {
|
||||||
|
|
||||||
glContext = new ModeSelectorContext(this, &wxGetApp().GetContext(this));
|
glContext = new ModeSelectorContext(this, &wxGetApp().GetContext(this));
|
||||||
}
|
}
|
||||||
@ -43,6 +43,10 @@ void ModeSelectorCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
|
|||||||
|
|
||||||
glContext->DrawBegin();
|
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();
|
glContext->DrawEnd();
|
||||||
|
|
||||||
|
@ -19,17 +19,41 @@ void ModeSelectorContext::DrawBegin() {
|
|||||||
glDisable(GL_TEXTURE_2D);
|
glDisable(GL_TEXTURE_2D);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModeSelectorContext::Draw(float r, float g, float b, float a, float level) {
|
void ModeSelectorContext::DrawSelector(std::string label, int c, int cMax, bool on, float r, float g, float b, float a) {
|
||||||
glEnable(GL_BLEND);
|
GLint vp[4];
|
||||||
glBlendFunc(GL_ONE, GL_ONE);
|
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);
|
glColor4f(r, g, b, a);
|
||||||
glBegin(GL_QUADS);
|
|
||||||
glVertex2f(1.0, -1.0 + 2.0 * level);
|
float y = 1.0 - ((float) c / (float) cMax * 2.0);
|
||||||
glVertex2f(-1.0, -1.0 + 2.0 * level);
|
float height = (2.0 / (float) cMax);
|
||||||
glVertex2f(-1.0, -1.0);
|
float padX = (4.0 / viewWidth);
|
||||||
glVertex2f(1.0, -1.0);
|
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();
|
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() {
|
void ModeSelectorContext::DrawEnd() {
|
||||||
|
@ -12,6 +12,6 @@ public:
|
|||||||
ModeSelectorContext(ModeSelectorCanvas *canvas, wxGLContext *sharedContext);
|
ModeSelectorContext(ModeSelectorCanvas *canvas, wxGLContext *sharedContext);
|
||||||
|
|
||||||
void DrawBegin();
|
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();
|
void DrawEnd();
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user