Changed the association layout for the package and class diagrams.

Wed, 05 Sep 2012 19:19:16 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 05 Sep 2012 19:19:16 +0200
changeset 2024
717b72b32420
parent 2023
6636ca1adc33
child 2025
8bb085c59cd2

Changed the association layout for the package and class diagrams.

APIs/Python3/eric5.api file | annotate | diff | comparison | revisions
Documentation/Help/source.qch file | annotate | diff | comparison | revisions
Documentation/Help/source.qhp file | annotate | diff | comparison | revisions
Documentation/Source/eric5.Graphics.AssociationItem.html file | annotate | diff | comparison | revisions
Graphics/AssociationItem.py file | annotate | diff | comparison | revisions
Graphics/PackageDiagram.py file | annotate | diff | comparison | revisions
Graphics/UMLClassDiagram.py file | annotate | diff | comparison | revisions
--- a/APIs/Python3/eric5.api	Wed Sep 05 19:18:35 2012 +0200
+++ b/APIs/Python3/eric5.api	Wed Sep 05 19:19:16 2012 +0200
@@ -1619,7 +1619,7 @@
 eric5.Graphics.ApplicationDiagram.ApplicationDiagram?1(project, parent=None, name=None, noModules=False)
 eric5.Graphics.AssociationItem.AssociationItem.unassociate?4()
 eric5.Graphics.AssociationItem.AssociationItem.widgetMoved?4()
-eric5.Graphics.AssociationItem.AssociationItem?1(itemA, itemB, type=Normal, parent=None)
+eric5.Graphics.AssociationItem.AssociationItem?1(itemA, itemB, type=Normal, topToBottom=False, parent=None)
 eric5.Graphics.AssociationItem.Center?7
 eric5.Graphics.AssociationItem.East?7
 eric5.Graphics.AssociationItem.Generalisation?7
Binary file Documentation/Help/source.qch has changed
--- a/Documentation/Help/source.qhp	Wed Sep 05 19:18:35 2012 +0200
+++ b/Documentation/Help/source.qhp	Wed Sep 05 19:19:16 2012 +0200
@@ -1301,6 +1301,7 @@
       <keyword name="AssociationItem (Module)" id="AssociationItem (Module)" ref="eric5.Graphics.AssociationItem.html" />
       <keyword name="AssociationItem.__calculateEndingPoints_center" id="AssociationItem.__calculateEndingPoints_center" ref="eric5.Graphics.AssociationItem.html#AssociationItem.__calculateEndingPoints_center" />
       <keyword name="AssociationItem.__calculateEndingPoints_rectangle" id="AssociationItem.__calculateEndingPoints_rectangle" ref="eric5.Graphics.AssociationItem.html#AssociationItem.__calculateEndingPoints_rectangle" />
+      <keyword name="AssociationItem.__calculateEndingPoints_topToBottom" id="AssociationItem.__calculateEndingPoints_topToBottom" ref="eric5.Graphics.AssociationItem.html#AssociationItem.__calculateEndingPoints_topToBottom" />
       <keyword name="AssociationItem.__findIntersection" id="AssociationItem.__findIntersection" ref="eric5.Graphics.AssociationItem.html#AssociationItem.__findIntersection" />
       <keyword name="AssociationItem.__findPointRegion" id="AssociationItem.__findPointRegion" ref="eric5.Graphics.AssociationItem.html#AssociationItem.__findPointRegion" />
       <keyword name="AssociationItem.__findRectIntersectionPoint" id="AssociationItem.__findRectIntersectionPoint" ref="eric5.Graphics.AssociationItem.html#AssociationItem.__findRectIntersectionPoint" />
--- a/Documentation/Source/eric5.Graphics.AssociationItem.html	Wed Sep 05 19:18:35 2012 +0200
+++ b/Documentation/Source/eric5.Graphics.AssociationItem.html	Wed Sep 05 19:19:16 2012 +0200
@@ -70,6 +70,9 @@
 <td><a href="#AssociationItem.__calculateEndingPoints_rectangle">__calculateEndingPoints_rectangle</a></td>
 <td>Private method to calculate the ending points of the association item.</td>
 </tr><tr>
+<td><a href="#AssociationItem.__calculateEndingPoints_topToBottom">__calculateEndingPoints_topToBottom</a></td>
+<td>Private method to calculate the ending points of the association item.</td>
+</tr><tr>
 <td><a href="#AssociationItem.__findIntersection">__findIntersection</a></td>
 <td>Method to calculate the intersection point of two lines.</td>
 </tr><tr>
@@ -98,7 +101,7 @@
 </table>
 <a NAME="AssociationItem.__init__" ID="AssociationItem.__init__"></a>
 <h4>AssociationItem (Constructor)</h4>
-<b>AssociationItem</b>(<i>itemA, itemB, type=Normal, parent=None</i>)
+<b>AssociationItem</b>(<i>itemA, itemB, type=Normal, topToBottom=False, parent=None</i>)
 <p>
         Constructor
 </p><dl>
@@ -116,6 +119,10 @@
             <li>Generalisation</li>
             <li>Imports</li>
             </ul>
