src/inputvertices.h

Sun, 09 Apr 2023 13:28:36 +0300

author
Teemu Piippo <teemu.s.piippo@gmail.com>
date
Sun, 09 Apr 2023 13:28:36 +0300
changeset 361
c5e8b68e34f8
parent 322
a39f454a3d7f
permissions
-rw-r--r--

Move some recent file handling to MainWindow

322
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff changeset
1 #pragma once
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff changeset
2 #include "src/basics.h"
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff changeset
3
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff changeset
4 class InputVertices
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff changeset
5 {
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff changeset
6 std::vector<glm::vec3> polygon = {origin};
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff changeset
7 std::size_t numpoints = 1;
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff changeset
8 public:
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff changeset
9 bool currentPointOnExistingPoint() const;
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff changeset
10 std::size_t calcNumPoints() const;
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff changeset
11 void updateCurrentPoint(const glm::vec3& p);
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff changeset
12 void removeLastPoint();
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff changeset
13 void finishCurrentPoint();
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff changeset
14 void clear();
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff changeset
15 const glm::vec3& operator[](std::size_t i) const
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff changeset
16 {
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff changeset
17 return this->polygon[i];
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff changeset
18 }
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff changeset
19 std::size_t bufferSize() const
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff changeset
20 {
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff changeset
21 return this->polygon.size();
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff changeset
22 }
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff changeset
23 std::size_t polygonSize() const
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff changeset
24 {
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff changeset
25 return this->numpoints;
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff changeset
26 }
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff changeset
27 auto begin() const
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff changeset
28 {
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff changeset
29 return std::begin(this->polygon);
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff changeset
30 }
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff changeset
31 auto end() const
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff changeset
32 {
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff changeset
33 return std::end(this->polygon);
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff changeset
34 }
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff changeset
35 auto polygonEnd() const
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff changeset
36 {
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff changeset
37 return std::begin(this->polygon) + static_cast<long int>(this->numpoints);
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff changeset
38 }
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
diff changeset
39 };

mercurial