src/linetypes/conditionaledge.cpp

changeset 87
93ec4d630346
parent 86
4bec0525ef1b
child 132
488d0ba6070b
equal deleted inserted replaced
86:4bec0525ef1b 87:93ec4d630346
1 #include "conditionaledge.h" 1 #include "conditionaledge.h"
2
3 ldraw::ConditionalEdge::ConditionalEdge(
4 const glm::vec3& point_1,
5 const glm::vec3& point_2,
6 const glm::vec3& controlPoint_1,
7 const glm::vec3& controlPoint_2,
8 const Color color_index) :
9 Edge{point_1, point_2, color_index},
10 controlPoint_1{controlPoint_1},
11 controlPoint_2{controlPoint_2}
12 {
13 }
14
15 ldraw::ConditionalEdge::ConditionalEdge(const std::array<glm::vec3, 4>& vertices, const Color color) :
16 Edge{vertices[0], vertices[1], color},
17 controlPoint_1{vertices[2]},
18 controlPoint_2{vertices[3]}
19 {
20 }
21
22 QVariant ldraw::ConditionalEdge::getProperty(Property property) const
23 {
24 switch (property)
25 {
26 case Property::ControlPoint0:
27 return QVariant::fromValue(controlPoint_1);
28 case Property::ControlPoint1:
29 return QVariant::fromValue(controlPoint_2);
30 default:
31 return Edge::getProperty(property);
32 }
33 }
34
35 void ldraw::ConditionalEdge::setProperty(SetPropertyResult* result, const PropertyKeyValue& pair)
36 {
37 LDRAW_OBJECT_HANDLE_SET_PROPERTY(ControlPoint0, {this->controlPoint_1 = value;})
38 LDRAW_OBJECT_HANDLE_SET_PROPERTY(ControlPoint1, {this->controlPoint_2 = value;})
39 BaseClass::setProperty(result, pair);
40 }
41 2
42 QString ldraw::ConditionalEdge::textRepresentation() const 3 QString ldraw::ConditionalEdge::textRepresentation() const
43 { 4 {
44 return Edge::textRepresentation() + utility::format("%1 %2", 5 return utility::format("%1 %2 %3 %4",
45 utility::vertexToStringParens(controlPoint_1), 6 utility::vertexToStringParens(this->points[0]),
46 utility::vertexToStringParens(controlPoint_2)); 7 utility::vertexToStringParens(this->points[1]),
8 utility::vertexToStringParens(this->points[2]),
9 utility::vertexToStringParens(this->points[3]));
47 } 10 }
48
49 int ldraw::ConditionalEdge::numPoints() const
50 {
51 return 4;
52 }
53
54 const glm::vec3& ldraw::ConditionalEdge::getPoint(int index) const
55 {
56 switch(index)
57 {
58 case 3:
59 return this->controlPoint_1;
60 case 4:
61 return this->controlPoint_2;
62 default:
63 return ldraw::Edge::getPoint(index);
64 }
65 }

mercurial