forked from zapmaker/GrblHoming
-
Notifications
You must be signed in to change notification settings - Fork 0
/
renderarea.cpp
75 lines (59 loc) · 1.78 KB
/
renderarea.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include "renderarea.h"
RenderArea::RenderArea(QWidget *parent)
: QWidget(parent),
penProposedPath(QPen(Qt::blue)), penAxes(QPen(QColor(193,97,0))),
penCoveredPath(QPen(QColor(60,196,70), 2)),
penCurrPosActive(QPen(Qt::red, 6)), penCurrPosInactive(QPen(QColor(60,196,70), 6)),
penMeasure(QPen(QColor(151,111,26))), isLiveCurrPos(false)
{
penCurrPosActive.setCapStyle(Qt::RoundCap);
penCurrPosInactive.setCapStyle(Qt::RoundCap);
}
void RenderArea::setItems(QList<PosItem> itemsRcvd)
{
items = itemsRcvd;
listToRender.setCurrFileLine(0);
listToRender.convertList(items);
listToRender.updateLivePoint();
update();
}
void RenderArea::setLivePoint(double x, double y, bool mm, bool isLiveCP)
{
isLiveCurrPos = isLiveCP;
livePoint.setCoords(x, y, mm);
listToRender.setLivePoint(livePoint);
update();
}
void RenderArea::setVisualLivenessCurrPos(bool isLiveCP)
{
isLiveCurrPos = isLiveCP;
}
void RenderArea::setVisCurrLine(int currLine)
{
if (listToRender.setCurrFileLine(currLine))
update();
}
void RenderArea::paintEvent(QPaintEvent * /* event */)
{
if (!items.size())
return;
QSize size = this->size();
listToRender.rescale(size);
QPainter painter(this);
painter.setPen(penProposedPath);
listToRender.writePath(painter, false);
painter.setPen(penAxes);
listToRender.drawAxes(painter);
painter.setPen(penMeasure);
listToRender.drawMeasurements(painter);
painter.setPen(penCoveredPath);
listToRender.writePath(painter, true);
//if (!livePoint.isNull()) FIX isNull
{
if (isLiveCurrPos)
painter.setPen(penCurrPosActive);
else
painter.setPen(penCurrPosInactive);
listToRender.drawPoint(painter, livePoint);
}
}