direcs  2012-09-30
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
compassWidget.h
Go to the documentation of this file.
1 /*************************************************************************
2  * Copyright (C) Markus Knapp *
3  * www.direcs.de *
4  * *
5  * This file is part of direcs. *
6  * *
7  * direcs is free software: you can redistribute it and/or modify it *
8  * under the terms of the GNU General Public License as published *
9  * by the Free Software Foundation, version 3 of the License. *
10  * *
11  * direcs is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14  * GNU General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU General Public License *
17  * along with direcs. If not, see <http://www.gnu.org/licenses/>. *
18  * *
19  *************************************************************************/
20 
21 #ifndef COMPASSWIDGET_H
22 #define COMPASSWIDGET_H
23 
24 #include <QtGui>
25 #include <QtOpenGL>
26 #include <QGLWidget>
27 
28 #include <math.h>
29 
30 
35 class CompassWidget : public QGLWidget
36 {
37  Q_OBJECT
38 
39  public:
40  CompassWidget(QWidget *parent = 0);
42 
43  QSize minimumSizeHint() const;
44  QSize sizeHint() const;
45 
46  public slots:
47  void setXRotation(float angle);
48  void setYRotation(float angle);
49  void setZRotation(float angle);
50 
58  void setAllRotations(float xAngle, float yAngle, float zAngle);
59 
60  void setBackgroundColor(QColor col);
61 
62 
63  signals:
64  void xRotationChanged(float angle);
65  void yRotationChanged(float angle);
66  void zRotationChanged(float angle);
67 
68 
69  protected:
70  void initializeGL();
71  void paintGL();
72  void resizeGL(int width, int height);
73  void mousePressEvent(QMouseEvent *event);
74  void mouseMoveEvent(QMouseEvent *event);
75 
76 
77  private:
78  void normalizeAngle(float *angle);
79 
80  GLUquadricObj* xAxisCylinder;
81  GLUquadricObj* yAxisCylinder;
82  GLUquadricObj* zAxisCylinder;
83  GLUquadricObj* xAxisCone;
84  GLUquadricObj* yAxisCone;
85  GLUquadricObj* zAxisCone;
86 
87  float xRot;
88  float yRot;
89  float zRot;
90 
93  double m_mouseAngleH;
94  double m_mouseAngleV;
95 
96  GLdouble cyl_radius;
97  GLdouble cyl_height;
98  GLdouble cubeWidth;
99  GLdouble cubeHeight;
100  GLdouble cubeDepth;
101  QPoint lastPos;
102  QColor xAxisColor;
103  QColor yAxisColor;
104  QColor zAxisColor;
114 };
115 
116 #endif