history.cpp

changeset 153
03a7bdcce50d
parent 146
2ab24976acaa
child 160
edcb03f3ef75
equal deleted inserted replaced
152:552e46650a95 153:03a7bdcce50d
95 // ============================================================================= 95 // =============================================================================
96 void DelHistory::undo () { 96 void DelHistory::undo () {
97 for (ulong i = 0; i < cache.size(); ++i) { 97 for (ulong i = 0; i < cache.size(); ++i) {
98 ulong idx = cache.size() - i - 1; 98 ulong idx = cache.size() - i - 1;
99 LDObject* obj = cache[idx]->clone (); 99 LDObject* obj = cache[idx]->clone ();
100 g_CurrentFile->objects.insert (g_CurrentFile->objects.begin() + indices[idx], obj); 100 g_CurrentFile->insertObj (indices[idx], obj);
101 } 101 }
102 102
103 g_ForgeWindow->refresh (); 103 g_ForgeWindow->refresh ();
104 } 104 }
105 105
215 void AddHistory::redo () { 215 void AddHistory::redo () {
216 for (ulong i = 0; i < paObjs.size(); ++i) { 216 for (ulong i = 0; i < paObjs.size(); ++i) {
217 ulong idx = ulaIndices[i]; 217 ulong idx = ulaIndices[i];
218 LDObject* obj = paObjs[i]->clone (); 218 LDObject* obj = paObjs[i]->clone ();
219 219
220 g_CurrentFile->objects.insert (g_CurrentFile->objects.begin() + idx, obj); 220 g_CurrentFile->insertObj (idx, obj);
221 } 221 }
222 222
223 g_ForgeWindow->refresh (); 223 g_ForgeWindow->refresh ();
224 } 224 }
225 225
256 256
257 LDQuad* pQuad = static_cast<LDQuad*> (g_CurrentFile->objects[idx]); 257 LDQuad* pQuad = static_cast<LDQuad*> (g_CurrentFile->objects[idx]);
258 std::vector<LDTriangle*> paTriangles = pQuad->splitToTriangles (); 258 std::vector<LDTriangle*> paTriangles = pQuad->splitToTriangles ();
259 259
260 g_CurrentFile->objects[idx] = paTriangles[0]; 260 g_CurrentFile->objects[idx] = paTriangles[0];
261 g_CurrentFile->objects.insert (g_CurrentFile->objects.begin() + idx + 1, paTriangles[1]); 261 g_CurrentFile->insertObj (idx + 1, paTriangles[1]);
262 delete pQuad; 262 delete pQuad;
263 } 263 }
264 264
265 g_ForgeWindow->refresh (); 265 g_ForgeWindow->refresh ();
266 } 266 }
275 delete obj; 275 delete obj;
276 } 276 }
277 277
278 for (ulong i = 0; i < ulaRefIndices.size(); ++i) { 278 for (ulong i = 0; i < ulaRefIndices.size(); ++i) {
279 LDSubfile* obj = paRefs[i]->clone (); 279 LDSubfile* obj = paRefs[i]->clone ();
280 g_CurrentFile->objects.insert (g_CurrentFile->objects.begin() + ulaRefIndices[i], obj); 280 g_CurrentFile->insertObj (ulaRefIndices[i], obj);
281 } 281 }
282 282
283 g_ForgeWindow->refresh (); 283 g_ForgeWindow->refresh ();
284 } 284 }
285 285
290 assert (g_CurrentFile->object (idx)->getType () == OBJ_Subfile); 290 assert (g_CurrentFile->object (idx)->getType () == OBJ_Subfile);
291 LDSubfile* ref = static_cast<LDSubfile*> (g_CurrentFile->object (idx)); 291 LDSubfile* ref = static_cast<LDSubfile*> (g_CurrentFile->object (idx));
292 vector<LDObject*> objs = ref->inlineContents (bDeep, false); 292 vector<LDObject*> objs = ref->inlineContents (bDeep, false);
293 293
294 for (LDObject* obj : objs) 294 for (LDObject* obj : objs)
295 g_CurrentFile->objects.insert (g_CurrentFile->objects.begin() + idx++, obj); 295 g_CurrentFile->insertObj (idx++, obj);
296 296
297 g_CurrentFile->forgetObject (ref); 297 g_CurrentFile->forgetObject (ref);
298 delete ref; 298 delete ref;
299 } 299 }
300 300

mercurial