Wed, 11 Mar 2020 17:19:38 +0200
added a render style for pick scene
#include "quadrilateral.h" ldraw::Quadrilateral::Quadrilateral( const glm::vec3& point_1, const glm::vec3& point_2, const glm::vec3& point_3, const glm::vec3& point_4, Color color_index) : ColoredObject{color_index}, points{point_1, point_2, point_3, point_4} { } ldraw::Quadrilateral::Quadrilateral(const std::array<glm::vec3, 4>& vertices, const Color color) : ColoredObject{color}, points{vertices[0], vertices[1], vertices[2], vertices[3]} { } QVariant ldraw::Quadrilateral::getProperty(const Property id) const { switch (id) { case Property::Point1: return QVariant::fromValue(points[0]); case Property::Point2: return QVariant::fromValue(points[1]); case Property::Point3: return QVariant::fromValue(points[2]); case Property::Point4: return QVariant::fromValue(points[3]); default: return ColoredObject::getProperty(id); } } auto ldraw::Quadrilateral::setProperty( const Property id, const QVariant& value) -> SetPropertyResult { switch (id) { case Property::Point1: points[0] = value.value<glm::vec3>(); return SetPropertyResult::Success; case Property::Point2: points[1] = value.value<glm::vec3>(); return SetPropertyResult::Success; case Property::Point3: points[2] = value.value<glm::vec3>(); return SetPropertyResult::Success; case Property::Point4: points[3] = value.value<glm::vec3>(); return SetPropertyResult::Success; default: return ColoredObject::setProperty(id, value); } } QString ldraw::Quadrilateral::textRepresentation() const { return utility::format("%1 %2 %3 %4", utility::vertexToStringParens(points[0]), utility::vertexToStringParens(points[1]), utility::vertexToStringParens(points[2]), utility::vertexToStringParens(points[3])); } void ldraw::Quadrilateral::getPolygons( std::vector<gl::Polygon>& polygons, GetPolygonsContext* context) const { Q_UNUSED(context) polygons.push_back(gl::quadrilateral( this->points[0], this->points[1], this->points[2], this->points[3], this->colorIndex, this->id)); } void ldraw::Quadrilateral::invert() { // 0 1 2 3 // -> 2 1 0 3 std::swap(this->points[0], this->points[2]); }