Sun, 19 Jan 2020 13:53:07 +0200
fixed a pile of nonsense that caused subfiles to go haywire
#include "subfilereference.h" #include "documentmanager.h" linetypes::SubfileReference::SubfileReference(const Matrix4x4& transformation, const QString& referenceName, const Color color) : ColoredObject{color}, transformation{transformation}, referenceName{referenceName} { } QVariant linetypes::SubfileReference::getProperty(Property property) const { switch (property) { case Property::Transformation: return QVariant::fromValue(this->transformation); case Property::ReferenceName: return this->referenceName; default: return ColoredObject::getProperty(property); } } auto linetypes::SubfileReference::setProperty( Property property, const QVariant& value) -> SetPropertyResult { switch (property) { case Property::Transformation: this->transformation = value.value<Matrix4x4>(); return SetPropertyResult::Success; case Property::ReferenceName: this->referenceName = value.toString(); return SetPropertyResult::Success; default: return ColoredObject::setProperty(property, value); } } QString linetypes::SubfileReference::textRepresentation() const { return referenceName + " " + vertexToStringParens(this->position()); } void linetypes::SubfileReference::getPolygons( std::vector<gl::Polygon>& polygons, GetPolygonsContext* context) const { Model* model = this->resolve(context->documents); if (model != nullptr) { const std::vector<gl::Polygon> modelPolygons = model->getPolygons(context->documents); polygons.reserve(polygons.size() + modelPolygons.size()); for (gl::Polygon polygon : modelPolygons) { for (unsigned int i = 0; i < polygon.numPolygonVertices(); i += 1) { polygon.vertices[i] = math::transform(polygon.vertices[i], this->transformation); } if (polygon.color == colors::main) { polygon.color = this->colorIndex; } polygon.id = this->id; polygons.push_back(polygon); } } } Point3D linetypes::SubfileReference::position() const { return {this->transformation(0, 3), this->transformation(1, 3), this->transformation(2, 3)}; } Model* linetypes::SubfileReference::resolve(DocumentManager* documents) const { return documents->findModelByName(this->referenceName); }