/[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 943 by jongui, Mon Jan 29 07:22:43 2007 UTC revision 994 by jongui, Fri Feb 23 07:00:54 2007 UTC
# Line 13  from constant import Viewport, Color, Lu Line 13  from constant import Viewport, Color, Lu
13  # public methods from the driver.  # public methods from the driver.
14  class Map(DataSetMapper, Actor3D):  class Map(DataSetMapper, Actor3D):
15      """      """
16      Class that shows a scalar field by color on a domain surface.      Class that shows a scalar field on a domain surface.
17      """      """
18    
19      # 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.
20      # 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.
21      # If no scalar field is specified, the first encountered in the file will      # If no scalar field is specified, the first encountered in the file will
22      # be loaded automatically.      # be loaded automatically. If no lut is specified, the color scheme will
23        # be used.
24      def __init__(self, scene, data_collector, scalar = None,      def __init__(self, scene, data_collector, scalar = None,
25              viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR,              viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR,
26              outline = True):              outline = True):
# Line 32  class Map(DataSetMapper, Actor3D): Line 33  class Map(DataSetMapper, Actor3D):
33          @type scalar: String          @type scalar: String
34          @param scalar: Scalar field to load from the source file          @param scalar: Scalar field to load from the source file
35          @type viewport: L{Viewport <constant.Viewport>} constant            @type viewport: L{Viewport <constant.Viewport>} constant  
36          @param viewport: Viewport in which the object is to be rendered on          @param viewport: Viewport in which objects are to be rendered on
37          @type lut : L{Lut <constant.Lut>} constant          @type lut : L{Lut <constant.Lut>} constant
38          @param lut: Lookup table color scheme          @param lut: Lookup table color scheme
39          @type outline: Boolean          @type outline: Boolean
# Line 42  class Map(DataSetMapper, Actor3D): Line 43  class Map(DataSetMapper, Actor3D):
43          # NOTE: Actor3D is inherited and there are two instances declared here.          # NOTE: Actor3D is inherited and there are two instances declared here.
44          # As a result, when methods from Actor3D is invoked from the driver,          # As a result, when methods from Actor3D is invoked from the driver,
45          # only the methods associated with the latest instance (which in this          # only the methods associated with the latest instance (which in this
46          # case is the Actor3D for the Surface map) can be executed. Actor3D          # case is the Actor3D for the  map) can be executed. Actor3D
47          # methods associated with Outline cannot be invoked from the driver.          # methods associated with Outline cannot be invoked from the driver.
48          # They can only be called within here, which is why Outline must          # They can only be called within here, which is why Outline must
49          # be place before Surface map as there is unlikely to be any changes          # be place before map as there is unlikely to be any changes
50          # made to the Outline's Actor3D.          # made to the Outline's Actor3D.
51    
52          # ----- Outline -----          # ----- Outline -----
# Line 57  class Map(DataSetMapper, Actor3D): Line 58  class Map(DataSetMapper, Actor3D):
58              Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))              Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))
59              # Default outline color is black.              # Default outline color is black.
60              Actor3D.setColor(self, Color.BLACK)              Actor3D.setColor(self, Color.BLACK)
61    
62              # Default line width is 1.              # Default line width is 1.
63              Actor3D._setLineWidth(self, 1)              Actor3D._setLineWidth(self, 1)
64              scene._addActor3D(viewport, Actor3D._getActor3D(self))              scene._addActor3D(viewport, Actor3D._getActor3D(self))
65    
66          # ----- Surface map -----          # ----- Map -----
67    
68          if(scalar != None): # True only if a scalar field was specified.          #if(scalar != None): # True only if a scalar field was specified.
69              data_collector._setActiveScalar(scalar)          #   data_collector._setActiveScalar(scalar)
70    
71          # NOTE: Lookup table color mapping (color or grey scale) MUST be set          # NOTE: Lookup table color mapping (color or grey scale) MUST be set
72          # before DataSetMapper. If it is done after DataSetMapper, no effect          # before DataSetMapper. If it is done after DataSetMapper, no effect
# Line 78  class Map(DataSetMapper, Actor3D): Line 80  class Map(DataSetMapper, Actor3D):
80    
81          DataSetMapper.__init__(self, data_collector._getOutput(),          DataSetMapper.__init__(self, data_collector._getOutput(),
82                  lookup_table._getLookupTable())                  lookup_table._getLookupTable())
   
