Tue, 17 Mar 2020 23:13:29 +0200
object editor widgets start to form up
#include <QVBoxLayout> #include "model.h" #include "widgets/vec3editor.h" #include "polygonobjecteditor.h" PolygonObjectEditor::PolygonObjectEditor(Model* model, ldraw::id_t id, QWidget* parent) : QWidget{parent}, model{model}, storedObjectId{ldraw::NULL_ID.value} { this->setLayout(new QVBoxLayout{this}); this->setObjectId(id); } // destructor needed for std::unique_ptr PolygonObjectEditor::~PolygonObjectEditor() { } ldraw::id_t PolygonObjectEditor::objectId() const { return this->storedObjectId; } void PolygonObjectEditor::setObjectId(ldraw::id_t id) { this->storedObjectId = id; this->updateNumRows(); } void PolygonObjectEditor::updateNumRows() { const ldraw::Object* object = model->get(this->storedObjectId); const int number = object->numPoints(); if (static_cast<int>(this->vec3Editors.size()) > number) { this->vec3Editors.resize(number); } else { while (static_cast<int>(this->vec3Editors.size()) < number) { const glm::vec3& value = object->getPoint(this->vec3Editors.size()); this->vec3Editors.emplace_back(std::make_unique<Vec3Editor>(value, this)); this->layout()->addWidget(this->vec3Editors.back().get()); } } }