/[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 947 by jongui, Wed Jan 31 07:17:43 2007 UTC
# Line 11  from constant import Viewport, Color, Lu Line 11  from constant import Viewport, Color, Lu
11  from contourmodule import ContourModule  from contourmodule import ContourModule
12    
13    
14  # NOTE: DataSetMapper, Actor3D and Contour were inherited to allow access to  # NOTE: DataSetMapper, Actor3D and ContourModule were inherited to allow
15  # their public methods from the driver.  # access to their public methods from the driver.
   
16  class Contour(DataSetMapper, Actor3D, ContourModule):  class Contour(DataSetMapper, Actor3D, ContourModule):
17      """      """
18      Class that shows a scalar field by contour surfaces.      Class that shows a scalar field by contour surfaces.
# Line 22  class Contour(DataSetMapper, Actor3D, Co Line 21  class Contour(DataSetMapper, Actor3D, Co
21      # 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.
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 scalar field is specified, the first encountered in the file will      # If no scalar field is specified, the first encountered in the file will
24      # be loaded automatically.      # be loaded automatically. If no lut is specified, the color scheme will
25        # be used.
26      def __init__(self, scene, data_collector, scalar = None,      def __init__(self, scene, data_collector, scalar = None,
27              viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, outline = True):              viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, outline = True):
28          """          """
# Line 34  class Contour(DataSetMapper, Actor3D, Co Line 34  class Contour(DataSetMapper, Actor3D, Co
34          @type scalar: String          @type scalar: String
35          @param scalar: Scalar field to load from the source file          @param scalar: Scalar field to load from the source file
36          @type viewport: L{Viewport <constant.Viewport>} constant            @type viewport: L{Viewport <constant.Viewport>} constant  
37          @param viewport: Viewport in which the object is to be rendered on          @param viewport: Viewport in which objects are to be rendered on
38          @type lut : L{Lut <constant.Lut>} constant          @type lut : L{Lut <constant.Lut>} constant
39          @param lut: Lookup table color scheme          @param lut: Lookup table color scheme
40          @type outline: Boolean          @type outline: Boolean
# Line 59  class Contour(DataSetMapper, Actor3D, Co Line 59  class Contour(DataSetMapper, Actor3D, Co
59              Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))              Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))
60              # Default outline color is black.              # Default outline color is black.
61              Actor3D.setColor(self, Color.BLACK)              Actor3D.setColor(self, Color.BLACK)
62    
63              # Default line width is 1.              # Default line width is 1.
64              Actor3D._setLineWidth(self, 1)              Actor3D._setLineWidth(self, 1)
65              scene._addActor3D(viewport, Actor3D._getActor3D(self))              scene._addActor3D(viewport, Actor3D._getActor3D(self))
66    
67            # ----- Contour -----
         # ----- contour -----  
68    
69          if(scalar != None): # True only if a scalar field was specified.          if(scalar != None): # True only if a scalar field was specified.
70              data_collector._setActiveScalar(scalar)              data_collector._setActiveScalar(scalar)
# Line 85  class Contour(DataSetMapper, Actor3D, Co Line 85  class Contour(DataSetMapper, Actor3D, Co
85          ContourModule.__init__(self, data_collector._getOutput())            ContourModule.__init__(self, data_collector._getOutput())  
86          # By default 10 contours are generated and the scalar range is based          # By default 10 contours are generated and the scalar range is based
87          # on the scalar data.          # on the scalar data.
88          ContourModule.generateContours(self, 10, data_collector._getScalarRange()[0],          ContourModule.generateContours(self, 10,
89                    data_collector._getScalarRange()[0],
90                  data_collector._getScalarRange()[1])                  data_collector._getScalarRange()[1])
91    
92          DataSetMapper.__init__(self, ContourModule._getOutput(self),          DataSetMapper.__init__(self, ContourModule._getOutput(self),
93                  lookup_table._getLookupTable())                  lookup_table._getLookupTable())
   
