-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaxdataseries.cpp
More file actions
executable file
·43 lines (38 loc) · 1.06 KB
/
axdataseries.cpp
File metadata and controls
executable file
·43 lines (38 loc) · 1.06 KB
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
#include "axdataseries.h"
AXDataSeries::AXDataSeries(
QString variableName,
QVector<double> xData,
QVector<double> yData
)
{
this->variableName = variableName;
this->xData = xData;
this->yData = yData;
this->multipliedYData = yData;
this->multiplier = 1.0;
this->isDividing = false;
this->isVisible = false;
int r, g, b;
r = 80 + qrand() % 120;
g = 80 + qrand() % 120;
b = 80 + qrand() % 120;
this->color = QColor(r, g, b);
}
void AXDataSeries::trySetMultiplier(QString newMultiplier) {
bool ok;
double mult;
mult = newMultiplier.toDouble(&ok);
if (ok) {
this->multiplier = mult;
this->applyMultiplier();
}
}
void AXDataSeries::applyMultiplier() {
for (int i=0; i < this->yData.count(); i++) {
if (this->isDividing && !(this->multiplier == 0.0)) {
multipliedYData[i] = yData[i] / multiplier;
} else if (!this->isDividing) {
multipliedYData[i] = yData[i] * multiplier;
}
}
}