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

Contents of /trunk/pyvisi/py_src/actor.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1197 - (show annotations)
Mon Jun 18 02:08:34 2007 UTC (12 years, 4 months ago) by jongui
File MIME type: text/x-python
File size: 3460 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
23 class Actor3D:
24 """
25 Class that defines a 3D actor.
26 """
27
28 def __init__(self):
29 """
30 Initialise the 3D actor.
31 """
32
33 self.__vtk_actor3D = vtk.vtkActor()
34
35 def _setupActor3D(self, mapper):
36 """
37 Setup the 3D actor.
38
39 @type mapper: vtkDataSetMapper
40 @param mapper: Mapped data
41 """
42
43 self.__mapper = mapper
44 self.__setMapper()
45
46 def __setMapper(self):
47 """
48 Set the mapper of the 3D actor.
49 """
50
51 self.__vtk_actor3D.SetMapper(self.__mapper)
52
53 def _setTexture(self, texture):
54 """
55 Set the texture of the 3D actor.
56
57 @type texture: vtkTexture
58 @param texture: Texture of the rendered object
59 """
60
61 self.__vtk_actor3D.SetTexture(texture)
62
63 def setOpacity(self, opacity):
64 """
65 Set the opacity (transparency) of the 3D actor.
66
67 @type opacity: Number (between 0 and 1)
68 @param opacity: Opacity (transparency) of the 3D actor
69 """
70
71 self.__vtk_actor3D.GetProperty().SetOpacity(opacity)
72
73 def setColor(self, color):
74 """
75 Set the color of the 3D actor.
76
77 @type color: L{Color <constant.Color>} constant
78 @param color: Color of the 3D actor
79 """
80
81 # NOTE: Must be used before actor.GetProperty().SetColor()
82 # in order for the change of color to take effect.
83 self.__mapper.ScalarVisibilityOff()
84 self.__vtk_actor3D.GetProperty().SetColor(color)
85
86 def setRepresentationToWireframe(self):
87 """
88 Set the representation of the 3D actor to Wireframe.
89 """
90
91 self.__vtk_actor3D.GetProperty().SetRepresentationToWireframe()
92
93 def _setLineWidth(self, line_width):
94 """
95 Set the line width of the 3D actor.
96
97 @type line_width: Number
98 @param line_width: 3D actor line width
99 """
100
101 self.__vtk_actor3D.GetProperty().SetLineWidth(line_width)
102
103 def _getActor3D(self):
104 """
105 Return the 3D actor.
106
107 @rtype: vtkActor
108 @return: 3D actor
109 """
110
111 return self.__vtk_actor3D
112
113
114 ###############################################################################
115
116
117 class Actor2D:
118 """
119 Class that defines a 2D actor.
120 """
121
122 def __init__(self):
123 """
124 Initialise the 2D actor.
125 """
126
127 self._vtk_actor2D = vtk.vtkActor2D()
128
129 def _setupActor2D(self, mapper):
130 """
131 Setup the 2D actor.
132
133 @type mapper: vtkMapper2D
134 @param mapper: Mapped data
135 """
136
137 self.__mapper = mapper
138 self.__setMapper()
139
140 def __setMapper(self):
141 """
142 Set the mapper for the 2D actor.
143 """
144
145 self._vtk_actor2D.SetMapper(self.__mapper)
146
147 def setPosition(self, position):
148 """
149 Set the position (XY) of the 2D actor. Default position is the lower
150 left hand corner of the window / viewport.
151
152 @type position: L{LocalPosition <position.LocalPosition>} object
153 @param position: Position of the 2D actor
154 """
155
156 self._vtk_actor2D.SetPosition(position._getLocalPosition())
157
158 def _getActor2D(self):
159 """
160 Return the 2D actor.
161
162 @rtype: vtkActor2D
163 @return 2D actor
164 """
165
166 return self._vtk_actor2D
167

  ViewVC Help
Powered by ViewVC 1.1.26