def saveSceneToFile(self, filename, imageformat, transparent, rastsize):
    '\n        Save the current scene to the named file.\n        \n        If imageformat is empty or None, the format is guessed from\n        the filename extension.\n\n        If transparent is False, the entire scene is initialized\n        to the last clearing color.\n\n        If given, rastsize is the pixels size of the saved image.\n        If rastsize is not given, the saved image will be saved\n        at the current scaled image size.  \n        '
    if (self.__sceneimage == None):
        return
    if (not imageformat):
        fileext = os.path.splitext(filename)[1].lower()
        if (fileext == '.gif'):
            myformat = 'gif'
        else:
            myformat = None
    else:
        myformat = imageformat.lower()
    if (myformat == 'gif'):
        myformat = 'png'
        myfilename = (os.path.splitext(filename)[0] + '.png')
    else:
        myfilename = filename
    QApplication.setOverrideCursor(Qt.WaitCursor)
    self.statusBar().showMessage(self.tr('Saving image'))
    try:
        if rastsize:
            imagewidth = int((rastsize.width() + 0.5))
            imageheight = int((rastsize.height() + 0.5))
        else:
            imagewidth = int(((self.__scenewidth * self.__scalefactor) + 0.5))
            imageheight = int(((self.__sceneheight * self.__scalefactor) + 0.5))
        myimage = QImage(QSize(imagewidth, imageheight), QImage.Format_ARGB32_Premultiplied)
        if (not transparent):
            fillint = self.__helper.computeARGB32PreMultInt(self.__lastclearcolor)
        else:
            fillint = 0
        myimage.fill(fillint)
        mypainter = QPainter(myimage)
        trgrect = QRectF(0.0, 0.0, float(imagewidth), float(imageheight))
        srcrect = QRectF(0.0, 0.0, float(self.__scenewidth), float(self.__sceneheight))
        mypainter.drawImage(trgrect, self.__sceneimage, srcrect, Qt.AutoColor)
        mypainter.end()
        if (not myimage.save(myfilename, myformat)):
            raise ValueError(('Unable to save the plot as ' + myfilename))
    finally:
        self.statusBar().clearMessage()
        QApplication.restoreOverrideCursor()
Save the current scene to the named file.

If imageformat is empty or None, the format is guessed from
the filename extension.

If transparent is False, the entire scene is initialized
to the last clearing color.

If given, rastsize is the pixels size of the saved image.
If rastsize is not given, the saved image will be saved
at the current scaled image size.
def saveSceneToFile(self, filename, imageformat, transparent, rastsize):
    '\n        Save the current scene to the named file.\n        \n        If imageformat is empty or None, the format is guessed from\n        the filename extension.\n\n        If transparent is False, the entire scene is initialized\n        to the last clearing color.\n\n        If given, rastsize is the pixels size of the saved image.\n        If rastsize is not given, the saved image will be saved\n        at the current scaled image size.  \n        '
    if (self.__sceneimage == None):
        return
    if (not imageformat):
        fileext = os.path.splitext(filename)[1].lower()
        if (fileext == '.gif'):
            myformat = 'gif'
        else:
            myformat = None
    else:
        myformat = imageformat.lower()
    if (myformat == 'gif'):
        myformat = 'png'
        myfilename = (os.path.splitext(filename)[0] + '.png')
    else:
        myfilename = filename
    QApplication.setOverrideCursor(Qt.WaitCursor)
    self.statusBar().showMessage(self.tr('Saving image'))
    try:
        if rastsize:
            imagewidth = int((rastsize.width() + 0.5))
            imageheight = int((rastsize.height() + 0.5))
        else:
            imagewidth = int(((self.__scenewidth * self.__scalefactor) + 0.5))
            imageheight = int(((self.__sceneheight * self.__scalefactor) + 0.5))
        myimage = QImage(QSize(imagewidth, imageheight), QImage.Format_ARGB32_Premultiplied)
        if (not transparent):
            fillint = self.__helper.computeARGB32PreMultInt(self.__lastclearcolor)
        else:
            fillint = 0
        myimage.fill(fillint)
        mypainter = QPainter(myimage)
        trgrect = QRectF(0.0, 0.0, float(imagewidth), float(imageheight))
        srcrect = QRectF(0.0, 0.0, float(self.__scenewidth), float(self.__sceneheight))
        mypainter.drawImage(trgrect, self.__sceneimage, srcrect, Qt.AutoColor)
        mypainter.end()
        if (not myimage.save(myfilename, myformat)):
            raise ValueError(('Unable to save the plot as ' + myfilename))
    finally:
        self.statusBar().clearMessage()
        QApplication.restoreOverrideCursor()