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

Diff of /trunk/pyvisi/py_src/map.py

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

revision 1042 by jongui, Fri Mar 16 05:00:32 2007 UTC revision 1043 by jongui, Mon Mar 19 06:46:34 2007 UTC
# Line 8  from actor import Actor3D Line 8  from actor import Actor3D
8  from lookuptable import LookupTable  from lookuptable import LookupTable
9  from outline import Outline  from outline import Outline
10  from constant import Viewport, Color, Lut, VizType, ColorMode  from constant import Viewport, Color, Lut, VizType, ColorMode
11    from average import CellDataToPointData
12    
13  # NOTE: DataSetMapper and Actor3D were inherited to allow access to their  # NOTE: DataSetMapper and Actor3D were inherited to allow access to their
14  # public methods from the driver.  # public methods from the driver.
# Line 21  class Map(DataSetMapper, Actor3D): Line 22  class Map(DataSetMapper, Actor3D):
22      # 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.
23      # If no lut is specified, the color scheme will be used.      # If no lut is specified, the color scheme will be used.
24      def __init__(self, scene, data_collector, viewport = Viewport.SOUTH_WEST,      def __init__(self, scene, data_collector, viewport = Viewport.SOUTH_WEST,
25              lut = Lut.COLOR, outline = True):              lut = Lut.COLOR, cell_to_point = False, outline = True):
26          """          """
27          @type scene: L{Scene <scene.Scene>} object          @type scene: L{Scene <scene.Scene>} object
28          @param scene: Scene in which objects are to be rendered on          @param scene: Scene in which objects are to be rendered on
# Line 32  class Map(DataSetMapper, Actor3D): Line 33  class Map(DataSetMapper, Actor3D):
33          @param viewport: Viewport in which objects are to be rendered on          @param viewport: Viewport in which objects are to be rendered on
34          @type lut : L{Lut <constant.Lut>} constant          @type lut : L{Lut <constant.Lut>} constant
35          @param lut: Lookup table color scheme          @param lut: Lookup table color scheme
36            @type cell_to_point: Boolean
37            @param cell_to_point: Converts cell data to point data (by averaging)
38          @type outline: Boolean          @type outline: Boolean
39          @param outline: Places an outline around the domain surface          @param outline: Places an outline around the domain surface
40          """          """
# Line 71  class Map(DataSetMapper, Actor3D): Line 74  class Map(DataSetMapper, Actor3D):
74              lookup_table = LookupTable()              lookup_table = LookupTable()
75              lookup_table._setLookupTableToGreyScale()              lookup_table._setLookupTableToGreyScale()
76    
77          DataSetMapper.__init__(self, data_collector._getOutput(),          if(cell_to_point == True): # Converts cell data to point data.
78                  lookup_table._getLookupTable())              c2p = CellDataToPointData(data_collector._getOutput())
79                DataSetMapper.__init__(self, c2p._getOutput(),
80                        lookup_table._getLookupTable())
81            elif(cell_to_point == False): # No conversion happens.
82                DataSetMapper.__init__(self, data_collector._getOutput(),
83                        lookup_table._getLookupTable())
84    
85          DataSetMapper._setScalarRange(self, data_collector._getScalarRange())          DataSetMapper._setScalarRange(self, data_collector._getScalarRange())
86    
87          data_collector._paramForUpdatingMultipleSources(VizType.MAP,          data_collector._paramForUpdatingMultipleSources(VizType.MAP,
# Line 102  class MapOnPlaneCut(DataSetMapper, Actor Line 111  class MapOnPlaneCut(DataSetMapper, Actor
111      # 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.
112      # If no lut is specified, the color scheme will be used.      # If no lut is specified, the color scheme will be used.
113      def __init__(self, scene, data_collector, viewport = Viewport.SOUTH_WEST,      def __init__(self, scene, data_collector, viewport = Viewport.SOUTH_WEST,
114              lut = Lut.COLOR, outline = True):              lut = Lut.COLOR, cell_to_point = False, outline = True):
115          """          """
116          @type scene: L{Scene <scene.Scene>} object          @type scene: L{Scene <scene.Scene>} object
117          @param scene: Scene in which objects are to be rendered on          @param scene: Scene in which objects are to be rendered on
# Line 113  class MapOnPlaneCut(DataSetMapper, Actor Line 122  class MapOnPlaneCut(DataSetMapper, Actor
122          @param viewport: Viewport in which objects are to be rendered on          @param viewport: Viewport in which objects are to be rendered on
123          @type lut : L{Lut <constant.Lut>} constant          @type lut : L{Lut <constant.Lut>} constant
124          @param lut: Lookup table color scheme          @param lut: Lookup table color scheme
125            @type cell_to_point: Boolean
126            @param cell_to_point: Converts cell data to point data (by averaging)
127          @type outline: Boolean          @type outline: Boolean
128          @param outline: Places an outline around the domain surface          @param outline: Places an outline around the domain surface
129          """          """
# Line 155  class MapOnPlaneCut(DataSetMapper, Actor Line 166  class MapOnPlaneCut(DataSetMapper, Actor
166          Transform.__init__(self)              Transform.__init__(self)    
167          Plane.__init__(self, Transform._getTransform(self))          Plane.__init__(self, Transform._getTransform(self))
168    
169          Cutter.__init__(self, data_collector._getOutput(),          if(cell_to_point == True): # Converts cell data to point data.
170                c2p = CellDataToPointData(data_collector._getOutput())
171                Cutter.__init__(self, c2p._getOutput(), Plane._getPlane(self))
172            elif(cell_to_point == False): # No conversion happens.
173                Cutter.__init__(self, data_collector._getOutput(),
174                  Plane._getPlane(self))                  Plane._getPlane(self))
175    
176          DataSetMapper.__init__(self, Cutter._getOutput(self),          DataSetMapper.__init__(self, Cutter._getOutput(self),
177                  lookup_table._getLookupTable())                  lookup_table._getLookupTable())
178          DataSetMapper._setScalarRange(self, data_collector._getScalarRange())            DataSetMapper._setScalarRange(self, data_collector._getScalarRange())  
179    
180            data_collector._paramForUpdatingMultipleSources(VizType.MAP,
181                    ColorMode.SCALAR, DataSetMapper._getDataSetMapper(self))
182    
183          Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))          Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))
184          scene._addActor3D(viewport, Actor3D._getActor3D(self))          scene._addActor3D(viewport, Actor3D._getActor3D(self))
185    
186    
187  ###########################################################################  ###############################################################################
188    
189    
190  from clipper import Clipper  from clipper import Clipper
# Line 183  class MapOnPlaneClip(DataSetMapper, Acto Line 201  class MapOnPlaneClip(DataSetMapper, Acto
201      # 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.
202      # If no lut is specified, the color scheme will be used.      # If no lut is specified, the color scheme will be used.
203      def __init__(self, scene, data_collector, viewport = Viewport.SOUTH_WEST,      def __init__(self, scene, data_collector, viewport = Viewport.SOUTH_WEST,
204              lut = Lut.COLOR, outline = True):              lut = Lut.COLOR, cell_to_point = False, outline = True):
205          """          """
206          @type scene: L{Scene <scene.Scene>} object          @type scene: L{Scene <scene.Scene>} object
207          @param scene: Scene in which objects are to be rendered on          @param scene: Scene in which objects are to be rendered on
# Line 194  class MapOnPlaneClip(DataSetMapper, Acto Line 212  class MapOnPlaneClip(DataSetMapper, Acto
212          @param viewport: Viewport in which objects are to be rendered on          @param viewport: Viewport in which objects are to be rendered on
213          @type lut : L{Lut <constant.Lut>} constant          @type lut : L{Lut <constant.Lut>} constant
214          @param lut: Lookup table color scheme          @param lut: Lookup table color scheme
215            @type cell_to_point: Boolean
216            @param cell_to_point: Converts cell data to point data (by averaging)
217          @type outline: Boolean          @type outline: Boolean
218          @param outline: Places an outline around the domain surface          @param outline: Places an outline around the domain surface
219          """          """
# Line 236  class MapOnPlaneClip(DataSetMapper, Acto Line 256  class MapOnPlaneClip(DataSetMapper, Acto
256          Transform.__init__(self)              Transform.__init__(self)    
257          Plane.__init__(self, Transform._getTransform(self))          Plane.__init__(self, Transform._getTransform(self))
258    
259          Clipper.__init__(self, data_collector._getOutput(),          if(cell_to_point == True): # Converts cell data to point data.
260                  Plane._getPlane(self))              c2p = CellDataToPointData(data_collector._getOutput())
261                Clipper.__init__(self, c2p._getOutput(), Plane._getPlane(self))
262            elif(cell_to_point == False): # No conversion happens.
263                Clipper.__init__(self, data_collector._getOutput(),
264                        Plane._getPlane(self))
265    
266          Clipper._setClipFunction(self)          Clipper._setClipFunction(self)
267    
268          DataSetMapper.__init__(self, Clipper._getOutput(self),          DataSetMapper.__init__(self, Clipper._getOutput(self),
269                  lookup_table._getLookupTable())                  lookup_table._getLookupTable())
270          DataSetMapper._setScalarRange(self, data_collector._getScalarRange())            DataSetMapper._setScalarRange(self, data_collector._getScalarRange())  
271    
272            data_collector._paramForUpdatingMultipleSources(VizType.MAP,
273                    ColorMode.SCALAR, DataSetMapper._getDataSetMapper(self))
274    
275          Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))          Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))
276          scene._addActor3D(viewport, Actor3D._getActor3D(self))          scene._addActor3D(viewport, Actor3D._getActor3D(self))
277    
# Line 263  class MapOnScalarClip(DataSetMapper, Act Line 291  class MapOnScalarClip(DataSetMapper, Act
291      # 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.
292      # If no lut is specified, the color scheme will be used.      # If no lut is specified, the color scheme will be used.
293      def __init__(self, scene, data_collector, viewport = Viewport.SOUTH_WEST,      def __init__(self, scene, data_collector, viewport = Viewport.SOUTH_WEST,
294              lut = Lut.COLOR, outline = True):              lut = Lut.COLOR, cell_to_point = False, outline = True):
295          """          """
296          @type scene: L{Scene <scene.Scene>} object          @type scene: L{Scene <scene.Scene>} object
297          @param scene: Scene in which objects are to be rendered on          @param scene: Scene in which objects are to be rendered on
# Line 274  class MapOnScalarClip(DataSetMapper, Act Line 302  class MapOnScalarClip(DataSetMapper, Act
302          @param viewport: Viewport in which objects are to be rendered on          @param viewport: Viewport in which objects are to be rendered on
303          @type lut : L{Lut <constant.Lut>} constant          @type lut : L{Lut <constant.Lut>} constant
304          @param lut: Lookup table color scheme          @param lut: Lookup table color scheme
305            @type cell_to_point: Boolean
306            @param cell_to_point: Converts cell data to point data (by averaging)
307          @type outline: Boolean          @type outline: Boolean
308          @param outline: Places an outline around the domain surface          @param outline: Places an outline around the domain surface
309          """          """
# Line 287  class MapOnScalarClip(DataSetMapper, Act Line 317  class MapOnScalarClip(DataSetMapper, Act
317          # be place before the map as there is unlikely to be any changes          # be place before the map as there is unlikely to be any changes
318          # made to the Outline's Actor3D.          # made to the Outline's Actor3D.
319    
320          # ----- Outline -----          # ----- Outline -----
321    
322          if(outline == True):          if(outline == True):
323              outline = Outline(data_collector._getOutput())              outline = Outline(data_collector._getOutput())
324              DataSetMapper.__init__(self, outline._getOutput())              DataSetMapper.__init__(self, outline._getOutput())
325    
326              Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))          Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))
327              # Default outline color is black.          # Default outline color is black.
328              Actor3D.setColor(self, Color.BLACK)          Actor3D.setColor(self, Color.BLACK)
329    
330              # Default line width is 1.          # Default line width is 1.
331              Actor3D._setLineWidth(self, 1)          Actor3D._setLineWidth(self, 1)
332              scene._addActor3D(viewport, Actor3D._getActor3D(self))          scene._addActor3D(viewport, Actor3D._getActor3D(self))
333    
334          # ----- Map clipped using a scalar value -----          # ----- Map clipped using a scalar value -----
335    
# Line 313  class MapOnScalarClip(DataSetMapper, Act Line 343  class MapOnScalarClip(DataSetMapper, Act
343              lookup_table = LookupTable()              lookup_table = LookupTable()
344              lookup_table._setLookupTableToGreyScale()              lookup_table._setLookupTableToGreyScale()
345    
346          # None is used because a plane is not required when a scalar value is  
347          # used to perform the clipping.          if(cell_to_point == True): # Converts cell data to point data.
348          Clipper.__init__(self, data_collector._getOutput(), None)              c2p = CellDataToPointData(data_collector._getOutput())
349                # None is used because a plane is not required when a scalar
350                # value is used to perform the clipping.
351                Clipper.__init__(self, c2p._getOutput(), None)
352            elif(cell_to_point == False): # No conversion happens.
353                Clipper.__init__(self, data_collector._getOutput(),None)
354    
355          DataSetMapper.__init__(self, Clipper._getOutput(self),          DataSetMapper.__init__(self, Clipper._getOutput(self),
356                  lookup_table._getLookupTable())                  lookup_table._getLookupTable())
357          DataSetMapper._setScalarRange(self, data_collector._getScalarRange())            DataSetMapper._setScalarRange(self, data_collector._getScalarRange())  
358    
359            data_collector._paramForUpdatingMultipleSources(VizType.MAP,
360                    ColorMode.SCALAR, DataSetMapper._getDataSetMapper(self))
361    
362          Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))          Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))
363          scene._addActor3D(viewport, Actor3D._getActor3D(self))          scene._addActor3D(viewport, Actor3D._getActor3D(self))
364    

Legend:
Removed from v.1042  
changed lines
  Added in v.1043

  ViewVC Help
Powered by ViewVC 1.1.26