diff -r 764381756899 -r 62373840e33a src/ui/objecteditor.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ui/objecteditor.cpp Tue Mar 17 23:13:29 2020 +0200 @@ -0,0 +1,32 @@ +#include +#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(); + } +}