src/ui/canvas.h

Sat, 29 Feb 2020 23:51:03 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Sat, 29 Feb 2020 23:51:03 +0200
changeset 65
87c906545fc3
parent 64
f99d52b1646b
child 66
77c819262b7a
permissions
-rw-r--r--

document the grid snapping transformations

#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();
	std::optional<GridProgram> gridProgram;
	std::optional<glm::vec3> worldPosition;
	glm::mat4 gridMatrix;
	geom::Plane gridPlane;
	int totalMouseMove = 0;
	QSet<ldraw::Id> selection;
};

mercurial