Sat, 29 Aug 2015 16:30:56 +0300
Closed old branch
941 | 1 | /* |
2 | * LDForge: LDraw parts authoring CAD | |
3 | * Copyright (C) 2013 - 2015 Teemu Piippo | |
4 | * | |
5 | * This program is free software: you can redistribute it and/or modify | |
6 | * it under the terms of the GNU General Public License as published by | |
7 | * the Free Software Foundation, either version 3 of the License, or | |
8 | * (at your option) any later version. | |
9 | * | |
10 | * This program is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | * GNU General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU General Public License | |
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
17 | */ | |
18 | ||
19 | #pragma once | |
20 | #include <QVector3D> | |
21 | #include <functional> | |
22 | #include "basics.h" | |
23 | ||
24 | class Matrix; | |
25 | ||
26 | enum Axis | |
27 | { | |
28 | X, | |
29 | Y, | |
30 | Z | |
31 | }; | |
32 | ||
33 | // | |
34 | // Derivative of QVector3D: this class is used for the vertices. | |
35 | // | |
36 | class Vertex : public QVector3D | |
37 | { | |
38 | public: | |
39 | using ApplyFunction = std::function<void (Axis, double&)>; | |
40 | using ApplyConstFunction = std::function<void (Axis, double)>; | |
41 | ||
42 | Vertex(); | |
43 | Vertex (const QVector3D& a); | |
44 | Vertex (qreal xpos, qreal ypos, qreal zpos); | |
45 | ||
46 | void apply (ApplyFunction func); | |
47 | void apply (ApplyConstFunction func) const; | |
48 | QString toString (bool mangled = false) const; | |
49 | void transform (const Matrix& matr, const Vertex& pos); | |
50 | void setCoordinate (Axis ax, qreal value); | |
51 | ||
52 | bool operator< (const Vertex& other) const; | |
53 | double operator[] (Axis ax) const; | |
54 | }; | |
55 | ||
56 | extern const Vertex Origin; | |
57 | Q_DECLARE_METATYPE (Vertex) |