<div dir="ltr">Running the test script works for me -- see attachment, the VTK window is on the right, and the svg rendered in chrome on the left.<div><br></div><div>Some other issues that might be coming into play:</div><div><br></div><div>1) What Qt version are you using, and</div><div>2) Which OpenGL backend is being used on VTK? (Did you explicitly select the experimental OpenGL2 backend while building VTK?)</div><div><br></div><div>Dave</div><div><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jun 29, 2015 at 8:54 AM, Stefan Lau <span dir="ltr"><<a href="mailto:github@stefanlau.com" target="_blank">github@stefanlau.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I'm trying to export an image from my application created in PyQt4 to a<br>
vector image. While the vtkGL2PSExporter works fine from outside my QT<br>
application, when trying to export the image from inside it the output looks corrupted. A minimal example can be found at the end of this email. Did I miss something (or call something incorrectly)? Is this a known issue?<br>
<br>
Version: VTK 6.1.0<br>
<br>
Thanks for any help,<br>
Stefan Lau<div><div><br>
<br>
<br>
Minimal Example:<br>
#!/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></div></div>
def store_visualization(self, render_window):<span><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></span>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" rel="noreferrer" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" rel="noreferrer" target="_blank">http://markmail.org/search/?q=vtkusers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/vtkusers" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/vtkusers</a><br>
</blockquote></div><br></div></div>