diff -r 6988973515d2 -r ca23936b455b src/linetypes/polygonobject.h --- a/src/linetypes/polygonobject.h Wed May 25 20:36:34 2022 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,88 +0,0 @@ -#pragma once -#include "object.h" -#include "widgets/vec3editor.h" -#include "model.h" -#include "modeleditor.h" - -namespace ldraw -{ - template - class PolygonObject; -} - -template 0 and N <= 4)>> -class ldraw::PolygonObject : public ColoredObject -{ -public: - using BaseClass = ColoredObject; - PolygonObject(const std::array& points, const Color color) : - ColoredObject{color}, - points{points} {} - int numPoints() const override - { - return N; - } - const glm::vec3& getPoint(int index) const override - { - Q_ASSERT(index >= 0 and index < N); - return this->points[index]; - } - QVariant getProperty(const Property id) const override - { - switch (id) - { - case Property::Point0: - return QVariant::fromValue(points[0]); - case Property::Point1: - return QVariant::fromValue(points[1]); - case Property::Point2: - if (N >= 3) - { - return QVariant::fromValue(points[2]); - } - break; - case Property::Point3: - if (N >= 4) - { - return QVariant::fromValue(points[3]); - } - break; - default: - break; - } - return BaseClass::getProperty(id); - } - void setProperty(SetPropertyResult* result, const PropertyKeyValue& pair) override - { - LDRAW_OBJECT_HANDLE_SET_PROPERTY(Point0, {points[0] = value;}) - LDRAW_OBJECT_HANDLE_SET_PROPERTY(Point1, {points[1] = value;}) - if constexpr (N >= 3) - { - LDRAW_OBJECT_HANDLE_SET_PROPERTY(Point2, {points[2] = value;}) - } - if constexpr (N >= 4) - { - LDRAW_OBJECT_HANDLE_SET_PROPERTY(Point3, {points[3] = value;}) - } - ColoredObject::setProperty(result, pair); - } - QDataStream &serialize(QDataStream& stream) const override - { - ColoredObject::serialize(stream); - for (const glm::vec3& point : this->points) - { - stream << point; - } - return stream; - } - QDataStream& deserialize(QDataStream& stream) override - { - ColoredObject::deserialize(stream); - for (glm::vec3& point : this->points) - { - stream >> point; - } - return stream; - } - std::array points; -};