83          DataSetMapper._setScalarRange(self, data_collector._getScalarRange())          DataSetMapper._setScalarRange(self, data_collector._getScalarRange())
84    
85    
86          Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))          Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))
87          scene._addActor3D(viewport, Actor3D._getActor3D(self))          scene._addActor3D(viewport, Actor3D._getActor3D(self))
88    
89    
90    ###############################################################################
91    
92    
93  from transform import Transform  from transform import Transform
94  from plane import Plane  from plane import Plane
# Line 94  from cutter import Cutter Line 98  from cutter import Cutter
98  # to allow access to their public methods from the driver.  # to allow access to their public methods from the driver.
99  class MapOnPlaneCut(DataSetMapper, Actor3D, Transform, Plane, Cutter):  class MapOnPlaneCut(DataSetMapper, Actor3D, Transform, Plane, Cutter):
100      """      """
101      Class that show a scalar field  on a plane.      Class that show a scalar field on a plane.  
102      """      """
103            
104      # 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.
105      # 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.
106      # If no scalar field is specified, the first encountered in the file will      # If no scalar field is specified, the first encountered in the file will
107      # be loaded automatically.      # be loaded automatically. If no lut is specified, the color scheme will
108        # be used.
109      def __init__(self, scene, data_collector, scalar = None,      def __init__(self, scene, data_collector, scalar = None,
110              viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, outline = True):              viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, outline = True):
111    
# Line 113  class MapOnPlaneCut(DataSetMapper, Actor Line 118  class MapOnPlaneCut(DataSetMapper, Actor
118          @type scalar: String          @type scalar: String
119          @param scalar: Scalar field to load from the source file          @param scalar: Scalar field to load from the source file
120          @type viewport: L{Viewport <constant.Viewport>} constant          @type viewport: L{Viewport <constant.Viewport>} constant
121          @param viewport: Viewport in which the object is to be rendered on          @param viewport: Viewport in which objects are to be rendered on
122          @type lut : L{Lut <constant.Lut>} constant          @type lut : L{Lut <constant.Lut>} constant
123          @param lut: Lookup table color scheme          @param lut: Lookup table color scheme
124          @type outline: Boolean          @type outline: Boolean
# Line 132  class MapOnPlaneCut(DataSetMapper, Actor Line 137  class MapOnPlaneCut(DataSetMapper, Actor
137          # ----- Outline -----          # ----- Outline -----
138    
139          if(outline == True):          if(outline == True):
             #outline = Outline(Glyph3D._getOutput(self))  
140              outline = Outline(data_collector._getOutput())              outline = Outline(data_collector._getOutput())
141              DataSetMapper.__init__(self, outline._getOutput())              DataSetMapper.__init__(self, outline._getOutput())
142    
# Line 140  class MapOnPlaneCut(DataSetMapper, Actor Line 144  class MapOnPlaneCut(DataSetMapper, Actor
144              # Default outline color is black.              # Default outline color is black.
145              Actor3D.setColor(self, Color.BLACK)              Actor3D.setColor(self, Color.BLACK)
146              # Default line width is 1.              # Default line width is 1.
147    
148              Actor3D._setLineWidth(self, 1)              Actor3D._setLineWidth(self, 1)
149              scene._addActor3D(viewport, Actor3D._getActor3D(self))              scene._addActor3D(viewport, Actor3D._getActor3D(self))
150    
   
151          # ----- Map on a plane -----          # ----- Map on a plane -----
152    
153          if(scalar != None):          #if(scalar != None):
154              data_collector._setActiveScalar(scalar)          #   data_collector._setActiveScalar(scalar)
155    
156          # NOTE: Lookup table color mapping (color or grey scale) MUST be set          # NOTE: Lookup table color mapping (color or grey scale) MUST be set
157          # before DataSetMapper. If it is done after DataSetMapper, no effect          # before DataSetMapper. If it is done after DataSetMapper, no effect
# Line 167  class MapOnPlaneCut(DataSetMapper, Actor Line 171  class MapOnPlaneCut(DataSetMapper, Actor
171    
172          DataSetMapper.__init__(self, Cutter._getOutput(self),          DataSetMapper.__init__(self, Cutter._getOutput(self),
173                  lookup_table._getLookupTable())                  lookup_table._getLookupTable())
   
174          DataSetMapper._setScalarRange(self, data_collector._getScalarRange())            DataSetMapper._setScalarRange(self, data_collector._getScalarRange())  
175    
176          Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))          Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))
177          scene._addActor3D(viewport, Actor3D._getActor3D(self))          scene._addActor3D(viewport, Actor3D._getActor3D(self))
178    
179    
   
