Thu, 13 Feb 2020 12:51:27 +0200
added grid program
24 | 1 | /* |
2 | * LDForge: LDraw parts authoring CAD | |
3 | * Copyright (C) 2013 - 2020 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 | ||
0 | 19 | #pragma once |
2 | 20 | #include <QString> |
21 | #include <QVector> | |
22 | #include <QSet> | |
7
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
3
diff
changeset
|
23 | #include <memory> |
3 | 24 | #include "basics.h" |
8
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
7
diff
changeset
|
25 | #include "utility.h" |
20 | 26 | #include "maths.h" |
2 | 27 | |
7
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
3
diff
changeset
|
28 | namespace settingGroups |
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
3
diff
changeset
|
29 | { |
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
3
diff
changeset
|
30 | // List of setting groups |
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
3
diff
changeset
|
31 | constexpr char mainwindow[] = "mainwindow"; |
68443f5be176
added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
3
diff
changeset
|
32 | } |
21 | 33 | |
35
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
34 | namespace ldraw |
21 | 35 | { |
36 | // Uniquely identifies a model body object | |
37 | struct Id | |
38 | { | |
46 | 39 | std::int32_t value; |
35
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
40 | constexpr bool operator<(ldraw::Id other) const |
26 | 41 | { |
42 | return this->value < other.value; | |
43 | } | |
51 | 44 | friend constexpr unsigned int qHash(ldraw::Id id) |
45 | { | |
46 | return qHash(id.value); | |
47 | } | |
48 | friend bool operator==(ldraw::Id one, ldraw::Id other) | |
49 | { | |
50 | return one.value == other.value; | |
51 | } | |
21 | 52 | }; |
46 | 53 | using id_t = Id; |
54 | constexpr id_t NULL_ID = id_t{0}; | |
21 | 55 | } |
22
6da867fa5429
commit work on GL rendering
Teemu Piippo <teemu@hecknology.net>
parents:
21
diff
changeset
|
56 | |
6da867fa5429
commit work on GL rendering
Teemu Piippo <teemu@hecknology.net>
parents:
21
diff
changeset
|
57 | constexpr std::size_t operator""_z(const unsigned long long int x) |
6da867fa5429
commit work on GL rendering
Teemu Piippo <teemu@hecknology.net>
parents:
21
diff
changeset
|
58 | { |
6da867fa5429
commit work on GL rendering
Teemu Piippo <teemu@hecknology.net>
parents:
21
diff
changeset
|
59 | return static_cast<std::size_t>(x); |
6da867fa5429
commit work on GL rendering
Teemu Piippo <teemu@hecknology.net>
parents:
21
diff
changeset
|
60 | } |
26 | 61 | |
62 | inline QString operator""_q(const char* string, const unsigned long int length) | |
63 | { | |
64 | Q_UNUSED(length) | |
65 | return QString{string}; | |
66 | } | |
67 | ||
68 | inline QPointF pointToPointF(const QPoint& point) | |
69 | { | |
70 | return {static_cast<qreal>(point.x()), static_cast<qreal>(point.y())}; | |
71 | } | |
72 | ||
73 | inline QPoint pointFToPoint(const QPointF& point) | |
74 | { | |
75 | return {static_cast<int>(std::round(point.x())), static_cast<int>(std::round(point.y()))}; | |
76 | } | |
77 | ||
78 | /** | |
79 | * \brief Hints to the specified vector that a certain amount of new elements are going to be added. | |
80 | * \param vector vector to consider | |
81 | * \param amount amount of new elements to expect | |
82 | */ | |
83 | template<typename T> | |
84 | void reserveMore(std::vector<T>& vector, std::size_t amount) | |
85 | { | |
86 | vector.reserve(vector.size() + amount); | |
87 | } |