src/ldObject.cpp

changeset 958
1dc890c73e01
parent 956
2af18ba2665f
child 959
737245eee433
equal deleted inserted replaced
957:429c7ed3cc54 958:1dc890c73e01
250 250
251 // ============================================================================= 251 // =============================================================================
252 // 252 //
253 void LDObject::swap (LDObject* other) 253 void LDObject::swap (LDObject* other)
254 { 254 {
255 assert (document() == other->document()); 255 if (document() == other->document())
256 document()->swapObjects (this, other); 256 document()->swapObjects (this, other);
257 } 257 }
258 258
259 // ============================================================================= 259 // =============================================================================
260 // 260 //
261 LDLine::LDLine (Vertex v1, Vertex v2, LDDocument* document) : 261 LDLine::LDLine (Vertex v1, Vertex v2, LDDocument* document) :
377 LDObjectList objs = fileInfo()->inlineContents (deep, render); 377 LDObjectList objs = fileInfo()->inlineContents (deep, render);
378 378
379 // Transform the objects 379 // Transform the objects
380 for (LDObject* obj : objs) 380 for (LDObject* obj : objs)
381 { 381 {
382 // assert (obj->type() != OBJ_Subfile);
383 // Set the parent now so we know what inlined the object. 382 // Set the parent now so we know what inlined the object.
384 obj->setParent (this); 383 obj->setParent (this);
385 TransformObject (obj, transform(), position(), color()); 384 TransformObject (obj, transform(), position(), color());
386 } 385 }
387 386
468 if ((up and idx == 0) or (not up and idx == (long) file->objects().size() - 1l)) 467 if ((up and idx == 0) or (not up and idx == (long) file->objects().size() - 1l))
469 { 468 {
470 // One of the objects hit the extrema. If this happens, this should be the first 469 // One of the objects hit the extrema. If this happens, this should be the first
471 // object to be iterated on. Thus, nothing has changed yet and it's safe to just 470 // object to be iterated on. Thus, nothing has changed yet and it's safe to just
472 // abort the entire operation. 471 // abort the entire operation.
473 assert (i == start);
474 return; 472 return;
475 } 473 }
476 474
477 objsToCompile << obj; 475 objsToCompile << obj;
478 objsToCompile << file->getObject (target); 476 objsToCompile << file->getObject (target);
547 // ============================================================================= 545 // =============================================================================
548 // 546 //
549 LDObject* LDObject::next() const 547 LDObject* LDObject::next() const
550 { 548 {
551 int idx = lineNumber(); 549 int idx = lineNumber();
552 assert (idx != -1); 550
553 551 if (idx == -1 or idx == document()->getObjectCount() - 1)
554 if (idx == document()->getObjectCount() - 1)
555 return nullptr; 552 return nullptr;
556 553
557 return document()->getObject (idx + 1); 554 return document()->getObject (idx + 1);
558 } 555 }
559 556
560 // ============================================================================= 557 // =============================================================================
561 // 558 //
562 LDObject* LDObject::previous() const 559 LDObject* LDObject::previous() const
563 { 560 {
564 int idx = lineNumber(); 561 int idx = lineNumber();
565 assert (idx != -1); 562
566 563 if (idx <= 0)
567 if (idx == 0)
568 return nullptr; 564 return nullptr;
569 565
570 return document()->getObject (idx - 1); 566 return document()->getObject (idx - 1);
571 } 567 }
572 568
621 case OBJ_Quad: return LDSpawn<LDQuad>(); 617 case OBJ_Quad: return LDSpawn<LDQuad>();
622 case OBJ_Empty: return LDSpawn<LDEmpty>(); 618 case OBJ_Empty: return LDSpawn<LDEmpty>();
623 case OBJ_Error: return LDSpawn<LDError>(); 619 case OBJ_Error: return LDSpawn<LDError>();
624 case OBJ_Vertex: return LDSpawn<LDVertex>(); 620 case OBJ_Vertex: return LDSpawn<LDVertex>();
625 case OBJ_Overlay: return LDSpawn<LDOverlay>(); 621 case OBJ_Overlay: return LDSpawn<LDOverlay>();
626 case OBJ_NumTypes: assert (false); 622 case OBJ_NumTypes: break;
627 } 623 }
628 return nullptr; 624 return nullptr;
629 } 625 }
630 626
631 // ============================================================================= 627 // =============================================================================

mercurial