1 |
\chapter{The module \pyvisi} |
2 |
|
3 |
\declaremodule{extension}{pyvisi} |
4 |
\modulesynopsis{visualization interface} |
5 |
|
6 |
The idea behind is to provide an easy to use interface and unified to a variety of |
7 |
visualization tools like \VTK, \OpenDX and \GnuPlot. |
8 |
|
9 |
The following script illustartes the usage of \pyvisi together with the |
10 |
\VTK library: |
11 |
\begin{python} |
12 |
from esys.pyvisi import * # base level visualisation stuff |
13 |
from esys.pyvisi.renderers.vtk import * # vtk renderer module |
14 |
from esys.escript import * |
15 |
from esys.finley import Brick |
16 |
# now make some data of some kind |
17 |
domain = Brick(3,5,7) # a Finley domain |
18 |
vectorData = domain.getX() # get vector data from the domain nodes |
19 |
# define the scene object |
20 |
scene = Scene() |
21 |
# create an ArrowPlot object |
22 |
plot = ArrowPlot(scene) |
23 |
# add the plot to the scene |
24 |
scene.add(plot) |
25 |
# assign some data to the plot |
26 |
plot.setData(vectorData) |
27 |
# render the scene |
28 |
scene.render() |
29 |
# saving a scene |
30 |
scene.save(file="example.jpg", format="jpeg") |
31 |
\begin{python} |
32 |
A \Scene is a container for all of the kinds of things you want to put into your plot, |
33 |
for instance, images, domaines, arrow plots, contour plots, spheres etc. |
34 |
The renderer is specified in the scene initialisation. In fact the |
35 |
\code{from esys.pyvisi.renderers.vtk import *} provides the specific implementation for |
36 |
\VTK |
37 |
|
38 |
|
39 |
\begin{verbose} |
40 |
class ArrowPlot3D(Plot): |
41 |
""" |
42 |
Arrow field plot in three dimensions |
43 |
""" |
44 |
def __init__(self, scene): |
45 |
""" |
46 |
Initialisation of the ArrowPlot3D class |
47 |
|
48 |
@param scene: The Scene to render the plot in |
49 |
@type scene: Scene object |
50 |
def setData(self, *dataList, **options): |
51 |
""" |
52 |
Set data to the plot |
53 |
|
54 |
@param dataList: List of data to set to the plot |
55 |
@type dataList: tuple |
56 |
|
57 |
@param options: Dictionary of extra options |
58 |
@type options: dict |
59 |
|
60 |
@param fname: Filename of the input vtk file |
61 |
@type fname: string |
62 |
|
63 |
@param format: Format of the input vtk file ('vtk' or 'vtk-xml') |
64 |
@type format: string |
65 |
|
66 |
@param vectors: the name of the vector data in the vtk file to use |
67 |
@type vectors: string |
68 |
""" |
69 |
class ArrowPlot(Plot): |
70 |
""" |
71 |
Arrow field plot |
72 |
""" |
73 |
def __init__(self, scene): |
74 |
""" |
75 |
Initialisation of the ArrowPlot class |
76 |
|
77 |
@param scene: The Scene to render the plot in |
78 |
@type scene: Scene object |
79 |
""" |
80 |
def setData(self, *dataList, **options): |
81 |
""" |
82 |
Set data to the plot |
83 |
|
84 |
@param dataList: List of data to set to the plot |
85 |
@type dataList: tuple |
86 |
|
87 |
@param options: Dictionary of extra options |
88 |
@type options: dict |
89 |
|
90 |
@param fname: the name of the input vtk file |
91 |
@type fname: string |
92 |
|
93 |
@param format: the format of the input vtk file ('vtk' or 'vtk-xml') |
94 |
@type format: string |
95 |
|
96 |
@param vectors: the name of the vector data in the vtk file to use |
97 |
@type vectors: string |
98 |
""" |
99 |
class Axes(Plot): |
100 |
""" |
101 |
Axes class |
102 |
""" |
103 |
def __init__(self): |
104 |
""" |
105 |
Initialisation of Axes object |
106 |
""" |
107 |
debugMsg("Called Axes.__init__()") |
108 |
Plot.__init__(self) |
109 |
|
110 |
class BallPlot(Plot): |
111 |
""" |
112 |
Ball plot |
113 |
""" |
114 |
def __init__(self, scene): |
115 |
|
116 |
def setData(self, points=None, |
117 |
fname=None, format=None, |
118 |
radii=None, colors=None, tags=None): |
119 |
""" |
120 |
Set data to the plot |
121 |
@param points: the array to use for the points of the sphere |
122 |
locations in space |
123 |
@type points: float array |
124 |
|
125 |
@param fname: the name of the input vtk file |
126 |
@type fname: string |
127 |
|
128 |
@param format: the format of the input vtk file ('vtk' or 'vtk-xml') |
129 |
@type format: string |
130 |
|
131 |
@param radii: the name of the scalar array in the vtk unstructured |
132 |
grid to use as the radii of the balls |
133 |
@type radii: float array |
134 |
|
135 |
@param colors: the name of the scalar array in the vtk unstructured |
136 |
grid to use as the colour tags of the balls |
137 |
@type colors: string |
138 |
|
139 |
@param tags: the name of the scalar array in the vtk unstructured |
140 |
grid to use as the colour of the tags of the balls |
141 |
@type tags: integer array |
142 |
""" |
143 |
|
144 |
class Box(Item): |
145 |
""" |
146 |
Generic class for Box objects |
147 |
|
148 |
To define a box one specify one of three groups of things: |
149 |
- The bounds of the box: xmin, xmax, ymin, ymax, zmin, zmax |
150 |
- The dimensions and origin: width, height, depth and origin |
151 |
- The bottom left front and top right back corners: blf, trb |
152 |
""" |
153 |
|
154 |
def __init__(self): |
155 |
""" |
156 |
Initialisation of the Box object |
157 |
""" |
158 |
debugMsg("Called Box.__init__()") |
159 |
Item.__init__(self) |
160 |
|
161 |
# define a box in many ways, either by its centre and width, height |
162 |
# and depth, or by its bounds, xmin, xmax, ymin, ymax, zmin, zmax, |
163 |
# or by its bottom left front and top right back points. |
164 |
|
165 |
# set the default bounds |
166 |
self.xmin = -0.5 |
167 |
self.xmax = 0.5 |
168 |
self.ymin = -0.5 |
169 |
self.ymax = 0.5 |
170 |
self.zmin = -0.5 |
171 |
self.zmax = 0.5 |
172 |
|
173 |
# set the default origin (the centre of the box) |
174 |
self.origin = ((self.xmin + self.xmax)/2.0, |
175 |
(self.ymin + self.ymax)/2.0, |
176 |
(self.zmin + self.zmax)/2.0) |
177 |
|
178 |
# set the default dimensions |
179 |
self.width = self.xmax - self.xmin |
180 |
self.height = self.ymax - self.ymin |
181 |
self.depth = self.zmax - self.zmin |
182 |
|
183 |
# set the default blf and trb points |
184 |
self.blf = (self.xmin, self.ymin, self.zmin) |
185 |
self.trb = (self.xmax, self.ymax, self.zmax) |
186 |
|
187 |
# tolerance for calculated variables checking purposes |
188 |
self.tolerance = 1e-8 |
189 |
|
190 |
def setBounds(self, xmin, xmax, ymin, ymax, zmin, zmax): |
191 |
""" |
192 |
Set the bounds of the box |
193 |
""" |
194 |
def getBounds(self): |
195 |
""" |
196 |
Get the current bounds of the box |
197 |
""" |
198 |
|
199 |
def setOrigin(self, xo, yo, zo): |
200 |
""" |
201 |
Set the origin of the box |
202 |
""" |
203 |
def getOrigin(self): |
204 |
""" |
205 |
Get the current origin of the box |
206 |
""" |
207 |
debugMsg("Called Box.getOrigin()") |
208 |
return self.origin |
209 |
|
210 |
def setWidth(self, width): |
211 |
""" |
212 |
Set the width of the box |
213 |
""" |
214 |
def getWidth(self): |
215 |
""" |
216 |
Get the current box width |
217 |
""" |
218 |
debugMsg("Called Box.getWidth()") |
219 |
return self.width |
220 |
|
221 |
def setHeight(self, height): |
222 |
""" |
223 |
Set the box height |
224 |
""" |
225 |
|
226 |
def getHeight(self): |
227 |
""" |
228 |
Get the current box height |
229 |
""" |
230 |
debugMsg("Called Box.getHeight()") |
231 |
return self.height |
232 |
|
233 |
def setDepth(self, depth): |
234 |
""" |
235 |
Set the box depth |
236 |
""" |
237 |
|
238 |
def getDepth(self): |
239 |
""" |
240 |
Get the current box depth |
241 |
""" |
242 |
debugMsg("Called Box.getDepth()") |
243 |
return self.depth |
244 |
|
245 |
def setBLF(self, bottom, left, front): |
246 |
""" |
247 |
Set the position of the bottom, left, front corner |
248 |
""" |
249 |
|
250 |
def getBLF(self): |
251 |
""" |
252 |
Get the current position of the bottom, left, front corner |
253 |
""" |
254 |
debugMsg("Called Box.getBLF()") |
255 |
return self.blf |
256 |
|
257 |
def setTRB(self, top, right, back): |
258 |
""" |
259 |
Set the position of the top, right, back corner |
260 |
""" |
261 |
|
262 |
def getTRB(self): |
263 |
""" |
264 |
Get the current position of the top, right, back corner |
265 |
""" |
266 |
debugMsg("Called Box.getTRB()") |
267 |
return self.trb |
268 |
|
269 |
|
270 |
class ClipBox(Box): |
271 |
""" |
272 |
Clip box class: used to clip data sets with a box |
273 |
|
274 |
A box in this sense means three planes at right angles to one another |
275 |
""" |
276 |
|
277 |
def __init__(self, plot): |
278 |
""" |
279 |
Intialisation of the ClipBox object |
280 |
""" |
281 |
|
282 |
def setInsideOut(self, insideOut): |
283 |
""" |
284 |
Set the inside out flag |
285 |
""" |
286 |
|
287 |
def getInsideOut(self): |
288 |
""" |
289 |
Get the current value of the inside out flag |
290 |
""" |
291 |
|
292 |
class Camera(Item): |
293 |
""" |
294 |
Camera class |
295 |
""" |
296 |
def __init__(self, scene): |
297 |
""" |
298 |
Initialisation of the Camera object |
299 |
|
300 |
@param scene: The Scene object to add the Camera object to |
301 |
@type scene: Scene object |
302 |
""" |
303 |
def setPosition(self, *pos): |
304 |
""" |
305 |
Set position of camera within scene |
306 |
|
307 |
@param pos: Position to set camera in terms of x,y,z coordinates |
308 |
@type pos: tuple |
309 |
""" |
310 |
|
311 |
def getPosition(self): |
312 |
""" |
313 |
Get the position of Camera within Scene |
314 |
|
315 |
Returns the position in a tuple of form (xPos, yPos, zPos) |
316 |
""" |
317 |
debugMsg("Called Camera.getPosition()") |
318 |
|
319 |
return (self.xPos, self.yPos, self.zPos) |
320 |
|
321 |
def setFocalPoint(self, *pos): |
322 |
""" |
323 |
Sets the focal point of the Camera with the Scene |
324 |
|
325 |
@param pos: Position to set the focal point |
326 |
@type pos: tuple |
327 |
""" |
328 |
|
329 |
def getFocalPoint(self): |
330 |
""" |
331 |
Get the position of the focal point of the Camera |
332 |
|
333 |
Returns the position of the focal point in a tuple of form |
334 |
(xPos, yPos, zPos) |
335 |
""" |
336 |
|
337 |
def setElevation(self, elevation): |
338 |
""" |
339 |
Set the elevation angle (in degrees) of the Camera |
340 |
|
341 |
@param elevation: The elevation angle (in degrees) of the Camera |
342 |
@type elevation: float |
343 |
""" |
344 |
|
345 |
return |
346 |
|
347 |
def getElevation(self): |
348 |
""" |
349 |
Gets the elevation angle (in degrees) of the Camera |
350 |
""" |
351 |
|
352 |
def setAzimuth(self, azimuth): |
353 |
""" |
354 |
Set the azimuthal angle (in degrees) of the Camera |
355 |
|
356 |
@param azimuth: The azimuthal angle (in degrees) of the Camera |
357 |
@type azimuth: float |
358 |
""" |
359 |
|
360 |
def getAzimuth(self): |
361 |
""" |
362 |
Get the azimuthal angle (in degrees) of the Camera |
363 |
""" |
364 |
class ContourPlot(Plot): |
365 |
""" |
366 |
Contour plot |
367 |
""" |
368 |
def __init__(self, scene): |
369 |
""" |
370 |
Initialisation of the ContourPlot class |
371 |
|
372 |
@param scene: The Scene to render the plot in |
373 |
@type scene: Scene object |
374 |
""" |
375 |
def setData(self, *dataList, **options): |
376 |
""" |
377 |
Set data to the plot |
378 |
|
379 |
@param dataList: List of data to set to the plot |
380 |
@type dataList: tuple |
381 |
|
382 |
@param options: Dictionary of extra options |
383 |
@type options: dict |
384 |
|
385 |
@param fname: the name of the input vtk file |
386 |
@type fname: string |
387 |
|
388 |
@param format: the format of the input vtk file ('vtk' or 'vtk-xml') |
389 |
@type format: string |
390 |
|
391 |
@param scalars: the scalar data in the vtk file to use |
392 |
@type scalars: string |
393 |
""" |
394 |
|
395 |
class EllipsoidPlot(Plot): |
396 |
""" |
397 |
Ellipsoid plot |
398 |
""" |
399 |
def __init__(self, scene): |
400 |
""" |
401 |
Initialisation of the EllipsoidPlot class |
402 |
|
403 |
@param scene: The Scene to render the plot in |
404 |
@type scene: Scene object |
405 |
""" |
406 |
debugMsg("Called EllipsoidPlot.__init__()") |
407 |
Plot.__init__(self, scene) |
408 |
|
409 |
self.renderer = scene.renderer |
410 |
self.renderer.addToInitStack("# EllipsoidPlot.__init__()") |
411 |
|
412 |
# labels and stuff |
413 |
self.title = None |
414 |
self.xlabel = None |
415 |
self.ylabel = None |
416 |
self.zlabel = None |
417 |
|
418 |
# default values for fname, format and tensors |
419 |
self.fname = None |
420 |
self.format = None |
421 |
self.tensors = None |
422 |
|
423 |
# default values for shared info |
424 |
self.escriptData = False |
425 |
self.otherData = False |
426 |
|
427 |
# add the plot to the scene |
428 |
scene.add(self) |
429 |
|
430 |
def setData(self, *dataList, **options): |
431 |
""" |
432 |
Set data to the plot |
433 |
|
434 |
@param dataList: List of data to set to the plot |
435 |
@type dataList: tuple |
436 |
|
437 |
@param options: Dictionary of keyword options to the method |
438 |
@type options: dict |
439 |
|
440 |
@param fname: the name of the input vtk file |
441 |
@type fname: string |
442 |
|
443 |
@param format: the format of the input vtk file ('vtk' or 'vtk-xml') |
444 |
@type format: string |
445 |
|
446 |
@param tensors: the name of the tensor data in the vtk file to use |
447 |
@type tensors: string |
448 |
""" |
449 |
|
450 |
class Image(Item): |
451 |
""" |
452 |
Image class. Generic class to handle image data. |
453 |
""" |
454 |
def __init__(self, scene=None): |
455 |
""" |
456 |
Initialises the Image class object |
457 |
|
458 |
@param scene: The Scene object to add to |
459 |
@type scene: Scene object |
460 |
""" |
461 |
debugMsg("Called Image.__init__()") |
462 |
Item.__init__(self) |
463 |
|
464 |
if scene is not None: |
465 |
self.renderer = scene.renderer |
466 |
|
467 |
def load(self, fname): |
468 |
""" |
469 |
Loads image data from file. |
470 |
|
471 |
@param fname: The filename from which to load image data |
472 |
@type fname: string |
473 |
""" |
474 |
debugMsg("Called Image.load()") |
475 |
|
476 |
fileCheck(fname) |
477 |
|
478 |
return |
479 |
|
480 |
class JpegImage(Image): |
481 |
""" |
482 |
Subclass of Image class to explicitly handle jpeg images |
483 |
""" |
484 |
def __init__(self, scene=None): |
485 |
""" |
486 |
Initialises the JpegImage class object |
487 |
|
488 |
@param scene: The Scene object to add to |
489 |
@type scene: Scene object |
490 |
""" |
491 |
|
492 |
def load(self, fname): |
493 |
""" |
494 |
Loads jpeg image data from file. |
495 |
|
496 |
@param fname: The filename from which to load jpeg image data |
497 |
@type fname: string |
498 |
""" |
499 |
|
500 |
class PngImage(Image): |
501 |
""" |
502 |
Subclass of Image class to explicitly handle png images |
503 |
""" |
504 |
def __init__(self, scene=None): |
505 |
""" |
506 |
Initialises the PngImage class object |
507 |
|
508 |
@param scene: The Scene object to add to |
509 |
@type scene: Scene object |
510 |
""" |
511 |
|
512 |
def load(self, fname): |
513 |
""" |
514 |
Loads png image data from file. |
515 |
|
516 |
@param fname: The filename from which to load png image data |
517 |
@type fname: string |
518 |
""" |
519 |
class BmpImage(Image): |
520 |
""" |
521 |
Subclass of Image class to explicitly handle bmp images |
522 |
""" |
523 |
def __init__(self, scene=None): |
524 |
""" |
525 |
Initialises the BmpImage class object |
526 |
|
527 |
@param scene: The Scene object to add to |
528 |
@type scene: Scene object |
529 |
""" |
530 |
def load(self, fname): |
531 |
""" |
532 |
Loads bmp image data from file. |
533 |
|
534 |
@param fname: The filename from which to load bmp image data |
535 |
@type fname: string |
536 |
""" |
537 |
|
538 |
class TiffImage(Image): |
539 |
""" |
540 |
Subclass of Image class to explicitly handle tiff images |
541 |
""" |
542 |
def __init__(self, scene=None): |
543 |
""" |
544 |
Initialises the TiffImage class object |
545 |
|
546 |
@param scene: The Scene object to add to |
547 |
@type scene: Scene object |
548 |
""" |
549 |
def load(self, fname): |
550 |
""" |
551 |
Loads tiff image data from file. |
552 |
|
553 |
@param fname: The filename from which to load tiff image data |
554 |
@type fname: string |
555 |
""" |
556 |
class PnmImage(Image): |
557 |
""" |
558 |
Subclass of Image class to explicitly handle pnm (ppm, pgm, pbm) images |
559 |
""" |
560 |
def __init__(self, scene=None): |
561 |
""" |
562 |
Initialises the PnmImage class object |
563 |
|
564 |
@param scene: The Scene object to add to |
565 |
@type scene: Scene object |
566 |
""" |
567 |
|
568 |
def load(self, fname): |
569 |
""" |
570 |
Loads pnm (ppm, pgm, pbm) image data from file. |
571 |
|
572 |
@param fname: The filename from which to load pnm image data |
573 |
@type fname: string |
574 |
""" |
575 |
|
576 |
class PsImage(Image): |
577 |
""" |
578 |
Subclass of Image class to explicitly handle ps images |
579 |
""" |
580 |
def __init__(self, scene=None): |
581 |
""" |
582 |
Initialises the PsImage class object |
583 |
|
584 |
This object is B{only} used for generating postscript output |
585 |
|
586 |
@param scene: The Scene object to add to |
587 |
@type scene: Scene object |
588 |
""" |
589 |
|
590 |
def load(self, fname): |
591 |
""" |
592 |
Loads ps image data from file. |
593 |
|
594 |
B{NOT} supported by this renderer module |
595 |
|
596 |
@param fname: The filename from which to load ps image data |
597 |
@type fname: string |
598 |
""" |
599 |
debugMsg("Called PsImage.load()") |
600 |
|
601 |
# need to check if the file exists |
602 |
fileCheck(fname) |
603 |
|
604 |
# this ability not handled by this renderer module |
605 |
unsupportedError() |
606 |
|
607 |
return |
608 |
|
609 |
def render(self): |
610 |
""" |
611 |
Does PsImage object specific (pre)rendering stuff |
612 |
""" |
613 |
debugMsg("Called PsImage.render()") |
614 |
|
615 |
return |
616 |
|
617 |
class PdfImage(Image): |
618 |
""" |
619 |
Subclass of Image class to explicitly handle pdf images |
620 |
""" |
621 |
def __init__(self, scene=None): |
622 |
""" |
623 |
Initialises the PdfImage class object |
624 |
|
625 |
This object is B{only} used for generating pdf output |
626 |
|
627 |
@param scene: The Scene object to add to |
628 |
@type scene: Scene object |
629 |
""" |
630 |
|
631 |
def load(self, fname): |
632 |
""" |
633 |
Loads pdf image data from file. |
634 |
|
635 |
B{NOT} supported by this renderer module |
636 |
|
637 |
@param fname: The filename from which to load pdf image data |
638 |
@type fname: string |
639 |
""" |
640 |
|
641 |
class IsosurfacePlot(Plot): |
642 |
""" |
643 |
Isosurface plot |
644 |
""" |
645 |
def __init__(self, scene): |
646 |
""" |
647 |
Initialisation of the IsosurfacePlot class |
648 |
|
649 |
@param scene: The Scene to render the plot in |
650 |
@type scene: Scene object |
651 |
""" |
652 |
def setData(self, *dataList, **options): |
653 |
""" |
654 |
Set data to the plot |
655 |
|
656 |
@param dataList: List of data to set to the plot |
657 |
@type dataList: tuple |
658 |
|
659 |
@param options: Dictionary of keyword options to the method |
660 |
@type options: dict |
661 |
|
662 |
@param fname: the name of the input vtk file |
663 |
@type fname: string |
664 |
|
665 |
@param format: the format of the input vtk file ('vtk' or 'vtk-xml') |
666 |
@type format: string |
667 |
|
668 |
@param scalars: the name of the scalar data in the vtk file to use |
669 |
@type scalars: string |
670 |
""" |
671 |
|
672 |
class LinePlot(Plot): |
673 |
""" |
674 |
Line plot |
675 |
""" |
676 |
def __init__(self, scene): |
677 |
""" |
678 |
Initialisation of the LinePlot class |
679 |
|
680 |
@param scene: The Scene to render the plot in |
681 |
@type scene: Scene object |
682 |
""" |
683 |
|
684 |
def setData(self, *dataList, **options): |
685 |
""" |
686 |
Set data to the plot |
687 |
|
688 |
@param dataList: List of data to set to the plot |
689 |
@type dataList: tuple |
690 |
|
691 |
@param options: Dictionary of extra options |
692 |
@type options: dict |
693 |
|
694 |
@param offset: whether or not to offset the lines from one another |
695 |
@type offset: boolean |
696 |
|
697 |
@param fname: Filename of the input vtk file |
698 |
@type fname: string |
699 |
|
700 |
@param format: format of the input vtk file ('vtk' or 'vtk-xml') |
701 |
@type format: string |
702 |
|
703 |
@param scalars: the name of the scalar data in the vtk file to use |
704 |
@type scalars: string |
705 |
""" |
706 |
|
707 |
class OffsetPlot(Plot): |
708 |
""" |
709 |
Offset plot |
710 |
""" |
711 |
def __init__(self, scene): |
712 |
""" |
713 |
Initialisation of the OffsetPlot class |
714 |
|
715 |
@param scene: The Scene to render the plot in |
716 |
@type scene: Scene object |
717 |
""" |
718 |
|
719 |
def setData(self, *dataList, **options): |
720 |
""" |
721 |
Set data to the plot |
722 |
|
723 |
@param dataList: List of data to set to the plot |
724 |
@type dataList: tuple |
725 |
|
726 |
@param options: Dictionary of extra options |
727 |
@type options: dict |
728 |
|
729 |
@param fname: Filename of the input vtk file |
730 |
@type fname: string |
731 |
|
732 |
@param format: Format of the input vtk file ('vtk' or 'vtk-xml') |
733 |
@type format: string |
734 |
|
735 |
@param scalars: the name of the scalar data in the vtk file to use |
736 |
@type scalars: string |
737 |
""" |
738 |
class Plane(Item): |
739 |
""" |
740 |
Generic class for Plane objects |
741 |
""" |
742 |
|
743 |
def __init__(self, scene): |
744 |
""" |
745 |
Initialisation of the Plane object |
746 |
""" |
747 |
|
748 |
def setOrigin(self, x, y, z): |
749 |
""" |
750 |
Set the origin of the plane |
751 |
""" |
752 |
|
753 |
def getOrigin(self): |
754 |
""" |
755 |
Get the current origin of the plane |
756 |
""" |
757 |
|
758 |
def setNormal(self, vx, vy, vz): |
759 |
""" |
760 |
Set the normal vector to the plane |
761 |
""" |
762 |
|
763 |
def getNormal(self): |
764 |
""" |
765 |
Get the current normal vector to the plane |
766 |
""" |
767 |
|
768 |
def mapImageToPlane(self, image): |
769 |
# this really needs to go somewhere else!!! |
770 |
""" |
771 |
Maps an Image object onto a Plane object |
772 |
""" |
773 |
|
774 |
class CutPlane(Plane): |
775 |
""" |
776 |
Cut plane class: used to cut data sets with a plane |
777 |
|
778 |
Cut plane objects define a plane to cut a data set or plot by and return |
779 |
the data along the intersection between the data set or plot with the |
780 |
defined plane. |
781 |
""" |
782 |
|
783 |
def __init__(self): |
784 |
""" |
785 |
Intialisation of the CutPlane object |
786 |
""" |
787 |
|
788 |
|
789 |
class ClipPlane(Plane): |
790 |
""" |
791 |
Class for planes used to clip datasets |
792 |
""" |
793 |
|
794 |
def __init__(self): |
795 |
""" |
796 |
Intialisation of the ClipPlane object |
797 |
""" |
798 |
|
799 |
def setInsideOut(self, insideOut): |
800 |
""" |
801 |
Set the inside out flag |
802 |
""" |
803 |
|
804 |
def getInsideOut(self): |
805 |
""" |
806 |
Get the current value of the inside out flag |
807 |
""" |
808 |
|
809 |
class Plot(Item): |
810 |
""" |
811 |
Abstract plot class |
812 |
""" |
813 |
def __init__(self, scene): |
814 |
""" |
815 |
Initialisation of the abstract Plot class |
816 |
|
817 |
@param scene: The Scene to render the plot in |
818 |
@type scene: Scene object |
819 |
""" |
820 |
|
821 |
def setData(self, *dataList, **options): |
822 |
""" |
823 |
Set data to the plot |
824 |
|
825 |
@param dataList: List of data to set to the plot |
826 |
@type dataList: tuple |
827 |
|
828 |
@param options: Dictionary of extra options |
829 |
@type options: dict |
830 |
""" |
831 |
|
832 |
def setTitle(self, title): |
833 |
""" |
834 |
Set the plot title |
835 |
|
836 |
@param title: the string holding the title to the plot |
837 |
@type title: string |
838 |
""" |
839 |
debugMsg("Called setTitle() in Plot()") |
840 |
|
841 |
|
842 |
def setXLabel(self, label): |
843 |
""" |
844 |
Set the label of the x-axis |
845 |
|
846 |
@param label: the string holding the label of the x-axis |
847 |
@type label: string |
848 |
""" |
849 |
|
850 |
def setYLabel(self, label): |
851 |
""" |
852 |
Set the label of the y-axis |
853 |
|
854 |
@param label: the string holding the label of the y-axis |
855 |
@type label: string |
856 |
""" |
857 |
|
858 |
def setZLabel(self, label): |
859 |
""" |
860 |
Set the label of the z-axis |
861 |
|
862 |
@param label: the string holding the label of the z-axis |
863 |
@type label: string |
864 |
""" |
865 |
|
866 |
def setLabel(self, axis, label): |
867 |
""" |
868 |
Set the label of a given axis |
869 |
|
870 |
@param axis: string (Axis object maybe??) of the axis (e.g. x, y, z) |
871 |
@type axis: string or Axis object |
872 |
|
873 |
@param label: string of the label to set for the axis |
874 |
@type label: string |
875 |
""" |
876 |
|
877 |
class Renderer(BaseRenderer): |
878 |
""" |
879 |
A generic object holding a renderer of a Scene(). |
880 |
""" |
881 |
|
882 |
def __init__(self): |
883 |
""" |
884 |
Initialisation of Renderer() class |
885 |
""" |
886 |
debugMsg("Called Renderer.__init__()") |
887 |
BaseRenderer.__init__(self) |
888 |
|
889 |
# initialise some attributes |
890 |
self.renderWindowWidth = 640 |
891 |
self.renderWindowHeight = 480 |
892 |
|
893 |
# what is the name of my renderer? |
894 |
self.name = _rendererName |
895 |
|
896 |
# the namespace to run the exec code |
897 |
self.renderDict = {} |
898 |
|
899 |
# initialise the evalstack |
900 |
self._evalStack = "" |
901 |
|
902 |
# keep the initial setup of the module for later reuse |
903 |
self._initStack = "" |
904 |
|
905 |
# initialise the renderer module |
906 |
self.runString("# Renderer._initRendererModule") |
907 |
self.addToInitStack("import vtk") |
908 |
self.addToInitStack("from numarray import *") |
909 |
|
910 |
__revision__ = '$Revision: 1.33 $' |
911 |
|
912 |
class Scene(BaseScene): |
913 |
""" |
914 |
The main object controlling the scene. |
915 |
|
916 |
Scene object methods and classes overriding the BaseScene class. |
917 |
""" |
918 |
|
919 |
def __init__(self): |
920 |
""" |
921 |
The init function |
922 |
""" |
923 |
|
924 |
def add(self, obj): |
925 |
""" |
926 |
Add a new item to the scene |
927 |
|
928 |
@param obj: The object to add to the scene |
929 |
@type obj: object |
930 |
""" |
931 |
|
932 |
def place(self, obj): |
933 |
""" |
934 |
Place an object within a scene |
935 |
|
936 |
@param obj: The object to place within the scene |
937 |
@type obj: object |
938 |
""" |
939 |
|
940 |
def render(self, pause=False, interactive=False): |
941 |
""" |
942 |
Render (or re-render) the scene |
943 |
|
944 |
Render the scene, either to screen, or to a buffer waiting for a save |
945 |
|
946 |
@param pause: Flag to wait at end of script evaluation for user input |
947 |
@type pause: boolean |
948 |
|
949 |
@param interactive: Whether or not to have interactive use of the output |
950 |
@type interactive: boolean |
951 |
""" |
952 |
|
953 |
def save(self, fname, format): |
954 |
""" |
955 |
Save the scene to a file |
956 |
|
957 |
Possible formats are: |
958 |
- Postscript |
959 |
- PNG |
960 |
- JPEG |
961 |
- TIFF |
962 |
- BMP |
963 |
- PNM |
964 |
|
965 |
@param fname: Name of output file |
966 |
@type fname: string |
967 |
|
968 |
@param format: Graphics format of output file |
969 |
@type format: Image object or string |
970 |
""" |
971 |
|
972 |
def setBackgroundColor(self, *color): |
973 |
""" |
974 |
Sets the background color of the Scene |
975 |
|
976 |
@param color: The color to set the background to. Can be RGB or CMYK |
977 |
@type color: tuple |
978 |
""" |
979 |
|
980 |
def getBackgroundColor(self): |
981 |
""" |
982 |
Gets the current background color setting of the Scene |
983 |
""" |
984 |
|
985 |
def setSize(self, xSize, ySize): |
986 |
""" |
987 |
Sets the size of the scene. |
988 |
|
989 |
This size is effectively the renderer window size. |
990 |
|
991 |
@param xSize: the size to set the x dimension |
992 |
@type xSize: float |
993 |
|
994 |
@param ySize: the size to set the y dimension |
995 |
@type ySize: float |
996 |
""" |
997 |
|
998 |
def getSize(self): |
999 |
""" |
1000 |
Gets the current size of the scene |
1001 |
|
1002 |
This size is effectively the renderer window size. Returns a tuple |
1003 |
of the x and y dimensions respectively, in pixel units(??). |
1004 |
""" |
1005 |
class SurfacePlot(Plot): |
1006 |
""" |
1007 |
Surface plot |
1008 |
""" |
1009 |
def __init__(self, scene): |
1010 |
""" |
1011 |
Initialisation of the SurfacePlot class |
1012 |
|
1013 |
@param scene: The Scene to render the plot in |
1014 |
@type scene: Scene object |
1015 |
""" |
1016 |
|
1017 |
def setData(self, *dataList, **options): |
1018 |
""" |
1019 |
Set data to the plot |
1020 |
|
1021 |
@param dataList: List of data to set to the plot |
1022 |
@type dataList: tuple |
1023 |
|
1024 |
@param options: Dictionary of extra options |
1025 |
@type options: dict |
1026 |
|
1027 |
@param fname: the name of the input vtk file |
1028 |
@type fname: string |
1029 |
|
1030 |
@param format: the format of the input vtk file ('vtk' or 'vtk-xml') |
1031 |
@type format: string |
1032 |
|
1033 |
@param scalars: the scalar data in the vtk file to use |
1034 |
@type scalars: string |
1035 |
""" |
1036 |
|
1037 |
class Text(Item): |
1038 |
""" |
1039 |
Text |
1040 |
""" |
1041 |
def __init__(self, scene): |
1042 |
""" |
1043 |
Initialisation of the Text object |
1044 |
|
1045 |
@param scene: the scene with which to associate the Text object |
1046 |
@type scene: Scene object |
1047 |
""" |
1048 |
|
1049 |
def setFont(self, font): |
1050 |
""" |
1051 |
Set the current font |
1052 |
|
1053 |
@param font: the font to set |
1054 |
@type font: string |
1055 |
""" |
1056 |
|
1057 |
def getFont(self): |
1058 |
""" |
1059 |
\end{verbose} |