src/tools/drawtool.h

Tue, 24 May 2022 16:11:10 +0300

author
Teemu Piippo <teemu@hecknology.net>
date
Tue, 24 May 2022 16:11:10 +0300
changeset 188
64ea7282611e
parent 185
a38a0eb007b0
permissions
-rw-r--r--

more work on circle tool + cleanup

#pragma once
#include "basetool.h"

class AbstractDrawTool : public BaseTool
{
public:
	AbstractDrawTool(Document* document);
	void reset() override;
	void overpaint(Canvas*, QPainter*) const override;
	bool mouseMove(Document* document, Canvas* canvas, QMouseEvent* event) override;
	bool mouseClick(Canvas* canvas, QMouseEvent* event) override;
	bool keyReleased(Document*, Canvas* canvas, QKeyEvent* event) override;
protected:
	void addCurrentPoint(Canvas *canvas);
	virtual void addPoint(const glm::vec3& pos);
	virtual void closeShape() = 0;
	void removeLastPoint();
	void clearPoints();
	bool isCloseToExistingPoints(const glm::vec3& pos) const;
	std::vector<glm::vec3> polygon;
	std::vector<glm::vec3> previewPolygon;
	glm::vec3 previewPoint;
	bool isconcave = false;
	void updatePreviewPolygon();
};

class DrawTool : public AbstractDrawTool
{
	Q_OBJECT

public:
	Q_INVOKABLE DrawTool(Document* document);

	QString name() const override;
	QString toolTip() const override;
	QString iconName() const override;
protected:
	virtual void addPoint(const glm::vec3& pos) override;
	void closeShape() override;
};

mercurial