summaryrefslogtreecommitdiff
path: root/src/GLView.h
blob: 751689463684a2adf36b4ab6fbab00fd8db803e5 (plain)
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
#ifndef GLVIEW_H_
#define GLVIEW_H_

#ifdef ENABLE_OPENCSG
// this must be included before the GL headers
#  include <GL/glew.h>
#endif

#include <QGLWidget>
#include <QLabel>

class GLView : public QGLWidget
{
	Q_OBJECT
	Q_PROPERTY(bool showAxes READ showAxes WRITE setShowAxes);
	Q_PROPERTY(bool showCrosshairs READ showCrosshairs WRITE setShowCrosshairs);
	Q_PROPERTY(bool orthoMode READ orthoMode WRITE setOrthoMode);

public:
	GLView(QWidget *parent = NULL);
	void setRenderFunc(void (*func)(void*), void *userdata);
#ifdef ENABLE_OPENCSG
	bool hasOpenCSGSupport() { return this->opencsg_support; }
#endif
	// Properties
	bool showAxes() const { return this->showaxes; }
	void setShowAxes(bool enabled) { this->showaxes = enabled; }
	bool showCrosshairs() const { return this->showcrosshairs; }
	void setShowCrosshairs(bool enabled) { this->showcrosshairs = enabled; }
	bool orthoMode() const { return this->orthomode; }
	void setOrthoMode(bool enabled) { this->orthomode = enabled; }

	QLabel *statusLabel;
	double object_rot_x;
	double object_rot_y;
	double object_rot_z;
	double object_trans_x;
	double object_trans_y;
	double object_trans_z;
	GLint shaderinfo[11];

#ifdef ENABLE_OPENCSG
	bool opencsg_support;
	int opencsg_id;
#endif

private:
	void (*renderfunc)(void*);
	void *renderfunc_vp;

	bool showaxes;
	bool showcrosshairs;
	bool orthomode;

	double viewer_distance;

	double w_h_ratio;

	bool mouse_drag_active;
	int last_mouse_x;
	int last_mouse_y;

	void keyPressEvent(QKeyEvent *event);
	void wheelEvent(QWheelEvent *event);
	void mousePressEvent(QMouseEvent *event);
	void mouseMoveEvent(QMouseEvent *event);
	void mouseReleaseEvent(QMouseEvent *event);

	void initializeGL();
	void resizeGL(int w, int h);
	void paintGL();

#ifdef ENABLE_OPENCSG
private slots:
	void display_opengl20_warning();
#endif

signals:
	void doAnimateUpdate();
};

#endif
contact: Jan Huwald // Impressum