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

Diff of /trunk/pyvisi/py_src/contour.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 996 by jongui, Mon Feb 26 03:43:13 2007 UTC
# Line 10  from outline import Outline Line 10  from outline import Outline
10  from constant import Viewport, Color, Lut  from constant import Viewport, Color, Lut
11  from contourmodule import ContourModule  from contourmodule import ContourModule
12    
13    # NOTE: DataSetMapper, Actor3D and ContourModule were inherited to allow
14  # NOTE: DataSetMapper, Actor3D and Contour were inherited to allow access to  # access to their public methods from the driver.
 # their public methods from the driver.  
   
15  class Contour(DataSetMapper, Actor3D, ContourModule):  class Contour(DataSetMapper, Actor3D, ContourModule):
16      """      """
17      Class that shows a scalar field by contour surfaces.      Class that shows a scalar field by contour surfaces.
# Line 21  class Contour(DataSetMapper, Actor3D, Co Line 19  class Contour(DataSetMapper, Actor3D, Co
19    
20      # 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.
21      # 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.
22      # If no scalar field is specified, the first encountered in the file will      # If no lut is specified, the color scheme will be used.
23      # be loaded automatically.      def __init__(self, scene, data_collector, viewport = Viewport.SOUTH_WEST,
24      def __init__(self, scene, data_collector, scalar = None,              lut = Lut.COLOR, outline = True):
             viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, outline = True):  
25          """          """
26          @type scene: L{Scene <scene.Scene>} object          @type scene: L{Scene <scene.Scene>} object
27          @param scene: Scene in which objects are to be rendered on          @param scene: Scene in which objects are to be rendered on
28          @type data_collector: L{DataCollector <datacollector.DataCollector>}          @type data_collector: L{DataCollector <datacollector.DataCollector>}
29                  object                  object
30          @param data_collector: Deal with source of data for visualisation          @param data_collector: Deal with source of data for visualisation
         @type scalar: String  
         @param scalar: Scalar field to load from the source file  
31          @type viewport: L{Viewport <constant.Viewport>} constant            @type viewport: L{Viewport <constant.Viewport>} constant  
32          @param viewport: Viewport in which the object is to be rendered on          @param viewport: Viewport in which objects are to be rendered on
33          @type lut : L{Lut <constant.Lut>} constant          @type lut : L{Lut <constant.Lut>} constant
34          @param lut: Lookup table color scheme          @param lut: Lookup table color scheme
35          @type outline: Boolean          @type outline: Boolean
# Line 59  class Contour(DataSetMapper, Actor3D, Co Line 54  class Contour(DataSetMapper, Actor3D, Co
54              Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))              Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))
55              # Default outline color is black.              # Default outline color is black.
56              Actor3D.setColor(self, Color.BLACK)              Actor3D.setColor(self, Color.BLACK)
57    
58              # Default line width is 1.              # Default line width is 1.
59              Actor3D._setLineWidth(self, 1)              Actor3D._setLineWidth(self, 1)
60              scene._addActor3D(viewport, Actor3D._getActor3D(self))              scene._addActor3D(viewport, Actor3D._getActor3D(self))
61    
62            # ----- Contour -----
         # ----- contour -----  
   
         if(scalar != None): # True only if a scalar field was specified.  
             data_collector._setActiveScalar(scalar)  
   
         lookup_table = LookupTable()  
63    
64          # NOTE: Lookup table color mapping (color or grey scale) MUST be set          # NOTE: Lookup table color mapping (color or grey scale) MUST be set
65          # before DataSetMapper. If it is done after DataSetMapper, no effect          # before DataSetMapper. If it is done after DataSetMapper, no effect
# Line 85  class Contour(DataSetMapper, Actor3D, Co Line 75  class Contour(DataSetMapper, Actor3D, Co
75          ContourModule.__init__(self, data_collector._getOutput())            ContourModule.__init__(self, data_collector._getOutput())  
76          # By default 10 contours are generated and the scalar range is based          # By default 10 contours are generated and the scalar range is based
77          # on the scalar data.          # on the scalar data.
78          ContourModule.generateContours(self, 10, data_collector._getScalarRange()[0],          ContourModule.generateContours(self, 10,
79                    data_collector._getScalarRange()[0],
80                  data_collector._getScalarRange()[1])                  data_collector._getScalarRange()[1])
81    
82          DataSetMapper.__init__(self, ContourModule._getOutput(self),          DataSetMapper.__init__(self, ContourModule._getOutput(self),
83                  lookup_table._getLookupTable())                  lookup_table._getLookupTable())
   
