src/linetypes/quadrilateral.cpp

Sat, 14 Dec 2019 22:36:06 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Sat, 14 Dec 2019 22:36:06 +0200
changeset 19
ed9685f44ab3
parent 18
918b6c0f8b5b
child 21
0133e565e072
permissions
-rw-r--r--

added missing files

#include "quadrilateral.h"

linetypes::Quadrilateral::Quadrilateral(
	const Point3D& point_1,
	const Point3D& point_2,
	const Point3D& point_3,
	const Point3D& point_4,
	Color color_index) :
	ColoredObject{color_index},
	points{point_1, point_2, point_3, point_4}
{
}

linetypes::Quadrilateral::Quadrilateral(const QVector<Point3D>& vertices, const Color color) :
	ColoredObject{color},
	points{vertices[0], vertices[1], vertices[2], vertices[3]}
{
}

QVariant linetypes::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 ColoredObject::getProperty(id);
	}
}

auto linetypes::Quadrilateral::setProperty(
	const Property id,
	const QVariant& value)
	-> SetPropertyResult
{
	switch (id)
	{
	case Property::Point1:
		points[0] = value.value<Point3D>();
		return SetPropertyResult::Success;
	case Property::Point2:
		points[1] = value.value<Point3D>();
		return SetPropertyResult::Success;
	case Property::Point3:
		points[2] = value.value<Point3D>();
		return SetPropertyResult::Success;
	case Property::Point4:
		points[3] = value.value<Point3D>();
		return SetPropertyResult::Success;
	default:
		return ColoredObject::setProperty(id, value);
	}
}

QString linetypes::Quadrilateral::textRepresentation() const
{
	return utility::format("%1 %2 %3 %4",
		vertexToStringParens(points[0]),
		vertexToStringParens(points[1]),
		vertexToStringParens(points[2]),
		vertexToStringParens(points[3]));
}

mercurial