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

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

  ViewVC Help
Powered by ViewVC 1.1.26