|
1 <!DOCTYPE html> |
|
2 <html><head> |
|
3 <title>eric7.EricGraphics.EricGraphicsView</title> |
|
4 <meta charset="UTF-8"> |
|
5 <link rel="stylesheet" href="styles.css"> |
|
6 </head> |
|
7 <body> |
|
8 <a NAME="top" ID="top"></a> |
|
9 <h1>eric7.EricGraphics.EricGraphicsView</h1> |
|
10 |
|
11 <p> |
|
12 Module implementing a canvas view class. |
|
13 </p> |
|
14 <h3>Global Attributes</h3> |
|
15 |
|
16 <table> |
|
17 <tr><td>None</td></tr> |
|
18 </table> |
|
19 <h3>Classes</h3> |
|
20 |
|
21 <table> |
|
22 |
|
23 <tr> |
|
24 <td><a href="#EricGraphicsView">EricGraphicsView</a></td> |
|
25 <td>Class implementing a graphics view.</td> |
|
26 </tr> |
|
27 </table> |
|
28 <h3>Functions</h3> |
|
29 |
|
30 <table> |
|
31 <tr><td>None</td></tr> |
|
32 </table> |
|
33 <hr /> |
|
34 <hr /> |
|
35 <a NAME="EricGraphicsView" ID="EricGraphicsView"></a> |
|
36 <h2>EricGraphicsView</h2> |
|
37 |
|
38 <p> |
|
39 Class implementing a graphics view. |
|
40 </p> |
|
41 <h3>Signals</h3> |
|
42 <dl> |
|
43 |
|
44 <dt>zoomValueChanged(int)</dt> |
|
45 <dd> |
|
46 emitted to signal a change of the zoom value |
|
47 </dd> |
|
48 </dl> |
|
49 <h3>Derived from</h3> |
|
50 QGraphicsView |
|
51 <h3>Class Attributes</h3> |
|
52 |
|
53 <table> |
|
54 <tr><td>ZoomLevelDefault</td></tr><tr><td>ZoomLevels</td></tr> |
|
55 </table> |
|
56 <h3>Class Methods</h3> |
|
57 |
|
58 <table> |
|
59 <tr><td>None</td></tr> |
|
60 </table> |
|
61 <h3>Methods</h3> |
|
62 |
|
63 <table> |
|
64 |
|
65 <tr> |
|
66 <td><a href="#EricGraphicsView.__init__">EricGraphicsView</a></td> |
|
67 <td>Constructor</td> |
|
68 </tr> |
|
69 <tr> |
|
70 <td><a href="#EricGraphicsView.__getDiagram">__getDiagram</a></td> |
|
71 <td>Private method to retrieve the diagram from the scene fitting it in the minimum rectangle.</td> |
|
72 </tr> |
|
73 <tr> |
|
74 <td><a href="#EricGraphicsView.__levelForZoom">__levelForZoom</a></td> |
|
75 <td>Private method determining the zoom level index given a zoom factor.</td> |
|
76 </tr> |
|
77 <tr> |
|
78 <td><a href="#EricGraphicsView._getDiagramRect">_getDiagramRect</a></td> |
|
79 <td>Protected method to calculate the minimum rectangle fitting the diagram.</td> |
|
80 </tr> |
|
81 <tr> |
|
82 <td><a href="#EricGraphicsView._getDiagramSize">_getDiagramSize</a></td> |
|
83 <td>Protected method to calculate the minimum size fitting the diagram.</td> |
|
84 </tr> |
|
85 <tr> |
|
86 <td><a href="#EricGraphicsView.autoAdjustSceneSize">autoAdjustSceneSize</a></td> |
|
87 <td>Public method to adjust the scene size to the diagram size.</td> |
|
88 </tr> |
|
89 <tr> |
|
90 <td><a href="#EricGraphicsView.filteredItems">filteredItems</a></td> |
|
91 <td>Public method to filter a list of items.</td> |
|
92 </tr> |
|
93 <tr> |
|
94 <td><a href="#EricGraphicsView.getBackgroundColor">getBackgroundColor</a></td> |
|
95 <td>Public method to get the configured background color.</td> |
|
96 </tr> |
|
97 <tr> |
|
98 <td><a href="#EricGraphicsView.getDrawingColors">getDrawingColors</a></td> |
|
99 <td>Public method to get the configured drawing colors.</td> |
|
100 </tr> |
|
101 <tr> |
|
102 <td><a href="#EricGraphicsView.getForegroundColor">getForegroundColor</a></td> |
|
103 <td>Public method to get the configured foreground color.</td> |
|
104 </tr> |
|
105 <tr> |
|
106 <td><a href="#EricGraphicsView.printDiagram">printDiagram</a></td> |
|
107 <td>Public method to print the diagram.</td> |
|
108 </tr> |
|
109 <tr> |
|
110 <td><a href="#EricGraphicsView.resizeScene">resizeScene</a></td> |
|
111 <td>Public method to resize the scene.</td> |
|
112 </tr> |
|
113 <tr> |
|
114 <td><a href="#EricGraphicsView.saveImage">saveImage</a></td> |
|
115 <td>Public method to save the scene to a file.</td> |
|
116 </tr> |
|
117 <tr> |
|
118 <td><a href="#EricGraphicsView.setSceneSize">setSceneSize</a></td> |
|
119 <td>Public method to set the scene size.</td> |
|
120 </tr> |
|
121 <tr> |
|
122 <td><a href="#EricGraphicsView.setZoom">setZoom</a></td> |
|
123 <td>Public method to set the zoom value in percent.</td> |
|
124 </tr> |
|
125 <tr> |
|
126 <td><a href="#EricGraphicsView.zoom">zoom</a></td> |
|
127 <td>Public method to get the current zoom factor in percent.</td> |
|
128 </tr> |
|
129 <tr> |
|
130 <td><a href="#EricGraphicsView.zoomIn">zoomIn</a></td> |
|
131 <td>Public method to zoom in.</td> |
|
132 </tr> |
|
133 <tr> |
|
134 <td><a href="#EricGraphicsView.zoomOut">zoomOut</a></td> |
|
135 <td>Public method to zoom out.</td> |
|
136 </tr> |
|
137 <tr> |
|
138 <td><a href="#EricGraphicsView.zoomReset">zoomReset</a></td> |
|
139 <td>Public method to handle the reset the zoom value.</td> |
|
140 </tr> |
|
141 </table> |
|
142 <h3>Static Methods</h3> |
|
143 |
|
144 <table> |
|
145 <tr><td>None</td></tr> |
|
146 </table> |
|
147 |
|
148 <a NAME="EricGraphicsView.__init__" ID="EricGraphicsView.__init__"></a> |
|
149 <h4>EricGraphicsView (Constructor)</h4> |
|
150 <b>EricGraphicsView</b>(<i>scene, parent=None</i>) |
|
151 |
|
152 <p> |
|
153 Constructor |
|
154 </p> |
|
155 <dl> |
|
156 |
|
157 <dt><i>scene</i></dt> |
|
158 <dd> |
|
159 reference to the scene object (QGraphicsScene) |
|
160 </dd> |
|
161 <dt><i>parent</i></dt> |
|
162 <dd> |
|
163 parent widget (QWidget) |
|
164 </dd> |
|
165 </dl> |
|
166 <a NAME="EricGraphicsView.__getDiagram" ID="EricGraphicsView.__getDiagram"></a> |
|
167 <h4>EricGraphicsView.__getDiagram</h4> |
|
168 <b>__getDiagram</b>(<i>rect, imageFormat="PNG", filename=None</i>) |
|
169 |
|
170 <p> |
|
171 Private method to retrieve the diagram from the scene fitting it |
|
172 in the minimum rectangle. |
|
173 </p> |
|
174 <dl> |
|
175 |
|
176 <dt><i>rect</i> (QRectF)</dt> |
|
177 <dd> |
|
178 minimum rectangle fitting the diagram |
|
179 </dd> |
|
180 <dt><i>imageFormat</i> (str)</dt> |
|
181 <dd> |
|
182 format for the image file |
|
183 </dd> |
|
184 <dt><i>filename</i></dt> |
|
185 <dd> |
|
186 name of the file for non pixmaps |
|
187 str |
|
188 </dd> |
|
189 </dl> |
|
190 <dl> |
|
191 <dt>Return:</dt> |
|
192 <dd> |
|
193 paint device containing the diagram |
|
194 </dd> |
|
195 </dl> |
|
196 <dl> |
|
197 <dt>Return Type:</dt> |
|
198 <dd> |
|
199 QPixmap or QSvgGenerator |
|
200 </dd> |
|
201 </dl> |
|
202 <a NAME="EricGraphicsView.__levelForZoom" ID="EricGraphicsView.__levelForZoom"></a> |
|
203 <h4>EricGraphicsView.__levelForZoom</h4> |
|
204 <b>__levelForZoom</b>(<i>zoom</i>) |
|
205 |
|
206 <p> |
|
207 Private method determining the zoom level index given a zoom factor. |
|
208 </p> |
|
209 <dl> |
|
210 |
|
211 <dt><i>zoom</i></dt> |
|
212 <dd> |
|
213 zoom factor (integer) |
|
214 </dd> |
|
215 </dl> |
|
216 <dl> |
|
217 <dt>Return:</dt> |
|
218 <dd> |
|
219 index of zoom factor (integer) |
|
220 </dd> |
|
221 </dl> |
|
222 <a NAME="EricGraphicsView._getDiagramRect" ID="EricGraphicsView._getDiagramRect"></a> |
|
223 <h4>EricGraphicsView._getDiagramRect</h4> |
|
224 <b>_getDiagramRect</b>(<i>border=0</i>) |
|
225 |
|
226 <p> |
|
227 Protected method to calculate the minimum rectangle fitting the |
|
228 diagram. |
|
229 </p> |
|
230 <dl> |
|
231 |
|
232 <dt><i>border</i></dt> |
|
233 <dd> |
|
234 border width to include in the calculation (integer) |
|
235 </dd> |
|
236 </dl> |
|
237 <dl> |
|
238 <dt>Return:</dt> |
|
239 <dd> |
|
240 the minimum rectangle (QRectF) |
|
241 </dd> |
|
242 </dl> |
|
243 <a NAME="EricGraphicsView._getDiagramSize" ID="EricGraphicsView._getDiagramSize"></a> |
|
244 <h4>EricGraphicsView._getDiagramSize</h4> |
|
245 <b>_getDiagramSize</b>(<i>border=0</i>) |
|
246 |
|
247 <p> |
|
248 Protected method to calculate the minimum size fitting the diagram. |
|
249 </p> |
|
250 <dl> |
|
251 |
|
252 <dt><i>border</i></dt> |
|
253 <dd> |
|
254 border width to include in the calculation (integer) |
|
255 </dd> |
|
256 </dl> |
|
257 <dl> |
|
258 <dt>Return:</dt> |
|
259 <dd> |
|
260 the minimum size (QSizeF) |
|
261 </dd> |
|
262 </dl> |
|
263 <a NAME="EricGraphicsView.autoAdjustSceneSize" ID="EricGraphicsView.autoAdjustSceneSize"></a> |
|
264 <h4>EricGraphicsView.autoAdjustSceneSize</h4> |
|
265 <b>autoAdjustSceneSize</b>(<i>limit=False</i>) |
|
266 |
|
267 <p> |
|
268 Public method to adjust the scene size to the diagram size. |
|
269 </p> |
|
270 <dl> |
|
271 |
|
272 <dt><i>limit</i></dt> |
|
273 <dd> |
|
274 flag indicating to limit the scene to the |
|
275 initial size (boolean) |
|
276 </dd> |
|
277 </dl> |
|
278 <a NAME="EricGraphicsView.filteredItems" ID="EricGraphicsView.filteredItems"></a> |
|
279 <h4>EricGraphicsView.filteredItems</h4> |
|
280 <b>filteredItems</b>(<i>items</i>) |
|
281 |
|
282 <p> |
|
283 Public method to filter a list of items. |
|
284 </p> |
|
285 <dl> |
|
286 |
|
287 <dt><i>items</i></dt> |
|
288 <dd> |
|
289 list of items as returned by the scene object |
|
290 (QGraphicsItem) |
|
291 </dd> |
|
292 </dl> |
|
293 <dl> |
|
294 <dt>Return:</dt> |
|
295 <dd> |
|
296 list of interesting collision items (QGraphicsItem) |
|
297 </dd> |
|
298 </dl> |
|
299 <a NAME="EricGraphicsView.getBackgroundColor" ID="EricGraphicsView.getBackgroundColor"></a> |
|
300 <h4>EricGraphicsView.getBackgroundColor</h4> |
|
301 <b>getBackgroundColor</b>(<i></i>) |
|
302 |
|
303 <p> |
|
304 Public method to get the configured background color. |
|
305 </p> |
|
306 <dl> |
|
307 <dt>Return:</dt> |
|
308 <dd> |
|
309 background color |
|
310 </dd> |
|
311 </dl> |
|
312 <dl> |
|
313 <dt>Return Type:</dt> |
|
314 <dd> |
|
315 QColor |
|
316 </dd> |
|
317 </dl> |
|
318 <a NAME="EricGraphicsView.getDrawingColors" ID="EricGraphicsView.getDrawingColors"></a> |
|
319 <h4>EricGraphicsView.getDrawingColors</h4> |
|
320 <b>getDrawingColors</b>(<i></i>) |
|
321 |
|
322 <p> |
|
323 Public method to get the configured drawing colors. |
|
324 </p> |
|
325 <dl> |
|
326 <dt>Return:</dt> |
|
327 <dd> |
|
328 tuple containing the foreground and background colors |
|
329 </dd> |
|
330 </dl> |
|
331 <dl> |
|
332 <dt>Return Type:</dt> |
|
333 <dd> |
|
334 tuple of (QColor, QColor) |
|
335 </dd> |
|
336 </dl> |
|
337 <a NAME="EricGraphicsView.getForegroundColor" ID="EricGraphicsView.getForegroundColor"></a> |
|
338 <h4>EricGraphicsView.getForegroundColor</h4> |
|
339 <b>getForegroundColor</b>(<i></i>) |
|
340 |
|
341 <p> |
|
342 Public method to get the configured foreground color. |
|
343 </p> |
|
344 <dl> |
|
345 <dt>Return:</dt> |
|
346 <dd> |
|
347 foreground color |
|
348 </dd> |
|
349 </dl> |
|
350 <dl> |
|
351 <dt>Return Type:</dt> |
|
352 <dd> |
|
353 QColor |
|
354 </dd> |
|
355 </dl> |
|
356 <a NAME="EricGraphicsView.printDiagram" ID="EricGraphicsView.printDiagram"></a> |
|
357 <h4>EricGraphicsView.printDiagram</h4> |
|
358 <b>printDiagram</b>(<i>printer, diagramName=""</i>) |
|
359 |
|
360 <p> |
|
361 Public method to print the diagram. |
|
362 </p> |
|
363 <dl> |
|
364 |
|
365 <dt><i>printer</i></dt> |
|
366 <dd> |
|
367 reference to a ready configured printer object |
|
368 (QPrinter) |
|
369 </dd> |
|
370 <dt><i>diagramName</i></dt> |
|
371 <dd> |
|
372 name of the diagram (string) |
|
373 </dd> |
|
374 </dl> |
|
375 <a NAME="EricGraphicsView.resizeScene" ID="EricGraphicsView.resizeScene"></a> |
|
376 <h4>EricGraphicsView.resizeScene</h4> |
|
377 <b>resizeScene</b>(<i>amount, isWidth=True</i>) |
|
378 |
|
379 <p> |
|
380 Public method to resize the scene. |
|
381 </p> |
|
382 <dl> |
|
383 |
|
384 <dt><i>amount</i></dt> |
|
385 <dd> |
|
386 size increment (integer) |
|
387 </dd> |
|
388 <dt><i>isWidth</i></dt> |
|
389 <dd> |
|
390 flag indicating width is to be resized (boolean) |
|
391 </dd> |
|
392 </dl> |
|
393 <a NAME="EricGraphicsView.saveImage" ID="EricGraphicsView.saveImage"></a> |
|
394 <h4>EricGraphicsView.saveImage</h4> |
|
395 <b>saveImage</b>(<i>filename, imageFormat="PNG"</i>) |
|
396 |
|
397 <p> |
|
398 Public method to save the scene to a file. |
|
399 </p> |
|
400 <dl> |
|
401 |
|
402 <dt><i>filename</i></dt> |
|
403 <dd> |
|
404 name of the file to write the image to (string) |
|
405 </dd> |
|
406 <dt><i>imageFormat</i></dt> |
|
407 <dd> |
|
408 format for the image file (string) |
|
409 </dd> |
|
410 </dl> |
|
411 <dl> |
|
412 <dt>Return:</dt> |
|
413 <dd> |
|
414 flag indicating success (boolean) |
|
415 </dd> |
|
416 </dl> |
|
417 <a NAME="EricGraphicsView.setSceneSize" ID="EricGraphicsView.setSceneSize"></a> |
|
418 <h4>EricGraphicsView.setSceneSize</h4> |
|
419 <b>setSceneSize</b>(<i>width, height</i>) |
|
420 |
|
421 <p> |
|
422 Public method to set the scene size. |
|
423 </p> |
|
424 <dl> |
|
425 |
|
426 <dt><i>width</i></dt> |
|
427 <dd> |
|
428 width for the scene (real) |
|
429 </dd> |
|
430 <dt><i>height</i></dt> |
|
431 <dd> |
|
432 height for the scene (real) |
|
433 </dd> |
|
434 </dl> |
|
435 <a NAME="EricGraphicsView.setZoom" ID="EricGraphicsView.setZoom"></a> |
|
436 <h4>EricGraphicsView.setZoom</h4> |
|
437 <b>setZoom</b>(<i>value</i>) |
|
438 |
|
439 <p> |
|
440 Public method to set the zoom value in percent. |
|
441 </p> |
|
442 <dl> |
|
443 |
|
444 <dt><i>value</i></dt> |
|
445 <dd> |
|
446 zoom value in percent (integer) |
|
447 </dd> |
|
448 </dl> |
|
449 <a NAME="EricGraphicsView.zoom" ID="EricGraphicsView.zoom"></a> |
|
450 <h4>EricGraphicsView.zoom</h4> |
|
451 <b>zoom</b>(<i></i>) |
|
452 |
|
453 <p> |
|
454 Public method to get the current zoom factor in percent. |
|
455 </p> |
|
456 <dl> |
|
457 <dt>Return:</dt> |
|
458 <dd> |
|
459 current zoom factor in percent (integer) |
|
460 </dd> |
|
461 </dl> |
|
462 <a NAME="EricGraphicsView.zoomIn" ID="EricGraphicsView.zoomIn"></a> |
|
463 <h4>EricGraphicsView.zoomIn</h4> |
|
464 <b>zoomIn</b>(<i></i>) |
|
465 |
|
466 <p> |
|
467 Public method to zoom in. |
|
468 </p> |
|
469 <a NAME="EricGraphicsView.zoomOut" ID="EricGraphicsView.zoomOut"></a> |
|
470 <h4>EricGraphicsView.zoomOut</h4> |
|
471 <b>zoomOut</b>(<i></i>) |
|
472 |
|
473 <p> |
|
474 Public method to zoom out. |
|
475 </p> |
|
476 <a NAME="EricGraphicsView.zoomReset" ID="EricGraphicsView.zoomReset"></a> |
|
477 <h4>EricGraphicsView.zoomReset</h4> |
|
478 <b>zoomReset</b>(<i></i>) |
|
479 |
|
480 <p> |
|
481 Public method to handle the reset the zoom value. |
|
482 </p> |
|
483 <div align="right"><a href="#top">Up</a></div> |
|
484 <hr /> |
|
485 </body></html> |