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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1148 - (hide annotations)
Wed May 16 22:45:33 2007 UTC (12 years, 3 months ago) by jongui
File MIME type: text/x-python
File size: 2617 byte(s)
Added the updated files for pyvisi and removed some incorrect reference images.
1 ksteube 1147 """
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 jongui 1148 self.__scene = scene
43     self.__image_reader = image_reader
44     self.__viewport = viewport
45 ksteube 1147
46 jongui 1148 # Keeps track whether Image has been modified.
47     self.__modified = True
48     Texture.__init__(self)
49 ksteube 1147 PlaneSource.__init__(self)
50     Transform.__init__(self)
51 jongui 1148 TransformFilter.__init__(self)
52     DataSetMapper.__init__(self)
53     Actor3D.__init__(self)
54     scene._addVisualizationModules(self)
55 ksteube 1147
56 jongui 1148 # ----- Image -----
57 ksteube 1147
58 jongui 1148 self._setupTexture(image_reader._getImageReaderOutput())
59     self._setupTransformFilter(self._getPlaneSourceOutput(),
60     self._getTransform())
61 ksteube 1147
62 jongui 1148 self._setupDataSetMapper(self._getTransformFilterOutput())
63     self._setupActor3D(self._getDataSetMapper())
64 ksteube 1147
65 jongui 1148 self._setTexture(self._getTexture())
66     self.__scene._addActor3D(self.__viewport, self._getActor3D())
67    
68     def _isModified(self):
69     """
70     Return whether the Image has been modified.
71    
72     @rtype: Boolean
73     @return: True or False
74     """
75    
76     if (self.__modified == True):
77     return True
78     else:
79     return False
80    
81     def _render(self):
82     """
83     Render the image.
84     """
85    
86     if(self._isModified() == True):
87     self.__isModified = False
88    
89    

  ViewVC Help
Powered by ViewVC 1.1.26