-
Notifications
You must be signed in to change notification settings - Fork 0
/
canvaswidget.h
100 lines (83 loc) · 2.14 KB
/
canvaswidget.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
#ifndef CANVASWIDGET_H
#define CANVASWIDGET_H
#include "stdafx.h"
#include "bezier.h"
#include "surface.h"
#include "heightmap.h"
#include <QKeyEvent>
#include <QPoint>
#include <QTimer>
#include <QMouseEvent>
#include <GL/glu.h>
//struct PatchBounds {
// QPoint upperLeft;
// QPoint upperRight;
// QPoint bottomLeft;
// QPoint bottomRight;
//};
struct Color {
GLfloat red;
GLfloat green;
GLfloat blue;
Color( GLfloat red, GLfloat green, GLfloat blue) : red(red), green(green), blue(blue) {}
};
class CanvasWidget : public QGLWidget
{
Q_OBJECT
public:
explicit CanvasWidget(QWidget *parent=0);
~CanvasWidget();
protected:
static const int EXPIRATION_TIME = 16;
static const int MAP_SIZE = 256;//64;//1024;//256
static const int PATCH_SIZE = 4;
static const int PATCHES_NUM = (MAP_SIZE - 1) / (PATCH_SIZE - 1);
static const int SURFACE_STRIDE = 1;//1;//8;
string MAP_NAME = "small-plane.bmp";//"heightmap.bmp";//"heightmap.bmp";//"heightmap-small.bmp";//"test64.bmp";//"heightmap.bmp";
vector<Color> colors;
int xMin;
int xMax;
int yMin;
int yMax;
int xCenter;
int yCenter;
int width;
int height;
int depth;
QTimer* timer;
bool useArcBall;
bool modifyHeight;
bool selectPatch;
bool modifyPatchHeight;
QPoint curMousePt;
QPoint lastMousePt;
glm::vec3 lastOGLPt;
glm::vec3 curOGLPt;
float xRotAngle;
float yRotAngle;
float xCurAngle;
float yCurAngle;
float curScale;
Bezier bezierPatch;
Patch patch;
Surface surface = Surface();
Patch surfaceImage;
//vector<PatchBounds> selectedPatches;
vector<QPoint> selectedPatches;
int temp_total;
glm::vec3 getOpenGLCoord(QPoint);
void addSelectedPatch(QPoint);
//void addSelectedPatch(QPoint);
void paintGL();
void initializeGL(void);
void resizeGL( int w, int h);
void keyPressEvent( QKeyEvent *e);
void mousePressEvent(QMouseEvent*);
void mouseMoveEvent(QMouseEvent*);
void mouseReleaseEvent(QMouseEvent*);
void wheelEvent(QWheelEvent*);
signals:
public slots:
void update();
};
#endif // CANVASWIDGET_H