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

Contents of /trunk/pyvisi/py_src/glyph.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1147 - (show annotations)
Wed May 16 06:39:11 2007 UTC (13 years, 11 months ago) by ksteube
File MIME type: text/x-python
File size: 4432 byte(s)
Added back in some files that were accidentally deleted.

1 """
2 @author: John NGUI
3 """
4
5 import vtk
6
7 class Glyph3D:
8 """
9 Class that defines 3D glyphs.
10 """
11
12 def __init__(self, object, source):
13 """
14 Initialise the 3D glyph.
15
16 @type object: vtkDataSet, etc
17 @param object: Input for the 3D glyph
18 @type source: vtkPolyData
19 @param source: Source for the 3D glyph (i.e. Arrow2D, Arrow3D, etc)
20 """
21
22 self.__object = object
23 self.__source = source
24 self.__vtk_glyph3D = vtk.vtkGlyph3D()
25
26 self.__setupGlyph3D()
27
28 def __setupGlyph3D(self):
29 """
30 Setup the 3D glyph.
31 """
32
33 self.__setInput()
34 self.__setSource()
35 self.setScaleModeByVector()
36 self.__setVectorModeByVector()
37 self.__setClampingOn()
38
39 self.__setScalingOn()
40 self.__setOrientOn()
41
42 def __setInput(self):
43 """
44 Set the input for the 3D glyph.
45 """
46
47 self.__vtk_glyph3D.SetInput(self.__object)
48
49 def __setSource(self):
50 """
51 Set the source for the 3D glyph.
52 """
53
54 self.__vtk_glyph3D.SetSource(self.__source)
55
56 def setScaleModeByVector(self):
57 """
58 Set the 3D glyph to scale according to the vector.
59 """
60
61 self.__vtk_glyph3D.SetScaleModeToScaleByVector()
62
63 def setScaleModeByScalar(self):
64 """
65 Set the 3D glyph to scale according to the scalar.
66 """
67
68 self.__vtk_glyph3D.SetScaleModeToScaleByScalar()
69
70 def _setColorModeByVector(self):
71 """
72 Set the 3D glyph to color according to the vector.
73 """
74
75 self.__vtk_glyph3D.SetColorModeToColorByVector()
76
77 def _setColorModeByScalar(self):
78 """
79 Set the 3D glyph to color according to the scalar.
80 """
81
82 self.__vtk_glyph3D.SetColorModeToColorByScalar()
83
84 def __setVectorModeByVector(self):
85 """
86 Set the 3D glyph vector mode according to the vector.
87 """
88
89 self.__vtk_glyph3D.SetVectorModeToUseVector()
90
91 def setScaleFactor(self, scale_factor):
92 """
93 Set the 3D glyph scale factor.
94
95 @type scale_factor: Number
96 @param scale_factor: Scale factor
97 """
98
99 self.__vtk_glyph3D.SetScaleFactor(scale_factor)
100
101 def __setClampingOn(self):
102 """
103 Enable clamping of "scalar" values to range.
104 """
105
106 self.__vtk_glyph3D.SetClamping(1)
107
108 def __setScalingOn(self):
109 """
110 Enable the scaling of the rendered object.
111 """
112
113 self.__vtk_glyph3D.ScalingOn()
114
115 def __setOrientOn(self):
116 """
117 Enable the orientation of the rendered object along the vector/normal.
118 """
119
120 self.__vtk_glyph3D.OrientOn()
121
122 def _setRange(self, range):
123 """
124 Set the range to map scalar values.
125
126 @type range: Two column tuple containing numbers
127 @param range: Range to map scalar values
128 """
129
130 self.__vtk_glyph3D.SetRange(range)
131
132 def _getGlyph3D(self):
133 """
134 Return the 3D glyph.
135
136 @rtype: vtkGlyph3D
137 @return: 3D glyph
138 """
139
140 return self.__vtk_glyph3D
141
142 def _getOutput(self):
143 """
144 Return the output of the 3D glyph.
145
146 @rtype: vtkPolyData
147 @return Polygonal data
148 """
149
150 return self.__vtk_glyph3D.GetOutput()
151
152
153 ###############################################################################
154
155
156 class TensorGlyph:
157 """
158 Class that defines tensor glyphs.
159 """
160
161 def __init__(self, object, source):
162 """
163 Initialise the tensor glyph.
164
165 @type object: vtkDataSet, etc
166 @param object: Input for the 3D glyph
167 @type source: vtkPolyData
168 @param source: Source for the 3D glyph (i.e. Sphere, etc)
169 """
170
171 self.__object = object
172 self.__source = source
173 self.__vtk_tensor_glyph = vtk.vtkTensorGlyph()
174
175 self.__setupTensorGlyph()
176
177 def __setupTensorGlyph(self):
178 """
179 Setup the tensor glyph.
180 """
181
182 self.__setInput()
183 self.__setSource()
184 self.__vtk_tensor_glyph.ClampScalingOn()
185
186
187 def __setInput(self):
188 """
189 Set the input for the tensor glyph.
190 """
191
192 self.__vtk_tensor_glyph.SetInput(self.__object)
193
194 def __setSource(self):
195 """
196 Set the source for the tensor glyph.
197 """
198
199 self.__vtk_tensor_glyph.SetSource(self.__source)
200
201 def setScaleFactor(self, scale_factor):
202 """
203 Set the scale factor for the tensor glyph.
204
205 @type scale_factor: Number
206 @param scale_factor: Scale factor
207 """
208
209 self.__vtk_tensor_glyph.SetScaleFactor(scale_factor)
210
211 def setMaxScaleFactor(self, max_scale_factor):
212 """
213 Set the maximum allowable scale factor for the tensor glyph.
214
215 @type max_scale_factor: Number
216 @param max_scale_factor: Maximum allowable scale factor.
217 """
218
219 self.__vtk_tensor_glyph.SetMaxScaleFactor(max_scale_factor)
220
221 def _getOutput(self):
222 """
223 Return the output of the tensor glyph.
224
225 @rtype: vtkPolyData
226 @return: Polygonal data
227 """
228
229 return self.__vtk_tensor_glyph.GetOutput()
230

  ViewVC Help
Powered by ViewVC 1.1.26