diff --git a/plotview.cpp b/plotview.cpp index d436311..f8de444 100644 --- a/plotview.cpp +++ b/plotview.cpp @@ -168,7 +168,7 @@ void PlotView::paintEvent(QPaintEvent *event) #define PLOT_LAYER(paintFunc) \ { \ - int y = 0; \ + int y = -verticalScrollBar()->value(); \ for (auto&& plot : plots) { \ QRect rect = QRect(0, y, width(), plot->height()); \ plot->paintFunc(painter, rect, {viewRange.first, viewRange.second});\ @@ -185,6 +185,15 @@ void PlotView::paintEvent(QPaintEvent *event) #undef PLOT_LAYER } +int PlotView::plotsHeight() +{ + int height = 0; + for (auto&& plot : plots) { + height += plot->height(); + } + return height; +} + void PlotView::resizeEvent(QResizeEvent * event) { updateView(); @@ -209,6 +218,8 @@ void PlotView::updateView() }; horizontalScrollBar()->setMaximum(mainSampleSource->count() - ((width() - 1) * samplesPerLine())); + verticalScrollBar()->setMaximum(std::max(0, plotsHeight() - viewport()->height())); + // Update cursors QRect rect = viewport()->rect(); range_t newSelection = { diff --git a/plotview.h b/plotview.h index 05c9319..1b837d4 100644 --- a/plotview.h +++ b/plotview.h @@ -73,6 +73,7 @@ private: TracePlot* createIQPlot(SampleSource> *src); TracePlot* createQuadratureDemodPlot(SampleSource> *src); + int plotsHeight(); off_t samplesPerLine(); void updateView(); }; \ No newline at end of file