Permalink
Browse files

plot: Add sample output interface

  • Loading branch information...
1 parent 2102e34 commit ec45e0f6daab6161eebcf42782b86545142b1433 @miek committed Apr 7, 2016
Showing with 20 additions and 7 deletions.
  1. +10 −0 plot.cpp
  2. +5 −0 plot.h
  3. +1 −1 plotview.cpp
  4. +1 −2 spectrogramplot.cpp
  5. +2 −2 spectrogramplot.h
  6. +1 −1 traceplot.cpp
  7. +0 −1 traceplot.h
View
@@ -19,11 +19,21 @@
#include "plot.h"
+Plot::Plot(std::shared_ptr<AbstractSampleSource> src) : sampleSource(src)
+{
+
+}
+
bool Plot::mouseEvent(QEvent::Type type, QMouseEvent event)
{
}
+std::shared_ptr<AbstractSampleSource> Plot::output()
+{
+ return sampleSource;
+}
+
void Plot::paintBack(QPainter &painter, QRect &rect, range_t<off_t> sampleRange)
{
painter.save();
View
@@ -22,14 +22,17 @@
#include <QMouseEvent>
#include <QObject>
#include <QPainter>
+#include "abstractsamplesource.h"
#include "util.h"
class Plot : public QObject
{
Q_OBJECT
public:
+ Plot(std::shared_ptr<AbstractSampleSource> src);
virtual bool mouseEvent(QEvent::Type type, QMouseEvent event);
+ virtual std::shared_ptr<AbstractSampleSource> output();
virtual void paintBack(QPainter &painter, QRect &rect, range_t<off_t> sampleRange);
virtual void paintMid(QPainter &painter, QRect &rect, range_t<off_t> sampleRange);
virtual void paintFront(QPainter &painter, QRect &rect, range_t<off_t> sampleRange);
@@ -41,6 +44,8 @@ class Plot : public QObject
protected:
void setHeight(int height) { _height = height; };
+ std::shared_ptr<AbstractSampleSource> sampleSource;
+
private:
// TODO: don't hardcode this
int _height = 200;
View
@@ -39,7 +39,7 @@ PlotView::PlotView(InputSource *input) : cursors(this), tuner(this), viewRange({
connect(&cursors, SIGNAL(cursorsMoved()), this, SLOT(cursorsMoved()));
connect(&tuner, &Tuner::tunerMoved, this, &PlotView::tunerMoved);
- spectrogramPlot = new SpectrogramPlot(mainSampleSource);
+ spectrogramPlot = new SpectrogramPlot(std::shared_ptr<SampleSource<std::complex<float>>>(mainSampleSource));
iqPlot = createIQPlot(mainSampleSource);
auto quadDemodPlot = createQuadratureDemodPlot(static_cast<SampleSource<std::complex<float>>*>(iqPlot->source().get()));
View
@@ -29,9 +29,8 @@
#include "util.h"
-SpectrogramPlot::SpectrogramPlot(SampleSource<std::complex<float>> *src)
+SpectrogramPlot::SpectrogramPlot(std::shared_ptr<SampleSource<std::complex<float>>> src) : Plot(src), inputSource(src)
{
- inputSource = src;
sampleRate = 8000000;
setFFTSize(512);
zoomLevel = 0;
View
@@ -37,7 +37,7 @@ class SpectrogramPlot : public Plot
Q_OBJECT
public:
- SpectrogramPlot(SampleSource<std::complex<float>> *src);
+ SpectrogramPlot(std::shared_ptr<SampleSource<std::complex<float>>> src);
void paintMid(QPainter &painter, QRect &rect, range_t<off_t> sampleRange);
@@ -46,7 +46,7 @@ class SpectrogramPlot : public Plot
int getStride();
off_t lineToSample(off_t line);
- SampleSource<std::complex<float>> *inputSource = nullptr;
+ std::shared_ptr<SampleSource<std::complex<float>>> inputSource;
public slots:
void setSampleRate(int rate);
View
@@ -23,7 +23,7 @@
#include "samplesource.h"
#include "traceplot.h"
-TracePlot::TracePlot(std::shared_ptr<AbstractSampleSource> source) : sampleSource(source) {
+TracePlot::TracePlot(std::shared_ptr<AbstractSampleSource> source) : Plot(source) {
connect(this, &TracePlot::imageReady, this, &TracePlot::handleImage);
}
View
@@ -42,7 +42,6 @@ public slots:
private:
QSet<QString> tasks;
const int tileWidth = 1000;
- std::shared_ptr<AbstractSampleSource> sampleSource;
QPixmap getTile(off_t tileID, off_t sampleCount);
void drawTile(QString key, const QRect &rect, range_t<off_t> sampleRange);

0 comments on commit ec45e0f

Please sign in to comment.