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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 827 by jongui, Wed Aug 30 00:08:02 2006 UTC revision 845 by jongui, Fri Sep 8 07:13:01 2006 UTC
# Line 1  Line 1 
1  """  """
2  class that shows a vector field by arrows  @author: John Ngui
3    @author: Lutz Gross
 @var __author__: name of author  
 @var __license__: licence agreement  
 @var __copyright__: copyrights  
 @var __url__: url entry point on documentation  
 @var __version__: version  
 @var __date__: date of the version  
4  """  """
 __copyright__="""  Copyright (c) 2006 by ACcESS MNRF  
                     http://www.access.edu.au  
                 Primary Business: Queensland, Australia"""  
 __license__="""Licensed under the Open Software License version 3.0  
              http://www.opensource.org/licenses/osl-3.0.php"""  
 __author__="Paul Cochrane, L. Gross"  
 __url__="http://www.iservo.edu.au/esys"  
 __version__="$Revision:$"  
 __date__="$Date:$"  
5    
6  import vtk  import vtk
7    from common import *
8    
9  class Arrows:  class Arrows(Common):
10        """
11        Class that shows a vector field by arrows.
12        """
13    
14        def __init__(self, scene, data_collector, lut = None):
15            """
16            @type scene: L{Scene <scene.Scene>} object
17            @param scene: Scene in which components are to be added to
18            @type data_collector: L{DataCollector <datacollector.DataCollector>}
19                object
20            @param data_collector: Source of data for visualization        
21            """
22    
23      def __init__(self, open_scene, data_collector):          Common.__init__(self, scene, data_collector)
         self.open_scene = open_scene  
         self.data_collector = data_collector  
24          self.vtk_glyph = None          self.vtk_glyph = None
         self.vtk_arrows_mapper = None  
         self.vtk_arrows_actor = None          
   
25          self.setArrows()          self.setArrows()
26          self.setMapper()  
27          self.setActor()          Common.setMapper(self, "self.vtk_glyph.GetOutput()", lut)
28            Common.setActor(self)
29            Common.addActor(self)      
30            
     # set up the glyph and use arrows as the source  
31      def setArrows(self):      def setArrows(self):
32            """
33            Set up the glyph and use arrows as the source.
34            """
35    
36          vtk_arrows = vtk.vtkArrowSource()          vtk_arrows = vtk.vtkArrowSource()
37                    
38          self.vtk_glyph = vtk.vtkGlyph3D()          self.vtk_glyph = vtk.vtkGlyph3D()
39          self.vtk_glyph.SetInput(self.data_collector.getReader().GetOutput())          self.vtk_glyph.SetInput(self.data_collector.getReader().GetOutput())
40          self.vtk_glyph.SetSource(vtk_arrows.GetOutput())          self.vtk_glyph.SetSource(vtk_arrows.GetOutput())
41          self.vtk_glyph.SetVectorModeToUseVector()          self.vtk_glyph.SetVectorModeToUseVector() # Default vector mode
42          self.vtk_glyph.SetScaleModeToScaleByVector()          self.vtk_glyph.SetScaleModeToScaleByVector() # Default scale mode
43          self.vtk_glyph.SetColorModeToColorByScalar()          self.setColorMode("Scalar") # Default color mode
44          self.vtk_glyph.SetScaleFactor(0.2)          self.setScaleFactor(0.2) # Default scale factor
45        
46      # set up the mapper and data          def setScaleFactor(self, scale_factor):
47      def setMapper(self):          """
48          self.vtk_arrows_mapper = vtk.vtkPolyDataMapper()          Set the scale factor for the arrows.
49          self.vtk_arrows_mapper.SetInput(  
50              self.vtk_glyph.GetOutput())          @type scale_factor: Number
51            @param scale_factor: Scale factor
52            """
53    
54            self.vtk_glyph.SetScaleFactor(scale_factor)
55    
56        def setColorMode(self, color_mode):
57            """
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      # set up the actor and add the actor to the scene            eval("self.vtk_glyph.SetColorModeToColorBy%s()" % color_mode)
     def setActor(self):  
         self.vtk_arrows_actor = vtk.vtkActor()  
         self.vtk_arrows_actor.SetMapper(self.vtk_arrows_mapper)  
65    
         self.open_scene.getRenderer().AddActor(self.vtk_arrows_actor)        
66    
67    from arrows import Arrows
68    from geo import Plane
69        
70    class ArrowsOnPlane(Arrows, Plane):
71        """
72        Class that shows a vector field by arrows on a given plane.
73        """
74    
75        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            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    
 #class ArrowsOnPlane:  
 """  
 shows a vector field by arrows on a plane  
 """  
 pass  

Legend:
Removed from v.827  
changed lines
  Added in v.845

  ViewVC Help
Powered by ViewVC 1.1.26