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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1199 - (hide annotations)
Wed Jun 20 05:01:30 2007 UTC (13 years, 10 months ago) by jongui
File MIME type: text/x-python
File size: 4867 byte(s)
- Updated the epydocs and guide.
Deleted redundant files and methods.
Tidied up the codes.
1 ksteube 1147 """
2 jongui 1197 @var __author__: name of author
3     @var __copyright__: copyrights
4     @var __license__: licence agreement
5     @var __url__: url entry point on documentation
6     @var __version__: version
7     @var __date__: date of the version
8 ksteube 1147 """
9    
10 jongui 1197 __author__="John Ngui, john.ngui@uq.edu.au"
11     __copyright__=""" Copyright (c) 2006 by ACcESS MNRF
12     http://www.access.edu.au
13     Primary Business: Queensland, Australia"""
14     __license__="""Licensed under the Open Software License version 3.0
15     http://www.opensource.org/licenses/osl-3.0.php"""
16     __url__="http://www.iservo.edu.au/esys"
17     __version__="$Revision$"
18     __date__="$Date$"
19    
20    
21 ksteube 1147 import vtk
22    
23     class Glyph3D:
24     """
25     Class that defines 3D glyphs.
26     """
27    
28 jongui 1148 def __init__(self):
29 ksteube 1147 """
30     Initialise the 3D glyph.
31 jongui 1148 """
32 ksteube 1147
33 jongui 1148 self.__vtk_glyph3D = vtk.vtkGlyph3D()
34    
35     def _setupGlyph3D(self, object, source):
36     """
37     Setup the 3D glyph.
38    
39 ksteube 1147 @type object: vtkDataSet, etc
40     @param object: Input for the 3D glyph
41     @type source: vtkPolyData
42     @param source: Source for the 3D glyph (i.e. Arrow2D, Arrow3D, etc)
43     """
44    
45     self.__object = object
46     self.__source = source
47    
48     self.__setInput()
49     self.__setSource()
50     self.setScaleModeByVector()
51     self.__setVectorModeByVector()
52     self.__setClampingOn()
53    
54     self.__setScalingOn()
55     self.__setOrientOn()
56    
57     def __setInput(self):
58     """
59     Set the input for the 3D glyph.
60     """
61    
62     self.__vtk_glyph3D.SetInput(self.__object)
63    
64     def __setSource(self):
65     """
66     Set the source for the 3D glyph.
67     """
68    
69     self.__vtk_glyph3D.SetSource(self.__source)
70    
71     def setScaleModeByVector(self):
72     """
73     Set the 3D glyph to scale according to the vector.
74     """
75    
76     self.__vtk_glyph3D.SetScaleModeToScaleByVector()
77    
78     def setScaleModeByScalar(self):
79     """
80     Set the 3D glyph to scale according to the scalar.
81     """
82    
83     self.__vtk_glyph3D.SetScaleModeToScaleByScalar()
84    
85     def _setColorModeByVector(self):
86     """
87     Set the 3D glyph to color according to the vector.
88     """
89    
90     self.__vtk_glyph3D.SetColorModeToColorByVector()
91    
92     def _setColorModeByScalar(self):
93     """
94     Set the 3D glyph to color according to the scalar.
95     """
96    
97     self.__vtk_glyph3D.SetColorModeToColorByScalar()
98    
99     def __setVectorModeByVector(self):
100     """
101     Set the 3D glyph vector mode according to the vector.
102     """
103    
104     self.__vtk_glyph3D.SetVectorModeToUseVector()
105    
106     def setScaleFactor(self, scale_factor):
107     """
108     Set the 3D glyph scale factor.
109    
110     @type scale_factor: Number
111     @param scale_factor: Scale factor
112     """
113    
114     self.__vtk_glyph3D.SetScaleFactor(scale_factor)
115    
116     def __setClampingOn(self):
117     """
118     Enable clamping of "scalar" values to range.
119     """
120    
121     self.__vtk_glyph3D.SetClamping(1)
122    
123     def __setScalingOn(self):
124     """
125     Enable the scaling of the rendered object.
126     """
127    
128     self.__vtk_glyph3D.ScalingOn()
129    
130     def __setOrientOn(self):
131     """
132     Enable the orientation of the rendered object along the vector/normal.
133     """
134    
135     self.__vtk_glyph3D.OrientOn()
136    
137     def _setRange(self, range):
138     """
139     Set the range to map scalar values.
140    
141     @type range: Two column tuple containing numbers
142     @param range: Range to map scalar values
143     """
144    
145     self.__vtk_glyph3D.SetRange(range)
146    
147 jongui 1148 def _getGlyph3DOutput(self):
148 ksteube 1147 """
149     Return the output of the 3D glyph.
150    
151     @rtype: vtkPolyData
152     @return Polygonal data
153     """
154    
155     return self.__vtk_glyph3D.GetOutput()
156    
157    
158     ###############################################################################
159    
160    
161     class TensorGlyph:
162     """
163     Class that defines tensor glyphs.
164     """
165    
166 jongui 1148 def __init__(self):
167 ksteube 1147 """
168     Initialise the tensor glyph.
169 jongui 1148 """
170 ksteube 1147
171 jongui 1148 self.__vtk_tensor_glyph = vtk.vtkTensorGlyph()
172    
173     def _setupTensorGlyph(self, object, source):
174     """
175     Setup the tensor glyph.
176    
177 ksteube 1147 @type object: vtkDataSet, etc
178     @param object: Input for the 3D glyph
179     @type source: vtkPolyData
180     @param source: Source for the 3D glyph (i.e. Sphere, etc)
181     """
182    
183     self.__object = object
184     self.__source = source
185    
186     self.__setInput()
187     self.__setSource()
188     self.__vtk_tensor_glyph.ClampScalingOn()
189    
190     def __setInput(self):
191     """
192     Set the input for the tensor glyph.
193     """
194    
195     self.__vtk_tensor_glyph.SetInput(self.__object)
196    
197     def __setSource(self):
198     """
199     Set the source for the tensor glyph.
200     """
201    
202     self.__vtk_tensor_glyph.SetSource(self.__source)
203    
204     def setScaleFactor(self, scale_factor):
205     """
206     Set the scale factor for the tensor glyph.
207    
208     @type scale_factor: Number
209     @param scale_factor: Scale factor
210     """
211    
212     self.__vtk_tensor_glyph.SetScaleFactor(scale_factor)
213    
214     def setMaxScaleFactor(self, max_scale_factor):
215     """
216     Set the maximum allowable scale factor for the tensor glyph.
217    
218     @type max_scale_factor: Number
219     @param max_scale_factor: Maximum allowable scale factor.
220     """
221    
222     self.__vtk_tensor_glyph.SetMaxScaleFactor(max_scale_factor)
223    
224 jongui 1148 def _getTensorGlyphOutput(self):
225 ksteube 1147 """
226     Return the output of the tensor glyph.
227    
228     @rtype: vtkPolyData
229     @return: Polygonal data
230     """
231    
232     return self.__vtk_tensor_glyph.GetOutput()
233    

  ViewVC Help
Powered by ViewVC 1.1.26