/[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 943 - (show annotations)
Mon Jan 29 07:22:43 2007 UTC (14 years, 1 month ago) by jongui
File MIME type: text/x-python
File size: 3790 byte(s)
new pyvisi files
1 """
2 @author: John NGUI
3 """
4
5 import vtk
6
7 class Glyph3D:
8 """
9 Class that defines 3D glyph.
10 """
11
12 def __init__(self, object, source, range):
13 """
14 Initialise the 3D glyph.
15
16 @type object: vtkUnstructuredGrid, 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 @type range: Two column list
21 @param range: Range to map scalar values into
22 """
23
24 self.__object = object
25 self.__source = source
26 self.__range = range
27 self.__vtk_glyph3D = vtk.vtkGlyph3D()
28
29 self.__setInput()
30 self.__setSource()
31 self.setScaleModeByVector()
32 #self.setColorModeByVector()
33 self.__setVectorModeByVector()
34 self.__setClampingOn()
35 self.__setScalingOn()
36 self.__setOrientOn()
37 self.__setRange()
38 self.__output = self.__vtk_glyph3D.GetOutput()
39
40 def __setInput(self):
41 """
42 Set the input for the 3D glyph.
43 """
44
45 self.__vtk_glyph3D.SetInput(self.__object)
46
47 def __setSource(self):
48 """
49 Set the source for the 3D glyph.
50 """
51
52 self.__vtk_glyph3D.SetSource(self.__source)
53
54 def setScaleModeByVector(self):
55 """
56 Set the 3D glyph to scale according to the vector.
57 """
58
59 self.__vtk_glyph3D.SetScaleModeToScaleByVector()
60
61 def setScaleModeByScalar(self):
62 """
63 Set the 3D glyph to scale according to the scalar.
64 """
65
66 self.__vtk_glyph3D.SetScaleModeToScaleByScalar()
67
68 def _setColorModeByVector(self):
69 """
70 Set the 3D glyph to color according to the vector.
71 """
72
73 self.__vtk_glyph3D.SetColorModeToColorByVector()
74
75 def _setColorModeByScalar(self):
76 """
77 Set the 3D glyph to color according to the scalar.
78 """
79
80 self.__vtk_glyph3D.SetColorModeToColorByScalar()
81
82 def __setVectorModeByVector(self):
83 """
84 Set the 3D glyph vector mode according to the vector.
85 """
86
87 self.__vtk_glyph3D.SetVectorModeToUseVector()
88
89 def setScaleFactor(self, scale_factor):
90 """
91 Set the 3D glyph scaling factor.
92
93 @type scale_factor: Number
94 @param scale_factor: Scale factor
95 """
96
97 self.__vtk_glyph3D.SetScaleFactor(scale_factor)
98
99 def __setClampingOn(self):
100 """
101 Enable clamping of "scalar" values to range.
102 """
103
104 self.__vtk_glyph3D.SetClamping(1)
105
106 def __setScalingOn(self):
107 """
108 Enable the scaling of the rendered object.
109 """
110
111 self.__vtk_glyph3D.ScalingOn()
112
113 def __setOrientOn(self):
114 """
115 Enable the orienting of the rendered object along vector/normal.
116 """
117
118 self.__vtk_glyph3D.OrientOn()
119
120 def __setRange(self):
121 """
122 Set the 3D glyph range to maps scalar values into.
123 """
124
125 self.__vtk_glyph3D.SetRange(self.__range)
126
127 def _getOutput(self):
128 """
129 Return the 3D glyph.
130
131 @rtype: vtkPolyData
132 @return Polygonal data
133 """
134
135 return self.__output
136
137
138 class TensorGlyph:
139
140 def __init__(self, object, source):
141 self.__object = object
142 self.__source = source
143 self.__vtk_tensor_glyph = vtk.vtkTensorGlyph()
144
145 self.__setInput()
146 self.__setSource()
147
148 def __setInput(self):
149 """
150 Set the input for the tensor glyph.
151 """
152
153 self.__vtk_tensor_glyph.SetInput(self.__object)
154
155 def __setSource(self):
156 """
157 Set the source for the tensor glyph.
158 """
159
160 self.__vtk_tensor_glyph.SetSource(self.__source)
161
162 def setScaleFactor(self, scale_factor):
163 """
164 Set the tensor glyph scaling factor.
165
166 @type scale_factor: Number
167 @param scale_factor: Scale factor
168 """
169
170 self.__vtk_tensor_glyph.SetScaleFactor(scale_factor)
171
172 def setMaxScaleFactor(self, max_scale_factor):
173 """
174 Set the maximum allowable scale factor.
175
176 @type max_scale_factor: Number
177 @param max_scale_factor: Maximum allowable scale factor.
178 """
179
180 self.__vtk_tensor_glyph.SetMaxScaleFactor(scale_factor)
181
182 def _getOutput(self):
183 """
184 Return the tensor glyph.
185
186 @rtype: vtkPolyData
187 @return: Polygonal data
188 """
189
190 return self.__vtk_tensor_glyph.GetOutput()

  ViewVC Help
Powered by ViewVC 1.1.26