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

Annotation of /temp_trunk_copy/pyvisi/py_src/actor.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1199 - (hide annotations)
Wed Jun 20 05:01:30 2007 UTC (13 years, 11 months ago) by jongui
Original Path: trunk/pyvisi/py_src/actor.py
File MIME type: text/x-python
File size: 3460 byte(s)
- Updated the epydocs and guide.
Deleted redundant files and methods.
Tidied up the codes.
1 ksteube 1147 """
2 jongui 1197 @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 ksteube 1147 """
9    
10 jongui 1197 __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 ksteube 1147 import vtk
22    
23     class Actor3D:
24     """
25     Class that defines a 3D actor.
26     """
27    
28 jongui 1148 def __init__(self):
29 ksteube 1147 """
30     Initialise the 3D actor.
31 jongui 1148 """
32 ksteube 1147
33 jongui 1148 self.__vtk_actor3D = vtk.vtkActor()
34    
35     def _setupActor3D(self, mapper):
36     """
37     Setup the 3D actor.
38    
39 ksteube 1147 @type mapper: vtkDataSetMapper
40     @param mapper: Mapped data
41     """
42    
43     self.__mapper = mapper
44     self.__setMapper()
45 jongui 1148
46 ksteube 1147 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 jongui 1199 Set the representation of the 3D actor to wireframe.
89 ksteube 1147 """
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 jongui 1148 def __init__(self):
123 ksteube 1147 """
124     Initialise the 2D actor.
125 jongui 1148 """
126 ksteube 1147
127 jongui 1148 self._vtk_actor2D = vtk.vtkActor2D()
128    
129     def _setupActor2D(self, mapper):
130     """
131     Setup the 2D actor.
132    
133 ksteube 1147 @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