94          DataSetMapper._setScalarRange(self, data_collector._getScalarRange())          DataSetMapper._setScalarRange(self, data_collector._getScalarRange())
95    
96          Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))          Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))
97          scene._addActor3D(viewport, Actor3D._getActor3D(self))          scene._addActor3D(viewport, Actor3D._getActor3D(self))
98    
99    
100    ###############################################################################
101    
102    
103  from transform import Transform  from transform import Transform
104  from plane import Plane  from plane import Plane
105  from cutter import Cutter  from cutter import Cutter
106    
107  # NOTE: DataSetMapper, Actor3D, Contour, Transform, Plane and Cutter were  # NOTE: DataSetMapper, Actor3D, ContourModule, Transform, Plane and Cutter were
108  # inherited to allow access to their public methods from the driver.  # inherited to allow access to their public methods from the driver.
109  class ContourOnPlaneCut(DataSetMapper, Actor3D, ContourModule, Transform, Plane, Cutter):  class ContourOnPlaneCut(DataSetMapper, Actor3D, ContourModule, Transform,
110            Plane, Cutter):
111      """      """
112      Class that show a scalar field contoured on a plane.          Class that show a scalar field contoured on a cut plane.    
113      """      """
114            
115      # 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.
116      # 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.
117      # 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
118      # be loaded automatically.      # be loaded automatically. If no lut is specified, the color scheme will
119        # be used.
120      def __init__(self, scene, data_collector, scalar = None,      def __init__(self, scene, data_collector, scalar = None,
121              viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, outline = True):              viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, outline = True):
122    
# Line 124  class ContourOnPlaneCut(DataSetMapper, A Line 129  class ContourOnPlaneCut(DataSetMapper, A
129          @type scalar: String          @type scalar: String
130          @param scalar: Scalar field to load from the source file          @param scalar: Scalar field to load from the source file
131          @type viewport: L{Viewport <constant.Viewport>} constant          @type viewport: L{Viewport <constant.Viewport>} constant
132          @param viewport: Viewport in which the object is to be rendered on          @param viewport: Viewport in which objects are to be rendered on
133          @type lut : L{Lut <constant.Lut>} constant          @type lut : L{Lut <constant.Lut>} constant
134          @param lut: Lookup table color scheme          @param lut: Lookup table color scheme
135          @type outline: Boolean          @type outline: Boolean
# Line 143  class ContourOnPlaneCut(DataSetMapper, A Line 148  class ContourOnPlaneCut(DataSetMapper, A
148          # ----- Outline -----          # ----- Outline -----
149    
150          if(outline == True):          if(outline == True):
             #outline = Outline(Glyph3D._getOutput(self))  
151              outline = Outline(data_collector._getOutput())              outline = Outline(data_collector._getOutput())
152              DataSetMapper.__init__(self, outline._getOutput())              DataSetMapper.__init__(self, outline._getOutput())
153    
154              Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))              Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))
155              # Default outline color is black.              # Default outline color is black.
156              Actor3D.setColor(self, Color.BLACK)              Actor3D.setColor(self, Color.BLACK)
157    
158              # Default line width is 1.              # Default line width is 1.
159              Actor3D._setLineWidth(self, 1)              Actor3D._setLineWidth(self, 1)
160              scene._addActor3D(viewport, Actor3D._getActor3D(self))              scene._addActor3D(viewport, Actor3D._getActor3D(self))
161    
162            # ----- Contour on a cut plane -----
         # ----- contour on a plane -----  
163    
164          if(scalar != None):          if(scalar != None):
165              data_collector._setActiveScalar(scalar)              data_collector._setActiveScalar(scalar)
# Line 170  class ContourOnPlaneCut(DataSetMapper, A Line 174  class ContourOnPlaneCut(DataSetMapper, A
174              lookup_table = LookupTable()              lookup_table = LookupTable()
175              lookup_table._setLookupTableToGreyScale()              lookup_table._setLookupTableToGreyScale()
176    
         """  
         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])  
         """  
177          Transform.__init__(self)              Transform.__init__(self)    
178          Plane.__init__(self, Transform._getTransform(self))          Plane.__init__(self, Transform._getTransform(self))
179    
180          Cutter.__init__(self, data_collector._getOutput(),          Cutter.__init__(self, data_collector._getOutput(),
181                  Plane._getPlane(self))                  Plane._getPlane(self))
   
182          ContourModule.__init__(self, Cutter._getOutput(self))          ContourModule.__init__(self, Cutter._getOutput(self))
183    
184          # By default 10 contours are generated and the scalar range is based          # By default 10 contours are generated and the scalar range is based
185          # on the scalar data.          # on the scalar data.
186          ContourModule.generateContours(self, 10, data_collector._getScalarRange()[0],          ContourModule.generateContours(self, 10,
187                    data_collector._getScalarRange()[0],
188                  data_collector._getScalarRange()[1])                  data_collector._getScalarRange()[1])
189    
190          DataSetMapper.__init__(self, ContourModule._getOutput(self),          DataSetMapper.__init__(self, ContourModule._getOutput(self),
191                  lookup_table._getLookupTable())                  lookup_table._getLookupTable())
   
