/[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 839 by jongui, Wed Sep 6 04:53:50 2006 UTC
# Line 1  Line 1 
1  """  """
 class that shows a vector field by arrows  
2    
3  @var __author__: name of author  @author: John Ngui
4  @var __license__: licence agreement  @author: Lutz Gross
 @var __copyright__: copyrights  
 @var __url__: url entry point on documentation  
 @var __version__: version  
 @var __date__: date of the version  
5  """  """
6  __copyright__="""  Copyright (c) 2006 by ACcESS MNRF  
7                      http://www.access.edu.au  import vtk
8                  Primary Business: Queensland, Australia"""  
9  __license__="""Licensed under the Open Software License version 3.0  class Common:
10               http://www.opensource.org/licenses/osl-3.0.php"""      """
11  __author__="Paul Cochrane, L. Gross"      Class that defines the common operations invoked by the components.
12  __url__="http://www.iservo.edu.au/esys"      """
13  __version__="$Revision:$"  
14  __date__="$Date:$"      def __init__(self, scene, data_collector):
15            """
16  class Property(object):          Initialize all the instance variables.
17      def __init__(self,val=None):  
18         self.setValue(val)          @type scene: L{OpenScene <scene.Scene>} object
19            @param scene: Scene in which components are to be added to
20      def setValue(self,val):          @type data_collector: L{DataCollector <datacollector.DataCollector>}
21         self.__val=val              object
22         self.__altered=True          @param data_collector: Source of data for visualization
23            """
24      def getValue(self):  
25         return self.__val          self.scene = scene
26            self.data_collector = data_collector
27      def isAltered(self):          self.vtk_mapper = None
28         return self.__altered          self.vtk_actor = None
29    
30      def markAsUsed(self):      def setMapper(self, component, lut = None):
31         self.__altered=False          """
32            Set up the mapper and its input.
33      
34  class Component(object):          @type component: String
35      """          @param component: Component to be mapped
36      shows a vector field by arrows          @type lut: L{BlueToRed <colormap.BlueToRed>} or
37      """              L{RedToBlue <colormap.RedToBlue>} object
38      def __init__(self):          @param lut: Color lookup table to be used by the mapper
39         self.features={} # item must be a Component or Property          """
40    
41      def render(self):          self.vtk_mapper = vtk.vtkDataSetMapper()
42         for i in self.features:          eval("self.vtk_mapper.SetInput(%s)" % component)
43            if isinstance(self.features[i],Component):          
44               self.features[i].render()          if(lut != None):
45         self._render()              self.vtk_mapper.SetLookupTable(lut.getLut())    
46    
47      def markFeaturesAsUsed(self):      def setActor(self):
48         for i in self.features:          """
49            if isinstance(self.features[i],Component):          Set up the actor and its mapper.
50               self.features[i].markAsUsed()          """
51            else:  
52               self.features[i].markFeaturesAsUsed()          self.vtk_actor = vtk.vtkActor()
53            self.vtk_actor.SetMapper(self.vtk_mapper)
54    
55        def addActor(self):
56            """
57            Add the actor to the renderer.
58            """
59    
60            self.scene.getRenderer().AddActor(self.vtk_actor)
61    
62        def setOpacity(self, opacity):
63            """
64            Set the opacity (transparency) of the actor.
65    
66            @type opacity: Number
67            @param opacity: Opacity (transparency) of the actor
68            """
69    
70            self.getProperty().SetOpacity(opacity)
71    
72        def setColor(self, red, green, blue):
73            self.getProperty().SetColor(red, green, blue)
74    
75        def setRepresentation(self, representation):
76            """
77            Set the representation of the actor.
78    
79            @type representation: String
80            @param representation: Representation type (I{i.e. Wireframe})
81            """
82    
83            eval("self.getProperty().SetRepresentationTo%s()" % representation)
84        
85        def getProperty(self):
86            """
87            Return the property of the actor.
88    
89            @rtype: vtkProperty
90            @return: VTK property  
91            """
92    
93            return self.vtk_actor.GetProperty()
94    
95            
96    class Component:
97         pass

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

  ViewVC Help
Powered by ViewVC 1.1.26