src/linetypes/modelobject.cpp

changeset 1312
f2974f3ac1ab
parent 1306
be85306198a2
child 1313
4baed9f54de3
equal deleted inserted replaced
1311:8d22e1dd272d 1312:f2974f3ac1ab
75 QString LDError::asText() const 75 QString LDError::asText() const
76 { 76 {
77 return contents(); 77 return contents();
78 } 78 }
79 79
80 // =============================================================================
81 //
82 QString LDBfc::asText() const
83 {
84 return format ("0 BFC %1", statementToString());
85 }
86
87 int LDObject::triangleCount(DocumentManager*) const 80 int LDObject::triangleCount(DocumentManager*) const
88 { 81 {
89 return 0; 82 return 0;
90 } 83 }
91 84
322 return new LDEdgeLine {}; 315 return new LDEdgeLine {};
323 316
324 case LDObjectType::ConditionalEdge: 317 case LDObjectType::ConditionalEdge:
325 return new LDConditionalEdge {}; 318 return new LDConditionalEdge {};
326 319
327 case LDObjectType::Bfc:
328 return new LDBfc {};
329
330 case LDObjectType::Comment: 320 case LDObjectType::Comment:
331 return new LDComment {}; 321 return new LDComment {};
332 322
333 case LDObjectType::Error: 323 case LDObjectType::Error:
334 return new LDError {}; 324 return new LDError {};
426 } 416 }
427 417
428 QString LDError::contents() const 418 QString LDError::contents() const
429 { 419 {
430 return m_contents; 420 return m_contents;
431 }
432
433 LDBfc::LDBfc (const BfcStatement type) :
434 m_statement {type} {}
435
436 BfcStatement LDBfc::statement() const
437 {
438 return m_statement;
439 }
440
441 void LDBfc::setStatement (BfcStatement value)
442 {
443 m_statement = value;
444 }
445
446 QString LDBfc::statementToString() const
447 {
448 return LDBfc::statementToString (statement());
449 }
450
451 QString LDBfc::statementToString (BfcStatement statement)
452 {
453 static const char* statementStrings[] =
454 {
455 "CERTIFY CCW",
456 "CCW",
457 "CERTIFY CW",
458 "CW",
459 "NOCERTIFY",
460 "INVERTNEXT",
461 "CLIP",
462 "CLIP CCW",
463 "CLIP CW",
464 "NOCLIP",
465 };
466
467 if ((int) statement >= 0 and (int) statement < countof (statementStrings))
468 return QString::fromLatin1 (statementStrings[(int) statement]);
469 else
470 return "";
471 } 421 }
472 422
473 Vertex LDBezierCurve::pointAt (qreal t) const 423 Vertex LDBezierCurve::pointAt (qreal t) const
474 { 424 {
475 if (t >= 0.0 and t <= 1.0) 425 if (t >= 0.0 and t <= 1.0)
585 for (int i = 0; i < 9; ++i) 535 for (int i = 0; i < 9; ++i)
586 result += format("%1%2", transformationMatrix().value(i), (i != 8) ? " " : ""); 536 result += format("%1%2", transformationMatrix().value(i), (i != 8) ? " " : "");
587 537
588 result += ')'; 538 result += ')';
589 return result; 539 return result;
590 }
591
592 QString LDBfc::objectListText() const
593 {
594 return statementToString();
595 } 540 }
596 541
597 bool LDObject::isInverted() const 542 bool LDObject::isInverted() const
598 { 543 {
599 return m_hasInvertNext; 544 return m_hasInvertNext;
621 LDObject::serialize(serializer); 566 LDObject::serialize(serializer);
622 serializer << m_position; 567 serializer << m_position;
623 serializer << m_transformationMatrix; 568 serializer << m_transformationMatrix;
624 } 569 }
625 570
626 void LDBfc::serialize(Serializer& serializer)
627 {
628 LDObject::serialize(serializer);
629 serializer << m_statement;
630 }
631
632 void LDError::serialize(Serializer& serializer) 571 void LDError::serialize(Serializer& serializer)
633 { 572 {
634 LDObject::serialize(serializer); 573 LDObject::serialize(serializer);
635 serializer << m_contents; 574 serializer << m_contents;
636 serializer << m_reason; 575 serializer << m_reason;

mercurial