src/linetypes/subfilereference.cpp

changeset 86
4bec0525ef1b
parent 81
62373840e33a
child 132
488d0ba6070b
equal deleted inserted replaced
85:40e2940605a3 86:4bec0525ef1b
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 ldraw::SubfileReference::SubfileReference(const glm::mat4& transformation, 5 ldraw::SubfileReference::SubfileReference
6 (
7 const glm::mat4& transformation,
6 const QString& referenceName, 8 const QString& referenceName,
7 const Color color) : 9 const Color color
10 ) :
8 ColoredObject{color}, 11 ColoredObject{color},
9 transformation{transformation}, 12 transformation{transformation},
10 referenceName{referenceName} 13 referenceName{referenceName}
11 { 14 {
12 } 15 }
22 default: 25 default:
23 return ColoredObject::getProperty(property); 26 return ColoredObject::getProperty(property);
24 } 27 }
25 } 28 }
26 29
27 auto ldraw::SubfileReference::setProperty( 30 void ldraw::SubfileReference::setProperty(SetPropertyResult* result, const PropertyKeyValue& pair)
28 Property property,
29 const QVariant& value)
30 -> SetPropertyResult
31 { 31 {
32 switch (property) 32 LDRAW_OBJECT_HANDLE_SET_PROPERTY(Transformation, {this->transformation = value;});
33 { 33 LDRAW_OBJECT_HANDLE_SET_PROPERTY(ReferenceName, {this->referenceName = value;});
34 case Property::Transformation: 34 ldraw::ColoredObject::setProperty(result, pair);
35 this->transformation = value.value<glm::mat4>();
36 return SetPropertyResult::Success;
37 case Property::ReferenceName:
38 this->referenceName = value.toString();
39 return SetPropertyResult::Success;
40 default:
41 return ColoredObject::setProperty(property, value);
42 }
43 } 35 }
44 36
45 QString ldraw::SubfileReference::textRepresentation() const 37 QString ldraw::SubfileReference::textRepresentation() const
46 { 38 {
47 return referenceName + " " + utility::vertexToStringParens(this->position()); 39 return referenceName + " " + utility::vertexToStringParens(this->position());
48 } 40 }
49 41
50 void ldraw::SubfileReference::getPolygons( 42 void ldraw::SubfileReference::getPolygons
43 (
51 std::vector<gl::Polygon>& polygons, 44 std::vector<gl::Polygon>& polygons,
52 GetPolygonsContext* context) const 45 GetPolygonsContext* context
46 ) const
53 { 47 {
54 Model* model = this->resolve(context->documents); 48 Model* model = this->resolve(context->documents);
55 if (model != nullptr) 49 if (model != nullptr)
56 { 50 {
57 const bool needInverting = glm::determinant(this->transformation) < 0; 51 const bool needInverting = glm::determinant(this->transformation) < 0;

mercurial