eric6/E5Graphics/E5GraphicsView.py

Mon, 15 Apr 2019 19:53:29 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Mon, 15 Apr 2019 19:53:29 +0200
branch
setup.py
changeset 6949
a5255f1ba3f0
parent 6942
2602857055c5
child 7229
53054eb5b15a
permissions
-rw-r--r--

setup.py: continued implementing support for setup.py.

51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
6645
ad476851d7e0 Updated copyright for 2019.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
3 # Copyright (c) 2007 - 2019 Detlev Offenbach <detlev@die-offenbachs.de>
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a canvas view class.
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
3145
a9de05d4a22f # __IGNORE_WARNING__ added/ removed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3060
diff changeset
10 from __future__ import unicode_literals
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2334
diff changeset
11
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 import sys
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
14 from PyQt5.QtCore import pyqtSignal, QRectF, QSize, QSizeF, Qt
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
15 from PyQt5.QtGui import QBrush, QPainter, QPixmap, QFont, QColor
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
16 from PyQt5.QtWidgets import QGraphicsView
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 import Preferences
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
20
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 class E5GraphicsView(QGraphicsView):
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 """
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 Class implementing a graphics view.
2334
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
24
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
25 @signal zoomValueChanged(int) emitted to signal a change of the zoom value
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 """
2334
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
27 zoomValueChanged = pyqtSignal(int)
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
28
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
29 ZoomLevels = [
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
30 1, 3, 5, 7, 9,
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
31 10, 20, 30, 50, 67, 80, 90,
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
32 100,
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
33 110, 120, 133, 150, 170, 200, 240, 300, 400,
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
34 500, 600, 700, 800, 900, 1000,
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
35 ]
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
36 ZoomLevelDefault = 100
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
37
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
38 def __init__(self, scene, parent=None):
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 """
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 Constructor
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 @param scene reference to the scene object (QGraphicsScene)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 @param parent parent widget (QWidget)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 """
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2334
diff changeset
45 super(E5GraphicsView, self).__init__(scene, parent)
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 self.setObjectName("E5GraphicsView")
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47
2027
144463496a54 A few fixes for issues with the graphics dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2026
diff changeset
48 self.__initialSceneSize = self.scene().sceneRect().size()
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 self.setBackgroundBrush(QBrush(Qt.white))
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 self.setRenderHint(QPainter.Antialiasing, True)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 self.setDragMode(QGraphicsView.RubberBandDrag)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 self.setAlignment(Qt.Alignment(Qt.AlignLeft | Qt.AlignTop))
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
2027
144463496a54 A few fixes for issues with the graphics dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2026
diff changeset
55 self.setViewportUpdateMode(QGraphicsView.SmartViewportUpdate)
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
57 self.setWhatsThis(self.tr(
2990
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
58 "<b>Graphics View</b>\n"
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 "<p>This graphics view is used to show a diagram. \n"
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 "There are various actions available to manipulate the \n"
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 "shown items.</p>\n"
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 "<ul>\n"
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 "<li>Clicking on an item selects it.</li>\n"
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 "<li>Ctrl-clicking adds an item to the selection.</li>\n"
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 "<li>Ctrl-clicking a selected item deselects it.</li>\n"
2990
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
66 "<li>Clicking on an empty spot of the canvas resets the selection."
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
67 "</li>\n"
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 "<li>Dragging the mouse over the canvas spans a rubberband to \n"
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 "select multiple items.</li>\n"
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 "<li>Dragging the mouse over a selected item moves the \n"
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 "whole selection.</li>\n"
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 "</ul>\n"
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 ))
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74
2334
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
75 def __levelForZoom(self, zoom):
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
76 """
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
77 Private method determining the zoom level index given a zoom factor.
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
78
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
79 @param zoom zoom factor (integer)
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
80 @return index of zoom factor (integer)
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
81 """
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
82 try:
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
83 index = E5GraphicsView.ZoomLevels.index(zoom)
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
84 except ValueError:
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
85 for index in range(len(E5GraphicsView.ZoomLevels)):
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
86 if zoom <= E5GraphicsView.ZoomLevels[index]:
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
87 break
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
88 return index
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
89
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 def zoomIn(self):
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 """
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 Public method to zoom in.
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 """
2334
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
94 index = self.__levelForZoom(self.zoom())
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
95 if index < len(E5GraphicsView.ZoomLevels) - 1:
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
96 self.setZoom(E5GraphicsView.ZoomLevels[index + 1])
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 def zoomOut(self):
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 """
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 Public method to zoom out.
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 """
2334
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
102 index = self.__levelForZoom(self.zoom())
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
103 if index > 0:
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
104 self.setZoom(E5GraphicsView.ZoomLevels[index - 1])
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 def zoomReset(self):
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 """
2334
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
108 Public method to handle the reset the zoom value.
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 """
2990
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
110 self.setZoom(
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
111 E5GraphicsView.ZoomLevels[E5GraphicsView.ZoomLevelDefault])
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112
2334
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
113 def setZoom(self, value):
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 """
2334
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
115 Public method to set the zoom value in percent.
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116
2334
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
117 @param value zoom value in percent (integer)
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 """
2334
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
119 if value != self.zoom():
3781
a27433350e5f Fixed an issue with obsolete Qt class methods in E5GraphicsView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
120 self.resetTransform()
2334
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
121 factor = value / 100.0
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
122 self.scale(factor, factor)
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
123 self.zoomValueChanged.emit(value)
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 def zoom(self):
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 """
2334
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
127 Public method to get the current zoom factor in percent.
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128
2334
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
129 @return current zoom factor in percent (integer)
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 """
3781
a27433350e5f Fixed an issue with obsolete Qt class methods in E5GraphicsView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
131 return int(self.transform().m11() * 100.0)
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
133 def resizeScene(self, amount, isWidth=True):
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134 """
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 Public method to resize the scene.
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136
2953
703452a2876f Started correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2334
diff changeset
137 @param amount size increment (integer)
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 @param isWidth flag indicating width is to be resized (boolean)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139 """
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140 sceneRect = self.scene().sceneRect()
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141 width = sceneRect.width()
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142 height = sceneRect.height()
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143 if isWidth:
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144 width += amount
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145 else:
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 height += amount
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147 rect = self._getDiagramRect(10)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148 if width < rect.width():
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 width = rect.width()
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 if height < rect.height():
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 height = rect.height()
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153 self.setSceneSize(width, height)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155 def setSceneSize(self, width, height):
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156 """
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 Public method to set the scene size.
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158
2027
144463496a54 A few fixes for issues with the graphics dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2026
diff changeset
159 @param width width for the scene (real)
144463496a54 A few fixes for issues with the graphics dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2026
diff changeset
160 @param height height for the scene (real)
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161 """
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162 rect = self.scene().sceneRect()
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163 rect.setHeight(height)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164 rect.setWidth(width)
2027
144463496a54 A few fixes for issues with the graphics dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2026
diff changeset
165 self.scene().setSceneRect(rect)
144463496a54 A few fixes for issues with the graphics dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2026
diff changeset
166
144463496a54 A few fixes for issues with the graphics dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2026
diff changeset
167 def autoAdjustSceneSize(self, limit=False):
144463496a54 A few fixes for issues with the graphics dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2026
diff changeset
168 """
144463496a54 A few fixes for issues with the graphics dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2026
diff changeset
169 Public method to adjust the scene size to the diagram size.
144463496a54 A few fixes for issues with the graphics dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2026
diff changeset
170
144463496a54 A few fixes for issues with the graphics dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2026
diff changeset
171 @param limit flag indicating to limit the scene to the
144463496a54 A few fixes for issues with the graphics dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2026
diff changeset
172 initial size (boolean)
144463496a54 A few fixes for issues with the graphics dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2026
diff changeset
173 """
144463496a54 A few fixes for issues with the graphics dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2026
diff changeset
174 size = self._getDiagramSize(10)
144463496a54 A few fixes for issues with the graphics dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2026
diff changeset
175 if limit:
144463496a54 A few fixes for issues with the graphics dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2026
diff changeset
176 newWidth = max(size.width(), self.__initialSceneSize.width())
144463496a54 A few fixes for issues with the graphics dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2026
diff changeset
177 newHeight = max(size.height(), self.__initialSceneSize.height())
144463496a54 A few fixes for issues with the graphics dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2026
diff changeset
178 else:
144463496a54 A few fixes for issues with the graphics dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2026
diff changeset
179 newWidth = size.width()
144463496a54 A few fixes for issues with the graphics dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2026
diff changeset
180 newHeight = size.height()
144463496a54 A few fixes for issues with the graphics dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2026
diff changeset
181 self.setSceneSize(newWidth, newHeight)
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
183 def _getDiagramRect(self, border=0):
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
184 """
2990
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
185 Protected method to calculate the minimum rectangle fitting the
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
186 diagram.
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
188 @param border border width to include in the calculation (integer)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
189 @return the minimum rectangle (QRectF)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190 """
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191 startx = sys.maxsize
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192 starty = sys.maxsize
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193 endx = 0
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
194 endy = 0
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195 items = self.filteredItems(list(self.scene().items()))
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196 for itm in items:
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
197 rect = itm.sceneBoundingRect()
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
198 itmEndX = rect.x() + rect.width()
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
199 itmEndY = rect.y() + rect.height()
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
200 itmStartX = rect.x()
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
201 itmStartY = rect.y()
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
202 if startx >= itmStartX:
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
203 startx = itmStartX
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204 if starty >= itmStartY:
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205 starty = itmStartY
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
206 if endx <= itmEndX:
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
207 endx = itmEndX
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
208 if endy <= itmEndY:
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
209 endy = itmEndY
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
210 if border:
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
211 startx -= border
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
212 starty -= border
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
213 endx += border
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
214 endy += border
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216 return QRectF(startx, starty, endx - startx + 1, endy - starty + 1)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
217
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
218 def _getDiagramSize(self, border=0):
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
219 """
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
220 Protected method to calculate the minimum size fitting the diagram.
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
221
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
222 @param border border width to include in the calculation (integer)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
223 @return the minimum size (QSizeF)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
224 """
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
225 endx = 0
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
226 endy = 0
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
227 items = self.filteredItems(list(self.scene().items()))
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
228 for itm in items:
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
229 rect = itm.sceneBoundingRect()
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
230 itmEndX = rect.x() + rect.width()
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
231 itmEndY = rect.y() + rect.height()
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
232 if endx <= itmEndX:
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
233 endx = itmEndX
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
234 if endy <= itmEndY:
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
235 endy = itmEndY
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
236 if border:
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
237 endx += border
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
238 endy += border
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
239
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
240 return QSizeF(endx + 1, endy + 1)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
241
5587
ea526b78ee6c Started to fix code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
242 def __getDiagram(self, rect, imageFormat="PNG", filename=None):
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
243 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
244 Private method to retrieve the diagram from the scene fitting it
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
245 in the minimum rectangle.
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
246
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
247 @param rect minimum rectangle fitting the diagram (QRectF)
5587
ea526b78ee6c Started to fix code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
248 @param imageFormat format for the image file (string)
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
249 @param filename name of the file for non pixmaps (string)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
250 @return diagram pixmap to receive the diagram (QPixmap)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
251 """
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
252 selectedItems = self.scene().selectedItems()
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
253
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
254 # step 1: deselect all widgets
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
255 if selectedItems:
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
256 for item in selectedItems:
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
257 item.setSelected(False)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
258
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
259 # step 2: grab the diagram
5587
ea526b78ee6c Started to fix code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
260 if imageFormat == "PNG":
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
261 paintDevice = QPixmap(int(rect.width()), int(rect.height()))
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
262 paintDevice.fill(self.backgroundBrush().color())
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
263 else:
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
264 from PyQt5.QtSvg import QSvgGenerator
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
265 paintDevice = QSvgGenerator()
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
266 paintDevice.setResolution(100) # 100 dpi
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
267 paintDevice.setSize(QSize(int(rect.width()), int(rect.height())))
2334
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
268 paintDevice.setViewBox(rect)
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
269 paintDevice.setFileName(filename)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
270 painter = QPainter(paintDevice)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
271 painter.setRenderHint(QPainter.Antialiasing, True)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
272 self.scene().render(painter, QRectF(), rect)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
273
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
274 # step 3: reselect the widgets
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
275 if selectedItems:
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
276 for item in selectedItems:
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
277 item.setSelected(True)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
278
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
279 return paintDevice
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
280
5587
ea526b78ee6c Started to fix code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
281 def saveImage(self, filename, imageFormat="PNG"):
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
282 """
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
283 Public method to save the scene to a file.
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
284
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
285 @param filename name of the file to write the image to (string)
5587
ea526b78ee6c Started to fix code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
286 @param imageFormat format for the image file (string)
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
287 @return flag indicating success (boolean)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
288 """
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
289 rect = self._getDiagramRect(self.border)
5587
ea526b78ee6c Started to fix code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
290 if imageFormat == "SVG":
ea526b78ee6c Started to fix code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
291 self.__getDiagram(rect, imageFormat=imageFormat, filename=filename)
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
292 return True
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
293 else:
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
294 pixmap = self.__getDiagram(rect)
5587
ea526b78ee6c Started to fix code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
295 return pixmap.save(filename, imageFormat)
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
296
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
297 def printDiagram(self, printer, diagramName=""):
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
298 """
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
299 Public method to print the diagram.
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
300
2990
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
301 @param printer reference to a ready configured printer object
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
302 (QPrinter)
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
303 @param diagramName name of the diagram (string)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
304 """
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
305 painter = QPainter()
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
306 painter.begin(printer)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
307 offsetX = 0
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
308 offsetY = 0
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
309 widthX = 0
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
310 heightY = 0
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
311 font = QFont("times", 10)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
312 painter.setFont(font)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
313 fm = painter.fontMetrics()
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
314 fontHeight = fm.lineSpacing()
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
315 marginX = printer.pageRect().x() - printer.paperRect().x()
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
316 marginX = \
2990
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
317 Preferences.getPrinter("LeftMargin") * int(
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
318 printer.resolution() / 2.54) - marginX
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
319 marginY = printer.pageRect().y() - printer.paperRect().y()
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
320 marginY = \
2990
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
321 Preferences.getPrinter("TopMargin") * int(
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
322 printer.resolution() / 2.54) - marginY
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
323
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
324 width = printer.width() - marginX \
2990
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
325 - Preferences.getPrinter("RightMargin") * int(
3035
36e9f388958b Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3022
diff changeset
326 printer.resolution() / 2.54)
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
327 height = printer.height() - fontHeight - 4 - marginY \
2990
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
328 - Preferences.getPrinter("BottomMargin") * int(
3035
36e9f388958b Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3022
diff changeset
329 printer.resolution() / 2.54)
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
330
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
331 border = self.border == 0 and 5 or self.border
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
332 rect = self._getDiagramRect(border)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
333 diagram = self.__getDiagram(rect)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
334
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
335 finishX = False
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
336 finishY = False
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
337 page = 0
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
338 pageX = 0
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
339 pageY = 1
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
340 while not finishX or not finishY:
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
341 if not finishX:
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
342 offsetX = pageX * width
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
343 pageX += 1
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
344 elif not finishY:
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
345 offsetY = pageY * height
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
346 offsetX = 0
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
347 pageY += 1
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
348 finishX = False
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
349 pageX = 1
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
350 if (width + offsetX) > diagram.width():
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
351 finishX = True
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
352 widthX = diagram.width() - offsetX
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
353 else:
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
354 widthX = width
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
355 if diagram.width() < width:
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
356 widthX = diagram.width()
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
357 finishX = True
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
358 offsetX = 0
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
359 if (height + offsetY) > diagram.height():
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
360 finishY = True
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
361 heightY = diagram.height() - offsetY
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
362 else:
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
363 heightY = height
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
364 if diagram.height() < height:
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
365 finishY = True
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
366 heightY = diagram.height()
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
367 offsetY = 0
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
368
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
369 painter.drawPixmap(marginX, marginY, diagram,
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
370 offsetX, offsetY, widthX, heightY)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
371 # write a foot note
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
372 s = self.tr("{0}, Page {1}").format(diagramName, page + 1)
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
373 tc = QColor(50, 50, 50)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
374 painter.setPen(tc)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
375 painter.drawRect(marginX, marginY, width, height)
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
376 painter.drawLine(marginX, marginY + height + 2,
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2990
diff changeset
377 marginX + width, marginY + height + 2)
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
378 painter.setFont(font)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
379 painter.drawText(marginX, marginY + height + 4, width,
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2990
diff changeset
380 fontHeight, Qt.AlignRight, s)
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
381 if not finishX or not finishY:
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
382 printer.newPage()
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
383 page += 1
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
384
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
385 painter.end()
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
386
2990
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
387 ###########################################################################
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
388 ## The methods below should be overridden by subclasses to get special
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
389 ## behavior.
2990
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
390 ###########################################################################
51
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
391
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
392 def filteredItems(self, items):
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
393 """
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
394 Public method to filter a list of items.
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
395
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
396 @param items list of items as returned by the scene object
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
397 (QGraphicsItem)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
398 @return list of interesting collision items (QGraphicsItem)
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
399 """
7d80b0f20ca6 Renamed E4Graphics to E5Graphics.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
400 # just return the list unchanged
96
9624a110667d Started to clean up the code supported by py3flakes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 51
diff changeset
401 return items

eric ide

mercurial