/[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 947 by jongui, Wed Jan 31 07:17:43 2007 UTC revision 948 by jongui, Thu Feb 1 07:23:34 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)
# 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          Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))          Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))
86          scene._addActor3D(viewport, Actor3D._getActor3D(self))          scene._addActor3D(viewport, Actor3D._getActor3D(self))
87    
88    
89    ###############################################################################
90    
91    
92  from transform import Transform  from transform import Transform
93  from plane import Plane  from plane import Plane
# Line 94  from cutter import Cutter Line 97  from cutter import Cutter
97  # to allow access to their public methods from the driver.  # to allow access to their public methods from the driver.
98  class MapOnPlaneCut(DataSetMapper, Actor3D, Transform, Plane, Cutter):  class MapOnPlaneCut(DataSetMapper, Actor3D, Transform, Plane, Cutter):
99      """      """
100      Class that show a scalar field  on a plane.      Class that show a scalar field on a plane.  
101      """      """
102            
103      # 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.
104      # 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.
105      # 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
106      # be loaded automatically.      # be loaded automatically. If no lut is specified, the color scheme will
107        # be used.
108      def __init__(self, scene, data_collector, scalar = None,      def __init__(self, scene, data_collector, scalar = None,
109              viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, outline = True):              viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, outline = True):
110    
# Line 113  class MapOnPlaneCut(DataSetMapper, Actor Line 117  class MapOnPlaneCut(DataSetMapper, Actor
117          @type scalar: String          @type scalar: String
118          @param scalar: Scalar field to load from the source file          @param scalar: Scalar field to load from the source file
119          @type viewport: L{Viewport <constant.Viewport>} constant          @type viewport: L{Viewport <constant.Viewport>} constant
120          @param viewport: Viewport in which the object is to be rendered on          @param viewport: Viewport in which objects are to be rendered on
121          @type lut : L{Lut <constant.Lut>} constant          @type lut : L{Lut <constant.Lut>} constant
122          @param lut: Lookup table color scheme          @param lut: Lookup table color scheme
123          @type outline: Boolean          @type outline: Boolean
# Line 132  class MapOnPlaneCut(DataSetMapper, Actor Line 136  class MapOnPlaneCut(DataSetMapper, Actor
136          # ----- Outline -----          # ----- Outline -----
137    
138          if(outline == True):          if(outline == True):
             #outline = Outline(Glyph3D._getOutput(self))  
139              outline = Outline(data_collector._getOutput())              outline = Outline(data_collector._getOutput())
140              DataSetMapper.__init__(self, outline._getOutput())              DataSetMapper.__init__(self, outline._getOutput())
141    
# Line 140  class MapOnPlaneCut(DataSetMapper, Actor Line 143  class MapOnPlaneCut(DataSetMapper, Actor
143              # Default outline color is black.              # Default outline color is black.
144              Actor3D.setColor(self, Color.BLACK)              Actor3D.setColor(self, Color.BLACK)
145              # Default line width is 1.              # Default line width is 1.
146    
147              Actor3D._setLineWidth(self, 1)              Actor3D._setLineWidth(self, 1)
148              scene._addActor3D(viewport, Actor3D._getActor3D(self))              scene._addActor3D(viewport, Actor3D._getActor3D(self))
149    
   
150          # ----- Map on a plane -----          # ----- Map on a plane -----
151    
152          if(scalar != None):          if(scalar != None):
# Line 167  class MapOnPlaneCut(DataSetMapper, Actor Line 170  class MapOnPlaneCut(DataSetMapper, Actor
170    
171          DataSetMapper.__init__(self, Cutter._getOutput(self),          DataSetMapper.__init__(self, Cutter._getOutput(self),
172                  lookup_table._getLookupTable())                  lookup_table._getLookupTable())
   
