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

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

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

revision 802 by gross, Wed Aug 9 09:21:00 2006 UTC revision 879 by jongui, Wed Oct 25 03:56:34 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  """  """
5  __copyright__="""  Copyright (c) 2006 by ACcESS MNRF  
6                      http://www.access.edu.au  import vtk
7                  Primary Business: Queensland, Australia"""  
8  __license__="""Licensed under the Open Software License version 3.0  class Common:
9               http://www.opensource.org/licenses/osl-3.0.php"""      """
10  __author__="Paul Cochrane, L. Gross"      Class that defines the common operations invoked by the components.
11  __url__="http://www.iservo.edu.au/esys"      """
12  __version__="$Revision:$"  
13  __date__="$Date:$"      def __init__(self, scene, data_collector = None):
14            """
15  class Property(object):          @type scene: L{Scene <scene.Scene>} object
16      def __init__(self,val=None):          @param scene: Scene in which components are to be added to
17         self.setValue(val)          @type data_collector: L{DataCollector <datacollector.DataCollector>}
18                object
19      def setValue(self,val):          @param data_collector: Source of data for visualization
20         self.__val=val          """
21         self.__altered=True  
22            self.scene = scene
23      def getValue(self):          self.data_collector = data_collector
24         return self.__val          self.vtk_mapper = vtk.vtkDataSetMapper()
25            self.vtk_actor = vtk.vtkActor()
26      def isAltered(self):  
27         return self.__altered      def setMapperInput(self, component, lut = None):
28            """
29      def markAsUsed(self):          Set up the mapper.
30         self.__altered=False          @type component: String
31            @param component: Component to be mapped
32              @type lut: L{BlueToRed <colormap.BlueToRed>} or
33  class Component(object):              L{RedToBlue <colormap.RedToBlue>} object
34      """          @param lut: Lookup table to be used by the mapper
35      shows a vector field by arrows          """
36      """          
37      def __init__(self):          # Convert unstructured grid data to polygonal data.
38         self.features={} # item must be a Component or Property          vtk_geometry = vtk.vtkGeometryFilter()
39            vtk_geometry.SetInput(component)
40      def render(self):  
41         for i in self.features:          # Compute normals to ensure consistent orientation across neighbours.
42            if isinstance(self.features[i],Component):          # This results in a better object being rendered.
43               self.features[i].render()          #vtk_normals = vtk.vtkPolyDataNormals()
44         self._render()          #vtk_normals.SetInput(vtk_geometry.GetOutput())
45    
46      def markFeaturesAsUsed(self):          #self.vtk_mapper.SetInput(vtk_normals.GetOutput())
47         for i in self.features:          #self.vtk_mapper.SetInput(vtk_geometry.GetOutput())
48            if isinstance(self.features[i],Component):          self.vtk_mapper.SetInput(component)
49               self.features[i].markAsUsed()  
50            else:      
51               self.features[i].markFeaturesAsUsed()          # Mapper uses the customized lookup table only if it is specified.
52            # Otherwise, the default one is used.
53            if(lut != None):
54                self.vtk_mapper.SetLookupTable(lut.getLut())    
55    
56        def setActorTexture(self, texture):
57            """
58            Set the texture of the actor.
59            @type texture: vtkTexture
60            @param texture: Texture map of the image
61            """
62    
63            self.vtk_actor.SetTexture(texture)
64    
65        def setActorInput(self):
66            """
67            Set up the actor.
68            """
69    
70            self.vtk_actor.SetMapper(self.vtk_mapper)
71    
72    
73        def addActor(self):
74            """
75            Add the actor to the renderer.
76            """
77    
78            self.scene.getRenderer().AddActor(self.vtk_actor)
79    
80        def setActorOpacity(self, opacity):
81            """
82            Set the opacity (transparency) of the actor.
83            @type opacity: Number
84            @param opacity: Opacity (transparency) of the actor
85            """
86    
87            self.vtk_actor.GetProperty().SetOpacity(opacity)
88    
89        def setActorColor(self, color):
90            """
91            Set the color of the actor.
92            @type color: RGB list
93            @param color: Color of the actor
94            """
95            
96            self.vtk_actor.GetProperty().SetColor(color[0], color[1],
97                color[2])
98    
99        def setActorRepresentation(self, representation):
100            """
101            Set the representation of the actor.
102            @type representation: String
103            @param representation: Actor representation type (I{i.e. Wireframe})
104            """
105    
106            eval("self.vtk_actor.GetProperty().SetRepresentationTo%s()" %
107                representation)
108        
109    
110    class Component:
111         pass

Legend:
Removed from v.802  
changed lines
  Added in v.879

  ViewVC Help
Powered by ViewVC 1.1.26