180  ###########################################################################  ###########################################################################
181    
182    
   
183  from clipper import Clipper  from clipper import Clipper
184    
185  # NOTE: DataSetMapper, Actor3D, Transform, Plane and Clipper were inherited  # NOTE: DataSetMapper, Actor3D, Transform, Plane and Clipper were inherited
186  # to allow access to their public methods from the driver.  # to allow access to their public methods from the driver.
187  class MapOnPlaneClip(DataSetMapper, Actor3D, Transform, Plane, Clipper):  class MapOnPlaneClip(DataSetMapper, Actor3D, Transform, Plane, Clipper):
188      """      """
189      Class that show a scalar field  on a clipped plane.      Class that show a scalar field on a clipped plane.  
190      """      """
191            
192      # 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.
193      # 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.
194      # If no scalar field is specified, the first encountered in the file will      # If no scalar field is specified, the first encountered in the file will
195      # be loaded automatically.      # be loaded automatically. If no lut is specified, the color scheme will
196        # be used.
197      def __init__(self, scene, data_collector, scalar = None,      def __init__(self, scene, data_collector, scalar = None,
198              viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, outline = True):              viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, outline = True):
199    
# Line 204  class MapOnPlaneClip(DataSetMapper, Acto Line 206  class MapOnPlaneClip(DataSetMapper, Acto
206          @type scalar: String          @type scalar: String
207          @param scalar: Scalar field to load from the source file          @param scalar: Scalar field to load from the source file
208          @type viewport: L{Viewport <constant.Viewport>} constant          @type viewport: L{Viewport <constant.Viewport>} constant
209          @param viewport: Viewport in which the object is to be rendered on          @param viewport: Viewport in which objects are to be rendered on
210          @type lut : L{Lut <constant.Lut>} constant          @type lut : L{Lut <constant.Lut>} constant
211          @param lut: Lookup table color scheme          @param lut: Lookup table color scheme
212          @type outline: Boolean          @type outline: Boolean
# Line 223  class MapOnPlaneClip(DataSetMapper, Acto Line 225  class MapOnPlaneClip(DataSetMapper, Acto
225          # ----- Outline -----          # ----- Outline -----
226    
227          if(outline == True):          if(outline == True):
             #outline = Outline(Glyph3D._getOutput(self))  
228              outline = Outline(data_collector._getOutput())              outline = Outline(data_collector._getOutput())
229              DataSetMapper.__init__(self, outline._getOutput())              DataSetMapper.__init__(self, outline._getOutput())
230    
231              Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))              Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))
232              # Default outline color is black.              # Default outline color is black.
233              Actor3D.setColor(self, Color.BLACK)              Actor3D.setColor(self, Color.BLACK)
234    
235              # Default line width is 1.              # Default line width is 1.
236              Actor3D._setLineWidth(self, 1)              Actor3D._setLineWidth(self, 1)
237              scene._addActor3D(viewport, Actor3D._getActor3D(self))              scene._addActor3D(viewport, Actor3D._getActor3D(self))
238    
   
239          # ----- Map on a clipped plane -----          # ----- Map on a clipped plane -----
240    
241          if(scalar != None):          #if(scalar != None):
242              data_collector._setActiveScalar(scalar)          #   data_collector._setActiveScalar(scalar)
243    
244          # NOTE: Lookup table color mapping (color or grey scale) MUST be set          # NOTE: Lookup table color mapping (color or grey scale) MUST be set
245          # before DataSetMapper. If it is done after DataSetMapper, no effect          # before DataSetMapper. If it is done after DataSetMapper, no effect
# Line 259  class MapOnPlaneClip(DataSetMapper, Acto Line 260  class MapOnPlaneClip(DataSetMapper, Acto
260    
261          DataSetMapper.__init__(self, Clipper._getOutput(self),          DataSetMapper.__init__(self, Clipper._getOutput(self),
262                  lookup_table._getLookupTable())                  lookup_table._getLookupTable())
   
263          DataSetMapper._setScalarRange(self, data_collector._getScalarRange())            DataSetMapper._setScalarRange(self, data_collector._getScalarRange())  
264    
265          Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))          Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))
266          scene._addActor3D(viewport, Actor3D._getActor3D(self))          scene._addActor3D(viewport, Actor3D._getActor3D(self))
267    
268    
   
269  #############################################################################  #############################################################################
270    
271    
   
