7 ( |
7 ( |
8 const glm::mat4& transformation, |
8 const glm::mat4& transformation, |
9 const QString& referenceName, |
9 const QString& referenceName, |
10 const Color color |
10 const Color color |
11 ) : |
11 ) : |
12 ColoredObject{color}, |
12 CompoundObject{transformation, color}, |
13 transformation{transformation}, |
|
14 referenceName{referenceName} |
13 referenceName{referenceName} |
15 { |
14 { |
16 } |
15 } |
17 |
16 |
18 QVariant ldraw::SubfileReference::getProperty(Property property) const |
17 QVariant ldraw::SubfileReference::getProperty(Property property) const |
19 { |
18 { |
20 switch (property) |
19 switch (property) |
21 { |
20 { |
22 case Property::Transformation: |
|
23 return QVariant::fromValue(this->transformation); |
|
24 case Property::ReferenceName: |
21 case Property::ReferenceName: |
25 return this->referenceName; |
22 return this->referenceName; |
26 default: |
23 default: |
27 return ColoredObject::getProperty(property); |
24 return CompoundObject::getProperty(property); |
28 } |
25 } |
29 } |
26 } |
30 |
27 |
31 void ldraw::SubfileReference::setProperty(SetPropertyResult* result, const PropertyKeyValue& pair) |
28 void ldraw::SubfileReference::setProperty(SetPropertyResult* result, const PropertyKeyValue& pair) |
32 { |
29 { |
33 LDRAW_OBJECT_HANDLE_SET_PROPERTY(Transformation, {this->transformation = value;}); |
|
34 LDRAW_OBJECT_HANDLE_SET_PROPERTY(ReferenceName, {this->referenceName = value;}); |
30 LDRAW_OBJECT_HANDLE_SET_PROPERTY(ReferenceName, {this->referenceName = value;}); |
35 ldraw::ColoredObject::setProperty(result, pair); |
31 ldraw::CompoundObject::setProperty(result, pair); |
36 } |
32 } |
37 |
33 |
38 QString ldraw::SubfileReference::textRepresentation() const |
34 QString ldraw::SubfileReference::textRepresentation() const |
39 { |
35 { |
40 return this->referenceName + " " + utility::vertexToStringParens(this->position()); |
36 return this->referenceName + " " + utility::vertexToStringParens(this->position()); |
81 polygons.push_back(polygon); |
77 polygons.push_back(polygon); |
82 } |
78 } |
83 } |
79 } |
84 } |
80 } |
85 |
81 |
86 glm::vec3 ldraw::SubfileReference::position() const |
|
87 { |
|
88 return this->transformation[3]; |
|
89 } |
|
90 |
|
91 void ldraw::SubfileReference::invert() |
|
92 { |
|
93 this->isInverted = not this->isInverted; |
|
94 } |
|
95 |
|
96 Model* ldraw::SubfileReference::resolve(const ModelId callingModelId, DocumentManager* documents) const |
82 Model* ldraw::SubfileReference::resolve(const ModelId callingModelId, DocumentManager* documents) const |
97 { |
83 { |
98 return documents->findDependencyByName(callingModelId, this->referenceName); |
84 return documents->findDependencyByName(callingModelId, this->referenceName); |
99 } |
85 } |
100 |
86 |
103 return Type::SubfileReference; |
89 return Type::SubfileReference; |
104 } |
90 } |
105 |
91 |
106 QDataStream& ldraw::SubfileReference::serialize(QDataStream &stream) const |
92 QDataStream& ldraw::SubfileReference::serialize(QDataStream &stream) const |
107 { |
93 { |
108 return ColoredObject::serialize(stream) << this->transformation << this->referenceName << this->isInverted; |
94 return CompoundObject::serialize(stream) << this->referenceName; |
109 } |
95 } |
110 |
96 |
111 QDataStream& ldraw::SubfileReference::deserialize(QDataStream &stream) |
97 QDataStream& ldraw::SubfileReference::deserialize(QDataStream &stream) |
112 { |
98 { |
113 return ColoredObject::deserialize(stream) >> this->transformation >> this->referenceName >> this->isInverted; |
99 return CompoundObject::deserialize(stream) >> this->referenceName; |
114 } |
100 } |
115 |
101 |
116 QString ldraw::SubfileReference::toLDrawCode() const |
102 QString ldraw::SubfileReference::toLDrawCode() const |
117 { |
103 { |
118 QString result; |
104 QString result; |