[vtkusers] vtkGL2PSExporter in combination with QVTKRenderWindowInteractor
Stefan Lau
github at stefanlau.com
Fri Jul 10 11:46:51 EDT 2015
Allright after a short holiday, I had another few hours to debug the
issue. But no success.
Some other stuff that I tried (but now I'm out of ideas):
* Installing everything inside a VirtualBox running Ubuntu 14.04 (using
the Ubuntu-provided
vtk packages, which are broken btw:
https://bugs.launchpad.net/ubuntu/+source/vtk6/+bug/1354127)
* Using VTK 6.2 (building my own version of VTK)
* Using OpenGL software rendering (I thought that maybe it's a driver
issue of the intel drivers)
All yield the same corrupted result: The image that I sent in the last
email.
I haven't tried running it on a completely different machine, since I
have none available ATM.
Any ideas on how I could proceed?
- Stefan
Am 29.06.2015 um 16:23 schrieb David Lonie:
> and the attachment...
>
> On Mon, Jun 29, 2015 at 10:22 AM, David Lonie <david.lonie at kitware.com
> <mailto:david.lonie at kitware.com>> wrote:
>
> 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.
>
> Some other issues that might be coming into play:
>
> 1) What Qt version are you using, and
> 2) Which OpenGL backend is being used on VTK? (Did you explicitly
> select the experimental OpenGL2 backend while building VTK?)
>
> Dave
>
>
> On Mon, Jun 29, 2015 at 8:54 AM, Stefan Lau <github at stefanlau.com
> <mailto:github at stefanlau.com>> wrote:
>
> Hi,
>
> I'm trying to export an image from my application created in
> PyQt4 to a
> vector image. While the vtkGL2PSExporter works fine from
> outside my QT
> 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?
>
> Version: VTK 6.1.0
>
> Thanks for any help,
> Stefan Lau
>
>
>
> Minimal Example:
> #!/usr/bin/env python
>
> import sys
> import os
> import vtk
> from PyQt4 import QtCore, QtGui
> from vtk.qt4.QVTKRenderWindowInteractor import
> QVTKRenderWindowInteractor
>
> class MainWindow(QtGui.QMainWindow):
>
> def __init__(self, parent = None):
> QtGui.QMainWindow.__init__(self, parent)
>
> self.frame = QtGui.QFrame()
>
> self.vl = QtGui.QVBoxLayout()
> self.vtkWidget = QVTKRenderWindowInteractor(self.frame)
> self.vl.addWidget(self.vtkWidget)
>
> self.ren = vtk.vtkRenderer()
> self.vtkWidget.GetRenderWindow().AddRenderer(self.ren)
> self.iren =
> self.vtkWidget.GetRenderWindow().GetInteractor()
>
> # Create source
> source = vtk.vtkSphereSource()
> source.SetCenter(0, 0, 0)
> source.SetRadius(5.0)
>
> # Create a mapper
> mapper = vtk.vtkPolyDataMapper()
> mapper.SetInputConnection(source.GetOutputPort())
>
> # Create an actor
> actor = vtk.vtkActor()
> actor.SetMapper(mapper)
>
> button = QtGui.QPushButton(self.frame)
> button.setGeometry(20, 20, 32, 32)
> button.setIcon(QtGui.QIcon.fromTheme('document-save'))
> button.setToolTip('Save Visualization')
>
> button.clicked.connect(self.store_visualization)
>
> self.ren.AddActor(actor)
>
> self.ren.ResetCamera()
>
> self.frame.setLayout(self.vl)
> self.setCentralWidget(self.frame)
>
> self.show()
> self.iren.Initialize()
>
> def store_visualization(self, render_window):
> file_name = str(QtGui.QFileDialog.getSaveFileName(
> self,
> 'Save Visualization',
> os.path.join(os.getcwd(), '/visualization.svg'),
> 'SVG-Images (*.svg)'
> ))
>
> if len(file_name) > 0:
> exporter = vtk.vtkGL2PSExporter()
> exporter.SetRenderWindow(self.vtkWidget.GetRenderWindow())
> exporter.SetFileFormatToSVG()
> exporter.CompressOff()
> exporter.DrawBackgroundOff()
> exporter.SetFilePrefix(os.path.splitext(file_name)[0])
> exporter.Write()
>
>
> if __name__ == "__main__":
> app = QtGui.QApplication(sys.argv)
> window = MainWindow()
> sys.exit(app.exec_())
> _______________________________________________
> Powered by www.kitware.com <http://www.kitware.com>
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at:
> http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20150710/a89f2e47/attachment.html>
More information about the vtkusers
mailing list