diff --git a/CMakeLists.txt b/CMakeLists.txt index 7a2928e..0836825 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,10 +34,10 @@ list(APPEND inspectrum_sources inputsource.cpp memory_sink_impl.cc memory_source_impl.cc + plotview.cpp samplebuffer.cpp spectrogram.cpp spectrogramcontrols.cpp - waveformview.cpp util.cpp ) diff --git a/mainwindow.cpp b/mainwindow.cpp index fe02602..3e2d809 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -34,12 +34,12 @@ MainWindow::MainWindow() dock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); addDockWidget(Qt::LeftDockWidgetArea, dock); - wave = new WaveformView(); - addDockWidget(Qt::BottomDockWidgetArea, wave); - connect(this, SIGNAL(viewChanged(off_t, off_t)), wave, SLOT(viewChanged(off_t, off_t))); + plots = new PlotView(); + addDockWidget(Qt::BottomDockWidgetArea, plots); + connect(this, SIGNAL(viewChanged(off_t, off_t)), plots, SLOT(viewChanged(off_t, off_t))); connect(this, SIGNAL(selectionChanged(std::pair, std::pair)), - wave, SLOT(selectionChanged(std::pair, std::pair))); - connect(this, SIGNAL(selectionCleared()), wave, SLOT(selectionCleared())); + plots, SLOT(selectionChanged(std::pair, std::pair))); + connect(this, SIGNAL(selectionCleared()), plots, SLOT(selectionCleared())); connect(dock, SIGNAL(openFile(QString)), this, SLOT(openFile(QString))); connect(dock->sampleRate, SIGNAL(textChanged(QString)), this, SLOT(setSampleRate(QString))); @@ -180,6 +180,6 @@ void MainWindow::openFile(QString fileName) QString title="%1: %2"; this->setWindowTitle(title.arg(QApplication::applicationName(),fileName.section('/',-1,-1))); spectrogram.openFile(fileName); - wave->inputSourceChanged(spectrogram.inputSource); + plots->inputSourceChanged(spectrogram.inputSource); emitViewChanged(); } diff --git a/mainwindow.h b/mainwindow.h index e224fe0..18fa2c4 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -23,7 +23,7 @@ #include #include "spectrogram.h" #include "spectrogramcontrols.h" -#include "waveformview.h" +#include "plotview.h" class MainWindow : public QMainWindow { @@ -52,7 +52,7 @@ private: QScrollArea scrollArea; Spectrogram spectrogram; SpectrogramControls *dock; - WaveformView *wave; + PlotView *plots; std::pair selectionTime; std::pair selectionFreq; diff --git a/waveformview.cpp b/plotview.cpp similarity index 90% rename from waveformview.cpp rename to plotview.cpp index 9c567e0..cc0d880 100644 --- a/waveformview.cpp +++ b/plotview.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015, Mike Walters + * Copyright (C) 2015-2016, Mike Walters * * This file is part of inspectrum. * @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -#include "waveformview.h" +#include "plotview.h" #include #include #include @@ -29,7 +29,7 @@ #include "memory_sink.h" #include "memory_source.h" -WaveformView::WaveformView() +PlotView::PlotView() { for (int i = 0; i < 128; i++) { colormap[i] = qRgb(i/2, i*1.5, i*1.5); @@ -39,7 +39,7 @@ WaveformView::WaveformView() } } -void WaveformView::refreshSources() +void PlotView::refreshSources() { sampleSources.clear(); @@ -73,7 +73,7 @@ void WaveformView::refreshSources() update(); } -void WaveformView::inputSourceChanged(AbstractSampleSource *src) +void PlotView::inputSourceChanged(AbstractSampleSource *src) { auto derived = dynamic_cast>*>(src); if (derived == nullptr) @@ -83,14 +83,14 @@ void WaveformView::inputSourceChanged(AbstractSampleSource *src) refreshSources(); } -void WaveformView::viewChanged(off_t firstSample, off_t lastSample) +void PlotView::viewChanged(off_t firstSample, off_t lastSample) { this->firstSample = firstSample; this->lastSample = lastSample; update(); } -void WaveformView::selectionChanged(std::pair selectionTime, std::pair selectionFreq) +void PlotView::selectionChanged(std::pair selectionTime, std::pair selectionFreq) { this->selectionTime = selectionTime; this->selectionFreq = selectionFreq; @@ -98,13 +98,13 @@ void WaveformView::selectionChanged(std::pair selectionTime, std:: refreshSources(); } -void WaveformView::selectionCleared() +void PlotView::selectionCleared() { selection = false; refreshSources(); } -void WaveformView::paintEvent(QPaintEvent *event) +void PlotView::paintEvent(QPaintEvent *event) { if (lastSample - firstSample <= 0) return; @@ -133,7 +133,7 @@ void WaveformView::paintEvent(QPaintEvent *event) } } -void WaveformView::plot(QPainter *painter, QRect &rect, float *samples, off_t count, int step = 1) +void PlotView::plot(QPainter *painter, QRect &rect, float *samples, off_t count, int step = 1) { int xprev = 0; int yprev = 0; diff --git a/waveformview.h b/plotview.h similarity index 93% rename from waveformview.h rename to plotview.h index 5ab6911..64f5d2a 100644 --- a/waveformview.h +++ b/plotview.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015, Mike Walters + * Copyright (C) 2015-2016, Mike Walters * * This file is part of inspectrum. * @@ -23,12 +23,12 @@ #include #include "inputsource.h" -class WaveformView : public QDockWidget +class PlotView : public QDockWidget { Q_OBJECT public: - WaveformView(); + PlotView(); public slots: void inputSourceChanged(AbstractSampleSource *input);