/[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 1809 - (show annotations)
Thu Sep 25 06:43:44 2008 UTC (11 years, 4 months ago) by ksteube
File MIME type: text/x-python
File size: 3854 byte(s)
Copyright updated in all python files

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

  ViewVC Help
Powered by ViewVC 1.1.26