31 ldraw::id_t append(std::unique_ptr<ldraw::Object>&& object); |
28 ldraw::id_t append(std::unique_ptr<ldraw::Object>&& object); |
32 template<typename T, typename... Args> |
29 template<typename T, typename... Args> |
33 ldraw::Id<T> insert(int position, Args&&... args); |
30 ldraw::Id<T> insert(int position, Args&&... args); |
34 void remove(int position); |
31 void remove(int position); |
35 template<ldraw::Property property> |
32 template<ldraw::Property property> |
36 void setObjectProperty(ldraw::id_t id, const ldraw::PropertyType_t<property>& value) |
33 void setObjectProperty(ldraw::id_t id, const ldraw::PropertyType<property>& value); |
37 { |
34 auto setObjectProperty(ldraw::id_t id, ldraw::Property property, const QVariant& value) |
38 ldraw::Object* object = this->model().objectAt(id); |
35 -> ldraw::Object::SetPropertyResult; |
39 if (object != nullptr) |
|
40 { |
|
41 object->setProperty<property>(value); |
|
42 modifiedObjects.insert(id); |
|
43 } |
|
44 } |
|
45 void setObjectPoint(ldraw::id_t id, int pointId, const glm::vec3& value); |
36 void setObjectPoint(ldraw::id_t id, int pointId, const glm::vec3& value); |
46 void invertObject(ldraw::id_t id); |
37 void invertObject(ldraw::id_t id); |
47 Model& model(); |
38 Model& model(); |
48 private: |
39 private: |
49 EditContext(Model& model); |
40 EditContext(Model& model); |
50 friend class Model; |
41 friend class Model; |
51 QSet<ldraw::id_t> modifiedObjects; |
42 QSet<ldraw::id_t> modifiedObjects; |
52 Model& storedModel; |
43 Model& storedModel; |
53 }; |
44 }; |
|
45 |
|
46 template<ldraw::Property Property> |
|
47 void Model::EditContext::setObjectProperty(const ldraw::id_t id, const ldraw::PropertyType<Property>& value) |
|
48 { |
|
49 ldraw::Object* object = this->model().objectAt(id); |
|
50 if (object != nullptr) |
|
51 { |
|
52 object->setProperty<Property>(value); |
|
53 modifiedObjects.insert(id); |
|
54 } |
|
55 } |
54 |
56 |
55 template<typename T, typename... Args> |
57 template<typename T, typename... Args> |
56 ldraw::Id<T> Model::EditContext::append(Args&&... args) |
58 ldraw::Id<T> Model::EditContext::append(Args&&... args) |
57 { |
59 { |
58 return this->storedModel.append<T>(args...); |
60 return this->storedModel.append<T>(args...); |