/[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 849 by jongui, Fri Sep 15 07:11:55 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):          Initialize all the instance variables.
16      def __init__(self,val=None):  
17         self.setValue(val)          @type scene: L{Scene <scene.Scene>} object
18            @param scene: Scene in which components are to be added to
19      def setValue(self,val):          @type data_collector: L{DataCollector <datacollector.DataCollector>}
20         self.__val=val              object
21         self.__altered=True          @param data_collector: Source of data for visualization
22            """
23      def getValue(self):  
24         return self.__val          self.scene = scene
25            self.data_collector = data_collector
26      def isAltered(self):          self.vtk_mapper = vtk.vtkDataSetMapper()
27         return self.__altered          self.vtk_actor = vtk.vtkActor()
28    
29      def markAsUsed(self):      def setMapperInput(self, component, lut = None):
30         self.__altered=False          """
31            Set up the mapper and its input.
32      
33  class Component(object):          @type component: String
34      """          @param component: Component to be mapped
35      shows a vector field by arrows          @type lut: L{BlueToRed <colormap.BlueToRed>} or
36      """              L{RedToBlue <colormap.RedToBlue>} object
37      def __init__(self):          @param lut: Color lookup table to be used by the mapper
38         self.features={} # item must be a Component or Property          """
39    
40      def render(self):          self.vtk_mapper.SetInput(component)
41         for i in self.features:          #eval("self.vtk_mapper.SetInput(%s)" % component)
42            if isinstance(self.features[i],Component):          
43               self.features[i].render()          if(lut != None):
44         self._render()              self.vtk_mapper.SetLookupTable(lut.getLut())    
45    
46      def markFeaturesAsUsed(self):      def setMapperTexture(self, texture):
47         for i in self.features:          """
48            if isinstance(self.features[i],Component):          Set the texture of the actor.
49               self.features[i].markAsUsed()  
50            else:          @type texture: vtkTexture
51               self.features[i].markFeaturesAsUsed()          @param texture: Texture map of the image
52            """
53            self.vtk_actor.SetTexture(texture)
54    
55        def setActorInput(self):
56            """
57            Set up the actor and its mapper.
58            """
59            self.vtk_actor.SetMapper(self.vtk_mapper)
60    
61    
62        def addActor(self):
63            """
64            Add the actor to the renderer.
65            """
66    
67            self.scene.getRenderer().AddActor(self.vtk_actor)
68    
69        def setActorOpacity(self, opacity):
70            """
71            Set the opacity (transparency) of the actor.
72    
73            @type opacity: Number
74            @param opacity: Opacity (transparency) of the actor
75            """
76    
77            self.vtk_actor.GetProperty().SetOpacity(opacity)
78    
79        def setActorColor(self, color):
80            self.vtk_actor.GetProperty().SetColor(color[0], color[1],
81                color[2])
82    
83        def setActorRepresentation(self, representation):
84            """
85            Set the representation of the actor.
86    
87            @type representation: String
88            @param representation: Representation type (I{i.e. Wireframe})
89            """
90    
91            eval("self.vtk_actor.GetProperty().SetRepresentationTo%s()" %
92                representation)
93        
94    
95    class Component:
96         pass

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

  ViewVC Help
Powered by ViewVC 1.1.26