Can now choose demodulator output devices

This commit is contained in:
Charles J. Cliffe
2014-12-31 21:31:37 -05:00
parent b7793ef905
commit 6679b20fbb
15 changed files with 136 additions and 71 deletions
+10 -7
View File
@@ -21,10 +21,9 @@ wxEND_EVENT_TABLE()
ScopeCanvas::ScopeCanvas(wxWindow *parent, int *attribList) :
wxGLCanvas(parent, wxID_ANY, attribList, wxDefaultPosition, wxDefaultSize,
wxFULL_REPAINT_ON_RESIZE), parent(parent), frameTimer(0), stereo(false) {
wxFULL_REPAINT_ON_RESIZE), parent(parent), stereo(false) {
glContext = new ScopeContext(this, &wxGetApp().GetContext(this));
timer.start();
}
ScopeCanvas::~ScopeCanvas() {
@@ -39,6 +38,11 @@ void ScopeCanvas::setStereo(bool state) {
stereo = state;
}
void ScopeCanvas::setDeviceName(std::string device_name) {
deviceName = device_name;
deviceName.append(" ");
}
void ScopeCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
wxPaintDC dc(this);
const wxSize ClientSize = GetClientSize();
@@ -47,17 +51,16 @@ void ScopeCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
glViewport(0, 0, ClientSize.x, ClientSize.y);
glContext->DrawBegin();
if (!deviceName.empty()) {
glContext->DrawDeviceName(deviceName);
}
glContext->Plot(waveform_points, stereo);
glContext->DrawEnd();
SwapBuffers();
}
void ScopeCanvas::OnIdle(wxIdleEvent &event) {
// timer.update();
// frameTimer += timer.lastUpdateSeconds();
// if (frameTimer > 1.0/30.0) {
Refresh(false);
// frameTimer = 0;
// }
}
+2 -4
View File
@@ -7,9 +7,7 @@
#include <queue>
#include "ScopeContext.h"
#include "fftw3.h"
#include "Timer.h"
class ScopeCanvas: public wxGLCanvas {
public:
@@ -20,6 +18,7 @@ public:
void setWaveformPoints(std::vector<float> &waveform_points_in);
void setStereo(bool state);
void setDeviceName(std::string device_name);
private:
void OnPaint(wxPaintEvent& event);
@@ -28,8 +27,7 @@ private:
wxWindow *parent;
ScopeContext *glContext;
Timer timer;
float frameTimer;
std::string deviceName;
bool stereo;
// event table
wxDECLARE_EVENT_TABLE();
+26 -16
View File
@@ -4,20 +4,20 @@
ScopeContext::ScopeContext(ScopeCanvas *canvas, wxGLContext *sharedContext) :
PrimaryGLContext(canvas, sharedContext) {
glDisable (GL_CULL_FACE);
glDisable (GL_DEPTH_TEST);
glDisable(GL_CULL_FACE);
glDisable(GL_DEPTH_TEST);
glMatrixMode (GL_PROJECTION);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
}
void ScopeContext::DrawBegin() {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode (GL_MODELVIEW);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glDisable (GL_TEXTURE_2D);
glDisable(GL_TEXTURE_2D);
}
void ScopeContext::Plot(std::vector<float> &points, bool stereo) {
@@ -26,27 +26,27 @@ void ScopeContext::Plot(std::vector<float> &points, bool stereo) {
if (stereo) {
glColor3f(0.7, 0.7, 0.7);
glBegin(GL_LINES);
glVertex2f(-1.0,0.0);
glVertex2f(1.0,0.0);
glVertex2f(-1.0, 0.0);
glVertex2f(1.0, 0.0);
glEnd();
glColor3f(0.3, 0.3, 0.3);
glBegin(GL_LINES);
glVertex2f(-1.0,0.5);
glVertex2f(1.0,0.5);
glVertex2f(-1.0,-0.5);
glVertex2f(1.0,-0.5);
glVertex2f(-1.0, 0.5);
glVertex2f(1.0, 0.5);
glVertex2f(-1.0, -0.5);
glVertex2f(1.0, -0.5);
glEnd();
} else {
glColor3f(0.3, 0.3, 0.3);
glBegin(GL_LINES);
glVertex2f(-1.0,0.0);
glVertex2f(1.0,0.0);
glVertex2f(-1.0, 0.0);
glVertex2f(1.0, 0.0);
glEnd();
}
glColor3f(0.9, 0.9, 0.9);
if (points.size()) {
glEnableClientState (GL_VERTEX_ARRAY);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, &points[0]);
if (stereo) {
glPushMatrix();
@@ -74,6 +74,16 @@ void ScopeContext::Plot(std::vector<float> &points, bool stereo) {
}
}
void ScopeContext::DrawDeviceName(std::string deviceName) {
GLint vp[4];
glGetIntegerv( GL_VIEWPORT, vp);
float viewHeight = (float) vp[3];
float hPos = (float) (viewHeight - 20) / viewHeight;
glColor3f(0.65,0.65,0.65);
getFont(PrimaryGLContext::GLFONT_SIZE12).drawString(deviceName.c_str(), 1.0, hPos, 12, GLFont::GLFONT_ALIGN_RIGHT, GLFont::GLFONT_ALIGN_CENTER);
}
void ScopeContext::DrawEnd() {
glFlush();
@@ -83,7 +93,7 @@ void ScopeContext::DrawEnd() {
void ScopeContext::DrawDivider() {
glColor3f(1.0, 1.0, 1.0);
glBegin(GL_LINES);
glVertex2f(0.0,-1.0);
glVertex2f(0.0,1.0);
glVertex2f(0.0, -1.0);
glVertex2f(0.0, 1.0);
glEnd();
}
+1
View File
@@ -13,6 +13,7 @@ public:
void DrawBegin();
void Plot(std::vector<float> &points, bool stereo=false);
void DrawDeviceName(std::string deviceName);
void DrawDivider();
void DrawEnd();
-5
View File
@@ -207,12 +207,7 @@ unsigned int SpectrumCanvas::GetBandwidth() {
}
void SpectrumCanvas::OnIdle(wxIdleEvent &event) {
// timer.update();
// frameTimer += timer.lastUpdateSeconds();
// if (frameTimer > 1.0/30.0) {
Refresh(false);
// frameTimer = 0;
// }
}
void SpectrumCanvas::mouseMoved(wxMouseEvent& event) {
-1
View File
@@ -9,7 +9,6 @@
#include "SpectrumContext.h"
#include "fftw3.h"
#include "Timer.h"
#include "MouseTracker.h"
class SpectrumCanvas: public wxGLCanvas {
+1 -7
View File
@@ -32,7 +32,7 @@ wxEND_EVENT_TABLE()
WaterfallCanvas::WaterfallCanvas(wxWindow *parent, int *attribList) :
wxGLCanvas(parent, wxID_ANY, attribList, wxDefaultPosition, wxDefaultSize,
wxFULL_REPAINT_ON_RESIZE), parent(parent), spectrumCanvas(NULL), frameTimer(0), activeDemodulatorBandwidth(0), activeDemodulatorFrequency(0), dragState(
wxFULL_REPAINT_ON_RESIZE), parent(parent), spectrumCanvas(NULL), activeDemodulatorBandwidth(0), activeDemodulatorFrequency(0), dragState(
WF_DRAG_NONE), nextDragState(WF_DRAG_NONE), shiftDown(false), altDown(false), ctrlDown(false), fft_size(0), waterfall_lines(0), plan(
NULL), in(NULL), out(NULL), center_freq(0), bandwidth(0), isView(false), resampler(NULL), resample_ratio(0), last_bandwidth(0), last_input_bandwidth(
0) {
@@ -85,7 +85,6 @@ void WaterfallCanvas::Setup(int fft_size_in, int waterfall_lines_in) {
plan = fftw_plan_dft_1d(fft_size, in, out, FFTW_FORWARD, FFTW_MEASURE);
glContext->Setup(fft_size, waterfall_lines);
timer.start();
}
int WaterfallCanvas::GetFrequencyAt(float x) {
@@ -447,12 +446,7 @@ void WaterfallCanvas::setData(DemodulatorThreadIQData *input) {
}
void WaterfallCanvas::OnIdle(wxIdleEvent &event) {
// timer.update();
// frameTimer += timer.lastUpdateSeconds();
// if (frameTimer > 1.0/30.0) {
Refresh(false);
// frameTimer = 0;
// }
}
void WaterfallCanvas::mouseMoved(wxMouseEvent& event) {
-3
View File
@@ -11,7 +11,6 @@
#include "SpectrumCanvas.h"
#include "fftw3.h"
#include "Timer.h"
class WaterfallCanvas: public wxGLCanvas {
public:
@@ -69,8 +68,6 @@ private:
std::vector<float> fft_result_maa;
WaterfallContext *glContext;
Timer timer;
float frameTimer;
MouseTracker mTracker;
int activeDemodulatorBandwidth;