192          DataSetMapper._setScalarRange(self, data_collector._getScalarRange())            DataSetMapper._setScalarRange(self, data_collector._getScalarRange())  
193    
194          Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))          Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))
195          scene._addActor3D(viewport, Actor3D._getActor3D(self))          scene._addActor3D(viewport, Actor3D._getActor3D(self))
196    
197    
198    ###############################################################################
199    
200    
201  from clipper import Clipper  from clipper import Clipper
202    
203  # NOTE: DataSetMapper, Actor3D, Contour, Transform, Plane and Clipper were  # NOTE: DataSetMapper, Actor3D, ContourModule, Transform, Plane and Clipper
204  # inherited to allow access to their public methods from the driver.  # were inherited to allow access to their public methods from the driver.
205  class ContourOnPlaneClip(DataSetMapper, Actor3D, ContourModule, Transform,  class ContourOnPlaneClip(DataSetMapper, Actor3D, ContourModule, Transform,
206          Plane, Clipper):          Plane, Clipper):
207      """      """
# Line 210  class ContourOnPlaneClip(DataSetMapper, Line 211  class ContourOnPlaneClip(DataSetMapper,
211      # 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.
212      # 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.
213      # 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
214      # be loaded automatically.      # be loaded automatically. If no lut is specified, the color scheme will
215        # be used.
216      def __init__(self, scene, data_collector, scalar = None,      def __init__(self, scene, data_collector, scalar = None,
217              viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, outline = True):              viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, outline = True):
218    
# Line 223  class ContourOnPlaneClip(DataSetMapper, Line 225  class ContourOnPlaneClip(DataSetMapper,
225          @type scalar: String          @type scalar: String
226          @param scalar: Scalar field to load from the source file          @param scalar: Scalar field to load from the source file
227          @type viewport: L{Viewport <constant.Viewport>} constant          @type viewport: L{Viewport <constant.Viewport>} constant
228          @param viewport: Viewport in which the object is to be rendered on          @param viewport: Viewport in which objects are to be rendered on
229          @type lut : L{Lut <constant.Lut>} constant          @type lut : L{Lut <constant.Lut>} constant
230          @param lut: Lookup table color scheme          @param lut: Lookup table color scheme
231          @type outline: Boolean          @type outline: Boolean
# Line 242  class ContourOnPlaneClip(DataSetMapper, Line 244  class ContourOnPlaneClip(DataSetMapper,
244          # ----- Outline -----          # ----- Outline -----
245    
246          if(outline == True):          if(outline == True):
             #outline = Outline(Glyph3D._getOutput(self))  
247              outline = Outline(data_collector._getOutput())              outline = Outline(data_collector._getOutput())
248              DataSetMapper.__init__(self, outline._getOutput())              DataSetMapper.__init__(self, outline._getOutput())
249    
250              Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))              Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))
251              # Default outline color is black.              # Default outline color is black.
252              Actor3D.setColor(self, Color.BLACK)              Actor3D.setColor(self, Color.BLACK)
253    
254              # Default line width is 1.              # Default line width is 1.
255              Actor3D._setLineWidth(self, 1)              Actor3D._setLineWidth(self, 1)
256              scene._addActor3D(viewport, Actor3D._getActor3D(self))              scene._addActor3D(viewport, Actor3D._getActor3D(self))
257    
258            # ----- Contour on a clipped plane -----
         # ----- contour on a clipped plane -----  
259    
260          if(scalar != None):          if(scalar != None):
261              data_collector._setActiveScalar(scalar)              data_collector._setActiveScalar(scalar)
# Line 279  class ContourOnPlaneClip(DataSetMapper, Line 280  class ContourOnPlaneClip(DataSetMapper,
280          ContourModule.__init__(self, Clipper._getOutput(self))          ContourModule.__init__(self, Clipper._getOutput(self))
281          # By default 10 contours are generated and the scalar range is based          # By default 10 contours are generated and the scalar range is based
282          # on the scalar data.          # on the scalar data.
283          ContourModule.generateContours(self, 10, data_collector._getScalarRange()[0],          ContourModule.generateContours(self, 10,
284                    data_collector._getScalarRange()[0],
285                  data_collector._getScalarRange()[1])                  data_collector._getScalarRange()[1])
286    
287          DataSetMapper.__init__(self, ContourModule._getOutput(self),          DataSetMapper.__init__(self, ContourModule._getOutput(self),
288                  lookup_table._getLookupTable())                  lookup_table._getLookupTable())
   
289          DataSetMapper._setScalarRange(self, data_collector._getScalarRange())            DataSetMapper._setScalarRange(self, data_collector._getScalarRange())  
290    
291          Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))          Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))
292          scene._addActor3D(viewport, Actor3D._getActor3D(self))          scene._addActor3D(viewport, Actor3D._getActor3D(self))
293    
   
   

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

  ViewVC Help
Powered by ViewVC 1.1.26