-
Notifications
You must be signed in to change notification settings - Fork 1
/
h3canvasdelegate.h
63 lines (55 loc) · 1.87 KB
/
h3canvasdelegate.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
#ifndef H3CANVASDELEGATE_H
#define H3CANVASDELEGATE_H
#include <QtOpenGL>
#include <QGLWidget>
#include <GL/glu.h>
#include "tools.h"
class GLVector
{
public :
GLVector(GLdouble x = 0.0d, GLdouble y = 0.0d, GLdouble z = 0.0d);
GLdouble x;
GLdouble y;
GLdouble z;
GLdouble norm() const { return sqrt(x*x+y*y+z*z);}
GLdouble scalarProduct(const GLVector &v) const;
GLVector vectorProduct(const GLVector &v) const;
GLVector add(const GLVector &v) const;
GLVector opposite() const;
GLVector scalarMult(const GLdouble lambda) const;
GLVector normalize() const;
};
class H3canvasDelegate : public QGLWidget
{
Q_OBJECT
public:
explicit H3canvasDelegate(int framesPerSecond = 0, QWidget *parent = 0, char *name = 0);
~H3canvasDelegate();
void initializeGL();
void resizeGL(int width, int height);
void paintGL();
void printAxis(double length);
void printCube();
void keyPressEvent( QKeyEvent *keyEvent );
void mouseGLCoordinates(const QMouseEvent * mouseevent, GLVector &pos, GLdouble *modelView = 0) const;
public slots:
void timeOutSlot();
void mousePressEvent(QMouseEvent * mouseevent);
void mouseReleaseEvent(QMouseEvent * mouseevent);
void mouseMoveEvent(QMouseEvent * mouseevent);
void wheelEvent(QWheelEvent * wheelevent);
private:
QTimer *t_Timer;
int timerInterval;
void glVertex3(const GLVector v);
bool isClicked;
GLdouble angle;
GLVector mousePosition;
GLVector normalvect;
GLVector currentPosition;
GLdouble modelviewsave[16];
void drawSphere(const GLVector ¢er,GLdouble radius,GLenum style = GLU_SILHOUETTE);
void drawCircleArc(const GLVector ¢er, const GLVector &normal, const GLVector &first /*relative to the center*/, GLdouble angle) const;
void drawH3geodesic(const GLVector &, const GLVector &) const;
};
#endif // H3CANVASDELEGATE_H