-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlaupolhumeswidget.h
169 lines (139 loc) · 5.01 KB
/
laupolhumeswidget.h
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#ifndef LAUPOLHUMESWIDGET_H
#define LAUPOLHUMESWIDGET_H
#include <QMenu>
#include <QWidget>
#include <QGroupBox>
#include <QQuaternion>
#include <QMessageBox>
#include <QPushButton>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QFileDialog>
#include <QApplication>
#include <QInputDialog>
#include <QTime>
#include <QList>
#include <QtCore>
#include <QDebug>
#include <QTimer>
#include <QThread>
#include <QPainter>
#include <QVector4D>
#include <QSettings>
#include <QSerialPort>
#include <QStandardPaths>
#include <QSerialPortInfo>
#include "lautcpserialportwidget.h"
#define LAUPOLHEMUS_ALIGNMENT_REFERENCE_FRAME 0x41
#define LAUPOLHEMUS_BORESIGHT 0x42
#define LAUPOLHEMUS_CONTINUOUS_PRINT_OUTPUT 0x43
#define LAUPOLHEMUS_SET_UNITS 0x55
/****************************************************************************/
/****************************************************************************/
/****************************************************************************/
class LAUPolhemusObject : public LAUTCPSerialPortClient
{
Q_OBJECT
public:
LAUPolhemusObject(QString portString, QObject *parent = 0) : LAUTCPSerialPortClient(portString, parent) { ; }
LAUPolhemusObject(QString ipAddr, int portNum, QObject *parent = 0) : LAUTCPSerialPortClient(ipAddr, portNum, parent) { ; }
~LAUPolhemusObject();
static QQuaternion quaternion(double pitch, double roll, double azimuth);
public slots:
void onReadyRead();
void onSendMessage(int message, void *argument);
void onError(QString error)
{
emit emitError(error);
}
private:
QByteArray processMessage(QByteArray byteArray);
signals:
void emitError(QString string);
void emitOdometry(QQuaternion pose, QVector3D position);
};
/****************************************************************************/
/****************************************************************************/
/****************************************************************************/
class LAUPolhemusLabel : public QLabel
{
Q_OBJECT
public:
LAUPolhemusLabel(QWidget *parent = 0);
public slots:
void onSavePoints();
void onEnableSavePoints(bool state);
void onUpdateOdometry(QQuaternion pose, QVector3D position);
protected:
void paintEvent(QPaintEvent *);
void mousePressEvent(QMouseEvent *event);
private:
bool savePointsFlag;
QList<QQuaternion> poses;
QList<QVector3D> points;
QVector3D topLeft;
QVector3D bottomRight;
QMenu *contextMenu;
int counter;
QTime time;
};
/****************************************************************************/
/****************************************************************************/
/****************************************************************************/
class LAUPolhemusWidget : public QWidget
{
Q_OBJECT
public:
LAUPolhemusWidget(QString portString = QString(), QWidget *parent = 0);
LAUPolhemusWidget(QString ipAddr, int portNum, QWidget *parent = 0);
~LAUPolhemusWidget();
bool isValid()
{
return (object && object->isValid());
}
protected:
void showEvent(QShowEvent *);
private:
LAUPolhemusObject *object;
LAUPolhemusLabel *label;
};
/****************************************************************************/
/****************************************************************************/
/****************************************************************************/
class LAUPolhemusDialog : public QDialog
{
Q_OBJECT
public:
LAUPolhemusDialog(QString portString = QString(), QWidget *parent = 0) : QDialog(parent)
{
this->setLayout(new QVBoxLayout());
this->layout()->setContentsMargins(6, 6, 6, 6);
this->setWindowTitle(QString("LAUPolhemus Dialog"));
widget = new LAUPolhemusWidget(portString);
this->layout()->addWidget(widget);
QDialogButtonBox *box = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
connect(box->button(QDialogButtonBox::Ok), SIGNAL(clicked()), this, SLOT(accept()));
connect(box->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), this, SLOT(reject()));
this->layout()->addWidget(box);
}
LAUPolhemusDialog(QString ipAddr, int portNum, QWidget *parent = 0) : QDialog(parent)
{
this->setLayout(new QVBoxLayout());
this->layout()->setContentsMargins(6, 6, 6, 6);
this->setWindowTitle(QString("LAUPolhemus Dialog"));
widget = new LAUPolhemusWidget(ipAddr, portNum);
this->layout()->addWidget(widget);
QDialogButtonBox *box = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
connect(box->button(QDialogButtonBox::Ok), SIGNAL(clicked()), this, SLOT(accept()));
connect(box->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), this, SLOT(reject()));
this->layout()->addWidget(box);
}
bool isValid()
{
return (widget->isValid());
}
public slots:
private:
LAUPolhemusWidget *widget;
};
#endif // LAUPOLHUMESWIDGET_H