-
Notifications
You must be signed in to change notification settings - Fork 0
/
basiswidget.h
executable file
·70 lines (54 loc) · 1.7 KB
/
basiswidget.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
#ifndef BASISWIDGET_H
#define BASISWIDGET_H
#include <QGLWidget>
#include <QMouseEvent>
#include <QUndoStack>
#include <vector>
#include "bspline.h"
#include "utils/vector.h"
using namespace std;
class BasisWidget : public QGLWidget {
Q_OBJECT
public:
BasisWidget(QWidget *parent = 0, QUndoStack *undoStack = 0, BSpline *spline = 0);
~BasisWidget();
protected:
/*OpenGL events*/
void initializeGL();
void resizeGL(int width, int height);
void paintGL();
/*mouse events*/
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *);
public slots:
//resets basis functions to original state
void reset();
//toggles if segments are distinctively colored
void toggleShowSegments();
protected:
//converts screen coordinates to world coordinates
void convertCoordinates(float xIn, float yIn, float &xOut, float &yOut);
//returns the coordinates of a knot's control triangle
void getControlTriangle(uint i, Vector2f &v1, Vector2f &v2, Vector2f &v3);
protected slots:
//updates the dimensions of the projection matrix to fit basis functions
void updateProjection();
protected:
QUndoStack *m_undoStack;
int m_commandId; //id used so consecutive move commands are merged
//spline whose basis functions will be drawn
BSpline *m_spline;
bool m_splineCreated;
//knot selection and movement
bool m_isKnotSelected;
uint m_selectedIndex;
uint m_lastKnotSize;
//dimensions of the world space after projection
float m_leftProj;
float m_rightProj;
float m_bottomProj;
float m_topProj;
bool m_showSegments;
};
#endif // BASISWIDGET_H