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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 845 - (hide annotations)
Fri Sep 8 07:13:01 2006 UTC (14 years, 1 month ago) by jongui
File MIME type: text/x-python
File size: 2301 byte(s)
Display an image is partially completed.

1 gross 792 """
2 jongui 839 @author: John Ngui
3     @author: Lutz Gross
4 gross 792 """
5    
6 jongui 827 import vtk
7 jongui 828 from common import *
8 gross 792
9 jongui 828 class Arrows(Common):
10 jongui 835 """
11 jongui 839 Class that shows a vector field by arrows.
12 jongui 835 """
13 gross 792
14 jongui 845 def __init__(self, scene, data_collector, lut = None):
15 jongui 835 """
16 jongui 845 @type scene: L{Scene <scene.Scene>} object
17 jongui 839 @param scene: Scene in which components are to be added to
18 jongui 835 @type data_collector: L{DataCollector <datacollector.DataCollector>}
19     object
20     @param data_collector: Source of data for visualization
21     """
22    
23 jongui 839 Common.__init__(self, scene, data_collector)
24 jongui 827 self.vtk_glyph = None
25     self.setArrows()
26 jongui 828
27 jongui 845 Common.setMapper(self, "self.vtk_glyph.GetOutput()", lut)
28 jongui 828 Common.setActor(self)
29     Common.addActor(self)
30 jongui 827
31     def setArrows(self):
32 jongui 835 """
33     Set up the glyph and use arrows as the source.
34     """
35    
36 jongui 827 vtk_arrows = vtk.vtkArrowSource()
37    
38     self.vtk_glyph = vtk.vtkGlyph3D()
39     self.vtk_glyph.SetInput(self.data_collector.getReader().GetOutput())
40     self.vtk_glyph.SetSource(vtk_arrows.GetOutput())
41 jongui 835 self.vtk_glyph.SetVectorModeToUseVector() # Default vector mode
42     self.vtk_glyph.SetScaleModeToScaleByVector() # Default scale mode
43     self.setColorMode("Scalar") # Default color mode
44     self.setScaleFactor(0.2) # Default scale factor
45 jongui 828
46     def setScaleFactor(self, scale_factor):
47 jongui 835 """
48     Set the scale factor for the arrows.
49    
50     @type scale_factor: Number
51     @param scale_factor: Scale factor
52     """
53    
54 jongui 828 self.vtk_glyph.SetScaleFactor(scale_factor)
55    
56     def setColorMode(self, color_mode):
57 jongui 835 """
58     Set the color mode for the arrows.
59    
60     @type color_mode: String
61     @param color_mode: Color mode for the arrows (I{Scalar or Vector})
62     """
63    
64 jongui 828 eval("self.vtk_glyph.SetColorModeToColorBy%s()" % color_mode)
65 jongui 827
66 jongui 840
67     from arrows import Arrows
68 jongui 845 from geo import Plane
69 jongui 840
70     class ArrowsOnPlane(Arrows, Plane):
71     """
72 jongui 845 Class that shows a vector field by arrows on a given plane.
73 jongui 840 """
74    
75 jongui 845 def __init__(self, scene, data_collector, lut = None):
76     """
77     @type scene: L{Scene <scene.Scene>} object
78     @param scene: Scene in which components are to be added to
79     @type data_collector: L{DataCollector <datacollector.DataCollector>}
80     object
81    
82     @param data_collector: Source of data for visualization
83     """
84    
85 jongui 840 Common.__init__(self, scene, data_collector)
86     self.vtk_glyph = None
87     self.setArrows()
88    
89     Plane.__init__(self, scene, data_collector,
90     "self.vtk_glyph.GetOutput()")
91    

  ViewVC Help
Powered by ViewVC 1.1.26