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. The module provides the following features: |
9 |
|
|
10 |
|
\begin{itemize} |
11 |
|
\item \Scene: Shows a scene in which components are to be displayed. |
12 |
|
\item \DataCollector: Deals with data for visualization. |
13 |
|
\item \Camera: Controls the camera manipulation. |
14 |
|
\item \Map: Shows a scalar field by color on the domain surface. |
15 |
|
\item \MapOnPlane: Shows a scalar field by color on a given plane. |
16 |
|
\item \MapOnClip: Shows a scalar field by color on a given clip. |
17 |
|
\item \Arrows: Shows a vector field by arrows. |
18 |
|
\item \ArrowsOnPlane: Shows a vector field by arrows on a given plane. |
19 |
|
\item \ArrowsOnClip: Shows a vector field by arrows on a given clip. |
20 |
|
\item \IsoSurface: Shows a scalar field for a given value by |
21 |
|
an isosurface. |
22 |
|
\item \IsoSurfaceOnPlane: Shows a scalar field for a given value by |
23 |
|
an isosurfaceon a given plane. |
24 |
|
\item \IsoSurfaceOnClip: Shows a scalar field for a given vlaue by |
25 |
|
an isosurface on a given clip. |
26 |
|
\item \Contour: Shows a scalar field by contour surfaces. |
27 |
|
\item \ContourOnPlane: Shows a scalar field by contour surfaces on |
28 |
|
a given plane. |
29 |
|
\item \ContourOnClip: Shows a scalar field by contour surfaces on |
30 |
|
a given clip. |
31 |
|
\item \TensorC: Shows a tensor field by ellipsoids. |
32 |
|
\item \TensorOnPlane: Shows a tensor field by ellipsoids on |
33 |
|
a given plane. |
34 |
|
\item \TensorOnClip: Shows a tensor field by ellipsoids on a given clip. |
35 |
|
\item \StreamLines: Shows the path of particles in a vector field. |
36 |
|
\item \Carpet: Shows a scalar field as plane deformated along |
37 |
|
the plane normal. |
38 |
|
\item \Image: Shows an image. |
39 |
|
\item \Text: Shows some 2D text. |
40 |
|
\item \Position: Defines the x,y and z coordinates rendered object. |
41 |
|
\item \Transform: Defines the orientation of rendered object. |
42 |
|
\item \Style: Defines the style of text. |
43 |
|
\item \BlueToRed: Defines a map spectrum from blue to red. |
44 |
|
\item \RedToBlue: Defines a map spectrum from red to blue. |
45 |
|
\end{itemize} |
46 |
|
|
47 |
|
\section{\Scene class} |
48 |
|
\begin{classdesc}{Scene}{renderer, x_size = 500, y_size = 500} |
49 |
|
A \Scene object creates a window onto which objects are to be displayed. |
50 |
|
\end{classdesc} |
51 |
|
|
52 |
|
The following are the methods available: |
53 |
|
\begin{methoddesc}[Scene]{saveImage}{image_name} |
54 |
|
Save the rendered object as an image off-screen. |
55 |
|
\end{methoddesc} |
56 |
|
|
57 |
|
\begin{methoddesc}[Scene]{render}{} |
58 |
|
Render the object on-screen. |
59 |
|
\end{methoddesc} |
60 |
|
|
61 |
|
The following is a sample code using the \Scene class: |
62 |
|
\verbatiminput{../examples/driverscene.py} |
63 |
|
|
64 |
|
\section{\DataCollector class} |
65 |
|
\begin{classdesc}{DataCollector}{scene, outline = True, cube_axes = False} |
66 |
|
A \DataCollector object deals with the data for visualization. |
67 |
|
\end{classdesc} |
68 |
|
|
69 |
|
The following are the methods available: |
70 |
|
\begin{methoddesc}[DataCollector]{setFileName}{file_name} |
71 |
|
Set the file name from which data is to be read. |
72 |
|
\end{methoddesc} |
73 |
|
|
74 |
|
The following is a sample code using the \DataCollector class. |
75 |
|
\fig{fig:datacollector.1} shows the corresponding output. |
76 |
|
\verbatiminput{../examples/driverdatacollector.py} |
77 |
|
|
78 |
|
\begin{figure}[ht] |
79 |
|
\begin{center} |
80 |
|
\includegraphics[width=40mm]{figures/DataCollector} |
81 |
|
\end{center} |
82 |
|
\caption{Datacollector generating an outline with cube axes.} |
83 |
|
\label{fig:datacollector.1} |
84 |
|
\end{figure} |
85 |
|
|
86 |
|
\section{\Camera class} |
87 |
|
\begin{classdesc}{Camera}{scene, data_collector} |
88 |
|
A \Camera object controls the camera's settings. |
89 |
|
\end{classdesc} |
90 |
|
|
91 |
|
The following are some of the methods available: |
92 |
|
\begin{methoddesc}[Camera]{setClippingRange}{near_clipping, far_clipping} |
93 |
|
Set the near and far clipping plane of the camera. |
94 |
|
\end{methoddesc} |
95 |
|
|
96 |
|
\begin{methoddesc}[Camera]{setFocalPoint}{position} |
97 |
|
Set the focal point of the camera. |
98 |
|
\end{methoddesc} |
99 |
|
|
100 |
|
\begin{methoddesc}[Camera]{setPosition}{position} |
101 |
|
Set the position of the camera. |
102 |
|
\end{methoddesc} |
103 |
|
|
104 |
|
\begin{methoddesc}[Camera]{azimuth}{angle} |
105 |
|
Rotate the camera to the left and right. |
106 |
|
\end{methoddesc} |
107 |
|
|
108 |
|
\begin{methoddesc}[Camera]{elevation}{angle} |
109 |
|
Rotate the camera to the top and bottom. |
110 |
|
\end{methoddesc} |
111 |
|
|
112 |
|
\begin{methoddesc}[Camera]{roll}{angle} |
113 |
|
Roll the camera to the left and right. |
114 |
|
\end{methoddesc} |
115 |
|
|
116 |
|
\begin{methoddesc}[Camera]{backView}{} |
117 |
|
View the back of the rendered object. |
118 |
|
\end{methoddesc} |
119 |
|
|
120 |
|
\begin{methoddesc}[Camera]{topView}{} |
121 |
|
View the top of the rendered object. |
122 |
|
\end{methoddesc} |
123 |
|
|
124 |
|
\begin{methoddesc}[Camera]{bottomView}{} |
125 |
|
View the bottom of the rendered object. |
126 |
|
\end{methoddesc} |
127 |
|
|
128 |
|
\begin{methoddesc}[Camera]{leftView}{} |
129 |
|
View the left side of the rendered object. |
130 |
|
\end{methoddesc} |
131 |
|
|
132 |
|
\begin{methoddesc}[Camera]{rightView}{} |
133 |
|
View the right side of the rendered object. |
134 |
|
\end{methoddesc} |
135 |
|
|
136 |
|
The following is a sample code using the \Camera class. |
137 |
|
\fig{fig:camera.1} shows the corresponding output. |
138 |
|
\verbatiminput{../examples/drivercamera.py} |
139 |
|
|
140 |
|
\begin{figure}[ht] |
141 |
|
\begin{center} |
142 |
|
\includegraphics[width=30mm]{figures/Camera} |
143 |
|
\end{center} |
144 |
|
\caption{Camera manipulation} |
145 |
|
\label{fig:camera.1} |
146 |
|
\end{figure} |
147 |
|
|
148 |
|
\section{\Map class} |
149 |
|
\begin{classdesc}{Map}{scene, data_collector, lut = None} |
150 |
|
A \Map object shows a scalar field by color on the domain surface. |
151 |
|
\end{classdesc} |
152 |
|
|
153 |
|
The following is a sample code using the \Map class. |
154 |
|
\fig{fig:map.1} shows the corresponding output. |
155 |
|
\verbatiminput{../examples/drivermap.py} |
156 |
|
|
157 |
|
\begin{figure}[ht] |
158 |
|
\begin{center} |
159 |
|
\includegraphics[width=40mm]{figures/Map} |
160 |
|
\end{center} |
161 |
|
\caption{Surface map} |
162 |
|
\label{fig:map.1} |
163 |
|
\end{figure} |
164 |
|
|
165 |
|
\section{\MapOnPlane class} |
166 |
|
\begin{classdesc}{MapOnPlane}{scene, data_collector, transform, lut = None} |
167 |
|
A \MapOnPlane object show a scalar field by color on a given plane. |
168 |
|
\end{classdesc} |
169 |
|
|
170 |
|
The following is a sample code using the \MapOnPlane class. |
171 |
|
\fig{fig:maponplane.1} shows the corresponding output. |
172 |
|
\verbatiminput{../examples/drivermaponplane.py} |
173 |
|
|
174 |
|
\begin{figure}[ht] |
175 |
|
\begin{center} |
176 |
|
\includegraphics[width=40mm]{figures/MapOnPlane} |
177 |
|
\end{center} |
178 |
|
\caption{Surface map on a plane} |
179 |
|
\label{fig:maponplane.1} |
180 |
|
\end{figure} |
181 |
|
|
182 |
|
\section{\MapOnClip class} |
183 |
|
\begin{classdesc}{MapOnClip}{scene, data_collector, transform, lut = None} |
184 |
|
A \MapOnClip object show a scalar field by color on a given clip. |
185 |
|
\end{classdesc} |
186 |
|
|
187 |
|
The following is a sample code using the \MapOnClip class. |
188 |
|
\fig{fig:maponclip.1} shows the corresponding output. |
189 |
|
\verbatiminput{../examples/drivermaponclip.py} |
190 |
|
|
191 |
|
\begin{figure}[ht] |
192 |
|
\begin{center} |
193 |
|
\includegraphics[width=40mm]{figures/MapOnClip} |
194 |
|
\end{center} |
195 |
|
\caption{Surface map on a clip} |
196 |
|
\label{fig:maponclip.1} |
197 |
|
\end{figure} |
198 |
|
|
199 |
|
\section{\Arrows class} |
200 |
|
\begin{classdesc}{Arrows}{scene, data_collector, lut = None} |
201 |
|
A \Arrows object shows a vector field by arrows. |
202 |
|
\end{classdesc} |
203 |
|
|
204 |
|
The following are the methods available: |
205 |
|
\begin{methoddesc}[Arrows]{setVectorMode}{vector_mode} |
206 |
|
Set the arrows vector mode. |
207 |
|
\end{methoddesc} |
208 |
|
|
209 |
|
\begin{methoddesc}[Arrows]{setScaleMode}{scale_mode} |
210 |
|
Set the arrows scale mode. |
211 |
|
\end{methoddesc} |
212 |
|
|
213 |
|
\begin{methoddesc}[Arrows]{setScaleFactor}{scale_factor} |
214 |
|
Set the arrows scale factor. |
215 |
|
\end{methoddesc} |
216 |
|
|
217 |
|
\begin{methoddesc}[Arrows]{setColorMode}{color_mode} |
218 |
|
Set the arrows color mode. |
219 |
|
\end{methoddesc} |
220 |
|
|
221 |
|
The following is a sample code using the \Arrows class. |
222 |
|
\fig{fig:arrows.1} shows the corresponding output. |
223 |
|
\verbatiminput{../examples/driverarrows.py} |
224 |
|
|
225 |
|
\begin{figure}[ht] |
226 |
|
\begin{center} |
227 |
|
\includegraphics[width=40mm]{figures/Arrows} |
228 |
|
\end{center} |
229 |
|
\caption{Arrows} |
230 |
|
\label{fig:arrows.1} |
231 |
|
\end{figure} |
232 |
|
|
233 |
|
\section{\ArrowsOnPlane class} |
234 |
|
\begin{classdesc}{ArrowsOnPlane}{scene, data_collector, transform, lut = None} |
235 |
|
A \ArrowsOnPlane object shows a vector field by arrows on a given plane. |
236 |
|
\end{classdesc} |
237 |
|
|
238 |
|
The following is a sample code using the \ArrowsOnPlane class. |
239 |
|
\fig{fig:arrowsonplane.1} shows the corresponding output. |
240 |
|
\verbatiminput{../examples/driverarrowsonplane.py} |
241 |
|
|
242 |
|
\begin{figure}[ht] |
243 |
|
\begin{center} |
244 |
|
\includegraphics[width=40mm]{figures/ArrowsOnPlane} |
245 |
|
\end{center} |
246 |
|
\caption{Arrows on a plane} |
247 |
|
\label{fig:arrowsonplane.1} |
248 |
|
\end{figure} |
249 |
|
|
250 |
|
\section{\ArrowsOnClip class} |
251 |
|
\begin{classdesc}{ArrowsOnClip}{scene, data_collector, transform, lut = None} |
252 |
|
A \ArrowsOnClip object shows a vector field by arrows on a given clip. |
253 |
|
\end{classdesc} |
254 |
|
|
255 |
|
The following is a sample code using the \ArrowsOnClip class. |
256 |
|
\fig{fig:arrowsonclip.1} shows the corresponding output. |
257 |
|
\verbatiminput{../examples/driverarrowsonclip.py} |
258 |
|
|
259 |
|
\begin{figure}[ht] |
260 |
|
\begin{center} |
261 |
|
\includegraphics[width=40mm]{figures/ArrowsOnClip} |
262 |
|
\end{center} |
263 |
|
\caption{Arrows on a clip} |
264 |
|
\label{fig:arrowsonclip.1} |
265 |
|
\end{figure} |
266 |
|
|
267 |
|
|
268 |
|
\section{\IsoSurface class} |
269 |
|
\begin{classdesc}{IsoSurface}{scene, data_collector, lut = None} |
270 |
|
An \IsoSurface object shows a scalar field for a given value by an isosurface. |
271 |
|
\end{classdesc} |
272 |
|
|
273 |
|
The following is the method available: |
274 |
|
|
275 |
|
\begin{methoddesc}[IsoSurface]{setValue}{contour_number, value} |
276 |
|
Set the contour number and value. |
277 |
|
\end{methoddesc} |
278 |
|
|
279 |
|
The following is a sample code using the \IsoSurface class. |
280 |
|
\fig{fig:isosurface.1} shows the corresponding output. |
281 |
|
\verbatiminput{../examples/driverisosurface.py} |
282 |
|
|
283 |
|
\begin{figure}[ht] |
284 |
|
\begin{center} |
285 |
|
\includegraphics[width=40mm]{figures/IsoSurface} |
286 |
|
\end{center} |
287 |
|
\caption{IsoSurface} |
288 |
|
\label{fig:isosurface.1} |
289 |
|
\end{figure} |
290 |
|
|
291 |
|
\section{\IsoSurfaceOnPlane class} |
292 |
|
\begin{classdesc}{IsoSurfaceOnPlane}{scene, data_collector, transform, |
293 |
|
lut = None} |
294 |
|
An \IsoSurfaceOnPlane object shows a scalar field for a given value |
295 |
|
by an isosurface on a given plane. |
296 |
|
\end{classdesc} |
297 |
|
|
298 |
|
The following is a sample code using the \IsoSurfaceOnPlane class. |
299 |
|
\fig{fig:isosurfaceonplane.1} shows the corresponding output. |
300 |
|
\verbatiminput{../examples/driverisosurfaceonplane.py} |
301 |
|
|
302 |
|
\begin{figure}[ht] |
303 |
|
\begin{center} |
304 |
|
\includegraphics[width=40mm]{figures/IsoSurfaceOnPlane} |
305 |
|
\end{center} |
306 |
|
\caption{IsoSurface on a plane} |
307 |
|
\label{fig:isosurfaceonplane.1} |
308 |
|
\end{figure} |
309 |
|
|
310 |
|
\section{\IsoSurfaceOnClip class} |
311 |
|
\begin{classdesc}{IsoSurfaceOnClip}{scene, data_collector, transform, |
312 |
|
lut = None} |
313 |
|
An \IsoSurfaceOnClip object shows a scalar field for a given value |
314 |
|
by an isosurface on a given clip. |
315 |
|
\end{classdesc} |
316 |
|
|
317 |
|
The following is a sample code using the \IsoSurfaceOnClip class. |
318 |
|
\fig{fig:isosurfaceonclip.1} shows the corresponding output. |
319 |
|
\verbatiminput{../examples/driverisosurfaceonclip.py} |
320 |
|
|
321 |
|
\begin{figure}[ht] |
322 |
|
\begin{center} |
323 |
|
\includegraphics[width=40mm]{figures/IsoSurfaceOnClip} |
324 |
|
\end{center} |
325 |
|
\caption{IsoSurface on a clip} |
326 |
|
\label{fig:isosurfaceonclip.1} |
327 |
|
\end{figure} |
328 |
|
|
329 |
|
\section{\Contour class} |
330 |
|
\begin{classdesc}{Contour}{scene, data_collector, lut = None} |
331 |
|
A \Contour object shows a scalar field contour surfaces. |
332 |
|
\end{classdesc} |
333 |
|
|
334 |
|
The following is the method available: |
335 |
|
\begin{methoddesc}[Contour]{generateValues}{number_contours, min_range, |
336 |
|
max_range} |
337 |
|
Generate the specified number of contours within the specified range. |
338 |
|
\end{methoddesc} |
339 |
|
|
340 |
|
The following is a sample code using the \Contour class. |
341 |
|
\fig{fig:contour.1} shows the corresponding output. |
342 |
|
\verbatiminput{../examples/drivercontour.py} |
343 |
|
|
344 |
|
\begin{figure}[ht] |
345 |
|
\begin{center} |
346 |
|
\includegraphics[width=40mm]{figures/Contour} |
347 |
|
\end{center} |
348 |
|
\caption{Contour} |
349 |
|
\label{fig:contour.1} |
350 |
|
\end{figure} |
351 |
|
|
352 |
|
\section{\ContourOnPlane class} |
353 |
|
\begin{classdesc}{ContourOnPlane}{scene, data_collector, transform, lut = None} |
354 |
|
A \ContourOnPlane object shows a scalar field contour surfaces on a given plane. |
355 |
|
\end{classdesc} |
356 |
|
|
357 |
|
The following is a sample code using the \ContourOnPlane class. |
358 |
|
\fig{fig:contouronplane.1} shows the corresponding output. |
359 |
|
\verbatiminput{../examples/drivercontouronplane.py} |
360 |
|
|
361 |
|
\begin{figure}[ht] |
362 |
|
\begin{center} |
363 |
|
\includegraphics[width=40mm]{figures/ContourOnPlane} |
364 |
|
\end{center} |
365 |
|
\caption{Contour on a plane} |
366 |
|
\label{fig:contouronplane.1} |
367 |
|
\end{figure} |
368 |
|
|
369 |
|
\section{\ContourOnClip class} |
370 |
|
\begin{classdesc}{ContourOnClip}{scene, data_collector, transform, lut = None} |
371 |
|
A \ContourOnClip object shows a scalar field contour surfaces on a given clip. |
372 |
|
\end{classdesc} |
373 |
|
|
374 |
|
The following is a sample code using the \ContourOnClip class. |
375 |
|
\fig{fig:contouronclip.1} shows the corresponding output. |
376 |
|
\verbatiminput{../examples/drivercontouronclip.py} |
377 |
|
|
378 |
|
\begin{figure}[ht] |
379 |
|
\begin{center} |
380 |
|
\includegraphics[width=40mm]{figures/ContourOnClip} |
381 |
|
\end{center} |
382 |
|
\caption{Contour on a clip} |
383 |
|
\label{fig:contouronclip.1} |
384 |
|
\end{figure} |
385 |
|
|
386 |
|
\section{\TensorC class} |
387 |
|
\begin{classdesc}{Tensor}{scene, data_collector, lut = None} |
388 |
|
A \TensorC object shows a tensor field by ellipsoids. |
389 |
|
\end{classdesc} |
390 |
|
|
391 |
|
The following are the methods available: |
392 |
|
\begin{methoddesc}[Tensor]{setThetaResolution}{resolution} |
393 |
|
Set the number of points in the longitude direction. |
394 |
|
\end{methoddesc} |
395 |
|
|
396 |
|
\begin{methoddesc}[Tensor]{setPhiResolution}{resolution} |
397 |
|
Set the number of points in the latitude direction. |
398 |
|
\end{methoddesc} |
399 |
|
|
400 |
|
\begin{methoddesc}[Tensor]{setScaleFactor}{scale_factor} |
401 |
|
Set the tensor scale factor. |
402 |
|
\end{methoddesc} |
403 |
|
|
404 |
|
\begin{methoddesc}[Tensor]{setMaxScaleFactor}{max_scale_factor} |
405 |
|
Set the maximum allowable scale factor. |
406 |
|
\end{methoddesc} |
407 |
|
|
408 |
|
The following is a sample code using the \TensorC class. |
409 |
|
\fig{fig:tensor.1} shows the corresponding output. |
410 |
|
\verbatiminput{../examples/drivertensor.py} |
411 |
|
|
412 |
|
\begin{figure}[ht] |
413 |
|
\begin{center} |
414 |
|
\includegraphics[width=40mm]{figures/Tensor} |
415 |
|
\end{center} |
416 |
|
\caption{Tensor} |
417 |
|
\label{fig:tensor.1} |
418 |
|
\end{figure} |
419 |
|
|
420 |
|
\section{\TensorOnPlane class} |
421 |
|
\begin{classdesc}{TensorOnPlane}{scene, data_collector, transform, lut = None} |
422 |
|
A \TensorOnPlane object shows a tensor field by ellipsoids on a given plane. |
423 |
|
\end{classdesc} |
424 |
|
|
425 |
|
The following is a sample code using the \TensorOnPlane class. |
426 |
|
\fig{fig:tensoronplane.1} shows the corresponding output. |
427 |
|
\verbatiminput{../examples/drivertensoronplane.py} |
428 |
|
|
429 |
|
\begin{figure}[ht] |
430 |
|
\begin{center} |
431 |
|
\includegraphics[width=40mm]{figures/TensorOnPlane} |
432 |
|
\end{center} |
433 |
|
\caption{Tensor on a plane} |
434 |
|
\label{fig:tensoronplane.1} |
435 |
|
\end{figure} |
436 |
|
|
437 |
|
\section{\TensorOnClip class} |
438 |
|
\begin{classdesc}{TensorOnClip}{scene, data_collector, transform, lut = None} |
439 |
|
A \TensorOnClip object shows a tensor field by ellipsoids on a given clip. |
440 |
|
\end{classdesc} |
441 |
|
|
442 |
|
The following is a sample code using the \TensorOnClip class. |
443 |
|
\fig{fig:tensoronclip.1} shows the corresponding output. |
444 |
|
\verbatiminput{../examples/drivertensoronclip.py} |
445 |
|
|
446 |
|
\begin{figure}[ht] |
447 |
|
\begin{center} |
448 |
|
\includegraphics[width=40mm]{figures/TensorOnClip} |
449 |
|
\end{center} |
450 |
|
\caption{Tensor on a clip} |
451 |
|
\label{fig:tensoronclip.1} |
452 |
|
\end{figure} |
453 |
|
|
454 |
|
\section{\StreamLines class} |
455 |
|
\begin{classdesc}{StreamLines}{scene, data_collector, lut = None} |
456 |
|
A \StreamLines object show the path of particles (within a specified cloud |
457 |
|
of points) in a vector field. |
458 |
|
\end{classdesc} |
459 |
|
|
460 |
|
The following are the methods available: |
461 |
|
\begin{methoddesc}[StreamLines]{setCloudRadius}{radius} |
462 |
|
Set the radius for the cloud of points. |
463 |
|
\end{methoddesc} |
464 |
|
|
465 |
|
\begin{methoddesc}[StreamLines]{setCenter}{position} |
466 |
|
Set the center for the cloud of points. |
467 |
|
\end{methoddesc} |
468 |
|
|
469 |
|
\begin{methoddesc}[StreamLines]{setNumberOfPoints}{points} |
470 |
|
Set the number of points to generate for the cloud of points. |
471 |
|
\end{methoddesc} |
472 |
|
|
473 |
|
\begin{methoddesc}[StreamLines]{setMaximumPropagationTime}{time} |
474 |
|
Set the maximum length for the streamlines in unit of time. |
475 |
|
\end{methoddesc} |
476 |
|
|
477 |
|
\begin{methoddesc}[StreamLines]{setStreamLinesSize}{stream_lines_size} |
478 |
|
Set the size of the steamlines. |
479 |
|
\end{methoddesc} |
480 |
|
|
481 |
|
\begin{methoddesc}[StreamLines]{setAccuracy}{accuracy} |
482 |
|
Set the accuracy for the streamlines. |
483 |
|
\end{methoddesc} |
484 |
|
|
485 |
|
\begin{methoddesc}[StreamLines]{setIntegrationToBothDirections}{} |
486 |
|
Set the integration to occur in both directions. |
487 |
|
\end{methoddesc} |
488 |
|
|
489 |
|
\begin{methoddesc}[StreamLines]{setTubeRadius}{radius} |
490 |
|
Set the minimum radius of the tube. |
491 |
|
\end{methoddesc} |
492 |
|
|
493 |
|
\begin{methoddesc}[StreamLines]{setNumberOfSides}{sides} |
494 |
|
Set the number of sides for the tube. |
495 |
|
\end{methoddesc} |
496 |
|
|
497 |
|
\begin{methoddesc}[StreamLines]{setVaryRadiusByVector}{} |
498 |
|
Set the variation of the tube radius with vector data. |
499 |
|
\end{methoddesc} |
500 |
|
|
501 |
|
The following is a sample code using the \StreamLines class. |
502 |
|
\fig{fig:streamlines.1} shows the corresponding output. |
503 |
|
\verbatiminput{../examples/driverstreamlines.py} |
504 |
|
|
505 |
|
\begin{figure}[ht] |
506 |
|
\begin{center} |
507 |
|
\includegraphics[width=40mm]{figures/StreamLines} |
508 |
|
\end{center} |
509 |
|
\caption{StreamLines} |
510 |
|
\label{fig:streamlines.1} |
511 |
|
\end{figure} |
512 |
|
|
513 |
|
\section{\Carpet class} |
514 |
|
\begin{classdesc}{Carpet}{scene, data_collector, transform, lut = None, |
515 |
|
deform = None} |
516 |
|
A \Carpet object shows a scalar field as a plane deformated along the plane |
517 |
|
normal. |
518 |
|
\end{classdesc} |
519 |
|
|
520 |
|
The following is the method available: |
521 |
|
\begin{methoddesc}[Carpet]{setScaleFactor}{scale_factor} |
522 |
|
Set the displancement scale factor. |
523 |
|
\end{methoddesc} |
524 |
|
|
525 |
|
The following is a sample code using the \Carpet class. |
526 |
|
\fig{fig:carpet.1} shows the corresponding output. |
527 |
|
\verbatiminput{../examples/drivercarpet.py} |
528 |
|
|
529 |
|
\begin{figure}[ht] |
530 |
|
\begin{center} |
531 |
|
\includegraphics[width=40mm]{figures/Carpet} |
532 |
|
\end{center} |
533 |
|
\caption{Carpet} |
534 |
|
\label{fig:carpet.1} |
535 |
|
\end{figure} |
536 |
|
|
537 |
|
\section{\Image class} |
538 |
|
\begin{classdesc}{Image}{scene, format} |
539 |
|
An \Image object shows an image. |
540 |
|
\end{classdesc} |
541 |
|
|
542 |
|
The following is the method available: |
543 |
|
\begin{methoddesc}[Image]{setFileName}{file_name} |
544 |
|
Set the file name. |
545 |
|
\end{methoddesc} |
546 |
|
|
547 |
|
The following is a sample code using the \Image class. |
548 |
|
\fig{fig:image.1} shows the corresponding output. |
549 |
|
\verbatiminput{../examples/driverimage.py} |
550 |
|
|
551 |
|
\begin{figure}[ht] |
552 |
|
\begin{center} |
553 |
|
\includegraphics[width=40mm]{figures/Image} |
554 |
|
\end{center} |
555 |
|
\caption{Image} |
556 |
|
\label{fig:image.1} |
557 |
|
\end{figure} |
558 |
|
|
559 |
|
\section{\Text class} |
560 |
|
\begin{classdesc}{Text}{scene} |
561 |
|
A \Text object shows 2D text. |
562 |
|
\end{classdesc} |
563 |
|
|
564 |
|
The following are the methods available: |
565 |
|
\begin{methoddesc}[Text]{setText}{text} |
566 |
|
Set the text. |
567 |
|
\end{methoddesc} |
568 |
|
|
569 |
|
\begin{methoddesc}[Text]{setPosition}{x_coor, y_coor} |
570 |
|
Set the display position of the text. |
571 |
|
\end{methoddesc} |
572 |
|
|
573 |
|
\begin{methoddesc}[Text]{setStyle}{style} |
574 |
|
Set the style of the text. |
575 |
|
\end{methoddesc} |
576 |
|
|
577 |
|
The following is a sample code using the \Text class. |
578 |
|
\fig{fig:text.1} shows the corresponding output. |
579 |
|
\verbatiminput{../examples/drivertext.py} |
580 |
|
|
581 |
|
\begin{figure}[ht] |
582 |
|
\begin{center} |
583 |
|
\includegraphics[width=40mm]{figures/Text} |
584 |
|
\end{center} |
585 |
|
\caption{2D text} |
586 |
|
\label{fig:text.1} |
587 |
|
\end{figure} |
588 |
|
|
589 |
|
\section{\Position class} |
590 |
|
\begin{classdesc}{Position}{x_coor, y_coor, z_coor} |
591 |
|
A \Position object defines the x, y and z coordinates of rendered object. |
592 |
|
\end{classdesc} |
593 |
|
|
594 |
|
\section{\Transform class} |
595 |
|
\begin{classdesc}{Transform}{} |
596 |
|
A \Transform object defines the orientation of rendered object. |
597 |
|
\end{classdesc} |
598 |
|
|
599 |
|
The following are some of the methods available: |
600 |
|
\begin{methoddesc}[Transform]{translate}{x_offset, y_offset, z_offset} |
601 |
|
Translate the rendered object along the x, y and z-axes. |
602 |
|
\end{methoddesc} |
603 |
|
|
604 |
|
\begin{methoddesc}[Transform]{rotateX}{angle} |
605 |
|
Rotate the rendered object along the x-axis. |
606 |
|
\end{methoddesc} |
607 |
|
|
608 |
|
\begin{methoddesc}[Transform]{rotateY}{angle} |
609 |
|
Rotate the rendered object along the y-axis. |
610 |
|
\end{methoddesc} |
611 |
|
|
612 |
|
\begin{methoddesc}[Transform]{rotateZ}{angle} |
613 |
|
Rotate the rendered object along the z-axis. |
614 |
|
\end{methoddesc} |
615 |
|
|
616 |
|
\begin{methoddesc}[Transform]{xyPlane}{offset = 0} |
617 |
|
Set the plane orthogonal to the z-axis. |
618 |
|
\end{methoddesc} |
619 |
|
|
620 |
|
\begin{methoddesc}[Transform]{yzPlane}{offset = 0} |
621 |
|
Set the plane orthogonal to the x-axis. |
622 |
|
\end{methoddesc} |
623 |
|
|
624 |
|
\begin{methoddesc}[Transform]{xzPlane}{offset = 0} |
625 |
|
Set the plane orthogonal to the y-axis. |
626 |
|
\end{methoddesc} |
627 |
|
|
628 |
|
\section{\Style class} |
629 |
|
\begin{classdesc}{Style}{} |
630 |
|
A \Style object defines the style of text. |
631 |
|
\end{classdesc} |
632 |
|
|
633 |
|
The following are the methods available: |
634 |
|
\begin{methoddesc}[Style]{setFontFamily}{family} |
635 |
|
Set the font family (i.e. Times) |
636 |
|
\end{methoddesc} |
637 |
|
|
638 |
|
\begin{methoddesc}[Style]{boldOn}{} |
639 |
|
Bold the text. |
640 |
|
\end{methoddesc} |
641 |
|
|
642 |
|
\begin{methoddesc}[Style]{italicOn}{} |
643 |
|
Italize the text. |
644 |
|
\end{methoddesc} |
645 |
|
|
646 |
|
\begin{methoddesc}[Style]{shadowOn}{} |
647 |
|
Apply shadows on the text. |
648 |
|
\end{methoddesc} |
649 |
|
|
650 |
|
\begin{methoddesc}[Style]{setColor}{} |
651 |
|
Set the text color. |
652 |
|
\end{methoddesc} |
653 |
|
|
654 |
|
\section{\BlueToRed class} |
655 |
|
\begin{classdesc}{BlueToRed}{} |
656 |
|
A \BlueToRed object defines a map spectrum from blue to red. |
657 |
|
\end{classdesc} |
658 |
|
|
659 |
|
\section{\RedToBlue class} |
660 |
|
\begin{classdesc}{RedToBlue}{} |
661 |
|
A \RedToBlue object defines a map spectrum from red to blue. |
662 |
|
\end{classdesc} |
663 |
|
|
|
The idea behind is to provide an easy to use interface and unified to a variety of |
|
|
visualization tools like \VTK, \OpenDX and \GnuPlot. |
|
664 |
|
|
|
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} |
|