waterfall jitter and general refresh improvements

This commit is contained in:
Charles J. Cliffe 2015-09-08 21:32:15 -04:00
parent ed2dd5e5d4
commit 11121d8a0e
10 changed files with 57 additions and 13 deletions

View File

@ -49,7 +49,7 @@ AppFrame::AppFrame() :
wxBoxSizer *demodTray = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer *demodTray = new wxBoxSizer(wxHORIZONTAL);
wxBoxSizer *demodScopeTray = new wxBoxSizer(wxVERTICAL); wxBoxSizer *demodScopeTray = new wxBoxSizer(wxVERTICAL);
int attribList[] = { WX_GL_RGBA, WX_GL_STENCIL_SIZE, 8, WX_GL_BUFFER_SIZE, 24, WX_GL_DOUBLEBUFFER, 0 }; int attribList[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, 0 };
demodModeSelector = new ModeSelectorCanvas(this, attribList); demodModeSelector = new ModeSelectorCanvas(this, attribList);
demodModeSelector->addChoice(DEMOD_TYPE_FM, "FM"); demodModeSelector->addChoice(DEMOD_TYPE_FM, "FM");
@ -840,7 +840,9 @@ void AppFrame::OnIdle(wxIdleEvent& event) {
wproc->setCenterFrequency(waterfallCanvas->getCenterFrequency()); wproc->setCenterFrequency(waterfallCanvas->getCenterFrequency());
waterfallCanvas->processInputQueue(); waterfallCanvas->processInputQueue();
// waterfallCanvas->Refresh();
demodWaterfallCanvas->processInputQueue(); demodWaterfallCanvas->processInputQueue();
// demodWaterfallCanvas->Refresh();
if (!this->IsActive()) { if (!this->IsActive()) {
std::this_thread::sleep_for(std::chrono::milliseconds(25)); std::this_thread::sleep_for(std::chrono::milliseconds(25));

View File

@ -90,7 +90,7 @@ bool CubicSDR::OnInit() {
sdrThread->setOutputQueue("IQDataOutput",pipeSDRIQData); sdrThread->setOutputQueue("IQDataOutput",pipeSDRIQData);
sdrPostThread = new SDRPostThread(); sdrPostThread = new SDRPostThread();
sdrPostThread->setNumVisSamples(BUF_SIZE); // sdrPostThread->setNumVisSamples(BUF_SIZE);
sdrPostThread->setInputQueue("IQDataInput", pipeSDRIQData); sdrPostThread->setInputQueue("IQDataInput", pipeSDRIQData);
sdrPostThread->setOutputQueue("IQVisualDataOutput", pipeIQVisualData); sdrPostThread->setOutputQueue("IQVisualDataOutput", pipeIQVisualData);
sdrPostThread->setOutputQueue("IQDataOutput", pipeWaterfallIQVisualData); sdrPostThread->setOutputQueue("IQDataOutput", pipeWaterfallIQVisualData);
@ -427,6 +427,10 @@ void CubicSDR::showFrequencyInput(FrequencyDialog::FrequencyDialogTarget targetM
fdialog.ShowModal(); fdialog.ShowModal();
} }
AppFrame *CubicSDR::getAppFrame() {
return appframe;
}
void CubicSDR::setFrequencySnap(int snap) { void CubicSDR::setFrequencySnap(int snap) {
if (snap > 1000000) { if (snap > 1000000) {
snap = 1000000; snap = 1000000;

View File

@ -80,7 +80,8 @@ public:
int getPPM(); int getPPM();
void showFrequencyInput(FrequencyDialog::FrequencyDialogTarget targetMode = FrequencyDialog::FDIALOG_TARGET_DEFAULT); void showFrequencyInput(FrequencyDialog::FrequencyDialogTarget targetMode = FrequencyDialog::FDIALOG_TARGET_DEFAULT);
AppFrame *getAppFrame();
private: private:
AppFrame *appframe; AppFrame *appframe;
AppConfig config; AppConfig config;

View File

@ -37,7 +37,8 @@ void FFTVisualDataThread::run() {
while(!terminated) { while(!terminated) {
std::this_thread::sleep_for(std::chrono::milliseconds(1)); std::this_thread::sleep_for(std::chrono::milliseconds(10));
// std::this_thread::yield();
int fftSize = wproc.getDesiredInputSize(); int fftSize = wproc.getDesiredInputSize();
@ -49,7 +50,7 @@ void FFTVisualDataThread::run() {
if (lpsChanged.load()) { if (lpsChanged.load()) {
fftDistrib.setLinesPerSecond(linesPerSecond.load()); fftDistrib.setLinesPerSecond(linesPerSecond.load());
pipeIQDataIn->set_max_num_items(linesPerSecond.load()); // pipeIQDataIn->set_max_num_items(linesPerSecond.load());
lpsChanged.store(false); lpsChanged.store(false);
} }

View File

@ -16,7 +16,8 @@ void SpectrumVisualDataThread::run() {
std::cout << "Spectrum visual data thread started." << std::endl; std::cout << "Spectrum visual data thread started." << std::endl;
while(!terminated) { while(!terminated) {
std::this_thread::sleep_for(std::chrono::milliseconds(1)); std::this_thread::sleep_for(std::chrono::milliseconds(10));
// std::this_thread::yield();
sproc.run(); sproc.run();
} }

View File

@ -36,6 +36,7 @@ MeterCanvas::~MeterCanvas() {
void MeterCanvas::setLevel(float level_in) { void MeterCanvas::setLevel(float level_in) {
level = level_in; level = level_in;
Refresh();
} }
float MeterCanvas::getLevel() { float MeterCanvas::getLevel() {
return level; return level;
@ -43,10 +44,12 @@ float MeterCanvas::getLevel() {
void MeterCanvas::setMax(float max_in) { void MeterCanvas::setMax(float max_in) {
level_max = max_in; level_max = max_in;
Refresh();
} }
void MeterCanvas::setInputValue(float slider_in) { void MeterCanvas::setInputValue(float slider_in) {
userInputValue = inputValue = slider_in; userInputValue = inputValue = slider_in;
Refresh();
} }
bool MeterCanvas::inputChanged() { bool MeterCanvas::inputChanged() {
@ -60,6 +63,7 @@ float MeterCanvas::getInputValue() {
void MeterCanvas::setShowUserInput(bool showUserInput) { void MeterCanvas::setShowUserInput(bool showUserInput) {
this->showUserInput = showUserInput; this->showUserInput = showUserInput;
Refresh();
} }
void MeterCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { void MeterCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
@ -87,8 +91,7 @@ void MeterCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
} }
void MeterCanvas::OnIdle(wxIdleEvent &event) { void MeterCanvas::OnIdle(wxIdleEvent &event) {
Refresh(); event.Skip();
event.RequestMore();
} }
void MeterCanvas::OnMouseMoved(wxMouseEvent& event) { void MeterCanvas::OnMouseMoved(wxMouseEvent& event) {
@ -101,21 +104,25 @@ void MeterCanvas::OnMouseMoved(wxMouseEvent& event) {
setStatusText(helpTip); setStatusText(helpTip);
} }
} }
Refresh();
} }
void MeterCanvas::OnMouseDown(wxMouseEvent& event) { void MeterCanvas::OnMouseDown(wxMouseEvent& event) {
InteractiveCanvas::OnMouseDown(event); InteractiveCanvas::OnMouseDown(event);
userInputValue = mouseTracker.getMouseY() * level_max; userInputValue = mouseTracker.getMouseY() * level_max;
mouseTracker.setHorizDragLock(true); mouseTracker.setHorizDragLock(true);
Refresh();
} }
void MeterCanvas::OnMouseWheelMoved(wxMouseEvent& event) { void MeterCanvas::OnMouseWheelMoved(wxMouseEvent& event) {
InteractiveCanvas::OnMouseWheelMoved(event); InteractiveCanvas::OnMouseWheelMoved(event);
Refresh();
} }
void MeterCanvas::OnMouseReleased(wxMouseEvent& event) { void MeterCanvas::OnMouseReleased(wxMouseEvent& event) {
InteractiveCanvas::OnMouseReleased(event); InteractiveCanvas::OnMouseReleased(event);
userInputValue = mouseTracker.getMouseY() * level_max; userInputValue = mouseTracker.getMouseY() * level_max;
Refresh();
} }
void MeterCanvas::OnMouseLeftWindow(wxMouseEvent& event) { void MeterCanvas::OnMouseLeftWindow(wxMouseEvent& event) {
@ -127,6 +134,7 @@ void MeterCanvas::OnMouseLeftWindow(wxMouseEvent& event) {
void MeterCanvas::OnMouseEnterWindow(wxMouseEvent& event) { void MeterCanvas::OnMouseEnterWindow(wxMouseEvent& event) {
InteractiveCanvas::mouseTracker.OnMouseEnterWindow(event); InteractiveCanvas::mouseTracker.OnMouseEnterWindow(event);
SetCursor(wxCURSOR_CROSS); SetCursor(wxCURSOR_CROSS);
Refresh();
} }
void MeterCanvas::setHelpTip(std::string tip) { void MeterCanvas::setHelpTip(std::string tip) {

View File

@ -79,18 +79,19 @@ void ModeSelectorCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
} }
void ModeSelectorCanvas::OnIdle(wxIdleEvent &event) { void ModeSelectorCanvas::OnIdle(wxIdleEvent &event) {
Refresh(); event.Skip();
event.RequestMore();
} }
void ModeSelectorCanvas::OnMouseMoved(wxMouseEvent& event) { void ModeSelectorCanvas::OnMouseMoved(wxMouseEvent& event) {
InteractiveCanvas::OnMouseMoved(event); InteractiveCanvas::OnMouseMoved(event);
Refresh();
} }
void ModeSelectorCanvas::OnMouseDown(wxMouseEvent& event) { void ModeSelectorCanvas::OnMouseDown(wxMouseEvent& event) {
InteractiveCanvas::OnMouseDown(event); InteractiveCanvas::OnMouseDown(event);
mouseTracker.setHorizDragLock(true); mouseTracker.setHorizDragLock(true);
mouseTracker.setVertDragLock(true); mouseTracker.setVertDragLock(true);
Refresh();
} }
void ModeSelectorCanvas::OnMouseWheelMoved(wxMouseEvent& event) { void ModeSelectorCanvas::OnMouseWheelMoved(wxMouseEvent& event) {
@ -120,6 +121,7 @@ void ModeSelectorCanvas::OnMouseReleased(wxMouseEvent& event) {
currentSelection = selectedButton; currentSelection = selectedButton;
SetCursor (wxCURSOR_HAND); SetCursor (wxCURSOR_HAND);
Refresh();
} }
void ModeSelectorCanvas::OnMouseLeftWindow(wxMouseEvent& event) { void ModeSelectorCanvas::OnMouseLeftWindow(wxMouseEvent& event) {
@ -134,6 +136,7 @@ void ModeSelectorCanvas::OnMouseEnterWindow(wxMouseEvent& event) {
if (!helpTip.empty()) { if (!helpTip.empty()) {
setStatusText(helpTip); setStatusText(helpTip);
} }
Refresh();
} }
void ModeSelectorCanvas::setHelpTip(std::string tip) { void ModeSelectorCanvas::setHelpTip(std::string tip) {
@ -142,6 +145,7 @@ void ModeSelectorCanvas::setHelpTip(std::string tip) {
void ModeSelectorCanvas::setNumChoices(int numChoices_in) { void ModeSelectorCanvas::setNumChoices(int numChoices_in) {
numChoices = numChoices_in; numChoices = numChoices_in;
Refresh();
} }
void ModeSelectorCanvas::addChoice(int value, std::string label) { void ModeSelectorCanvas::addChoice(int value, std::string label) {
@ -157,6 +161,7 @@ void ModeSelectorCanvas::setSelection(int value) {
} }
} }
currentSelection = -1; currentSelection = -1;
Refresh();
} }
int ModeSelectorCanvas::getSelection() { int ModeSelectorCanvas::getSelection() {

View File

@ -102,6 +102,10 @@ void ScopeCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
wxPaintDC dc(this); wxPaintDC dc(this);
const wxSize ClientSize = GetClientSize(); const wxSize ClientSize = GetClientSize();
#ifdef __APPLE__
glFinish();
#endif
while (!inputData.empty()) { while (!inputData.empty()) {
ScopeRenderData *avData; ScopeRenderData *avData;
inputData.pop(avData); inputData.pop(avData);

View File

@ -45,6 +45,10 @@ SpectrumCanvas::~SpectrumCanvas() {
void SpectrumCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { void SpectrumCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
wxPaintDC dc(this); wxPaintDC dc(this);
const wxSize ClientSize = GetClientSize(); const wxSize ClientSize = GetClientSize();
#ifdef __APPLE__
glFinish();
#endif
if (!visualDataQueue.empty()) { if (!visualDataQueue.empty()) {
SpectrumVisualData *vData; SpectrumVisualData *vData;

View File

@ -74,6 +74,7 @@ void WaterfallCanvas::processInputQueue() {
} }
glContext->SetCurrent(*this); glContext->SetCurrent(*this);
bool processed = false;
while (!visualDataQueue.empty()) { while (!visualDataQueue.empty()) {
SpectrumVisualData *vData; SpectrumVisualData *vData;
@ -83,14 +84,24 @@ void WaterfallCanvas::processInputQueue() {
waterfallPanel.setPoints(vData->spectrum_points); waterfallPanel.setPoints(vData->spectrum_points);
waterfallPanel.step(); waterfallPanel.step();
vData->decRefCount(); vData->decRefCount();
processed = true;
} }
} }
if (processed) {
Refresh();
}
} }
void WaterfallCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { void WaterfallCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
// wxClientDC dc(this); // wxClientDC dc(this);
wxPaintDC dc(this); wxPaintDC dc(this);
//#ifdef __APPLE__
// glFinish();
//#endif
// processInputQueue();
const wxSize ClientSize = GetClientSize(); const wxSize ClientSize = GetClientSize();
long double currentZoom = zoom; long double currentZoom = zoom;
@ -272,6 +283,7 @@ void WaterfallCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
glContext->EndDraw(); glContext->EndDraw();
glFlush();
SwapBuffers(); SwapBuffers();
} }
@ -389,9 +401,11 @@ void WaterfallCanvas::OnKeyDown(wxKeyEvent& event) {
} }
void WaterfallCanvas::OnIdle(wxIdleEvent &event) { void WaterfallCanvas::OnIdle(wxIdleEvent &event) {
Refresh(); // Refresh();
event.RequestMore(); // processInputQueue();
// event.Skip(); // Refresh();
// event.RequestMore();
event.Skip();
} }
void WaterfallCanvas::OnMouseMoved(wxMouseEvent& event) { void WaterfallCanvas::OnMouseMoved(wxMouseEvent& event) {