-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchartpainterlineseries.cpp
47 lines (38 loc) · 1.06 KB
/
chartpainterlineseries.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
#include "chartpainterlineseries.h"
ChartPainterLineSeries::ChartPainterLineSeries()
{
}
ChartPainterLineSeries::ChartPainterLineSeries(qreal lineWidth, QColor lineColor, qreal yMin, qreal yMax)
{
this->lineWidth = lineWidth;
this->lineColor = lineColor;
this->yMax = yMax;
this->yMin = yMin;
}
void ChartPainterLineSeries::addData(QList<QPointF> data)
{
for (QPointF point : data)
addPoint(point);
}
const QList<QLineF> ChartPainterLineSeries::getData()
{
return _data;
}
void ChartPainterLineSeries::addPoint(QPointF point)
{
QLineF line;
if (_data.empty())
line.setP1(point);
else
line.setP1(_data.last().p2());
line.setP2(point);
_data.append(line);
}
qreal ChartPainterLineSeries::_convertValueToNewScale(qreal oldValue, qreal oldScaleBottom, qreal oldScaleTop, qreal newScaleBottom, qreal newScaleTop)
{
qreal newValue = oldValue - oldScaleBottom;
newValue *= newScaleTop - newScaleBottom;
newValue /= oldScaleTop - oldScaleBottom;
newValue += newScaleBottom;
return newValue;
}