Updates and improvements for low-bandwidth input usage

This commit is contained in:
Charles J. Cliffe
2015-12-29 20:52:49 -05:00
parent 2867f90977
commit 7d6a387a77
14 changed files with 393 additions and 225 deletions
+3
View File
@@ -169,6 +169,9 @@ void SpectrumCanvas::setScaleFactorEnabled(bool en) {
scaleFactorEnabled = en;
}
void SpectrumCanvas::setFFTSize(int fftSize) {
spectrumPanel.setFFTSize(fftSize);
}
void SpectrumCanvas::updateScaleFactor(float factor) {
SpectrumVisualProcessor *sp = wxGetApp().getSpectrumProcessor();
+1
View File
@@ -26,6 +26,7 @@ public:
void disableView();
void setScaleFactorEnabled(bool en);
void setFFTSize(int fftSize);
SpectrumVisualDataQueue *getVisualDataQueue();
+20 -3
View File
@@ -33,7 +33,7 @@ EVT_MOUSEWHEEL(WaterfallCanvas::OnMouseWheelMoved)
wxEND_EVENT_TABLE()
WaterfallCanvas::WaterfallCanvas(wxWindow *parent, int *attribList) :
InteractiveCanvas(parent, attribList), dragState(WF_DRAG_NONE), nextDragState(WF_DRAG_NONE), fft_size(0), waterfall_lines(0),
InteractiveCanvas(parent, attribList), dragState(WF_DRAG_NONE), nextDragState(WF_DRAG_NONE), fft_size(0), new_fft_size(0), waterfall_lines(0),
dragOfs(0), mouseZoom(1), zoom(1), freqMoving(false), freqMove(0.0), hoverAlpha(1.0) {
glContext = new PrimaryGLContext(this, &wxGetApp().GetContext(this));
@@ -43,6 +43,7 @@ WaterfallCanvas::WaterfallCanvas(wxWindow *parent, int *attribList) :
SetCursor(wxCURSOR_CROSS);
scaleMove = 0;
minBandwidth = 30000;
fft_size_changed.store(false);
}
WaterfallCanvas::~WaterfallCanvas() {
@@ -59,6 +60,14 @@ void WaterfallCanvas::setup(int fft_size_in, int waterfall_lines_in) {
gTimer.start();
}
void WaterfallCanvas::setFFTSize(int fft_size_in) {
if (fft_size_in == fft_size) {
return;
}
new_fft_size = fft_size_in;
fft_size_changed.store(true);
}
WaterfallCanvas::DragState WaterfallCanvas::getDragState() {
return dragState;
}
@@ -88,7 +97,9 @@ void WaterfallCanvas::processInputQueue() {
visualDataQueue.pop(vData);
if (vData) {
waterfallPanel.setPoints(vData->spectrum_points);
if (vData->spectrum_points.size() == fft_size * 2) {
waterfallPanel.setPoints(vData->spectrum_points);
}
waterfallPanel.step();
vData->decRefCount();
updated = true;
@@ -111,7 +122,7 @@ void WaterfallCanvas::processInputQueue() {
void WaterfallCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
tex_update.lock();
wxPaintDC dc(this);
const wxSize ClientSize = GetClientSize();
long double currentZoom = zoom;
@@ -235,6 +246,12 @@ void WaterfallCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
glContext->SetCurrent(*this);
initGLExtensions();
glViewport(0, 0, ClientSize.x, ClientSize.y);
if (fft_size_changed.load()) {
fft_size = new_fft_size;
waterfallPanel.setup(fft_size, waterfall_lines);
fft_size_changed.store(false);
}
glContext->BeginDraw(0,0,0);
+3 -1
View File
@@ -20,6 +20,7 @@ public:
WaterfallCanvas(wxWindow *parent, int *attribList = NULL);
void setup(int fft_size_in, int waterfall_lines_in);
void setFFTSize(int fft_size_in);
~WaterfallCanvas();
DragState getDragState();
@@ -59,7 +60,7 @@ private:
DragState dragState;
DragState nextDragState;
int fft_size;
int fft_size, new_fft_size;
int waterfall_lines;
int dragOfs;
@@ -77,6 +78,7 @@ private:
bool preBuf;
std::mutex tex_update;
int minBandwidth;
std::atomic_bool fft_size_changed;
// event table
wxDECLARE_EVENT_TABLE();
};