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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1158 - (show annotations)
Tue May 22 04:24:01 2007 UTC (12 years, 3 months ago) by jongui
File MIME type: text/x-python
File size: 2700 byte(s)
Made some changes to fix the memory leak problem. However, the problem still persists for run_escript_with_lazy_evaluation.py, run_streamline.py and run_streamline_with_lazy_evaluation.py.

1 """
2 @author: John NGUI
3 """
4
5 import vtk
6 from mapper import DataSetMapper
7 from actor import Actor3D
8 from constant import Viewport
9 from texture import Texture
10 from plane import PlaneSource
11 from transform import Transform, TransformFilter
12
13 # NOTE: DataSetMapper, Actor3D, Texture, PlaneSource, Transform and
14 # TransformFilter were inherited to allow access to their public methods
15 # from the driver.
16 class Image(DataSetMapper, Actor3D, Texture, PlaneSource, Transform,
17 TransformFilter):
18 """
19 Class that displays an image which can be scaled (upwards and downwards)
20 and has interaction capability. The image can also be translated and
21 rotated along the X, Y and Z axes.
22
23 @bug: Translating an image works differently (opposite) compared to
24 translating a plane. For example, a positive translation along the
25 z-axis moves a plane up. However, if the identical translation is applied on
26 an image, the image moves down.
27 """
28
29 # The SOUTH_WEST default viewport is used when there is only one viewport.
30 # This saves the user from specifying the viewport when there is only one.
31 def __init__(self, scene, image_reader, viewport = Viewport.SOUTH_WEST):
32 """
33 @type scene: L{Scene <scene.Scene>} object
34 @param scene: Scene in which the image is to be displayed
35 @type image_reader: L{ImageReader <imagereader.ImageReader>}
36 object
37 @param image_reader: Deal with source of data for vizualisation
38 @type viewport: L{Viewport <constant.Viewport>} constant
39 @param viewport: Viewport in which the image is to be displayed
40 """
41
42 self.__image_reader = image_reader
43 self.__viewport = viewport
44
45 # Keeps track whether Image has been modified.
46 self.__modified = True
47 Texture.__init__(self)
48 PlaneSource.__init__(self)
49 Transform.__init__(self)
50 TransformFilter.__init__(self)
51 DataSetMapper.__init__(self)
52 Actor3D.__init__(self)
53 scene._addVisualizationModules(self)
54
55 # ----- Image -----
56
57 self._setupTexture(image_reader._getImageReaderOutput())
58 self._setupTransformFilter(self._getPlaneSourceOutput(),
59 self._getTransform())
60
61 self._setupDataSetMapper(self._getTransformFilterOutput())
62 self._setupActor3D(self._getDataSetMapper())
63
64 self._setTexture(self._getTexture())
65 scene._addActor3D(self.__viewport, self._getActor3D())
66
67 def _isModified(self):
68 """
69 Return whether the Image has been modified.
70
71 @rtype: Boolean
72 @return: True or False
73 """
74
75 if (self.__modified == True):
76 return True
77 else:
78 return False
79
80 def _render(self, scene):
81 """
82 Render the image.
83
84 @type scene: L{Scene <scene.Scene>} object
85 @param scene: Scene in which the image is to be displayed
86 """
87
88 if(self._isModified() == True):
89 self.__isModified = False
90
91

  ViewVC Help
Powered by ViewVC 1.1.26