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