/[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 849 - (hide annotations)
Fri Sep 15 07:11:55 2006 UTC (14 years, 4 months ago) by jongui
File MIME type: text/x-python
File size: 2388 byte(s)
Optimized codes and modularized functions to make it more scalable. Partially 
integrated carpet into the existing modules.  

1 gross 792 """
2 jongui 839 @author: John Ngui
3     @author: Lutz Gross
4 gross 792 """
5    
6 jongui 827 import vtk
7 jongui 849 from common import Common
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 849 self.vtk_glyph = vtk.vtkGlyph3D()
25 jongui 827 self.setArrows()
26 jongui 828
27 jongui 849 Common.setMapperInput(self, self.vtk_glyph.GetOutput(), lut)
28     Common.setActorInput(self)
29 jongui 828 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.SetInput(self.data_collector.getReader().GetOutput())
39     self.vtk_glyph.SetSource(vtk_arrows.GetOutput())
40 jongui 849 self.setVectorMode("Vector")
41     self.setScaleMode("Vector")
42     self.setColorMode("Scalar")
43     self.setScaleFactor(0.3)
44 jongui 828
45 jongui 849 def setVectorMode(self, vector_mode):
46     eval("self.vtk_glyph.SetVectorModeToUse%s" % vector_mode)
47    
48     def setScaleMode(self, scale_mode):
49     eval("self.vtk_glyph.SetScaleModeToScaleBy%s" % scale_mode)
50    
51 jongui 828 def setScaleFactor(self, scale_factor):
52 jongui 835 """
53     Set the scale factor for the arrows.
54    
55     @type scale_factor: Number
56     @param scale_factor: Scale factor
57     """
58    
59 jongui 828 self.vtk_glyph.SetScaleFactor(scale_factor)
60    
61     def setColorMode(self, color_mode):
62 jongui 835 """
63     Set the color mode for the arrows.
64    
65     @type color_mode: String
66     @param color_mode: Color mode for the arrows (I{Scalar or Vector})
67     """
68    
69 jongui 828 eval("self.vtk_glyph.SetColorModeToColorBy%s()" % color_mode)
70 jongui 827
71 jongui 840
72     from arrows import Arrows
73 jongui 849 from plane import Plane
74 jongui 840
75     class ArrowsOnPlane(Arrows, Plane):
76     """
77 jongui 845 Class that shows a vector field by arrows on a given plane.
78 jongui 840 """
79    
80 jongui 845 def __init__(self, scene, data_collector, lut = None):
81     """
82     @type scene: L{Scene <scene.Scene>} object
83     @param scene: Scene in which components are to be added to
84     @type data_collector: L{DataCollector <datacollector.DataCollector>}
85     object
86    
87     @param data_collector: Source of data for visualization
88     """
89    
90 jongui 849 self.data_collector = data_collector
91     self.vtk_glyph = vtk.vtkGlyph3D()
92     Arrows.setArrows(self)
93 jongui 840
94     Plane.__init__(self, scene, data_collector,
95 jongui 849 self.vtk_glyph.GetOutput(), lut)
96 jongui 840

  ViewVC Help
Powered by ViewVC 1.1.26