src/tools/drawtool.h

Wed, 25 May 2022 13:49:45 +0300

author
Teemu Piippo <teemu@hecknology.net>
date
Wed, 25 May 2022 13:49:45 +0300
changeset 190
3dbdc243f053
parent 185
a38a0eb007b0
permissions
-rw-r--r--

add missing file

96
165777a20dc7 added tool base code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1 #pragma once
165777a20dc7 added tool base code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
2 #include "basetool.h"
165777a20dc7 added tool base code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
3
185
a38a0eb007b0 Added line path tool
Teemu Piippo <teemu@hecknology.net>
parents: 163
diff changeset
4 class AbstractDrawTool : public BaseTool
a38a0eb007b0 Added line path tool
Teemu Piippo <teemu@hecknology.net>
parents: 163
diff changeset
5 {
a38a0eb007b0 Added line path tool
Teemu Piippo <teemu@hecknology.net>
parents: 163
diff changeset
6 public:
a38a0eb007b0 Added line path tool
Teemu Piippo <teemu@hecknology.net>
parents: 163
diff changeset
7 AbstractDrawTool(Document* document);
a38a0eb007b0 Added line path tool
Teemu Piippo <teemu@hecknology.net>
parents: 163
diff changeset
8 void reset() override;
a38a0eb007b0 Added line path tool
Teemu Piippo <teemu@hecknology.net>
parents: 163
diff changeset
9 void overpaint(Canvas*, QPainter*) const override;
a38a0eb007b0 Added line path tool
Teemu Piippo <teemu@hecknology.net>
parents: 163
diff changeset
10 bool mouseMove(Document* document, Canvas* canvas, QMouseEvent* event) override;
a38a0eb007b0 Added line path tool
Teemu Piippo <teemu@hecknology.net>
parents: 163
diff changeset
11 bool mouseClick(Canvas* canvas, QMouseEvent* event) override;
a38a0eb007b0 Added line path tool
Teemu Piippo <teemu@hecknology.net>
parents: 163
diff changeset
12 bool keyReleased(Document*, Canvas* canvas, QKeyEvent* event) override;
a38a0eb007b0 Added line path tool
Teemu Piippo <teemu@hecknology.net>
parents: 163
diff changeset
13 protected:
a38a0eb007b0 Added line path tool
Teemu Piippo <teemu@hecknology.net>
parents: 163
diff changeset
14 void addCurrentPoint(Canvas *canvas);
a38a0eb007b0 Added line path tool
Teemu Piippo <teemu@hecknology.net>
parents: 163
diff changeset
15 virtual void addPoint(const glm::vec3& pos);
a38a0eb007b0 Added line path tool
Teemu Piippo <teemu@hecknology.net>
parents: 163
diff changeset
16 virtual void closeShape() = 0;
a38a0eb007b0 Added line path tool
Teemu Piippo <teemu@hecknology.net>
parents: 163
diff changeset
17 void removeLastPoint();
a38a0eb007b0 Added line path tool
Teemu Piippo <teemu@hecknology.net>
parents: 163
diff changeset
18 void clearPoints();
a38a0eb007b0 Added line path tool
Teemu Piippo <teemu@hecknology.net>
parents: 163
diff changeset
19 bool isCloseToExistingPoints(const glm::vec3& pos) const;
a38a0eb007b0 Added line path tool
Teemu Piippo <teemu@hecknology.net>
parents: 163
diff changeset
20 std::vector<glm::vec3> polygon;
a38a0eb007b0 Added line path tool
Teemu Piippo <teemu@hecknology.net>
parents: 163
diff changeset
21 std::vector<glm::vec3> previewPolygon;
a38a0eb007b0 Added line path tool
Teemu Piippo <teemu@hecknology.net>
parents: 163
diff changeset
22 glm::vec3 previewPoint;
a38a0eb007b0 Added line path tool
Teemu Piippo <teemu@hecknology.net>
parents: 163
diff changeset
23 bool isconcave = false;
a38a0eb007b0 Added line path tool
Teemu Piippo <teemu@hecknology.net>
parents: 163
diff changeset
24 void updatePreviewPolygon();
a38a0eb007b0 Added line path tool
Teemu Piippo <teemu@hecknology.net>
parents: 163
diff changeset
25 };
a38a0eb007b0 Added line path tool
Teemu Piippo <teemu@hecknology.net>
parents: 163
diff changeset
26
a38a0eb007b0 Added line path tool
Teemu Piippo <teemu@hecknology.net>
parents: 163
diff changeset
27 class DrawTool : public AbstractDrawTool
96
165777a20dc7 added tool base code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
28 {
165777a20dc7 added tool base code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
29 Q_OBJECT
165777a20dc7 added tool base code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
30
165777a20dc7 added tool base code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
31 public:
152
03f8e6d42e13 Major refactoring
Teemu Piippo <teemu@hecknology.net>
parents: 143
diff changeset
32 Q_INVOKABLE DrawTool(Document* document);
96
165777a20dc7 added tool base code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
33
105
6ca6e8c647d4 added preview layer code and fixed build warnings
Teemu Piippo <teemu@hecknology.net>
parents: 104
diff changeset
34 QString name() const override;
6ca6e8c647d4 added preview layer code and fixed build warnings
Teemu Piippo <teemu@hecknology.net>
parents: 104
diff changeset
35 QString toolTip() const override;
163
36ea1a8aee33 Add icons for tools
Teemu Piippo <teemu@hecknology.net>
parents: 152
diff changeset
36 QString iconName() const override;
185
a38a0eb007b0 Added line path tool
Teemu Piippo <teemu@hecknology.net>
parents: 163
diff changeset
37 protected:
a38a0eb007b0 Added line path tool
Teemu Piippo <teemu@hecknology.net>
parents: 163
diff changeset
38 virtual void addPoint(const glm::vec3& pos) override;
a38a0eb007b0 Added line path tool
Teemu Piippo <teemu@hecknology.net>
parents: 163
diff changeset
39 void closeShape() override;
96
165777a20dc7 added tool base code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
40 };

mercurial