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

Diff of /trunk/pyvisi/py_src/velocity.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 1199 by jongui, Wed Jun 20 05:01:30 2007 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 mapper import DataSetMapper  from mapper import DataSetMapper
23  from lookuptable import LookupTable  from lookuptable import LookupTable
24  from actor import Actor3D  from actor import Actor3D
25  from constant import Viewport, Color, Arrow, ColorMode, Lut, VizType  from constant import Viewport, Color, Arrow, ColorMode, Lut
26  from arrow import Arrow2D, Arrow3D  from arrow import Arrow2D, Arrow3D
27  from glyph import  Glyph3D  from glyph import  Glyph3D
28  from outline import Outline  from outline import Outline
# Line 28  class Velocity(DataSetMapper, Actor3D, A Line 44  class Velocity(DataSetMapper, Actor3D, A
44      # 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.
45      # 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.
46      # If no lut is specified, the color scheme will be used.      # If no lut is specified, the color scheme will be used.
47      def __init__(self, scene, data_collector, viewport = Viewport.SOUTH_WEST,      def __init__(self, scene, data_collector, arrow = Arrow.TWO_D,
48              color_mode = ColorMode.VECTOR, arrow = Arrow.TWO_D,                color_mode = ColorMode.VECTOR, viewport = Viewport.SOUTH_WEST,  
49              lut = Lut.COLOR, cell_to_point = False, outline = True):              lut = Lut.COLOR, cell_to_point = False, outline = True):
50          """          """
51          Initialise the Velocity.          Initialise the Velocity.
# Line 38  class Velocity(DataSetMapper, Actor3D, A Line 54  class Velocity(DataSetMapper, Actor3D, A
54          source is cell data, a conversion to point data may or may not be          source is cell data, a conversion to point data may or may not be
55          required, in order for the object to be rendered correctly.          required, in order for the object to be rendered correctly.
56          If a conversion is needed, the 'cell_to_point' flag must be set to          If a conversion is needed, the 'cell_to_point' flag must be set to
57          'True', otherwise 'False' (which is the default).          'True', otherwise 'False' (which is the default). On occasions, an
58            inaccurate object may be rendered from cell data even after conversion.
59    
60          @type scene: L{Scene <scene.Scene>} object          @type scene: L{Scene <scene.Scene>} object
61          @param scene: Scene in which objects are to be rendered on          @param scene: Scene in which objects are to be rendered on
62          @type data_collector: L{DataCollector <datacollector.DataCollector>}          @type data_collector: L{DataCollector <datacollector.DataCollector>}
63                  object                  object
64          @param data_collector: Deal with source of data for visualisation          @param data_collector: Deal with source of data for visualisation
         @type viewport: L{Viewport <constant.Viewport>} constant  
         @param viewport: Viewport in which objects are to be rendered on  
         @type color_mode: L{ColorMode <constant.ColorMode>} constant  
         @param color_mode: Type of color mode  
