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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 802 - (hide annotations)
Wed Aug 9 09:21:00 2006 UTC (14 years ago) by gross
File MIME type: text/x-python
File size: 3834 byte(s)
some stuff for john
1 gross 792 """
2     defines a scene in which items are shown
3    
4     @var __author__: name of author
5     @var __license__: licence agreement
6     @var __copyright__: copyrights
7     @var __url__: url entry point on documentation
8     @var __version__: version
9     @var __date__: date of the version
10     """
11    
12     __copyright__=""" Copyright (c) 2006 by ACcESS MNRF
13     http://www.access.edu.au
14     Primary Business: Queensland, Australia"""
15     __license__="""Licensed under the Open Software License version 3.0
16     http://www.opensource.org/licenses/osl-3.0.php"""
17     __author__="Paul Cochrane, L. Gross"
18     __url__="http://www.iservo.edu.au/esys"
19     __version__="$Revision:$"
20     __date__="$Date:$"
21    
22     from camera import IsometricCamera
23     from colors import White
24    
25    
26    
27 gross 802 def Scene(Component):
28 gross 792 """
29     a scene for visualization
30     """
31 gross 802 def __init__(self,x_size,y_size)
32     super(Scene, self).__init__()
33     self.x_size=x_size
34     self.y_size=y_size
35     self.setBackgroundColor()
36     self.setCamera()
37 gross 792
38     def render(self,filename=None,wait=False):
39     """
40     renders the scene. If filename is present the file is rendered in the file filename
41     """
42     pass
43    
44 gross 802 def _addComponent(self,comp):
45     pass
46    
47     def setBackgroundColor(self,color=White()):
48 gross 792 """
49     Sets the background color of the Scene
50    
51     @param color: The color to set the background to. Can be RGB or CMYK
52     @type color: L{Color}
53     """
54     pass
55    
56 gross 802 def openScene(renderer="pyvisi",x_size=640,y_size=480):
57 gross 792 """
58     opens a scene
59    
60     @param renderer: renderer to be used
61     @param x_size: window width (in pixel)
62     @param y_size: window height (in pixel)
63     @param camera: camera
64     @param background: background color
65     @returns: L{Scene}
66     """
67     if renderer == "vtk_online":
68     import renderers.vtk.VTKScene as VTKScene
69 gross 802 return VTKScene(x_size,y_size,"online", offscreen=False)
70 gross 792 elif renderer == "vtk_ps":
71     import renderers.vtk.VTKScene as VTKScene
72 gross 802 return VTKScene(x_size,y_size,"ps", offscreen=True)
73 gross 792 elif renderer == "vtk_png":
74     import renderers.vtk.VTKScene as VTKScene
75 gross 802 return VTKScene(x_size,y_size,"png", offscreen=True)
76 gross 792 elif renderer == "vtk_jpeg":
77     import renderers.vtk.VTKScene as VTKScene
78 gross 802 return VTKScene(x_size,y_size,"jpeg", offscreen=True)
79 gross 792 elif renderer == "vtk_tiff":
80     import renderers.vtk.VTKScene as VTKScene
81 gross 802 return VTKScene(x_size,y_size,"tiff", offscreen=True)
82 gross 792 elif renderer == "vtk_bmp":
83     import renderers.vtk.VTKScene as VTKScene
84 gross 802 return VTKScene(x_size,y_size,"bmp", offscreen=True)
85 gross 792 elif renderer == "vtk_pnm":
86     import renderers.vtk.VTKScene as VTKScene
87 gross 802 return VTKScene(x_size,y_size,"pnm", offscreen=True)
88 gross 792 elif renderer == "pyvisi" or renderer==None:
89     import Scene
90 gross 802 return Scene(x_size,y_size)
91 gross 792 else:
92     raise ValueError, "Unknown renderer %s."%renderer
93 gross 802 ##########################################################################################
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    

  ViewVC Help
Powered by ViewVC 1.1.26