/[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 1197 - (show annotations)
Mon Jun 18 02:08:34 2007 UTC (12 years, 1 month ago) by jongui
File MIME type: text/x-python
File size: 3311 byte(s)
Update the way movies are generated. Please refer to the examples. 

The user can now either specify the image range(first and last images inclusive):
mov.imageRange(input_directory = PYVISI_EXAMPLE_IMAGES_PATH,
        first_image = IMAGE_NAME + "000938.jpg",
		last_image = IMAGE_NAME + "000948.jpg")
mov.makeMovie(os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, "movie.mpg"))

or the user can specify a list of images:

lst = ['image1.jpg', 'image5.jpg', 'image7.jpg]
mov.imageList(input_directory = PYVISI_EXAMPLE_IMAGES_PATH, image_list = lst)
mov.makeMovie(os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, "movie.mpg"))


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

  ViewVC Help
Powered by ViewVC 1.1.26