Beispiel #1
0
    def outTIF(self, plotWidget, d_folder, name, title):
        if d_folder:
            fileName = os.path.join(d_folder, name + '.tif')
        else:
            if self.settings.value('lastOutputDir'):
                folder = self.settings.value('lastOutputDir')
            else:
                folder = self.settings.value('projFolder')

            fileName = QFileDialog.getSaveFileName(
                caption="Save Plot As .tif file",
                directory=folder,
                filter="Tagged Image File Format (*.tif;*.tiff)")
        fileName = toUnicode(fileName)

        if fileName:
            if not title:
                title = self.settings.value('figureTitle')
            plotWidget.setTitle(title)
            pix = QPixmap(QSize(600, 400))
            sh = QBrush(pix)
            sh.setColor(Qt.white)
            sh.setStyle(Qt.SolidPattern)
            painter = QPainter()
            painter.begin(pix)
            painter.setBrush(sh)
            painter.drawRect(0, 0, 600, 400)
            painter.end()

            legend = QwtLegend()
            plotWidget.insertLegend(legend)
            plotWidget.setAxisTitle(QwtPlot.xBottom,
                                    self.settings.value('xAxisTitle'))
            plotWidget.setAxisTitle(QwtPlot.yLeft,
                                    self.settings.value('yAxisTitle'))

            QSettings().setValue("lastOutputDir", os.path.dirname(fileName))
            filter = QwtPlotPrintFilter()
            filter.setOptions(QwtPlotPrintFilter.PrintAll
                              & ~QwtPlotPrintFilter.PrintBackground)
            plotWidget.print_(pix, filter)
            pix.save(fileName)
            plotWidget.insertLegend(None)
            plotWidget.setAxisTitle(QwtPlot.xBottom, None)
            plotWidget.setAxisTitle(QwtPlot.yLeft, None)
            plotWidget.setTitle(None)
Beispiel #2
0
    def outSVG(self, plotWidget, d_folder, name, title):
        if d_folder:
            fileName = os.path.join(d_folder, name + '.svg')
        else:
            if self.settings.value('lastOutputDir'):
                folder = self.settings.value('lastOutputDir')
            else:
                folder = self.settings.value('projFolder')

            fileName = QFileDialog.getSaveFileName(
                caption="Save Plot As .svg file",
                directory=folder,
                filter="Scalable Vector Graphics(*.svg)")
        fileName = toUnicode(fileName)

        if fileName:
            pix = QSvgGenerator()
            pix.setFileName(fileName)
            pix.setSize(QSize(600, 400))

            if not title:
                title = self.settings.value('figureTitle')
            plotWidget.setTitle(title)
            legend = QwtLegend()
            plotWidget.insertLegend(legend)
            plotWidget.setAxisTitle(QwtPlot.xBottom,
                                    self.settings.value('xAxisTitle'))
            plotWidget.setAxisTitle(QwtPlot.yLeft,
                                    self.settings.value('yAxisTitle'))

            QSettings().setValue("lastOutputDir", os.path.dirname(fileName))
            filter = QwtPlotPrintFilter()
            filter.setOptions(QwtPlotPrintFilter.PrintAll
                              & ~QwtPlotPrintFilter.PrintBackground)
            plotWidget.print_(pix, filter)
            plotWidget.insertLegend(None)
            plotWidget.setAxisTitle(QwtPlot.xBottom, None)
            plotWidget.setAxisTitle(QwtPlot.yLeft, None)
            plotWidget.setTitle(None)