diff --git a/plotview.cpp b/plotview.cpp index 683ecdd..7f143cf 100644 --- a/plotview.cpp +++ b/plotview.cpp @@ -48,6 +48,11 @@ PlotView::PlotView(InputSource *input) : cursors(this), viewRange({0, 0}) mainSampleSource->subscribe(this); } +off_t PlotView::coordToSample(int x) +{ + return fftSize * x / (int)pow(2, zoomLevel); +} + TracePlot* PlotView::createIQPlot(SampleSource> *src) { gr::top_block_sptr iq_tb = gr::make_top_block("multiply"); @@ -200,7 +205,7 @@ void PlotView::updateView() { viewRange = { horizontalScrollBar()->value(), - horizontalScrollBar()->value() + fftSize * width() / (int)pow(2, zoomLevel) + horizontalScrollBar()->value() + coordToSample(width()) }; viewport()->update(); } diff --git a/plotview.h b/plotview.h index 55a46a7..22d31b6 100644 --- a/plotview.h +++ b/plotview.h @@ -69,6 +69,7 @@ private: int powerMax; bool cursorsEnabled; + off_t coordToSample(int x); TracePlot* createIQPlot(SampleSource> *src); TracePlot* createQuadratureDemodPlot(SampleSource> *src); void updateView();