Changeset View
Changeset View
Standalone View
Standalone View
umbrello/umlwidgets/associationline.cpp
Context not available. | |||||
149 | * Includes start and end points. | 149 | * Includes start and end points. | ||
---|---|---|---|---|---|
150 | * @return number of points in the AssociationLine | 150 | * @return number of points in the AssociationLine | ||
151 | */ | 151 | */ | ||
152 | int AssociationLine::count() const | 152 | int AssociationLine::count() const | ||
153 | { | 153 | { | ||
154 | return m_points.size(); | 154 | return m_points.size(); | ||
155 | } | 155 | } | ||
Context not available. | |||||
524 | void AssociationLine::reconstructSymbols() | 524 | void AssociationLine::reconstructSymbols() | ||
525 | { | 525 | { | ||
526 | switch( m_associationWidget->associationType() ) { | 526 | switch( m_associationWidget->associationType() ) { | ||
527 | case Uml::AssociationType::Exception: | 527 | case Uml::AssociationType::Generalization: | ||
528 | setLayout(Uml::LayoutType::Polyline); | 528 | setToolTip(QLatin1String("<b>Generalization</b>" | ||
529 | case Uml::AssociationType::State: | 529 | "<p>A <b>Generalization</b> is an inheritance link indicating " | ||
530 | case Uml::AssociationType::Activity: | 530 | "one class is a superclass of the other and has a triangle pointing " | ||
531 | case Uml::AssociationType::UniAssociation: | 531 | "to the superclass.</p>")); | ||
532 | setStartSymbol(Symbol::None); | ||||
533 | setEndSymbol(Symbol::ClosedArrow); | ||||
534 | removeSubsetSymbol(); | ||||
535 | removeCollaborationLine(); | ||||
536 | break; | ||||
537 | | ||||
538 | case Uml::AssociationType::Aggregation: | ||||
539 | setToolTip(QLatin1String("<b>Aggregation</b>" | ||||
540 | "<p>An <b>Aggregation</b> is an association in which one " | ||||
541 | "class belongs to a collection. An aggregation has a diamond " | ||||
542 | "end pointing to the part containing the whole and can " | ||||
543 | "have either one-to-many or many-to-many multiplicity</p>")); | ||||
544 | setStartSymbol(Symbol::Diamond); | ||||
545 | setEndSymbol(Symbol::None); | ||||
546 | removeSubsetSymbol(); | ||||
547 | removeCollaborationLine(); | ||||
548 | break; | ||||
549 | | ||||
532 | case Uml::AssociationType::Dependency: | 550 | case Uml::AssociationType::Dependency: | ||
551 | setToolTip(QLatin1String("<b>Dependency</b>" | ||||
552 | "<p>A relationship between two elements in " | ||||
553 | "which a change to one element (the supplier) " | ||||
554 | "may affect or supply information needed by " | ||||
555 | "the other element (the client). This is a " | ||||
556 | "term of convenience that groups together " | ||||
557 | "several different kinds of modeling relationships.</p>")); | ||||
558 | setLayout(Uml::LayoutType::Polyline); | ||||
533 | setStartSymbol(Symbol::None); | 559 | setStartSymbol(Symbol::None); | ||
534 | setEndSymbol(Symbol::OpenArrow); | 560 | setEndSymbol(Symbol::OpenArrow); | ||
535 | removeSubsetSymbol(); | 561 | removeSubsetSymbol(); | ||
536 | removeCollaborationLine(); | 562 | removeCollaborationLine(); | ||
537 | break; | 563 | break; | ||
538 | 564 | | |||
539 | case Uml::AssociationType::Relationship: | 565 | case Uml::AssociationType::Association: | ||
566 | setToolTip(QLatin1String("<b>Association</b>" | ||||
567 | "<p>An <b>Association</b> represents a relationship between instances " | ||||
568 | "of the two classes. There is an association between two classes if an " | ||||
569 | "instance of one class must know about the other in order to perform its " | ||||
570 | "work. In a diagram, an association is a link connecting two classes.</p>")); | ||||
571 | break; | ||||
572 | | ||||
573 | case Uml::AssociationType::Association_Self: | ||||
574 | setToolTip(QLatin1String("<b>Self Association</b>" | ||||
575 | "<p>A stereotype of an association end (including link " | ||||
576 | "end and the end of an association role), specifying a " | ||||
577 | "pseudolink from an object to itself for the purpose of " | ||||
578 | "calling an operation on the same object within an " | ||||
579 | "interaction. It does not imply an actual data structure.</p>")); | ||||
580 | break; | ||||
581 | | ||||
582 | case Uml::AssociationType::Coll_Message_Asynchronous: | ||||
540 | setStartSymbol(Symbol::None); | 583 | setStartSymbol(Symbol::None); | ||
541 | setEndSymbol(Symbol::CrowFeet); | 584 | setEndSymbol(Symbol::None); | ||
542 | removeSubsetSymbol(); | 585 | removeSubsetSymbol(); | ||
543 | removeCollaborationLine(); | 586 | createCollaborationLine(); | ||
544 | break; | 587 | break; | ||
545 | 588 | | |||
546 | case Uml::AssociationType::Generalization: | 589 | case Uml::AssociationType::Seq_Message: | ||
547 | case Uml::AssociationType::Realization: | 590 | setToolTip(QLatin1String("<b>Sequence Message</b>" | ||
591 | "<p>On a sequence diagram, a message is shown as a solid " | ||||
592 | "arrow from the lifeline of one object (the sender) to the " | ||||
593 | "lifeline of another object (the target). If the arrow is " | ||||
594 | "perpendicular to the lifelines, the message transmission is " | ||||
595 | "regarded as instantaneous or at least fast, compared with " | ||||
596 | "external messages. If the arrow is slanted, then the message " | ||||
597 | "transmission is regarded as having duration, during which other " | ||||
598 | "messages might be sent. In case of a message from an object to " | ||||
599 | "itself, the arrow may start and finish on the same lifeline.</p>")); | ||||
600 | break; | ||||
601 | | ||||
602 | case Uml::AssociationType::Coll_Message_Self: | ||||
603 | setToolTip(QLatin1String("<b>Call Message</b>" | ||||
604 | "<p>A transition in which the source state " | ||||
605 | "and the target state are the same. It is " | ||||
606 | "considered a state change. When it fires, " | ||||
607 | "the source state is exited and reentered so " | ||||
608 | "exit actions and entry actions are invoked. " | ||||
609 | "It is not equivalent to an internal transition, " | ||||
610 | "in which no change of state occurs.</p>")); | ||||
548 | setStartSymbol(Symbol::None); | 611 | setStartSymbol(Symbol::None); | ||
549 | setEndSymbol(Symbol::ClosedArrow); | 612 | setEndSymbol(Symbol::None); | ||
613 | removeSubsetSymbol(); | ||||
614 | createCollaborationLine(); | ||||
615 | break; | ||||
616 | | ||||
617 | case Uml::AssociationType::Seq_Message_Self: | ||||
618 | setToolTip(QLatin1String("<b>Seq_Message_Self</b>")); | ||||
619 | break; | ||||
620 | | ||||
621 | case Uml::AssociationType::Containment: | ||||
622 | setToolTip(QLatin1String("<b>Containment</b>" | ||||
623 | "<p>An object that exists to contain other " | ||||
624 | "objects, and which provides operations to " | ||||
625 | "access or iterate over its contents, or a " | ||||
626 | "class describing such objects. For example, " | ||||
627 | "arrays, lists, and sets.</p>")); | ||||
628 | setStartSymbol(Symbol::Circle); | ||||
629 | setEndSymbol(Symbol::None); | ||||
550 | removeSubsetSymbol(); | 630 | removeSubsetSymbol(); | ||
551 | removeCollaborationLine(); | 631 | removeCollaborationLine(); | ||
552 | break; | 632 | break; | ||
553 | 633 | | |||
554 | case Uml::AssociationType::Composition: | 634 | case Uml::AssociationType::Composition: | ||
555 | case Uml::AssociationType::Aggregation: | 635 | setToolTip(QLatin1String("<b>Composition</b>" | ||
636 | "<p>A form of aggregation association with strong " | ||||
637 | "ownership and coincident lifetime of parts by the " | ||||
638 | "whole. A part may belong to only one composite.</p>")); | ||||
556 | setStartSymbol(Symbol::Diamond); | 639 | setStartSymbol(Symbol::Diamond); | ||
557 | setEndSymbol(Symbol::None); | 640 | setEndSymbol(Symbol::None); | ||
558 | removeSubsetSymbol(); | 641 | removeSubsetSymbol(); | ||
559 | removeCollaborationLine(); | 642 | removeCollaborationLine(); | ||
560 | break; | 643 | break; | ||
561 | 644 | | |||
562 | case Uml::AssociationType::Containment: | 645 | case Uml::AssociationType::Realization: | ||
563 | setStartSymbol(Symbol::Circle); | 646 | setToolTip(QLatin1String("<b>Realization</b>" | ||
564 | setEndSymbol(Symbol::None); | 647 | "<p>The relationship between a specification " | ||
648 | "and its implementation; an indication of the " | ||||
649 | "inheritance of behavior without the inheritance " | ||||
650 | "of structure.</p>")); | ||||
651 | setStartSymbol(Symbol::None); | ||||
652 | setEndSymbol(Symbol::ClosedArrow); | ||||
653 | removeSubsetSymbol(); | ||||
654 | removeCollaborationLine(); | ||||
655 | break; | ||||
656 | | ||||
657 | case Uml::AssociationType::UniAssociation: | ||||
658 | setToolTip(QLatin1String("<b>UniAssociation</b>" | ||||
659 | "<p>Is a single directed arrow from a single source " | ||||
660 | "and terminating on a single target. The association " | ||||
661 | "only runs one direction.</p>")); | ||||
662 | setLayout(Uml::LayoutType::Polyline); | ||||
663 | setStartSymbol(Symbol::None); | ||||
664 | setEndSymbol(Symbol::OpenArrow); | ||||
665 | removeSubsetSymbol(); | ||||
666 | removeCollaborationLine(); | ||||
667 | break; | ||||
668 | | ||||
669 | case Uml::AssociationType::Anchor: | ||||
670 | setToolTip(QLatin1String("<b>Anchor</b>" | ||||
671 | "<p>An anchor association that allows the modeller to tie or " | ||||
672 | "associate a note object with another object.</p>")); | ||||
673 | break; | ||||
674 | | ||||
675 | case Uml::AssociationType::State: | ||||
676 | setToolTip(QLatin1String("<b>State Transition</b>" | ||||
677 | "<p>A Transition is a single directed arrow " | ||||
678 | "originating from a single source and " | ||||
679 | "terminating on a single target</p>")); | ||||
680 | setLayout(Uml::LayoutType::Polyline); | ||||
681 | setStartSymbol(Symbol::None); | ||||
682 | setEndSymbol(Symbol::OpenArrow); | ||||
683 | removeSubsetSymbol(); | ||||
684 | removeCollaborationLine(); | ||||
685 | break; | ||||
686 | | ||||
687 | case Uml::AssociationType::Activity: | ||||
688 | setToolTip(QLatin1String("<b>Activity</b>" | ||||
689 | "<p>An activity is a coordinated " | ||||
690 | "set of actions</p>")); | ||||
691 | setLayout(Uml::LayoutType::Polyline); | ||||
692 | setStartSymbol(Symbol::None); | ||||
693 | setEndSymbol(Symbol::OpenArrow); | ||||
694 | removeSubsetSymbol(); | ||||
695 | removeCollaborationLine(); | ||||
696 | break; | ||||
697 | | ||||
698 | case Uml::AssociationType::Exception: | ||||
699 | setToolTip(QLatin1String("<b>Exception</b>" | ||||
700 | "<p>A signal raised in response to behavioral " | ||||
701 | "faults by the underlying execution machinery.</p>")); | ||||
702 | setLayout(Uml::LayoutType::Polyline); | ||||
703 | setStartSymbol(Symbol::None); | ||||
704 | setEndSymbol(Symbol::OpenArrow); | ||||
565 | removeSubsetSymbol(); | 705 | removeSubsetSymbol(); | ||
566 | removeCollaborationLine(); | 706 | removeCollaborationLine(); | ||
567 | break; | 707 | break; | ||
568 | 708 | | |||
709 | case Uml::AssociationType::Category2Parent: | ||||
710 | setToolTip(QLatin1String("<b>Category to Parent</b>" | ||||
711 | "<p></p>")); | ||||
712 | break; | ||||
713 | | ||||
569 | case Uml::AssociationType::Child2Category: | 714 | case Uml::AssociationType::Child2Category: | ||
715 | setToolTip(QLatin1String("<b>Child to Category</b>" | ||||
716 | "<p></p>")); | ||||
570 | setStartSymbol(Symbol::None); | 717 | setStartSymbol(Symbol::None); | ||
571 | setEndSymbol(Symbol::None); | 718 | setEndSymbol(Symbol::None); | ||
572 | createSubsetSymbol(); | 719 | createSubsetSymbol(); | ||
573 | removeCollaborationLine(); | 720 | removeCollaborationLine(); | ||
574 | break; | 721 | break; | ||
575 | 722 | | |||
723 | case Uml::AssociationType::Relationship: | ||||
724 | setToolTip(QLatin1String("<b>Relationship</b>" | ||||
725 | "<p>An abstract semantic connection among model elements. " | ||||
726 | "Kinds of relationships include association, generalization, " | ||||
727 | "metarelationship, flow, and several kinds grouped under dependency.</p>")); | ||||
728 | setStartSymbol(Symbol::None); | ||||
729 | setEndSymbol(Symbol::CrowFeet); | ||||
730 | removeSubsetSymbol(); | ||||
731 | removeCollaborationLine(); | ||||
732 | break; | ||||
733 | | ||||
576 | case Uml::AssociationType::Coll_Message_Synchronous: | 734 | case Uml::AssociationType::Coll_Message_Synchronous: | ||
577 | case Uml::AssociationType::Coll_Message_Asynchronous: | | |||
578 | case Uml::AssociationType::Coll_Message_Self: | | |||
579 | setStartSymbol(Symbol::None); | 735 | setStartSymbol(Symbol::None); | ||
580 | setEndSymbol(Symbol::None); | 736 | setEndSymbol(Symbol::None); | ||
581 | removeSubsetSymbol(); | 737 | removeSubsetSymbol(); | ||
Context not available. | |||||
869 | QPointF c1, c2; | 1025 | QPointF c1, c2; | ||
870 | QPointF p1 = m_points.first(); // start point | 1026 | QPointF p1 = m_points.first(); // start point | ||
871 | QPointF p2 = m_points.last(); // end point | 1027 | QPointF p2 = m_points.last(); // end point | ||
872 | 1028 | | |||
873 | if (m_autoLayoutSpline) { | 1029 | if (m_autoLayoutSpline) { | ||
874 | qreal dx = p2.x() - p1.x(); | 1030 | qreal dx = p2.x() - p1.x(); | ||
875 | qreal dy = p2.y() - p1.y(); | 1031 | qreal dy = p2.y() - p1.y(); | ||
Context not available. | |||||
893 | c2dx = 0; | 1049 | c2dx = 0; | ||
894 | c2dy = -oneHalfY; | 1050 | c2dy = -oneHalfY; | ||
895 | } | 1051 | } | ||
896 | 1052 | | |||
897 | c1 = QPointF(p1.x() + c1dx, // control point 1 | 1053 | c1 = QPointF(p1.x() + c1dx, // control point 1 | ||
898 | p1.y() + c1dy); | 1054 | p1.y() + c1dy); | ||
899 | c2 = QPointF(p2.x() + c2dx, // control point 2 | 1055 | c2 = QPointF(p2.x() + c2dx, // control point 2 | ||
Context not available. | |||||
901 | } else { | 1057 | } else { | ||
902 | //c1 = m_points[1]; | 1058 | //c1 = m_points[1]; | ||
903 | //c2 = m_points[2]; | 1059 | //c2 = m_points[2]; | ||
904 | 1060 | | |||
905 | //c1dx = c1.x() - p1.x(); | 1061 | //c1dx = c1.x() - p1.x(); | ||
906 | //c1dy = c1.y() - p1.y(); | 1062 | //c1dy = c1.y() - p1.y(); | ||
907 | //c2dx = c2.x() - p2.x(); | 1063 | //c2dx = c2.x() - p2.x(); | ||
908 | //c2dy = c2.y() - p2.y(); | 1064 | //c2dy = c2.y() - p2.y(); | ||
909 | 1065 | | |||
910 | c1 = QPointF(p1.x() + c1dx, // control point 1 | 1066 | c1 = QPointF(p1.x() + c1dx, // control point 1 | ||
911 | p1.y() + c1dy); | 1067 | p1.y() + c1dy); | ||
912 | c2 = QPointF(p2.x() + c2dx, // control point 2 | 1068 | c2 = QPointF(p2.x() + c2dx, // control point 2 | ||
Context not available. | |||||
1074 | painter->drawRect(circle); | 1230 | painter->drawRect(circle); | ||
1075 | } | 1231 | } | ||
1076 | } | 1232 | } | ||
1077 | 1233 | | |||
1078 | //circle.moveCenter(savedStart); | 1234 | //circle.moveCenter(savedStart); | ||
1079 | //painter->drawRect(circle); | 1235 | //painter->drawRect(circle); | ||
1080 | 1236 | | |||
1081 | // draw bezier handles | 1237 | // draw bezier handles | ||
1082 | if (m_layout == Uml::LayoutType::Spline) { | 1238 | if (m_layout == Uml::LayoutType::Spline) { | ||
1083 | for (int i = 2; i < sz-1; ++i) { | 1239 | for (int i = 2; i < sz-1; ++i) { | ||
Context not available. | |||||
1085 | // if(m_layout == Uml::LayoutType::Spline) { | 1241 | // if(m_layout == Uml::LayoutType::Spline) { | ||
1086 | QLineF mysegmentLine(savedStart, m_points[i-1]); | 1242 | QLineF mysegmentLine(savedStart, m_points[i-1]); | ||
1087 | painter->drawLine(mysegmentLine); | 1243 | painter->drawLine(mysegmentLine); | ||
1088 | 1244 | | |||
1089 | QLineF mysegmentLine2(m_points[i], savedEnd); | 1245 | QLineF mysegmentLine2(m_points[i], savedEnd); | ||
1090 | painter->drawLine(mysegmentLine2); | 1246 | painter->drawLine(mysegmentLine2); | ||
1091 | } | 1247 | } | ||
1092 | } | 1248 | } | ||
1093 | 1249 | | |||
1094 | circle.moveCenter(savedEnd); | 1250 | circle.moveCenter(savedEnd); | ||
1095 | painter->drawRect(circle); | 1251 | painter->drawRect(circle); | ||
1096 | 1252 | | |||
Context not available. | |||||
1111 | painter->drawLine(segmentLine); | 1267 | painter->drawLine(segmentLine); | ||
1112 | } | 1268 | } | ||
1113 | } | 1269 | } | ||
1114 | 1270 | | |||
1115 | // debug info | 1271 | // debug info | ||
1116 | if (Tracer::instance()->isEnabled(QString::fromLatin1(metaObject()->className()))) { | 1272 | if (Tracer::instance()->isEnabled(QString::fromLatin1(metaObject()->className()))) { | ||
1117 | QPen p(Qt::green); | 1273 | QPen p(Qt::green); | ||
Context not available. |