Commit 3d198497 authored by Ralf Habacker's avatar Ralf Habacker

Add UML2 support for "required interface" associations

With UML2 a "required interface" association is created by adding a
normal association from the interface to the component, wherein adding
an association from the component to the interface creates a "provided
interface".

With UML1, according to current research, there is no visible label for
a required interface mapping. This behavior has been corrected.

CCBUG:115269
CCBUG:403808
(cherry picked from commit 48ae6b8e)
parent d52b27b1
This diff is collapsed.
......@@ -42,6 +42,7 @@ public:
static Uml::AssociationType::Enum isGeneralisationOrRealisation(UMLWidget* widgetA, UMLWidget* widgetB);
typedef enum {All, Java} Language;
typedef enum {Any, UML1, UML2 } Level;
private:
class Assoc_Rule { ///< Structure to help determine association rules.
......@@ -55,6 +56,7 @@ private:
bool multiplicity; ///< multipliciy text on association
bool bidirectional; ///< can have an association of same type going between widget each way
bool self; ///< association to self
Level level; ///< UML level
};
static Assoc_Rule m_AssocRules[]; ///< Container that holds all the rules.
......
......@@ -908,9 +908,31 @@ void ClassifierWidget::drawAsCircle(QPainter *painter, const QStyleOptionGraphic
Q_UNUSED(option);
const int w = width();
bool showProvider = associationWidgetList().size() == 0;
bool showRequired = false;
AssociationWidgetList requiredAssocs;
foreach (AssociationWidget *aw, associationWidgetList()) {
const Uml::AssociationType::Enum aType = aw->associationType();
UMLWidget *otherEnd = aw->widgetForRole(Uml::RoleType::A);
UMLWidget *thisEnd = aw->widgetForRole(Uml::RoleType::B);
if (aType == Uml::AssociationType::UniAssociation ||
aType == Uml::AssociationType::Association) {
if (otherEnd->baseType() == WidgetBase::wt_Component ||
otherEnd->baseType() == WidgetBase::wt_Port) // provider
showProvider = true;
else if (thisEnd->baseType() == WidgetBase::wt_Component ||
thisEnd->baseType() == WidgetBase::wt_Port) {
showRequired = true;
requiredAssocs.push_back(aw);
}
}
}
if (associationWidgetList().size() > 1) {
if (showProvider || !showRequired)
painter->drawEllipse(w/2 - CIRCLE_SIZE/2, SOCKET_INCREMENT / 2, CIRCLE_SIZE, CIRCLE_SIZE);
if (showRequired) {
// Draw socket for required interface.
const qreal angleSpan = 180; // 360.0 / (m_Assocs.size() + 1.0);
const int arcDiameter = CIRCLE_SIZE + SOCKET_INCREMENT;
......@@ -918,16 +940,8 @@ void ClassifierWidget::drawAsCircle(QPainter *painter, const QStyleOptionGraphic
const QPointF center(x() + w/2, y() + arcDiameter/2);
const qreal cX = center.x();
const qreal cY = center.y();
foreach (AssociationWidget *aw, associationWidgetList()) {
const Uml::AssociationType::Enum aType = aw->associationType();
if (aType == Uml::AssociationType::UniAssociation ||
aType == Uml::AssociationType::Association) // provider
continue;
UMLWidget *otherEnd = aw->widgetForRole(Uml::RoleType::A);
const WidgetBase::WidgetType oType = otherEnd->baseType();
if (oType != WidgetBase::wt_Component && oType != WidgetBase::wt_Port)
continue;
foreach (AssociationWidget *aw, requiredAssocs) {
AssociationLine *assocLine = aw->associationLine();
const QPointF p(assocLine->endPoint());
const qreal tolerance = 18.0;
......@@ -966,8 +980,6 @@ void ClassifierWidget::drawAsCircle(QPainter *painter, const QStyleOptionGraphic
}
}
}
else
painter->drawEllipse(w/2 - CIRCLE_SIZE/2, 0, CIRCLE_SIZE, CIRCLE_SIZE);
}
/**
......@@ -977,8 +989,7 @@ void ClassifierWidget::drawAsCircle(QPainter *painter, const QStyleOptionGraphic
QSize ClassifierWidget::calculateAsCircleSize() const
{
int circleSize = CIRCLE_SIZE;
if (associationWidgetList().size() > 1)
circleSize += SOCKET_INCREMENT;
circleSize += SOCKET_INCREMENT;
return QSize(circleSize, circleSize);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment