Thu, 03 Oct 2019 23:44:28 +0300
language support
3 | 1 | /* |
2 | * LDForge: LDraw parts authoring CAD | |
3 | * Copyright (C) 2013 - 2019 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 <functional> | |
21 | #include <QVector3D> | |
22 | #include "basics.h" | |
23 | ||
24 | struct Vertex | |
25 | { | |
5 | 26 | using ValueType = float; |
27 | ValueType x; | |
28 | ValueType y; | |
29 | ValueType z; | |
3 | 30 | // void transform(const class Matrix& matrix, const Vertex& pos); |
31 | Vertex transformed(const GLRotationMatrix& matrix) const; | |
5 | 32 | void setCoordinate(Axis ax, ValueType value); |
3 | 33 | Vertex& operator+=(const QVector3D& other); |
34 | Vertex operator+(const QVector3D& other) const; | |
35 | QVector3D operator-(const Vertex& other) const; | |
36 | Vertex operator-(const QVector3D& vector) const; | |
37 | Vertex& operator-=(const QVector3D& vector); | |
5 | 38 | Vertex& operator*=(ValueType scalar); |
39 | Vertex operator*(ValueType scalar) const; | |
3 | 40 | bool operator<(const Vertex& other) const; |
5 | 41 | ValueType& operator[](Axis ax); |
42 | ValueType operator[](Axis ax) const; | |
3 | 43 | bool operator==(const Vertex& other) const; |
44 | bool operator!=(const Vertex& other) const; | |
45 | operator QVariant() const; | |
46 | }; | |
47 | ||
48 | inline Vertex operator*(qreal scalar, const Vertex& vertex) | |
49 | { | |
50 | return vertex * scalar; | |
51 | } | |
52 | ||
53 | Q_DECLARE_METATYPE(Vertex) | |
54 | qreal distance(const Vertex& one, const Vertex& other); | |
55 | Vertex vertexFromVector(const QVector3D& vector); | |
56 | QVector3D vertexToVector(const Vertex &vertex); | |
6 | 57 | QString vertexToStringParens(const Vertex& vertex); |
3 | 58 | unsigned int qHash(const Vertex& key); |
59 | Vertex operator-(const Vertex& vertex); | |
60 | QDataStream& operator<<(QDataStream& out, const Vertex& vertex); | |
61 | QDataStream& operator>>(QDataStream& in, Vertex& vertex); |