diff --git a/CMakeLists.txt b/CMakeLists.txt
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -67,6 +67,7 @@ qt5_wrap_ui(UI_FILES
src/framedreadersettings.ui
src/demoreadersettings.ui
src/updatecheckdialog.ui
+ src/datatextview.ui
)
if (WIN32)
@@ -134,6 +135,7 @@ add_executable(${PROGRAM_NAME} WIN32
src/sink.cpp
src/samplecounter.cpp
src/ledwidget.cpp
+ src/datatextview.cpp
misc/windows_icon.rc
${UI_FILES}
${RES_FILES}
diff --git a/serialplot.pro b/serialplot.pro
--- a/serialplot.pro
+++ b/serialplot.pro
@@ -71,7 +71,8 @@ SOURCES += \
src/recordpanel.cpp \
src/updatechecker.cpp \
src/updatecheckdialog.cpp \
- src/demoreadersettings.cpp
+ src/demoreadersettings.cpp \
+ src/datatextview.cpp
HEADERS += \
src/mainwindow.h \
@@ -114,7 +115,8 @@ HEADERS += \
src/recordpanel.h \
src/updatechecker.h \
src/updatecheckdialog.h \
- src/demoreadersettings.h
+ src/demoreadersettings.h \
+ src/datatextview.h
FORMS += \
src/mainwindow.ui \
@@ -132,7 +134,8 @@ FORMS += \
src/asciireadersettings.ui \
src/recordpanel.ui \
src/updatecheckdialog.ui \
- src/demoreadersettings.ui
+ src/demoreadersettings.ui \
+ src/datatextview.ui
INCLUDEPATH += qmake/ src/
diff --git a/src/datatextview.cpp b/src/datatextview.cpp
new file mode 100644
--- /dev/null
+++ b/src/datatextview.cpp
@@ -0,0 +1,110 @@
+/*
+ Copyright © 2019 Hasan Yavuz Özderya
+
+ This file is part of serialplot.
+
+ serialplot is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ serialplot is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with serialplot. If not, see .
+*/
+
+#include "datatextview.h"
+#include "ui_datatextview.h"
+
+#include "setting_defines.h"
+#include "utils.h"
+
+class DataTextViewSink : public Sink
+{
+public:
+ DataTextViewSink(DataTextView* textView)
+ {
+ _textView = textView;
+ }
+
+protected:
+ virtual void feedIn(const SamplePack& data) override
+ {
+ _textView->addData(data);
+ };
+
+private:
+ DataTextView* _textView;
+};
+
+DataTextView::DataTextView(Stream* stream, QWidget *parent) :
+ QWidget(parent),
+ ui(new Ui::DataTextView)
+{
+ _stream = stream;
+ ui->setupUi(this);
+ sink = new DataTextViewSink(this);
+
+ connect(ui->cbEnable, &QCheckBox::toggled, [this](bool checked)
+ {
+ if (checked)
+ {
+ _stream->connectFollower(sink);
+ }
+ else
+ {
+ _stream->disconnectFollower(sink);
+ }
+ });
+
+ ui->textView->setMaximumBlockCount(ui->spNumLines->value());
+ connect(ui->spNumLines, SELECT::OVERLOAD_OF(&QSpinBox::valueChanged),
+ [this](int value)
+ {
+ ui->textView->setMaximumBlockCount(value);
+ });
+
+ connect(ui->pbClear, &QPushButton::clicked, ui->textView, &QPlainTextEdit::clear);
+}
+
+DataTextView::~DataTextView()
+{
+ delete sink;
+ delete ui;
+}
+
+void DataTextView::addData(const SamplePack& data)
+{
+ for (unsigned int i = 0; i < data.numSamples(); i++)
+ {
+ QString str;
+ for (unsigned ci = 0; ci < data.numChannels(); ci++)
+ {
+ str += QString::number(data.data(ci)[i], 'f', ui->spDecimals->value());
+ if (ci != data.numChannels()-1) str += " ";
+ }
+ ui->textView->appendPlainText(str);
+ }
+}
+
+void DataTextView::saveSettings(QSettings* settings)
+{
+ settings->beginGroup(SettingGroup_Plot);
+ settings->setValue(SG_TextView_NumLines, ui->spNumLines->value());
+ settings->setValue(SG_TextView_Decimals, ui->spDecimals->value());
+ settings->endGroup();
+}
+
+void DataTextView::loadSettings(QSettings* settings)
+{
+ settings->beginGroup(SettingGroup_Plot);
+ ui->spNumLines->setValue(
+ settings->value(SG_TextView_NumLines, ui->spNumLines->value()).toInt());
+ ui->spDecimals->setValue(
+ settings->value(SG_TextView_Decimals, ui->spDecimals->value()).toInt());
+ settings->endGroup();
+}
diff --git a/src/datatextview.h b/src/datatextview.h
new file mode 100644
--- /dev/null
+++ b/src/datatextview.h
@@ -0,0 +1,57 @@
+/*
+ Copyright © 2019 Hasan Yavuz Özderya
+
+ This file is part of serialplot.
+
+ serialplot is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ serialplot is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with serialplot. If not, see .
+*/
+
+#ifndef DATATEXTVIEW_H
+#define DATATEXTVIEW_H
+
+#include
+
+#include "stream.h"
+
+namespace Ui {
+class DataTextView;
+}
+
+class DataTextViewSink;
+
+class DataTextView : public QWidget
+{
+ Q_OBJECT
+
+public:
+ explicit DataTextView(Stream* stream, QWidget *parent = 0);
+ ~DataTextView();
+
+ /// Stores settings into a `QSettings`
+ void saveSettings(QSettings* settings);
+ /// Loads settings from a `QSettings`.
+ void loadSettings(QSettings* settings);
+
+protected:
+ void addData(const SamplePack& data);
+
+ friend DataTextViewSink;
+
+private:
+ Ui::DataTextView *ui;
+ DataTextViewSink* sink;
+ Stream* _stream;
+};
+
+#endif // DATATEXTVIEW_H
diff --git a/src/datatextview.ui b/src/datatextview.ui
new file mode 100644
--- /dev/null
+++ b/src/datatextview.ui
@@ -0,0 +1,99 @@
+
+
+ DataTextView
+
+
+
+ 0
+ 0
+ 451
+ 212
+
+
+
+ Form
+
+
+ -
+
+
-
+
+
+ Enable display of plotted data as text.
+
+
+ Enable
+
+
+
+ -
+
+
+ Num. Lines:
+
+
+
+ -
+
+
+ 1
+
+
+ 10000
+
+
+ 1000
+
+
+
+ -
+
+
+ Decimals:
+
+
+
+ -
+
+
+ 9
+
+
+ 6
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 1
+
+
+
+
+ -
+
+
+ Clear
+
+
+
+
+
+ -
+
+
+ true
+
+
+
+
+
+
+
+
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -1,5 +1,5 @@
/*
- Copyright © 2018 Hasan Yavuz Özderya
+ Copyright © 2019 Hasan Yavuz Özderya
This file is part of serialplot.
@@ -55,7 +55,8 @@ const QMap panelSettingMap
{2, "Plot"},
{3, "Commands"},
{4, "Record"},
- {5, "Log"}
+ {5, "TextView"},
+ {6, "Log"}
});
MainWindow::MainWindow(QWidget *parent) :
@@ -68,6 +69,7 @@ MainWindow::MainWindow(QWidget *parent)
commandPanel(&serialPort),
dataFormatPanel(&serialPort),
recordPanel(&stream),
+ textView(&stream),
updateCheckDialog(this)
{
ui->setupUi(this);
@@ -79,6 +81,7 @@ MainWindow::MainWindow(QWidget *parent)
ui->tabWidget->insertTab(2, &plotControlPanel, "Plot");
ui->tabWidget->insertTab(3, &commandPanel, "Commands");
ui->tabWidget->insertTab(4, &recordPanel, "Record");
+ ui->tabWidget->insertTab(5, &textView, "Text View");
ui->tabWidget->setCurrentIndex(0);
auto tbPortControl = portControl.toolBar();
addToolBar(tbPortControl);
@@ -521,6 +524,7 @@ void MainWindow::saveAllSettings(QSettin
plotMenu.saveSettings(settings);
commandPanel.saveSettings(settings);
recordPanel.saveSettings(settings);
+ textView.saveSettings(settings);
updateCheckDialog.saveSettings(settings);
}
@@ -534,6 +538,7 @@ void MainWindow::loadAllSettings(QSettin
plotMenu.loadSettings(settings);
commandPanel.loadSettings(settings);
recordPanel.loadSettings(settings);
+ textView.loadSettings(settings);
updateCheckDialog.loadSettings(settings);
}
diff --git a/src/mainwindow.h b/src/mainwindow.h
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -1,5 +1,5 @@
/*
- Copyright © 2018 Hasan Yavuz Özderya
+ Copyright © 2019 Hasan Yavuz Özderya
This file is part of serialplot.
@@ -46,6 +46,7 @@
#include "plotmenu.h"
#include "updatecheckdialog.h"
#include "samplecounter.h"
+#include "datatextview.h"
namespace Ui {
class MainWindow;
@@ -89,6 +90,7 @@ private:
RecordPanel recordPanel;
PlotControlPanel plotControlPanel;
PlotMenu plotMenu;
+ DataTextView textView;
UpdateCheckDialog updateCheckDialog;
/// Returns true if demo is running
diff --git a/src/setting_defines.h b/src/setting_defines.h
--- a/src/setting_defines.h
+++ b/src/setting_defines.h
@@ -1,5 +1,5 @@
/*
- Copyright © 2018 Hasan Yavuz Özderya
+ Copyright © 2019 Hasan Yavuz Özderya
This file is part of serialplot.
@@ -30,6 +30,7 @@ const char SettingGroup_Channels[] = "Ch
const char SettingGroup_Plot[] = "Plot";
const char SettingGroup_Commands[] = "Commands";
const char SettingGroup_Record[] = "Record";
+const char SettingGroup_TextView[] = "TextView";
const char SettingGroup_UpdateCheck[] = "UpdateCheck";
// mainwindow setting keys
@@ -112,6 +113,10 @@ const char SG_Record_Separator[]
const char SG_Record_DisableBuffering[] = "disableBuffering";
const char SG_Record_Timestamp[] = "timestamp";
+// text view settings keys
+const char SG_TextView_NumLines[] = "numLines";
+const char SG_TextView_Decimals[] = "decimals";
+
// update check settings keys
const char SG_UpdateCheck_Periodic[] = "periodicCheck";
const char SG_UpdateCheck_LastCheck[] = "lastCheck";