/[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 834 by jongui, Fri Sep 1 07:48:20 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  """  """
 __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:$"  
4    
5  import vtk  import vtk
6    
 class Component:  
      pass  
   
7  class Common:  class Common:
8        """
9        @author: John Ngui
10        @author: Lutz Gross
11        """
12    
13      def __init__(self, open_scene, data_collector):      def __init__(self, open_scene, data_collector):
14            """
15            Initialize all the instance variables.
16    
17            @type open_scene: L{OpenScene <openscene.OpenScene>} object
18            @param open_scene: Scene in which components are to be added to
19            @type data_collector: L{DataCollector <datacollector.DataCollector>}
20                object
21            @param data_collector: Source of data for visualization
22            """
23    
24          self.open_scene = open_scene          self.open_scene = open_scene
25          self.data_collector = data_collector          self.data_collector = data_collector
26          self.vtk_mapper = None          self.vtk_mapper = None
27          self.vtk_actor = None          self.vtk_actor = None
28    
29      def setMapper(self, component):      def setMapper(self, component):
30            """
31            Set up the mapper and its input.
32    
33            @type component: String
34            @param component: Component to be mapped
35            """
36    
37          self.vtk_mapper = vtk.vtkDataSetMapper()          self.vtk_mapper = vtk.vtkDataSetMapper()
38          eval("self.vtk_mapper.SetInput(%s)" % component)          eval("self.vtk_mapper.SetInput(%s)" % component)
39    
40      def setActor(self):      def setActor(self):
41            """
42            Set up the actor and its mapper.
43            """
44    
45          self.vtk_actor = vtk.vtkActor()          self.vtk_actor = vtk.vtkActor()
46          self.vtk_actor.SetMapper(self.vtk_mapper)          self.vtk_actor.SetMapper(self.vtk_mapper)
47    
48      def addActor(self):      def addActor(self):
49            """
50            Add the actor to the renderer.
51            """
52    
53          self.open_scene.getRenderer().AddActor(self.vtk_actor)          self.open_scene.getRenderer().AddActor(self.vtk_actor)
54    
55      def setOpacity(self, opacity):      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)          self.getProperty().SetOpacity(opacity)
64    
65      def setColor(self, red, green, blue):      def setColor(self, red, green, blue):
66          self.getProperty().SetColor(red, green, blue)          self.getProperty().SetColor(red, green, blue)
67    
68      def setRepresentation(self, representation):      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)          eval("self.getProperty().SetRepresentationTo%s()" % representation)
77            
78      def getProperty(self):      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()          return self.vtk_actor.GetProperty()
87    
88                    
89    class Component:
90         pass

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

  ViewVC Help
Powered by ViewVC 1.1.26