84          DataSetMapper._setScalarRange(self, data_collector._getScalarRange())          DataSetMapper._setScalarRange(self, data_collector._getScalarRange())
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
95  from cutter import Cutter  from cutter import Cutter
96    
97  # NOTE: DataSetMapper, Actor3D, Contour, Transform, Plane and Cutter were  # NOTE: DataSetMapper, Actor3D, ContourModule, Transform, Plane and Cutter were
98  # inherited to allow access to their public methods from the driver.  # inherited to allow access to their public methods from the driver.
99  class ContourOnPlaneCut(DataSetMapper, Actor3D, ContourModule, Transform, Plane, Cutter):  class ContourOnPlaneCut(DataSetMapper, Actor3D, ContourModule, Transform,
100            Plane, Cutter):
101      """      """
102      Class that show a scalar field contoured on a plane.          Class that show a scalar field contoured on a cut plane.    
103      """      """
104            
105      # 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.
106      # 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.
107      # If no scalar field is specified, the first encountered in the file will      # If no lut is specified, the color scheme will be used.
108      # be loaded automatically.      def __init__(self, scene, data_collector, viewport = Viewport.SOUTH_WEST,
109      def __init__(self, scene, data_collector, scalar = None,              lut = Lut.COLOR, outline = True):
             viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, outline = True):  
110    
111          """          """
112          @type scene: L{Scene <scene.Scene>} object          @type scene: L{Scene <scene.Scene>} object
# Line 121  class ContourOnPlaneCut(DataSetMapper, A Line 114  class ContourOnPlaneCut(DataSetMapper, A
114          @type data_collector: L{DataCollector <datacollector.DataCollector>}          @type data_collector: L{DataCollector <datacollector.DataCollector>}
115                  object                  object
116          @param data_collector: Deal with source of data for visualisation          @param data_collector: Deal with source of data for visualisation
         @type scalar: String  
         @param scalar: Scalar field to load from the source file  
117          @type viewport: L{Viewport <constant.Viewport>} constant          @type viewport: L{Viewport <constant.Viewport>} constant
118          @param viewport: Viewport in which the object is to be rendered on          @param viewport: Viewport in which objects are to be rendered on
119          @type lut : L{Lut <constant.Lut>} constant          @type lut : L{Lut <constant.Lut>} constant
120          @param lut: Lookup table color scheme          @param lut: Lookup table color scheme
121          @type outline: Boolean          @type outline: Boolean
# Line 143  class ContourOnPlaneCut(DataSetMapper, A Line 134  class ContourOnPlaneCut(DataSetMapper, A
134          # ----- Outline -----          # ----- Outline -----
135    
136          if(outline == True):          if(outline == True):
             #outline = Outline(Glyph3D._getOutput(self))  
137              outline = Outline(data_collector._getOutput())              outline = Outline(data_collector._getOutput())
138              DataSetMapper.__init__(self, outline._getOutput())              DataSetMapper.__init__(self, outline._getOutput())
139    
140              Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))              Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))
141              # Default outline color is black.              # Default outline color is black.
142              Actor3D.setColor(self, Color.BLACK)              Actor3D.setColor(self, Color.BLACK)
143    
144              # Default line width is 1.              # Default line width is 1.
145              Actor3D._setLineWidth(self, 1)              Actor3D._setLineWidth(self, 1)
146              scene._addActor3D(viewport, Actor3D._getActor3D(self))              scene._addActor3D(viewport, Actor3D._getActor3D(self))
147    
148            # ----- Contour on a cut plane -----
         # ----- contour on a plane -----  
   
         if(scalar != None):  
             data_collector._setActiveScalar(scalar)  
