29 void Model::insertObject(int position, LDObject* object) |
29 void Model::insertObject(int position, LDObject* object) |
30 { |
30 { |
31 if (object->model() and object->model() != this) |
31 if (object->model() and object->model() != this) |
32 object->model()->withdraw(object); |
32 object->model()->withdraw(object); |
33 |
33 |
34 if (not object->model()) |
34 // TODO: check that the object isn't in the vector once there's a cheap way to do so! |
35 { |
35 _objects.insert(position, object); |
36 _objects.insert(position, object); |
36 _needsTriangleRecount = true; |
37 _needsTriangleRecount = true; |
37 object->setDocument(this); |
38 object->setDocument(this); |
38 print("Object %1 added to position %2", object->id(), position); |
39 print("Object %1 added to position %2", object->id(), position); |
|
40 } |
|
41 } |
39 } |
42 |
40 |
43 bool Model::swapObjects(LDObject* one, LDObject* other) |
41 bool Model::swapObjects(LDObject* one, LDObject* other) |
44 { |
42 { |
45 int a = _objects.indexOf(one); |
43 int a = _objects.indexOf(one); |
89 |
87 |
90 void Model::removeAt(int position) |
88 void Model::removeAt(int position) |
91 { |
89 { |
92 LDObject* object = withdrawAt(position); |
90 LDObject* object = withdrawAt(position); |
93 delete object; |
91 delete object; |
94 } |
|
95 |
|
96 void Model::replace(LDObject* object, LDObject* newObject) |
|
97 { |
|
98 if (object->model() == this) |
|
99 setObjectAt(object->lineNumber(), newObject); |
|
100 } |
92 } |
101 |
93 |
102 void Model::replace(LDObject *object, Model &model) |
94 void Model::replace(LDObject *object, Model &model) |
103 { |
95 { |
104 if (object->model() == this) |
96 if (object->model() == this) |