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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 860 by jongui, Thu Sep 28 08:17:29 2006 UTC revision 861 by jongui, Fri Sep 29 06:54:46 2006 UTC
# Line 26  class Scene: Line 26  class Scene:
26          self.y_size = y_size          self.y_size = y_size
27          self.vtk_renderer = vtk.vtkRenderer()          self.vtk_renderer = vtk.vtkRenderer()
28          self.vtk_render_window = vtk.vtkRenderWindow()          self.vtk_render_window = vtk.vtkRenderWindow()
29            self.vtk_render_window_interactor = vtk.vtkRenderWindowInteractor()
30    
31          self.setRenderWindow()          self.setRenderWindow()
         #self.setRenderWindowInteractor()  
32                    
33      def saveImage(self, image_name):      def saveImage(self, image_name):
34          """          """
# Line 37  class Scene: Line 37  class Scene:
37          @param image_name: Name of the image file          @param image_name: Name of the image file
38          """          """
39    
40          self.vtk_render_window.Render()          #self.vtk_render_window.Render()
41          #self.vtk_render_window.OffScreenRenderingOn()          #self.vtk_render_window.OffScreenRenderingOn()
42          #self.vtk_render_window.OffScreenRenderingOff()          #self.vtk_render_window.OffScreenRenderingOff()
43    
44          # Converts the output of the render window into vtkImageData.          # Converts the output of the render window into vtkImageData.
45          vtk_window_to_image = vtk.vtkWindowToImageFilter()          vtk_window_to_image = vtk.vtkWindowToImageFilter()
46          vtk_window_to_image.Modified() # Update precaution          #vtk_window_to_image.Update() # Update precaution
         vtk_window_to_image.Update() # Update precaution  
47          vtk_window_to_image.SetInput(self.vtk_render_window)          vtk_window_to_image.SetInput(self.vtk_render_window)
48            vtk_window_to_image.Modified() # Update precaution
49          # Force an update to the of the output image as vtk window's          # Force an update to the of the output image as vtk window's
50          # modification time does not get updated automatically.          # modification time does not get updated automatically.
51          vtk_window_to_image.Modified() # Update precaution          #vtk_window_to_image.Modified() # Update precaution
52          vtk_window_to_image.Update() # Update precaution          #vtk_window_to_image.Update() # Update precaution
53                    
54          # Write the image to file.          # Write the image to file.
55          vtk_image_writer = self.getImageWriter(self.renderer)          vtk_image_writer = self.getImageWriter(self.renderer)
# Line 72  class Scene: Line 72  class Scene:
72          self.vtk_renderer.SetBackground(          self.vtk_renderer.SetBackground(
73              WHITE[0], WHITE[1], WHITE[2])              WHITE[0], WHITE[1], WHITE[2])
74    
     def setRenderWindowInteractor(self):  
         """  
         Set up the render window interactor.  
         """  
   
         vtk_render_window_interactor = vtk.vtkRenderWindowInteractor()  
         vtk_render_window_interactor.SetRenderWindow(self.vtk_render_window)  
         vtk_render_window_interactor.Initialize()  
         self.vtk_render_window.Render()  
         vtk_render_window_interactor.Start()  
           
   
75      def render(self):      def render(self):
76          """          """
77          Render the image.          Render the image.
78          """          """
79            
80          vtk_render_window_interactor = vtk.vtkRenderWindowInteractor()          # True if not initialized yet.
81          vtk_render_window_interactor.SetRenderWindow(self.vtk_render_window)          if(self.vtk_render_window_interactor.GetInitialized() == 0):
82          vtk_render_window_interactor.Initialize()              self.vtk_render_window_interactor.SetRenderWindow(
83          self.vtk_render_window.Render()                  self.vtk_render_window)
84          vtk_render_window_interactor.Start()              self.vtk_render_window_interactor.Initialize()
85                #self.vtk_render_window.Render()
86                self.vtk_render_window_interactor.GetInitialized()
87                self.vtk_render_window_interactor.Start()
88            else: # True if already initialized.
89                #self.vtk_render_window.Modified()
90                self.vtk_render_window.Render()
91                #self.vtk_render_window.Modified()
92    
93    
94      def getImageWriter(self, renderer):      def getImageWriter(self, renderer):

Legend:
Removed from v.860  
changed lines
  Added in v.861

  ViewVC Help
Powered by ViewVC 1.1.26