149    
150          # NOTE: Lookup table color mapping (color or grey scale) MUST be set          # NOTE: Lookup table color mapping (color or grey scale) MUST be set
151          # before DataSetMapper. If it is done after DataSetMapper, no effect          # before DataSetMapper. If it is done after DataSetMapper, no effect
# Line 170  class ContourOnPlaneCut(DataSetMapper, A Line 157  class ContourOnPlaneCut(DataSetMapper, A
157              lookup_table = LookupTable()              lookup_table = LookupTable()
158              lookup_table._setLookupTableToGreyScale()              lookup_table._setLookupTableToGreyScale()
159    
         """  
         Contour.__init__(self, data_collector._getOutput())  
         # By default 10 contours are generated and the scalar range is based  
         # on the scalar data.  
         Contour.generateContours(self, 10, data_collector._getScalarRange()[0],  
                 data_collector._getScalarRange()[1])  
         """  
160          Transform.__init__(self)              Transform.__init__(self)    
161          Plane.__init__(self, Transform._getTransform(self))          Plane.__init__(self, Transform._getTransform(self))
162    
163          Cutter.__init__(self, data_collector._getOutput(),          Cutter.__init__(self, data_collector._getOutput(),
164                  Plane._getPlane(self))                  Plane._getPlane(self))
   
165          ContourModule.__init__(self, Cutter._getOutput(self))          ContourModule.__init__(self, Cutter._getOutput(self))
166    
167          # By default 10 contours are generated and the scalar range is based          # By default 10 contours are generated and the scalar range is based
168          # on the scalar data.          # on the scalar data.
169          ContourModule.generateContours(self, 10, data_collector._getScalarRange()[0],          ContourModule.generateContours(self, 10,
170                    data_collector._getScalarRange()[0],
171                  data_collector._getScalarRange()[1])                  data_collector._getScalarRange()[1])
172    
173          DataSetMapper.__init__(self, ContourModule._getOutput(self),          DataSetMapper.__init__(self, ContourModule._getOutput(self),
174                  lookup_table._getLookupTable())                  lookup_table._getLookupTable())
   
175          DataSetMapper._setScalarRange(self, data_collector._getScalarRange())            DataSetMapper._setScalarRange(self, data_collector._getScalarRange())  
176    
177          Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))          Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))
178          scene._addActor3D(viewport, Actor3D._getActor3D(self))          scene._addActor3D(viewport, Actor3D._getActor3D(self))
179    
180    
181    ###############################################################################
182    
183    
184  from clipper import Clipper  from clipper import Clipper
185    
186  # NOTE: DataSetMapper, Actor3D, Contour, Transform, Plane and Clipper were  # NOTE: DataSetMapper, Actor3D, ContourModule, Transform, Plane and Clipper
187  # inherited to allow access to their public methods from the driver.  # were inherited to allow access to their public methods from the driver.
188  class ContourOnPlaneClip(DataSetMapper, Actor3D, ContourModule, Transform,  class ContourOnPlaneClip(DataSetMapper, Actor3D, ContourModule, Transform,
189          Plane, Clipper):          Plane, Clipper):
190      """      """
# Line 209  class ContourOnPlaneClip(DataSetMapper, Line 193  class ContourOnPlaneClip(DataSetMapper,
193            
194      # 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.
195      # 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.
196      # If no scalar field is specified, the first encountered in the file will      # If no lut is specified, the color scheme will be used.
197      # be loaded automatically.      def __init__(self, scene, data_collector, viewport = Viewport.SOUTH_WEST,
198      def __init__(self, scene, data_collector, scalar = None,              lut = Lut.COLOR, outline = True):
             viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, outline = True):  
