src/linetypes/object.cpp

Tue, 27 Jul 2021 16:29:00 +0300

author
Teemu Piippo <teemu@hecknology.net>
date
Tue, 27 Jul 2021 16:29:00 +0300
changeset 118
8e1c9f18ae15
parent 89
7abaf1d64719
child 132
488d0ba6070b
permissions
-rw-r--r--

Add vertex rendering

#include <QBrush>
#include <QFont>
#include "object.h"
#include "widgets/vec3editor.h"
#include "modeleditcontext.h"

static std::int32_t getIdForNewObject()
{
	static std::int32_t id = 0;
	id += 1;
	return id;
}

ldraw::Object::Object() :
	id {getIdForNewObject()}
{
}

ldraw::Object::~Object()
{
}

bool ldraw::Object::hasColor() const
{
	return false;
}

QVariant ldraw::Object::getProperty(Property id) const
{
	Q_UNUSED(id);
	return {};
}

void ldraw::Object::setProperty(SetPropertyResult* result, const PropertyKeyValue& pair)
{
	Q_UNUSED(result)
	Q_UNUSED(pair)
}

/**
 * @brief public interface to setProperty
 */
ldraw::Object::SetPropertyResult ldraw::Object::setProperty(const PropertyKeyValue& pair)
{
	SetPropertyResult result;
	this->setProperty(&result, pair);
	return result;
}

QBrush ldraw::Object::textRepresentationForeground() const
{
	return {};
}

QBrush ldraw::Object::textRepresentationBackground() const
{
	return {};
}

QFont ldraw::Object::textRepresentationFont() const
{
	return {};
}

void ldraw::Object::getPolygons(std::vector<gl::Polygon>& polygons, GetPolygonsContext* context) const
{
	Q_UNUSED(polygons)
	Q_UNUSED(context)
}

const glm::vec3& ldraw::Object::getPoint(int index) const
{
	Q_UNUSED(index);
	throw BadPointIndex{};
}

ldraw::ColoredObject::ColoredObject(const Color color_index) :
	colorIndex{color_index}
{
}

bool ldraw::ColoredObject::hasColor() const
{
	return true;
}

QVariant ldraw::ColoredObject::getProperty(Property id) const
{
	switch (id)
	{
	case Property::Color:
		return QVariant::fromValue<Color>(colorIndex);
	default:
		return Object::getProperty(id);
	}
}

void ldraw::ColoredObject::setProperty(SetPropertyResult* result, const PropertyKeyValue& pair)
{
	LDRAW_OBJECT_HANDLE_SET_PROPERTY(Color, {colorIndex = value;});
	Object::setProperty(result, pair);
}

QString ldraw::Empty::textRepresentation() const
{
	return "";
}

mercurial