65          @type arrow: L{Arrow <constant.Arrow>} constant          @type arrow: L{Arrow <constant.Arrow>} constant
66          @param arrow: Type of arrow (two dimensional or three dimensional)          @param arrow: Type of arrow (two dimensional or three dimensional)
67            @type color_mode: L{ColorMode <constant.ColorMode>} constant
68            @param color_mode: Type of color mode
69            @type viewport: L{Viewport <constant.Viewport>} constant
70            @param viewport: Viewport in which objects are to be rendered on
71          @type lut : L{Lut <constant.Lut>} constant          @type lut : L{Lut <constant.Lut>} constant
72          @param lut: Lookup table color scheme          @param lut: Lookup table color scheme
73          @type cell_to_point: Boolean          @type cell_to_point: Boolean
# Line 59  class Velocity(DataSetMapper, Actor3D, A Line 76  class Velocity(DataSetMapper, Actor3D, A
76          @param outline: Places an outline around the domain surface          @param outline: Places an outline around the domain surface
77          """          """
78    
79          # NOTE: Actor3D is inherited and there are two instances declared here.          self.__data_collector = data_collector
80          # As a result, when methods from Actor3D is invoked from the driver,          self.__arrow = arrow
81          # only the methods associated with the latest instance (which in this          self.__color_mode = color_mode
82          # case is the Actor3D for the Velocity) can be executed. Actor3D          self.__viewport = viewport
83          # methods associated with Outline cannot be invoked from the driver.          self.__lut = lut
84          # They can only be called within here, which is why Outline must be          self.__cell_to_point = cell_to_point
85          # place before Velocity as there is unlikely to be any changes          self.__outline = outline
86          # made to the Outline's Actor3D.          
87            self.__modified = True # Keeps track whether Velocity has been modified.
88          # ----- Outline -----          MaskPoints.__init__(self)
89            Glyph3D.__init__(self)
90          if(outline == True):          DataSetMapper.__init__(self)
91              outline = Outline(data_collector._getOutput())          Actor3D.__init__(self)
92              DataSetMapper.__init__(self, outline._getOutput())          scene._addVisualizationModules(self)
93    
94            # ----- Outline -----
95    
96            # NOTE: Changes cannot be made to the Outline's properties from the
97            # driver.
98            if(self.__outline == True):
99                outline = Outline(self.__data_collector._getDataCollectorOutput())
100                mapper = DataSetMapper()
101                mapper._setupDataSetMapper(outline._getOutlineOutput())
102    
103              Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))              actor3D = Actor3D()
104                actor3D._setupActor3D(mapper._getDataSetMapper())
105              # Default outline color is black.              # Default outline color is black.
106              Actor3D.setColor(self, Color.BLACK)              actor3D.setColor(Color.BLACK)
107    
108              # Default line width is 1.              # Default line width is 1.
109              Actor3D._setLineWidth(self, 1)              actor3D._setLineWidth(1)
110              scene._addActor3D(viewport, Actor3D._getActor3D(self))              scene._addActor3D(self.__viewport, actor3D._getActor3D())
111    
112          # ----- Velocity -----          # ----- Velocity -----
113    
114          # NOTE: Lookup table color mapping (color or grey scale) MUST be set          # NOTE: Lookup table color mapping (color or grey scale) MUST be set
115          # before DataSetMapper. If it is done after DataSetMapper, no effect          # before DataSetMapper. If it is done after DataSetMapper, no effect
116          # will take place.          # will take place.
117          if(lut == Lut.COLOR): # Colored lookup table.          if(self.__lut == Lut.COLOR): # Colored lookup table.
118              lookup_table = LookupTable()              lookup_table = LookupTable()
119              lookup_table._setTableValue()              lookup_table._setTableValue()
120          elif(lut == Lut.GREY_SCALE): # Grey scaled lookup table.          elif(self.__lut == Lut.GREY_SCALE): # Grey scaled lookup table.
121              lookup_table = LookupTable()              lookup_table = LookupTable()
122              lookup_table._setLookupTableToGreyScale()              lookup_table._setLookupTableToGreyScale()
123                    
124          if(cell_to_point == True): # Converts cell data to point data.          if(self.__cell_to_point == True): # Converts cell data to point data.
125              c2p = CellDataToPointData(data_collector._getOutput())              c2p = CellDataToPointData(
126              MaskPoints.__init__(self, c2p._getOutput())                      self.__data_collector._getDataCollectorOutput())
127          elif(cell_to_point == False): # No conversion happens.                self._setupMaskPoints(c2p._getCellToPointOutput())
128              MaskPoints.__init__(self, data_collector._getOutput())          elif(self.__cell_to_point == False): # No conversion happens.  
129                self._setupMaskPoints(data_collector._getDataCollectorOutput())
130            
131          if(arrow == Arrow.TWO_D): # Use 2D arrows.          if(self.__arrow == Arrow.TWO_D): # Use 2D arrows.
132              Arrow2D.__init__(self)              Arrow2D.__init__(self)
133              Glyph3D.__init__(self, MaskPoints._getOutput(self),              self._setupGlyph3D(self._getMaskPointsOutput(),
134                      Arrow2D._getOutput(self))                      self._getArrow2DOutput())
135          elif(arrow == Arrow.THREE_D): # Use 3D arrows.          elif(arrow == Arrow.THREE_D): # Use 3D arrows.
136              Arrow3D.__init__(self)              Arrow3D.__init__(self)
137              Glyph3D.__init__(self, MaskPoints._getOutput(self),              self._setupGlyph3D(self._getMaskPointsOutput(),
138                      Arrow3D._getOutput(self))                      self._getArrow3DOutput())
139    
140          DataSetMapper.__init__(self, Glyph3D._getOutput(self),          self._setupDataSetMapper(self._getGlyph3DOutput(),
141                  lookup_table._getLookupTable())                  lookup_table._getLookupTable())
142    
143          if(color_mode == ColorMode.VECTOR): # Color velocity by vector.          self._setupActor3D(self._getDataSetMapper())
144              Glyph3D._setColorModeByVector(self)          scene._addActor3D(self.__viewport, self._getActor3D())
             Glyph3D._setRange(self, data_collector._getVectorRange())  
             DataSetMapper._setScalarRange(self,  
                     data_collector._getVectorRange())  
             data_collector._paramForUpdatingMultipleSources(VizType.VELOCITY,  
                     ColorMode.VECTOR, DataSetMapper._getDataSetMapper(self),  
                     Glyph3D._getGlyph3D(self))  
   
         elif(color_mode == ColorMode.SCALAR): # Color velocity by scalar.  
             Glyph3D._setColorModeByScalar(self)  
             Glyph3D._setRange(self, data_collector._getScalarRange())  
             DataSetMapper._setScalarRange(self,  
                     data_collector._getScalarRange())  
             data_collector._paramForUpdatingMultipleSources(VizType.VELOCITY,  
                     ColorMode.SCALAR, DataSetMapper._getDataSetMapper(self),  
                     Glyph3D._getGlyph3D(self))  
