-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathglwidget.h
executable file
·157 lines (117 loc) · 3.38 KB
/
glwidget.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
#ifndef GLWIDGET_H
#define GLWIDGET_H
#include <QObject>
#include <QWidget>
#include <QGLWidget>
#include <QTimer>
#include <QMouseEvent>
class GLWidget : public QGLWidget
{
Q_OBJECT
public:
enum LeftMouseButtonMode
{
INACTIVE,
ROTATE,
PANNING
};
enum DeadReckoningMethod
{
INTEGRAL,
SIMPLE
};
explicit GLWidget(QWidget *parent = 0);
~GLWidget();
void addXY(GLfloat x, GLfloat y);
void addPulsesVrVl(int vr, int vl);
void addPulsesSrSl(int srPulses, int slPulses);
void resetDeadReckoning();
QSize sizeHint() const;
void clearEncoderLists();
int encoderListCount();
float getWheelDiameter() const;
void setWheelDiameter(float value);
float getPulsesPerRevolution() const;
void setPulsesPerRevolution(float value);
float getAxleLength() const;
void setAxleLength(float value);
void setDeadReckoningMethod(const DeadReckoningMethod &value);
QList<GLfloat> getEncoderRList() const;
void setEncoderRList(const QList<GLfloat> &value);
QList<GLfloat> getEncoderLList() const;
void setEncoderLList(const QList<GLfloat> &value);
signals:
void xRotationChanged(const int angle) const;
void yRotationChanged(const int angle) const;
void zRotationChanged(const int angle) const;
void xTranslationChanged(const float distance) const;
void yTranslationChanged(const float distance) const;
void zoomChanged(const float zoom);
public slots:
void setXRotation(int angle);
void setYRotation(int angle);
void setZRotation(int angle);
void setXTranslation(const float distance);
void setYTranslation(const float distance);
void setZoomLevel(const float level);
void setLeftMouseButtonMode(const GLWidget::LeftMouseButtonMode mode);
void update();
void addEncoderPulesVrVl(float *encoders);
protected:
//opengl events
void initializeGL();
void paintGL();
void resizeGL(int w, int h);
//mouse events
void mousePressEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent*);
void mouseMoveEvent(QMouseEvent *event);
void wheelEvent(QWheelEvent *event);
private:
//Struct to dead reckoning
struct position
{
float x; /* meter */
float y; /* meter */
float theta; /* radian (counterclockwise from x-axis) */
};
struct position current_position;
float wheelDiameter;
float pulsesPerRevolution;
float axleLength;
void draw(void);
void updateCursor(void);
void normalizeAngle(int *angle);
void convertVrVl(int vr, int vl);
GLfloat zoomfactor;
int xRot, yRot, zRot;
int xPos, yPos, zPos;
float xTrans, yTrans, zTrans;
QPoint lastPos;
float zoomFactor;
float zoomInc;
float defaultZoomFactor;
bool yAxisReversed;
LeftMouseButtonMode leftMouseButtonMode;
int width, height;
QTimer* timer;
bool newPoint;
GLfloat mX, mY;
QList<GLfloat> listPointsx;
QList<GLfloat> listPointsy;
QList<GLfloat> encoderRList;
QList<GLfloat> encoderLList;
int left_count;
int right_count;
float dist_left;
float dist_right;
int left_ticks;
int right_ticks;
float expr1;
float cos_current;
float sin_current;
float right_minus_left;
float MUL_COUNT;
DeadReckoningMethod deadReckoningMethod;
};
#endif // GLWIDGET_H