Sun, 06 Mar 2022 10:32:54 +0200
add missing file
81
62373840e33a
object editor widgets start to form up
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
1 | #include <QVBoxLayout> |
62373840e33a
object editor widgets start to form up
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
2 | #include "objecteditor.h" |
152 | 3 | #include "document.h" |
81
62373840e33a
object editor widgets start to form up
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
4 | |
152 | 5 | ObjectEditor::ObjectEditor(Document* document, const ldraw::id_t id) : |
6 | QWidget{document}, | |
7 | document{document} | |
81
62373840e33a
object editor widgets start to form up
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
8 | { |
62373840e33a
object editor widgets start to form up
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
9 | this->setObjectId(id); |
62373840e33a
object editor widgets start to form up
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
10 | this->setLayout(new QVBoxLayout{this}); |
62373840e33a
object editor widgets start to form up
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
11 | } |
62373840e33a
object editor widgets start to form up
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
12 | |
62373840e33a
object editor widgets start to form up
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
13 | void ObjectEditor::setObjectId(const ldraw::id_t id) |
62373840e33a
object editor widgets start to form up
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
14 | { |
62373840e33a
object editor widgets start to form up
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
15 | this->objectId = id; |
152 | 16 | const ldraw::Object* object = this->document->getModel().get(id); |
81
62373840e33a
object editor widgets start to form up
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
17 | if (object != nullptr and object->numPoints() > 0) |
62373840e33a
object editor widgets start to form up
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
18 | { |
62373840e33a
object editor widgets start to form up
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
19 | if (not this->polygonEditor.has_value()) |
62373840e33a
object editor widgets start to form up
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
20 | { |
152 | 21 | this->polygonEditor.emplace(this->document, id); |
81
62373840e33a
object editor widgets start to form up
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
22 | this->layout()->addWidget(&*this->polygonEditor); |
62373840e33a
object editor widgets start to form up
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
23 | } |
62373840e33a
object editor widgets start to form up
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
24 | else |
62373840e33a
object editor widgets start to form up
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
25 | { |
62373840e33a
object editor widgets start to form up
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
26 | this->polygonEditor->setObjectId(id); |
62373840e33a
object editor widgets start to form up
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
27 | } |
62373840e33a
object editor widgets start to form up
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
28 | } |
62373840e33a
object editor widgets start to form up
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
29 | else |
62373840e33a
object editor widgets start to form up
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
30 | { |
62373840e33a
object editor widgets start to form up
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
31 | this->polygonEditor.reset(); |
62373840e33a
object editor widgets start to form up
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
32 | } |
62373840e33a
object editor widgets start to form up
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
33 | } |