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(); \ } \ }