forked from apsystems/GrblHoming
-
Notifications
You must be signed in to change notification settings - Fork 189
/
lineitem.cpp
61 lines (51 loc) · 1.03 KB
/
lineitem.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
#include "lineitem.h"
LineItem::LineItem(double x1, double y1, int index1)
: ItemToBase(index1), x(x1), y(y1)
{
}
LineItem::LineItem(double x1, double y1, bool stretchX1, double length1)
: ItemToBase(0), x(x1), y(y1), stretchX(stretchX1), length(length1)
{
}
PosItem LineItem::computeExtents()
{
PosItem curr(x, y, x, y);
return curr;
}
void LineItem::addToPath(QPainterPath& path)
{
path.lineTo(screenX(x), screenY(y));
}
void LineItem::moveToFirst(QPainterPath& path)
{
path.moveTo(screenX(x), screenY(y));
}
double LineItem::getXScr()
{
return screenX(x);
}
double LineItem::getYScr()
{
return screenY(y);
}
double LineItem::getXRaw()
{
return x;
}
double LineItem::getYRaw()
{
return y;
}
void LineItem::drawTo(QPainterPath& path)
{
if (stretchX)
{
path.moveTo(screenX(x), screenY(y) + length);
path.lineTo(screenX(x), screenY(y) - length);
}
else
{
path.moveTo(screenX(x) + length, screenY(y));
path.lineTo(screenX(x) - length, screenY(y));
}
}