+</dd><dt><i>topToBottom=</i></dt>
+<dd>
+flag indicating to draw the association
+            from item A top to item B bottom (boolean)
 </dd><dt><i>parent=</i></dt>
 <dd>
 reference to the parent object (QGraphicsItem)
@@ -162,6 +169,14 @@
 </p><p>
         To calculate the end point we repeat the above but in the opposite direction
         (from itemB to itemA)
+</p><a NAME="AssociationItem.__calculateEndingPoints_topToBottom" ID="AssociationItem.__calculateEndingPoints_topToBottom"></a>
+<h4>AssociationItem.__calculateEndingPoints_topToBottom</h4>
+<b>__calculateEndingPoints_topToBottom</b>(<i></i>)
+<p>
+        Private method to calculate the ending points of the association item.
+</p><p>
+        The ending points are calculated from the top center of the lower item
+        to the bottom center of the upper item.
 </p><a NAME="AssociationItem.__findIntersection" ID="AssociationItem.__findIntersection"></a>
 <h4>AssociationItem.__findIntersection</h4>
 <b>__findIntersection</b>(<i>p1, p2, p3, p4</i>)
--- a/Graphics/AssociationItem.py	Wed Sep 05 19:18:35 2012 +0200
+++ b/Graphics/AssociationItem.py	Wed Sep 05 19:19:16 2012 +0200
@@ -35,7 +35,8 @@
     The association is drawn as an arrow starting at the first items and
     ending at the second.
     """
-    def __init__(self, itemA, itemB, type=Normal, parent=None):
+    def __init__(self, itemA, itemB, type=Normal, topToBottom=False,
+                 parent=None):
         """
         Constructor
         
@@ -47,6 +48,8 @@
             <li>Generalisation</li>
             <li>Imports</li>
             </ul>
+        @keyparam topToBottom flag indicating to draw the association
+            from item A top to item B bottom (boolean)
         @keyparam parent reference to the parent object (QGraphicsItem)
         """
         if type == Normal:
@@ -65,8 +68,11 @@
         self.setFlag(QGraphicsItem.ItemIsMovable, False)
         self.setFlag(QGraphicsItem.ItemIsSelectable, False)
         
-##        self.calculateEndingPoints = self.__calculateEndingPoints_center
-        self.calculateEndingPoints = self.__calculateEndingPoints_rectangle
+        if topToBottom:
+            self.calculateEndingPoints = self.__calculateEndingPoints_topToBottom
+        else:
+##            self.calculateEndingPoints = self.__calculateEndingPoints_center
+            self.calculateEndingPoints = self.__calculateEndingPoints_rectangle
         
         self.itemA = itemA
         self.itemB = itemB
@@ -91,6 +97,34 @@
         tl = self.mapFromItem(item, rect.topLeft())
         return QRectF(tl.x(), tl.y(), rect.width(), rect.height())
         
+    def __calculateEndingPoints_topToBottom(self):
+        """
+        Private method to calculate the ending points of the association item.
+        
+        The ending points are calculated from the top center of the lower item
+        to the bottom center of the upper item.
+        """
+        if self.itemA is None or self.itemB is None:
+            return
+        
+        self.prepareGeometryChange()
+        
+        rectA = self.__mapRectFromItem(self.itemA)
+        rectB = self.__mapRectFromItem(self.itemB)
+        midA = QPointF(rectA.x() + rectA.width() / 2.0,
+                       rectA.y() + rectA.height() / 2.0)
+        midB = QPointF(rectB.x() + rectB.width() / 2.0,
+                       rectB.y() + rectB.height() / 2.0)
+        if midA.y() > midB.y():
+            startP = QPointF(rectA.x() + rectA.width() / 2.0, rectA.y())
+            endP = QPointF(rectB.x() + rectB.width() / 2.0,
+                           rectB.y() + rectB.height())
+        else:
+            startP = QPointF(rectA.x() + rectA.width() / 2.0,
+                           rectA.y() + rectA.height())
+            endP = QPointF(rectB.x() + rectB.width() / 2.0, rectB.y())
+        self.setPoints(startP.x(), startP.y(), endP.x(), endP.y())
+    
     def __calculateEndingPoints_center(self):
         """
         Private method to calculate the ending points of the association item.
--- a/Graphics/PackageDiagram.py	Wed Sep 05 19:18:35 2012 +0200
+++ b/Graphics/PackageDiagram.py	Wed Sep 05 19:19:16 2012 +0200
@@ -295,7 +295,8 @@
                 assoc = AssociationItem(
                         self.__getCurrentShape(route[1]),
                         self.__getCurrentShape(route[0]),
-                        Generalisation)
+                        Generalisation,
+                        topToBottom=True)
                 self.scene.addItem(assoc)
         
     def show(self):
--- a/Graphics/UMLClassDiagram.py	Wed Sep 05 19:18:35 2012 +0200
+++ b/Graphics/UMLClassDiagram.py	Wed Sep 05 19:19:16 2012 +0200
@@ -249,7 +249,8 @@
                 assoc = AssociationItem(
                         self.__getCurrentShape(route[1]),
                         self.__getCurrentShape(route[0]),
-                        Generalisation)
+                        Generalisation,
+                        topToBottom=True)
                 self.scene.addItem(assoc)
         
     def show(self):

eric ide

mercurial