src/gl/partrenderer.h

changeset 217
6d95c1a41e6e
parent 215
34c6e7bc4ee1
child 232
8efa3a33172e
--- a/src/gl/partrenderer.h	Mon Jun 13 02:18:25 2022 +0300
+++ b/src/gl/partrenderer.h	Tue Jun 14 17:55:50 2022 +0300
@@ -6,9 +6,28 @@
 #include "documentmanager.h"
 #include "types/boundingbox.h"
 
-class PartRenderer : public QOpenGLWidget
+class PartRenderer final : public QOpenGLWidget
 {
 	Q_OBJECT
+	Model* const model;
+	DocumentManager* const documents;
+	const ColorTable& colorTable;
+	BoundingBox boundingBox;
+	gl::ModelShaders shaders;
+	ModelId highlighted = {0};
+	glm::mat4 projectionMatrix;
+	glm::mat4 viewMatrix;
+	glm::mat4 modelMatrix;
+	glm::vec4 viewportVector;
+	glm::quat modelQuaternion;
+	QPoint lastMousePosition;
+	int totalMouseMove = 0;
+	gl::RenderPreferences renderPreferences;
+	double zoom = 1.0;
+	bool initialized = false;
+	bool needBuild = true;
+	std::vector<RenderLayer*> activeRenderLayers;
+	std::vector<RenderLayer*> inactiveRenderLayers;
 public:
 	PartRenderer(
 		Model* model,
@@ -20,46 +39,31 @@
 	ModelId getHighlightedObject() const;
 	void addRenderLayer(RenderLayer* layer);
 	void setLayerEnabled(RenderLayer* layer, bool enabled);
-protected:
+	std::optional<glm::vec3> screenToModelCoordinates(const QPointF& point, const Plane& plane) const;
+	QPointF modelToScreenCoordinates(const glm::vec3& point) const;
+	bool isDark() const;
 	ModelId pick(QPoint where);
-	void initializeGL() override;
-	void resizeGL(int width, int height) override;
-	void paintGL() override;
-	void mouseMoveEvent(QMouseEvent* event) override;
-	void wheelEvent(QWheelEvent* event) override;
-	Model* const model;
-	DocumentManager* const documents;
-	const ColorTable& colorTable;
-	BoundingBox boundingBox;
-	gl::ModelShaders shaders;
-	ModelId highlighted = {0};
-	std::optional<glm::vec3> screenToModelCoordinates(const QPointF &point, const Plane& plane) const;
-	QPointF modelToScreenCoordinates(const glm::vec3& point) const;
-	Line<3> cameraLine(const QPointF& point) const;
-	glm::vec3 unproject(const glm::vec3& win) const;
-	glm::mat4 projectionMatrix;
-	glm::mat4 viewMatrix;
-	glm::mat4 modelMatrix;
-	glm::vec4 viewportVector;
-	glm::quat modelQuaternion;
-	QPoint lastMousePosition;
-	gl::RenderPreferences renderPreferences;
+	void setSelection(const QSet<ModelId>& selectedIds);
 Q_SIGNALS:
 	void projectionMatrixChanged(const glm::mat4& newMatrix);
 	void modelMatrixChanged(const glm::mat4& newMatrix);
 	void viewMatrixChanged(const glm::mat4& newMatrix);
 	void renderPreferencesChanged();
 private:
+	void initializeGL() override;
+	void resizeGL(int width, int height) override;
+	void paintGL() override;
+	void mouseMoveEvent(QMouseEvent* event) override;
+	void mousePressEvent(QMouseEvent* event) override;
+	void mouseReleaseEvent(QMouseEvent* event) override;
+	void wheelEvent(QWheelEvent* event) override;
+	Line<3> cameraLine(const QPointF& point) const;
+	glm::vec3 unproject(const glm::vec3& win) const;
 	void setFragmentStyle(gl::FragmentStyle fragStyle);
 	void renderScene();
 	void updateViewMatrix();
 	void updateModelMatrix();
 	Q_SLOT void build();
-	double zoom = 1.0;
-	bool initialized = false;
-	bool needBuild = true;
 	void renderVao(const gl::ArrayClass arrayClass);
 	void checkForGLErrors();
-	std::vector<RenderLayer*> activeRenderLayers;
-	std::vector<RenderLayer*> inactiveRenderLayers;
 };

mercurial