272  # NOTE: DataSetMapper, Actor3D and Clipper were inherited  # NOTE: DataSetMapper, Actor3D and Clipper were inherited
273  # to allow access to their public methods from the driver.  # to allow access to their public methods from the driver.
274  class MapOnScalarClip(DataSetMapper, Actor3D, Clipper):  class MapOnScalarClip(DataSetMapper, Actor3D, Clipper):
# Line 281  class MapOnScalarClip(DataSetMapper, Act Line 279  class MapOnScalarClip(DataSetMapper, Act
279      # 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.
280      # 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.
281      # If no scalar field is specified, the first encountered in the file will      # If no scalar field is specified, the first encountered in the file will
282      # be loaded automatically.      # be loaded automatically. If no lut is specified, the color scheme will
283        # be used.
284    
285      def __init__(self, scene, data_collector, scalar = None,      def __init__(self, scene, data_collector, scalar = None,
286              viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, outline = True):              viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, outline = True):
287    
# Line 294  class MapOnScalarClip(DataSetMapper, Act Line 294  class MapOnScalarClip(DataSetMapper, Act
294          @type scalar: String          @type scalar: String
295          @param scalar: Scalar field to load from the source file          @param scalar: Scalar field to load from the source file
296          @type viewport: L{Viewport <constant.Viewport>} constant          @type viewport: L{Viewport <constant.Viewport>} constant
297          @param viewport: Viewport in which the object is to be rendered on          @param viewport: Viewport in which objects are to be rendered on
298          @type lut : L{Lut <constant.Lut>} constant          @type lut : L{Lut <constant.Lut>} constant
299          @param lut: Lookup table color scheme          @param lut: Lookup table color scheme
300          @type outline: Boolean          @type outline: Boolean
# Line 313  class MapOnScalarClip(DataSetMapper, Act Line 313  class MapOnScalarClip(DataSetMapper, Act
313          # ----- Outline -----          # ----- Outline -----
314    
315          if(outline == True):          if(outline == True):
             #outline = Outline(Glyph3D._getOutput(self))  
316              outline = Outline(data_collector._getOutput())              outline = Outline(data_collector._getOutput())
317              DataSetMapper.__init__(self, outline._getOutput())              DataSetMapper.__init__(self, outline._getOutput())
318    
319              Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))              Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))
320              # Default outline color is black.              # Default outline color is black.
321              Actor3D.setColor(self, Color.BLACK)              Actor3D.setColor(self, Color.BLACK)
322    
323              # Default line width is 1.              # Default line width is 1.
324              Actor3D._setLineWidth(self, 1)              Actor3D._setLineWidth(self, 1)
325              scene._addActor3D(viewport, Actor3D._getActor3D(self))              scene._addActor3D(viewport, Actor3D._getActor3D(self))
326    
   
327          # ----- Map clipped using a scalar value -----          # ----- Map clipped using a scalar value -----
328    
329          if(scalar != None):          #if(scalar != None):
330              data_collector._setActiveScalar(scalar)          #   data_collector._setActiveScalar(scalar)
331    
332          # NOTE: Lookup table color mapping (color or grey scale) MUST be set          # NOTE: Lookup table color mapping (color or grey scale) MUST be set
333          # before DataSetMapper. If it is done after DataSetMapper, no effect          # before DataSetMapper. If it is done after DataSetMapper, no effect
# Line 340  class MapOnScalarClip(DataSetMapper, Act Line 339  class MapOnScalarClip(DataSetMapper, Act
339              lookup_table = LookupTable()              lookup_table = LookupTable()
340              lookup_table._setLookupTableToGreyScale()              lookup_table._setLookupTableToGreyScale()
341    
342          Clipper.__init__(self, data_collector._getOutput())          # None is used because a plane is not required when a scalar value is
343            # used to perform the clipping.
344            Clipper.__init__(self, data_collector._getOutput(), None)
345    
346          DataSetMapper.__init__(self, Clipper._getOutput(self),          DataSetMapper.__init__(self, Clipper._getOutput(self),
347                  lookup_table._getLookupTable())                  lookup_table._getLookupTable())
   
348          DataSetMapper._setScalarRange(self, data_collector._getScalarRange())            DataSetMapper._setScalarRange(self, data_collector._getScalarRange())  
349    
350          Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))          Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))

Legend:
Removed from v.943  
changed lines
  Added in v.994

  ViewVC Help
Powered by ViewVC 1.1.26