-
Notifications
You must be signed in to change notification settings - Fork 1
/
poschart.cpp
42 lines (39 loc) · 1.03 KB
/
poschart.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
#include "poschart.h"
PosChart::PosChart(QWidget *parent) :
QWidget(parent)
{
posRecord.clear();
}
void PosChart::paintEvent(QPaintEvent *)
{
posPainter = new QPainter(this);
posPainter->setRenderHint(QPainter::Antialiasing, true);
QPen* pen = new QPen;
pen->setWidth(3);
pen->setColor(QColor(Qt::black));
posPainter->setPen(*pen);
posPainter->drawLine(0, 0, 0, 100);
posPainter->drawLine(0, 50, 580, 50);
pen->setColor(QColor(Qt::darkMagenta));
posPainter->setPen(*pen);
if (posRecord.size() < 580)
{
for (int i = 0; i < posRecord.size() - 1; ++i)
{
posPainter->drawLine(i, posRecord.at(i), i + 1, posRecord.at(i+1));
}
}
else
{
for (int i = 580; i > 1; --i)
{
posPainter->drawLine(580 - i, posRecord.at(posRecord.size() - i),
581 - i, posRecord.at(posRecord.size() - i + 1));
}
}
posPainter->end();
}
void PosChart::insertPosValue(int pos)
{
posRecord << pos;
}