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

  ViewVC Help
Powered by ViewVC 1.1.26