173          DataSetMapper._setScalarRange(self, data_collector._getScalarRange())            DataSetMapper._setScalarRange(self, data_collector._getScalarRange())  
174    
175          Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))          Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))
176          scene._addActor3D(viewport, Actor3D._getActor3D(self))          scene._addActor3D(viewport, Actor3D._getActor3D(self))
177    
178    
   
179  ###########################################################################  ###########################################################################
180    
181    
   
182  from clipper import Clipper  from clipper import Clipper
183    
184  # NOTE: DataSetMapper, Actor3D, Transform, Plane and Clipper were inherited  # NOTE: DataSetMapper, Actor3D, Transform, Plane and Clipper were inherited
# Line 191  class MapOnPlaneClip(DataSetMapper, Acto Line 191  class MapOnPlaneClip(DataSetMapper, Acto
191      # 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.
192      # 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.
193      # 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
194      # be loaded automatically.      # be loaded automatically. If no lut is specified, the color scheme will
195        # be used.
196      def __init__(self, scene, data_collector, scalar = None,      def __init__(self, scene, data_collector, scalar = None,
197              viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, outline = True):              viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, outline = True):
198    
# Line 204  class MapOnPlaneClip(DataSetMapper, Acto Line 205  class MapOnPlaneClip(DataSetMapper, Acto
205          @type scalar: String          @type scalar: String
206          @param scalar: Scalar field to load from the source file          @param scalar: Scalar field to load from the source file
207          @type viewport: L{Viewport <constant.Viewport>} constant          @type viewport: L{Viewport <constant.Viewport>} constant
208          @param viewport: Viewport in which the object is to be rendered on          @param viewport: Viewport in which objects are to be rendered on
209          @type lut : L{Lut <constant.Lut>} constant          @type lut : L{Lut <constant.Lut>} constant
210          @param lut: Lookup table color scheme          @param lut: Lookup table color scheme
211          @type outline: Boolean          @type outline: Boolean
# Line 223  class MapOnPlaneClip(DataSetMapper, Acto Line 224  class MapOnPlaneClip(DataSetMapper, Acto
224          # ----- Outline -----          # ----- Outline -----
225    
226          if(outline == True):          if(outline == True):
             #outline = Outline(Glyph3D._getOutput(self))  
227              outline = Outline(data_collector._getOutput())              outline = Outline(data_collector._getOutput())
228              DataSetMapper.__init__(self, outline._getOutput())              DataSetMapper.__init__(self, outline._getOutput())
229    
230              Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))              Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))
231              # Default outline color is black.              # Default outline color is black.
232              Actor3D.setColor(self, Color.BLACK)              Actor3D.setColor(self, Color.BLACK)
233    
234              # Default line width is 1.              # Default line width is 1.
235              Actor3D._setLineWidth(self, 1)              Actor3D._setLineWidth(self, 1)
236              scene._addActor3D(viewport, Actor3D._getActor3D(self))              scene._addActor3D(viewport, Actor3D._getActor3D(self))
237    
   
238          # ----- Map on a clipped plane -----          # ----- Map on a clipped plane -----
239    
240          if(scalar != None):          if(scalar != None):
# Line 259  class MapOnPlaneClip(DataSetMapper, Acto Line 259  class MapOnPlaneClip(DataSetMapper, Acto
259    
260          DataSetMapper.__init__(self, Clipper._getOutput(self),          DataSetMapper.__init__(self, Clipper._getOutput(self),
261                  lookup_table._getLookupTable())                  lookup_table._getLookupTable())
   
262          DataSetMapper._setScalarRange(self, data_collector._getScalarRange())            DataSetMapper._setScalarRange(self, data_collector._getScalarRange())  
263    
264          Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))          Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))
265          scene._addActor3D(viewport, Actor3D._getActor3D(self))          scene._addActor3D(viewport, Actor3D._getActor3D(self))
266    
267    
   
268  #############################################################################  #############################################################################
269    
270    
   
