/[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

revision 1147 by ksteube, Wed May 16 06:39:11 2007 UTC revision 1158 by jongui, Tue May 22 04:24:01 2007 UTC
# Line 14  class Light: Line 14  class Light:
14    
15      # 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.
16      # 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.
17      def __init__(self, scene, data_collector, viewport = Viewport.SOUTH_WEST):      def __init__(self, scene, viewport = Viewport.SOUTH_WEST):
18          """          """
19          Initialise the light.          Initialise the light.
20    
21          @type scene: L{Scene <scene.Scene>} object          @type scene: L{Scene <scene.Scene>} object
22          @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  
23          @type viewport: L{Viewport <constant.Viewport>} constant          @type viewport: L{Viewport <constant.Viewport>} constant
24          @param viewport: Viewport in which objects are to be rendered on          @param viewport: Viewport in which objects are to be rendered on
25          """          """
26    
         self.__scene = scene  
         self.__data_collector = data_collector  
27          self.__viewport = viewport          self.__viewport = viewport
28          self.__vtk_light = vtk.vtkLight()          self.__vtk_light = vtk.vtkLight()
29    
30          self.__setupLight()          # Keeps track whether light has been modified.
31            self.__modified = True
32            # Keeps track whether the modification to the light was due to the
33            # instantiation. If it is, then __setupLight() method is called.
34            self.__initialization = True
35            scene._addVisualizationModules(self)
36    
37      def __setupLight(self):      def __setupLight(self, scene):
38          """          """
39          Set up the light and associate it with the renderer.          Set up the light and associate it with the renderer.
40    
41            @type scene: L{Scene <scene.Scene>} object
42            @param scene: Scene in which objects are to be rendered on
43          """          """
44    
45          self.__scene._addLight(self.__viewport, self.__vtk_light)          scene._addLight(self.__viewport, self.__vtk_light)
46    
47      def setColor(self, color):      def setColor(self, color):
48          """          """
# Line 50  class Light: Line 53  class Light:
53          """          """
54    
55          self.__vtk_light.SetColor(color)          self.__vtk_light.SetColor(color)
56            self.__modified = True
57    
58      def setFocalPoint(self, position):      def setFocalPoint(self, position):
59          """          """
# Line 60  class Light: Line 64  class Light:
64          """          """
65    
66          self.__vtk_light.SetFocalPoint(position._getGlobalPosition())          self.__vtk_light.SetFocalPoint(position._getGlobalPosition())
67            self.__modified = True
68    
69      def setPosition(self, position):      def setPosition(self, position):
70          """          """
# Line 70  class Light: Line 75  class Light:
75          """          """
76    
77          self.__vtk_light.SetPosition(position._getGlobalPosition())          self.__vtk_light.SetPosition(position._getGlobalPosition())
78            self.__modified = True
79    
80      # Elevation and azimuth is set to zero so that users do not      # Elevation and azimuth is set to zero so that users do not
81      # have to change both at the same time.      # have to change both at the same time.
# Line 88  class Light: Line 94  class Light:
94          # constraint as the elevation angle of camera where the elevation          # constraint as the elevation angle of camera where the elevation
95          # angle is constraint between 90/-90.          # angle is constraint between 90/-90.
96          self.__vtk_light.SetDirectionAngle(elevation, azimuth)          self.__vtk_light.SetDirectionAngle(elevation, azimuth)
97            self.__modified = True
98    
99      def setIntensity(self, intensity):      def setIntensity(self, intensity):
100          """          """
# Line 98  class Light: Line 105  class Light:
105          """          """
106    
107          self.__vtk_light.SetIntensity(intensity)          self.__vtk_light.SetIntensity(intensity)
108            self.__modified = True
109    
110        def _isModified(self):
111            """
112            Return whether the Light has been modified.
113    
114            @rtype: Boolean
115            @return: True or False
116            """
117    
118            if (self.__modified == True):
119                return True
120            else:
121                return False
122    
123        def _render(self, scene):
124            """
125            Render the light.
126    
127            @type scene: L{Scene <scene.Scene>} object
128            @param scene: Scene in which objects are to be rendered on
129            """
130    
131            if(self._isModified() == True):
132                # Will only be true once only when the light is instantiated.
133                if(self.__initialization == True):
134                    self.__setupLight(scene)
135                    self.__initialization == False
136    
137                self.__isModified = False
138                
139    

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

  ViewVC Help
Powered by ViewVC 1.1.26