/[escript]/trunk/pyvisi/py_src/scene.py
ViewVC logotype

Contents of /trunk/pyvisi/py_src/scene.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 849 - (show annotations)
Fri Sep 15 07:11:55 2006 UTC (14 years, 2 months ago) by jongui
File MIME type: text/x-python
File size: 1514 byte(s)
Optimized codes and modularized functions to make it more scalable. Partially 
integrated carpet into the existing modules.  

1 """
2 @author: John Ngui
3 @author: Lutz Gross
4 """
5
6 import vtk
7 from constants import *
8
9 class Scene:
10 """
11 Class that defines a scene in which components are displayed.
12 """
13
14 def __init__(self, renderer = "vtk_online", x_size = 800, y_size = 600):
15 """
16 Initialize all the instance variables.
17
18
19 @type renderer: String
20 @param renderer: Type of rendering (I{vtk-online or vtk-offline})
21 @type x_size: Number
22 @param x_size: Size of the rendering window on the x-axis
23 @type y_size: Number
24 @param y_size: Size of the rendering window on the y-axis
25 """
26
27 self.x_size = x_size
28 self.y_size = y_size
29 self.vtk_renderer = vtk.vtkRenderer()
30 self.vtk_render_window = vtk.vtkRenderWindow()
31
32 if(renderer == "vtk_online"):
33 self.setRenderWindow()
34
35 def setRenderWindow(self):
36 """
37 Set up the renderer and rendering window.
38 """
39
40 self.vtk_render_window.AddRenderer(self.vtk_renderer)
41 self.vtk_render_window.SetSize(self.x_size, self.y_size)
42 self.vtk_renderer.SetBackground(
43 WHITE[0], WHITE[1], WHITE[2])
44
45 def render(self):
46 """
47 Set up the render window interactor and render the image.
48 """
49
50 vtk_render_window_interactor = vtk.vtkRenderWindowInteractor()
51 vtk_render_window_interactor.SetRenderWindow(self.vtk_render_window)
52 vtk_render_window_interactor.Initialize()
53 self.vtk_render_window.Render()
54 vtk_render_window_interactor.Start()
55
56 def getRenderer(self):
57 """
58 Return the renderer.
59
60 @rtype: vtkRenderer
61 @return: VTK renderer
62 """
63
64 return self.vtk_renderer

  ViewVC Help
Powered by ViewVC 1.1.26