1 #include "edge.h" |
1 #include "edge.h" |
2 |
|
3 ldraw::Edge::Edge( |
|
4 const glm::vec3& point_1, |
|
5 const glm::vec3& point_2, |
|
6 const Color color_index) : |
|
7 ColoredObject{color_index}, |
|
8 point_1{point_1}, |
|
9 point_2{point_2} {} |
|
10 |
|
11 ldraw::Edge::Edge(const std::array<glm::vec3, 2>& vertices, const Color color) : |
|
12 ColoredObject{color}, |
|
13 point_1{vertices[0]}, |
|
14 point_2{vertices[1]} |
|
15 { |
|
16 } |
|
17 |
|
18 QVariant ldraw::Edge::getProperty(Property property) const |
|
19 { |
|
20 switch (property) |
|
21 { |
|
22 case Property::Point0: |
|
23 return QVariant::fromValue(point_1); |
|
24 case Property::Point1: |
|
25 return QVariant::fromValue(point_2); |
|
26 default: |
|
27 return BaseClass::getProperty(property); |
|
28 } |
|
29 } |
|
30 |
|
31 void ldraw::Edge::setProperty(SetPropertyResult* result, const PropertyKeyValue& pair) |
|
32 { |
|
33 LDRAW_OBJECT_HANDLE_SET_PROPERTY(Point0, {this->point_1 = value;}) |
|
34 LDRAW_OBJECT_HANDLE_SET_PROPERTY(Point1, {this->point_2 = value;}) |
|
35 BaseClass::setProperty(result, pair); |
|
36 } |
|
37 |
2 |
38 QString ldraw::Edge::textRepresentation() const |
3 QString ldraw::Edge::textRepresentation() const |
39 { |
4 { |
40 return utility::format("%1 %2", utility::vertexToStringParens(point_1), utility::vertexToStringParens(point_2)); |
5 return utility::format( |
|
6 "%1 %2", |
|
7 utility::vertexToStringParens(this->points[0]), |
|
8 utility::vertexToStringParens(this->points[1])); |
41 } |
9 } |
42 |
10 |
43 void ldraw::Edge::getPolygons( |
11 void ldraw::Edge::getPolygons( |
44 std::vector<gl::Polygon>& polygons, |
12 std::vector<gl::Polygon>& polygons, |
45 GetPolygonsContext* context) const |
13 GetPolygonsContext* context) const |
46 { |
14 { |
47 Q_UNUSED(context) |
15 Q_UNUSED(context) |
48 polygons.push_back(gl::edgeLine(this->point_1, this->point_2, this->colorIndex, this->id)); |
16 polygons.push_back(gl::edgeLine(this->points[0], this->points[1], this->colorIndex, this->id)); |
49 } |
17 } |
50 |
|
51 int ldraw::Edge::numPoints() const |
|
52 { |
|
53 return 2; |
|
54 } |
|
55 |
|
56 const glm::vec3& ldraw::Edge::getPoint(int index) const |
|
57 { |
|
58 switch (index) |
|
59 { |
|
60 case 0: |
|
61 return this->point_1; |
|
62 case 1: |
|
63 return this->point_2; |
|
64 default: |
|
65 return ldraw::ColoredObject::getPoint(index); |
|
66 } |
|
67 } |
|