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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2344 - (hide annotations)
Mon Mar 30 02:13:58 2009 UTC (12 years ago) by jfenwick
File MIME type: text/x-python
File size: 4164 byte(s)
Change __url__ to launchpad site

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

  ViewVC Help
Powered by ViewVC 1.1.26