/
ecgch.cpp
61 lines (57 loc) · 2.09 KB
/
ecgch.cpp
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
#include "ecgch.h"
EcgCh::EcgCh(QWidget *parent) :
QwtPlot(parent)
{
setMinimumHeight(10);
setMinimumWidth(10);
QwtPlotGrid *grid = new QwtPlotGrid;
grid->enableXMin(true);
grid->setMajPen(QPen(Qt::white, 0, Qt::DotLine));
grid->setMinPen(QPen(Qt::gray, 0 , Qt::DotLine));
grid->attach(this);
setAxisTitle(QwtPlot::xBottom, "Czas [s]");
setAxisTitle(QwtPlot::yLeft, "Amplituda [mv]");
// picker = new QwtPlotPicker(QwtPlot::xBottom, QwtPlot::yLeft, QwtPlotPicker::CrossRubberBand, QwtPicker::AlwaysOn, canvas());
// picker->setStateMachine(new QwtPickerDragPointMachine());
// picker->setRubberBandPen(QColor(Qt::green));
// picker->setRubberBand(QwtPicker::CrossRubberBand);
// picker->setTrackerPen(QColor(Qt::white));
curve = new QwtPlotCurve("signal");
curve->setYAxis(QwtPlot::yLeft);
curve->attach(this);
peaksCurve = new QwtPlotCurve("signal");
peaksCurve->setYAxis(QwtPlot::yLeft);
peaksCurve->setStyle(QwtPlotCurve::CurveStyle::Dots);
peaksCurve->setPen(QPen(Qt::red, 5));
peaksCurve->attach(this);
samples = new QVector<QPointF>;
data = new QwtPointSeriesData;
peaksSamples = new QVector<QPointF>;
peaksData = new QwtPointSeriesData;
replot();
}
void EcgCh::setSignal(ECGSignalChannel signal, ECGChannelInfo info)
{
gsl_vector *v = signal->signal;
float invgain = 1.0 / float(info.gain);
float dt = 1.0 / float(info.frequecy);
int size = int(v->size);
samples->clear();
for (int i = 0; i < size; i++)
samples->push_back(QPointF(float(i)*dt, float(v->data[i*v->stride])*invgain));
data->setSamples(*samples);
curve->setData(data);
replot();
}
void EcgCh::setSignal(ECGSignalChannel signal, ECGChannelInfo info, IntSignal peaks)
{
this->setSignal(signal, info);
// gsl_vector_int *v = peaks->signal;
// int size = int(v->size);
// peaksSamples->clear();
// for (int i = 0; i < size; i++)
// peaksSamples->push_back(data->sample(i));
// peaksData->setSamples(*peaksSamples);
// peaksCurve->setData(data);
// replot();
}