|
% |
|
|
% Copyright © 2006 by ACcESS MNRF |
|
|
% \url{http://www.access.edu.au |
|
|
% Primary Business: Queensland, Australia. |
|
|
% Licensed under the Open Software License version 3.0 |
|
|
% http://www.opensource.org/license/osl-3.0.php |
|
|
% |
|
1 |
\chapter{The module \pyvisi} |
\chapter{The module \pyvisi} |
2 |
|
\label{PYVISI CHAP} |
3 |
|
|
4 |
\declaremodule{extension}{pyvisi} |
\declaremodule{extension}{pyvisi} |
5 |
\modulesynopsis{visualization interface} |
\modulesynopsis{Python visualization interface} |
6 |
|
|
7 |
|
\pyvisi provides an easy to use interface to the \VTK visualization |
8 |
|
tool. \pyvisi provides the following modules: |
9 |
|
|
10 |
|
\begin{itemize} |
11 |
|
\item \Scene: Shows a scene in which components are to be displayed. |
12 |
|
\item \Image: Shows an image. |
13 |
|
\item \Text: Shows some 2D text. |
14 |
|
\item \DataCollector: Deals with data for visualization. |
15 |
|
\item \Camera: Controls the camera manipulation. |
16 |
|
\item \Light: Controls the light manipulation. |
17 |
|
\item \Map: Shows a scalar field by color on the domain surface. |
18 |
|
\item \MapOnPlane: Shows a scalar field by color on a given plane. |
19 |
|
\item \MapOnClip: Shows a scalar field by color on a given clip. |
20 |
|
\item \MapOnScalarClip: Shows a scalar field by color on a give scalar clip. |
21 |
|
\item \Arrows: Shows a vector field by arrows. |
22 |
|
\item \ArrowsOnPlane: Shows a vector field by arrows on a given plane. |
23 |
|
\item \ArrowsOnClip: Shows a vector field by arrows on a given clip. |
24 |
|
\item \IsoSurface: Shows a scalar field for a given value by |
25 |
|
an isosurface. |
26 |
|
\item \IsoSurfaceOnPlane: Shows a scalar field for a given value by |
27 |
|
an isosurfaceon a given plane. |
28 |
|
\item \IsoSurfaceOnClip: Shows a scalar field for a given vlaue by |
29 |
|
an isosurface on a given clip. |
30 |
|
\item \Contour: Shows a scalar field by contour surfaces. |
31 |
|
\item \ContourOnPlane: Shows a scalar field by contour surfaces on |
32 |
|
a given plane. |
33 |
|
\item \ContourOnClip: Shows a scalar field by contour surfaces on |
34 |
|
a given clip. |
35 |
|
\item \TensorC: Shows a tensor field by ellipsoids. |
36 |
|
\item \TensorOnPlane: Shows a tensor field by ellipsoids on |
37 |
|
a given plane. |
38 |
|
\item \TensorOnClip: Shows a tensor field by ellipsoids on a given clip. |
39 |
|
\item \StreamLines: Shows the path of particles in a vector field. |
40 |
|
\item \Carpet: Shows a scalar field as plane deformated along |
41 |
|
the plane normal. |
42 |
|
\item \Position: Defines the x,y and z coordinates rendered object. |
43 |
|
\item \Transform: Defines the orientation of rendered object. |
44 |
|
\item \Style: Defines the style of text. |
45 |
|
\item \BlueToRed: Defines a map spectrum from blue to red. |
46 |
|
\item \RedToBlue: Defines a map spectrum from red to blue. |
47 |
|
\item \Plane: Defines the cutting/clipping of rendered objects. |
48 |
|
\end{itemize} |
49 |
|
|
50 |
|
\section{\Scene class} |
51 |
|
\begin{classdesc}{Scene}{renderer, x_size = 500, y_size = 500} |
52 |
|
A \Scene object creates a window onto which objects are to be displayed. |
53 |
|
\end{classdesc} |
54 |
|
|
55 |
|
The following are the methods available: |
56 |
|
\begin{methoddesc}[Scene]{saveImage}{image_name} |
57 |
|
Save the rendered object as an image off-screen. |
58 |
|
\end{methoddesc} |
59 |
|
|
60 |
|
\begin{methoddesc}[Scene]{render}{} |
61 |
|
Render the object on-screen. |
62 |
|
\end{methoddesc} |
63 |
|
|
64 |
|
The following is a sample code using the \Scene class: |
65 |
|
\verbatiminput{../examples/driverscene.py} |
66 |
|
|
67 |
|
\section{\Image class} |
68 |
|
\begin{classdesc}{Image}{scene, format} |
69 |
|
An \Image object shows an image. |
70 |
|
\end{classdesc} |
71 |
|
|
72 |
|
The following is the method available: |
73 |
|
\begin{methoddesc}[Image]{setFileName}{file_name} |
74 |
|
Set the file name. |
75 |
|
\end{methoddesc} |
76 |
|
|
77 |
|
The following is a sample code using the \Image class. |
78 |
|
\fig{fig:image.1} shows the corresponding output. |
79 |
|
\verbatiminput{../examples/driverimage.py} |
80 |
|
|
81 |
|
\begin{figure}[ht] |
82 |
|
\begin{center} |
83 |
|
\includegraphics[width=40mm]{figures/Image} |
84 |
|
\end{center} |
85 |
|
\caption{Image} |
86 |
|
\label{fig:image.1} |
87 |
|
\end{figure} |
88 |
|
|
89 |
|
\section{\Text class} |
90 |
|
\begin{classdesc}{Text}{scene} |
91 |
|
A \Text object shows 2D text. |
92 |
|
\end{classdesc} |
93 |
|
|
94 |
|
The following are the methods available: |
95 |
|
\begin{methoddesc}[Text]{setText}{text} |
96 |
|
Set the text. |
97 |
|
\end{methoddesc} |
98 |
|
|
99 |
|
\begin{methoddesc}[Text]{setPosition}{x_coor, y_coor} |
100 |
|
Set the display position of the text. |
101 |
|
\end{methoddesc} |
102 |
|
|
103 |
|
\begin{methoddesc}[Text]{setStyle}{style} |
104 |
|
Set the style of the text. |
105 |
|
\end{methoddesc} |
106 |
|
|
107 |
|
The following is a sample code using the \Text class. |
108 |
|
\fig{fig:text.1} shows the corresponding output. |
109 |
|
\verbatiminput{../examples/drivertext.py} |
110 |
|
|
111 |
|
\begin{figure}[ht] |
112 |
|
\begin{center} |
113 |
|
\includegraphics[width=40mm]{figures/Text} |
114 |
|
\end{center} |
115 |
|
\caption{2D text} |
116 |
|
\label{fig:text.1} |
117 |
|
\end{figure} |
118 |
|
|
119 |
|
\section{\DataCollector class} |
120 |
|
\begin{classdesc}{DataCollector}{scene, outline = True, cube_axes = False} |
121 |
|
A \DataCollector object deals with the data for visualization. |
122 |
|
\end{classdesc} |
123 |
|
|
124 |
|
The following are the methods available: |
125 |
|
\begin{methoddesc}[DataCollector]{setFileName}{file_name} |
126 |
|
Set the file name from which data is to be read. |
127 |
|
\end{methoddesc} |
128 |
|
|
129 |
|
The following is a sample code using the \DataCollector class. |
130 |
|
\fig{fig:datacollector.1} shows the corresponding output. |
131 |
|
\verbatiminput{../examples/driverdatacollector.py} |
132 |
|
|
133 |
|
\begin{figure}[ht] |
134 |
|
\begin{center} |
135 |
|
\includegraphics[width=40mm]{figures/DataCollector} |
136 |
|
\end{center} |
137 |
|
\caption{Datacollector generating an outline with cube axes.} |
138 |
|
\label{fig:datacollector.1} |
139 |
|
\end{figure} |
140 |
|
|
141 |
|
\section{\Camera class} |
142 |
|
\begin{classdesc}{Camera}{scene, data_collector} |
143 |
|
A \Camera object controls the camera's settings. |
144 |
|
\end{classdesc} |
145 |
|
|
146 |
|
The following are some of the methods available: |
147 |
|
\begin{methoddesc}[Camera]{setFocalPoint}{position} |
148 |
|
Set the focal point of the camera. |
149 |
|
\end{methoddesc} |
150 |
|
|
151 |
|
\begin{methoddesc}[Camera]{setPosition}{position} |
152 |
|
Set the position of the camera. |
153 |
|
\end{methoddesc} |
154 |
|
|
155 |
|
\begin{methoddesc}[Camera]{azimuth}{angle} |
156 |
|
Rotate the camera to the left and right. |
157 |
|
\end{methoddesc} |
158 |
|
|
159 |
|
\begin{methoddesc}[Camera]{elevation}{angle} |
160 |
|
Rotate the camera to the top and bottom. |
161 |
|
\end{methoddesc} |
162 |
|
|
163 |
|
\begin{methoddesc}[Camera]{roll}{angle} |
164 |
|
Roll the camera to the left and right. |
165 |
|
\end{methoddesc} |
166 |
|
|
167 |
|
\begin{methoddesc}[Camera]{backView}{} |
168 |
|
View the back of the rendered object. |
169 |
|
\end{methoddesc} |
170 |
|
|
171 |
|
\begin{methoddesc}[Camera]{topView}{} |
172 |
|
View the top of the rendered object. |
173 |
|
\end{methoddesc} |
174 |
|
|
175 |
|
\begin{methoddesc}[Camera]{bottomView}{} |
176 |
|
View the bottom of the rendered object. |
177 |
|
\end{methoddesc} |
178 |
|
|
179 |
|
\begin{methoddesc}[Camera]{leftView}{} |
180 |
|
View the left side of the rendered object. |
181 |
|
\end{methoddesc} |
182 |
|
|
183 |
|
\begin{methoddesc}[Camera]{rightView}{} |
184 |
|
View the right side of the rendered object. |
185 |
|
\end{methoddesc} |
186 |
|
|
187 |
|
\begin{methoddesc}[Camera]{isometricView}{} |
188 |
|
View the isometric side of the rendered object. |
189 |
|
\end{methoddesc} |
190 |
|
|
191 |
|
The following is a sample code using the \Camera class. |
192 |
|
\fig{fig:camera.1} shows the corresponding output. |
193 |
|
\verbatiminput{../examples/drivercamera.py} |
194 |
|
|
195 |
|
\begin{figure}[ht] |
196 |
|
\begin{center} |
197 |
|
\includegraphics[width=30mm]{figures/Camera} |
198 |
|
\end{center} |
199 |
|
\caption{Camera manipulation} |
200 |
|
\label{fig:camera.1} |
201 |
|
\end{figure} |
202 |
|
|
203 |
|
\section{\Light class} |
204 |
|
\begin{classdesc}{Light}{scene, data_collector} |
205 |
|
A \Light object controls the light's settings. |
206 |
|
\end{classdesc} |
207 |
|
|
208 |
|
The following are the methods available: |
209 |
|
\begin{methoddesc}[Light]{setColor}{color} |
210 |
|
Set the color of the light. |
211 |
|
\end{methoddesc} |
212 |
|
|
213 |
|
\begin{methoddesc}[Light]{setFocalPoint}{position} |
214 |
|
Set the focal point of the light. |
215 |
|
\end{methoddesc} |
216 |
|
|
217 |
|
\begin{methoddesc}[Light]{setPosition}{position} |
218 |
|
Set the position of the light. |
219 |
|
\end{methoddesc} |
220 |
|
|
221 |
|
\begin{methoddesc}[Light]{setIntensity}{intesity} |
222 |
|
Set the intensity (brightness) of the light. |
223 |
|
\end{methoddesc} |
224 |
|
|
225 |
|
The following is a sample code using the \Light class. |
226 |
|
\fig{fig:light.1} shows the corresponding output. |
227 |
|
\verbatiminput{../examples/driverlight.py} |
228 |
|
|
229 |
|
\begin{figure}[ht] |
230 |
|
\begin{center} |
231 |
|
\includegraphics[width=40mm]{figures/Light} |
232 |
|
\end{center} |
233 |
|
\caption{Light} |
234 |
|
\label{fig:light.1} |
235 |
|
\end{figure} |
236 |
|
|
237 |
|
\section{\Map class} |
238 |
|
\begin{classdesc}{Map}{scene, data_collector, lut = None} |
239 |
|
A \Map object shows a scalar field by color on the domain surface. |
240 |
|
\end{classdesc} |
241 |
|
|
242 |
|
The following is a sample code using the \Map class. |
243 |
|
\fig{fig:map.1} shows the corresponding output. |
244 |
|
\verbatiminput{../examples/drivermap.py} |
245 |
|
|
246 |
|
\begin{figure}[ht] |
247 |
|
\begin{center} |
248 |
|
\includegraphics[width=40mm]{figures/Map} |
249 |
|
\end{center} |
250 |
|
\caption{Surface map} |
251 |
|
\label{fig:map.1} |
252 |
|
\end{figure} |
253 |
|
|
254 |
|
\section{\MapOnPlane class} |
255 |
|
\begin{classdesc}{MapOnPlane}{scene, data_collector, transform, lut = None} |
256 |
|
A \MapOnPlane object show a scalar field by color on a given plane. |
257 |
|
\end{classdesc} |
258 |
|
|
259 |
|
The following is a sample code using the \MapOnPlane class. |
260 |
|
\fig{fig:maponplane.1} shows the corresponding output. |
261 |
|
\verbatiminput{../examples/drivermaponplane.py} |
262 |
|
|
263 |
|
\begin{figure}[ht] |
264 |
|
\begin{center} |
265 |
|
\includegraphics[width=40mm]{figures/MapOnPlane} |
266 |
|
\end{center} |
267 |
|
\caption{Surface map on a plane} |
268 |
|
\label{fig:maponplane.1} |
269 |
|
\end{figure} |
270 |
|
|
271 |
|
\section{\MapOnClip class} |
272 |
|
\begin{classdesc}{MapOnClip}{scene, data_collector, transform, lut = None} |
273 |
|
A \MapOnClip object show a scalar field by color on a given clip. |
274 |
|
\end{classdesc} |
275 |
|
|
276 |
|
The following is a sample code using the \MapOnClip class. |
277 |
|
\fig{fig:maponclip.1} shows the corresponding output. |
278 |
|
\verbatiminput{../examples/drivermaponclip.py} |
279 |
|
|
280 |
|
\begin{figure}[ht] |
281 |
|
\begin{center} |
282 |
|
\includegraphics[width=40mm]{figures/MapOnClip} |
283 |
|
\end{center} |
284 |
|
\caption{Surface map on a clip} |
285 |
|
\label{fig:maponclip.1} |
286 |
|
\end{figure} |
287 |
|
|
288 |
|
\section{\MapOnScalarClip class} |
289 |
|
\begin{classdesc}{MapOnScalarClip}{scene, data_collector, lut = None} |
290 |
|
A \MapOnScalarClip object show a scalar field by color on a given scalar clip. |
291 |
|
\end{classdesc} |
292 |
|
|
293 |
|
The following is a sample code using the \MapOnScalarClip class. |
294 |
|
\fig{fig:maponscalarclip.1} shows the corresponding output. |
295 |
|
\verbatiminput{../examples/drivermaponscalarclip.py} |
296 |
|
|
297 |
|
\begin{figure}[ht] |
298 |
|
\begin{center} |
299 |
|
\includegraphics[width=40mm]{figures/MapOnScalarClip} |
300 |
|
\end{center} |
301 |
|
\caption{Surface map on a scalar clip} |
302 |
|
\label{fig:maponscalarclip.1} |
303 |
|
\end{figure} |
304 |
|
|
305 |
|
\section{\Arrows class} |
306 |
|
\begin{classdesc}{Arrows}{scene, data_collector, lut = None} |
307 |
|
A \Arrows object shows a vector field by arrows. |
308 |
|
\end{classdesc} |
309 |
|
|
310 |
|
The following are the methods available: |
311 |
|
\begin{methoddesc}[Arrows]{setVectorMode}{vector_mode} |
312 |
|
Set the arrows vector mode. |
313 |
|
\end{methoddesc} |
314 |
|
|
315 |
|
\begin{methoddesc}[Arrows]{setScaleMode}{scale_mode} |
316 |
|
Set the arrows scale mode. |
317 |
|
\end{methoddesc} |
318 |
|
|
319 |
|
\begin{methoddesc}[Arrows]{setScaleFactor}{scale_factor} |
320 |
|
Set the arrows scale factor. |
321 |
|
\end{methoddesc} |
322 |
|
|
323 |
|
\begin{methoddesc}[Arrows]{setColorMode}{color_mode} |
324 |
|
Set the arrows color mode. |
325 |
|
\end{methoddesc} |
326 |
|
|
327 |
|
The following is a sample code using the \Arrows class. |
328 |
|
\fig{fig:arrows.1} shows the corresponding output. |
329 |
|
\verbatiminput{../examples/driverarrows.py} |
330 |
|
|
331 |
|
\begin{figure}[ht] |
332 |
|
\begin{center} |
333 |
|
\includegraphics[width=40mm]{figures/Arrows} |
334 |
|
\end{center} |
335 |
|
\caption{Arrows} |
336 |
|
\label{fig:arrows.1} |
337 |
|
\end{figure} |
338 |
|
|
339 |
|
\section{\ArrowsOnPlane class} |
340 |
|
\begin{classdesc}{ArrowsOnPlane}{scene, data_collector, transform, lut = None} |
341 |
|
A \ArrowsOnPlane object shows a vector field by arrows on a given plane. |
342 |
|
\end{classdesc} |
343 |
|
|
344 |
|
The following is a sample code using the \ArrowsOnPlane class. |
345 |
|
\fig{fig:arrowsonplane.1} shows the corresponding output. |
346 |
|
\verbatiminput{../examples/driverarrowsonplane.py} |
347 |
|
|
348 |
|
\begin{figure}[ht] |
349 |
|
\begin{center} |
350 |
|
\includegraphics[width=40mm]{figures/ArrowsOnPlane} |
351 |
|
\end{center} |
352 |
|
\caption{Arrows on a plane} |
353 |
|
\label{fig:arrowsonplane.1} |
354 |
|
\end{figure} |
355 |
|
|
356 |
|
\section{\ArrowsOnClip class} |
357 |
|
\begin{classdesc}{ArrowsOnClip}{scene, data_collector, transform, lut = None} |
358 |
|
A \ArrowsOnClip object shows a vector field by arrows on a given clip. |
359 |
|
\end{classdesc} |
360 |
|
|
361 |
|
The following is a sample code using the \ArrowsOnClip class. |
362 |
|
\fig{fig:arrowsonclip.1} shows the corresponding output. |
363 |
|
\verbatiminput{../examples/driverarrowsonclip.py} |
364 |
|
|
365 |
|
\begin{figure}[ht] |
366 |
|
\begin{center} |
367 |
|
\includegraphics[width=40mm]{figures/ArrowsOnClip} |
368 |
|
\end{center} |
369 |
|
\caption{Arrows on a clip} |
370 |
|
\label{fig:arrowsonclip.1} |
371 |
|
\end{figure} |
372 |
|
|
373 |
|
|
374 |
|
\section{\IsoSurface class} |
375 |
|
\begin{classdesc}{IsoSurface}{scene, data_collector, lut = None} |
376 |
|
An \IsoSurface object shows a scalar field for a given value by an isosurface. |
377 |
|
\end{classdesc} |
378 |
|
|
379 |
|
The following is the method available: |
380 |
|
|
381 |
|
\begin{methoddesc}[IsoSurface]{setValue}{contour_number, value} |
382 |
|
Set the contour number and value. |
383 |
|
\end{methoddesc} |
384 |
|
|
385 |
|
The following is a sample code using the \IsoSurface class. |
386 |
|
\fig{fig:isosurface.1} shows the corresponding output. |
387 |
|
\verbatiminput{../examples/driverisosurface.py} |
388 |
|
|
389 |
|
\begin{figure}[ht] |
390 |
|
\begin{center} |
391 |
|
\includegraphics[width=40mm]{figures/IsoSurface} |
392 |
|
\end{center} |
393 |
|
\caption{IsoSurface} |
394 |
|
\label{fig:isosurface.1} |
395 |
|
\end{figure} |
396 |
|
|
397 |
|
\section{\IsoSurfaceOnPlane class} |
398 |
|
\begin{classdesc}{IsoSurfaceOnPlane}{scene, data_collector, transform, |
399 |
|
lut = None} |
400 |
|
An \IsoSurfaceOnPlane object shows a scalar field for a given value |
401 |
|
by an isosurface on a given plane. |
402 |
|
\end{classdesc} |
403 |
|
|
404 |
|
The following is a sample code using the \IsoSurfaceOnPlane class. |
405 |
|
\fig{fig:isosurfaceonplane.1} shows the corresponding output. |
406 |
|
\verbatiminput{../examples/driverisosurfaceonplane.py} |
407 |
|
|
408 |
|
\begin{figure}[ht] |
409 |
|
\begin{center} |
410 |
|
\includegraphics[width=40mm]{figures/IsoSurfaceOnPlane} |
411 |
|
\end{center} |
412 |
|
\caption{IsoSurface on a plane} |
413 |
|
\label{fig:isosurfaceonplane.1} |
414 |
|
\end{figure} |
415 |
|
|
416 |
|
\section{\IsoSurfaceOnClip class} |
417 |
|
\begin{classdesc}{IsoSurfaceOnClip}{scene, data_collector, transform, |
418 |
|
lut = None} |
419 |
|
An \IsoSurfaceOnClip object shows a scalar field for a given value |
420 |
|
by an isosurface on a given clip. |
421 |
|
\end{classdesc} |
422 |
|
|
423 |
|
The following is a sample code using the \IsoSurfaceOnClip class. |
424 |
|
\fig{fig:isosurfaceonclip.1} shows the corresponding output. |
425 |
|
\verbatiminput{../examples/driverisosurfaceonclip.py} |
426 |
|
|
427 |
|
\begin{figure}[ht] |
428 |
|
\begin{center} |
429 |
|
\includegraphics[width=40mm]{figures/IsoSurfaceOnClip} |
430 |
|
\end{center} |
431 |
|
\caption{IsoSurface on a clip} |
432 |
|
\label{fig:isosurfaceonclip.1} |
433 |
|
\end{figure} |
434 |
|
|
435 |
|
\section{\Contour class} |
436 |
|
\begin{classdesc}{Contour}{scene, data_collector, lut = None} |
437 |
|
A \Contour object shows a scalar field contour surfaces. |
438 |
|
\end{classdesc} |
439 |
|
|
440 |
|
The following is the method available: |
441 |
|
\begin{methoddesc}[Contour]{generateValues}{number_contours, min_range, |
442 |
|
max_range} |
443 |
|
Generate the specified number of contours within the specified range. |
444 |
|
\end{methoddesc} |
445 |
|
|
446 |
|
The following is a sample code using the \Contour class. |
447 |
|
\fig{fig:contour.1} shows the corresponding output. |
448 |
|
\verbatiminput{../examples/drivercontour.py} |
449 |
|
|
450 |
|
\begin{figure}[ht] |
451 |
|
\begin{center} |
452 |
|
\includegraphics[width=40mm]{figures/Contour} |
453 |
|
\end{center} |
454 |
|
\caption{Contour} |
455 |
|
\label{fig:contour.1} |
456 |
|
\end{figure} |
457 |
|
|
458 |
|
\section{\ContourOnPlane class} |
459 |
|
\begin{classdesc}{ContourOnPlane}{scene, data_collector, transform, lut = None} |
460 |
|
A \ContourOnPlane object shows a scalar field contour surfaces on a given plane. |
461 |
|
\end{classdesc} |
462 |
|
|
463 |
|
The following is a sample code using the \ContourOnPlane class. |
464 |
|
\fig{fig:contouronplane.1} shows the corresponding output. |
465 |
|
\verbatiminput{../examples/drivercontouronplane.py} |
466 |
|
|
467 |
|
\begin{figure}[ht] |
468 |
|
\begin{center} |
469 |
|
\includegraphics[width=40mm]{figures/ContourOnPlane} |
470 |
|
\end{center} |
471 |
|
\caption{Contour on a plane} |
472 |
|
\label{fig:contouronplane.1} |
473 |
|
\end{figure} |
474 |
|
|
475 |
|
\section{\ContourOnClip class} |
476 |
|
\begin{classdesc}{ContourOnClip}{scene, data_collector, transform, lut = None} |
477 |
|
A \ContourOnClip object shows a scalar field contour surfaces on a given clip. |
478 |
|
\end{classdesc} |
479 |
|
|
480 |
|
The following is a sample code using the \ContourOnClip class. |
481 |
|
\fig{fig:contouronclip.1} shows the corresponding output. |
482 |
|
\verbatiminput{../examples/drivercontouronclip.py} |
483 |
|
|
484 |
|
\begin{figure}[ht] |
485 |
|
\begin{center} |
486 |
|
\includegraphics[width=40mm]{figures/ContourOnClip} |
487 |
|
\end{center} |
488 |
|
\caption{Contour on a clip} |
489 |
|
\label{fig:contouronclip.1} |
490 |
|
\end{figure} |
491 |
|
|
492 |
|
\section{\TensorC class} |
493 |
|
\begin{classdesc}{Tensor}{scene, data_collector, lut = None} |
494 |
|
A \TensorC object shows a tensor field by ellipsoids. |
495 |
|
\end{classdesc} |
496 |
|
|
497 |
|
The following are the methods available: |
498 |
|
\begin{methoddesc}[Tensor]{setThetaResolution}{resolution} |
499 |
|
Set the number of points in the longitude direction. |
500 |
|
\end{methoddesc} |
501 |
|
|
502 |
|
\begin{methoddesc}[Tensor]{setPhiResolution}{resolution} |
503 |
|
Set the number of points in the latitude direction. |
504 |
|
\end{methoddesc} |
505 |
|
|
506 |
|
\begin{methoddesc}[Tensor]{setScaleFactor}{scale_factor} |
507 |
|
Set the tensor scale factor. |
508 |
|
\end{methoddesc} |
509 |
|
|
510 |
|
\begin{methoddesc}[Tensor]{setMaxScaleFactor}{max_scale_factor} |
511 |
|
Set the maximum allowable scale factor. |
512 |
|
\end{methoddesc} |
513 |
|
|
514 |
|
The following is a sample code using the \TensorC class. |
515 |
|
\fig{fig:tensor.1} shows the corresponding output. |
516 |
|
\verbatiminput{../examples/drivertensor.py} |
517 |
|
|
518 |
|
\begin{figure}[ht] |
519 |
|
\begin{center} |
520 |
|
\includegraphics[width=40mm]{figures/Tensor} |
521 |
|
\end{center} |
522 |
|
\caption{Tensor} |
523 |
|
\label{fig:tensor.1} |
524 |
|
\end{figure} |
525 |
|
|
526 |
|
\section{\TensorOnPlane class} |
527 |
|
\begin{classdesc}{TensorOnPlane}{scene, data_collector, transform, lut = None} |
528 |
|
A \TensorOnPlane object shows a tensor field by ellipsoids on a given plane. |
529 |
|
\end{classdesc} |
530 |
|
|
531 |
|
The following is a sample code using the \TensorOnPlane class. |
532 |
|
\fig{fig:tensoronplane.1} shows the corresponding output. |
533 |
|
\verbatiminput{../examples/drivertensoronplane.py} |
534 |
|
|
535 |
|
\begin{figure}[ht] |
536 |
|
\begin{center} |
537 |
|
\includegraphics[width=40mm]{figures/TensorOnPlane} |
538 |
|
\end{center} |
539 |
|
\caption{Tensor on a plane} |
540 |
|
\label{fig:tensoronplane.1} |
541 |
|
\end{figure} |
542 |
|
|
543 |
|
\section{\TensorOnClip class} |
544 |
|
\begin{classdesc}{TensorOnClip}{scene, data_collector, transform, lut = None} |
545 |
|
A \TensorOnClip object shows a tensor field by ellipsoids on a given clip. |
546 |
|
\end{classdesc} |
547 |
|
|
548 |
|
The following is a sample code using the \TensorOnClip class. |
549 |
|
\fig{fig:tensoronclip.1} shows the corresponding output. |
550 |
|
\verbatiminput{../examples/drivertensoronclip.py} |
551 |
|
|
552 |
|
\begin{figure}[ht] |
553 |
|
\begin{center} |
554 |
|
\includegraphics[width=40mm]{figures/TensorOnClip} |
555 |
|
\end{center} |
556 |
|
\caption{Tensor on a clip} |
557 |
|
\label{fig:tensoronclip.1} |
558 |
|
\end{figure} |
559 |
|
|
560 |
|
\section{\StreamLines class} |
561 |
|
\begin{classdesc}{StreamLines}{scene, data_collector, lut = None} |
562 |
|
A \StreamLines object show the path of particles (within a specified cloud |
563 |
|
of points) in a vector field. |
564 |
|
\end{classdesc} |
565 |
|
|
566 |
|
The following are the methods available: |
567 |
|
\begin{methoddesc}[StreamLines]{setCloudRadius}{radius} |
568 |
|
Set the radius for the cloud of points. |
569 |
|
\end{methoddesc} |
570 |
|
|
571 |
|
\begin{methoddesc}[StreamLines]{setCenter}{position} |
572 |
|
Set the center for the cloud of points. |
573 |
|
\end{methoddesc} |
574 |
|
|
575 |
|
\begin{methoddesc}[StreamLines]{setNumberOfPoints}{points} |
576 |
|
Set the number of points to generate for the cloud of points. |
577 |
|
\end{methoddesc} |
578 |
|
|
579 |
|
\begin{methoddesc}[StreamLines]{setMaximumPropagationTime}{time} |
580 |
|
Set the maximum length for the streamlines in unit of time. |
581 |
|
\end{methoddesc} |
582 |
|
|
583 |
|
\begin{methoddesc}[StreamLines]{setStreamLinesSize}{stream_lines_size} |
584 |
|
Set the size of the steamlines. |
585 |
|
\end{methoddesc} |
586 |
|
|
587 |
|
\begin{methoddesc}[StreamLines]{setAccuracy}{accuracy} |
588 |
|
Set the accuracy for the streamlines. |
589 |
|
\end{methoddesc} |
590 |
|
|
591 |
|
\begin{methoddesc}[StreamLines]{setIntegrationToBothDirections}{} |
592 |
|
Set the integration to occur in both directions. |
593 |
|
\end{methoddesc} |
594 |
|
|
595 |
|
\begin{methoddesc}[StreamLines]{setTubeRadius}{radius} |
596 |
|
Set the minimum radius of the tube. |
597 |
|
\end{methoddesc} |
598 |
|
|
599 |
|
\begin{methoddesc}[StreamLines]{setNumberOfSides}{sides} |
600 |
|
Set the number of sides for the tube. |
601 |
|
\end{methoddesc} |
602 |
|
|
603 |
|
\begin{methoddesc}[StreamLines]{setVaryRadiusByVector}{} |
604 |
|
Set the variation of the tube radius with vector data. |
605 |
|
\end{methoddesc} |
606 |
|
|
607 |
|
The following is a sample code using the \StreamLines class. |
608 |
|
\fig{fig:streamlines.1} shows the corresponding output. |
609 |
|
\verbatiminput{../examples/driverstreamlines.py} |
610 |
|
|
611 |
|
\begin{figure}[ht] |
612 |
|
\begin{center} |
613 |
|
\includegraphics[width=40mm]{figures/StreamLines} |
614 |
|
\end{center} |
615 |
|
\caption{StreamLines} |
616 |
|
\label{fig:streamlines.1} |
617 |
|
\end{figure} |
618 |
|
|
619 |
|
\section{\Carpet class} |
620 |
|
\begin{classdesc}{Carpet}{scene, data_collector, transform, lut = None, |
621 |
|
deform = None} |
622 |
|
A \Carpet object shows a scalar/vector field as a plane deformated along |
623 |
|
the plane normal. |
624 |
|
\end{classdesc} |
625 |
|
|
626 |
|
The following is the method available: |
627 |
|
\begin{methoddesc}[Carpet]{setScaleFactor}{scale_factor} |
628 |
|
Set the displancement scale factor. |
629 |
|
\end{methoddesc} |
630 |
|
|
631 |
|
The following is a sample code using the \Carpet class. |
632 |
|
\fig{fig:carpet.1} shows the corresponding output. |
633 |
|
\verbatiminput{../examples/drivercarpet.py} |
634 |
|
|
635 |
|
\begin{figure}[ht] |
636 |
|
\begin{center} |
637 |
|
\includegraphics[width=40mm]{figures/Carpet} |
638 |
|
\end{center} |
639 |
|
\caption{Carpet} |
640 |
|
\label{fig:carpet.1} |
641 |
|
\end{figure} |
642 |
|
|
643 |
|
|
644 |
|
\section{\Position class} |
645 |
|
\begin{classdesc}{Position}{x_coor, y_coor, z_coor} |
646 |
|
A \Position object defines the x, y and z coordinates of rendered object. |
647 |
|
\end{classdesc} |
648 |
|
|
649 |
|
\section{\Transform class} |
650 |
|
\begin{classdesc}{Transform}{} |
651 |
|
A \Transform object defines the orientation of rendered object. |
652 |
|
\end{classdesc} |
653 |
|
|
654 |
|
The following are some of the methods available: |
655 |
|
\begin{methoddesc}[Transform]{translate}{x_offset, y_offset, z_offset} |
656 |
|
Translate the rendered object along the x, y and z-axes. |
657 |
|
\end{methoddesc} |
658 |
|
|
659 |
|
\begin{methoddesc}[Transform]{rotateX}{angle} |
660 |
|
Rotate the rendered object along the x-axis. |
661 |
|
\end{methoddesc} |
662 |
|
|
663 |
|
\begin{methoddesc}[Transform]{rotateY}{angle} |
664 |
|
Rotate the rendered object along the y-axis. |
665 |
|
\end{methoddesc} |
666 |
|
|
667 |
|
\begin{methoddesc}[Transform]{rotateZ}{angle} |
668 |
|
Rotate the rendered object along the z-axis. |
669 |
|
\end{methoddesc} |
670 |
|
|
671 |
|
\begin{methoddesc}[Transform]{xyPlane}{offset = 0} |
672 |
|
Set the plane orthogonal to the z-axis. |
673 |
|
\end{methoddesc} |
674 |
|
|
675 |
|
\begin{methoddesc}[Transform]{yzPlane}{offset = 0} |
676 |
|
Set the plane orthogonal to the x-axis. |
677 |
|
\end{methoddesc} |
678 |
|
|
679 |
|
\begin{methoddesc}[Transform]{xzPlane}{offset = 0} |
680 |
|
Set the plane orthogonal to the y-axis. |
681 |
|
\end{methoddesc} |
682 |
|
|
683 |
|
\section{\Style class} |
684 |
|
\begin{classdesc}{Style}{} |
685 |
|
A \Style object defines the style of text. |
686 |
|
\end{classdesc} |
687 |
|
|
688 |
|
The following are the methods available: |
689 |
|
\begin{methoddesc}[Style]{setFontFamily}{family} |
690 |
|
Set the font family (i.e. Times) |
691 |
|
\end{methoddesc} |
692 |
|
|
693 |
|
\begin{methoddesc}[Style]{boldOn}{} |
694 |
|
Bold the text. |
695 |
|
\end{methoddesc} |
696 |
|
|
697 |
|
\begin{methoddesc}[Style]{italicOn}{} |
698 |
|
Italize the text. |
699 |
|
\end{methoddesc} |
700 |
|
|
701 |
|
\begin{methoddesc}[Style]{shadowOn}{} |
702 |
|
Apply shadows on the text. |
703 |
|
\end{methoddesc} |
704 |
|
|
705 |
|
\begin{methoddesc}[Style]{setColor}{} |
706 |
|
Set the text color. |
707 |
|
\end{methoddesc} |
708 |
|
|
709 |
|
\section{\BlueToRed class} |
710 |
|
\begin{classdesc}{BlueToRed}{} |
711 |
|
A \BlueToRed object defines a map spectrum from blue to red. |
712 |
|
\end{classdesc} |
713 |
|
|
714 |
|
\section{\RedToBlue class} |
715 |
|
\begin{classdesc}{RedToBlue}{} |
716 |
|
A \RedToBlue object defines a map spectrum from red to blue. |
717 |
|
\end{classdesc} |
718 |
|
|
719 |
|
\section{\Plane class} |
720 |
|
The following are the methods available: |
721 |
|
\begin{methoddesc}[Plane]{setPlaneOrigin}{position} |
722 |
|
Set the plane origin |
723 |
|
\end{methoddesc} |
724 |
|
|
725 |
|
\begin{methoddesc}[Plane]{setPlaneNormal}{position} |
726 |
|
Set the plane normal |
727 |
|
\end{methoddesc} |
728 |
|
|
729 |
|
\begin{methoddesc}[Plane]{setValue}{clipping_value} |
730 |
|
Set the clipping value |
731 |
|
\end{methoddesc} |
732 |
|
|
733 |
|
\begin{methoddesc}[Plane]{setInsideOutOn}{} |
734 |
|
Set the clipping to inside out |
735 |
|
\end{methoddesc} |
736 |
|
|
737 |
|
\begin{methoddesc}[Plane]{setInsideOutOff}{} |
738 |
|
Disable the inside out clipping |
739 |
|
\end{methoddesc} |
740 |
|
|
741 |
|
\section{Additional Notes} |
742 |
|
The following is a sample code rendering multiple planes. |
743 |
|
\fig{fig:multipleplanes.1} shows the corresponding output. |
744 |
|
\verbatiminput{../examples/drivermultipleplanes.py} |
745 |
|
|
746 |
|
\begin{figure}[ht] |
747 |
|
\begin{center} |
748 |
|
\includegraphics[width=60mm]{figures/MultiplePlanes} |
749 |
|
\end{center} |
750 |
|
\caption{Multiple planes} |
751 |
|
\label{fig:multipleplanes.1} |
752 |
|
\end{figure} |
753 |
|
|
754 |
|
The following is a sample code rendering multiple cuts. |
755 |
|
\verbatiminput{../examples/drivermultiplecuts.py} |
756 |
|
|
757 |
|
|
758 |
The idea behind is to provide an easy to use interface and unified to a variety of |
The following is a sample code rendering multiple reads from multiple files. |
759 |
visualization tools like \VTK, \OpenDX and \GnuPlot. |
\verbatiminput{../examples/drivermultiplereads.py} |
760 |
|
|
|
The following script illustartes the usage of \pyvisi together with the |
|
|
\VTK library: |
|
|
\begin{python} |
|
|
from esys.pyvisi import * # base level visualisation stuff |
|
|
from esys.pyvisi.renderers.vtk import * # vtk renderer module |
|
|
from esys.escript import * |
|
|
from esys.finley import Brick |
|
|
# now make some data of some kind |
|
|
domain = Brick(3,5,7) # a Finley domain |
|
|
vectorData = domain.getX() # get vector data from the domain nodes |
|
|
# define the scene object |
|
|
scene = Scene() |
|
|
# create an ArrowPlot object |
|
|
plot = ArrowPlot(scene) |
|
|
# add the plot to the scene |
|
|
scene.add(plot) |
|
|
# assign some data to the plot |
|
|
plot.setData(vectorData) |
|
|
# render the scene |
|
|
scene.render() |
|
|
# saving a scene |
|
|
scene.save(file="example.jpg", format="jpeg") |
|
|
\begin{python} |
|
|
A \Scene is a container for all of the kinds of things you want to put into your plot, |
|
|
for instance, images, domaines, arrow plots, contour plots, spheres etc. |
|
|
The renderer is specified in the scene initialisation. In fact the |
|
|
\code{from esys.pyvisi.renderers.vtk import *} provides the specific implementation for |
|
|
\VTK |
|
|
|
|
|
|
|
|
\begin{verbose} |
|
|
class ArrowPlot3D(Plot): |
|
|
""" |
|
|
Arrow field plot in three dimensions |
|
|
""" |
|
|
def __init__(self, scene): |
|
|
""" |
|
|
Initialisation of the ArrowPlot3D class |
|
|
|
|
|
@param scene: The Scene to render the plot in |
|
|
@type scene: Scene object |
|
|
def setData(self, *dataList, **options): |
|
|
""" |
|
|
Set data to the plot |
|
|
|
|
|
@param dataList: List of data to set to the plot |
|
|
@type dataList: tuple |
|
|
|
|
|
@param options: Dictionary of extra options |
|
|
@type options: dict |
|
|
|
|
|
@param fname: Filename of the input vtk file |
|
|
@type fname: string |
|
|
|
|
|
@param format: Format of the input vtk file ('vtk' or 'vtk-xml') |
|
|
@type format: string |
|
|
|
|
|
@param vectors: the name of the vector data in the vtk file to use |
|
|
@type vectors: string |
|
|
""" |
|
|
class ArrowPlot(Plot): |
|
|
""" |
|
|
Arrow field plot |
|
|
""" |
|
|
def __init__(self, scene): |
|
|
""" |
|
|
Initialisation of the ArrowPlot class |
|
|
|
|
|
@param scene: The Scene to render the plot in |
|
|
@type scene: Scene object |
|
|
""" |
|
|
def setData(self, *dataList, **options): |
|
|
""" |
|
|
Set data to the plot |
|
|
|
|
|
@param dataList: List of data to set to the plot |
|
|
@type dataList: tuple |
|
|
|
|
|
@param options: Dictionary of extra options |
|
|
@type options: dict |
|
|
|
|
|
@param fname: the name of the input vtk file |
|
|
@type fname: string |
|
|
|
|
|
@param format: the format of the input vtk file ('vtk' or 'vtk-xml') |
|
|
@type format: string |
|
|
|
|
|
@param vectors: the name of the vector data in the vtk file to use |
|
|
@type vectors: string |
|
|
""" |
|
|
class Axes(Plot): |
|
|
""" |
|
|
Axes class |
|
|
""" |
|
|
def __init__(self): |
|
|
""" |
|
|
Initialisation of Axes object |
|
|
""" |
|
|
debugMsg("Called Axes.__init__()") |
|
|
Plot.__init__(self) |
|
|
|
|
|
class BallPlot(Plot): |
|
|
""" |
|
|
Ball plot |
|
|
""" |
|
|
def __init__(self, scene): |
|
|
|
|
|
def setData(self, points=None, |
|
|
fname=None, format=None, |
|
|
radii=None, colors=None, tags=None): |
|
|
""" |
|
|
Set data to the plot |
|
|
@param points: the array to use for the points of the sphere |
|
|
locations in space |
|
|
@type points: float array |
|
|
|
|
|
@param fname: the name of the input vtk file |
|
|
@type fname: string |
|
|
|
|
|
@param format: the format of the input vtk file ('vtk' or 'vtk-xml') |
|
|
@type format: string |
|
|
|
|
|
@param radii: the name of the scalar array in the vtk unstructured |
|
|
grid to use as the radii of the balls |
|
|
@type radii: float array |
|
|
|
|
|
@param colors: the name of the scalar array in the vtk unstructured |
|
|
grid to use as the colour tags of the balls |
|
|
@type colors: string |
|
|
|
|
|
@param tags: the name of the scalar array in the vtk unstructured |
|
|
grid to use as the colour of the tags of the balls |
|
|
@type tags: integer array |
|
|
""" |
|
|
|
|
|
class Box(Item): |
|
|
""" |
|
|
Generic class for Box objects |
|
|
|
|
|
To define a box one specify one of three groups of things: |
|
|
- The bounds of the box: xmin, xmax, ymin, ymax, zmin, zmax |
|
|
- The dimensions and origin: width, height, depth and origin |
|
|
- The bottom left front and top right back corners: blf, trb |
|
|
""" |
|
|
|
|
|
def __init__(self): |
|
|
""" |
|
|
Initialisation of the Box object |
|
|
""" |
|
|
debugMsg("Called Box.__init__()") |
|
|
Item.__init__(self) |
|
|
|
|
|
# define a box in many ways, either by its centre and width, height |
|
|
# and depth, or by its bounds, xmin, xmax, ymin, ymax, zmin, zmax, |
|
|
# or by its bottom left front and top right back points. |
|
|
|
|
|
# set the default bounds |
|
|
self.xmin = -0.5 |
|
|
self.xmax = 0.5 |
|
|
self.ymin = -0.5 |
|
|
self.ymax = 0.5 |
|
|
self.zmin = -0.5 |
|
|
self.zmax = 0.5 |
|
|
|
|
|
# set the default origin (the centre of the box) |
|
|
self.origin = ((self.xmin + self.xmax)/2.0, |
|
|
(self.ymin + self.ymax)/2.0, |
|
|
(self.zmin + self.zmax)/2.0) |
|
|
|
|
|
# set the default dimensions |
|
|
self.width = self.xmax - self.xmin |
|
|
self.height = self.ymax - self.ymin |
|
|
self.depth = self.zmax - self.zmin |
|
|
|
|
|
# set the default blf and trb points |
|
|
self.blf = (self.xmin, self.ymin, self.zmin) |
|
|
self.trb = (self.xmax, self.ymax, self.zmax) |
|
|
|
|
|
# tolerance for calculated variables checking purposes |
|
|
self.tolerance = 1e-8 |
|
|
|
|
|
def setBounds(self, xmin, xmax, ymin, ymax, zmin, zmax): |
|
|
""" |
|
|
Set the bounds of the box |
|
|
""" |
|
|
def getBounds(self): |
|
|
""" |
|
|
Get the current bounds of the box |
|
|
""" |
|
|
|
|
|
def setOrigin(self, xo, yo, zo): |
|
|
""" |
|
|
Set the origin of the box |
|
|
""" |
|
|
def getOrigin(self): |
|
|
""" |
|
|
Get the current origin of the box |
|
|
""" |
|
|
debugMsg("Called Box.getOrigin()") |
|
|
return self.origin |
|
|
|
|
|
def setWidth(self, width): |
|
|
""" |
|
|
Set the width of the box |
|
|
""" |
|
|
def getWidth(self): |
|
|
""" |
|
|
Get the current box width |
|
|
""" |
|
|
debugMsg("Called Box.getWidth()") |
|
|
return self.width |
|
|
|
|
|
def setHeight(self, height): |
|
|
""" |
|
|
Set the box height |
|
|
""" |
|
|
|
|
|
def getHeight(self): |
|
|
""" |
|
|
Get the current box height |
|
|
""" |
|
|
debugMsg("Called Box.getHeight()") |
|
|
return self.height |
|
|
|
|
|
def setDepth(self, depth): |
|
|
""" |
|
|
Set the box depth |
|
|
""" |
|
|
|
|
|
def getDepth(self): |
|
|
""" |
|
|
Get the current box depth |
|
|
""" |
|
|
debugMsg("Called Box.getDepth()") |
|
|
return self.depth |
|
|
|
|
|
def setBLF(self, bottom, left, front): |
|
|
""" |
|
|
Set the position of the bottom, left, front corner |
|
|
""" |
|
|
|
|
|
def getBLF(self): |
|
|
""" |
|
|
Get the current position of the bottom, left, front corner |
|
|
""" |
|
|
debugMsg("Called Box.getBLF()") |
|
|
return self.blf |
|
|
|
|
|
def setTRB(self, top, right, back): |
|
|
""" |
|
|
Set the position of the top, right, back corner |
|
|
""" |
|
|
|
|
|
def getTRB(self): |
|
|
""" |
|
|
Get the current position of the top, right, back corner |
|
|
""" |
|
|
debugMsg("Called Box.getTRB()") |
|
|
return self.trb |
|
|
|
|
|
|
|
|
class ClipBox(Box): |
|
|
""" |
|
|
Clip box class: used to clip data sets with a box |
|
|
|
|
|
A box in this sense means three planes at right angles to one another |
|
|
""" |
|
|
|
|
|
def __init__(self, plot): |
|
|
""" |
|
|
Intialisation of the ClipBox object |
|
|
""" |
|
|
|
|
|
def setInsideOut(self, insideOut): |
|
|
""" |
|
|
Set the inside out flag |
|
|
""" |
|
|
|
|
|
def getInsideOut(self): |
|
|
""" |
|
|
Get the current value of the inside out flag |
|
|
""" |
|
|
|
|
|
class Camera(Item): |
|
|
""" |
|
|
Camera class |
|
|
""" |
|
|
def __init__(self, scene): |
|
|
""" |
|
|
Initialisation of the Camera object |
|
|
|
|
|
@param scene: The Scene object to add the Camera object to |
|
|
@type scene: Scene object |
|
|
""" |
|
|
def setPosition(self, *pos): |
|
|
""" |
|
|
Set position of camera within scene |
|
|
|
|
|
@param pos: Position to set camera in terms of x,y,z coordinates |
|
|
@type pos: tuple |
|
|
""" |
|
|
|
|
|
def getPosition(self): |
|
|
""" |
|
|
Get the position of Camera within Scene |
|
|
|
|
|
Returns the position in a tuple of form (xPos, yPos, zPos) |
|
|
""" |
|
|
debugMsg("Called Camera.getPosition()") |
|
|
|
|
|
return (self.xPos, self.yPos, self.zPos) |
|
|
|
|
|
def setFocalPoint(self, *pos): |
|
|
""" |
|
|
Sets the focal point of the Camera with the Scene |
|
|
|
|
|
@param pos: Position to set the focal point |
|
|
@type pos: tuple |
|
|
""" |
|
|
|
|
|
def getFocalPoint(self): |
|
|
""" |
|
|
Get the position of the focal point of the Camera |
|
|
|
|
|
Returns the position of the focal point in a tuple of form |
|
|
(xPos, yPos, zPos) |
|
|
""" |
|
|
|
|
|
def setElevation(self, elevation): |
|
|
""" |
|
|
Set the elevation angle (in degrees) of the Camera |
|
|
|
|
|
@param elevation: The elevation angle (in degrees) of the Camera |
|
|
@type elevation: float |
|
|
""" |
|
|
|
|
|
return |
|
|
|
|
|
def getElevation(self): |
|
|
""" |
|
|
Gets the elevation angle (in degrees) of the Camera |
|
|
""" |
|
|
|
|
|
def setAzimuth(self, azimuth): |
|
|
""" |
|
|
Set the azimuthal angle (in degrees) of the Camera |
|
|
|
|
|
@param azimuth: The azimuthal angle (in degrees) of the Camera |
|
|
@type azimuth: float |
|
|
""" |
|
|
|
|
|
def getAzimuth(self): |
|
|
""" |
|
|
Get the azimuthal angle (in degrees) of the Camera |
|
|
""" |
|
|
class ContourPlot(Plot): |
|
|
""" |
|
|
Contour plot |
|
|
""" |
|
|
def __init__(self, scene): |
|
|
""" |
|
|
Initialisation of the ContourPlot class |
|
|
|
|
|
@param scene: The Scene to render the plot in |
|
|
@type scene: Scene object |
|
|
""" |
|
|
def setData(self, *dataList, **options): |
|
|
""" |
|
|
Set data to the plot |
|
|
|
|
|
@param dataList: List of data to set to the plot |
|
|
@type dataList: tuple |
|
|
|
|
|
@param options: Dictionary of extra options |
|
|
@type options: dict |
|
|
|
|
|
@param fname: the name of the input vtk file |
|
|
@type fname: string |
|
|
|
|
|
@param format: the format of the input vtk file ('vtk' or 'vtk-xml') |
|
|
@type format: string |
|
|
|
|
|
@param scalars: the scalar data in the vtk file to use |
|
|
@type scalars: string |
|
|
""" |
|
|
|
|
|
class EllipsoidPlot(Plot): |
|
|
""" |
|
|
Ellipsoid plot |
|
|
""" |
|
|
def __init__(self, scene): |
|
|
""" |
|
|
Initialisation of the EllipsoidPlot class |
|
|
|
|
|
@param scene: The Scene to render the plot in |
|
|
@type scene: Scene object |
|
|
""" |
|
|
debugMsg("Called EllipsoidPlot.__init__()") |
|
|
Plot.__init__(self, scene) |
|
|
|
|
|
self.renderer = scene.renderer |
|
|
self.renderer.addToInitStack("# EllipsoidPlot.__init__()") |
|
|
|
|
|
# labels and stuff |
|
|
self.title = None |
|
|
self.xlabel = None |
|
|
self.ylabel = None |
|
|
self.zlabel = None |
|
|
|
|
|
# default values for fname, format and tensors |
|
|
self.fname = None |
|
|
self.format = None |
|
|
self.tensors = None |
|
|
|
|
|
# default values for shared info |
|
|
self.escriptData = False |
|
|
self.otherData = False |
|
|
|
|
|
# add the plot to the scene |
|
|
scene.add(self) |
|
|
|
|
|
def setData(self, *dataList, **options): |
|
|
""" |
|
|
Set data to the plot |
|
|
|
|
|
@param dataList: List of data to set to the plot |
|
|
@type dataList: tuple |
|
|
|
|
|
@param options: Dictionary of keyword options to the method |
|
|
@type options: dict |
|
|
|
|
|
@param fname: the name of the input vtk file |
|
|
@type fname: string |
|
|
|
|
|
@param format: the format of the input vtk file ('vtk' or 'vtk-xml') |
|
|
@type format: string |
|
|
|
|
|
@param tensors: the name of the tensor data in the vtk file to use |
|
|
@type tensors: string |
|
|
""" |
|
|
|
|
|
class Image(Item): |
|
|
""" |
|
|
Image class. Generic class to handle image data. |
|
|
""" |
|
|
def __init__(self, scene=None): |
|
|
""" |
|
|
Initialises the Image class object |
|
|
|
|
|
@param scene: The Scene object to add to |
|
|
@type scene: Scene object |
|
|
""" |
|
|
debugMsg("Called Image.__init__()") |
|
|
Item.__init__(self) |
|
|
|
|
|
if scene is not None: |
|
|
self.renderer = scene.renderer |
|
|
|
|
|
def load(self, fname): |
|
|
""" |
|
|
Loads image data from file. |
|
|
|
|
|
@param fname: The filename from which to load image data |
|
|
@type fname: string |
|
|
""" |
|
|
debugMsg("Called Image.load()") |
|
|
|
|
|
fileCheck(fname) |
|
|
|
|
|
return |
|
|
|
|
|
class JpegImage(Image): |
|
|
""" |
|
|
Subclass of Image class to explicitly handle jpeg images |
|
|
""" |
|
|
def __init__(self, scene=None): |
|
|
""" |
|
|
Initialises the JpegImage class object |
|
|
|
|
|
@param scene: The Scene object to add to |
|
|
@type scene: Scene object |
|
|
""" |
|
|
|
|
|
def load(self, fname): |
|
|
""" |
|
|
Loads jpeg image data from file. |
|
|
|
|
|
@param fname: The filename from which to load jpeg image data |
|
|
@type fname: string |
|
|
""" |
|
|
|
|
|
class PngImage(Image): |
|
|
""" |
|
|
Subclass of Image class to explicitly handle png images |
|
|
""" |
|
|
def __init__(self, scene=None): |
|
|
""" |
|
|
Initialises the PngImage class object |
|
|
|
|
|
@param scene: The Scene object to add to |
|
|
@type scene: Scene object |
|
|
""" |
|
|
|
|
|
def load(self, fname): |
|
|
""" |
|
|
Loads png image data from file. |
|
|
|
|
|
@param fname: The filename from which to load png image data |
|
|
@type fname: string |
|
|
""" |
|
|
class BmpImage(Image): |
|
|
""" |
|
|
Subclass of Image class to explicitly handle bmp images |
|
|
""" |
|
|
def __init__(self, scene=None): |
|
|
""" |
|
|
Initialises the BmpImage class object |
|
|
|
|
|
@param scene: The Scene object to add to |
|
|
@type scene: Scene object |
|
|
""" |
|
|
def load(self, fname): |
|
|
""" |
|
|
Loads bmp image data from file. |
|
|
|
|
|
@param fname: The filename from which to load bmp image data |
|
|
@type fname: string |
|
|
""" |
|
|
|
|
|
class TiffImage(Image): |
|
|
""" |
|
|
Subclass of Image class to explicitly handle tiff images |
|
|
""" |
|
|
def __init__(self, scene=None): |
|
|
""" |
|
|
Initialises the TiffImage class object |
|
|
|
|
|
@param scene: The Scene object to add to |
|
|
@type scene: Scene object |
|
|
""" |
|
|
def load(self, fname): |
|
|
""" |
|
|
Loads tiff image data from file. |
|
|
|
|
|
@param fname: The filename from which to load tiff image data |
|
|
@type fname: string |
|
|
""" |
|
|
class PnmImage(Image): |
|
|
""" |
|
|
Subclass of Image class to explicitly handle pnm (ppm, pgm, pbm) images |
|
|
""" |
|
|
def __init__(self, scene=None): |
|
|
""" |
|
|
Initialises the PnmImage class object |
|
|
|
|
|
@param scene: The Scene object to add to |
|
|
@type scene: Scene object |
|
|
""" |
|
|
|
|
|
def load(self, fname): |
|
|
""" |
|
|
Loads pnm (ppm, pgm, pbm) image data from file. |
|
|
|
|
|
@param fname: The filename from which to load pnm image data |
|
|
@type fname: string |
|
|
""" |
|
|
|
|
|
class PsImage(Image): |
|
|
""" |
|
|
Subclass of Image class to explicitly handle ps images |
|
|
""" |
|
|
def __init__(self, scene=None): |
|
|
""" |
|
|
Initialises the PsImage class object |
|
|
|
|
|
This object is B{only} used for generating postscript output |
|
|
|
|
|
@param scene: The Scene object to add to |
|
|
@type scene: Scene object |
|
|
""" |
|
|
|
|
|
def load(self, fname): |
|
|
""" |
|
|
Loads ps image data from file. |
|
|
|
|
|
B{NOT} supported by this renderer module |
|
|
|
|
|
@param fname: The filename from which to load ps image data |
|
|
@type fname: string |
|
|
""" |
|
|
debugMsg("Called PsImage.load()") |
|
|
|
|
|
# need to check if the file exists |
|
|
fileCheck(fname) |
|
|
|
|
|
# this ability not handled by this renderer module |
|
|
unsupportedError() |
|
|
|
|
|
return |
|
|
|
|
|
def render(self): |
|
|
""" |
|
|
Does PsImage object specific (pre)rendering stuff |
|
|
""" |
|
|
debugMsg("Called PsImage.render()") |
|
|
|
|
|
return |
|
|
|
|
|
class PdfImage(Image): |
|
|
""" |
|
|
Subclass of Image class to explicitly handle pdf images |
|
|
""" |
|
|
def __init__(self, scene=None): |
|
|
""" |
|
|
Initialises the PdfImage class object |
|
|
|
|
|
This object is B{only} used for generating pdf output |
|
|
|
|
|
@param scene: The Scene object to add to |
|
|
@type scene: Scene object |
|
|
""" |
|
|
|
|
|
def load(self, fname): |
|
|
""" |
|
|
Loads pdf image data from file. |
|
|
|
|
|
B{NOT} supported by this renderer module |
|
|
|
|
|
@param fname: The filename from which to load pdf image data |
|
|
@type fname: string |
|
|
""" |
|
|
|
|
|
class IsosurfacePlot(Plot): |
|
|
""" |
|
|
Isosurface plot |
|
|
""" |
|
|
def __init__(self, scene): |
|
|
""" |
|
|
Initialisation of the IsosurfacePlot class |
|
|
|
|
|
@param scene: The Scene to render the plot in |
|
|
@type scene: Scene object |
|
|
""" |
|
|
def setData(self, *dataList, **options): |
|
|
""" |
|
|
Set data to the plot |
|
|
|
|
|
@param dataList: List of data to set to the plot |
|
|
@type dataList: tuple |
|
|
|
|
|
@param options: Dictionary of keyword options to the method |
|
|
@type options: dict |
|
|
|
|
|
@param fname: the name of the input vtk file |
|
|
@type fname: string |
|
|
|
|
|
@param format: the format of the input vtk file ('vtk' or 'vtk-xml') |
|
|
@type format: string |
|
|
|
|
|
@param scalars: the name of the scalar data in the vtk file to use |
|
|
@type scalars: string |
|
|
""" |
|
|
|
|
|
class LinePlot(Plot): |
|
|
""" |
|
|
Line plot |
|
|
""" |
|
|
def __init__(self, scene): |
|
|
""" |
|
|
Initialisation of the LinePlot class |
|
|
|
|
|
@param scene: The Scene to render the plot in |
|
|
@type scene: Scene object |
|
|
""" |
|
|
|
|
|
def setData(self, *dataList, **options): |
|
|
""" |
|
|
Set data to the plot |
|
|
|
|
|
@param dataList: List of data to set to the plot |
|
|
@type dataList: tuple |
|
|
|
|
|
@param options: Dictionary of extra options |
|
|
@type options: dict |
|
|
|
|
|
@param offset: whether or not to offset the lines from one another |
|
|
@type offset: boolean |
|
|
|
|
|
@param fname: Filename of the input vtk file |
|
|
@type fname: string |
|
|
|
|
|
@param format: format of the input vtk file ('vtk' or 'vtk-xml') |
|
|
@type format: string |
|
|
|
|
|
@param scalars: the name of the scalar data in the vtk file to use |
|
|
@type scalars: string |
|
|
""" |
|
|
|
|
|
class OffsetPlot(Plot): |
|
|
""" |
|
|
Offset plot |
|
|
""" |
|
|
def __init__(self, scene): |
|
|
""" |
|
|
Initialisation of the OffsetPlot class |
|
|
|
|
|
@param scene: The Scene to render the plot in |
|
|
@type scene: Scene object |
|
|
""" |
|
|
|
|
|
def setData(self, *dataList, **options): |
|
|
""" |
|
|
Set data to the plot |
|
|
|
|
|
@param dataList: List of data to set to the plot |
|
|
@type dataList: tuple |
|
|
|
|
|
@param options: Dictionary of extra options |
|
|
@type options: dict |
|
|
|
|
|
@param fname: Filename of the input vtk file |
|
|
@type fname: string |
|
|
|
|
|
@param format: Format of the input vtk file ('vtk' or 'vtk-xml') |
|
|
@type format: string |
|
|
|
|
|
@param scalars: the name of the scalar data in the vtk file to use |
|
|
@type scalars: string |
|
|
""" |
|
|
class Plane(Item): |
|
|
""" |
|
|
Generic class for Plane objects |
|
|
""" |
|
|
|
|
|
def __init__(self, scene): |
|
|
""" |
|
|
Initialisation of the Plane object |
|
|
""" |
|
|
|
|
|
def setOrigin(self, x, y, z): |
|
|
""" |
|
|
Set the origin of the plane |
|
|
""" |
|
|
|
|
|
def getOrigin(self): |
|
|
""" |
|
|
Get the current origin of the plane |
|
|
""" |
|
|
|
|
|
def setNormal(self, vx, vy, vz): |
|
|
""" |
|
|
Set the normal vector to the plane |
|
|
""" |
|
|
|
|
|
def getNormal(self): |
|
|
""" |
|
|
Get the current normal vector to the plane |
|
|
""" |
|
|
|
|
|
def mapImageToPlane(self, image): |
|
|
# this really needs to go somewhere else!!! |
|
|
""" |
|
|
Maps an Image object onto a Plane object |
|
|
""" |
|
|
|
|
|
class CutPlane(Plane): |
|
|
""" |
|
|
Cut plane class: used to cut data sets with a plane |
|
|
|
|
|
Cut plane objects define a plane to cut a data set or plot by and return |
|
|
the data along the intersection between the data set or plot with the |
|
|
defined plane. |
|
|
""" |
|
|
|
|
|
def __init__(self): |
|
|
""" |
|
|
Intialisation of the CutPlane object |
|
|
""" |
|
|
|
|
|
|
|
|
class ClipPlane(Plane): |
|
|
""" |
|
|
Class for planes used to clip datasets |
|
|
""" |
|
|
|
|
|
def __init__(self): |
|
|
""" |
|
|
Intialisation of the ClipPlane object |
|
|
""" |
|
|
|
|
|
def setInsideOut(self, insideOut): |
|
|
""" |
|
|
Set the inside out flag |
|
|
""" |
|
|
|
|
|
def getInsideOut(self): |
|
|
""" |
|
|
Get the current value of the inside out flag |
|
|
""" |
|
|
|
|
|
class Plot(Item): |
|
|
""" |
|
|
Abstract plot class |
|
|
""" |
|
|
def __init__(self, scene): |
|
|
""" |
|
|
Initialisation of the abstract Plot class |
|
|
|
|
|
@param scene: The Scene to render the plot in |
|
|
@type scene: Scene object |
|
|
""" |
|
|
|
|
|
def setData(self, *dataList, **options): |
|
|
""" |
|
|
Set data to the plot |
|
|
|
|
|
@param dataList: List of data to set to the plot |
|
|
@type dataList: tuple |
|
|
|
|
|
@param options: Dictionary of extra options |
|
|
@type options: dict |
|
|
""" |
|
|
|
|
|
def setTitle(self, title): |
|
|
""" |
|
|
Set the plot title |
|
|
|
|
|
@param title: the string holding the title to the plot |
|
|
@type title: string |
|
|
""" |
|
|
debugMsg("Called setTitle() in Plot()") |
|
|
|
|
|
|
|
|
def setXLabel(self, label): |
|
|
""" |
|
|
Set the label of the x-axis |
|
|
|
|
|
@param label: the string holding the label of the x-axis |
|
|
@type label: string |
|
|
""" |
|
|
|
|
|
def setYLabel(self, label): |
|
|
""" |
|
|
Set the label of the y-axis |
|
|
|
|
|
@param label: the string holding the label of the y-axis |
|
|
@type label: string |
|
|
""" |
|
|
|
|
|
def setZLabel(self, label): |
|
|
""" |
|
|
Set the label of the z-axis |
|
|
|
|
|
@param label: the string holding the label of the z-axis |
|
|
@type label: string |
|
|
""" |
|
|
|
|
|
def setLabel(self, axis, label): |
|
|
""" |
|
|
Set the label of a given axis |
|
|
|
|
|
@param axis: string (Axis object maybe??) of the axis (e.g. x, y, z) |
|
|
@type axis: string or Axis object |
|
|
|
|
|
@param label: string of the label to set for the axis |
|
|
@type label: string |
|
|
""" |
|
|
|
|
|
class Renderer(BaseRenderer): |
|
|
""" |
|
|
A generic object holding a renderer of a Scene(). |
|
|
""" |
|
|
|
|
|
def __init__(self): |
|
|
""" |
|
|
Initialisation of Renderer() class |
|
|
""" |
|
|
debugMsg("Called Renderer.__init__()") |
|
|
BaseRenderer.__init__(self) |
|
|
|
|
|
# initialise some attributes |
|
|
self.renderWindowWidth = 640 |
|
|
self.renderWindowHeight = 480 |
|
|
|
|
|
# what is the name of my renderer? |
|
|
self.name = _rendererName |
|
|
|
|
|
# the namespace to run the exec code |
|
|
self.renderDict = {} |
|
|
|
|
|
# initialise the evalstack |
|
|
self._evalStack = "" |
|
|
|
|
|
# keep the initial setup of the module for later reuse |
|
|
self._initStack = "" |
|
|
|
|
|
# initialise the renderer module |
|
|
self.runString("# Renderer._initRendererModule") |
|
|
self.addToInitStack("import vtk") |
|
|
self.addToInitStack("from numarray import *") |
|
|
|
|
|
__revision__ = '$Revision: 1.33 $' |
|
|
|
|
|
class Scene(BaseScene): |
|
|
""" |
|
|
The main object controlling the scene. |
|
|
|
|
|
Scene object methods and classes overriding the BaseScene class. |
|
|
""" |
|
|
|
|
|
def __init__(self): |
|
|
""" |
|
|
The init function |
|
|
""" |
|
|
|
|
|
def add(self, obj): |
|
|
""" |
|
|
Add a new item to the scene |
|
|
|
|
|
@param obj: The object to add to the scene |
|
|
@type obj: object |
|
|
""" |
|
|
|
|
|
def place(self, obj): |
|
|
""" |
|
|
Place an object within a scene |
|
|
|
|
|
@param obj: The object to place within the scene |
|
|
@type obj: object |
|
|
""" |
|
|
|
|
|
def render(self, pause=False, interactive=False): |
|
|
""" |
|
|
Render (or re-render) the scene |
|
|
|
|
|
Render the scene, either to screen, or to a buffer waiting for a save |
|
|
|
|
|
@param pause: Flag to wait at end of script evaluation for user input |
|
|
@type pause: boolean |
|
|
|
|
|
@param interactive: Whether or not to have interactive use of the output |
|
|
@type interactive: boolean |
|
|
""" |
|
|
|
|
|
def save(self, fname, format): |
|
|
""" |
|
|
Save the scene to a file |
|
|
|
|
|
Possible formats are: |
|
|
- Postscript |
|
|
- PNG |
|
|
- JPEG |
|
|
- TIFF |
|
|
- BMP |
|
|
- PNM |
|
|
|
|
|
@param fname: Name of output file |
|
|
@type fname: string |
|
|
|
|
|
@param format: Graphics format of output file |
|
|
@type format: Image object or string |
|
|
""" |
|
|
|
|
|
def setBackgroundColor(self, *color): |
|
|
""" |
|
|
Sets the background color of the Scene |
|
|
|
|
|
@param color: The color to set the background to. Can be RGB or CMYK |
|
|
@type color: tuple |
|
|
""" |
|
|
|
|
|
def getBackgroundColor(self): |
|
|
""" |
|
|
Gets the current background color setting of the Scene |
|
|
""" |
|
|
|
|
|
def setSize(self, xSize, ySize): |
|
|
""" |
|
|
Sets the size of the scene. |
|
|
|
|
|
This size is effectively the renderer window size. |
|
|
|
|
|
@param xSize: the size to set the x dimension |
|
|
@type xSize: float |
|
|
|
|
|
@param ySize: the size to set the y dimension |
|
|
@type ySize: float |
|
|
""" |
|
|
|
|
|
def getSize(self): |
|
|
""" |
|
|
Gets the current size of the scene |
|
|
|
|
|
This size is effectively the renderer window size. Returns a tuple |
|
|
of the x and y dimensions respectively, in pixel units(??). |
|
|
""" |
|
|
class SurfacePlot(Plot): |
|
|
""" |
|
|
Surface plot |
|
|
""" |
|
|
def __init__(self, scene): |
|
|
""" |
|
|
Initialisation of the SurfacePlot class |
|
|
|
|
|
@param scene: The Scene to render the plot in |
|
|
@type scene: Scene object |
|
|
""" |
|
|
|
|
|
def setData(self, *dataList, **options): |
|
|
""" |
|
|
Set data to the plot |
|
|
|
|
|
@param dataList: List of data to set to the plot |
|
|
@type dataList: tuple |
|
|
|
|
|
@param options: Dictionary of extra options |
|
|
@type options: dict |
|
|
|
|
|
@param fname: the name of the input vtk file |
|
|
@type fname: string |
|
|
|
|
|
@param format: the format of the input vtk file ('vtk' or 'vtk-xml') |
|
|
@type format: string |
|
|
|
|
|
@param scalars: the scalar data in the vtk file to use |
|
|
@type scalars: string |
|
|
""" |
|
|
|
|
|
class Text(Item): |
|
|
""" |
|
|
Text |
|
|
""" |
|
|
def __init__(self, scene): |
|
|
""" |
|
|
Initialisation of the Text object |
|
|
|
|
|
@param scene: the scene with which to associate the Text object |
|
|
@type scene: Scene object |
|
|
""" |
|
|
|
|
|
def setFont(self, font): |
|
|
""" |
|
|
Set the current font |
|
|
|
|
|
@param font: the font to set |
|
|
@type font: string |
|
|
""" |
|
|
|
|
|
def getFont(self): |
|
|
""" |
|
|
\end{verbose} |
|