Files
@ 23909dc96af6
Branch filter:
Location: tempo-plotter/src/datatextview.cpp - annotation
23909dc96af6
3.0 KiB
text/x-c++hdr
make buildable with Qt version smaller then 5.5
ubuntu 14.04 ships with qt 5.2 and this is a relatively small optimisation
ubuntu 14.04 ships with qt 5.2 and this is a relatively small optimisation
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | d622519d65b3 d622519d65b3 d622519d65b3 d622519d65b3 d622519d65b3 d622519d65b3 d622519d65b3 d622519d65b3 d622519d65b3 d622519d65b3 d622519d65b3 d622519d65b3 d622519d65b3 d622519d65b3 d622519d65b3 d622519d65b3 d622519d65b3 d622519d65b3 d622519d65b3 8d241dce8310 8d241dce8310 8d241dce8310 0aac016ebd15 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 8d241dce8310 0aac016ebd15 0aac016ebd15 0aac016ebd15 0aac016ebd15 0aac016ebd15 0aac016ebd15 0aac016ebd15 0aac016ebd15 0aac016ebd15 0aac016ebd15 0aac016ebd15 0aac016ebd15 0aac016ebd15 0aac016ebd15 0aac016ebd15 0aac016ebd15 0aac016ebd15 0aac016ebd15 | /*
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 <http://www.gnu.org/licenses/>.
*/
#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<int>::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();
}
|