src/eric7/EricGraphics/EricGraphicsView.py

branch
eric7
changeset 10917
4f40180b98dc
parent 10439
21c28b0f9e41
child 10922
36a90a94765c
equal deleted inserted replaced
10916:5445732f693f 10917:4f40180b98dc
339 if imageFormat == "PNG": 339 if imageFormat == "PNG":
340 paintDevice = QPixmap(int(rect.width()), int(rect.height())) 340 paintDevice = QPixmap(int(rect.width()), int(rect.height()))
341 paintDevice.fill(self.backgroundBrush().color()) 341 paintDevice.fill(self.backgroundBrush().color())
342 else: 342 else:
343 paintDevice = QSvgGenerator() 343 paintDevice = QSvgGenerator()
344 paintDevice.setFileName(filename)
344 paintDevice.setResolution(100) # 100 dpi 345 paintDevice.setResolution(100) # 100 dpi
345 paintDevice.setSize(QSize(int(rect.width()), int(rect.height()))) 346 paintDevice.setSize(QSize(int(rect.width()), int(rect.height())))
346 paintDevice.setViewBox(rect) 347 paintDevice.setViewBox(rect)
347 paintDevice.setFileName(filename)
348 painter = QPainter(paintDevice) 348 painter = QPainter(paintDevice)
349 painter.setRenderHint(QPainter.RenderHint.Antialiasing, True) 349 painter.setRenderHint(QPainter.RenderHint.Antialiasing, True)
350 self.scene().render(painter, QRectF(), rect) 350 painter.begin(paintDevice)
351 self.render(painter, QRectF(), rect.toRect())
352 painter.end()
351 353
352 # step 3: reselect the widgets 354 # step 3: reselect the widgets
353 if selectedItems: 355 if selectedItems:
354 for item in selectedItems: 356 for item in selectedItems:
355 item.setSelected(True) 357 item.setSelected(True)
393 marginX = ( 395 marginX = (
394 printer.pageLayout().paintRectPixels(printer.resolution()).x() 396 printer.pageLayout().paintRectPixels(printer.resolution()).x()
395 - printer.pageLayout().fullRectPixels(printer.resolution()).x() 397 - printer.pageLayout().fullRectPixels(printer.resolution()).x()
396 ) 398 )
397 marginX = ( 399 marginX = (
398 Preferences.getPrinter("LeftMargin") * int(printer.resolution() / 2.54) 400 int(Preferences.getPrinter("LeftMargin") * printer.resolution() / 2.54)
399 - marginX 401 - marginX
400 ) 402 )
401 marginY = ( 403 marginY = (
402 printer.pageLayout().paintRectPixels(printer.resolution()).y() 404 printer.pageLayout().paintRectPixels(printer.resolution()).y()
403 - printer.pageLayout().fullRectPixels(printer.resolution()).y() 405 - printer.pageLayout().fullRectPixels(printer.resolution()).y()
404 ) 406 )
405 marginY = ( 407 marginY = (
406 Preferences.getPrinter("TopMargin") * int(printer.resolution() / 2.54) 408 int(Preferences.getPrinter("TopMargin") * printer.resolution() / 2.54)
407 - marginY 409 - marginY
408 ) 410 )
409 411
410 width = ( 412 width = (
411 printer.width() 413 printer.width()
412 - marginX 414 - marginX
413 - Preferences.getPrinter("RightMargin") * int(printer.resolution() / 2.54) 415 - int(Preferences.getPrinter("RightMargin") * printer.resolution() / 2.54)
414 ) 416 )
415 height = ( 417 height = (
416 printer.height() 418 printer.height()
417 - fontHeight 419 - fontHeight
418 - 4 420 - 4
419 - marginY 421 - marginY
420 - Preferences.getPrinter("BottomMargin") * int(printer.resolution() / 2.54) 422 - int(Preferences.getPrinter("BottomMargin") * printer.resolution() / 2.54)
421 ) 423 )
422 424
423 self.scene().render(painter, target=QRectF(marginX, marginY, width, height)) 425 self.render(painter, target=QRectF(marginX, marginY, width, height))
424 426
425 # write a foot note 427 # write a foot note
426 tc = QColor(50, 50, 50) 428 tc = QColor(50, 50, 50)
427 painter.setPen(tc) 429 painter.setPen(tc)
428 painter.drawRect(marginX, marginY, width, height) 430 painter.drawRect(marginX, marginY, width, height)

eric ide

mercurial