src/linetypes/triangle.cpp

changeset 200
ca23936b455b
parent 199
6988973515d2
child 201
5d201ee4a9c3
equal deleted inserted replaced
199:6988973515d2 200:ca23936b455b
1 #include "triangle.h"
2
3 QString ldraw::Triangle::textRepresentation() const
4 {
5 return utility::format("%1 %2 %3",
6 utility::vertexToStringParens(points[0]),
7 utility::vertexToStringParens(points[1]),
8 utility::vertexToStringParens(points[2]));
9 }
10
11 void ldraw::Triangle::getPolygons(
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,
21 this->id));
22 }
23
24 void ldraw::Triangle::invert(GetPolygonsContext *)
25 {
26 // 0 1 2
27 // -> 1 0 2
28 std::swap(this->points[0], this->points[1]);
29 }
30
31 ldraw::Object::Type ldraw::Triangle::typeIdentifier() const
32 {
33 return Type::Triangle;
34 }
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]),
43 utility::vertexToString(this->points[2]));
44 }
45
46 QString ldraw::Triangle::iconName() const
47 {
48 return ":/icons/linetype-triangle.png";
49 }
50
51 QString ldraw::Triangle::typeName() const
52 {
53 return QObject::tr("triangle");
54 }

mercurial