<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    Hi all,<br>
    <br>
    I'm trying to export an image from my application that is written in
    PyQt4 to SVG.<br>
    Since I want to get a vector graphic im using vtkGL2PSExporter for
    this purpose.<br>
    Outside of PyQt4 I can export an SVG without any issues (I tried it
    by exporting an<br>
    image from an example). When I'm trying to export the
    vtkRenderWindow that I<br>
    get from QVTKRenderWindowInteractor.GetRenderWindow() the output is
    corrupted<br>
    though. Some of the Elements get rendered correctly (i.e. a
    vtkScale) others just<br>
    look randomly distorted. The same happens when I run a minimal
    example (attached<br>
    to this mail).<br>
    <br>
    Did anyone experience this as well? Do I call something wrong?<br>
    <br>
    I appreciate any help.<br>
    <br>
    Thanks,<br>
    Stefan<br>
    <br>
    <br>
    Minimal Example:<br>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    #!/usr/bin/env python<br>
    <br>
    import sys<br>
    import os<br>
    import vtk<br>
    from PyQt4 import QtCore, QtGui<br>
    from vtk.qt4.QVTKRenderWindowInteractor import
    QVTKRenderWindowInteractor<br>
    <br>
    class MainWindow(QtGui.QMainWindow):<br>
    <br>
        def __init__(self, parent = None):<br>
            QtGui.QMainWindow.__init__(self, parent)<br>
    <br>
            self.frame = QtGui.QFrame()<br>
    <br>
            self.vl = QtGui.QVBoxLayout()<br>
            self.vtkWidget = QVTKRenderWindowInteractor(self.frame)<br>
            self.vl.addWidget(self.vtkWidget)<br>
    <br>
            self.ren = vtk.vtkRenderer()<br>
            self.vtkWidget.GetRenderWindow().AddRenderer(self.ren)<br>
            self.iren = self.vtkWidget.GetRenderWindow().GetInteractor()<br>
    <br>
            # Create source<br>
            source = vtk.vtkSphereSource()<br>
            source.SetCenter(0, 0, 0)<br>
            source.SetRadius(5.0)<br>
    <br>
            # Create a mapper<br>
            mapper = vtk.vtkPolyDataMapper()<br>
            mapper.SetInputConnection(source.GetOutputPort())<br>
    <br>
            # Create an actor<br>
            actor = vtk.vtkActor()<br>
            actor.SetMapper(mapper)<br>
    <br>
            button = QtGui.QPushButton(self.frame)<br>
            button.setGeometry(20, 20, 32, 32)<br>
            button.setIcon(QtGui.QIcon.fromTheme('document-save'))<br>
            button.setToolTip('Save Visualization')<br>
    <br>
            button.clicked.connect(self.store_visualization)<br>
    <br>
            self.ren.AddActor(actor)<br>
    <br>
            self.ren.ResetCamera()<br>
    <br>
            self.frame.setLayout(self.vl)<br>
            self.setCentralWidget(self.frame)<br>
    <br>
            self.show()<br>
            self.iren.Initialize()<br>
    <br>
        def store_visualization(self):<br>
            file_name = str(QtGui.QFileDialog.getSaveFileName(<br>
                self,<br>
                'Save Visualization',<br>
                os.path.join(os.getcwd(), '/visualization.svg'),<br>
                'SVG-Images (*.svg)'<br>
            ))<br>
    <br>
            if len(file_name) > 0:<br>
                exporter = vtk.vtkGL2PSExporter()<br>
               
    exporter.SetRenderWindow(self.vtkWidget.GetRenderWindow())<br>
                exporter.SetFileFormatToSVG()<br>
                exporter.CompressOff()<br>
                exporter.DrawBackgroundOff()<br>
                exporter.SetFilePrefix(os.path.splitext(file_name)[0])<br>
                exporter.Write()<br>
    <br>
    <br>
    if __name__ == "__main__":<br>
        app = QtGui.QApplication(sys.argv)<br>
        window = MainWindow()<br>
        sys.exit(app.exec_())<br>
    <br>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
  </body>
</html>