diff --git a/plotview.cpp b/plotview.cpp index ca14828..bc4d088 100644 --- a/plotview.cpp +++ b/plotview.cpp @@ -48,11 +48,6 @@ 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"); @@ -96,7 +91,7 @@ TracePlot* PlotView::createQuadratureDemodPlot(SampleSource> void PlotView::cursorsMoved() { int selection = cursors.selection().length(); - off_t sampleCount = coordToSample(selection); + off_t sampleCount = selection * samplesPerLine(); float selectionTime = sampleCount / (float)mainSampleSource->rate(); emit timeSelectionChanged(selectionTime); viewport()->update(); @@ -188,6 +183,11 @@ void PlotView::resizeEvent(QResizeEvent * event) updateView(); } +off_t PlotView::samplesPerLine() +{ + return fftSize / (int)pow(2, zoomLevel); +} + void PlotView::scrollContentsBy(int dx, int dy) { updateView(); @@ -197,7 +197,7 @@ void PlotView::updateView() { viewRange = { horizontalScrollBar()->value(), - horizontalScrollBar()->value() + coordToSample(width()) + horizontalScrollBar()->value() + width() * samplesPerLine() }; viewport()->update(); } diff --git a/plotview.h b/plotview.h index 1117ad2..aa1cf61 100644 --- a/plotview.h +++ b/plotview.h @@ -70,8 +70,8 @@ private: int powerMax; bool cursorsEnabled; - off_t coordToSample(int x); TracePlot* createIQPlot(SampleSource> *src); TracePlot* createQuadratureDemodPlot(SampleSource> *src); + off_t samplesPerLine(); void updateView(); }; \ No newline at end of file