src/tools/drawtool.h

Mon, 16 May 2022 01:40:49 +0300

author
Teemu Piippo <teemu@hecknology.net>
date
Mon, 16 May 2022 01:40:49 +0300
changeset 187
30204975694a
parent 185
a38a0eb007b0
permissions
-rw-r--r--

work on circle tool

#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