# HG changeset patch # User Hasan Yavuz Ă–ZDERYA # Date 2016-04-03 14:53:24 # Node ID 110ac52a689451e7eb86cc5e0a7a44199a06ae92 # Parent ba9c69189b81c7504f277ecefddb3ae9eadd2508 added legend (channel names) to snapshot view diff --git a/src/snapshot.cpp b/src/snapshot.cpp --- a/src/snapshot.cpp +++ b/src/snapshot.cpp @@ -92,6 +92,16 @@ void Snapshot::setName(QString name) emit nameChanged(this); } +void Snapshot::setChannelNames(QStringList names) +{ + _channelNames = names; +} + +QString Snapshot::channelName(unsigned channel) +{ + return _channelNames[channel]; +} + void Snapshot::save(QString fileName) { // TODO: remove code duplication (MainWindow::onExportCsv) diff --git a/src/snapshot.h b/src/snapshot.h --- a/src/snapshot.h +++ b/src/snapshot.h @@ -25,6 +25,7 @@ #include #include #include +#include class SnapshotView; @@ -42,6 +43,8 @@ public: QString name(); void setName(QString name); + void setChannelNames(QStringList names); // must be called when setting data! + QString channelName(unsigned channel); void save(QString fileName); /// save snapshot data as CSV @@ -51,6 +54,7 @@ signals: private: QString _name; + QStringList _channelNames; QAction _showAction; QAction _deleteAction; QMainWindow* mainWindow; diff --git a/src/snapshotmanager.cpp b/src/snapshotmanager.cpp --- a/src/snapshotmanager.cpp +++ b/src/snapshotmanager.cpp @@ -76,6 +76,7 @@ void SnapshotManager::takeSnapshot() snapshot->data[ci][i] = QPointF(i, _channelMan->channelBuffer(ci)->sample(i)); } } + snapshot->setChannelNames(_channelMan->channelNames()->stringList()); addSnapshot(snapshot); } diff --git a/src/snapshotview.cpp b/src/snapshotview.cpp --- a/src/snapshotview.cpp +++ b/src/snapshotview.cpp @@ -35,7 +35,7 @@ SnapshotView::SnapshotView(QWidget *pare for (unsigned ci = 0; ci < numOfChannels; ci++) { - QwtPlotCurve* curve = new QwtPlotCurve(); + QwtPlotCurve* curve = new QwtPlotCurve(snapshot->channelName(ci)); curves.append(curve); curve->setSamples(snapshot->data[ci]); curve->setPen(Plot::makeColor(ci));