Sun, 13 Mar 2022 14:51:39 +0200
fix saving
add color editing to object editor
15
9e18ec63eec3
split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
14
diff
changeset
|
1 | #include "triangle.h" |
3 | 2 | |
35
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
33
diff
changeset
|
3 | QString ldraw::Triangle::textRepresentation() const |
6 | 4 | { |
8
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
6
diff
changeset
|
5 | return utility::format("%1 %2 %3", |
33
4c41bfe2ec6e
replaced matrix and vertex classes with glm
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
6 | utility::vertexToStringParens(points[0]), |
4c41bfe2ec6e
replaced matrix and vertex classes with glm
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
7 | utility::vertexToStringParens(points[1]), |
4c41bfe2ec6e
replaced matrix and vertex classes with glm
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
8 | utility::vertexToStringParens(points[2])); |
6 | 9 | } |
21 | 10 | |
35
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
33
diff
changeset
|
11 | void ldraw::Triangle::getPolygons( |
21 | 12 | std::vector<gl::Polygon>& polygons, |
13 | GetPolygonsContext* context) const | |
14 | { | |
15 | Q_UNUSED(context) | |
16 | polygons.push_back(gl::triangle( | |
17 | this->points[0], | |
18 | this->points[1], | |
19 | this->points[2], | |
20 | this->colorIndex, | |
87
93ec4d630346
added PolygonObject and refactored away a lot of boilerplate
Teemu Piippo <teemu@hecknology.net>
parents:
86
diff
changeset
|
21 | this->id)); |
21 | 22 | } |
26 | 23 | |
35
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
33
diff
changeset
|
24 | void ldraw::Triangle::invert() |
26 | 25 | { |
26 | // 0 1 2 | |
27 | // -> 1 0 2 | |
28 | std::swap(this->points[0], this->points[1]); | |
29 | } | |
132
488d0ba6070b
Begin work with serialization
Teemu Piippo <teemu@hecknology.net>
parents:
87
diff
changeset
|
30 | |
488d0ba6070b
Begin work with serialization
Teemu Piippo <teemu@hecknology.net>
parents:
87
diff
changeset
|
31 | ldraw::Object::Type ldraw::Triangle::typeIdentifier() const |
488d0ba6070b
Begin work with serialization
Teemu Piippo <teemu@hecknology.net>
parents:
87
diff
changeset
|
32 | { |
488d0ba6070b
Begin work with serialization
Teemu Piippo <teemu@hecknology.net>
parents:
87
diff
changeset
|
33 | return Type::Triangle; |
488d0ba6070b
Begin work with serialization
Teemu Piippo <teemu@hecknology.net>
parents:
87
diff
changeset
|
34 | } |
141 | 35 | |
36 | QString ldraw::Triangle::toLDrawCode() const | |
37 | { | |
38 | return utility::format( | |
39 | "3 %1 %2 %3 %4", | |
40 | this->colorIndex.index, | |
41 | utility::vertexToString(this->points[0]), | |
42 | utility::vertexToString(this->points[1]), | |
158
5bd755eaa5a8
Add icons from ionicons
Teemu Piippo <teemu@hecknology.net>
parents:
141
diff
changeset
|
43 | utility::vertexToString(this->points[2])); |
141 | 44 | } |
158
5bd755eaa5a8
Add icons from ionicons
Teemu Piippo <teemu@hecknology.net>
parents:
141
diff
changeset
|
45 | |
5bd755eaa5a8
Add icons from ionicons
Teemu Piippo <teemu@hecknology.net>
parents:
141
diff
changeset
|
46 | QString ldraw::Triangle::iconName() const |
5bd755eaa5a8
Add icons from ionicons
Teemu Piippo <teemu@hecknology.net>
parents:
141
diff
changeset
|
47 | { |
5bd755eaa5a8
Add icons from ionicons
Teemu Piippo <teemu@hecknology.net>
parents:
141
diff
changeset
|
48 | return ":/icons/linetype-triangle.png"; |
5bd755eaa5a8
Add icons from ionicons
Teemu Piippo <teemu@hecknology.net>
parents:
141
diff
changeset
|
49 | } |
177
f69d53c053df
Show type of object in the object editor
Teemu Piippo <teemu@hecknology.net>
parents:
158
diff
changeset
|
50 | |
f69d53c053df
Show type of object in the object editor
Teemu Piippo <teemu@hecknology.net>
parents:
158
diff
changeset
|
51 | QString ldraw::Triangle::typeName() const |
f69d53c053df
Show type of object in the object editor
Teemu Piippo <teemu@hecknology.net>
parents:
158
diff
changeset
|
52 | { |
f69d53c053df
Show type of object in the object editor
Teemu Piippo <teemu@hecknology.net>
parents:
158
diff
changeset
|
53 | return QObject::tr("triangle"); |
f69d53c053df
Show type of object in the object editor
Teemu Piippo <teemu@hecknology.net>
parents:
158
diff
changeset
|
54 | } |