145    
146          Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))      def _isModified(self):  
147          scene._addActor3D(viewport, Actor3D._getActor3D(self))          """
148            Return whether the Velocity or DataCollector has been modified.
149    
150            @rtype: Boolean
151            @return: True or False
152            """
153    
154            return self.__modified or self.__data_collector._isModified()
155    
156        def _render(self, scene):
157            """
158            Render the velocity.
159    
160            @type scene: L{Scene <scene.Scene>} object
161            @param scene: Scene in which objects are to be rendered on
162            """
163    
164            if (self._isModified() == True):
165                if(self.__data_collector._isScalarSet() == True):
166                    self.__data_collector._setActiveScalar()
167                if(self.__data_collector._isVectorSet() == True):
168                    self.__data_collector._setActiveVector()
169    
170                # Color velocity by vector.
171                if(self.__color_mode == ColorMode.VECTOR):              
172                    self._setColorModeByVector()
173    
174                    # self._isScalarRangeSet checks whether the scalar range has
175                    # been specified by the user. If it has, then the scalar range
176                    # read from the source will be ignored.
177                    if(not(self._isScalarRangeSet())):
178                        self._setRange(self.__data_collector._getVectorRange())
179                        self._setScalarRange(\
180                                self.__data_collector._getVectorRange())
181                    else:
182                        self._setRange(self._getDataSetMapperRange())
183                        
184                # Color velocity by scalar.
185                elif(self.__color_mode == ColorMode.SCALAR):                
186                    self._setColorModeByScalar()
187    
188                    # self._isScalarRangeSet checks whether the scalar range has
189                    # been specified by the user. If it has, then the scalar range
190                    # read from the source will be ignored.
191                    if(not(self._isScalarRangeSet())):
192                        self._setRange(self.__data_collector._getScalarRange())
193                        self._setScalarRange(\
194                                self.__data_collector._getScalarRange())
195                    else:
196                        self._setRange(self._getDataSetMapperRange())
197    
198                self.__modified = False
199    
200    
201  ###############################################################################  ###############################################################################
# Line 148  class VelocityOnPlaneCut(DataSetMapper, Line 212  class VelocityOnPlaneCut(DataSetMapper,
212          Glyph3D, Transform, Plane, Cutter, MaskPoints):          Glyph3D, Transform, Plane, Cutter, MaskPoints):
213      """      """
214      This class works in a similar way to L{MapOnPlaneCut <map.MapOnPlaneCut>},      This class works in a similar way to L{MapOnPlaneCut <map.MapOnPlaneCut>},
215      except that it shows a vector field using arrows on a plane.      except that it shows a vector field using arrows cut using a plane.
216      """      """
217    
218      # 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.
# Line 164  class VelocityOnPlaneCut(DataSetMapper, Line 228  class VelocityOnPlaneCut(DataSetMapper,
228          source is cell data, a conversion to point data may or may not be          source is cell data, a conversion to point data may or may not be
229          required, in order for the object to be rendered correctly.          required, in order for the object to be rendered correctly.
230          If a conversion is needed, the 'cell_to_point' flag must be set to          If a conversion is needed, the 'cell_to_point' flag must be set to
231          'True', otherwise 'False' (which is the default).          'True', otherwise 'False' (which is the default). On occasions, an
232            inaccurate object may be rendered from cell data even after conversion.
233    
234          @type scene: L{Scene <scene.Scene>} object          @type scene: L{Scene <scene.Scene>} object
235          @param scene: Scene in which objects are to be rendered on          @param scene: Scene in which objects are to be rendered on
# Line 185  class VelocityOnPlaneCut(DataSetMapper, Line 250  class VelocityOnPlaneCut(DataSetMapper,
250          @param outline: Places an outline around the domain surface          @param outline: Places an outline around the domain surface
251          """          """
252    
253          # NOTE: Actor3D is inherited and there are two instances declared here.          self.__data_collector = data_collector
254          # As a result, when methods from Actor3D is invoked from the driver,          self.__arrow = arrow
255          # only the methods associated with the latest instance (which in this          self.__color_mode = color_mode
256          # case is the Actor3D for the Velocity) can be executed. Actor3D          self.__viewport = viewport
257          # methods associated with Outline cannot be invoked from the driver.          self.__lut = lut
258          # They can only be called within here, which is why Outline must be          self.__cell_to_point = cell_to_point
259          # place before Velocity as there is unlikely to be any changes          self.__outline = outline
260          # made to the Outline's Actor3D.          
261            # Keeps track whether VelocityOnPlaneCut has been modified.
262          # ----- Outline -----          self.__modified = True
263            Transform.__init__(self)
264          if(outline == True):          Plane.__init__(self)
265              outline = Outline(data_collector._getOutput())          Cutter.__init__(self)
266              DataSetMapper.__init__(self, outline._getOutput())          MaskPoints.__init__(self)
267            Glyph3D.__init__(self)
268            DataSetMapper.__init__(self)
269            Actor3D.__init__(self)
270            scene._addVisualizationModules(self)
271    
272            # ----- Outline -----
273    
274            # NOTE: Changes cannot be made to the Outline's properties from the
275            # driver.
276            if(self.__outline == True):
277                outline = Outline(self.__data_collector._getDataCollectorOutput())
278                mapper = DataSetMapper()
279                mapper._setupDataSetMapper(outline._getOutlineOutput())
280    
281              Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))              actor3D = Actor3D()
282                actor3D._setupActor3D(mapper._getDataSetMapper())
283              # Default outline color is black.              # Default outline color is black.
284              Actor3D.setColor(self, Color.BLACK)              actor3D.setColor(Color.BLACK)
285    
286              # Default line width is 1.              # Default line width is 1.
287              Actor3D._setLineWidth(self, 1)              actor3D._setLineWidth(1)
288              scene._addActor3D(viewport, Actor3D._getActor3D(self))              scene._addActor3D(self.__viewport, actor3D._getActor3D())
289    
290          # ----- Velocity on a cut plane -----          # ----- Velocity on a cut plane -----
291    
# Line 220  class VelocityOnPlaneCut(DataSetMapper, Line 299  class VelocityOnPlaneCut(DataSetMapper,
299              lookup_table = LookupTable()              lookup_table = LookupTable()
300              lookup_table._setLookupTableToGreyScale()              lookup_table._setLookupTableToGreyScale()
301    
302          Transform.__init__(self)              self._setupPlane(self._getTransform())
         Plane.__init__(self, Transform._getTransform(self))  
