src/ui/canvas.h

Fri, 06 Mar 2020 16:08:45 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Fri, 06 Mar 2020 16:08:45 +0200
changeset 68
ddb07bb6840c
parent 67
612213a168da
child 70
f21b800b02a4
permissions
-rw-r--r--

default to XZ

#pragma once
#include "gl/partrenderer.h"
#include "gl/gridprogram.h"

class Canvas : public PartRenderer
{
	Q_OBJECT
public:
	Canvas(
		Model* model,
		DocumentManager* documents,
		const ldraw::ColorTable& colorTable,
		QWidget* parent = nullptr);
public slots:
	void handleSelectionChange(const QSet<ldraw::Id>& selectedIds, const QSet<ldraw::Id>& deselectedIds);
protected:
	void mouseMoveEvent(QMouseEvent* event) override;
	void mousePressEvent(QMouseEvent* event) override;
	void mouseReleaseEvent(QMouseEvent* event) override;
	void initializeGL() override;
	void paintGL() override;
signals:
	void newStatusText(const QString& newStatusText);
	void selectionChanged(const QSet<ldraw::Id>& newSelection);
private:
	void updateGridMatrix();
	glm::vec3 cameraVector() const;
	bool isGridPerpendicularToScreen(float threshold) const;
	std::optional<GridProgram> gridProgram;
	std::optional<glm::vec3> worldPosition;
	glm::mat4 gridMatrix;
	geom::Plane gridPlane;
	int totalMouseMove = 0;
	QSet<ldraw::Id> selection;
};

mercurial