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

  ViewVC Help
Powered by ViewVC 1.1.26