-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathopenglwidget.h
117 lines (105 loc) · 2.85 KB
/
openglwidget.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/**
* PGR 2013 project
* OpenGL widget class header
*
* @author xskota05 Klara Vankova
* xsimet00 Vojtech Simetka
* @date 2013/11/26
* @version 1
* @file openglwidget.h
*/
#ifndef OPENGLWIDGET_H
#define OPENGLWIDGET_H
#include <QGLWidget>
#include <QtOpenGL>
#include "data.h"
#include "metaelement.h"
#include "guideline.h"
#include "selection.h"
#include "gui.h"
#include "font.h"
const int MINDISTANCE = 8;
const int INF = 10000;
// Necesarry declarations for linker
class Data;
class Line;
class GuideLine;
class Gui;
class Selection;
// Drawer state enumerator
typedef enum
{
DRAW,
SELECT_E,
ROTATE,
CHANGESIZE,
PAN
} Status;
// Catch status enumerator
typedef enum
{
CLASSIC,
PARALLEL,
PERPENDICULAR,
MIDDLE,
FIXEDLENGTH
} CatchStatus;
class OpenGLWidget : public QGLWidget
{
public:
OpenGLWidget(Gui *gui, QWidget *parent = NULL);
~OpenGLWidget();
void initializeGL();
void paintGL();
void setAction(Status s);
void setAction(ElementType::Type t);
void deleteSelection();
Element *topObjectAtMousePosition();
static float treshold_value;
private:
Data *data;
Status status;
ElementType::Type type;
CatchStatus catchStatus;
MetaElement metaElement;
GuideLine *vertical_guideline;
GuideLine *horizontal_guideline;
Selection *selection;
Point offset;
Point aux_offset;
Point mouse_start_position;
Point mouse_end_position;
// Point mouse_position;
float scale;
Gui *gui;
Font *font;
bool isHorizontal(float y1, float y2);
bool isVertical(float x1, float x2);
bool catchToParallelLine(float x11, float y11, float *x21, float *y21);
bool catchToPerpendicular(float x11, float y11, float *x21, float *y21);
bool catchToDiagonal(float *x1, float *y1, float x2, float y2);
void catchToClosePoint(float *x, float *y);
void catchToMiddleOfLine(float x11, float y11, float *x, float *y);
void changeLengthNotMoveMouse(float len, float x1, float y1, float *x2, float *y2);
void changeLength(float length);
void mouseReleaseDraw(float x, float y);
void createNewElement(float x, float y);
QString qKeyEventToQString(QKeyEvent *keyEvent);
void mouseReleaseSelect();
void mousePressSelect();
void mouseMoveDraw(float *x, float *y);
float translateX(float) const;
float translateY(float) const;
void paintRuler();
void drawRectangle(float, float, float, float) const;
void drawLine(float, float, float, float) const;
void drawString(std::string, float, float) const;
protected:
void resizeGL(int w, int h);
void mouseReleaseEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void mousePressEvent(QMouseEvent *event);
void keyPressEvent(QKeyEvent *keyEvent);
void wheelEvent(QWheelEvent* event);
};
#endif // OPENGLWIDGET_H