eric6/Documentation/Source/eric6.Graphics.AssociationItem.html

branch
maintenance
changeset 6989
8b8cadf8d7e9
parent 6942
2602857055c5
child 7273
391d6b7b1eff
equal deleted inserted replaced
6938:7926553b7509 6989:8b8cadf8d7e9
1 <!DOCTYPE html>
2 <html><head>
3 <title>eric6.Graphics.AssociationItem</title>
4 <meta charset="UTF-8">
5 <style>
6 body {
7 background: #EDECE6;
8 margin: 0em 1em 10em 1em;
9 color: black;
10 }
11
12 h1 { color: white; background: #85774A; }
13 h2 { color: white; background: #85774A; }
14 h3 { color: white; background: #9D936E; }
15 h4 { color: white; background: #9D936E; }
16
17 a { color: #BA6D36; }
18
19 </style>
20 </head>
21 <body><a NAME="top" ID="top"></a>
22 <h1>eric6.Graphics.AssociationItem</h1>
23 <p>
24 Module implementing a graphics item for an association between two items.
25 </p>
26 <h3>Global Attributes</h3>
27 <table>
28 <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>
29 </table>
30 <h3>Classes</h3>
31 <table>
32 <tr>
33 <td><a href="#AssociationItem">AssociationItem</a></td>
34 <td>Class implementing a graphics item for an association between two items.</td>
35 </tr>
36 </table>
37 <h3>Functions</h3>
38 <table>
39 <tr><td>None</td></tr>
40 </table>
41 <hr /><hr />
42 <a NAME="AssociationItem" ID="AssociationItem"></a>
43 <h2>AssociationItem</h2>
44 <p>
45 Class implementing a graphics item for an association between two items.
46 </p><p>
47 The association is drawn as an arrow starting at the first items and
48 ending at the second.
49 </p>
50 <h3>Derived from</h3>
51 E5ArrowItem
52 <h3>Class Attributes</h3>
53 <table>
54 <tr><td>None</td></tr>
55 </table>
56 <h3>Class Methods</h3>
57 <table>
58 <tr>
59 <td><a href="#AssociationItem.parseAssociationItemDataString">parseAssociationItemDataString</a></td>
60 <td>Class method to parse the given persistence data.</td>
61 </tr>
62 </table>
63 <h3>Methods</h3>
64 <table>
65 <tr>
66 <td><a href="#AssociationItem.__init__">AssociationItem</a></td>
67 <td>Constructor</td>
68 </tr><tr>
69 <td><a href="#AssociationItem.__calculateEndingPoints_center">__calculateEndingPoints_center</a></td>
70 <td>Private method to calculate the ending points of the association item.</td>
71 </tr><tr>
72 <td><a href="#AssociationItem.__calculateEndingPoints_rectangle">__calculateEndingPoints_rectangle</a></td>
73 <td>Private method to calculate the ending points of the association item.</td>
74 </tr><tr>
75 <td><a href="#AssociationItem.__calculateEndingPoints_topToBottom">__calculateEndingPoints_topToBottom</a></td>
76 <td>Private method to calculate the ending points of the association item.</td>
77 </tr><tr>
78 <td><a href="#AssociationItem.__findIntersection">__findIntersection</a></td>
79 <td>Private method to calculate the intersection point of two lines.</td>
80 </tr><tr>
81 <td><a href="#AssociationItem.__findPointRegion">__findPointRegion</a></td>
82 <td>Private method to find out, which region of rectangle rect contains the point (PosX, PosY) and returns the region number.</td>
83 </tr><tr>
84 <td><a href="#AssociationItem.__findRectIntersectionPoint">__findRectIntersectionPoint</a></td>
85 <td>Private method to find the intersetion point of a line with a rectangle.</td>
86 </tr><tr>
87 <td><a href="#AssociationItem.__mapRectFromItem">__mapRectFromItem</a></td>
88 <td>Private method to map item's rectangle to this item's coordinate system.</td>
89 </tr><tr>
90 <td><a href="#AssociationItem.__updateEndPoint">__updateEndPoint</a></td>
91 <td>Private method to update an endpoint.</td>
92 </tr><tr>
93 <td><a href="#AssociationItem.buildAssociationItemDataString">buildAssociationItemDataString</a></td>
94 <td>Public method to build a string to persist the specific item data.</td>
95 </tr><tr>
96 <td><a href="#AssociationItem.unassociate">unassociate</a></td>
97 <td>Public method to unassociate from the widgets.</td>
98 </tr><tr>
99 <td><a href="#AssociationItem.widgetMoved">widgetMoved</a></td>
100 <td>Public method to recalculate the association after a widget was moved.</td>
101 </tr>
102 </table>
103 <h3>Static Methods</h3>
104 <table>
105 <tr><td>None</td></tr>
106 </table>
107 <a NAME="AssociationItem.parseAssociationItemDataString" ID="AssociationItem.parseAssociationItemDataString"></a>
108 <h4>AssociationItem.parseAssociationItemDataString (class method)</h4>
109 <b>parseAssociationItemDataString</b>(<i>data</i>)
110 <p>
111 Class method to parse the given persistence data.
112 </p><dl>
113 <dt><i>data</i></dt>
114 <dd>
115 persisted data to be parsed (string)
116 </dd>
117 </dl><dl>
118 <dt>Returns:</dt>
119 <dd>
120 tuple with the IDs of the source and destination items,
121 the association type and a flag indicating to associate from top
122 to bottom (integer, integer, integer, boolean)
123 </dd>
124 </dl><a NAME="AssociationItem.__init__" ID="AssociationItem.__init__"></a>
125 <h4>AssociationItem (Constructor)</h4>
126 <b>AssociationItem</b>(<i>itemA, itemB, assocType=Normal, topToBottom=False, parent=None</i>)
127 <p>
128 Constructor
129 </p><dl>
130 <dt><i>itemA</i></dt>
131 <dd>
132 first widget of the association
133 </dd><dt><i>itemB</i></dt>
134 <dd>
135 second widget of the association
136 </dd><dt><i>assocType</i></dt>
137 <dd>
138 type of the association. This must be one of
139 <ul>
140 <li>Normal (default)</li>
141 <li>Generalisation</li>
142 <li>Imports</li>
143 </ul>
144 </dd><dt><i>topToBottom=</i></dt>
145 <dd>
146 flag indicating to draw the association
147 from item A top to item B bottom (boolean)
148 </dd><dt><i>parent=</i></dt>
149 <dd>
150 reference to the parent object (QGraphicsItem)
151 </dd>
152 </dl><a NAME="AssociationItem.__calculateEndingPoints_center" ID="AssociationItem.__calculateEndingPoints_center"></a>
153 <h4>AssociationItem.__calculateEndingPoints_center</h4>
154 <b>__calculateEndingPoints_center</b>(<i></i>)
155 <p>
156 Private method to calculate the ending points of the association item.
157 </p><p>
158 The ending points are calculated from the centers of the
159 two associated items.
160 </p><a NAME="AssociationItem.__calculateEndingPoints_rectangle" ID="AssociationItem.__calculateEndingPoints_rectangle"></a>
161 <h4>AssociationItem.__calculateEndingPoints_rectangle</h4>
162 <b>__calculateEndingPoints_rectangle</b>(<i></i>)
163 <p>
164 Private method to calculate the ending points of the association item.
165 </p><p>
166 The ending points are calculated by the following method.
167 </p><p>
168 For each item the diagram is divided in four Regions by its diagonals
169 as indicated below
170 <pre>
171 \ Region 2 /
172 \ /
173 |--------|
174 | \ / |
175 | \ / |
176 | \/ |
177 Region 1 | /\ | Region 3
178 | / \ |
179 | / \ |
180 |--------|
181 / \
182 / Region 4 \
183 </pre>
184 </p><p>
185 Each diagonal is defined by two corners of the bounding rectangle
186 </p><p>
187 To calculate the start point we have to find out in which
188 region (defined by itemA's diagonals) is itemB's TopLeft corner
189 (lets call it region M). After that the start point will be
190 the middle point of rectangle's side contained in region M.
191 </p><p>
192 To calculate the end point we repeat the above but in the opposite
193 direction (from itemB to itemA)
194 </p><a NAME="AssociationItem.__calculateEndingPoints_topToBottom" ID="AssociationItem.__calculateEndingPoints_topToBottom"></a>
195 <h4>AssociationItem.__calculateEndingPoints_topToBottom</h4>
196 <b>__calculateEndingPoints_topToBottom</b>(<i></i>)
197 <p>
198 Private method to calculate the ending points of the association item.
199 </p><p>
200 The ending points are calculated from the top center of the lower item
201 to the bottom center of the upper item.
202 </p><a NAME="AssociationItem.__findIntersection" ID="AssociationItem.__findIntersection"></a>
203 <h4>AssociationItem.__findIntersection</h4>
204 <b>__findIntersection</b>(<i>p1, p2, p3, p4</i>)
205 <p>
206 Private method to calculate the intersection point of two lines.
207 </p><p>
208 The first line is determined by the points p1 and p2, the second
209 line by p3 and p4. If the intersection point is not contained in
210 the segment p1p2, then it returns (-1.0, -1.0).
211 </p><p>
212 For the function's internal calculations remember:<br />
213 QT coordinates start with the point (0,0) as the topleft corner
214 and x-values increase from left to right and y-values increase
215 from top to bottom; it means the visible area is quadrant I in
216 the regular XY coordinate system
217 </p><p>
218 <pre>
219 Quadrant II | Quadrant I
220 -----------------|-----------------
221 Quadrant III | Quadrant IV
222 </pre>
223 </p><p>
224 In order for the linear function calculations to work in this method
225 we must switch x and y values (x values become y values and viceversa)
226 </p><dl>
227 <dt><i>p1</i></dt>
228 <dd>
229 first point of first line (QPointF)
230 </dd><dt><i>p2</i></dt>
231 <dd>
232 second point of first line (QPointF)
233 </dd><dt><i>p3</i></dt>
234 <dd>
235 first point of second line (QPointF)
236 </dd><dt><i>p4</i></dt>
237 <dd>
238 second point of second line (QPointF)
239 </dd>
240 </dl><dl>
241 <dt>Returns:</dt>
242 <dd>
243 the intersection point (QPointF)
244 </dd>
245 </dl><a NAME="AssociationItem.__findPointRegion" ID="AssociationItem.__findPointRegion"></a>
246 <h4>AssociationItem.__findPointRegion</h4>
247 <b>__findPointRegion</b>(<i>rect, posX, posY</i>)
248 <p>
249 Private method to find out, which region of rectangle rect contains
250 the point (PosX, PosY) and returns the region number.
251 </p><dl>
252 <dt><i>rect</i></dt>
253 <dd>
254 rectangle to calculate the region for (QRectF)
255 </dd><dt><i>posX</i></dt>
256 <dd>
257 x position of point (float)
258 </dd><dt><i>posY</i></dt>
259 <dd>
260 y position of point (float)
261 </dd>
262 </dl><dl>
263 <dt>Returns:</dt>
264 <dd>
265 the calculated region number<br />
266 West = Region 1<br />
267 North = Region 2<br />
268 East = Region 3<br />
269 South = Region 4<br />
270 NorthWest = On diagonal 2 between Region 1 and 2<br />
271 NorthEast = On diagonal 1 between Region 2 and 3<br />
272 SouthEast = On diagonal 2 between Region 3 and 4<br />
273 SouthWest = On diagonal 1 between Region4 and 1<br />
274 Center = On diagonal 1 and On diagonal 2 (the center)<br />
275 </dd>
276 </dl><a NAME="AssociationItem.__findRectIntersectionPoint" ID="AssociationItem.__findRectIntersectionPoint"></a>
277 <h4>AssociationItem.__findRectIntersectionPoint</h4>
278 <b>__findRectIntersectionPoint</b>(<i>item, p1, p2</i>)
279 <p>
280 Private method to find the intersetion point of a line with a
281 rectangle.
282 </p><dl>
283 <dt><i>item</i></dt>
284 <dd>
285 item to check against
286 </dd><dt><i>p1</i></dt>
287 <dd>
288 first point of the line (QPointF)
289 </dd><dt><i>p2</i></dt>
290 <dd>
291 second point of the line (QPointF)
292 </dd>
293 </dl><dl>
294 <dt>Returns:</dt>
295 <dd>
296 the intersection point (QPointF)
297 </dd>
298 </dl><a NAME="AssociationItem.__mapRectFromItem" ID="AssociationItem.__mapRectFromItem"></a>
299 <h4>AssociationItem.__mapRectFromItem</h4>
300 <b>__mapRectFromItem</b>(<i>item</i>)
301 <p>
302 Private method to map item's rectangle to this item's coordinate
303 system.
304 </p><dl>
305 <dt><i>item</i></dt>
306 <dd>
307 reference to the item to be mapped (QGraphicsRectItem)
308 </dd>
309 </dl><dl>
310 <dt>Returns:</dt>
311 <dd>
312 item's rectangle in local coordinates (QRectF)
313 </dd>
314 </dl><a NAME="AssociationItem.__updateEndPoint" ID="AssociationItem.__updateEndPoint"></a>
315 <h4>AssociationItem.__updateEndPoint</h4>
316 <b>__updateEndPoint</b>(<i>region, isWidgetA</i>)
317 <p>
318 Private method to update an endpoint.
319 </p><dl>
320 <dt><i>region</i></dt>
321 <dd>
322 the region for the endpoint (integer)
323 </dd><dt><i>isWidgetA</i></dt>
324 <dd>
325 flag indicating update for itemA is done (boolean)
326 </dd>
327 </dl><a NAME="AssociationItem.buildAssociationItemDataString" ID="AssociationItem.buildAssociationItemDataString"></a>
328 <h4>AssociationItem.buildAssociationItemDataString</h4>
329 <b>buildAssociationItemDataString</b>(<i></i>)
330 <p>
331 Public method to build a string to persist the specific item data.
332 </p><p>
333 This string should be built like "attribute=value" with pairs separated
334 by ", ". value must not contain ", " or newlines.
335 </p><dl>
336 <dt>Returns:</dt>
337 <dd>
338 persistence data (string)
339 </dd>
340 </dl><a NAME="AssociationItem.unassociate" ID="AssociationItem.unassociate"></a>
341 <h4>AssociationItem.unassociate</h4>
342 <b>unassociate</b>(<i></i>)
343 <p>
344 Public method to unassociate from the widgets.
345 </p><a NAME="AssociationItem.widgetMoved" ID="AssociationItem.widgetMoved"></a>
346 <h4>AssociationItem.widgetMoved</h4>
347 <b>widgetMoved</b>(<i></i>)
348 <p>
349 Public method to recalculate the association after a widget was moved.
350 </p>
351 <div align="right"><a href="#top">Up</a></div>
352 <hr />
353 </body></html>

eric ide

mercurial