Esempio n. 1
0
 def export_picture(self, filename):
     w2if = tvtk.WindowToImageFilter()
     w2if.magnification = 2
     w2if.input = self.render_window
     ex = tvtk.PNGWriter()
     ex.file_name = filename
     ex.input = w2if.output
     ex.write()
Esempio n. 2
0
 def save_png(self, file_name):
     """Save to a PNG image file."""
     if len(file_name) != 0:
         w2if = tvtk.WindowToImageFilter(read_front_buffer=False)
         w2if.magnification = self.magnification
         self._lift()
         w2if.input = self._renwin
         ex = tvtk.PNGWriter()
         ex.file_name = file_name
         ex.input = w2if.output
         self._exporter_write(ex)
Esempio n. 3
0
 def save_ps(self, file_name):
     """Saves the rendered scene to a rasterized PostScript image.
     For vector graphics use the save_gl2ps method."""
     if len(file_name) != 0:
         w2if = tvtk.WindowToImageFilter(read_front_buffer=False)
         w2if.magnification = self.magnification
         self._lift()
         w2if.input = self._renwin
         ex = tvtk.PostScriptWriter()
         ex.file_name = file_name
         ex.input = w2if.output
         self._exporter_write(ex)
Esempio n. 4
0
 def save_jpg(self, file_name, quality=None, progressive=None):
     """Arguments: file_name if passed will be used, quality is the
     quality of the JPEG(10-100) are valid, the progressive
     arguments toggles progressive jpegs."""
     if len(file_name) != 0:
         if not quality and not progressive:
             quality, progressive = self.jpeg_quality, self.jpeg_progressive
         w2if = tvtk.WindowToImageFilter(read_front_buffer=False)
         w2if.magnification = self.magnification
         self._lift()
         w2if.input = self._renwin
         ex = tvtk.JPEGWriter()
         ex.quality = quality
         ex.progressive = progressive
         ex.file_name = file_name
         ex.input = w2if.output
         self._exporter_write(ex)
Esempio n. 5
0
m = tvtk.PolyDataMapper()

# Note that VTK's GetOutput method is special because it has two call
# signatures: GetOutput() and GetOutput(int N) (which gets the N'th
# output).  In tvtk it is represented as both a property and as a
# method.  Using the output property will work fine if all you want is
# the default output.  OTOH if you want the N'th output use
# get_output(N).
m.input = cs.output  # or m.input = cs.get_output()

# Create the actor and set its mapper.
a = tvtk.Actor(mapper=m)

# Create a Renderer, add the actor and set its background color.
ren = tvtk.Renderer(background=(0.1, 0.2, 0.4))
ren.add_actor(a)
ren.reset_camera()

# Create a RenderWindow, add the renderer and set its size.
rw = tvtk.RenderWindow(size=(300, 300))
rw.off_screen_rendering = 1
rw.add_renderer(ren)

w2if = tvtk.WindowToImageFilter()
w2if.magnification = 2
w2if.input = rw
ex = tvtk.PNGWriter()
ex.file_name = "example.png"
ex.input = w2if.output
ex.write()