-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlaserpointer.cpp
More file actions
82 lines (65 loc) · 1.65 KB
/
laserpointer.cpp
File metadata and controls
82 lines (65 loc) · 1.65 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
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
76
77
78
79
80
81
#include "laserpointer.h"
Laserpointer::Laserpointer()
{
angles = QPointF(0,0);
minMaxAngles = QRectF(QPointF(-45, -45), QPointF(45,45));
calibrationAngles.clear();
calibrationAngles.push_back(QPointF(-30,30));
calibrationAngles.push_back(QPointF(30,30));
calibrationAngles.push_back(QPointF(30,-30));
calibrationAngles.push_back(QPointF(-30,-30));
laserMode = LASER_OFF;
}
Laserpointer::~Laserpointer()
{
}
void Laserpointer::setAngles(QPointF angles)
{
setAngleX(angles.x());
setAngleY(angles.y());
}
void Laserpointer::setAngleX(qreal x)
{
if(this->angles.x() != x)
{
angles.setX(qMax(minMaxAngles.left(),qMin(minMaxAngles.right(),x)));
notifyObservers();
}
}
void Laserpointer::setAngleY(qreal y)
{
if(this->angles.y() != y)
{
angles.setY(qMax(minMaxAngles.top(),qMin(minMaxAngles.bottom(),y)));
notifyObservers();
}
}
void Laserpointer::setMinMaxAngles(QRectF minMaxAngles)
{
if(this->minMaxAngles != minMaxAngles)
{
this->minMaxAngles = minMaxAngles;
notifyObservers();
}
}
void Laserpointer::setLaserMode(LaserMode laserMode)
{
if(laserMode != this->laserMode)
{
this->laserMode = laserMode;
notifyObservers();
}
}
void Laserpointer::notifyObservers()
{
for(Observer *o : observerList)
{
o->updateObserver(minMaxAngles, angles, laserMode, calibrationAngles);
}
}
void Laserpointer::setCalibrationAngles(QPointF *calibrationAngles)
{
this->calibrationAngles.clear();
std::copy(calibrationAngles, calibrationAngles+4, std::back_inserter(this->calibrationAngles));
notifyObservers();
}