Tue, 07 Jun 2022 21:35:29 +0300
Move editing modes tool bar, tool options widget stack and model list view into the main window
17 | 1 | #pragma once |
2 | #include <QOpenGLWidget> | |
3 | #include "main.h" | |
18 | 4 | #include "gl/common.h" |
21 | 5 | #include "gl/compiler.h" |
200 | 6 | #include "documentmanager.h" |
7 | #include "types/boundingbox.h" | |
17 | 8 | |
189
815fbaae9cb2
cleanup, gl::Compiler changed to gl::ModelShaders
Teemu Piippo <teemu@hecknology.net>
parents:
120
diff
changeset
|
9 | class PartRenderer : public QOpenGLWidget |
17 | 10 | { |
21 | 11 | Q_OBJECT |
17 | 12 | public: |
35
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
34
diff
changeset
|
13 | PartRenderer( |
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
34
diff
changeset
|
14 | Model* model, |
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
34
diff
changeset
|
15 | DocumentManager* documents, |
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
34
diff
changeset
|
16 | const ldraw::ColorTable& colorTable, |
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
34
diff
changeset
|
17 | QWidget* parent = nullptr); |
26 | 18 | ~PartRenderer() override; |
39
caac957e9834
Main color is now configurable
Teemu Piippo <teemu@hecknology.net>
parents:
37
diff
changeset
|
19 | void setRenderPreferences(const gl::RenderPreferences& newPreferences); |
200 | 20 | ModelId getHighlightedObject() const; |
17 | 21 | protected: |
200 | 22 | ModelId pick(QPoint where); |
17 | 23 | void initializeGL() override; |
24 | void resizeGL(int width, int height) override; | |
25 | void paintGL() override; | |
26 | void mouseMoveEvent(QMouseEvent* event) override; | |
31
b6df269a2c6b
fix remaining rendering control issues
Teemu Piippo <teemu@hecknology.net>
parents:
30
diff
changeset
|
27 | void wheelEvent(QWheelEvent* event) override; |
51 | 28 | Model* const model; |
29 | DocumentManager* const documents; | |
30 | const ldraw::ColorTable& colorTable; | |
189
815fbaae9cb2
cleanup, gl::Compiler changed to gl::ModelShaders
Teemu Piippo <teemu@hecknology.net>
parents:
120
diff
changeset
|
31 | BoundingBox boundingBox; |
815fbaae9cb2
cleanup, gl::Compiler changed to gl::ModelShaders
Teemu Piippo <teemu@hecknology.net>
parents:
120
diff
changeset
|
32 | gl::ModelShaders shaders; |
200 | 33 | ModelId highlighted = {0}; |
201
5d201ee4a9c3
Continue giant refactor
Teemu Piippo <teemu@hecknology.net>
parents:
200
diff
changeset
|
34 | std::optional<glm::vec3> screenToModelCoordinates(const QPoint& point, const Plane& plane) const; |
66
77c819262b7a
added a method to find out if the view is perpendicular to grid
Teemu Piippo <teemu@hecknology.net>
parents:
61
diff
changeset
|
35 | QPointF modelToScreenCoordinates(const glm::vec3& point) const; |
201
5d201ee4a9c3
Continue giant refactor
Teemu Piippo <teemu@hecknology.net>
parents:
200
diff
changeset
|
36 | Line<3> cameraLine(const QPoint& point) const; |
66
77c819262b7a
added a method to find out if the view is perpendicular to grid
Teemu Piippo <teemu@hecknology.net>
parents:
61
diff
changeset
|
37 | glm::vec3 unproject(const glm::vec3& win) const; |
61
4585d8d7a7ec
moved GridProgram to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
58
diff
changeset
|
38 | glm::mat4 projectionMatrix; |
4585d8d7a7ec
moved GridProgram to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
58
diff
changeset
|
39 | glm::mat4 viewMatrix; |
4585d8d7a7ec
moved GridProgram to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
58
diff
changeset
|
40 | glm::mat4 modelMatrix; |
4585d8d7a7ec
moved GridProgram to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
58
diff
changeset
|
41 | glm::vec4 viewportVector; |
4585d8d7a7ec
moved GridProgram to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
58
diff
changeset
|
42 | glm::quat modelQuaternion; |
4585d8d7a7ec
moved GridProgram to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
58
diff
changeset
|
43 | QPoint lastMousePosition; |
4585d8d7a7ec
moved GridProgram to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
58
diff
changeset
|
44 | gl::RenderPreferences renderPreferences; |
112 | 45 | Q_SIGNALS: |
70 | 46 | void projectionMatrixChanged(const glm::mat4& newMatrix); |
47 | void modelMatrixChanged(const glm::mat4& newMatrix); | |
48 | void viewMatrixChanged(const glm::mat4& newMatrix); | |
61
4585d8d7a7ec
moved GridProgram to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
58
diff
changeset
|
49 | void renderPreferencesChanged(); |
17 | 50 | private: |
37 | 51 | void setFragmentStyle(gl::FragmentStyle fragStyle); |
22
6da867fa5429
commit work on GL rendering
Teemu Piippo <teemu@hecknology.net>
parents:
21
diff
changeset
|
52 | void renderScene(); |
31
b6df269a2c6b
fix remaining rendering control issues
Teemu Piippo <teemu@hecknology.net>
parents:
30
diff
changeset
|
53 | void updateViewMatrix(); |
55 | 54 | void updateModelMatrix(); |
86
4bec0525ef1b
PolygonObjectEditor can now modify the object properly
Teemu Piippo <teemu@hecknology.net>
parents:
73
diff
changeset
|
55 | Q_SLOT void build(); |
31
b6df269a2c6b
fix remaining rendering control issues
Teemu Piippo <teemu@hecknology.net>
parents:
30
diff
changeset
|
56 | double zoom = 1.0; |
22
6da867fa5429
commit work on GL rendering
Teemu Piippo <teemu@hecknology.net>
parents:
21
diff
changeset
|
57 | bool initialized = false; |
86
4bec0525ef1b
PolygonObjectEditor can now modify the object properly
Teemu Piippo <teemu@hecknology.net>
parents:
73
diff
changeset
|
58 | bool needBuild = true; |
26 | 59 | void renderVao(const gl::ArrayClass arrayClass); |
60 | void checkForGLErrors(); | |
17 | 61 | }; |