ldtypes.cpp

changeset 104
6e29bb0e83c5
parent 103
b0a345196435
child 108
351aef26f444
equal deleted inserted replaced
103:b0a345196435 104:6e29bb0e83c5
1 /* 1 /*
2 * LDForge: LDraw parts authoring CAD 2 * LDForge: LDraw parts authoring CAD
3 * Copyright (C) 2013 Santeri `arezey` Piippo 3 * Copyright (C) 2013 Santeri Piippo
4 * 4 *
5 * This program is free software: you can redistribute it and/or modify 5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or 7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version. 8 * (at your option) any later version.
57 LDObject::LDObject () { 57 LDObject::LDObject () {
58 commonInit (); 58 commonInit ();
59 } 59 }
60 60
61 void LDObject::commonInit () { 61 void LDObject::commonInit () {
62 qObjListEntry = nullptr; 62 qObjListEntry = null;
63 parent = null;
63 } 64 }
64 65
65 LDGibberish::LDGibberish () { 66 LDGibberish::LDGibberish () {
66 commonInit (); 67 commonInit ();
67 dColor = -1; 68 dColor = -1;
377 if (bCache) 378 if (bCache)
378 pFile->objCache = cache; 379 pFile->objCache = cache;
379 } 380 }
380 381
381 // Transform the objects 382 // Transform the objects
382 for (LDObject* obj : objs) 383 for (LDObject* obj : objs) {
384 // Set the parent now so we know what inlined this.
385 obj->parent = this;
386
383 transformObject (obj, mMatrix, vPosition, dColor); 387 transformObject (obj, mMatrix, vPosition, dColor);
388 }
384 389
385 return objs; 390 return objs;
386 } 391 }
387 392
388 // ============================================================================= 393 // =============================================================================
460 465
461 return zText; 466 return zText;
462 } 467 }
463 468
464 // ============================================================================= 469 // =============================================================================
470 LDSubfile* LDObject::topLevelParent () {
471 if (!parent)
472 return null;
473
474 LDObject* it = this;
475
476 while (it->parent)
477 it = it->parent;
478
479 return static_cast<LDSubfile*> (it);
480 }
481
482
483 // =============================================================================
465 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 484 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
466 // ============================================================================= 485 // =============================================================================
467 void LDObject::move (vertex vVector) { vVector = vVector; /* to shut up GCC */ } 486 void LDObject::move (vertex vVector) { vVector = vVector; /* to shut up GCC */ }
468 void LDEmpty::move (vertex vVector) { vVector = vVector; } 487 void LDEmpty::move (vertex vVector) { vVector = vVector; }
469 void LDBFC::move (vertex vVector) { vVector = vVector; } 488 void LDBFC::move (vertex vVector) { vVector = vVector; }

mercurial