303    
304          if(cell_to_point == True): # Converts cell data to point data.          if(self.__cell_to_point == True): # Converts cell data to point data.
305              c2p = CellDataToPointData(data_collector._getOutput())              c2p = CellDataToPointData(
306              Cutter.__init__(self, c2p._getOutput(), Plane._getPlane(self))                        self.__data_collector._getDataCollectorOutput())
307          elif(cell_to_point == False): # No conversion happens.                self._setupCutter(c2p._getCellToPointOutput(), self._getPlane())    
308              Cutter.__init__(self, data_collector._getOutput(),          elif(self.__cell_to_point == False): # No conversion happens.  
309                      Plane._getPlane(self))                self._setupCutter(self.__data_collector._getDataCollectorOutput(),
310                        self._getPlane())  
311    
312          MaskPoints.__init__(self, Cutter._getOutput(self))          self._setupMaskPoints(self._getCutterOutput())
313    
314          if(arrow == Arrow.TWO_D): # Use 2D arrows.          if(self.__arrow == Arrow.TWO_D): # Use 2D arrows.
315              Arrow2D.__init__(self)              Arrow2D.__init__(self)
316              Glyph3D.__init__(self, MaskPoints._getOutput(self),              self._setupGlyph3D(self._getMaskPointsOutput(),
317                      Arrow2D._getOutput(self))                      self._getActor2DOutput())
318          elif(arrow == Arrow.THREE_D): # Use 3D arrows.          elif(self.__arrow == Arrow.THREE_D): # Use 3D arrows.
319              Arrow3D.__init__(self)              Arrow3D.__init__(self)
320              Glyph3D.__init__(self, MaskPoints._getOutput(self),              self._setupGlyph3D(self._getMaskPointsOutput(),
321                      Arrow3D._getOutput(self))                      self._getArrow3DOutput())
322    
323          DataSetMapper.__init__(self, Glyph3D._getOutput(self),          self._setupDataSetMapper(self._getGlyph3DOutput(),
324                  lookup_table._getLookupTable())                  lookup_table._getLookupTable())
325    
326          if(color_mode == ColorMode.VECTOR): # Color velocity by vector.          self._setupActor3D(self._getDataSetMapper())
327              Glyph3D._setColorModeByVector(self)          scene._addActor3D(self.__viewport, self._getActor3D())
328              Glyph3D._setRange(self, data_collector._getVectorRange())      
329              DataSetMapper._setScalarRange(self,      def _isModified(self):  
330                      data_collector._getVectorRange())          """
331              data_collector._paramForUpdatingMultipleSources(VizType.VELOCITY,          Return whether the VelocityOnPlaneCut or DataCollector has been
332                      ColorMode.VECTOR, DataSetMapper._getDataSetMapper(self),          modified.
                     Glyph3D._getGlyph3D(self))  
   
         elif(color_mode == ColorMode.SCALAR): # Color velocity by scalar.  
             Glyph3D._setColorModeByScalar(self)  
             Glyph3D._setRange(self, data_collector._getScalarRange())  
             DataSetMapper._setScalarRange(self,  
                     data_collector._getScalarRange())  
             data_collector._paramForUpdatingMultipleSources(VizType.VELOCITY,  
                     ColorMode.SCALAR, DataSetMapper._getDataSetMapper(self),  
                     Glyph3D._getGlyph3D(self))  
333    
334          Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))          @rtype: Boolean
335          scene._addActor3D(viewport, Actor3D._getActor3D(self))          @return: True or False
336            """
337    
338            return self.__modified or self.__data_collector._isModified()
339    
340        def _render(self, scene):
341            """
342            Render the velocity cut using a plane.
343    
344            @type scene: L{Scene <scene.Scene>} object
345            @param scene: Scene in which objects are to be rendered on
346            """
347    
348            if (self._isModified() == True):
349                if(self.__data_collector._isVectorSet() == True):
350                    self.__data_collector._setActiveVector()
351                # Color velocity by vector.
352                if(self.__color_mode == ColorMode.VECTOR):              
353                    self._setColorModeByVector()
354    
355                    # self._isScalarRangeSet checks whether the scalar range has
356                    # been specified by the user. If it has, then the scalar range
357                    # read from the source will be ignored.
358                    if(not(self._isScalarRangeSet())):
359                        self._setRange(self.__data_collector._getVectorRange())
360                        self._setScalarRange(\
361                                self.__data_collector._getVectorRange())
362                    else:
363                        self._setRange(self._getDataSetMapperRange())
364    
365                # Color velocity by scalar.
366                elif(self.__color_mode == ColorMode.SCALAR):                
367                    self._setColorModeByScalar()
368    
369                    # self._isScalarRangeSet checks whether the scalar range has
370                    # been specified by the user. If it has, then the scalar range
371                    # read from the source will be ignored.
372                    if(not(self._isScalarRangeSet())):
373                        self._setRange(self.__data_collector._getScalarRange())
374                        self._setScalarRange(\
375                                self.__data_collector._getScalarRange())
376                    else:
377                        self._setRange(self._getDataSetMapperRange())
378    
379                self.__modified = False
380    
381    
382  ###############################################################################  ###############################################################################
# Line 294  class VelocityOnPlaneClip(DataSetMapper, Line 407  class VelocityOnPlaneClip(DataSetMapper,
407          source is cell data, a conversion to point data may or may not be          source is cell data, a conversion to point data may or may not be
408          required, in order for the object to be rendered correctly.          required, in order for the object to be rendered correctly.
409          If a conversion is needed, the 'cell_to_point' flag must be set to          If a conversion is needed, the 'cell_to_point' flag must be set to
410          'True', otherwise 'False' (which is the default).          'True', otherwise 'False' (which is the default). On occasions, an
411            inaccurate object may be rendered from cell data even after conversion.
412    
413          @type scene: L{Scene <scene.Scene>} object          @type scene: L{Scene <scene.Scene>} object
414          @param scene: Scene in which objects are to be rendered on          @param scene: Scene in which objects are to be rendered on
# Line 315  class VelocityOnPlaneClip(DataSetMapper, Line 429  class VelocityOnPlaneClip(DataSetMapper,
429          @param outline: Places an outline around the domain surface          @param outline: Places an outline around the domain surface
430          """          """
431    
432          # NOTE: Actor3D is inherited and there are two instances declared here.          self.__data_collector = data_collector
433          # As a result, when methods from Actor3D is invoked from the driver,          self.__arrow = arrow
434          # only the methods associated with the latest instance (which in this          self.__color_mode = color_mode
435          # case is the Actor3D for the Velocity) can be executed. Actor3D          self.__viewport = viewport
436          # methods associated with Outline cannot be invoked from the driver.          self.__lut = lut
437          # They can only be called within here, which is why Outline must be          self.__cell_to_point = cell_to_point
438          # place before Velocity as there is unlikely to be any changes          self.__outline = outline
439          # made to the Outline's Actor3D.          
440            # Keeps track whether VelocityOnPlaneCut has been modified.
441          # ----- Outline -----          self.__modified = True
442            Transform.__init__(self)
443          if(outline == True):          Plane.__init__(self)
444              outline = Outline(data_collector._getOutput())          Clipper.__init__(self)
445              DataSetMapper.__init__(self, outline._getOutput())          MaskPoints.__init__(self)
446            Glyph3D.__init__(self)
447            DataSetMapper.__init__(self)
448            Actor3D.__init__(self)
449            scene._addVisualizationModules(self)
450    
451            # ----- Outline -----
452    
453            # NOTE: Changes cannot be made to the Outline's properties from the
454            # driver.
455            if(self.__outline == True):
456                outline = Outline(self.__data_collector._getDataCollectorOutput())
457                mapper = DataSetMapper()
458                mapper._setupDataSetMapper(outline._getOutlineOutput())
459    
460              Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))              actor3D = Actor3D()
461                actor3D._setupActor3D(mapper._getDataSetMapper())
462              # Default outline color is black.              # Default outline color is black.
463              Actor3D.setColor(self, Color.BLACK)              actor3D.setColor(Color.BLACK)
464    
465              # Default line width is 1.              # Default line width is 1.
466              Actor3D._setLineWidth(self, 1)              actor3D._setLineWidth(1)
467              scene._addActor3D(viewport, Actor3D._getActor3D(self))              scene._addActor3D(self.__viewport, actor3D._getActor3D())
468    
469          # ----- Velocity on a clipped plane -----          # ----- Velocity on a clipped plane -----
470    
471          # NOTE: Lookup table color mapping (color or grey scale) MUST be set          # NOTE: Lookup table color mapping (color or grey scale) MUST be set
472          # before DataSetMapper. If it is done after DataSetMapper, no effect          # before DataSetMapper. If it is done after DataSetMapper, no effect
473          # will take place.          # will take place.
474          if(lut == Lut.COLOR): # Colored lookup table.          if(self.__lut == Lut.COLOR): # Colored lookup table.
475              lookup_table = LookupTable()              lookup_table = LookupTable()
476              lookup_table._setTableValue()              lookup_table._setTableValue()
477          elif(lut == Lut.GREY_SCALE): # Grey scaled lookup table.          elif(self.__lut == Lut.GREY_SCALE): # Grey scaled lookup table.
478              lookup_table = LookupTable()              lookup_table = LookupTable()
479              lookup_table._setLookupTableToGreyScale()              lookup_table._setLookupTableToGreyScale()
480    
481          Transform.__init__(self)              self._setupPlane(self._getTransform())
         Plane.__init__(self, Transform._getTransform(self))  
