5
5
#include " chart.h"
6
6
#include < QDebug>
7
7
#include < QRandomGenerator>
8
+ #include < iostream>
9
+
10
+ using namespace std ;
8
11
9
12
Chart::Chart (QObject *parent) : QObject(parent) {
10
13
dataUpdater.setInterval (0 );
11
14
dataUpdater.setSingleShot (true );
12
15
QObject::connect (&dataUpdater, &QTimer::timeout, this , &Chart::updateAllSeries);
16
+
17
+ matrix = new MatrixXd (250 ,24 );
13
18
}
14
19
15
20
void Chart::startUpdating (const QList<QLineSeries *> &seriesList, const QVector<qreal> &values, qreal windowWidth,
@@ -20,7 +25,14 @@ void Chart::startUpdating(const QList<QLineSeries *> &seriesList, const QVector<
20
25
return ;
21
26
}
22
27
28
+ auto valuesVector = std::vector<qreal>(values.begin (), values.end ());
29
+ RowVectorXd vector = Map<RowVectorXd, Unaligned>(valuesVector.data (), valuesVector.size ());
30
+ // cout << vector << endl;
31
+
23
32
c_seriesList = seriesList;
33
+ matrix->row (valueCounter) = vector;
34
+ // cout << matrix->row(0) << endl;
35
+ // cout << "hello" << endl;
24
36
25
37
// qreal xAdjustment = 20.0 / (10 * values.length());
26
38
// qreal yMultiplier = 3.0 / qreal(values.length());
@@ -36,7 +48,7 @@ void Chart::startUpdating(const QList<QLineSeries *> &seriesList, const QVector<
36
48
// }
37
49
// qInfo() << m_data;
38
50
39
- tempData.append (values);
51
+ // tempData.append(values);
40
52
41
53
// for (int i = 0; i < values.length(); ++i) {
42
54
// // seriesList[i]->clear();
@@ -67,9 +79,35 @@ void Chart::updateAllSeries() {
67
79
qInfo () << " updates called" ;
68
80
qInfo () << tempData.length ();
69
81
70
- tempData.clear ();
82
+ // tempData.clear();
83
+ removeZeroRows (*matrix);
84
+ cout << matrix->colwise ().mean () << endl;
85
+ // exit(0);
71
86
72
87
// for (int i = 0; i < c_seriesList.length(); ++i) {
73
88
// c_seriesList[i]->replace(m_data);
74
89
// }
90
+ delete matrix;
91
+ matrix = nullptr ;
92
+ matrix = new MatrixXd (250 , 24 );
93
+ }
94
+
95
+ void Chart::removeZeroRows (Eigen::MatrixXd& mat)
96
+ {
97
+ Matrix<bool , Dynamic, 1 > empty = (mat.array () == 0 ).rowwise ().all ();
98
+
99
+ size_t last = mat.rows () - 1 ;
100
+ for (size_t i = 0 ; i < last + 1 ;)
101
+ {
102
+ if (empty (i))
103
+ {
104
+ mat.row (i).swap (mat.row (last));
105
+ empty.segment <1 >(i).swap (empty.segment <1 >(last));
106
+ --last;
107
+ }
108
+ else {
109
+ ++i;
110
+ }
111
+ }
112
+ mat.conservativeResize (last + 1 , mat.cols ());
75
113
}
0 commit comments