[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [umbrello/_associationline_refactoring_] umbrello: Association class for the association fixed.
From:       Andi Fischer <andi.fischer () hispeed ! ch>
Date:       2013-08-07 7:41:19
Message-ID: E1V6yMx-0000he-Oo () scm ! kde ! org
[Download RAW message or body]

Git commit bb4b094d7f00470997ffbdd75f26f7c9a634832f by Andi Fischer.
Committed on 07/08/2013 at 07:39.
Pushed by fischer into branch '_associationline_refactoring_'.

Association class for the association fixed.
Params and variables from int to qreal changed.
Some unnecessary includes removed.
Debug info improved.
Code format adapted to style.

M  +1    -7    umbrello/controller/objectwidgetcontroller.cpp
M  +3    -2    umbrello/umlscene.cpp
M  +16   -15   umbrello/widgets/associationline.cpp
M  +290  -303  umbrello/widgets/associationwidget.cpp
M  +14   -23   umbrello/widgets/associationwidget.h
M  +7    -7    umbrello/widgets/umlwidget.cpp
M  +3    -3    umbrello/widgets/umlwidget.h
M  +17   -18   umbrello/widgets/widget_utils.cpp
M  +6    -6    umbrello/widgets/widget_utils.h

http://commits.kde.org/umbrello/bb4b094d7f00470997ffbdd75f26f7c9a634832f

diff --git a/umbrello/controller/objectwidgetcontroller.cpp \
b/umbrello/controller/objectwidgetcontroller.cpp index ae95c56..ef461d3 100644
--- a/umbrello/controller/objectwidgetcontroller.cpp
+++ b/umbrello/controller/objectwidgetcontroller.cpp
@@ -4,7 +4,7 @@
  *   the Free Software Foundation; either version 2 of the License, or     *
  *   (at your option) any later version.                                   *
  *                                                                         *
- *   copyright (C) 2006-2011                                               *
+ *   copyright (C) 2006-2013                                               *
  *   Umbrello UML Modeller Authors <uml-devel@uml.sf.net>                  *
  ***************************************************************************/
 
@@ -15,15 +15,9 @@
 #include "objectwidget.h"
 #include "seqlinewidget.h"
 #include "uml.h"
-#include "umldoc.h"
 #include "umlscene.h"
-#include "umlview.h"
 #include "umlwidget.h"
 #include "umlwidgetlist.h"
-#include "umlobject.h"
-#include "classifierwidget.h"
-#include "associationwidget.h"
-#include "messagewidget.h"
 
 // kde includes
 #include <kcursor.h>
diff --git a/umbrello/umlscene.cpp b/umbrello/umlscene.cpp
index 240e222..49d72a1 100644
--- a/umbrello/umlscene.cpp
+++ b/umbrello/umlscene.cpp
@@ -841,8 +841,9 @@ void UMLScene::mousePressEvent(QGraphicsSceneMouseEvent* event)
         AssociationWidget* association = associationAt(event->scenePos());
         if (association) {
             DEBUG(DBG_SRC) << "association widget = " << association->name() << " / \
                type = " << association->baseTypeStr();
-            showDocumentation(association, true);
-            event->accept();
+            // the following is done in AssociationWidget::setSelected()
+            // showDocumentation(association, true);
+            // event->accept();
         }
         //:TODO: else if (clicking on other elements with documentation) {
         //:TODO: showDocumentation(umlObject, true);
diff --git a/umbrello/widgets/associationline.cpp \
b/umbrello/widgets/associationline.cpp index a869218..b4f5c25 100644
--- a/umbrello/widgets/associationline.cpp
+++ b/umbrello/widgets/associationline.cpp
@@ -999,8 +999,8 @@ QPainterPath \
AssociationLine::createOrthogonalPath(QVector<QPointF> points)  QPointF end    = \
points.last();  qreal deltaX = abs(start.x() - end.x());
         qreal deltaY = abs(start.y() - end.y());
-        DEBUG("AssociationLine") << "start=" << start << " / end=" << end
-                       << " / deltaX=" << deltaX << " / deltaY=" << deltaY;
+        // DEBUG("AssociationLine") << "start=" << start << " / end=" << end
+        //               << " / deltaX=" << deltaX << " / deltaY=" << deltaY;
         QVector<QPointF> vector;
         for (int i = 0; i < points.size() - 1; ++i) {
             QPointF curr = points.at(i);
@@ -1085,29 +1085,29 @@ void AssociationLine::paint(QPainter* painter, const \
QStyleOptionGraphicsItem* o  
         // set color for selected painting
         _pen.setColor(Qt::blue);
-        QRectF ellipse(0, 0, SelectedPointDiameter, SelectedPointDiameter);
+        QRectF circle(0, 0, SelectedPointDiameter, SelectedPointDiameter);
         painter->setBrush(_pen.color());
         painter->setPen(Qt::NoPen);
 
         // draw points
-        ellipse.moveCenter(savedStart);
-        painter->drawRect(ellipse);
+        circle.moveCenter(savedStart);
+        painter->drawRect(circle);
         for (int i = 1; i < sz-1; ++i) {
             if (i != m_activePointIndex) {
-                ellipse.moveCenter(m_points.at(i));
-                painter->drawRect(ellipse);
+                circle.moveCenter(m_points.at(i));
+                painter->drawRect(circle);
             }
         }
-        ellipse.moveCenter(savedEnd);
-        painter->drawRect(ellipse);
+        circle.moveCenter(savedEnd);
+        painter->drawRect(circle);
 
         if (m_activePointIndex != -1) {
             painter->setBrush(invertedColor);
             painter->setPen(Qt::NoPen);
-            ellipse.setWidth(1.5*SelectedPointDiameter);
-            ellipse.setHeight(1.5*SelectedPointDiameter);
-            ellipse.moveCenter(m_points.at(m_activePointIndex));
-            painter->drawEllipse(ellipse);
+            circle.setWidth(1.5*SelectedPointDiameter);
+            circle.setHeight(1.5*SelectedPointDiameter);
+            circle.moveCenter(m_points.at(m_activePointIndex));
+            painter->drawEllipse(circle);
         }
         else if (m_activeSegmentIndex != -1) {
             painter->setPen(QPen(invertedColor, _pen.widthF() + 1));
@@ -1117,12 +1117,13 @@ void AssociationLine::paint(QPainter* painter, const \
QStyleOptionGraphicsItem* o  painter->drawLine(segmentLine);
         }
 
+        // debug info
         if (Tracer::instance()->isEnabled(metaObject()->className())) {
-            QPen p(Qt::green);
-            painter->setPen(p);
+            painter->setPen(Qt::green);
             painter->setBrush(Qt::NoBrush);
             //painter->drawPath(shape());
             painter->drawRect(shape().boundingRect());
+            painter->setPen(Qt::red);
             painter->drawRect(boundingRect());
         }
     }
diff --git a/umbrello/widgets/associationwidget.cpp \
b/umbrello/widgets/associationwidget.cpp index 103ec52..b698dd5 100644
--- a/umbrello/widgets/associationwidget.cpp
+++ b/umbrello/widgets/associationwidget.cpp
@@ -1342,8 +1342,7 @@ bool AssociationWidget::isPointAddable()
 {
     if (!m_selected || associationType() == Uml::AssociationType::Exception)
         return false;
-    QPointF scenePos = m_eventScenePos;
-    int i = m_associationLine->closestPointIndex(scenePos);
+    int i = m_associationLine->closestPointIndex(m_eventScenePos);
     return i == -1;
 }
 
@@ -1358,8 +1357,7 @@ bool AssociationWidget::isPointRemovable()
 {
     if (!m_selected || associationType() == Uml::AssociationType::Exception || \
m_associationLine->count() <= 2)  return false;
-    QPointF scenePos = m_eventScenePos;
-    int i = m_associationLine->closestPointIndex(scenePos);
+    int i = m_associationLine->closestPointIndex(m_eventScenePos);
     return i > 0 && i < m_associationLine->count() - 1;
 }
 
@@ -1600,8 +1598,8 @@ void AssociationWidget::moveEvent(QGraphicsSceneMouseEvent *me)
     }
 
     if (m_nameWidget) {
-        if (movingPoint == (int)m_unNameLineSegment ||
-                movingPoint - 1 == (int)m_unNameLineSegment) {
+        if (movingPoint == m_unNameLineSegment ||
+                movingPoint - 1 == m_unNameLineSegment) {
             setTextPositionRelatively(TextRole::Name, oldNamePoint);
         }
     }
@@ -1612,8 +1610,11 @@ void AssociationWidget::moveEvent(QGraphicsSceneMouseEvent \
*me)  if (m_role[RoleType::B].roleWidget) {
         setTextPositionRelatively(TextRole::RoleBName, oldRoleBPoint);
     }
-}
 
+    if (m_pAssocClassLine) {
+        computeAssocClassLine();
+    }
+}
 
 /**
  * Calculates and sets the first and last point in the Association's \
AssociationLine. @@ -1655,7 +1656,7 @@ void \
AssociationWidget::calculateEndingPoints()  return;
 
     int size = m_associationLine->count();
-    if(size < 2)
+    if (size < 2)
         m_associationLine->setEndPoints(pWidgetA->pos(), pWidgetB->pos());
 
     // See if an association to self.
@@ -1665,12 +1666,12 @@ void AssociationWidget::calculateEndingPoints()
     // This only happens on first time through that we are worried about.
     if (pWidgetA == pWidgetB && size < 4) {
         const int DISTANCE = 50;
-        int x = pWidgetA->x();
-        int y = pWidgetA->y();
-        int h = pWidgetA->height();
-        int w = pWidgetA->width();
+        qreal x = pWidgetA->x();
+        qreal y = pWidgetA->y();
+        qreal h = pWidgetA->height();
+        qreal w = pWidgetA->width();
         //see if above widget ok to start
-        if( y - DISTANCE > 0 ) {
+        if ( y - DISTANCE > 0 ) {
             m_associationLine->setEndPoints( QPointF( x + w / 4, y ) , QPointF( x + \
                w * 3 / 4, y ) );
             m_associationLine->insertPoint( 1, QPointF( x + w / 4, y - DISTANCE ) );
             m_associationLine->insertPoint( 2 ,QPointF( x + w * 3 / 4, y - DISTANCE \
) ); @@ -1685,15 +1686,15 @@ void AssociationWidget::calculateEndingPoints()
     }//end a == b
 
     if (associationType() == AssociationType::Exception && size < 4) {
-        int xa = pWidgetA->x();
-        int ya = pWidgetA->y();
-        int ha = pWidgetA->height();
-        int wa = pWidgetA->width();
+        qreal xa = pWidgetA->x();
+        qreal ya = pWidgetA->y();
+        qreal ha = pWidgetA->height();
+        qreal wa = pWidgetA->width();
 
-        int xb = pWidgetB->x();
-        int yb = pWidgetB->y();
-        int hb = pWidgetB->height();
-        //int wb = pWidgetB->width();
+        qreal xb = pWidgetB->x();
+        qreal yb = pWidgetB->y();
+        qreal hb = pWidgetB->height();
+        //qreal wb = pWidgetB->width();
 
         m_associationLine->setEndPoints( QPointF( xa + wa , ya + ha/2 ) , QPointF( \
                xb , yb + hb/2 ) );
         m_associationLine->insertPoint( 1, QPointF( xa + wa , ya + ha/2 ));
@@ -1703,14 +1704,14 @@ void AssociationWidget::calculateEndingPoints()
     }
     // If the line has more than one segment change the values to calculate
     // from widget to point 1.
-    int xB = pWidgetB->x() + pWidgetB->width() / 2;
-    int yB = pWidgetB->y() + pWidgetB->height() / 2;
-    if( size > 2 ) {
+    qreal xB = pWidgetB->x() + pWidgetB->width() / 2;
+    qreal yB = pWidgetB->y() + pWidgetB->height() / 2;
+    if (size > 2) {
         QPointF p = m_associationLine->point( 1 );
         xB = p.x();
         yB = p.y();
     }
-    doUpdates(xB, yB, RoleType::A);
+    doUpdates(QPointF(xB, yB), RoleType::A);
 
     // Now do the same for widgetB.
     // If the line has more than one segment change the values to calculate
@@ -1722,20 +1723,23 @@ void AssociationWidget::calculateEndingPoints()
         xA = p.x();
         yA = p.y();
     }
-    doUpdates( xA, yA, RoleType::B );
+    doUpdates(QPointF(xA, yA), RoleType::B);
 
     computeAssocClassLine();
 }
 
-void AssociationWidget::doUpdates(int otherX, int otherY, Uml::RoleType::Enum role)
+/**
+ * :TODO:
+ */
+void AssociationWidget::doUpdates(const QPointF &otherP, RoleType::Enum role)
 {
     // Find widget region.
     Uml::Region::Enum oldRegion = m_role[role].m_WidgetRegion;
     UMLWidget *pWidget = m_role[role].umlWidget;
-    QRect rc(pWidget->x(), pWidget->y(),
-             pWidget->width(), pWidget->height());
+    QRectF rc(pWidget->x(), pWidget->y(),
+              pWidget->width(), pWidget->height());
     Uml::Region::Enum region = m_role[role].m_WidgetRegion;  // alias for brevity
-    region = findPointRegion( rc, otherX, otherY);
+    region = findPointRegion(rc, otherP);
     // Move some regions to the standard ones.
     switch( region ) {
     case Uml::Region::NorthWest:
@@ -1754,17 +1758,17 @@ void AssociationWidget::doUpdates(int otherX, int otherY, \
Uml::RoleType::Enum ro  default:
         break;
     }
-    int regionCount = getRegionCount(region, role) + 2;//+2 = (1 for this one and \
one to halve it) +    int regionCount = getRegionCount(region, role) + 2; //+2 = (1 \
for this one and one to halve it)  int totalCount = m_role[role].m_nTotalCount;
-    if( oldRegion != region ) {
-        updateRegionLineCount( regionCount - 1, regionCount, region, role );
-        updateAssociations( totalCount - 1, oldRegion, role );
-    } else if( totalCount != regionCount ) {
-        updateRegionLineCount( regionCount - 1, regionCount, region, role );
+    if (oldRegion != region) {
+        updateRegionLineCount(regionCount - 1, regionCount, region, role);
+        updateAssociations(totalCount - 1, oldRegion, role);
+    } else if (totalCount != regionCount) {
+        updateRegionLineCount(regionCount - 1, regionCount, region, role);
     } else {
-        updateRegionLineCount( m_role[role].m_nIndex, totalCount, region, role );
+        updateRegionLineCount(m_role[role].m_nIndex, totalCount, region, role);
     }
-    updateAssociations( regionCount, region, role );
+    updateAssociations(regionCount, region, role);
 }
 
 /**
@@ -1778,7 +1782,7 @@ bool AssociationWidget::isActivated() const
 /**
  * Set the m_activated flag of a widget but does not perform the Activate method.
  */
-void AssociationWidget::setActivated(bool active /*=true*/)
+void AssociationWidget::setActivated(bool active)
 {
     m_activated = active;
 }
@@ -1887,7 +1891,7 @@ void AssociationWidget::saveIdealTextPositions()
 /**
  * Adjusts the ending point of the association that connects to Widget.
  */
-void AssociationWidget::widgetMoved(UMLWidget* widget, int x, int y )
+void AssociationWidget::widgetMoved(UMLWidget* widget, qreal x, qreal y )
 {
     // 2004-04-30: Achim Spangler
     // Simple Approach to block moveEvent during load of
@@ -1904,28 +1908,30 @@ void AssociationWidget::widgetMoved(UMLWidget* widget, int x, \
int y )  return;
     }
 
-    int dx = m_role[RoleType::A].umlWidget->x() - x;
-    int dy = m_role[RoleType::A].umlWidget->y() - y;
+    qreal dx = m_role[RoleType::A].umlWidget->x() - x;
+    qreal dy = m_role[RoleType::A].umlWidget->y() - y;
     int size = m_associationLine->count();
     int pos = size - 1;
     if (associationType() == AssociationType::Exception) {
         updatePointsException();
         setTextPosition( TextRole::Name );
     }
-    else
+    else {
         calculateEndingPoints();
+        computeAssocClassLine();
+    }
 
     // Assoc to self - move all points:
     if( m_role[RoleType::A].umlWidget == m_role[RoleType::B].umlWidget) {
-        for (int i = 1; i < (int)pos; ++i) {
+        for (int i = 1; i < pos; ++i) {
             QPointF p = m_associationLine->point( i );
-            int newX = p.x() - dx;
-            int newY = p.y() - dy;
+            qreal newX = p.x() - dx;
+            qreal newY = p.y() - dy;
             // safety. We DON'T want to go off the screen
-            if(newX < 0)
+            if (newX < 0)
                 newX = 0;
             // safety. We DON'T want to go off the screen
-            if(newY < 0)
+            if (newY < 0)
                 newY = 0;
             newX = m_scene->snappedX( newX );
             newY = m_scene->snappedY( newY );
@@ -2045,7 +2051,7 @@ void AssociationWidget::updatePointsException()
 }
 
 /**
- * Finds out in which region of rectangle Rect contains the Point (PosX, PosY) and \
returns the region + * Finds out in which region of rectangle 'rect' contains the \
                point 'pos' and returns the region
  * number:
  * 1 = Region 1
  * 2 = Region 2
@@ -2057,55 +2063,55 @@ void AssociationWidget::updatePointsException()
  * 8 = On diagonal 1 between Region 4 and 1
  * 9 = On diagonal 1 and On diagonal 2 (the center)
  */
-Uml::Region::Enum AssociationWidget::findPointRegion(const QRectF& Rect, int PosX, \
int PosY) +Uml::Region::Enum AssociationWidget::findPointRegion(const QRectF& rect, \
const QPointF &pos)  {
-    float w = (float)Rect.width();
-    float h = (float)Rect.height();
-    float x = (float)Rect.x();
-    float y = (float)Rect.y();
-    float Slope2 = w / h;
-    float Slope1 = Slope2*(float)(-1);
-    float b1 = x + w - ( Slope1* y );
-    float b2 = x - ( Slope2* y );
-
-    float eval1 = Slope1 * (float)PosY + b1;
-    float eval2 = Slope2  *(float)PosY + b2;
+    qreal w = rect.width();
+    qreal h = rect.height();
+    qreal x = rect.x();
+    qreal y = rect.y();
+    qreal slope2 = w / h;
+    qreal slope1 = slope2 *(-1.0);
+    qreal b1 = x + w - (slope1 * y);
+    qreal b2 = x - (slope2 * y);
+
+    qreal eval1 = slope1 * pos.y() + b1;
+    qreal eval2 = slope2 * pos.y() + b2;
 
     Uml::Region::Enum result = Uml::Region::Error;
     //if inside region 1
-    if(eval1 > PosX && eval2 > PosX) {
+    if (eval1 > pos.x() && eval2 > pos.x()) {
         result = Uml::Region::West;
     }
     //if inside region 2
-    else if (eval1 > PosX && eval2 < PosX) {
+    else if (eval1 > pos.x() && eval2 < pos.x()) {
         result = Uml::Region::North;
     }
     //if inside region 3
-    else if (eval1 < PosX && eval2 < PosX) {
+    else if (eval1 < pos.x() && eval2 < pos.x()) {
         result = Uml::Region::East;
     }
     //if inside region 4
-    else if (eval1 < PosX && eval2 > PosX) {
+    else if (eval1 < pos.x() && eval2 > pos.x()) {
         result = Uml::Region::South;
     }
     //if inside region 5
-    else if (eval1 == PosX && eval2 < PosX) {
+    else if (eval1 == pos.x() && eval2 < pos.x()) {
         result = Uml::Region::NorthWest;
     }
     //if inside region 6
-    else if (eval1 < PosX && eval2 == PosX) {
+    else if (eval1 < pos.x() && eval2 == pos.x()) {
         result = Uml::Region::NorthEast;
     }
     //if inside region 7
-    else if (eval1 == PosX && eval2 > PosX) {
+    else if (eval1 == pos.x() && eval2 > pos.x()) {
         result = Uml::Region::SouthEast;
     }
     //if inside region 8
-    else if (eval1 > PosX && eval2 == PosX) {
+    else if (eval1 > pos.x() && eval2 == pos.x()) {
         result = Uml::Region::SouthWest;
     }
     //if inside region 9
-    else if (eval1 == PosX && eval2 == PosX) {
+    else if (eval1 == pos.x() && eval2 == pos.x()) {
         result = Uml::Region::Center;
     }
     return result;
@@ -2121,29 +2127,6 @@ QPointF AssociationWidget::swapXY(const QPointF &p)
 }
 
 /**
- * Returns the total length of the association's AssociationLine:
- * result = segment_1_length + segment_2_length + ... + segment_n_length
- */
-//:TODO:
-//float AssociationWidget::totalLength()
-//{
-//    uint size = m_associationLine->count();
-//    float total_length = 0;
-
-//    for(uint i = 0; i < size - 1; ++i) {
-//        QPointF pi = m_associationLine->point( i );
-//        QPointF pj = m_associationLine->point( i+1 );
-//        int xi = pi.y();
-//        int xj = pj.y();
-//        int yi = pi.x();
-//        int yj = pj.x();
-//        total_length +=  sqrt( double(((xj - xi)*(xj - xi)) + ((yj - yi)*(yj - \
                yi))) );
-//    }
-
-//    return total_length;
-//}
-
-/**
  * Calculates which point of segment P1P2 has a distance equal to
  * Distance from P1.
  * Let's say such point is PX, the distance from P1 to PX must be equal
@@ -2714,10 +2697,8 @@ void AssociationWidget::setTextPosition(Uml::TextRole::Enum \
role)  if (ft == NULL)
         return;
     QPointF pos = calculateTextPosition(role);
-    int x = pos.x();
-    int y = pos.y();
-    ft->setX( x );
-    ft->setY( y );
+    ft->setX(pos.x());
+    ft->setY(pos.y());
 }
 
 /**
@@ -2769,14 +2750,15 @@ void \
                AssociationWidget::setTextPositionRelatively(Uml::TextRole::Enum \
                role, cons
  */
 void AssociationWidget::removeAssocClassLine()
 {
-    selectAssocClassLine(false);
-    if (m_pAssocClassLine) {
-        delete m_pAssocClassLine;
-        m_pAssocClassLine = NULL;
-    }
+    delete m_pAssocClassLineSel0;
+    m_pAssocClassLineSel0 = 0;
+    delete m_pAssocClassLineSel1;
+    m_pAssocClassLineSel1 = 0;
+    delete m_pAssocClassLine;
+    m_pAssocClassLine = 0;
     if (m_associationClass) {
-        m_associationClass->setClassAssociationWidget(NULL);
-        m_associationClass = NULL;
+        m_associationClass->setClassAssociationWidget(0);
+        m_associationClass = 0;
     }
 }
 
@@ -2786,13 +2768,17 @@ void AssociationWidget::removeAssocClassLine()
 void AssociationWidget::createAssocClassLine()
 {
     if (m_pAssocClassLine == NULL) {
-        m_pAssocClassLine = new QGraphicsLineItem;
-        m_scene->addItem(m_pAssocClassLine);
+        m_pAssocClassLine = new QGraphicsLineItem(this);
     }
-    computeAssocClassLine();
     QPen pen(lineColor(), lineWidth(), Qt::DashLine);
     m_pAssocClassLine->setPen(pen);
-    m_pAssocClassLine->setVisible(true);
+    // decoration points
+    m_pAssocClassLineSel0 = \
Widget_Utils::decoratePoint(m_pAssocClassLine->line().p1(), +                         \
m_pAssocClassLine); +    m_pAssocClassLineSel1 = \
Widget_Utils::decoratePoint(m_pAssocClassLine->line().p2(), +                         \
m_pAssocClassLine); +    computeAssocClassLine();
+    selectAssocClassLine(false);
 }
 
 /**
@@ -2821,6 +2807,9 @@ void AssociationWidget::createAssocClassLine(ClassifierWidget* \
classifier,  /**
  * Compute the end points of m_pAssocClassLine in case this
  * association has an attached association class.
+ * TODO: The end point is now at the center of the widget. Maybe it should be at
+ *       the border (edge) of it. Use 'findIntercept(...)'.
+ *       Also the decoration points make no sense now, because they are not movable.
  */
 void AssociationWidget::computeAssocClassLine()
 {
@@ -2832,44 +2821,37 @@ void AssociationWidget::computeAssocClassLine()
     }
     QPointF segStart = m_associationLine->point(m_nLinePathSegmentIndex);
     QPointF segEnd = m_associationLine->point(m_nLinePathSegmentIndex + 1);
-    const int midSegX = segStart.x() + (segEnd.x() - segStart.x()) / 2;
-    const int midSegY = segStart.y() + (segEnd.y() - segStart.y()) / 2;
-
-    QPointF segmentMidPoint(midSegX, midSegY);
-    QRectF classRectangle = m_associationClass->rect();
-    QPointF cwEdgePoint = findIntercept(classRectangle, segmentMidPoint);
-    int acwMinX = cwEdgePoint.x();
-    int acwMinY = cwEdgePoint.y();
+    const qreal midSegX = segStart.x() + (segEnd.x() - segStart.x()) / 2.0;
+    const qreal midSegY = segStart.y() + (segEnd.y() - segStart.y()) / 2.0;
 
-    m_pAssocClassLine->setLine(midSegX, midSegY, acwMinX, acwMinY);
+//:TODO:
+//    QPointF segmentMidPoint(midSegX, midSegY);
+//    QRectF classRectangle = m_associationClass->rect();
+//    QPointF cwEdgePoint = findIntercept(classRectangle, segmentMidPoint);
+//    int acwMinX = cwEdgePoint.x();
+//    int acwMinY = cwEdgePoint.y();
+    QPointF acwPos = m_associationClass->pos();
+    QRectF acwRect = m_associationClass->rect();
+
+    m_pAssocClassLine->setLine(midSegX, midSegY,
+                               acwPos.x() + acwRect.width()/2.0,
+                               acwPos.y() + acwRect.height()/2.0);
+
+    if (m_pAssocClassLineSel0 && m_pAssocClassLineSel1) {
+        m_pAssocClassLineSel0->setPos(m_pAssocClassLine->line().p1());
+        m_pAssocClassLineSel1->setPos(m_pAssocClassLine->line().p2());
+    }
 }
 
 /**
  * Renders the association class connecting line selected.
  */
-void AssociationWidget::selectAssocClassLine(bool sel /* =true */)
+void AssociationWidget::selectAssocClassLine(bool sel)
 {
-    if (!sel) {
-        if (m_pAssocClassLineSel0) {
-            delete m_pAssocClassLineSel0;
-            m_pAssocClassLineSel0 = NULL;
-        }
-        if (m_pAssocClassLineSel1) {
-            delete m_pAssocClassLineSel1;
-            m_pAssocClassLineSel1 = NULL;
-        }
-        return;
-    }
-    if (m_pAssocClassLine == NULL) {
-        uError() << "cannot select because m_pAssocClassLine is NULL";
-        return;
+    if (m_pAssocClassLineSel0 && m_pAssocClassLineSel1) {
+        m_pAssocClassLineSel0->setVisible(sel);
+        m_pAssocClassLineSel1->setVisible(sel);
     }
-    if (m_pAssocClassLineSel0)
-        delete m_pAssocClassLineSel0;
-    m_pAssocClassLineSel0 = \
                Widget_Utils::decoratePoint(m_pAssocClassLine->line().p1());
-    if (m_pAssocClassLineSel1)
-        delete m_pAssocClassLineSel1;
-    m_pAssocClassLineSel1 = \
Widget_Utils::decoratePoint(m_pAssocClassLine->line().p2());  }
 
 /**
@@ -3159,15 +3141,14 @@ bool AssociationWidget::checkAddPoint(const QPointF \
                &scenePos)
             const int midSegX = segStart.x() + (segEnd.x() - segStart.x()) / 2;
             const int midSegY = segStart.y() + (segEnd.y() - segStart.y()) / 2;
             /*
-            DEBUG(DBG_SRC) << "segStart=(" << segStart.x() << "," << segStart.y()
-                  << "), segEnd=(" << segEnd.x() << "," << segEnd.y()
-                  << "), midSeg=(" << midSegX << "," << midSegY
-                  << "), mp=(" << mp.x() << "," << mp.y() << ")";
+            DEBUG(DBG_SRC) << "segStart=" << segStart << ", segEnd=" << segEnd
+                           << ", midSeg=(" << midSegX << "," << midSegY
+                           << "), mp=" << mp;
              */
             if (midSegX > scenePos.x() || midSegY < scenePos.y()) {
                 m_nLinePathSegmentIndex++;
                 DEBUG(DBG_SRC) << "setting m_nLinePathSegmentIndex to "
-                    << m_nLinePathSegmentIndex;
+                               << m_nLinePathSegmentIndex;
                 computeAssocClassLine();
             }
             m_associationLine->update();
@@ -3221,18 +3202,6 @@ void \
AssociationWidget::mouseMoveEvent(QGraphicsSceneMouseEvent* me)  return;
     }
 
-    // if we have no moving point,create one
-//:TODO:
-//    if (m_nMovingPoint == -1) {
-//        //create moving point near the mouse on the line
-//        int i = m_associationLine->closestSegmentIndex(me->scenePos());
-
-//        if (i == -1)
-//            return;
-//        m_associationLine->insertPoint( i + 1, me->scenePos() );
-//        m_nMovingPoint = i + 1;
-//    }
-
     setSelected();
 
     // new position for point
@@ -3326,96 +3295,104 @@ int AssociationWidget::getRegionCount(Uml::Region::Enum \
region, Uml::RoleType::E  return widgetCount;
 }
 
-QPointF AssociationWidget::findIntercept(const QRectF &rect, const QPointF &point)
-{
-    Uml::Region::Enum region = findPointRegion(rect, point.x(), point.y());
-//:TODO:    /*
-    DEBUG("AssociationWidget") << "findPointRegion(rect(" << rect.x() << "," << \
                rect.y()
-                               << "," << rect.width() << "," << rect.height() << "), \
                p("
-                               << point.x() << "," << point.y() << ")) = "
-                               << Uml::Region::toString(region);
-//:TODO:     */
-    // Move some regions to the standard ones.
-    switch (region) {
-    case Uml::Region::NorthWest:
-        region = Uml::Region::North;
-        break;
-    case Uml::Region::NorthEast:
-        region = Uml::Region::East;
-        break;
-    case Uml::Region::SouthEast:
-        region = Uml::Region::South;
-        break;
-    case Uml::Region::SouthWest:
-    case Uml::Region::Center:
-        region = Uml::Region::West;
-        break;
-    default:
-        break;
-    }
-    // The Qt coordinate system has (0,0) in the top left corner.
-    // In order to go to the regular XY coordinate system with (0,0)
-    // in the bottom left corner, we swap the X and Y axis.
-    // That's why the following assignments look twisted.
-    const int rectHalfWidth = rect.height() / 2;
-    const int rectHalfHeight = rect.width() / 2;
-    const int rectMidX = rect.y() + rectHalfWidth;
-    const int rectMidY = rect.x() + rectHalfHeight;
-    const int pX = point.y();
-    const int pY = point.x();
-    const int dX = rectMidX - pX;
-    const int dY = rectMidY - pY;
-    switch (region) {
-    case Uml::Region::West:
-        region = Uml::Region::South;
-        break;
-    case Uml::Region::North:
-        region = Uml::Region::East;
-        break;
-    case Uml::Region::East:
-        region = Uml::Region::North;
-        break;
-    case Uml::Region::South:
-        region = Uml::Region::West;
-        break;
-    default:
-        break;
-    }
-    // Now we have regular coordinates with the point (0,0) in the
-    // bottom left corner.
-    if (region == Uml::Region::North || region == Uml::Region::South) {
-        int yoff = rectHalfHeight;
-        if (region == Uml::Region::North)
-            yoff = -yoff;
-        if (dX == 0) {
-            return QPointF(rectMidY + yoff, rectMidX);  // swap back X and Y
-        }
-        if (dY == 0) {
-            uError() << "usage error: " << "North/South (dY == 0)";
-            return QPointF(0,0);
-        }
-        const float m = (float)dY / (float)dX;
-        const float b = (float)pY - m * pX;
-        const int inputY = rectMidY + yoff;
-        const float outputX = ((float)inputY - b) / m;
-        return QPointF(inputY, (int)outputX);  // swap back X and Y
-    } else {
-        int xoff = rectHalfWidth;
-        if (region == Uml::Region::East)
-            xoff = -xoff;
-        if (dY == 0)
-            return QPointF(rectMidY, rectMidX + xoff);  // swap back X and Y
-        if (dX == 0) {
-            uError() << "usage error: " << "East/West (dX == 0)";
-            return QPointF(0,0);
-        }
-        const float m = (float)dY / (float)dX;
-        const float b = (float)pY - m * pX;
-        const int inputX = rectMidX + xoff;
-        const float outputY = m * (float)inputX + b;
-        return QPointF((int)outputY, inputX);  // swap back X and Y
-    }
-}
+/**
+ * Find the border point of the given rect when a line is drawn from the
+ * given point to the rect.
+ * @param rect    rect of a classifier
+ * @param point   the start point of a line to the rect
+ * @return        the intercept point on the border of the rect
+ */
+//:TODO:
+//QPointF AssociationWidget::findIntercept(const QRectF &rect, const QPointF &point)
+//{
+//    Uml::Region::Enum region = findPointRegion(rect, point);
+////:TODO:    /*
+//    DEBUG("AssociationWidget") << "findPointRegion(" << rect << ", "
+//                               << point << ") = "
+//                               << Uml::Region::toString(region);
+////:TODO:     */
+//    // Move some regions to the standard ones.
+//    switch (region) {
+//    case Uml::Region::NorthWest:
+//        region = Uml::Region::North;
+//        break;
+//    case Uml::Region::NorthEast:
+//        region = Uml::Region::East;
+//        break;
+//    case Uml::Region::SouthEast:
+//        region = Uml::Region::South;
+//        break;
+//    case Uml::Region::SouthWest:
+//    case Uml::Region::Center:
+//        region = Uml::Region::West;
+//        break;
+//    default:
+//        break;
+//    }
+//    // The Qt coordinate system has (0,0) in the top left corner.
+//    // In order to go to the regular XY coordinate system with (0,0)
+//    // in the bottom left corner, we swap the X and Y axis.
+//    // That's why the following assignments look twisted.
+//    const qreal rectHalfWidth  = rect.height() / 2.0;
+//    const qreal rectHalfHeight = rect.width() / 2.0;
+//    const qreal rectMidX = rect.y() + rectHalfWidth;
+//    const qreal rectMidY = rect.x() + rectHalfHeight;
+//    const qreal pX = point.y();
+//    const qreal pY = point.x();
+//    const qreal dX = rectMidX - pX;
+//    const qreal dY = rectMidY - pY;
+//    switch (region) {
+//    case Uml::Region::West:
+//        region = Uml::Region::South;
+//        break;
+//    case Uml::Region::North:
+//        region = Uml::Region::East;
+//        break;
+//    case Uml::Region::East:
+//        region = Uml::Region::North;
+//        break;
+//    case Uml::Region::South:
+//        region = Uml::Region::West;
+//        break;
+//    default:
+//        break;
+//    }
+//    // Now we have regular coordinates with the point (0,0) in the
+//    // bottom left corner.
+//    if (region == Uml::Region::North || region == Uml::Region::South) {
+//        qreal yoff = rectHalfHeight;
+//        if (region == Uml::Region::North)
+//            yoff = -yoff;
+//        if (dX == 0.0) {
+//            return QPointF(rectMidY + yoff, rectMidX);  // swap back X and Y
+//        }
+//        if (dY == 0.0) {
+//            uError() << "usage error: " << "North/South (dY == 0)";
+//            return QPointF();
+//        }
+//        const qreal m = dY / dX;
+//        const qreal b = pY - m * pX;
+//        const qreal inputY = rectMidY + yoff;
+//        const qreal outputX = (inputY - b) / m;
+//        return QPointF(inputY, outputX);  // swap back X and Y
+//    } else {
+//        qreal xoff = rectHalfWidth;
+//        if (region == Uml::Region::East)
+//            xoff = -xoff;
+//        if (dY == 0.0)
+//            return QPointF(rectMidY, rectMidX + xoff);  // swap back X and Y
+//        if (dX == 0.0) {
+//            uError() << "usage error: " << "East/West (dX == 0)";
+//            return QPointF();
+//        }
+//        const qreal m = dY / dX;
+//        const qreal b = pY - m * pX;
+//        const qreal inputX = rectMidX + xoff;
+//        const qreal outputY = m * inputX + b;
+//        return QPointF(outputY, inputX);  // swap back X and Y
+//    }
+//}
+
 /**
  * Given a rectangle and a point, findInterceptOnEdge computes the
  * connecting line between the middle point of the rectangle and
@@ -3427,20 +3404,20 @@ QPointF AssociationWidget::findIntercept(const QRectF &rect, \
                const QPointF &poin
  * constant.)
  * @todo This is buggy. Try replacing by findIntercept()
  */
-int AssociationWidget::findInterceptOnEdge(const QRectF &rect,
-                                           Uml::Region::Enum region,
-                                           const QPointF &point)
+qreal AssociationWidget::findInterceptOnEdge(const QRectF &rect,
+                                             Uml::Region::Enum region,
+                                             const QPointF &point)
 {
     // The Qt coordinate system has (0,0) in the top left corner.
     // In order to go to the regular XY coordinate system with (0,0)
     // in the bottom left corner, we swap the X and Y axis.
     // That's why the following assignments look twisted.
-    const int rectHalfWidth = rect.height() / 2;
-    const int rectHalfHeight = rect.width() / 2;
-    const int rectMidX = rect.y() + rectHalfWidth;
-    const int rectMidY = rect.x() + rectHalfHeight;
-    const int dX = rectMidX - point.y();
-    const int dY = rectMidY - point.x();
+    const qreal rectHalfWidth = rect.height() / 2.0;
+    const qreal rectHalfHeight = rect.width() / 2.0;
+    const qreal rectMidX = rect.y() + rectHalfWidth;
+    const qreal rectMidY = rect.x() + rectHalfHeight;
+    const qreal dX = rectMidX - point.y();
+    const qreal dY = rectMidY - point.x();
     switch (region) {
     case Uml::Region::West:
         region = Uml::Region::South;
@@ -3465,15 +3442,15 @@ int AssociationWidget::findInterceptOnEdge(const QRectF \
&rect,  // should be rectMidX, but we go back to Qt coord.sys.
         if (dY == 0) {
             uError() << "usage error: " << "North/South (dY == 0)";
-            return -1;
+            return -1.0;
         }
-        const float m = (float)dY / (float)dX;
-        float relativeX;
+        const qreal m = dY / dX;
+        qreal relativeX;
         if (region == Uml::Region::North)
-            relativeX = (float)rectHalfHeight / m;
+            relativeX = rectHalfHeight / m;
         else
-            relativeX = -(float)rectHalfHeight / m;
-        return (rectMidY + (int)relativeX);
+            relativeX = -rectHalfHeight / m;
+        return (rectMidY + relativeX);
         // should be rectMidX, but we go back to Qt coord.sys.
     } else {
         if (dY == 0)
@@ -3481,13 +3458,13 @@ int AssociationWidget::findInterceptOnEdge(const QRectF \
&rect,  // should be rectMidY, but we go back to Qt coord.sys.
         if (dX == 0) {
             uError() << "usage error: " << "East/West (dX == 0)";
-            return -1;
+            return -1.0;
         }
-        const float m = (float)dY / (float)dX;
-        float relativeY = m * (float)rectHalfWidth;
+        const qreal m = dY / dX;
+        qreal relativeY = m * rectHalfWidth;
         if (region == Uml::Region::West)
             relativeY = -relativeY;
-        return (rectMidX + (int)relativeY);
+        return (rectMidX + relativeY);
         // should be rectMidY, but we go back to Qt coord.sys.
     }
 }
@@ -3499,7 +3476,7 @@ int AssociationWidget::findInterceptOnEdge(const QRectF &rect,
  * m_positions and m_ordered move in parallel and are sorted by
  * ascending position.
  */
-void AssociationWidget::insertIntoLists(int position, const AssociationWidget* \
assoc) +void AssociationWidget::insertIntoLists(qreal position, const \
AssociationWidget* assoc)  {
     bool did_insertion = false;
     for (int index = 0; index < m_positions_len; ++index) {
@@ -3569,9 +3546,9 @@ void AssociationWidget::updateAssociations(int totalCount,
             refpoint.setX(otherWidget->x() + otherWidget->width() / 2);
             refpoint.setY(otherWidget->y() + otherWidget->height() / 2);
         }
-        int intercept = findInterceptOnEdge(ownWidget->rect(), region, refpoint);
+        qreal intercept = findInterceptOnEdge(ownWidget->rect(), region, refpoint);
         if (intercept < 0) {
-            DEBUG(DBG_SRC) << "updateAssociations: error from findInterceptOnEdge \
for" +            DEBUG(DBG_SRC) << "error from findInterceptOnEdge for"
                            << " assocType=" << assocwidget->associationType()
                            << " ownWidget=" << ownWidget->name()
                            << " otherWidget=" << otherWidget->name();
@@ -3582,7 +3559,7 @@ void AssociationWidget::updateAssociations(int totalCount,
 
     // we now have an ordered list and we only have to call updateRegionLineCount
     int index = 1;
-    foreach (AssociationWidget* assocwidget , m_ordered ) {
+    foreach (AssociationWidget* assocwidget, m_ordered ) {
         if (ownWidget == assocwidget->widgetForRole(RoleType::A)) {
             assocwidget->updateRegionLineCount(index++, totalCount, region, \
                RoleType::A);
         } else if (ownWidget == assocwidget->widgetForRole(RoleType::B)) {
@@ -3649,13 +3626,13 @@ void AssociationWidget::updateRegionLineCount(int index, int \
totalCount,  
     robj.m_nIndex = index;
     robj.m_nTotalCount = totalCount;
-    int x = pWidget->x();
-    int y = pWidget->y();
-    int ww = pWidget->width();
-    int wh = pWidget->height();
+    qreal x = pWidget->x();
+    qreal y = pWidget->y();
+    qreal ww = pWidget->width();
+    qreal wh = pWidget->height();
     const bool angular = Settings::optionState().generalState.angularlines;
-    int ch = 0;
-    int cw = 0;
+    qreal ch = 0;
+    qreal cw = 0;
     if (angular) {
         uint nind = (role == RoleType::A ? 1 : m_associationLine->count() - 2);
         QPointF neighbour = m_associationLine->point(nind);
@@ -3676,8 +3653,8 @@ void AssociationWidget::updateRegionLineCount(int index, int \
totalCount,  cw = ww * index / totalCount;
     }
 
-    int snapX = m_scene->snappedX(x + cw);
-    int snapY = m_scene->snappedY(y + ch);
+    qreal snapX = m_scene->snappedX(x + cw);
+    qreal snapY = m_scene->snappedY(y + ch);
 
     QPointF pt;
     if (angular) {
@@ -3736,29 +3713,27 @@ bool AssociationWidget::isSelected() const
 void AssociationWidget::setSelected(bool _select /* = true */)
 {
     m_selected = _select;
-    if( m_nameWidget)
+    if ( m_nameWidget)
         m_nameWidget->setSelected( _select );
-    if( m_role[RoleType::A].roleWidget )
+    if ( m_role[RoleType::A].roleWidget )
         m_role[RoleType::A].roleWidget->setSelected( _select );
-    if( m_role[RoleType::B].roleWidget )
+    if ( m_role[RoleType::B].roleWidget )
         m_role[RoleType::B].roleWidget->setSelected( _select );
-    if( m_role[RoleType::A].multiplicityWidget )
+    if ( m_role[RoleType::A].multiplicityWidget )
         m_role[RoleType::A].multiplicityWidget->setSelected( _select );
-    if( m_role[RoleType::B].multiplicityWidget )
+    if ( m_role[RoleType::B].multiplicityWidget )
         m_role[RoleType::B].multiplicityWidget->setSelected( _select );
-    if( m_role[RoleType::A].changeabilityWidget)
+    if ( m_role[RoleType::A].changeabilityWidget)
         m_role[RoleType::A].changeabilityWidget->setSelected( _select );
-    if( m_role[RoleType::B].changeabilityWidget)
+    if ( m_role[RoleType::B].changeabilityWidget)
         m_role[RoleType::B].changeabilityWidget->setSelected( _select );
 
-    // Why call the following ? It makes sense only if there is  a long operation \
                going on.
-    qApp->processEvents();
     // Update the docwindow for this association.
     // This is done last because each of the above setSelected calls
     // overwrites the docwindow, but we want the main association doc
     // to win.
-    if( _select ) {
-        if( m_scene->selectedCount() == 0 )
+    if ( _select ) {
+        if ( m_scene->selectedCount() == 0 )
                 m_scene->showDocumentation( this, false );
     } else
         m_scene->updateDocumentation( true );
@@ -3795,12 +3770,26 @@ bool AssociationWidget::onAssocClassLine(const QPointF \
&point)  }
 
 /**
- * Returns true if the given point is on the Association.
+ * Returns true if the given point is on the association line.
+ * A circle (rectangle) around the point is used to obtain more tolerance.
+ * @param point   the point to check
+ * @return   flag whether point is on association line
  */
-bool AssociationWidget::onAssociation(const QPointF & point)
+bool AssociationWidget::onAssociation(const QPointF& point)
 {
-    if (m_associationLine->closestSegmentIndex(point) != -1)
+    // check the path
+    const int diameter(4);
+    QRectF circle(point.x(), point.y(), diameter, diameter);
+    QPainterPath path = m_associationLine->shape();
+    if (path.intersects(circle)) {
         return true;
+    }
+    // check also the points
+    if (m_associationLine->layout() == AssociationLine::Spline) {
+        if (m_associationLine->closestPointIndex(point) > -1) {
+            return true;
+        }
+    }
     return onAssocClassLine(point);
 }
 
@@ -3815,13 +3804,13 @@ void AssociationWidget::slotClearAllSelected()
 /**
  * Moves all the mid points (all expcept start /end ) by the given amount.
  */
-void AssociationWidget::moveMidPointsBy( int x, int y )
+void AssociationWidget::moveMidPointsBy(qreal x, qreal y)
 {
     int pos = m_associationLine->count() - 1;
     for (int i = 1; i < (int)pos; ++i) {
         QPointF p = m_associationLine->point( i );
-        int newX = p.x() + x;
-        int newY = p.y() + y;
+        qreal newX = p.x() + x;
+        qreal newY = p.y() + y;
         newX = m_scene->snappedX( newX );
         newY = m_scene->snappedY( newY );
         p.setX( newX );
@@ -3833,10 +3822,10 @@ void AssociationWidget::moveMidPointsBy( int x, int y )
 /**
  * Moves the entire association by the given offset.
  */
-void AssociationWidget::moveEntireAssoc( int x, int y )
+void AssociationWidget::moveEntireAssoc(qreal x, qreal y)
 {
     //TODO: ADD SUPPORT FOR ASSOC. ON SEQ. DIAGRAMS WHEN NOTES BACK IN.
-    moveMidPointsBy( x, y );
+    moveMidPointsBy(x, y);
     calculateEndingPoints();
     calculateNameTextSegment();
     resetTextPositions();
@@ -4024,7 +4013,7 @@ ListPopupMenu* AssociationWidget::setupPopupMenu(ListPopupMenu \
                *menu, const QPoi
 */
 
 /**
- * :TODO:
+ * Reimplemented event handler for hover enter events.
  */
 void AssociationWidget::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
 {
@@ -4032,7 +4021,7 @@ void \
AssociationWidget::hoverEnterEvent(QGraphicsSceneHoverEvent *event)  }
 
 /**
- * :TODO:
+ * Reimplemented event handler for hover leave events.
  */
 void AssociationWidget::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
 {
@@ -4040,7 +4029,7 @@ void \
AssociationWidget::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)  }
 
 /**
- * :TODO:
+ * Reimplemented event handler for hover move events.
  */
 void AssociationWidget::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
 {
@@ -4269,11 +4258,9 @@ bool AssociationWidget::loadFromXMI(QDomElement& qElement,
         Uml::ID::Type acid = Uml::ID::fromString(assocclassid);
         UMLWidget *w = Widget_Utils::findWidget(acid, widgets);
         if (w) {
-            m_associationClass = static_cast<ClassifierWidget*>(w);
-            m_associationClass->setClassAssociationWidget(this);
-            // Preparation of the assoc class line is done in activate()
-            QString aclsegindex = qElement.attribute("aclsegindex", "0");
-            m_nLinePathSegmentIndex = aclsegindex.toInt();
+            ClassifierWidget* aclWidget = static_cast<ClassifierWidget*>(w);
+            QString aclSegIndex = qElement.attribute("aclsegindex", "0");
+            createAssocClassLine(aclWidget, aclSegIndex.toInt());
         } else {
             uError() << "cannot find assocclass " << assocclassid;
         }
diff --git a/umbrello/widgets/associationwidget.h \
b/umbrello/widgets/associationwidget.h index 0346d4d..97966c6 100644
--- a/umbrello/widgets/associationwidget.h
+++ b/umbrello/widgets/associationwidget.h
@@ -140,7 +140,7 @@ public:
     QString toString() const;
 
     bool isActivated() const;
-    void setActivated(bool active /*=true*/);
+    void setActivated(bool active);
 
     bool isSelected() const;
     void setSelected(bool _select = true);
@@ -151,7 +151,7 @@ public:
     virtual QRectF boundingRect() const;
     virtual QPainterPath shape() const;
 
-    void widgetMoved(UMLWidget* widget, int x, int y);
+    void widgetMoved(UMLWidget* widget, qreal x, qreal y);
 
     void saveIdealTextPositions();
 
@@ -166,16 +166,13 @@ public:
     void removeAssocClassLine();
     void computeAssocClassLine();
 
-    void moveMidPointsBy(int x, int y);
-    void moveEntireAssoc(int x, int y);
+    void moveMidPointsBy(qreal x, qreal y);
+    void moveEntireAssoc(qreal x, qreal y);
 
     QFont font() const;
 
     virtual void setTextColor(const QColor &color);
 
-//    void setIndex(int index, Uml::RoleType::Enum role);
-//    int getIndex(Uml::RoleType::Enum role) const;
-
     void calculateEndingPoints();
 
     void clipSize();
@@ -223,21 +220,16 @@ private:
 
     void mergeAssociationDataIntoUMLRepresentation();
 
-    static Uml::Region::Enum findPointRegion(const QRectF& Rect, int PosX, int \
                PosY);
-    static int findInterceptOnEdge(const QRectF &rect, Uml::Region::Enum region, \
                const QPointF &point);
-    static QPointF findIntercept(const QRectF &rect, const QPointF &point);
+    static Uml::Region::Enum findPointRegion(const QRectF& rect, const QPointF& \
pos); +    static qreal findInterceptOnEdge(const QRectF &rect, Uml::Region::Enum \
region, const QPointF &point); +//    static QPointF findIntercept(const QRectF \
&rect, const QPointF &point);  
     void moveEvent(QGraphicsSceneMouseEvent *me);
 
     Uml::TextRole::Enum calculateNameType(Uml::TextRole::Enum defaultRoleType);
 
-//    bool isPointInsideBoundaries(int PosX, int PosY, QPointF & SPoint,
-//                                 uint & StartSegmentIndex, uint & \
                EndSegmentIndex);
-
     static QPointF swapXY(const QPointF &p);
 
-//    float totalLength();
-
     static QPointF calculatePointAtDistance(const QPointF &P1, const QPointF &P2, \
                float Distance);
     static QPointF calculatePointAtDistanceOnPerpendicular(const QPointF &P1, const \
QPointF &P2, float Distance);  
@@ -281,7 +273,7 @@ private:
 
     int getRegionCount(Uml::Region::Enum region, Uml::RoleType::Enum role);
 
-    void doUpdates(int otherX, int otherY, Uml::RoleType::Enum role);
+    void doUpdates(const QPointF &otherP, Uml::RoleType::Enum role);
 
     void setChangeWidget(const QString &strChangeWidget, Uml::RoleType::Enum role);
 
@@ -290,9 +282,9 @@ private:
 
     bool linePathStartsAt(const UMLWidget* widget);
 
-    void insertIntoLists(int position, const AssociationWidget* assoc);
+    void insertIntoLists(qreal position, const AssociationWidget* assoc);
 
-    int m_positions[100];             ///< auxiliary variable for \
updateAssociations() +    qreal m_positions[100];           ///< auxiliary variable \
                for updateAssociations()
     int m_positions_len;              ///< auxiliary variable for \
                updateAssociations()
     AssociationWidgetList m_ordered;  ///< auxiliary variable for \
updateAssociations()  
@@ -316,11 +308,10 @@ private:
     QPointF m_oldRoleAPoint;   ///< Position of role A name floatingtext saved by \
                saveIdealTextPositions()
     QPointF m_oldRoleBPoint;   ///< Position of role B name floatingtext saved by \
saveIdealTextPositions()  
-    int m_nLinePathSegmentIndex; ///< anchor for m_pAssocClassLine
-    QGraphicsLineItem *m_pAssocClassLine;  ///< used for connecting assoc. class
-    /// selection adornment for the endpoints of the assoc. class connecting line
-    QGraphicsRectItem *m_pAssocClassLineSel0;
-    QGraphicsRectItem *m_pAssocClassLineSel1;
+    int m_nLinePathSegmentIndex;               ///< anchor for m_pAssocClassLine
+    QGraphicsLineItem *m_pAssocClassLine;      ///< used for connecting assoc. class
+    QGraphicsRectItem *m_pAssocClassLineSel0;  ///< selection decoration for the \
start point of the assoc. class line +    QGraphicsRectItem *m_pAssocClassLineSel1;  \
///< selection decoration for the end point of the assoc. class line  
     AssociationLine *m_associationLine;      ///< the definition points for the \
                association line
     ClassifierWidget *m_associationClass;    ///< used if we have an assoc. class
diff --git a/umbrello/widgets/umlwidget.cpp b/umbrello/widgets/umlwidget.cpp
index 5e59f9e..ea119e1 100644
--- a/umbrello/widgets/umlwidget.cpp
+++ b/umbrello/widgets/umlwidget.cpp
@@ -739,7 +739,7 @@ void UMLWidget::removeAssoc(AssociationWidget* pAssoc)
  * @param x The x-coordinate.
  * @param y The y-coordinate.
  */
-void UMLWidget::adjustAssocs(int x, int y)
+void UMLWidget::adjustAssocs(qreal x, qreal y)
 {
     // 2004-04-30: Achim Spangler
     // don't adjust Assocs on file load, as
@@ -770,15 +770,15 @@ void UMLWidget::adjustAssocs(int x, int y)
  * @param x The x-coordinate.
  * @param y The y-coordinate.
  */
-void UMLWidget::adjustUnselectedAssocs(int x, int y)
+void UMLWidget::adjustUnselectedAssocs(qreal x, qreal y)
 {
-    foreach(AssociationWidget* assocwidget , m_Assocs) {
+    foreach(AssociationWidget* assocwidget, m_Assocs) {
 
         if (!assocwidget->isSelected())
             assocwidget->saveIdealTextPositions();
     }
 
-    foreach(AssociationWidget* assocwidget , m_Assocs) {
+    foreach(AssociationWidget* assocwidget, m_Assocs) {
         if (!assocwidget->isSelected())
             assocwidget->widgetMoved(this, x, y);
     }
@@ -829,10 +829,10 @@ UMLSceneValue UMLWidget::onWidget(const UMLScenePoint & p)
  * Move the widget by an X and Y offset relative to
  * the current position.
  */
-void UMLWidget::moveByLocal(int dx, int dy)
+void UMLWidget::moveByLocal(qreal dx, qreal dy)
 {
-    int newX = x() + dx;
-    int newY = y() + dy;
+    qreal newX = x() + dx;
+    qreal newY = y() + dy;
     setX(newX);
     setY(newY);
     // DEBUG(DBG_SRC) << "********** x=" << newX << " / y=" << newY;
diff --git a/umbrello/widgets/umlwidget.h b/umbrello/widgets/umlwidget.h
index 57abc79..fcc2fd6 100644
--- a/umbrello/widgets/umlwidget.h
+++ b/umbrello/widgets/umlwidget.h
@@ -136,7 +136,7 @@ public:
     bool getIgnoreSnapToGrid() const;
     void setIgnoreSnapToGrid(bool to);
 
-    void moveByLocal(int dx, int dy);
+    void moveByLocal(qreal dx, qreal dy);
 
     void removeAssoc(AssociationWidget* pAssoc);
     void addAssoc(AssociationWidget* pAssoc);
@@ -183,8 +183,8 @@ public:
 
     bool isActivated();
 
-    virtual void adjustAssocs(int x, int y);
-    void adjustUnselectedAssocs(int x, int y);
+    virtual void adjustAssocs(qreal x, qreal y);
+    void adjustUnselectedAssocs(qreal x, qreal y);
 
     void setActivated(bool Active = true);
 
diff --git a/umbrello/widgets/widget_utils.cpp b/umbrello/widgets/widget_utils.cpp
index c332132..61544e2 100644
--- a/umbrello/widgets/widget_utils.cpp
+++ b/umbrello/widgets/widget_utils.cpp
@@ -15,14 +15,13 @@
 #include "debug_utils.h"
 #include "objectwidget.h"
 #include "messagewidget.h"
-#include "uml.h"
-#include "umlscene.h"
-#include "umlview.h"
 #include "umlwidget.h"
 
 // qt includes
 #include <QBuffer>
 #include <QImageReader>
+#include <QGraphicsItem>
+#include <QGraphicsRectItem>
 #include <QPolygonF>
 
 // c++ include
@@ -63,20 +62,20 @@ namespace Widget_Utils
 
     /**
      * Creates the decoration point.
-     * @param p   the base point
-     * @return    the decoration point
+     * @param p        base point to decorate
+     * @param parent   parent item
+     * @return         decoration point
      */
-    QGraphicsRectItem* decoratePoint(const UMLScenePoint& p)
+    QGraphicsRectItem* decoratePoint(const QPointF &p, QGraphicsItem* parent)
     {
-        const int SIZE = 4;
-        UMLView *currentView = UMLApp::app()->currentView();
-        QGraphicsRectItem *rect = new QGraphicsRectItem(p.x() - SIZE / 2,
-                                                        p.y() - SIZE / 2,
-                                                        SIZE, SIZE);
-        currentView->umlScene()->addItem(rect);
-        rect->setBrush( QBrush(Qt::blue) );
-        rect->setPen( QPen(Qt::blue) );
-        rect->setVisible(true);
+        const qreal SIZE = 4.0;
+        const qreal SIZE_HALF = SIZE / 2.0;
+        QGraphicsRectItem *rect = new QGraphicsRectItem(p.x() - SIZE_HALF,
+                                                        p.y() - SIZE_HALF,
+                                                        SIZE, SIZE,
+                                                        parent);
+        rect->setBrush(QBrush(Qt::blue));
+        rect->setPen(QPen(Qt::blue));
         return rect;
     }
 
@@ -127,7 +126,7 @@ namespace Widget_Utils
      * @param triSize The size of the triange in the top-right corner.
      */
     void drawTriangledRect(QPainter *painter,
-                           const UMLSceneRect& rect, const UMLSceneSize& triSize)
+                           const QRectF &rect, const QSizeF &triSize)
     {
         // Draw outer boundary defined by polygon "poly".
         QPolygonF poly(5);
@@ -139,9 +138,9 @@ namespace Widget_Utils
         painter->drawPolygon(poly);
 
         // Now draw the triangle base and height edges.
-        UMLSceneLine heightEdge(poly[1], poly[1] + QPointF(0, triSize.height()));
+        QLineF heightEdge(poly[1], poly[1] + QPointF(0, triSize.height()));
         painter->drawLine(heightEdge);
-        UMLSceneLine baseEdge(heightEdge.p2(), poly[2]);
+        QLineF baseEdge(heightEdge.p2(), poly[2]);
         painter->drawLine(baseEdge);
     }
 
diff --git a/umbrello/widgets/widget_utils.h b/umbrello/widgets/widget_utils.h
index 642bcfe..5411b30 100644
--- a/umbrello/widgets/widget_utils.h
+++ b/umbrello/widgets/widget_utils.h
@@ -13,14 +13,14 @@
 
 #include "basictypes.h"
 #include "messagewidgetlist.h"
-#include "umlscene.h"
 #include "umlwidgetlist.h"
 
 #include <QBrush>
 #include <QDomDocument>
-#include <QFont>
-#include <QPen>
-#include <QPoint>
+#include <QPointF>
+
+class QGraphicsItem;
+class QGraphicsRectItem;
 
 /**
  * General purpose widget utilities.
@@ -32,10 +32,10 @@ namespace Widget_Utils
                           const UMLWidgetList& widgets,
                           const MessageWidgetList* messages = 0);
 
-    QGraphicsRectItem* decoratePoint(const UMLScenePoint& p);
+    QGraphicsRectItem* decoratePoint(const QPointF& p, QGraphicsItem* parent = 0);
 
     void drawCrossInEllipse(QPainter *p, const QRectF& ellipse);
-    void drawTriangledRect(QPainter *painter, const UMLSceneRect& rect, const \
UMLSceneSize& triSize); +    void drawTriangledRect(QPainter *painter, const QRectF& \
rect, const QSizeF& triSize);  void drawArrowHead(QPainter *painter, const QPointF& \
arrowPos,  const QSizeF& arrowSize, Qt::ArrowType arrowType,
                        bool solid = false);


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic