src/linetypes/subfilereference.cpp

changeset 35
98906a94732f
parent 33
4c41bfe2ec6e
child 81
62373840e33a
equal deleted inserted replaced
34:1de2b8d64e9f 35:98906a94732f
1 #include "subfilereference.h" 1 #include "subfilereference.h"
2 #include "documentmanager.h" 2 #include "documentmanager.h"
3 #include "invert.h" 3 #include "invert.h"
4 4
5 linetypes::SubfileReference::SubfileReference(const glm::mat4& transformation, 5 ldraw::SubfileReference::SubfileReference(const glm::mat4& transformation,
6 const QString& referenceName, 6 const QString& referenceName,
7 const Color color) : 7 const Color color) :
8 ColoredObject{color}, 8 ColoredObject{color},
9 transformation{transformation}, 9 transformation{transformation},
10 referenceName{referenceName} 10 referenceName{referenceName}
11 { 11 {
12 } 12 }
13 13
14 QVariant linetypes::SubfileReference::getProperty(Property property) const 14 QVariant ldraw::SubfileReference::getProperty(Property property) const
15 { 15 {
16 switch (property) 16 switch (property)
17 { 17 {
18 case Property::Transformation: 18 case Property::Transformation:
19 return QVariant::fromValue(this->transformation); 19 return QVariant::fromValue(this->transformation);
22 default: 22 default:
23 return ColoredObject::getProperty(property); 23 return ColoredObject::getProperty(property);
24 } 24 }
25 } 25 }
26 26
27 auto linetypes::SubfileReference::setProperty( 27 auto ldraw::SubfileReference::setProperty(
28 Property property, 28 Property property,
29 const QVariant& value) 29 const QVariant& value)
30 -> SetPropertyResult 30 -> SetPropertyResult
31 { 31 {
32 switch (property) 32 switch (property)
40 default: 40 default:
41 return ColoredObject::setProperty(property, value); 41 return ColoredObject::setProperty(property, value);
42 } 42 }
43 } 43 }
44 44
45 QString linetypes::SubfileReference::textRepresentation() const 45 QString ldraw::SubfileReference::textRepresentation() const
46 { 46 {
47 return referenceName + " " + utility::vertexToStringParens(this->position()); 47 return referenceName + " " + utility::vertexToStringParens(this->position());
48 } 48 }
49 49
50 void linetypes::SubfileReference::getPolygons( 50 void ldraw::SubfileReference::getPolygons(
51 std::vector<gl::Polygon>& polygons, 51 std::vector<gl::Polygon>& polygons,
52 GetPolygonsContext* context) const 52 GetPolygonsContext* context) const
53 { 53 {
54 Model* model = this->resolve(context->documents); 54 Model* model = this->resolve(context->documents);
55 if (model != nullptr) 55 if (model != nullptr)
67 } 67 }
68 if (needInverting != this->isInverted) 68 if (needInverting != this->isInverted)
69 { 69 {
70 gl::invert(polygon); 70 gl::invert(polygon);
71 } 71 }
72 if (polygon.color == colors::main) 72 if (polygon.color == ldraw::mainColor)
73 { 73 {
74 polygon.color = this->colorIndex; 74 polygon.color = this->colorIndex;
75 } 75 }
76 polygon.id = this->id; 76 polygon.id = this->id;
77 polygons.push_back(polygon); 77 polygons.push_back(polygon);
78 } 78 }
79 } 79 }
80 } 80 }
81 81
82 glm::vec3 linetypes::SubfileReference::position() const 82 glm::vec3 ldraw::SubfileReference::position() const
83 { 83 {
84 return {this->transformation[3][0], this->transformation[3][1], this->transformation[3][2]}; 84 return {this->transformation[3][0], this->transformation[3][1], this->transformation[3][2]};
85 } 85 }
86 86
87 void linetypes::SubfileReference::invert() 87 void ldraw::SubfileReference::invert()
88 { 88 {
89 this->isInverted = not this->isInverted; 89 this->isInverted = not this->isInverted;
90 } 90 }
91 91
92 Model* linetypes::SubfileReference::resolve(DocumentManager* documents) const 92 Model* ldraw::SubfileReference::resolve(DocumentManager* documents) const
93 { 93 {
94 return documents->findModelByName(this->referenceName); 94 return documents->findModelByName(this->referenceName);
95 } 95 }

mercurial