| 34 |
34 |
| 35 // ============================================================================= |
35 // ============================================================================= |
| 36 // LDObject constructors |
36 // LDObject constructors |
| 37 // |
37 // |
| 38 LDObject::LDObject() : |
38 LDObject::LDObject() : |
| 39 m_Hidden (false), |
39 m_isHidden (false), |
| 40 m_Selected (false), |
40 m_isSelected (false), |
| 41 m_Parent (null), |
41 m_parent (null), |
| 42 m_File (null), |
42 m_document (null), |
| 43 m_GLInit (false), |
43 m_isGLInit (false), |
| 44 qObjListEntry (null) |
44 qObjListEntry (null) |
| 45 { |
45 { |
| 46 memset (m_coords, 0, sizeof m_coords); |
46 memset (m_coords, 0, sizeof m_coords); |
| 47 chooseID(); |
47 chooseID(); |
| 48 g_LDObjects << this; |
48 g_LDObjects << this; |
| 78 |
78 |
| 79 // ============================================================================= |
79 // ============================================================================= |
| 80 // |
80 // |
| 81 QString LDComment::asText() const |
81 QString LDComment::asText() const |
| 82 { |
82 { |
| 83 return fmt ("0 %1", text); |
83 return fmt ("0 %1", text()); |
| 84 } |
84 } |
| 85 |
85 |
| 86 // ============================================================================= |
86 // ============================================================================= |
| 87 // |
87 // |
| 88 QString LDSubfile::asText() const |
88 QString LDSubfile::asText() const |
| 89 { |
89 { |
| 90 QString val = fmt ("1 %1 %2 ", getColor(), getPosition()); |
90 QString val = fmt ("1 %1 %2 ", color(), position()); |
| 91 val += getTransform().toString(); |
91 val += transform().toString(); |
| 92 val += ' '; |
92 val += ' '; |
| 93 val += getFileInfo()->getName(); |
93 val += fileInfo()->name(); |
| 94 return val; |
94 return val; |
| 95 } |
95 } |
| 96 |
96 |
| 97 // ============================================================================= |
97 // ============================================================================= |
| 98 // |
98 // |
| 99 QString LDLine::asText() const |
99 QString LDLine::asText() const |
| 100 { |
100 { |
| 101 QString val = fmt ("2 %1", getColor()); |
101 QString val = fmt ("2 %1", color()); |
| 102 |
102 |
| 103 for (int i = 0; i < 2; ++i) |
103 for (int i = 0; i < 2; ++i) |
| 104 val += fmt (" %1", vertex (i)); |
104 val += fmt (" %1", vertex (i)); |
| 105 |
105 |
| 106 return val; |
106 return val; |
| 108 |
108 |
| 109 // ============================================================================= |
109 // ============================================================================= |
| 110 // |
110 // |
| 111 QString LDTriangle::asText() const |
111 QString LDTriangle::asText() const |
| 112 { |
112 { |
| 113 QString val = fmt ("3 %1", getColor()); |
113 QString val = fmt ("3 %1", color()); |
| 114 |
114 |
| 115 for (int i = 0; i < 3; ++i) |
115 for (int i = 0; i < 3; ++i) |
| 116 val += fmt (" %1", vertex (i)); |
116 val += fmt (" %1", vertex (i)); |
| 117 |
117 |
| 118 return val; |
118 return val; |
| 120 |
120 |
| 121 // ============================================================================= |
121 // ============================================================================= |
| 122 // |
122 // |
| 123 QString LDQuad::asText() const |
123 QString LDQuad::asText() const |
| 124 { |
124 { |
| 125 QString val = fmt ("4 %1", getColor()); |
125 QString val = fmt ("4 %1", color()); |
| 126 |
126 |
| 127 for (int i = 0; i < 4; ++i) |
127 for (int i = 0; i < 4; ++i) |
| 128 val += fmt (" %1", vertex (i)); |
128 val += fmt (" %1", vertex (i)); |
| 129 |
129 |
| 130 return val; |
130 return val; |
| 132 |
132 |
| 133 // ============================================================================= |
133 // ============================================================================= |
| 134 // |
134 // |
| 135 QString LDCondLine::asText() const |
135 QString LDCondLine::asText() const |
| 136 { |
136 { |
| 137 QString val = fmt ("5 %1", getColor()); |
137 QString val = fmt ("5 %1", color()); |
| 138 |
138 |
| 139 // Add the coordinates |
139 // Add the coordinates |
| 140 for (int i = 0; i < 4; ++i) |
140 for (int i = 0; i < 4; ++i) |
| 141 val += fmt (" %1", vertex (i)); |
141 val += fmt (" %1", vertex (i)); |
| 142 |
142 |
| 145 |
145 |
| 146 // ============================================================================= |
146 // ============================================================================= |
| 147 // |
147 // |
| 148 QString LDError::asText() const |
148 QString LDError::asText() const |
| 149 { |
149 { |
| 150 return contents; |
150 return contents(); |
| 151 } |
151 } |
| 152 |
152 |
| 153 // ============================================================================= |
153 // ============================================================================= |
| 154 // |
154 // |
| 155 QString LDVertex::asText() const |
155 QString LDVertex::asText() const |
| 156 { |
156 { |
| 157 return fmt ("0 !LDFORGE VERTEX %1 %2", getColor(), pos); |
157 return fmt ("0 !LDFORGE VERTEX %1 %2", color(), pos); |
| 158 } |
158 } |
| 159 |
159 |
| 160 // ============================================================================= |
160 // ============================================================================= |
| 161 // |
161 // |
| 162 QString LDEmpty::asText() const |
162 QString LDEmpty::asText() const |
| 197 // 1---2 1 1---2 |
197 // 1---2 1 1---2 |
| 198 LDTriangle* tri1 = new LDTriangle (vertex (0), vertex (1), vertex (3)); |
198 LDTriangle* tri1 = new LDTriangle (vertex (0), vertex (1), vertex (3)); |
| 199 LDTriangle* tri2 = new LDTriangle (vertex (1), vertex (2), vertex (3)); |
199 LDTriangle* tri2 = new LDTriangle (vertex (1), vertex (2), vertex (3)); |
| 200 |
200 |
| 201 // The triangles also inherit the quad's color |
201 // The triangles also inherit the quad's color |
| 202 tri1->setColor (getColor()); |
202 tri1->setColor (color()); |
| 203 tri2->setColor (getColor()); |
203 tri2->setColor (color()); |
| 204 |
204 |
| 205 QList<LDTriangle*> triangles; |
205 QList<LDTriangle*> triangles; |
| 206 triangles << tri1; |
206 triangles << tri1; |
| 207 triangles << tri2; |
207 triangles << tri2; |
| 208 return triangles; |
208 return triangles; |
| 214 { |
214 { |
| 215 long idx = lineNumber(); |
215 long idx = lineNumber(); |
| 216 assert (idx != -1); |
216 assert (idx != -1); |
| 217 |
217 |
| 218 // Replace the instance of the old object with the new object |
218 // Replace the instance of the old object with the new object |
| 219 getFile()->setObject (idx, other); |
219 document()->setObject (idx, other); |
| 220 |
220 |
| 221 // Remove the old object |
221 // Remove the old object |
| 222 destroy(); |
222 destroy(); |
| 223 } |
223 } |
| 224 |
224 |
| 225 // ============================================================================= |
225 // ============================================================================= |
| 226 // |
226 // |
| 227 void LDObject::swap (LDObject* other) |
227 void LDObject::swap (LDObject* other) |
| 228 { |
228 { |
| 229 assert (getFile() == other->getFile()); |
229 assert (document() == other->document()); |
| 230 getFile()->swapObjects (this, other); |
230 document()->swapObjects (this, other); |
| 231 } |
231 } |
| 232 |
232 |
| 233 // ============================================================================= |
233 // ============================================================================= |
| 234 // |
234 // |
| 235 LDLine::LDLine (Vertex v1, Vertex v2) |
235 LDLine::LDLine (Vertex v1, Vertex v2) |
| 263 // If this object was selected, unselect it now |
263 // If this object was selected, unselect it now |
| 264 if (isSelected()) |
264 if (isSelected()) |
| 265 unselect(); |
265 unselect(); |
| 266 |
266 |
| 267 // If this object was associated to a file, remove it off it now |
267 // If this object was associated to a file, remove it off it now |
| 268 if (getFile()) |
268 if (document()) |
| 269 getFile()->forgetObject (this); |
269 document()->forgetObject (this); |
| 270 |
270 |
| 271 // Delete the GL lists |
271 // Delete the GL lists |
| 272 GL::deleteLists (this); |
272 GL::deleteLists (this); |
| 273 |
273 |
| 274 // Remove this object from the list of LDObjects |
274 // Remove this object from the list of LDObjects |
| 298 break; |
298 break; |
| 299 |
299 |
| 300 case LDObject::ESubfile: |
300 case LDObject::ESubfile: |
| 301 { |
301 { |
| 302 LDSubfile* ref = static_cast<LDSubfile*> (obj); |
302 LDSubfile* ref = static_cast<LDSubfile*> (obj); |
| 303 Matrix newMatrix = transform * ref->getTransform(); |
303 Matrix newMatrix = transform * ref->transform(); |
| 304 Vertex newpos = ref->getPosition(); |
304 Vertex newpos = ref->position(); |
| 305 |
305 |
| 306 newpos.transform (transform, pos); |
306 newpos.transform (transform, pos); |
| 307 ref->setPosition (newpos); |
307 ref->setPosition (newpos); |
| 308 ref->setTransform (newMatrix); |
308 ref->setTransform (newMatrix); |
| 309 } |
309 } |
| 311 |
311 |
| 312 default: |
312 default: |
| 313 break; |
313 break; |
| 314 } |
314 } |
| 315 |
315 |
| 316 if (obj->getColor() == maincolor) |
316 if (obj->color() == maincolor) |
| 317 obj->setColor (parentcolor); |
317 obj->setColor (parentcolor); |
| 318 } |
318 } |
| 319 |
319 |
| 320 // ============================================================================= |
320 // ============================================================================= |
| 321 // |
321 // |
| 322 LDObjectList LDSubfile::inlineContents (InlineFlags flags) |
322 LDObjectList LDSubfile::inlineContents (InlineFlags flags) |
| 323 { |
323 { |
| 324 LDObjectList objs = getFileInfo()->inlineContents (flags); |
324 LDObjectList objs = fileInfo()->inlineContents (flags); |
| 325 |
325 |
| 326 // Transform the objects |
326 // Transform the objects |
| 327 for (LDObject* obj : objs) |
327 for (LDObject* obj : objs) |
| 328 { |
328 { |
| 329 // Set the parent now so we know what inlined the object. |
329 // Set the parent now so we know what inlined the object. |
| 330 obj->setParent (this); |
330 obj->setParent (this); |
| 331 transformObject (obj, getTransform(), getPosition(), getColor()); |
331 transformObject (obj, transform(), position(), color()); |
| 332 } |
332 } |
| 333 |
333 |
| 334 return objs; |
334 return objs; |
| 335 } |
335 } |
| 336 |
336 |
| 337 // ============================================================================= |
337 // ============================================================================= |
| 338 // |
338 // |
| 339 long LDObject::lineNumber() const |
339 long LDObject::lineNumber() const |
| 340 { |
340 { |
| 341 assert (getFile() != null); |
341 assert (document() != null); |
| 342 |
342 |
| 343 for (int i = 0; i < getFile()->getObjectCount(); ++i) |
343 for (int i = 0; i < document()->getObjectCount(); ++i) |
| 344 if (getFile()->getObject (i) == this) |
344 if (document()->getObject (i) == this) |
| 345 return i; |
345 return i; |
| 346 |
346 |
| 347 return -1; |
347 return -1; |
| 348 } |
348 } |
| 349 |
349 |
| 357 // If we move down, we need to iterate the array in reverse order. |
357 // If we move down, we need to iterate the array in reverse order. |
| 358 const long start = up ? 0 : (objs.size() - 1); |
358 const long start = up ? 0 : (objs.size() - 1); |
| 359 const long end = up ? objs.size() : -1; |
359 const long end = up ? objs.size() : -1; |
| 360 const long incr = up ? 1 : -1; |
360 const long incr = up ? 1 : -1; |
| 361 LDObjectList objsToCompile; |
361 LDObjectList objsToCompile; |
| 362 LDDocument* file = objs[0]->getFile(); |
362 LDDocument* file = objs[0]->document(); |
| 363 |
363 |
| 364 for (long i = start; i != end; i += incr) |
364 for (long i = start; i != end; i += incr) |
| 365 { |
365 { |
| 366 LDObject* obj = objs[i]; |
366 LDObject* obj = objs[i]; |
| 367 |
367 |
| 368 const long idx = obj->lineNumber(), |
368 const long idx = obj->lineNumber(), |
| 369 target = idx + (up ? -1 : 1); |
369 target = idx + (up ? -1 : 1); |
| 370 |
370 |
| 371 if ( (up && idx == 0) || (!up && idx == (long) (file->getObjects().size() - 1))) |
371 if ((up && idx == 0) || (!up && idx == (long) (file->objects().size() - 1))) |
| 372 { |
372 { |
| 373 // One of the objects hit the extrema. If this happens, this should be the first |
373 // One of the objects hit the extrema. If this happens, this should be the first |
| 374 // object to be iterated on. Thus, nothing has changed yet and it's safe to just |
374 // object to be iterated on. Thus, nothing has changed yet and it's safe to just |
| 375 // abort the entire operation. |
375 // abort the entire operation. |
| 376 assert (i == start); |
376 assert (i == start); |
| 441 |
441 |
| 442 // ============================================================================= |
442 // ============================================================================= |
| 443 // |
443 // |
| 444 LDObject* LDObject::topLevelParent() |
444 LDObject* LDObject::topLevelParent() |
| 445 { |
445 { |
| 446 if (!getParent()) |
446 if (parent() == null) |
| 447 return this; |
447 return this; |
| 448 |
448 |
| 449 LDObject* it = this; |
449 LDObject* it = this; |
| 450 |
450 |
| 451 while (it->getParent()) |
451 while (it->parent() != null) |
| 452 it = it->getParent(); |
452 it = it->parent(); |
| 453 |
453 |
| 454 return it; |
454 return it; |
| 455 } |
455 } |
| 456 |
456 |
| 457 // ============================================================================= |
457 // ============================================================================= |
| 459 LDObject* LDObject::next() const |
459 LDObject* LDObject::next() const |
| 460 { |
460 { |
| 461 long idx = lineNumber(); |
461 long idx = lineNumber(); |
| 462 assert (idx != -1); |
462 assert (idx != -1); |
| 463 |
463 |
| 464 if (idx == (long) getFile()->getObjectCount() - 1) |
464 if (idx == (long) document()->getObjectCount() - 1) |
| 465 return null; |
465 return null; |
| 466 |
466 |
| 467 return getFile()->getObject (idx + 1); |
467 return document()->getObject (idx + 1); |
| 468 } |
468 } |
| 469 |
469 |
| 470 // ============================================================================= |
470 // ============================================================================= |
| 471 // |
471 // |
| 472 LDObject* LDObject::previous() const |
472 LDObject* LDObject::previous() const |
| 475 assert (idx != -1); |
475 assert (idx != -1); |
| 476 |
476 |
| 477 if (idx == 0) |
477 if (idx == 0) |
| 478 return null; |
478 return null; |
| 479 |
479 |
| 480 return getFile()->getObject (idx - 1); |
480 return document()->getObject (idx - 1); |
| 481 } |
481 } |
| 482 |
482 |
| 483 // ============================================================================= |
483 // ============================================================================= |
| 484 // |
484 // |
| 485 void LDObject::move (Vertex vect) |
485 void LDObject::move (Vertex vect) |
| 486 { |
486 { |
| 487 if (hasMatrix()) |
487 if (hasMatrix()) |
| 488 { |
488 { |
| 489 LDMatrixObject* mo = dynamic_cast<LDMatrixObject*> (this); |
489 LDMatrixObject* mo = dynamic_cast<LDMatrixObject*> (this); |
| 490 mo->setPosition (mo->getPosition() + vect); |
490 mo->setPosition (mo->position() + vect); |
| 491 } |
491 } |
| 492 elif (type() == LDObject::EVertex) |
492 elif (type() == LDObject::EVertex) |
| 493 { |
493 { |
| 494 // ugh |
494 // ugh |
| 495 static_cast<LDVertex*> (this)->pos += vect; |
495 static_cast<LDVertex*> (this)->pos += vect; |
| 571 |
571 |
| 572 if (idx > 0) |
572 if (idx > 0) |
| 573 { |
573 { |
| 574 LDBFC* bfc = dynamic_cast<LDBFC*> (previous()); |
574 LDBFC* bfc = dynamic_cast<LDBFC*> (previous()); |
| 575 |
575 |
| 576 if (bfc && bfc->m_statement == LDBFC::InvertNext) |
576 if (bfc && bfc->statement() == LDBFC::InvertNext) |
| 577 { |
577 { |
| 578 // This is prefixed with an invertnext, thus remove it. |
578 // This is prefixed with an invertnext, thus remove it. |
| 579 bfc->destroy(); |
579 bfc->destroy(); |
| 580 return; |
580 return; |
| 581 } |
581 } |
| 582 } |
582 } |
| 583 |
583 |
| 584 // Not inverted, thus prefix it with a new invertnext. |
584 // Not inverted, thus prefix it with a new invertnext. |
| 585 LDBFC* bfc = new LDBFC (LDBFC::InvertNext); |
585 LDBFC* bfc = new LDBFC (LDBFC::InvertNext); |
| 586 getFile()->insertObj (idx, bfc); |
586 document()->insertObj (idx, bfc); |
| 587 } |
587 } |
| 588 |
588 |
| 589 // ============================================================================= |
589 // ============================================================================= |
| 590 // |
590 // |
| 591 static void invertLine (LDObject* line) |
591 static void invertLine (LDObject* line) |
| 616 LDLine* repl = new LDLine; |
616 LDLine* repl = new LDLine; |
| 617 |
617 |
| 618 for (int i = 0; i < repl->vertices(); ++i) |
618 for (int i = 0; i < repl->vertices(); ++i) |
| 619 repl->setVertex (i, vertex (i)); |
619 repl->setVertex (i, vertex (i)); |
| 620 |
620 |
| 621 repl->setColor (getColor()); |
621 repl->setColor (color()); |
| 622 |
622 |
| 623 replace (repl); |
623 replace (repl); |
| 624 return repl; |
624 return repl; |
| 625 } |
625 } |
| 626 |
626 |
| 627 // ============================================================================= |
627 // ============================================================================= |
| 628 // |
628 // |
| 629 LDObject* LDObject::fromID (int id) |
629 LDObject* LDObject::fromID (int id) |
| 630 { |
630 { |
| 631 for (LDObject* obj : g_LDObjects) |
631 for (LDObject* obj : g_LDObjects) |
| 632 if (obj->getID() == id) |
632 if (obj->id() == id) |
| 633 return obj; |
633 return obj; |
| 634 |
634 |
| 635 return null; |
635 return null; |
| 636 } |
636 } |
| 637 |
637 |
| 638 // ============================================================================= |
638 // ============================================================================= |
| 639 // |
639 // |
| 640 QString LDOverlay::asText() const |
640 QString LDOverlay::asText() const |
| 641 { |
641 { |
| 642 return fmt ("0 !LDFORGE OVERLAY %1 %2 %3 %4 %5 %6", |
642 return fmt ("0 !LDFORGE OVERLAY %1 %2 %3 %4 %5 %6", |
| 643 getFileName(), getCamera(), getX(), getY(), getWidth(), getHeight()); |
643 fileName(), camera(), x(), y(), width(), height()); |
| 644 } |
644 } |
| 645 |
645 |
| 646 void LDOverlay::invert() {} |
646 void LDOverlay::invert() {} |
| 647 |
647 |
| 648 // ============================================================================= |
648 // ============================================================================= |
| 655 long idx; |
655 long idx; |
| 656 |
656 |
| 657 if (*ptr == val) |
657 if (*ptr == val) |
| 658 return; |
658 return; |
| 659 |
659 |
| 660 if (obj->getFile() && (idx = obj->lineNumber()) != -1) |
660 if (obj->document() && (idx = obj->lineNumber()) != -1) |
| 661 { |
661 { |
| 662 QString before = obj->asText(); |
662 QString before = obj->asText(); |
| 663 *ptr = val; |
663 *ptr = val; |
| 664 QString after = obj->asText(); |
664 QString after = obj->asText(); |
| 665 |
665 |
| 666 if (before != after) |
666 if (before != after) |
| 667 obj->getFile()->addToHistory (new EditHistory (idx, before, after)); |
667 obj->document()->addToHistory (new EditHistory (idx, before, after)); |
| 668 } |
668 } |
| 669 else |
669 else |
| 670 *ptr = val; |
670 *ptr = val; |
| 671 } |
671 } |
| 672 |
672 |
| 673 // ============================================================================= |
673 // ============================================================================= |
| 674 // |
674 // |
| 675 void LDObject::setColor (const int& val) |
675 void LDObject::setColor (const int& val) |
| 676 { |
676 { |
| 677 changeProperty (this, &m_Color, val); |
677 changeProperty (this, &m_color, val); |
| 678 } |
678 } |
| 679 |
679 |
| 680 // ============================================================================= |
680 // ============================================================================= |
| 681 // |
681 // |
| 682 const Vertex& LDObject::vertex (int i) const |
682 const Vertex& LDObject::vertex (int i) const |
| 693 |
693 |
| 694 // ============================================================================= |
694 // ============================================================================= |
| 695 // |
695 // |
| 696 void LDMatrixObject::setPosition (const Vertex& a) |
696 void LDMatrixObject::setPosition (const Vertex& a) |
| 697 { |
697 { |
| 698 changeProperty (getLinkPointer(), &m_Position, LDSharedVertex::getSharedVertex (a)); |
698 changeProperty (linkPointer(), &m_position, LDSharedVertex::getSharedVertex (a)); |
| 699 } |
699 } |
| 700 |
700 |
| 701 // ============================================================================= |
701 // ============================================================================= |
| 702 // |
702 // |
| 703 void LDMatrixObject::setTransform (const Matrix& val) |
703 void LDMatrixObject::setTransform (const Matrix& val) |
| 704 { |
704 { |
| 705 changeProperty (getLinkPointer(), &m_Transform, val); |
705 changeProperty (linkPointer(), &m_transform, val); |
| 706 } |
706 } |
| 707 |
707 |
| 708 // ============================================================================= |
708 // ============================================================================= |
| 709 // |
709 // |
| 710 static QMap<Vertex, LDSharedVertex*> g_sharedVerts; |
710 static QMap<Vertex, LDSharedVertex*> g_sharedVerts; |
| 745 |
745 |
| 746 // ============================================================================= |
746 // ============================================================================= |
| 747 // |
747 // |
| 748 void LDObject::select() |
748 void LDObject::select() |
| 749 { |
749 { |
| 750 if (!getFile()) |
750 if (!document()) |
| 751 { |
751 { |
| 752 log ("Warning: Object #%1 cannot be selected as it is not assigned a file!\n", getID()); |
752 log ("Warning: Object #%1 cannot be selected as it is not assigned a file!\n", id()); |
| 753 return; |
753 return; |
| 754 } |
754 } |
| 755 |
755 |
| 756 getFile()->addToSelection (this); |
756 document()->addToSelection (this); |
| 757 } |
757 } |
| 758 |
758 |
| 759 // ============================================================================= |
759 // ============================================================================= |
| 760 // |
760 // |
| 761 void LDObject::unselect() |
761 void LDObject::unselect() |
| 762 { |
762 { |
| 763 if (!getFile()) |
763 if (!document()) |
| 764 { |
764 { |
| 765 log ("Warning: Object #%1 cannot be unselected as it is not assigned a file!\n", getID()); |
765 log ("Warning: Object #%1 cannot be unselected as it is not assigned a file!\n", id()); |
| 766 return; |
766 return; |
| 767 } |
767 } |
| 768 |
768 |
| 769 getFile()->removeFromSelection (this); |
769 document()->removeFromSelection (this); |
| 770 } |
770 } |
| 771 |
771 |
| 772 // ============================================================================= |
772 // ============================================================================= |
| 773 // |
773 // |
| 774 QString getLicenseText (int id) |
774 QString getLicenseText (int id) |
| 775 { |
775 { |
| 776 switch (id) |
776 switch (id) |
| 777 { |
777 { |
| 778 case 0: |
778 case 0: |
| 779 return CALicense; |
779 return g_CALicense; |
| 780 |
780 |
| 781 case 1: |
781 case 1: |
| 782 return NonCALicense; |
782 return g_nonCALicense; |
| 783 |
783 |
| 784 case 2: |
784 case 2: |
| 785 return ""; |
785 return ""; |
| 786 } |
786 } |
| 787 |
787 |
| 801 copy->setSelected (false); |
801 copy->setSelected (false); |
| 802 */ |
802 */ |
| 803 |
803 |
| 804 /* |
804 /* |
| 805 LDObject* copy = getDefault (getType()); |
805 LDObject* copy = getDefault (getType()); |
| 806 copy->setColor (getColor()); |
806 copy->setColor (color()); |
| 807 |
807 |
| 808 if (hasMatrix()) |
808 if (hasMatrix()) |
| 809 { |
809 { |
| 810 LDMatrixObject* copyMo = static_cast<LDMatrixObject*> (copy); |
810 LDMatrixObject* copyMo = static_cast<LDMatrixObject*> (copy); |
| 811 const LDMatrixObject* mo = static_cast<const LDMatrixObject*> (this); |
811 const LDMatrixObject* mo = static_cast<const LDMatrixObject*> (this); |
| 812 copyMo->setPosition (mo->getPosition()); |
812 copyMo->setPosition (mo->getPosition()); |
| 813 copyMo->setTransform (mo->getTransform()); |
813 copyMo->setTransform (mo->transform()); |
| 814 } |
814 } |
| 815 else |
815 else |
| 816 { |
816 { |
| 817 for (int i = 0; i < vertices(); ++i) |
817 for (int i = 0; i < vertices(); ++i) |
| 818 copy->setVertex (getVertex (i)); |
818 copy->setVertex (getVertex (i)); |