Fix some waterfall zoom navigation mistakes

This commit is contained in:
Charles J. Cliffe 2015-12-11 19:57:40 -05:00
parent fe25aaefdf
commit 7038652141
3 changed files with 19 additions and 11 deletions

View File

@ -53,6 +53,12 @@ long long InteractiveCanvas::getFrequencyAt(float x) {
return freq;
}
long long InteractiveCanvas::getFrequencyAt(float x, long long iqCenterFreq, long long iqBandwidth) {
long long freq = iqCenterFreq - (long long)(0.5 * (long double) iqBandwidth) + ((long double) x * (long double) iqBandwidth);
return freq;
}
void InteractiveCanvas::setCenterFrequency(long long center_freq_in) {
centerFreq = center_freq_in;
}

View File

@ -12,6 +12,7 @@ public:
~InteractiveCanvas();
long long getFrequencyAt(float x);
long long getFrequencyAt(float x, long long iqCenterFreq, long long iqBandwidth);
virtual void setView(long long center_freq_in, int bandwidth_in);
virtual void disableView();

View File

@ -182,9 +182,8 @@ void WaterfallCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
bw = minBandwidth;
}
if (mouseInView) {
long long mfreqA = getFrequencyAt(mpos);
setBandwidth(bw);
long long mfreqB = getFrequencyAt(mpos);
long long mfreqA = getFrequencyAt(mpos, centerFreq, getBandwidth());
long long mfreqB = getFrequencyAt(mpos, centerFreq, bw);
centerFreq += mfreqA - mfreqB;
}
@ -198,12 +197,14 @@ void WaterfallCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
if (spectrumCanvas) {
spectrumCanvas->disableView();
}
bw = wxGetApp().getSampleRate();
centerFreq = wxGetApp().getFrequency();
} else {
if (mouseInView) {
long long mfreqA = getFrequencyAt(mpos);
setBandwidth(bw);
long long mfreqB = getFrequencyAt(mpos);
long long mfreqA = getFrequencyAt(mpos, centerFreq, getBandwidth());
long long mfreqB = getFrequencyAt(mpos, centerFreq, bw);
centerFreq += mfreqA - mfreqB;
setBandwidth(bw);
} else {
setBandwidth(bw);
}
@ -822,11 +823,11 @@ void WaterfallCanvas::updateCenterFrequency(long long freq) {
long long minFreq = wxGetApp().getFrequency()-(wxGetApp().getSampleRate()/2);
long long maxFreq = wxGetApp().getFrequency()+(wxGetApp().getSampleRate()/2);
if (freq < minFreq) {
wxGetApp().setFrequency(freq+(wxGetApp().getSampleRate()/2));
if (freq - bandwidth / 2 < minFreq) {
wxGetApp().setFrequency(wxGetApp().getFrequency() - (minFreq - (freq - bandwidth/2)));
}
if (freq > maxFreq) {
wxGetApp().setFrequency(freq-(wxGetApp().getSampleRate()/2));
if (freq + bandwidth / 2 > maxFreq) {
wxGetApp().setFrequency(wxGetApp().getFrequency() + ((freq + bandwidth/2) - maxFreq));
}
} else {
if (spectrumCanvas) {