mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2024-11-23 12:18:37 -05:00
keyboard waterfall zoom input tweaks
This commit is contained in:
parent
d1ed603ff0
commit
5de181cf67
@ -759,9 +759,9 @@ void AppFrame::OnIdle(wxIdleEvent& event) {
|
||||
GetStatusBar()->SetStatusText(wxString::Format(wxT("Spectrum averaging speed changed to %0.2f%%."),val*100.0));
|
||||
}
|
||||
|
||||
proc->setView(spectrumCanvas->getViewState());
|
||||
proc->setBandwidth(spectrumCanvas->getBandwidth());
|
||||
proc->setCenterFrequency(spectrumCanvas->getCenterFrequency());
|
||||
proc->setView(waterfallCanvas->getViewState());
|
||||
proc->setBandwidth(waterfallCanvas->getBandwidth());
|
||||
proc->setCenterFrequency(waterfallCanvas->getCenterFrequency());
|
||||
|
||||
SpectrumVisualProcessor *dproc = wxGetApp().getDemodSpectrumProcessor();
|
||||
|
||||
@ -784,7 +784,7 @@ void AppFrame::OnIdle(wxIdleEvent& event) {
|
||||
|
||||
waterfallCanvas->processInputQueue();
|
||||
demodWaterfallCanvas->processInputQueue();
|
||||
|
||||
|
||||
if (!this->IsActive()) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(25));
|
||||
}
|
||||
|
@ -221,14 +221,14 @@ void SDRPostThread::run() {
|
||||
data_in->decRefCount();
|
||||
}
|
||||
|
||||
buffers.purge();
|
||||
// buffers.purge();
|
||||
|
||||
if (iqVisualQueue && !iqVisualQueue->empty()) {
|
||||
DemodulatorThreadIQData *visualDataDummy;
|
||||
iqVisualQueue->pop(visualDataDummy);
|
||||
}
|
||||
|
||||
visualDataBuffers.purge();
|
||||
// visualDataBuffers.purge();
|
||||
|
||||
std::cout << "SDR post-processing thread done." << std::endl;
|
||||
}
|
||||
|
@ -295,7 +295,7 @@ void SDRThread::run() {
|
||||
}
|
||||
}
|
||||
|
||||
buffers.purge();
|
||||
// buffers.purge();
|
||||
|
||||
std::cout << "SDR thread done." << std::endl;
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ EVT_IDLE(SpectrumCanvas::OnIdle)
|
||||
EVT_MOTION(SpectrumCanvas::OnMouseMoved)
|
||||
EVT_LEFT_DOWN(SpectrumCanvas::OnMouseDown)
|
||||
EVT_LEFT_UP(SpectrumCanvas::OnMouseReleased)
|
||||
EVT_ENTER_WINDOW(SpectrumCanvas::OnMouseEnterWindow)
|
||||
EVT_LEAVE_WINDOW(SpectrumCanvas::OnMouseLeftWindow)
|
||||
EVT_MOUSEWHEEL(SpectrumCanvas::OnMouseWheelMoved)
|
||||
wxEND_EVENT_TABLE()
|
||||
@ -152,6 +153,11 @@ void SpectrumCanvas::OnMouseReleased(wxMouseEvent& event) {
|
||||
SetCursor(wxCURSOR_SIZEWE);
|
||||
}
|
||||
|
||||
void SpectrumCanvas::OnMouseEnterWindow(wxMouseEvent& event) {
|
||||
InteractiveCanvas::OnMouseEnterWindow(event);
|
||||
SetCursor(wxCURSOR_SIZEWE);
|
||||
}
|
||||
|
||||
void SpectrumCanvas::OnMouseLeftWindow(wxMouseEvent& event) {
|
||||
InteractiveCanvas::OnMouseLeftWindow(event);
|
||||
SetCursor(wxCURSOR_SIZEWE);
|
||||
@ -163,4 +169,4 @@ void SpectrumCanvas::attachWaterfallCanvas(WaterfallCanvas* canvas_in) {
|
||||
|
||||
SpectrumVisualDataQueue *SpectrumCanvas::getVisualDataQueue() {
|
||||
return &visualDataQueue;
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ private:
|
||||
void OnMouseDown(wxMouseEvent& event);
|
||||
void OnMouseWheelMoved(wxMouseEvent& event);
|
||||
void OnMouseReleased(wxMouseEvent& event);
|
||||
void OnMouseEnterWindow(wxMouseEvent& event);
|
||||
void OnMouseLeftWindow(wxMouseEvent& event);
|
||||
|
||||
PrimaryGLContext *glContext;
|
||||
|
@ -105,45 +105,49 @@ void WaterfallCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
|
||||
long long bw;
|
||||
if (currentZoom != 1) {
|
||||
long long freq = wxGetApp().getFrequency();
|
||||
|
||||
bw = getBandwidth();
|
||||
|
||||
double mpos = 0;
|
||||
float mouseInView = false;
|
||||
|
||||
if (mouseTracker.mouseInView()) {
|
||||
mpos = mouseTracker.getMouseX();
|
||||
mouseInView = true;
|
||||
} else if (spectrumCanvas && spectrumCanvas->getMouseTracker()->mouseInView()) {
|
||||
mpos = spectrumCanvas->getMouseTracker()->getMouseX();
|
||||
mouseInView = true;
|
||||
}
|
||||
|
||||
if (currentZoom < 1) {
|
||||
centerFreq = getCenterFrequency();
|
||||
bw = getBandwidth();
|
||||
bw = (long long) ceil((long double) bw * currentZoom);
|
||||
if (bw < 30000) {
|
||||
bw = 30000;
|
||||
}
|
||||
if (mouseTracker.mouseInView()) {
|
||||
long long mfreqA = getFrequencyAt(mouseTracker.getMouseX());
|
||||
if (mouseInView) {
|
||||
long long mfreqA = getFrequencyAt(mpos);
|
||||
setBandwidth(bw);
|
||||
long long mfreqB = getFrequencyAt(mouseTracker.getMouseX());
|
||||
long long mfreqB = getFrequencyAt(mpos);
|
||||
centerFreq += mfreqA - mfreqB;
|
||||
}
|
||||
|
||||
setView(centerFreq, bw);
|
||||
if (spectrumCanvas) {
|
||||
spectrumCanvas->setView(centerFreq, bw);
|
||||
}
|
||||
} else {
|
||||
if (isView) {
|
||||
bw = getBandwidth();
|
||||
bw = (long long) ceil((long double) bw * currentZoom);
|
||||
|
||||
if (bw >= wxGetApp().getSampleRate()) {
|
||||
disableView();
|
||||
if (spectrumCanvas) {
|
||||
spectrumCanvas->disableView();
|
||||
}
|
||||
} else {
|
||||
if (mouseTracker.mouseInView()) {
|
||||
long long mfreqA = getFrequencyAt(mouseTracker.getMouseX());
|
||||
if (mouseInView) {
|
||||
long long mfreqA = getFrequencyAt(mpos);
|
||||
setBandwidth(bw);
|
||||
long long mfreqB = getFrequencyAt(mouseTracker.getMouseX());
|
||||
long long mfreqB = getFrequencyAt(mpos);
|
||||
centerFreq += mfreqA - mfreqB;
|
||||
}
|
||||
|
||||
setView(getCenterFrequency(), bw);
|
||||
if (spectrumCanvas) {
|
||||
spectrumCanvas->setView(centerFreq, bw);
|
||||
} else {
|
||||
setBandwidth(bw);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -154,8 +158,15 @@ void WaterfallCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
|
||||
if (centerFreq > freq && (centerFreq + bandwidth / 2) > (freq + wxGetApp().getSampleRate() / 2)) {
|
||||
centerFreq = (freq + wxGetApp().getSampleRate() / 2) - bandwidth / 2;
|
||||
}
|
||||
|
||||
if (spectrumCanvas) {
|
||||
if ((spectrumCanvas->getCenterFrequency() != centerFreq) || (spectrumCanvas->getBandwidth() != bw)) {
|
||||
spectrumCanvas->setView(centerFreq,bw);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
glContext->SetCurrent(*this);
|
||||
initGLExtensions();
|
||||
glViewport(0, 0, ClientSize.x, ClientSize.y);
|
||||
@ -255,11 +266,13 @@ void WaterfallCanvas::OnKeyUp(wxKeyEvent& event) {
|
||||
case WXK_UP:
|
||||
case WXK_NUMPAD_UP:
|
||||
zoom = 1.0;
|
||||
mouseZoom = 0.95;
|
||||
break;
|
||||
case 'Z':
|
||||
case WXK_DOWN:
|
||||
case WXK_NUMPAD_DOWN:
|
||||
zoom = 1.0;
|
||||
mouseZoom = 1.05;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -276,11 +289,13 @@ void WaterfallCanvas::OnKeyDown(wxKeyEvent& event) {
|
||||
case 'A':
|
||||
case WXK_UP:
|
||||
case WXK_NUMPAD_UP:
|
||||
mouseZoom = 1.0;
|
||||
zoom = 0.95;
|
||||
break;
|
||||
case 'Z':
|
||||
case WXK_DOWN:
|
||||
case WXK_NUMPAD_DOWN:
|
||||
mouseZoom = 1.0;
|
||||
zoom = 1.05;
|
||||
break;
|
||||
case WXK_RIGHT:
|
||||
@ -349,6 +364,9 @@ void WaterfallCanvas::OnKeyDown(wxKeyEvent& event) {
|
||||
setStatusText("Set center frequency: %s", freq);
|
||||
}
|
||||
} else {
|
||||
if (spectrumCanvas) {
|
||||
spectrumCanvas->setCenterFrequency(freq);
|
||||
}
|
||||
wxGetApp().setFrequency(freq);
|
||||
setStatusText("Set center frequency: %s", freq);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user