src/ui/objecteditor.cpp

Sun, 25 Jul 2021 16:26:38 +0300

author
Teemu Piippo <teemu@hecknology.net>
date
Sun, 25 Jul 2021 16:26:38 +0300
changeset 109
40a1cf2f38f5
parent 81
62373840e33a
child 152
03f8e6d42e13
permissions
-rw-r--r--

replaced preview layers in favor of overpainting callback

#include <QVBoxLayout>
#include "objecteditor.h"

ObjectEditor::ObjectEditor(Model* model, const ldraw::id_t id, QWidget *parent) :
	QWidget{parent},
	model{model}
{
	this->setObjectId(id);
	this->setLayout(new QVBoxLayout{this});
}

void ObjectEditor::setObjectId(const ldraw::id_t id)
{
	this->objectId = id;
	const ldraw::Object* object = this->model->get(id);
	if (object != nullptr and object->numPoints() > 0)
	{
		if (not this->polygonEditor.has_value())
		{
			this->polygonEditor.emplace(this->model, id);
			this->layout()->addWidget(&*this->polygonEditor);
		}
		else
		{
			this->polygonEditor->setObjectId(id);
		}
	}
	else
	{
		this->polygonEditor.reset();
	}
}

mercurial