271  # NOTE: DataSetMapper, Actor3D and Clipper were inherited  # NOTE: DataSetMapper, Actor3D and Clipper were inherited
272  # to allow access to their public methods from the driver.  # to allow access to their public methods from the driver.
273  class MapOnScalarClip(DataSetMapper, Actor3D, Clipper):  class MapOnScalarClip(DataSetMapper, Actor3D, Clipper):
# Line 281  class MapOnScalarClip(DataSetMapper, Act Line 278  class MapOnScalarClip(DataSetMapper, Act
278      # 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.
279      # 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.
280      # 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
281      # be loaded automatically.      # be loaded automatically. If no lut is specified, the color scheme will
282        # be used.
283    
284      def __init__(self, scene, data_collector, scalar = None,      def __init__(self, scene, data_collector, scalar = None,
285              viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, outline = True):              viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, outline = True):
286    
# Line 294  class MapOnScalarClip(DataSetMapper, Act Line 293  class MapOnScalarClip(DataSetMapper, Act
293          @type scalar: String          @type scalar: String
294          @param scalar: Scalar field to load from the source file          @param scalar: Scalar field to load from the source file
295          @type viewport: L{Viewport <constant.Viewport>} constant          @type viewport: L{Viewport <constant.Viewport>} constant
296          @param viewport: Viewport in which the object is to be rendered on          @param viewport: Viewport in which objects are to be rendered on
297          @type lut : L{Lut <constant.Lut>} constant          @type lut : L{Lut <constant.Lut>} constant
298          @param lut: Lookup table color scheme          @param lut: Lookup table color scheme
299          @type outline: Boolean          @type outline: Boolean
# Line 313  class MapOnScalarClip(DataSetMapper, Act Line 312  class MapOnScalarClip(DataSetMapper, Act
312          # ----- Outline -----          # ----- Outline -----
313    
314          if(outline == True):          if(outline == True):
             #outline = Outline(Glyph3D._getOutput(self))  
315              outline = Outline(data_collector._getOutput())              outline = Outline(data_collector._getOutput())
316              DataSetMapper.__init__(self, outline._getOutput())              DataSetMapper.__init__(self, outline._getOutput())
317    
318              Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))              Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))
319              # Default outline color is black.              # Default outline color is black.
320              Actor3D.setColor(self, Color.BLACK)              Actor3D.setColor(self, Color.BLACK)
321    
322              # Default line width is 1.              # Default line width is 1.
323              Actor3D._setLineWidth(self, 1)              Actor3D._setLineWidth(self, 1)
324              scene._addActor3D(viewport, Actor3D._getActor3D(self))              scene._addActor3D(viewport, Actor3D._getActor3D(self))
325    
   
326          # ----- Map clipped using a scalar value -----          # ----- Map clipped using a scalar value -----
327    
328          if(scalar != None):          if(scalar != None):
# Line 340  class MapOnScalarClip(DataSetMapper, Act Line 338  class MapOnScalarClip(DataSetMapper, Act
338              lookup_table = LookupTable()              lookup_table = LookupTable()
339              lookup_table._setLookupTableToGreyScale()              lookup_table._setLookupTableToGreyScale()
340    
341          # None because a plane is not required when a scalar value is          # None is used because a plane is not required when a scalar value is
342          # used to perform the clipping.          # used to perform the clipping.
343          Clipper.__init__(self, data_collector._getOutput(), None)          Clipper.__init__(self, data_collector._getOutput(), None)
344    
345          DataSetMapper.__init__(self, Clipper._getOutput(self),          DataSetMapper.__init__(self, Clipper._getOutput(self),
346                  lookup_table._getLookupTable())                  lookup_table._getLookupTable())
   
347          DataSetMapper._setScalarRange(self, data_collector._getScalarRange())            DataSetMapper._setScalarRange(self, data_collector._getScalarRange())  
348    
349          Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))          Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))

Legend:
Removed from v.947  
changed lines
  Added in v.948

  ViewVC Help
Powered by ViewVC 1.1.26