src/linetypes/quadrilateral.cpp

changeset 200
ca23936b455b
parent 199
6988973515d2
child 201
5d201ee4a9c3
equal deleted inserted replaced
199:6988973515d2 200:ca23936b455b
1 #include "quadrilateral.h"
2
3 QString ldraw::Quadrilateral::textRepresentation() const
4 {
5 return utility::format("%1 %2 %3 %4",
6 utility::vertexToStringParens(this->points[0]),
7 utility::vertexToStringParens(this->points[1]),
8 utility::vertexToStringParens(this->points[2]),
9 utility::vertexToStringParens(this->points[3]));
10 }
11
12 void ldraw::Quadrilateral::getPolygons(
13 std::vector<gl::Polygon>& polygons,
14 GetPolygonsContext* context) const
15 {
16 Q_UNUSED(context)
17 polygons.push_back(gl::quadrilateral(
18 this->points[0],
19 this->points[1],
20 this->points[2],
21 this->points[3],
22 this->colorIndex,
23 this->id));
24 }
25
26 void ldraw::Quadrilateral::invert(GetPolygonsContext *)
27 {
28 // 0 1 2 3
29 // -> 2 1 0 3
30 std::swap(this->points[0], this->points[2]);
31 }
32
33 ldraw::Object::Type ldraw::Quadrilateral::typeIdentifier() const
34 {
35 return Type::Quadrilateral;
36 }
37
38 QString ldraw::Quadrilateral::toLDrawCode() const
39 {
40 return utility::format(
41 "4 %1 %2 %3 %4 %5",
42 this->colorIndex.index,
43 utility::vertexToString(this->points[0]),
44 utility::vertexToString(this->points[1]),
45 utility::vertexToString(this->points[2]),
46 utility::vertexToString(this->points[3]));
47 }
48
49 QString ldraw::Quadrilateral::iconName() const
50 {
51 return ":/icons/linetype-quadrilateral.png";
52 }
53
54 QString ldraw::Quadrilateral::typeName() const
55 {
56 return QObject::tr("quadrilateral");
57 }

mercurial