/[escript]/temp_trunk_copy/pyvisi/py_src/light.py
ViewVC logotype

Diff of /temp_trunk_copy/pyvisi/py_src/light.py

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

trunk/pyvisi/py_src/light.py revision 1147 by ksteube, Wed May 16 06:39:11 2007 UTC temp_trunk_copy/pyvisi/py_src/light.py revision 1384 by phornby, Fri Jan 11 02:29:38 2008 UTC
# Line 1  Line 1 
1  """  """
2  @author: John NGUI  @var __author__: name of author
3    @var __copyright__: copyrights
4    @var __license__: licence agreement
5    @var __url__: url entry point on documentation
6    @var __version__: version
7    @var __date__: date of the version
8  """  """
9    
10    __author__="John Ngui, john.ngui@uq.edu.au"
11    __copyright__="""  Copyright (c) 2006 by ACcESS MNRF
12                        http://www.access.edu.au
13                    Primary Business: Queensland, Australia"""
14    __license__="""Licensed under the Open Software License version 3.0
15                 http://www.opensource.org/licenses/osl-3.0.php"""
16    __url__="http://www.iservo.edu.au/esys"
17    __version__="$Revision$"
18    __date__="$Date$"
19    
20    
21  import vtk  import vtk
22  from position import GlobalPosition  from position import GlobalPosition
23  from constant import Viewport  from constant import Viewport
# Line 14  class Light: Line 30  class Light:
30    
31      # The SOUTH_WEST default viewport is used when there is only one viewport.      # The SOUTH_WEST default viewport is used when there is only one viewport.
32      # This saves the user from specifying the viewport when there is only one.      # This saves the user from specifying the viewport when there is only one.
33      def __init__(self, scene, data_collector, viewport = Viewport.SOUTH_WEST):      def __init__(self, scene, viewport = Viewport.SOUTH_WEST):
34          """          """
35          Initialise the light.          Initialise the light.
36    
37          @type scene: L{Scene <scene.Scene>} object          @type scene: L{Scene <scene.Scene>} object
38          @param scene: Scene in which components are to be added to            @param scene: Scene in which components are to be added to  
         @type data_collector: L{DataCollector <datacollector.DataCollector>}  
             object  
         @param data_collector: Source of data for vizualization  
39          @type viewport: L{Viewport <constant.Viewport>} constant          @type viewport: L{Viewport <constant.Viewport>} constant
40          @param viewport: Viewport in which objects are to be rendered on          @param viewport: Viewport in which objects are to be rendered on
41          """          """
42    
         self.__scene = scene  
         self.__data_collector = data_collector  
43          self.__viewport = viewport          self.__viewport = viewport
44          self.__vtk_light = vtk.vtkLight()          self.__vtk_light = vtk.vtkLight()
45    
46          self.__setupLight()          # Keeps track whether light has been modified.
47            self.__modified = True
48            # Keeps track whether the modification to the light was due to the
49            # instantiation. If it is, then __setupLight() method is called.
50            self.__initialization = True
51            scene._addVisualizationModules(self)
52    
53      def __setupLight(self):      def __setupLight(self, scene):
54          """          """
55          Set up the light and associate it with the renderer.          Set up the light and associate it with the renderer.
56    
57            @type scene: L{Scene <scene.Scene>} object
58            @param scene: Scene in which objects are to be rendered on
59          """          """
60    
61          self.__scene._addLight(self.__viewport, self.__vtk_light)          scene._addLight(self.__viewport, self.__vtk_light)
62    
63      def setColor(self, color):      def setColor(self, color):
64          """          """
# Line 50  class Light: Line 69  class Light:
69          """          """
70    
71          self.__vtk_light.SetColor(color)          self.__vtk_light.SetColor(color)
72            self.__modified = True
73    
74      def setFocalPoint(self, position):      def setFocalPoint(self, position):
75          """          """
# Line 60  class Light: Line 80  class Light:
80          """          """
81    
82          self.__vtk_light.SetFocalPoint(position._getGlobalPosition())          self.__vtk_light.SetFocalPoint(position._getGlobalPosition())
83            self.__modified = True
84    
85      def setPosition(self, position):      def setPosition(self, position):
86          """          """
# Line 70  class Light: Line 91  class Light:
91          """          """
92    
93          self.__vtk_light.SetPosition(position._getGlobalPosition())          self.__vtk_light.SetPosition(position._getGlobalPosition())
94            self.__modified = True
95    
96      # Elevation and azimuth is set to zero so that users do not      # Elevation and azimuth is set to zero so that users do not
97      # have to change both at the same time.      # have to change both at the same time.
# Line 88  class Light: Line 110  class Light:
110          # constraint as the elevation angle of camera where the elevation          # constraint as the elevation angle of camera where the elevation
111          # angle is constraint between 90/-90.          # angle is constraint between 90/-90.
112          self.__vtk_light.SetDirectionAngle(elevation, azimuth)          self.__vtk_light.SetDirectionAngle(elevation, azimuth)
113            self.__modified = True
114    
115      def setIntensity(self, intensity):      def setIntensity(self, intensity):
116          """          """
# Line 98  class Light: Line 121  class Light:
121          """          """
122    
123          self.__vtk_light.SetIntensity(intensity)          self.__vtk_light.SetIntensity(intensity)
124            self.__modified = True
125    
126        def _isModified(self):
127            """
128            Return whether the Light has been modified.
129    
130            @rtype: Boolean
131            @return: True or False
132            """
133    
134            if (self.__modified == True):
135                return True
136            else:
137                return False
138    
139        def _render(self, scene):
140            """
141            Render the light.
142    
143            @type scene: L{Scene <scene.Scene>} object
144            @param scene: Scene in which objects are to be rendered on
145            """
146    
147            if(self._isModified() == True):
148                # Will only be true once only when the light is instantiated.
149                if(self.__initialization == True):
150                    self.__setupLight(scene)
151                    self.__initialization == False
152    
153                self.__modified = False
154                
155    

Legend:
Removed from v.1147  
changed lines
  Added in v.1384

  ViewVC Help
Powered by ViewVC 1.1.26