/[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 1809 - (show annotations)
Thu Sep 25 06:43:44 2008 UTC (11 years, 1 month ago) by ksteube
File MIME type: text/x-python
File size: 3706 byte(s)
Copyright updated in all python files

1
2 ########################################################
3 #
4 # Copyright (c) 2003-2008 by University of Queensland
5 # Earth Systems Science Computational Center (ESSCC)
6 # http://www.uq.edu.au/esscc
7 #
8 # Primary Business: Queensland, Australia
9 # Licensed under the Open Software License version 3.0
10 # http://www.opensource.org/licenses/osl-3.0.php
11 #
12 ########################################################
13
14 __copyright__="""Copyright (c) 2003-2008 by University of Queensland
15 Earth Systems Science Computational Center (ESSCC)
16 http://www.uq.edu.au/esscc
17 Primary Business: Queensland, Australia"""
18 __license__="""Licensed under the Open Software License version 3.0
19 http://www.opensource.org/licenses/osl-3.0.php"""
20 __url__="http://www.uq.edu.au/esscc/escript-finley"
21
22 """
23 @var __author__: name of author
24 @var __copyright__: copyrights
25 @var __license__: licence agreement
26 @var __url__: url entry point on documentation
27 @var __version__: version
28 @var __date__: date of the version
29 """
30
31 __author__="John Ngui, john.ngui@uq.edu.au"
32
33
34 import vtk
35 from mapper import DataSetMapper
36 from actor import Actor3D
37 from constant import Viewport
38 from texture import Texture
39 from plane import PlaneSource
40 from transform import Transform, TransformFilter
41
42 # NOTE: DataSetMapper, Actor3D, Texture, PlaneSource, Transform and
43 # TransformFilter were inherited to allow access to their public methods
44 # from the driver.
45 class Image(DataSetMapper, Actor3D, Texture, PlaneSource, Transform,
46 TransformFilter):
47 """
48 Class that displays an image which can be scaled (upwards and downwards)
49 and has interaction capability. The image can also be translated and
50 rotated along the X, Y and Z axes.
51
52 @attention: Translating an image works differently (opposite) compared to
53 translating a plane. For example, a positive translation along the
54 z-axis moves a plane up. However, if the identical translation is applied
55 on an image, the image moves down.
56 """
57
58 # The SOUTH_WEST default viewport is used when there is only one viewport.
59 # This saves the user from specifying the viewport when there is only one.
60 def __init__(self, scene, image_reader, viewport = Viewport.SOUTH_WEST):
61 """
62 @type scene: L{Scene <scene.Scene>} object
63 @param scene: Scene in which the image is to be displayed
64 @type image_reader: L{ImageReader <imagereader.ImageReader>}
65 object
66 @param image_reader: Deal with source of data for vizualisation
67 @type viewport: L{Viewport <constant.Viewport>} constant
68 @param viewport: Viewport in which the image is to be displayed
69 """
70
71 self.__image_reader = image_reader
72 self.__viewport = viewport
73
74 # Keeps track whether Image has been modified.
75 self.__modified = True
76 Texture.__init__(self)
77 PlaneSource.__init__(self)
78 Transform.__init__(self)
79 TransformFilter.__init__(self)
80 DataSetMapper.__init__(self)
81 Actor3D.__init__(self)
82 scene._addVisualizationModules(self)
83
84 # ----- Image -----
85
86 self._setupTexture(image_reader._getImageReaderOutput())
87 self._setupTransformFilter(self._getPlaneSourceOutput(),
88 self._getTransform())
89
90 self._setupDataSetMapper(self._getTransformFilterOutput())
91 self._setupActor3D(self._getDataSetMapper())
92
93 self._setTexture(self._getTexture())
94 scene._addActor3D(self.__viewport, self._getActor3D())
95
96 def _isModified(self):
97 """
98 Return whether the Image has been modified.
99
100 @rtype: Boolean
101 @return: True or False
102 """
103
104 if (self.__modified == True):
105 return True
106 else:
107 return False
108
109 def _render(self, scene):
110 """
111 Render the image.
112
113 @type scene: L{Scene <scene.Scene>} object
114 @param scene: Scene in which the image is to be displayed
115 """
116
117 if(self._isModified() == True):
118 self.__isModified = False
119
120

  ViewVC Help
Powered by ViewVC 1.1.26