199    
200          """          """
201          @type scene: L{Scene <scene.Scene>} object          @type scene: L{Scene <scene.Scene>} object
# Line 220  class ContourOnPlaneClip(DataSetMapper, Line 203  class ContourOnPlaneClip(DataSetMapper,
203          @type data_collector: L{DataCollector <datacollector.DataCollector>}          @type data_collector: L{DataCollector <datacollector.DataCollector>}
204                  object                  object
205          @param data_collector: Deal with source of data for visualisation          @param data_collector: Deal with source of data for visualisation
         @type scalar: String  
         @param scalar: Scalar field to load from the source file  
206          @type viewport: L{Viewport <constant.Viewport>} constant          @type viewport: L{Viewport <constant.Viewport>} constant
207          @param viewport: Viewport in which the object is to be rendered on          @param viewport: Viewport in which objects are to be rendered on
208          @type lut : L{Lut <constant.Lut>} constant          @type lut : L{Lut <constant.Lut>} constant
209          @param lut: Lookup table color scheme          @param lut: Lookup table color scheme
210          @type outline: Boolean          @type outline: Boolean
# Line 242  class ContourOnPlaneClip(DataSetMapper, Line 223  class ContourOnPlaneClip(DataSetMapper,
223          # ----- Outline -----          # ----- Outline -----
224    
225          if(outline == True):          if(outline == True):
             #outline = Outline(Glyph3D._getOutput(self))  
226              outline = Outline(data_collector._getOutput())              outline = Outline(data_collector._getOutput())
227              DataSetMapper.__init__(self, outline._getOutput())              DataSetMapper.__init__(self, outline._getOutput())
228    
229              Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))              Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))
230              # Default outline color is black.              # Default outline color is black.
231              Actor3D.setColor(self, Color.BLACK)              Actor3D.setColor(self, Color.BLACK)
232    
233              # Default line width is 1.              # Default line width is 1.
234              Actor3D._setLineWidth(self, 1)              Actor3D._setLineWidth(self, 1)
235              scene._addActor3D(viewport, Actor3D._getActor3D(self))              scene._addActor3D(viewport, Actor3D._getActor3D(self))
236    
237            # ----- Contour on a clipped plane -----
         # ----- contour on a clipped plane -----  
   
         if(scalar != None):  
             data_collector._setActiveScalar(scalar)  
238    
239          # NOTE: Lookup table color mapping (color or grey scale) MUST be set          # NOTE: Lookup table color mapping (color or grey scale) MUST be set
240          # before DataSetMapper. If it is done after DataSetMapper, no effect          # before DataSetMapper. If it is done after DataSetMapper, no effect
# Line 279  class ContourOnPlaneClip(DataSetMapper, Line 256  class ContourOnPlaneClip(DataSetMapper,
256          ContourModule.__init__(self, Clipper._getOutput(self))          ContourModule.__init__(self, Clipper._getOutput(self))
257          # By default 10 contours are generated and the scalar range is based          # By default 10 contours are generated and the scalar range is based
258          # on the scalar data.          # on the scalar data.
259          ContourModule.generateContours(self, 10, data_collector._getScalarRange()[0],          ContourModule.generateContours(self, 10,
260                    data_collector._getScalarRange()[0],
261                  data_collector._getScalarRange()[1])                  data_collector._getScalarRange()[1])
262    
263          DataSetMapper.__init__(self, ContourModule._getOutput(self),          DataSetMapper.__init__(self, ContourModule._getOutput(self),
264                  lookup_table._getLookupTable())                  lookup_table._getLookupTable())
   
265          DataSetMapper._setScalarRange(self, data_collector._getScalarRange())            DataSetMapper._setScalarRange(self, data_collector._getScalarRange())  
266    
267          Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))          Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))
268          scene._addActor3D(viewport, Actor3D._getActor3D(self))          scene._addActor3D(viewport, Actor3D._getActor3D(self))
269    
   
   

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

  ViewVC Help
Powered by ViewVC 1.1.26