Graphics/AssociationItem.py

changeset 945
8cd4d08fa9f6
parent 791
9ec2ac20e54e
child 1112
8a7d1b9d18db
equal deleted inserted replaced
944:1b59c4ba121e 945:8cd4d08fa9f6
25 NorthEast = 6 25 NorthEast = 6
26 SouthEast = 7 26 SouthEast = 7
27 SouthWest = 8 27 SouthWest = 8
28 Center = 9 28 Center = 9
29 29
30
30 class AssociationItem(E5ArrowItem): 31 class AssociationItem(E5ArrowItem):
31 """ 32 """
32 Class implementing a graphics item for an association between two items. 33 Class implementing a graphics item for an association between two items.
33 34
34 The association is drawn as an arrow starting at the first items and 35 The association is drawn as an arrow starting at the first items and
35 ending at the second. 36 ending at the second.
36 """ 37 """
37 def __init__(self, itemA, itemB, type = Normal, parent = None): 38 def __init__(self, itemA, itemB, type=Normal, parent=None):
38 """ 39 """
39 Constructor 40 Constructor
40 41
41 @param itemA first widget of the association 42 @param itemA first widget of the association
42 @param itemB second widget of the association 43 @param itemB second widget of the association
56 arrowFilled = True 57 arrowFilled = True
57 elif type == Generalisation: 58 elif type == Generalisation:
58 arrowType = WideArrow 59 arrowType = WideArrow
59 arrowFilled = False 60 arrowFilled = False
60 61
61 E5ArrowItem.__init__(self, QPointF(0, 0), QPointF(100, 100), 62 E5ArrowItem.__init__(self, QPointF(0, 0), QPointF(100, 100),
62 arrowFilled, arrowType, parent) 63 arrowFilled, arrowType, parent)
63 64
64 self.setFlag(QGraphicsItem.ItemIsMovable, False) 65 self.setFlag(QGraphicsItem.ItemIsMovable, False)
65 self.setFlag(QGraphicsItem.ItemIsSelectable, False) 66 self.setFlag(QGraphicsItem.ItemIsSelectable, False)
66 67
139 </pre> 140 </pre>
140 141
141 Each diagonal is defined by two corners of the bounding rectangle 142 Each diagonal is defined by two corners of the bounding rectangle
142 143
143 To calculate the start point we have to find out in which 144 To calculate the start point we have to find out in which
144 region (defined by itemA's diagonals) is itemB's TopLeft corner 145 region (defined by itemA's diagonals) is itemB's TopLeft corner
145 (lets call it region M). After that the start point will be 146 (lets call it region M). After that the start point will be
146 the middle point of rectangle's side contained in region M. 147 the middle point of rectangle's side contained in region M.
147 148
148 To calculate the end point we repeat the above but in the opposite direction 149 To calculate the end point we repeat the above but in the opposite direction
149 (from itemB to itemA) 150 (from itemB to itemA)
195 196
196 self.__updateEndPoint(self.regionB, False) 197 self.__updateEndPoint(self.regionB, False)
197 198
198 def __findPointRegion(self, rect, posX, posY): 199 def __findPointRegion(self, rect, posX, posY):
199 """ 200 """
200 Private method to find out, which region of rectangle rect contains the point 201 Private method to find out, which region of rectangle rect contains the point
201 (PosX, PosY) and returns the region number. 202 (PosX, PosY) and returns the region number.
202 203
203 @param rect rectangle to calculate the region for (QRectF) 204 @param rect rectangle to calculate the region for (QRectF)
204 @param posX x position of point (float) 205 @param posX x position of point (float)
205 @param posY y position of point (float) 206 @param posY y position of point (float)

eric ide

mercurial