482    
483          if(cell_to_point == True): # Converts cell data to point data.          if(self.__cell_to_point == True): # Converts cell data to point data.
484              c2p = CellDataToPointData(data_collector._getOutput())              c2p = CellDataToPointData(
485              MaskPoints.__init__(self, c2p._getOutput())                      self.__data_collector._getDataCollectorOutput())
486          elif(cell_to_point == False): # No conversion happens.                self._setupMaskPoints(c2p._getCellToPointOutput())
487              MaskPoints.__init__(self, data_collector._getOutput())          elif(self.__cell_to_point == False): # No conversion happens.  
488                self._setupMaskPoints(
489                        self.__data_collector._getDataCollectorOutput())
490    
491          # NOTE: Glyph3D must come before Clipper. Otherwise clipping may not          # NOTE: Glyph3D must come before Clipper. Otherwise clipping may not
492          # work correctly.          # work correctly.
493          if(arrow == Arrow.TWO_D): # Use 2D arrows.          if(self.__arrow == Arrow.TWO_D): # Use 2D arrows.
494              Arrow2D.__init__(self)              Arrow2D.__init__(self)
495              Glyph3D.__init__(self, MaskPoints._getOutput(self),              self._setupGlyph3D(self._getMaskPointsOutput(),
496                      Arrow2D._getOutput(self))                      self._getArrow2DOutput())
497          elif(arrow == Arrow.THREE_D): # Use 3D arrows.          elif(self.__arrow == Arrow.THREE_D): # Use 3D arrows.
498              Arrow3D.__init__(self)              Arrow3D.__init__(self)
499              Glyph3D.__init__(self, MaskPoints._getOutput(self),              self._setupGlyph3D(self._getMaskPointsOutput(),
500                      Arrow3D._getOutput(self))                      self._getArrow3DOutput())
501                    
502          Clipper.__init__(self, Glyph3D._getOutput(self),          self._setupClipper(self._getGlyph3DOutput(), self._getPlane())  
503                  Plane._getPlane(self))            self._setClipFunction()
         Clipper._setClipFunction(self)  
