~mcfletch/eric/update-to-4.5.13

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN'
'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
<html><head>
<title>eric4.Graphics.AssociationItem</title>
<style>
body {
    background:white;
    margin: 0em 1em 10em 1em;
    color: black;
}

h1 { color: white; background: #4FA4FF; }
h2 { color: white; background: #4FA4FF; }
h3 { color: white; background: #00557F; }
h4 { color: white; background: #00557F; }
    
a { color: #AA5500; }

</style>
</head>
<body><a NAME="top" ID="top"></a>
<h1>eric4.Graphics.AssociationItem</h1>
<p>
Module implementing a graphics item for an association between two items.
</p>
<h3>Global Attributes</h3>
<table>
<tr><td>Center</td></tr><tr><td>East</td></tr><tr><td>Generalisation</td></tr><tr><td>Imports</td></tr><tr><td>NoRegion</td></tr><tr><td>Normal</td></tr><tr><td>North</td></tr><tr><td>NorthEast</td></tr><tr><td>NorthWest</td></tr><tr><td>South</td></tr><tr><td>SouthEast</td></tr><tr><td>SouthWest</td></tr><tr><td>West</td></tr>
</table>
<h3>Classes</h3>
<table>
<tr>
<td><a href="#AssociationItem">AssociationItem</a></td>
<td>Class implementing a graphics item for an association between two items.</td>
</tr>
</table>
<h3>Functions</h3>
<table>
<tr><td>None</td></tr>
</table>
<hr /><hr />
<a NAME="AssociationItem" ID="AssociationItem"></a>
<h2>AssociationItem</h2>
<p>
    Class implementing a graphics item for an association between two items.
</p><p>
    The association is drawn as an arrow starting at the first items and
    ending at the second.
</p>
<h3>Derived from</h3>
E4ArrowItem
<h3>Class Attributes</h3>
<table>
<tr><td>None</td></tr>
</table>
<h3>Class Methods</h3>
<table>
<tr><td>None</td></tr>
</table>
<h3>Methods</h3>
<table>
<tr>
<td><a href="#AssociationItem.__init__">AssociationItem</a></td>
<td>Constructor</td>
</tr><tr>
<td><a href="#AssociationItem.__calculateEndingPoints_center">__calculateEndingPoints_center</a></td>
<td>Private method to calculate the ending points of the association item.</td>
</tr><tr>
<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.__findIntersection">__findIntersection</a></td>
<td>Method to calculate the intersection point of two lines.</td>
</tr><tr>
<td><a href="#AssociationItem.__findPointRegion">__findPointRegion</a></td>
<td>Private method to find out, which region of rectangle rect contains the point (PosX, PosY) and returns the region number.</td>
</tr><tr>
<td><a href="#AssociationItem.__findRectIntersectionPoint">__findRectIntersectionPoint</a></td>
<td>Private method to find the intersetion point of a line with a rectangle.</td>
</tr><tr>
<td><a href="#AssociationItem.__mapRectFromItem">__mapRectFromItem</a></td>
<td>Private method to map item's rectangle to this item's coordinate system.</td>
</tr><tr>
<td><a href="#AssociationItem.__updateEndPoint">__updateEndPoint</a></td>
<td>Private method to update an endpoint.</td>
</tr><tr>
<td><a href="#AssociationItem.unassociate">unassociate</a></td>
<td>Public method to unassociate from the widgets.</td>
</tr><tr>
<td><a href="#AssociationItem.widgetMoved">widgetMoved</a></td>
<td>Public method to recalculate the association after a widget was moved.</td>
</tr>
</table>
<h3>Static Methods</h3>
<table>
<tr><td>None</td></tr>
</table>
<a NAME="AssociationItem.__init__" ID="AssociationItem.__init__"></a>
<h4>AssociationItem (Constructor)</h4>
<b>AssociationItem</b>(<i>itemA, itemB, type = Normal, parent = None</i>)
<p>
        Constructor
</p><dl>
<dt><i>itemA</i></dt>
<dd>
first widget of the association
</dd><dt><i>itemB</i></dt>
<dd>
second widget of the association
</dd><dt><i>type</i></dt>
<dd>
type of the association. This must be one of
            <ul>
            <li>Normal (default)</li>
            <li>Generalisation</li>
            <li>Imports</li>
            </ul>
</dd><dt><i>parent=</i></dt>
<dd>
reference to the parent object (QGraphicsItem)
</dd>
</dl><a NAME="AssociationItem.__calculateEndingPoints_center" ID="AssociationItem.__calculateEndingPoints_center"></a>
<h4>AssociationItem.__calculateEndingPoints_center</h4>
<b>__calculateEndingPoints_center</b>(<i></i>)
<p>
        Private method to calculate the ending points of the association item.
</p><p>
        The ending points are calculated from the centers of the
        two associated items.
</p><a NAME="AssociationItem.__calculateEndingPoints_rectangle" ID="AssociationItem.__calculateEndingPoints_rectangle"></a>
<h4>AssociationItem.__calculateEndingPoints_rectangle</h4>
<b>__calculateEndingPoints_rectangle</b>(<i></i>)
<p>
        Private method to calculate the ending points of the association item.
</p><p>
        The ending points are calculated by the following method.
</p><p>
        For each item the diagram is divided in four Regions by its diagonals
        as indicated below
        <pre>
                   \  Region 2  /
                    \          /
                     |--------|
                     | \    / |
                     |  \  /  |
                     |   \/   |
            Region 1 |   /\   | Region 3
                     |  /  \  |
                     | /    \ |
                     |--------|
                    /          \
                   /  Region 4  \
        </pre>
</p><p>
        Each diagonal is defined by two corners of the bounding rectangle
</p><p>
        To calculate the start point  we have to find out in which
        region (defined by itemA's diagonals) is itemB's TopLeft corner 
        (lets call it region M). After that the start point will be
        the middle point of rectangle's side contained in region M.
</p><p>
        To calculate the end point we repeat the above but in the opposite direction
        (from itemB to itemA)
</p><a NAME="AssociationItem.__findIntersection" ID="AssociationItem.__findIntersection"></a>
<h4>AssociationItem.__findIntersection</h4>
<b>__findIntersection</b>(<i>p1, p2, p3, p4</i>)
<p>
        Method to calculate the intersection point of two lines.
</p><p>
        The first line is determined by the points p1 and p2, the second
        line by p3 and p4. If the intersection point is not contained in
        the segment p1p2, then it returns (-1.0, -1.0).
</p><p>
        For the function's internal calculations remember:<br />
        QT coordinates start with the point (0,0) as the topleft corner
        and x-values increase from left to right and y-values increase
        from top to bottom; it means the visible area is quadrant I in
        the regular XY coordinate system
</p><p>
        <pre>
            Quadrant II     |   Quadrant I
           -----------------|-----------------
            Quadrant III    |   Quadrant IV
        </pre>
</p><p>
        In order for the linear function calculations to work in this method
        we must switch x and y values (x values become y values and viceversa)
</p><dl>
<dt><i>p1</i></dt>
<dd>
first point of first line (QPointF)
</dd><dt><i>p2</i></dt>
<dd>
second point of first line (QPointF)
</dd><dt><i>p3</i></dt>
<dd>
first point of second line (QPointF)
</dd><dt><i>p4</i></dt>
<dd>
second point of second line (QPointF)
</dd>
</dl><dl>
<dt>Returns:</dt>
<dd>
the intersection point (QPointF)
</dd>
</dl><a NAME="AssociationItem.__findPointRegion" ID="AssociationItem.__findPointRegion"></a>
<h4>AssociationItem.__findPointRegion</h4>
<b>__findPointRegion</b>(<i>rect, posX, posY</i>)
<p>
        Private method to find out, which region of rectangle rect contains the point 
        (PosX, PosY) and returns the region number.
</p><dl>
<dt><i>rect</i></dt>
<dd>
rectangle to calculate the region for (QRectF)
</dd><dt><i>posX</i></dt>
<dd>
x position of point (float)
</dd><dt><i>posY</i></dt>
<dd>
y position of point (float)
</dd>
</dl><dl>
<dt>Returns:</dt>
<dd>
the calculated region number<br />
            West = Region 1<br />
            North = Region 2<br />
            East = Region 3<br />
            South = Region 4<br />
            NorthWest = On diagonal 2 between Region 1 and 2<br />
            NorthEast = On diagonal 1 between Region 2 and 3<br />
            SouthEast = On diagonal 2 between Region 3 and 4<br />
            SouthWest = On diagonal 1 between Region4 and 1<br />
            Center = On diagonal 1 and On diagonal 2 (the center)<br />
</dd>
</dl><a NAME="AssociationItem.__findRectIntersectionPoint" ID="AssociationItem.__findRectIntersectionPoint"></a>
<h4>AssociationItem.__findRectIntersectionPoint</h4>
<b>__findRectIntersectionPoint</b>(<i>item, p1, p2</i>)
<p>
        Private method to find the intersetion point of a line with a rectangle.
</p><dl>
<dt><i>item</i></dt>
<dd>
item to check against
</dd><dt><i>p1</i></dt>
<dd>
first point of the line (QPointF)
</dd><dt><i>p2</i></dt>
<dd>
second point of the line (QPointF)
</dd>
</dl><dl>
<dt>Returns:</dt>
<dd>
the intersection point (QPointF)
</dd>
</dl><a NAME="AssociationItem.__mapRectFromItem" ID="AssociationItem.__mapRectFromItem"></a>
<h4>AssociationItem.__mapRectFromItem</h4>
<b>__mapRectFromItem</b>(<i>item</i>)
<p>
        Private method to map item's rectangle to this item's coordinate system.
</p><dl>
<dt><i>item</i></dt>
<dd>
reference to the item to be mapped (QGraphicsRectItem)
</dd>
</dl><dl>
<dt>Returns:</dt>
<dd>
item's rectangle in local coordinates (QRectF)
</dd>
</dl><a NAME="AssociationItem.__updateEndPoint" ID="AssociationItem.__updateEndPoint"></a>
<h4>AssociationItem.__updateEndPoint</h4>
<b>__updateEndPoint</b>(<i>region, isWidgetA</i>)
<p>
        Private method to update an endpoint.
</p><dl>
<dt><i>region</i></dt>
<dd>
the region for the endpoint (integer)
</dd><dt><i>isWidgetA</i></dt>
<dd>
flag indicating update for itemA is done (boolean)
</dd>
</dl><a NAME="AssociationItem.unassociate" ID="AssociationItem.unassociate"></a>
<h4>AssociationItem.unassociate</h4>
<b>unassociate</b>(<i></i>)
<p>
        Public method to unassociate from the widgets.
</p><a NAME="AssociationItem.widgetMoved" ID="AssociationItem.widgetMoved"></a>
<h4>AssociationItem.widgetMoved</h4>
<b>widgetMoved</b>(<i></i>)
<p>
        Public method to recalculate the association after a widget was moved.
</p>
<div align="right"><a href="#top">Up</a></div>
<hr />
</body></html>