src/objecttypes/edge.cpp

Sun, 03 Nov 2019 13:18:55 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Sun, 03 Nov 2019 13:18:55 +0200
changeset 11
771168ee2c76
parent 8
44679e468ba9
child 13
6e838748867b
permissions
-rw-r--r--

added matrix conversions and datastream operators

#include "edge.h"

modelobjects::Edge::Edge(
	const Vertex& point_1,
	const Vertex& point_2,
	const Color color_index) :
	ColoredBaseObject{color_index},
	point_1{point_1},
	point_2{point_2} {}

modelobjects::Edge::Edge(const QVector<Vertex>& vertices, const Color color) :
	ColoredBaseObject{color},
	point_1{vertices[0]},
	point_2{vertices[1]}
{
}

QVariant modelobjects::Edge::getProperty(Property property) const
{
	switch (property)
	{
	case Property::Point1:
		return point_1;
	case Property::Point2:
		return point_2;
	default:
		return BaseClass::getProperty(property);
	}
}

auto modelobjects::Edge::setProperty(Property property, const QVariant& value)
	-> SetPropertyResult
{
	switch (property)
	{
	case Property::Point1:
		point_1 = value.value<Vertex>();
		return SetPropertyResult::Success;
	case Property::Point2:
		point_2 = value.value<Vertex>();
		return SetPropertyResult::Success;
	default:
		return BaseClass::setProperty(property, value);
	}
}

QString modelobjects::Edge::textRepresentation() const
{
	return utility::format("%1 %2", vertexToStringParens(point_1), vertexToStringParens(point_2));
}

mercurial