diff --git a/plot.h b/plot.h index 14f6cc4..0e0e57c 100644 --- a/plot.h +++ b/plot.h @@ -25,6 +25,7 @@ class Plot : public QObject { + Q_OBJECT public: virtual void paintBack(QPainter &painter, QRect &rect, range_t sampleRange); @@ -32,6 +33,9 @@ public: virtual void paintFront(QPainter &painter, QRect &rect, range_t sampleRange); int height() const { return _height; }; +signals: + void repaint(); + protected: void setHeight(int height) { _height = height; }; diff --git a/plotview.cpp b/plotview.cpp index e7d85ab..ec257bb 100644 --- a/plotview.cpp +++ b/plotview.cpp @@ -42,19 +42,22 @@ PlotView::PlotView(InputSource *input) : cursors(this), tuner(this), viewRange({ connect(&tuner, &Tuner::tunerMoved, this, &PlotView::tunerMoved); spectrogramPlot = new SpectrogramPlot(mainSampleSource); - plots.emplace_back(spectrogramPlot); - iqPlot = createIQPlot(mainSampleSource); - plots.emplace_back(iqPlot); auto quadDemodPlot = createQuadratureDemodPlot(static_cast>*>(iqPlot->source().get())); - plots.emplace_back(quadDemodPlot); - connect(iqPlot, &TracePlot::repaint, this, &PlotView::repaint); - connect(quadDemodPlot, &TracePlot::repaint, this, &PlotView::repaint); + addPlot(spectrogramPlot); + addPlot(iqPlot); + addPlot(quadDemodPlot); mainSampleSource->subscribe(this); } +void PlotView::addPlot(Plot *plot) +{ + plots.emplace_back(plot); + connect(plot, &Plot::repaint, this, &PlotView::repaint); +} + TracePlot* PlotView::createIQPlot(SampleSource> *src) { gr::top_block_sptr iq_tb = gr::make_top_block("multiply"); diff --git a/plotview.h b/plotview.h index 2f237f9..5ed4791 100644 --- a/plotview.h +++ b/plotview.h @@ -79,6 +79,7 @@ private: int powerMax; bool cursorsEnabled; + void addPlot(Plot *plot); TracePlot* createIQPlot(SampleSource> *src); TracePlot* createQuadratureDemodPlot(SampleSource> *src); int plotsHeight(); diff --git a/traceplot.h b/traceplot.h index 6f2da7f..c277f41 100644 --- a/traceplot.h +++ b/traceplot.h @@ -35,7 +35,6 @@ public: signals: void imageReady(QString key, QImage image); - void repaint(); public slots: void handleImage(QString key, QImage image);