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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 600 - (show annotations)
Fri Mar 17 05:53:59 2006 UTC (13 years, 7 months ago) by gross
File MIME type: text/x-python
File size: 6214 byte(s)
some renaming
1 # Copyright (C) 2004-2005 Paul Cochrane
2 #
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16
17 # $Id: renderer.py,v 1.21 2005/11/03 05:55:59 paultcochrane Exp $
18
19 ## @file render.py
20
21 """
22 This is the file for the base Renderer class
23 """
24
25 from pyvisi.common import debugMsg
26
27 __revision__ = '$Revision: 1.21 $'
28
29 class Renderer(object):
30 """
31 A generic object holding a renderer of a Scene().
32 """
33
34 def __init__(self):
35 """
36 Initialisation of Renderer() class
37 """
38 object.__init__(self)
39 debugMsg("Called Renderer.__init__()")
40
41 # initialise some attributes
42 self.renderWindowWidth = 640
43 self.renderWindowHeight = 480
44
45 # the namespace to run the exec code
46 self.renderDict = {}
47
48 # initialise the evalstack
49 self._evalStack = ""
50
51 # keep the initial setup of the module for later reuse
52 self._initStack = ""
53
54 # initialise the renderer module
55
56 def setRenderWindowWidth(self, width):
57 """
58 Sets the render window width
59
60 @param width: The width of the render window
61 @type width: int
62 """
63 debugMsg("Called Renderer.setRenderWindowWidth()")
64 # check that the argument makes sense
65 if __debug__:
66 assert isinstance(width, int), "Incorrect data type; expected int"
67
68 self.renderWindowWidth = width
69 return
70
71 def setRenderWindowHeight(self, height):
72 """
73 Sets the render window height
74
75 @param height: The height of the render window
76 @type height: int
77 """
78 debugMsg("Called Renderer.setRenderWindowHeight()")
79 # check that the argument makes sense
80 if __debug__:
81 assert isinstance(height, int), "Incorrect data type; expected int"
82
83 self.renderWindowHeight = height
84 return
85
86 def getRenderWindowWidth(self):
87 """
88 Gets the render window width
89 """
90 debugMsg("Called Renderer.getRenderWindowWidth()")
91 return self.renderWindowWidth
92
93 def getRenderWindowHeight(self):
94 """
95 Gets the render window height
96 """
97 debugMsg("Called Renderer.getRenderWindowHeight()")
98 return self.renderWindowHeight
99
100 def setRenderWindowDimensions(self, width, height):
101 """
102 Sets the render window dimensions
103
104 @param width: the width of the render window
105 @type width: int
106
107 @param height: the height of the render window
108 @type height: int
109 """
110 debugMsg("Called Renderer.setRenderWindowDimensions()")
111 # check that the argument makes sense
112 if __debug__:
113 assert isinstance(width, int), "Incorrect data type; expected int"
114 assert isinstance(height, int), "Incorrect data type; expected int"
115
116 self.renderWindowWidth = width
117 self.renderWindowHeight = height
118
119 return
120
121 def getRenderWindowDimensions(self):
122 """
123 Gets the render window dimensions
124
125 @return: tuple of window width and window height, respectively
126 """
127 debugMsg("Called Renderer.getRenderWindowDimensions()")
128 return (self.renderWindowWidth, self.renderWindowHeight)
129
130 def getEvalStack(self):
131 """
132 Gets the evaluation stack as it currently stands
133 """
134 debugMsg("Called Renderer.getEvalStack()")
135 return self._evalStack
136
137 def addToEvalStack(self, evalString):
138 """
139 Method to add commands to the evaluation stack
140
141 @param evalString: The string of commands to be added to the evalStack
142 @type evalString: string
143 """
144 debugMsg("Called Renderer.addToEvalStack()")
145 # check that the argument is ok
146 if __debug__:
147 assert isinstance(evalString, str), \
148 "Incorrect data type; expected string"
149
150 self._evalStack += evalString + '\n'
151 return
152
153 def runString(self, evalString):
154 """
155 Method to run the given string in the renderer python interpreter
156
157 @param evalString: The string of commands to be run
158 @type evalString: string
159 """
160 debugMsg("Called Renderer.runString()")
161 # check that the argument is ok
162 if __debug__:
163 assert isinstance(evalString, str), \
164 "Incorrect data type; expected string"
165
166 self._evalStack += evalString + '\n'
167 return
168
169 def getInitStack(self):
170 """
171 Gets the initialisation stack as it currently stands
172 """
173 debugMsg("called Renderer.getInitStack()")
174 return self._initStack
175
176 def addToInitStack(self, evalString):
177 """
178 Method to add commands to the reusable part of the evaluation stack
179
180 @param evalString: The string of commands to be added to the evalStack
181 @type evalString: string
182 """
183 debugMsg("Called Renderer.addToInitStack()")
184 # check that the argument is ok
185 if __debug__:
186 assert isinstance(evalString, str)
187
188 self._initStack += evalString + '\n'
189 return
190
191 def resetEvalStack(self):
192 """
193 Reset/flush the evaluation stack
194 """
195 debugMsg("Called Renderer.resetEvalStack()")
196 self._evalStack = ""
197 return
198
199 def resetInitStack(self):
200 """
201 Reset/flush the initialisation stack
202 """
203 debugMsg("Called Renderer.resetInitStack()")
204 self._initStack = ""
205 return
206
207 # vim: expandtab shiftwidth=4:

  ViewVC Help
Powered by ViewVC 1.1.26