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

Diff of /trunk/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 1148 by jongui, Wed May 16 22:45:33 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    
27          self.__scene = scene          self.__scene = scene
         self.__data_collector = data_collector  
28          self.__viewport = viewport          self.__viewport = viewport
29          self.__vtk_light = vtk.vtkLight()          self.__vtk_light = vtk.vtkLight()
30    
31          self.__setupLight()          # Keeps track whether light has been modified.
32            self.__modified = True
33            # Keeps track whether the modification to the light was due to the
34            # instantiation. If it is, then __setupLight() method is called.
35            self.__initialization = True
36            self.__scene._addVisualizationModules(self)
37    
38      def __setupLight(self):      def __setupLight(self):
39          """          """
# Line 50  class Light: Line 51  class Light:
51          """          """
52    
53          self.__vtk_light.SetColor(color)          self.__vtk_light.SetColor(color)
54            self.__modified = True
55    
56      def setFocalPoint(self, position):      def setFocalPoint(self, position):
57          """          """
# Line 60  class Light: Line 62  class Light:
62          """          """
63    
64          self.__vtk_light.SetFocalPoint(position._getGlobalPosition())          self.__vtk_light.SetFocalPoint(position._getGlobalPosition())
65            self.__modified = True
66    
67      def setPosition(self, position):      def setPosition(self, position):
68          """          """
# Line 70  class Light: Line 73  class Light:
73          """          """
74    
75          self.__vtk_light.SetPosition(position._getGlobalPosition())          self.__vtk_light.SetPosition(position._getGlobalPosition())
76            self.__modified = True
77    
78      # Elevation and azimuth is set to zero so that users do not      # Elevation and azimuth is set to zero so that users do not
79      # have to change both at the same time.      # have to change both at the same time.
# Line 88  class Light: Line 92  class Light:
92          # constraint as the elevation angle of camera where the elevation          # constraint as the elevation angle of camera where the elevation
93          # angle is constraint between 90/-90.          # angle is constraint between 90/-90.
94          self.__vtk_light.SetDirectionAngle(elevation, azimuth)          self.__vtk_light.SetDirectionAngle(elevation, azimuth)
95            self.__modified = True
96    
97      def setIntensity(self, intensity):      def setIntensity(self, intensity):
98          """          """
# Line 98  class Light: Line 103  class Light:
103          """          """
104    
105          self.__vtk_light.SetIntensity(intensity)          self.__vtk_light.SetIntensity(intensity)
106            self.__modified = True
107    
108        def _isModified(self):
109            """
110            Return whether the Light has been modified.
111    
112            @rtype: Boolean
113            @return: True or False
114            """
115    
116            if (self.__modified == True):
117                return True
118            else:
119                return False
120    
121        def _render(self):
122            """
123            Render the light.
124            """
125    
126            if(self._isModified() == True):
127                # Will only be true once only when the light is instantiated.
128                if(self.__initialization == True):
129                    self.__setupLight()
130                    self.__initialization == False
131    
132                self.__isModified = False
133                
134    

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

  ViewVC Help
Powered by ViewVC 1.1.26