Graphics/SvgDiagram.py

changeset 945
8cd4d08fa9f6
parent 791
9ec2ac20e54e
child 1112
8a7d1b9d18db
equal deleted inserted replaced
944:1b59c4ba121e 945:8cd4d08fa9f6
14 from .ZoomDialog import ZoomDialog 14 from .ZoomDialog import ZoomDialog
15 15
16 import UI.Config 16 import UI.Config
17 17
18 import Preferences 18 import Preferences
19
19 20
20 class SvgDiagram(QMainWindow): 21 class SvgDiagram(QMainWindow):
21 """ 22 """
22 Class implementing a dialog showing a SVG graphic. 23 Class implementing a dialog showing a SVG graphic.
23 """ 24 """
24 def __init__(self, svgFile, parent = None, name = None): 25 def __init__(self, svgFile, parent=None, name=None):
25 """ 26 """
26 Constructor 27 Constructor
27 28
28 @param svgFile filename of a SVG graphics file to show (string) 29 @param svgFile filename of a SVG graphics file to show (string)
29 @param parent parent widget of the view (QWidget) 30 @param parent parent widget of the view (QWidget)
164 165
165 @param scrollBar reference to the scrollbar object (QScrollBar) 166 @param scrollBar reference to the scrollbar object (QScrollBar)
166 @param factor factor to adjust by (float) 167 @param factor factor to adjust by (float)
167 """ 168 """
168 scrollBar.setValue(int(factor * scrollBar.value() 169 scrollBar.setValue(int(factor * scrollBar.value()
169 + ((factor - 1) * scrollBar.pageStep()/2))) 170 + ((factor - 1) * scrollBar.pageStep() / 2)))
170 171
171 def __doZoom(self, factor): 172 def __doZoom(self, factor):
172 """ 173 """
173 Private method to perform the zooming. 174 Private method to perform the zooming.
174 175
211 212
212 def __printDiagram(self): 213 def __printDiagram(self):
213 """ 214 """
214 Private slot called to print the diagram. 215 Private slot called to print the diagram.
215 """ 216 """
216 printer = QPrinter(mode = QPrinter.ScreenResolution) 217 printer = QPrinter(mode=QPrinter.ScreenResolution)
217 printer.setFullPage(True) 218 printer.setFullPage(True)
218 if Preferences.getPrinter("ColorMode"): 219 if Preferences.getPrinter("ColorMode"):
219 printer.setColorMode(QPrinter.Color) 220 printer.setColorMode(QPrinter.Color)
220 else: 221 else:
221 printer.setColorMode(QPrinter.GrayScale) 222 printer.setColorMode(QPrinter.GrayScale)
233 """ 234 """
234 Private slot called to show a print preview of the diagram. 235 Private slot called to show a print preview of the diagram.
235 """ 236 """
236 from PyQt4.QtGui import QPrintPreviewDialog 237 from PyQt4.QtGui import QPrintPreviewDialog
237 238
238 printer = QPrinter(mode = QPrinter.ScreenResolution) 239 printer = QPrinter(mode=QPrinter.ScreenResolution)
239 printer.setFullPage(True) 240 printer.setFullPage(True)
240 if Preferences.getPrinter("ColorMode"): 241 if Preferences.getPrinter("ColorMode"):
241 printer.setColorMode(QPrinter.Color) 242 printer.setColorMode(QPrinter.Color)
242 else: 243 else:
243 printer.setColorMode(QPrinter.GrayScale) 244 printer.setColorMode(QPrinter.GrayScale)
282 # write a foot note 283 # write a foot note
283 s = self.trUtf8("Diagram: {0}").format(self.getDiagramName()) 284 s = self.trUtf8("Diagram: {0}").format(self.getDiagramName())
284 tc = QColor(50, 50, 50) 285 tc = QColor(50, 50, 50)
285 painter.setPen(tc) 286 painter.setPen(tc)
286 painter.drawRect(marginX, marginY, width, height) 287 painter.drawRect(marginX, marginY, width, height)
287 painter.drawLine(marginX, marginY + height + 2, 288 painter.drawLine(marginX, marginY + height + 2,
288 marginX + width, marginY + height + 2) 289 marginX + width, marginY + height + 2)
289 painter.setFont(font) 290 painter.setFont(font)
290 painter.drawText(marginX, marginY + height + 4, width, 291 painter.drawText(marginX, marginY + height + 4, width,
291 fontHeight, Qt.AlignRight, s) 292 fontHeight, Qt.AlignRight, s)
292 293

eric ide

mercurial