From c797e2b83c00139e950b9df679da0fc36adeb2e3 Mon Sep 17 00:00:00 2001 From: Mike Walters Date: Tue, 1 Mar 2016 21:24:32 +0000 Subject: [PATCH] plot: Add height() --- plot.h | 7 +++++++ plotview.cpp | 8 +++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/plot.h b/plot.h index 850f5fa..c9d2c3e 100644 --- a/plot.h +++ b/plot.h @@ -30,4 +30,11 @@ public: virtual void paintBack(QPainter &painter, QRect &rect, range_t sampleRange) = 0; virtual void paintMid(QPainter &painter, QRect &rect, range_t sampleRange) = 0; virtual void paintFront(QPainter &painter, QRect &rect, range_t sampleRange) = 0; + int height() const { return _height; }; + +protected: + void setHeight(int height) { _height = height; }; + +private: + int _height = 50; }; diff --git a/plotview.cpp b/plotview.cpp index db22de4..af5c57f 100644 --- a/plotview.cpp +++ b/plotview.cpp @@ -121,16 +121,14 @@ void PlotView::paintEvent(QPaintEvent *event) QPainter painter(this); painter.fillRect(rect, Qt::black); - // Split space equally between waveforms for now - int plotHeight = height() / plots.size(); #define PLOT_LAYER(paintFunc) \ { \ - int plotCount = 0; \ + int y = 0; \ for (auto&& plot : plots) { \ - QRect rect = QRect(0, plotCount * plotHeight, width(), plotHeight); \ + QRect rect = QRect(0, y, width(), plot->height()); \ plot->paintFunc(painter, rect, {firstSample, lastSample}); \ - plotCount++; \ + y += plot->height(); \ } \ }