504    
505          # NOTE: Clipper must come after Glyph. Otherwise clipping          # NOTE: Clipper must come after Glyph. Otherwise clipping
506          # may not work correctly.          # may not work correctly.
507          DataSetMapper.__init__(self, Clipper._getOutput(self),          self._setupDataSetMapper(self._getClipperOutput(),
508                  lookup_table._getLookupTable())                  lookup_table._getLookupTable())
509    
510          if(color_mode == ColorMode.VECTOR): # Color velocity by vector.          self._setupActor3D(self._getDataSetMapper())
511              Glyph3D._setColorModeByVector(self)          scene._addActor3D(self.__viewport, self._getActor3D())
512              Glyph3D._setRange(self, data_collector._getVectorRange())      
513              DataSetMapper._setScalarRange(self,      def _isModified(self):  
514                      data_collector._getVectorRange())          """
515              data_collector._paramForUpdatingMultipleSources(VizType.VELOCITY,          Return whether the VelocityOnPlaneClip or DataCollector has been
516                      ColorMode.VECTOR, DataSetMapper._getDataSetMapper(self),          modified.
517                      Glyph3D._getGlyph3D(self))  
518            @rtype: Boolean
519          elif(color_mode == ColorMode.SCALAR): # Color velocity by scalar.          @return: True or False
520              Glyph3D._setColorModeByScalar(self)          """
521              Glyph3D._setRange(self, data_collector._getScalarRange())  
522              DataSetMapper._setScalarRange(self,          return self.__modified or self.__data_collector._isModified()
523                      data_collector._getScalarRange())  
524              data_collector._paramForUpdatingMultipleSources(VizType.VELOCITY,      def _render(self, scene):
525                      ColorMode.SCALAR, DataSetMapper._getDataSetMapper(self),          """
526                      Glyph3D._getGlyph3D(self))          Render the velocity clip using a plane..
527    
528            @type scene: L{Scene <scene.Scene>} object
529            @param scene: Scene in which objects are to be rendered on
530            """
531    
532            if (self._isModified() == True):
533                if(self.__data_collector._isVectorSet() == True):
534                    self.__data_collector._setActiveVector()
535                # Color velocity by vector.
536                if(self.__color_mode == ColorMode.VECTOR):              
537                    self._setColorModeByVector()
538    
539                    # self._isScalarRangeSet checks whether the scalar range has
540                    # been specified by the user. If it has, then the scalar range
541                    # read from the source will be ignored.
542                    if(not(self._isScalarRangeSet())):
543                        self._setRange(self.__data_collector._getVectorRange())
544                        self._setScalarRange(\
545                                self.__data_collector._getVectorRange())
546                    else:
547                        self._setRange(self._getDataSetMapperRange())
548    
549                # Color velocity by scalar.
550                elif(self.__color_mode == ColorMode.SCALAR):                
551                    self._setColorModeByScalar()
552    
553                    # self._isScalarRangeSet checks whether the scalar range has
554                    # been specified by the user. If it has, then the scalar range
555                    # read from the source will be ignored.
556                    if(not(self._isScalarRangeSet())):
557                        self._setRange(self.__data_collector._getScalarRange())
558                        self._setScalarRange(\
559                                self.__data_collector._getScalarRange())
560                    else:
561                        self._setRange(self._getDataSetMapperRange())
562    
563                self.__modified = False
564    
565    
         Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))  
         scene._addActor3D(viewport, Actor3D._getActor3D(self))  

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

  ViewVC Help
Powered by ViewVC 1.1.26