-
Notifications
You must be signed in to change notification settings - Fork 9
/
stlview.h
138 lines (132 loc) · 3.42 KB
/
stlview.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#ifndef STLVIEW_H
#define STLVIEW_H
#include <QGLWidget>
#if defined(Q_WS_MAC)
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#elif defined(Q_WS_WIN)
#include <GL/gl.h>
#include <GL/glu.h>
#endif
#include <QtOpenGL>
#include <QRect>
#include "stlobject.h"
#include "material.h"
#include "slice.h"
class StlView : public QGLWidget
{
Q_OBJECT
public:
StlView(QWidget *parent = 0,const QGLWidget * shareWidget = 0);
QSize minimumSizeHint() const;
QSize sizeHint() const;
QString addObject(QString fileName);
QString addObject(StlObject *object);
void setTableSize(int x, int y);
QStringList getColorsList();
///tool enum
enum tools{
SELECT = 0,
MOVE = 1,
SCALE = 2,
ROTATE = 3,
REMOVE = 4,
CENTER = 5,
COPY = 6,
MIRROR = 7,
REPAIR = 8,
SLICE = 9,
FILL = 10,
BOX_SELECT = 11
};
void setMaterialList(QList<Material*>* list);
inline void setActiveMaterial(int Material) {activeMaterial=Material;}
signals:
void objectPicked(bool);
void selectedRotation(int);
void selectedScale(int);
void selectedCors(QPointF);
void selectedCol(QString);
void nonManifold(QString);
void progress(int value, int max, QString text);
void doneProcessing(bool);
public slots:
void selectObject(QString);
void repairObject();
StlObject* getObject(QString);
void removeObject();
void rotateObject(double);
void changeObjectMaterial();
void sliceObject();
void scaleObject(double);
void moveObject(QPointF);
void mirrorObject(QChar axis);
void duplicateObject();
void viewTop();
void viewFront();
void viewSide();
void centerCamera();
void updateBoxCords();
void clearObjects();
void setActiveTool(int tool);
void mirrorX();
void mirrorY();
void mirrorZ();
inline void setShowLayers(bool value) { showLayers=value; updateGL(); }
void setLayerNum(int value);
protected:
void initializeGL();
void paintGL();
void paintPicking();
void resizeGL(int width, int height);
void mousePressEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *);
void mouseMoveEvent(QMouseEvent *event);
void wheelEvent(QWheelEvent * event);
void keyPressEvent (QKeyEvent * event);
private:
bool showLayers;
int layerNum;
QMenu* mirrorMenu;
QAction* mirrorXAction;
QAction* mirrorYAction;
QAction* mirrorZAction;
int activeTool;
int previousTool;
int activeMaterial;
GLfloat eyeX,eyeY,eyeZ;
GLfloat upX,upY,upZ;
GLfloat theta,phi;
GLfloat r;
int sizeX, sizeY;
double clickedX, clickedY;
bool objectSelected;
//list of selected objets
QStringList selectedObjects;
QColor objectColor;
float xMove;
float yMove;
float zoom;
QPoint lastPos;
QPointF lastPosWorld;
QPointF lastObjectPos;
QColor qtGreen;
QColor qtPurple;
void drawAxis();
void drawGrid();
QHash<QString, StlObject*> objects;
QPointF screenToWorld(int x, int y);
QList<QVector3D> getSelectedObjectsCords();
QList<QVector3D> oryginalCenters;
QList<Material*>* materials;
double originalScale;
QList<double> oryginalScales;
QList<double> getScales();
bool drawBox;
QPointF selectionBoxP1;
QPointF selectionBoxP2;
QTimer* boxUpdater;
void drawSelectionBox();
bool allMirrored();
};
#endif // STLVIEW_H