High quality png export of bar figures. Save file dialog added for bar figures.
This commit is contained in:
parent
6b4e5fba9b
commit
38d1cfe435
@ -36,11 +36,13 @@ DEFAULT_COLORS = [ASCEEColors.blue, ASCEEColors.green, Qt.red, Qt.cyan,
|
|||||||
Qt.darkYellow,
|
Qt.darkYellow,
|
||||||
Qt.darkMagenta]
|
Qt.darkMagenta]
|
||||||
|
|
||||||
|
|
||||||
def graphicsTextItem(label):
|
def graphicsTextItem(label):
|
||||||
item = QGraphicsTextItem(label)
|
item = QGraphicsTextItem(label)
|
||||||
item.setFont(Branding.figureFont())
|
item.setFont(Branding.figureFont())
|
||||||
return item
|
return item
|
||||||
|
|
||||||
|
|
||||||
class BarScene(QGraphicsScene):
|
class BarScene(QGraphicsScene):
|
||||||
"""
|
"""
|
||||||
Graphhics Scene for plotting bars
|
Graphhics Scene for plotting bars
|
||||||
@ -231,18 +233,22 @@ class BarScene(QGraphicsScene):
|
|||||||
Returns:
|
Returns:
|
||||||
True on success
|
True on success
|
||||||
"""
|
"""
|
||||||
image = QImage(*self.size,
|
size = self.size
|
||||||
|
pixelsx = max(1200, size[0])
|
||||||
|
pixelsy = int(pixelsx*size[1]/size[0])
|
||||||
|
imagesize = (pixelsx, pixelsy)
|
||||||
|
image = QImage(pixelsx,
|
||||||
|
pixelsy,
|
||||||
QImage.Format_ARGB32_Premultiplied)
|
QImage.Format_ARGB32_Premultiplied)
|
||||||
|
|
||||||
painter = QPainter(image)
|
painter = QPainter(image)
|
||||||
# painter.begin()
|
painter.setRenderHint(QPainter.Antialiasing)
|
||||||
# painter.setRenderHint(QPainter.Antialiasing)
|
|
||||||
painter.setBrush(Qt.white)
|
painter.setBrush(Qt.white)
|
||||||
painter.setPen(Qt.white)
|
painter.setPen(Qt.white)
|
||||||
painter.drawRect(QRect(0, 0, *self.size))
|
painter.drawRect(QRect(0, 0, *imagesize))
|
||||||
|
|
||||||
targetrect = QRectF(0, 0, *self.size)
|
targetrect = QRectF(0, 0, *imagesize)
|
||||||
sourcerect = QRectF(0, 0, *self.size)
|
sourcerect = QRectF(0, 0, *size)
|
||||||
self.render(painter, targetrect, sourcerect)
|
self.render(painter, targetrect, sourcerect)
|
||||||
painter.end()
|
painter.end()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user