src/ui/objecteditor.cpp

changeset 81
62373840e33a
child 152
03f8e6d42e13
equal deleted inserted replaced
80:764381756899 81:62373840e33a
1 #include <QVBoxLayout>
2 #include "objecteditor.h"
3
4 ObjectEditor::ObjectEditor(Model* model, const ldraw::id_t id, QWidget *parent) :
5 QWidget{parent},
6 model{model}
7 {
8 this->setObjectId(id);
9 this->setLayout(new QVBoxLayout{this});
10 }
11
12 void ObjectEditor::setObjectId(const ldraw::id_t id)
13 {
14 this->objectId = id;
15 const ldraw::Object* object = this->model->get(id);
16 if (object != nullptr and object->numPoints() > 0)
17 {
18 if (not this->polygonEditor.has_value())
19 {
20 this->polygonEditor.emplace(this->model, id);
21 this->layout()->addWidget(&*this->polygonEditor);
22 }
23 else
24 {
25 this->polygonEditor->setObjectId(id);
26 }
27 }
28 else
29 {
30 this->polygonEditor.reset();
31 }
32 }

mercurial