/[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 2344 - (show annotations)
Mon Mar 30 02:13:58 2009 UTC (10 years, 5 months ago) by jfenwick
File MIME type: text/x-python
File size: 3742 byte(s)
Change __url__ to launchpad site

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__="https://launchpad.net/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 from esys.escript import getMPISizeWorld
42
43 # NOTE: DataSetMapper, Actor3D, Texture, PlaneSource, Transform and
44 # TransformFilter were inherited to allow access to their public methods
45 # from the driver.
46 class Image(DataSetMapper, Actor3D, Texture, PlaneSource, Transform,
47 TransformFilter):
48 """
49 Class that displays an image which can be scaled (upwards and downwards)
50 and has interaction capability. The image can also be translated and
51 rotated along the X, Y and Z axes.
52
53 @attention: Translating an image works differently (opposite) compared to
54 translating a plane. For example, a positive translation along the
55 z-axis moves a plane up. However, if the identical translation is applied
56 on an image, the image moves down.
57 """
58
59 # The SOUTH_WEST default viewport is used when there is only one viewport.
60 # This saves the user from specifying the viewport when there is only one.
61 def __init__(self, scene, image_reader, viewport = Viewport.SOUTH_WEST):
62 """
63 @type scene: L{Scene <scene.Scene>} object
64 @param scene: Scene in which the image is to be displayed
65 @type image_reader: L{ImageReader <imagereader.ImageReader>}
66 object
67 @param image_reader: Deal with source of data for vizualisation
68 @type viewport: L{Viewport <constant.Viewport>} constant
69 @param viewport: Viewport in which the image is to be displayed
70 """
71
72 self.__image_reader = image_reader
73 self.__viewport = viewport
74
75 # Keeps track whether Image has been modified.
76 self.__modified = True
77 Texture.__init__(self)
78 PlaneSource.__init__(self)
79 Transform.__init__(self)
80 TransformFilter.__init__(self)
81 DataSetMapper.__init__(self)
82 Actor3D.__init__(self)
83 scene._addVisualizationModules(self)
84
85 # ----- Image -----
86
87 self._setupTexture(image_reader._getImageReaderOutput())
88 self._setupTransformFilter(self._getPlaneSourceOutput(),
89 self._getTransform())
90
91 self._setupDataSetMapper(self._getTransformFilterOutput())
92 self._setupActor3D(self._getDataSetMapper())
93
94 self._setTexture(self._getTexture())
95 scene._addActor3D(self.__viewport, self._getActor3D())
96
97 def _isModified(self):
98 """
99 Return whether the Image has been modified.
100
101 @rtype: Boolean
102 @return: True or False
103 """
104
105 if (self.__modified == True):
106 return True
107 else:
108 return False
109
110 def _render(self, scene):
111 """
112 Render the image.
113
114 @type scene: L{Scene <scene.Scene>} object
115 @param scene: Scene in which the image is to be displayed
116 """
117
118 if(self._isModified() == True):
119 self.__isModified = False
120
121

  ViewVC Help
Powered by ViewVC 1.1.26