17 */ |
17 */ |
18 |
18 |
19 #include "modeleditcontext.h" |
19 #include "modeleditcontext.h" |
20 |
20 |
21 Model::EditContext::EditContext(Model& model) : |
21 Model::EditContext::EditContext(Model& model) : |
22 model{model} |
22 storedModel{model} |
23 { |
23 { |
24 } |
24 } |
25 |
25 |
26 ldraw::Id Model::EditContext::append(std::unique_ptr<ldraw::Object>&& object) |
26 ldraw::id_t Model::EditContext::append(std::unique_ptr<ldraw::Object>&& object) |
27 { |
27 { |
28 const ldraw::Id id = object->id; |
28 const ldraw::id_t id = object->id; |
29 this->model.objectsById[id] = object.get(); |
29 this->model().objectsById[id] = object.get(); |
30 this->model.append(std::move(object)); |
30 this->model().append(std::move(object)); |
31 return id; |
31 return id; |
32 } |
32 } |
33 |
33 |
34 void Model::EditContext::setObjectProperty( |
34 void Model::EditContext::setObjectProperty( |
35 ldraw::Object* object, |
35 ldraw::Object* object, |
37 const QVariant& value) |
37 const QVariant& value) |
38 { |
38 { |
39 object->setProperty(property, value); |
39 object->setProperty(property, value); |
40 } |
40 } |
41 |
41 |
42 void Model::EditContext::invertObject(ldraw::Id id) |
42 void Model::EditContext::invertObject(ldraw::id_t id) |
43 { |
43 { |
44 auto it = this->model.objectsById.find(id); |
44 auto it = this->model().objectsById.find(id); |
45 if (it != this->model.objectsById.end()) |
45 if (it != this->model().objectsById.end()) |
46 { |
46 { |
47 ldraw::Object* object = it->second; |
47 ldraw::Object* object = it->second; |
48 object->invert(); |
48 object->invert(); |
49 } |
49 } |
50 } |
50 } |
|
51 |
|
52 Model& Model::EditContext::model() |
|
53 { |
|
54 return this->storedModel; |
|
55 } |
|
56 |
|
57 auto ldraw::splitQuadrilateral( |
|
58 Model::EditContext& editor, |
|
59 ldraw::quadrilateralid_t quadrilateral_id, |
|
60 ldraw::QuadrilateralSplit splitType |
|
61 ) -> std::optional<std::pair<ldraw::triangleid_t, ldraw::triangleid_t>> |
|
62 { |
|
63 std::optional<std::pair<ldraw::triangleid_t, ldraw::triangleid_t>> result; |
|
64 const ldraw::Quadrilateral* quadrilateral = editor.model().get(quadrilateral_id); |
|
65 if (quadrilateral != nullptr) |
|
66 { |
|
67 |
|
68 } |
|
69 return result; |
|
70 } |