214 } |
214 } |
215 |
215 |
216 // ============================================================================= |
216 // ============================================================================= |
217 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
217 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
218 // ============================================================================= |
218 // ============================================================================= |
219 static void transformObject (LDObject* obj, matrix<3> transform, vertex pos, short parentcolor) { |
219 static void transformObject (LDObject* obj, matrix transform, vertex pos, short parentcolor) { |
220 switch (obj->getType()) { |
220 switch (obj->getType()) { |
221 case LDObject::Line: |
221 case LDObject::Line: |
222 case LDObject::CondLine: |
222 case LDObject::CondLine: |
223 case LDObject::Triangle: |
223 case LDObject::Triangle: |
224 case LDObject::Quad: |
224 case LDObject::Quad: |
317 } |
317 } |
318 |
318 |
319 // ============================================================================= |
319 // ============================================================================= |
320 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
320 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
321 // ============================================================================= |
321 // ============================================================================= |
322 long LDObject::getIndex (OpenFile* pFile) { |
322 long LDObject::getIndex (OpenFile* pFile) const { |
323 for (ulong i = 0; i < pFile->m_objs.size(); ++i) |
323 for (ulong i = 0; i < pFile->m_objs.size(); ++i) |
324 if (pFile->m_objs[i] == this) |
324 if (pFile->m_objs[i] == this) |
325 return i; |
325 return i; |
326 |
326 |
327 return -1; |
327 return -1; |
394 } |
394 } |
395 |
395 |
396 // ============================================================================= |
396 // ============================================================================= |
397 LDObject* LDObject::topLevelParent () { |
397 LDObject* LDObject::topLevelParent () { |
398 if (!parent) |
398 if (!parent) |
399 return null; |
399 return this; |
400 |
400 |
401 LDObject* it = this; |
401 LDObject* it = this; |
402 |
402 |
403 while (it->parent) |
403 while (it->parent) |
404 it = it->parent; |
404 it = it->parent; |
405 |
405 |
406 return it; |
406 return it; |
407 } |
407 } |
408 |
408 |
409 |
409 // ============================================================================= |
410 // ============================================================================= |
410 LDObject* LDObject::next () const { |
411 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
411 long idx = getIndex (g_curfile); |
412 // ============================================================================= |
412 assert (idx != -1); |
413 void LDObject::move (vertex vVector) { vVector = vVector; /* to shut up GCC */ } |
413 |
414 void LDEmpty::move (vertex vVector) { vVector = vVector; } |
414 if (idx == (long) g_curfile->m_objs.size () - 1) |
415 void LDBFC::move (vertex vVector) { vVector = vVector; } |
415 return null; |
416 void LDComment::move (vertex vVector) { vVector = vVector; } |
416 |
417 void LDGibberish::move (vertex vVector) { vVector = vVector; } |
417 return g_curfile->m_objs[idx + 1]; |
418 |
418 } |
419 void LDVertex::move (vertex vVector) { |
419 |
420 pos += vVector; |
420 // ============================================================================= |
421 } |
421 LDObject* LDObject::prev () const { |
422 |
422 long idx = getIndex (g_curfile); |
423 void LDSubfile::move (vertex vVector) { |
423 assert (idx != -1); |
424 pos += vVector; |
424 |
425 } |
425 if (idx == 0) |
426 |
426 return null; |
427 void LDRadial::move (vertex vVector) { |
427 |
428 pos += vVector; |
428 return g_curfile->m_objs[idx - 1]; |
429 } |
429 } |
430 |
430 |
431 void LDLine::move (vertex vVector) { |
431 // ============================================================================= |
|
432 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
|
433 // ============================================================================= |
|
434 void LDObject::move (vertex vect) { (void) vect; } |
|
435 void LDEmpty::move (vertex vect) { (void) vect; } |
|
436 void LDBFC::move (vertex vect) { (void) vect; } |
|
437 void LDComment::move (vertex vect) { (void) vect; } |
|
438 void LDGibberish::move (vertex vect) { (void) vect; } |
|
439 |
|
440 void LDVertex::move (vertex vect) { |
|
441 pos += vect; |
|
442 } |
|
443 |
|
444 void LDSubfile::move (vertex vect) { |
|
445 pos += vect; |
|
446 } |
|
447 |
|
448 void LDRadial::move (vertex vect) { |
|
449 pos += vect; |
|
450 } |
|
451 |
|
452 void LDLine::move (vertex vect) { |
432 for (short i = 0; i < 2; ++i) |
453 for (short i = 0; i < 2; ++i) |
433 coords[i] += vVector; |
454 coords[i] += vect; |
434 } |
455 } |
435 |
456 |
436 void LDTriangle::move (vertex vVector) { |
457 void LDTriangle::move (vertex vect) { |
437 for (short i = 0; i < 3; ++i) |
458 for (short i = 0; i < 3; ++i) |
438 coords[i] += vVector; |
459 coords[i] += vect; |
439 } |
460 } |
440 |
461 |
441 void LDQuad::move (vertex vVector) { |
462 void LDQuad::move (vertex vect) { |
442 for (short i = 0; i < 4; ++i) |
463 for (short i = 0; i < 4; ++i) |
443 coords[i] += vVector; |
464 coords[i] += vect; |
444 } |
465 } |
445 |
466 |
446 void LDCondLine::move (vertex vVector) { |
467 void LDCondLine::move (vertex vect) { |
447 for (short i = 0; i < 4; ++i) |
468 for (short i = 0; i < 4; ++i) |
448 coords[i] += vVector; |
469 coords[i] += vect; |
449 } |
470 } |
450 |
471 |
451 // ============================================================================= |
472 // ============================================================================= |
452 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
473 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
453 // ============================================================================= |
474 // ============================================================================= |