/[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 2881 - (show annotations)
Thu Jan 28 02:03:15 2010 UTC (11 years, 1 month ago) by jfenwick
File MIME type: text/x-python
File size: 3683 byte(s)
Don't panic.
Updating copyright stamps

1
2 ########################################################
3 #
4 # Copyright (c) 2003-2010 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-2010 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 from mapper import DataSetMapper
35 from actor import Actor3D
36 from constant import Viewport
37 from texture import Texture
38 from plane import PlaneSource
39 from transform import Transform, TransformFilter
40 from esys.escript import getMPISizeWorld
41 if getMPISizeWorld()==1: import vtk
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 translating a plane. For example, a positive translation along the z-axis moves a plane up. However, if the identical translation is applied on an image, the image moves down.
54 """
55
56 # The SOUTH_WEST default viewport is used when there is only one viewport.
57 # This saves the user from specifying the viewport when there is only one.
58 def __init__(self, scene, image_reader, viewport = Viewport.SOUTH_WEST):
59 """
60 :type scene: `Scene` object
61 :param scene: Scene in which the image is to be displayed
62 :type image_reader: `ImageReader`
63 object
64 :param image_reader: Deal with source of data for vizualisation
65 :type viewport: `Viewport` constant
66 :param viewport: Viewport in which the image is to be displayed
67 """
68
69 self.__image_reader = image_reader
70 self.__viewport = viewport
71
72 # Keeps track whether Image has been modified.
73 self.__modified = True
74 Texture.__init__(self)
75 PlaneSource.__init__(self)
76 Transform.__init__(self)
77 TransformFilter.__init__(self)
78 DataSetMapper.__init__(self)
79 Actor3D.__init__(self)
80 scene._addVisualizationModules(self)
81
82 # ----- Image -----
83
84 self._setupTexture(image_reader._getImageReaderOutput())
85 self._setupTransformFilter(self._getPlaneSourceOutput(),
86 self._getTransform())
87
88 self._setupDataSetMapper(self._getTransformFilterOutput())
89 self._setupActor3D(self._getDataSetMapper())
90
91 self._setTexture(self._getTexture())
92 scene._addActor3D(self.__viewport, self._getActor3D())
93
94 def _isModified(self):
95 """
96 Return whether the Image has been modified.
97
98 :rtype: Boolean
99 :return: True or False
100 """
101
102 if (self.__modified == True):
103 return True
104 else:
105 return False
106
107 def _render(self, scene):
108 """
109 Render the image.
110
111 :type scene: `Scene` object
112 :param scene: Scene in which the image is to be displayed
113 """
114
115 if(self._isModified() == True):
116 self.__isModified = False
117
118

  ViewVC Help
Powered by ViewVC 1.1.26