--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/objecttypes/polygon.cpp Sun Sep 22 11:51:41 2019 +0300 @@ -0,0 +1,97 @@ +#include "polygon.h" + +modelobjects::Triangle::Triangle( + const Vertex& point_1, + const Vertex& point_2, + const Vertex& point_3, + Color color_index) : + ColoredBaseObject{color_index}, + points{point_1, point_2, point_3} +{ +} + +QVariant modelobjects::Triangle::getProperty(const Property id) const +{ + switch (id) + { + case Property::Point1: + return points[0]; + case Property::Point2: + return points[1]; + case Property::Point3: + return points[2]; + default: + return ColoredBaseObject::getProperty(id); + } +} + +auto modelobjects::Triangle::setProperty(Property id, const QVariant& value) + -> SetPropertyResult +{ + switch (id) + { + case Property::Point1: + points[0] = value.value<Vertex>(); + return SetPropertyResult::Success; + case Property::Point2: + points[1] = value.value<Vertex>(); + return SetPropertyResult::Success; + case Property::Point3: + points[2] = value.value<Vertex>(); + return SetPropertyResult::Success; + default: + return ColoredBaseObject::setProperty(id, value); + } +} + +modelobjects::Quadrilateral::Quadrilateral( + const Vertex& point_1, + const Vertex& point_2, + const Vertex& point_3, + const Vertex& point_4, + Color color_index) : + ColoredBaseObject{color_index}, + points{point_1, point_2, point_3, point_4} +{ +} + +QVariant modelobjects::Quadrilateral::getProperty(const Property id) const +{ + switch (id) + { + case Property::Point1: + return points[0]; + case Property::Point2: + return points[1]; + case Property::Point3: + return points[2]; + case Property::Point4: + return points[3]; + default: + return ColoredBaseObject::getProperty(id); + } +} + +auto modelobjects::Quadrilateral::setProperty( + const Property id, + const QVariant& value) + -> SetPropertyResult +{ + switch (id) + { + case Property::Point1: + points[0] = value.value<Vertex>(); + return SetPropertyResult::Success; + case Property::Point2: + points[1] = value.value<Vertex>(); + return SetPropertyResult::Success; + case Property::Point3: + points[2] = value.value<Vertex>(); + return SetPropertyResult::Success; + case Property::Point4: + points[3] = value.value<Vertex>(); + return SetPropertyResult::Success; + default: + return ColoredBaseObject::setProperty(id, value); + } +}