/[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 792 by gross, Fri Jul 28 10:37:16 2006 UTC revision 802 by gross, Wed Aug 9 09:21:00 2006 UTC
# Line 24  from colors import White Line 24  from colors import White
24    
25    
26    
27  def Scene(PyvisiObject):  def Scene(Component):
28     """     """
29     a scene for visualization     a scene for visualization
30     """     """
31     def __init__(self,x_size,y_size,camera,background):     def __init__(self,x_size,y_size)
32        self.setSize(x_size,y_size)        super(Scene, self).__init__()
33        self.setBackgroundColor(backgound)        self.x_size=x_size
34        self.setCamera(backgound)        self.y_size=y_size
35          self.setBackgroundColor()
36          self.setCamera()
37    
38     def render(self,filename=None,wait=False):     def render(self,filename=None,wait=False):
39        """        """
40        renders the scene. If filename is present the file is rendered in the file filename        renders the scene. If filename is present the file is rendered in the file filename
41        """        """
42        pass        pass
    def setSize(self,x_size,y_size):  
       """  
       sets the size of the output window  
       """  
       pass  
43    
44     def setBackgroundColor(self,color):     def _addComponent(self,comp):
45           pass
46    
47       def setBackgroundColor(self,color=White()):
48        """        """
49        Sets the background color of the Scene        Sets the background color of the Scene
50    
# Line 53  def Scene(PyvisiObject): Line 53  def Scene(PyvisiObject):
53        """        """
54        pass        pass
55    
56     def setCamera(self,camera):  def openScene(renderer="pyvisi",x_size=640,y_size=480):
       """  
       sets the camera  
 `     """  
       pass  
   
 def openScene(renderer="pyvisi",x_size=640,y_size=480,camera=IsometricCamera(),background=White()):  
57       """       """
58       opens a scene       opens a scene
59    
# Line 72  def openScene(renderer="pyvisi",x_size=6 Line 66  def openScene(renderer="pyvisi",x_size=6
66       """       """
67       if renderer == "vtk_online":       if renderer == "vtk_online":
68           import renderers.vtk.VTKScene as VTKScene           import renderers.vtk.VTKScene as VTKScene
69           return VTKScene(x_size,y_size,camera,background,"online", offscreen=False)           return VTKScene(x_size,y_size,"online", offscreen=False)
70       elif renderer == "vtk_ps":       elif renderer == "vtk_ps":
71           import renderers.vtk.VTKScene as VTKScene           import renderers.vtk.VTKScene as VTKScene
72           return VTKScene(x_size,y_size,camera,background,"ps", offscreen=True)           return VTKScene(x_size,y_size,"ps", offscreen=True)
73       elif renderer == "vtk_png":       elif renderer == "vtk_png":
74           import renderers.vtk.VTKScene as VTKScene           import renderers.vtk.VTKScene as VTKScene
75           return VTKScene(x_size,y_size,camera,background,"png", offscreen=True)           return VTKScene(x_size,y_size,"png", offscreen=True)
76       elif renderer == "vtk_jpeg":       elif renderer == "vtk_jpeg":
77           import renderers.vtk.VTKScene as VTKScene           import renderers.vtk.VTKScene as VTKScene
78           return VTKScene(x_size,y_size,camera,background,"jpeg", offscreen=True)           return VTKScene(x_size,y_size,"jpeg", offscreen=True)
79       elif renderer == "vtk_tiff":       elif renderer == "vtk_tiff":
80           import renderers.vtk.VTKScene as VTKScene           import renderers.vtk.VTKScene as VTKScene
81           return VTKScene(x_size,y_size,camera,background,"tiff", offscreen=True)           return VTKScene(x_size,y_size,"tiff", offscreen=True)
82       elif renderer == "vtk_bmp":       elif renderer == "vtk_bmp":
83           import renderers.vtk.VTKScene as VTKScene           import renderers.vtk.VTKScene as VTKScene
84           return VTKScene(x_size,y_size,camera,background,"bmp", offscreen=True)           return VTKScene(x_size,y_size,"bmp", offscreen=True)
85       elif renderer == "vtk_pnm":       elif renderer == "vtk_pnm":
86           import renderers.vtk.VTKScene as VTKScene           import renderers.vtk.VTKScene as VTKScene
87           return VTKScene(x_size,y_size,camera,background,"pnm", offscreen=True)           return VTKScene(x_size,y_size,"pnm", offscreen=True)
88       elif renderer == "pyvisi" or renderer==None:       elif renderer == "pyvisi" or renderer==None:
89           import Scene           import Scene
90           return Scene(x_size,y_size,camera,background)           return Scene(x_size,y_size)
91       else:       else:
92           raise ValueError, "Unknown renderer %s."%renderer           raise ValueError, "Unknown renderer %s."%renderer
93    ##########################################################################################
94    ## vtk specific stuff (should be in renderers.vtk)
95    ##########################################################################################
96    def renderArrow(comp):
97          pass #
98    class VTKScene(Scene):
99        def __init__(x_size,y_size,format,offscreen):
100             super(VTKScene, self).__init__()
101             self.__comps=[]
102             pass
103        def _addComponent(self,comp):
104            if isinstance(Arrow,comp):
105               # ... some vtk set up here"
106               comp._render=renderArrow
107            self.__comps.append(comp)
108    
109       def render(self,filename=None,wait=False):
110          """
111          renders the scene. If filename is present the file is rendered in the file filename
112          """
113          for i in self.__comps: i.render()
114          pass # more rendering work
115          for i in self.__comps: i.markFeaturesAsUsed()
116      

Legend:
Removed from v.792  
changed lines
  Added in v.802

  ViewVC Help
Powered by ViewVC 1.1.26