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

Diff of /trunk/pyvisi/py_src/velocity.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 949 by jongui, Fri Feb 2 05:33:05 2007 UTC
# Line 15  from point import StructuredPoints Line 15  from point import StructuredPoints
15    
16  # NOTE: DataSetMapper, Actor3D, Arrow2D, Arrow3D, Glyph3D, StructuredPoints and  # NOTE: DataSetMapper, Actor3D, Arrow2D, Arrow3D, Glyph3D, StructuredPoints and
17  # Probe were inherited to allow access to their public methods from the driver.  # Probe were inherited to allow access to their public methods from the driver.
18  class Velocity(DataSetMapper, Actor3D, Arrow2D, Arrow3D,  Glyph3D, StructuredPoints, Probe):  class Velocity(DataSetMapper, Actor3D, Arrow2D, Arrow3D,  Glyph3D,
19            StructuredPoints, Probe):
20      """      """
21      Class that show a vector field using arrows.          Class that show a vector field using arrows.    
22      """      """
# Line 23  class Velocity(DataSetMapper, Actor3D, A Line 24  class Velocity(DataSetMapper, Actor3D, A
24      # 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.
25      # 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.
26      # If no vector field is specified, the first encountered in the file will      # If no vector field is specified, the first encountered in the file will
27      # be loaded automatically.      # be loaded automatically. If no lut is specified, the color scheme will
28        # be used.
29      def __init__(self, scene, data_collector, vector = None,      def __init__(self, scene, data_collector, vector = None,
             viewport = Viewport.SOUTH_WEST, outline = True,  
30              arrow = Arrow.TWO_D, color_mode = ColorMode.VECTOR,              arrow = Arrow.TWO_D, color_mode = ColorMode.VECTOR,
31              lut = Lut.COLOR):              viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, outline = True):
32    
33          """          """
34          @type scene: L{Scene <scene.Scene>} object          @type scene: L{Scene <scene.Scene>} object
# Line 37  class Velocity(DataSetMapper, Actor3D, A Line 38  class Velocity(DataSetMapper, Actor3D, A
38          @param data_collector: Deal with source of data for visualisation          @param data_collector: Deal with source of data for visualisation
39          @type vector: String          @type vector: String
40          @param vector: Vector field to load from the source file          @param vector: Vector field to load from the source file
         @type viewport: L{Viewport <constant.Viewport>} constant  
         @param viewport: Viewport in which the object is to be rendered on  
         @type outline: Boolean  
         @param outline: Places an outline around the domain surface  
41          @type arrow: L{Arrow <constant.Arrow>} constant          @type arrow: L{Arrow <constant.Arrow>} constant
42          @param arrow: Type of arrow (two dimensional or three dimensional)          @param arrow: Type of arrow (two dimensional or three dimensional)
43          @type color_mode: L{ColorMode <constant.ColorMode>} constant          @type color_mode: L{ColorMode <constant.ColorMode>} constant
44          @param color_mode: Type of color mode          @param color_mode: Type of color mode
45            @type viewport: L{Viewport <constant.Viewport>} constant
46            @param viewport: Viewport in which objects are to be rendered on
47          @type lut : L{Lut <constant.Lut>} constant          @type lut : L{Lut <constant.Lut>} constant
48          @param lut: Lookup table color scheme          @param lut: Lookup table color scheme
49            @type outline: Boolean
50            @param outline: Places an outline around the domain surface
51          """          """
52    
53          # NOTE: Actor3D is inherited and there are two instances declared here.          # NOTE: Actor3D is inherited and there are two instances declared here.
# Line 61  class Velocity(DataSetMapper, Actor3D, A Line 62  class Velocity(DataSetMapper, Actor3D, A
62          # ----- Outline -----          # ----- Outline -----
63    
64          if(outline == True):          if(outline == True):
             #outline = Outline(Glyph3D._getOutput(self))  
65              outline = Outline(data_collector._getOutput())              outline = Outline(data_collector._getOutput())
66              DataSetMapper.__init__(self, outline._getOutput())              DataSetMapper.__init__(self, outline._getOutput())
67    
68              Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))              Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))
69              # Default outline color is black.              # Default outline color is black.
70              Actor3D.setColor(self, Color.BLACK)              Actor3D.setColor(self, Color.BLACK)
71    
72              # Default line width is 1.              # Default line width is 1.
73              Actor3D._setLineWidth(self, 1)              Actor3D._setLineWidth(self, 1)
74              scene._addActor3D(viewport, Actor3D._getActor3D(self))              scene._addActor3D(viewport, Actor3D._getActor3D(self))
75    
   
76          # ----- Velocity -----          # ----- Velocity -----
77    
78          if(vector != None):          if(vector != None):
# Line 92  class Velocity(DataSetMapper, Actor3D, A Line 92  class Velocity(DataSetMapper, Actor3D, A
92          Probe.__init__(self, data_collector._getOutput(),          Probe.__init__(self, data_collector._getOutput(),
93                  StructuredPoints._getStructuredPoints(self))                  StructuredPoints._getStructuredPoints(self))
94    
   
95          if(arrow == Arrow.TWO_D): # Use 2D arrows.          if(arrow == Arrow.TWO_D): # Use 2D arrows.
96              Arrow2D.__init__(self)              Arrow2D.__init__(self)
             #Glyph3D.__init__(self, data_collector._getOutput(),  
97              Glyph3D.__init__(self, Probe._getOutput(self),              Glyph3D.__init__(self, Probe._getOutput(self),
             #Glyph3D.__init__(self, MaskPoints._getOutput(self),  
98                      Arrow2D._getOutput(self), data_collector._getScalarRange())                      Arrow2D._getOutput(self), data_collector._getScalarRange())
99          elif(arrow == Arrow.THREE_D): # Use 3D arrows.          elif(arrow == Arrow.THREE_D): # Use 3D arrows.
100              Arrow3D.__init__(self)              Arrow3D.__init__(self)
             #Glyph3D.__init__(self, data_collector._getOutput(),  
101              Glyph3D.__init__(self, Probe._getOutput(self),              Glyph3D.__init__(self, Probe._getOutput(self),
             #Glyph3D.__init__(self, MaskPoints._getOutput(self),  
102                      Arrow3D._getOutput(self), data_collector._getScalarRange())                      Arrow3D._getOutput(self), data_collector._getScalarRange())
103    
104          DataSetMapper.__init__(self, Glyph3D._getOutput(self),          DataSetMapper.__init__(self, Glyph3D._getOutput(self),
# Line 122  class Velocity(DataSetMapper, Actor3D, A Line 117  class Velocity(DataSetMapper, Actor3D, A
117          scene._addActor3D(viewport, Actor3D._getActor3D(self))          scene._addActor3D(viewport, Actor3D._getActor3D(self))
118    
119    
120    ###############################################################################
121    
122    
123  from transform import Transform  from transform import Transform
124  from plane import Plane  from plane import Plane
125  from cutter import Cutter  from cutter import Cutter
# Line 138  class VelocityOnPlaneCut(DataSetMapper, Line 136  class VelocityOnPlaneCut(DataSetMapper,
136      # 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.
137      # 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.
138      # If no vector field is specified, the first encountered in the file will      # If no vector field is specified, the first encountered in the file will
139      # be loaded automatically.      # be loaded automatically.  If no lut is specified, the color scheme will
140        # be used.
141      def __init__(self, scene, data_collector, vector = None,      def __init__(self, scene, data_collector, vector = None,
142              viewport = Viewport.SOUTH_WEST, outline = True,              arrow = Arrow.TWO_D, color_mode = ColorMode.VECTOR,
143              arrow = Arrow.THREE_D, color_mode = ColorMode.VECTOR,              viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, outline = True):
             lut = Lut.COLOR):  
   
144          """          """
145          @type scene: L{Scene <scene.Scene>} object          @type scene: L{Scene <scene.Scene>} object
146          @param scene: Scene in which objects are to be rendered on          @param scene: Scene in which objects are to be rendered on
# Line 152  class VelocityOnPlaneCut(DataSetMapper, Line 149  class VelocityOnPlaneCut(DataSetMapper,
149          @param data_collector: Deal with source of data for visualisation          @param data_collector: Deal with source of data for visualisation
150          @type vector: String          @type vector: String
151          @param vector: Vector field to load from the source file          @param vector: Vector field to load from the source file
         @type viewport: L{Viewport <constant.Viewport>} constant  
         @param viewport: Viewport in which the object is to be rendered on  
         @type outline: Boolean  
         @param outline: Places an outline around the domain surface  
152          @type arrow: L{Arrow <constant.Arrow>} constant          @type arrow: L{Arrow <constant.Arrow>} constant
153          @param arrow: Type of arrow (two dimensional or three dimensional)          @param arrow: Type of arrow (two dimensional or three dimensional)
154          @type color_mode: L{ColorMode <constant.ColorMode>} constant          @type color_mode: L{ColorMode <constant.ColorMode>} constant
155          @param color_mode: Type of color mode          @param color_mode: Type of color mode
156            @type viewport: L{Viewport <constant.Viewport>} constant
157            @param viewport: Viewport in which objects are to be rendered on
158          @type lut : L{Lut <constant.Lut>} constant          @type lut : L{Lut <constant.Lut>} constant
159          @param lut: Lookup table color scheme          @param lut: Lookup table color scheme
160            @type outline: Boolean
161            @param outline: Places an outline around the domain surface
162          """          """
163    
164          # NOTE: Actor3D is inherited and there are two instances declared here.          # NOTE: Actor3D is inherited and there are two instances declared here.
# Line 176  class VelocityOnPlaneCut(DataSetMapper, Line 173  class VelocityOnPlaneCut(DataSetMapper,
173          # ----- Outline -----          # ----- Outline -----
174    
175          if(outline == True):          if(outline == True):
             #outline = Outline(Glyph3D._getOutput(self))  
176              outline = Outline(data_collector._getOutput())              outline = Outline(data_collector._getOutput())
177              DataSetMapper.__init__(self, outline._getOutput())              DataSetMapper.__init__(self, outline._getOutput())
178    
179              Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))              Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))
180              # Default outline color is black.              # Default outline color is black.
181              Actor3D.setColor(self, Color.BLACK)              Actor3D.setColor(self, Color.BLACK)
182    
183              # Default line width is 1.              # Default line width is 1.
184              Actor3D._setLineWidth(self, 1)              Actor3D._setLineWidth(self, 1)
185              scene._addActor3D(viewport, Actor3D._getActor3D(self))              scene._addActor3D(viewport, Actor3D._getActor3D(self))
186    
   
187          # ----- Velocity on a cut plane -----          # ----- Velocity on a cut plane -----
188    
189          if(vector != None):          if(vector != None):
# Line 211  class VelocityOnPlaneCut(DataSetMapper, Line 207  class VelocityOnPlaneCut(DataSetMapper,
207                  StructuredPoints._getStructuredPoints(self))                  StructuredPoints._getStructuredPoints(self))
208    
209          Cutter.__init__(self, Probe._getOutput(self),          Cutter.__init__(self, Probe._getOutput(self),
         #Cutter.__init__(self, data_collector._getOutput(),  
210                  Plane._getPlane(self))                    Plane._getPlane(self))  
211    
212          if(arrow == Arrow.TWO_D): # Use 2D arrows.          if(arrow == Arrow.TWO_D): # Use 2D arrows.
213              Arrow2D.__init__(self)              Arrow2D.__init__(self)
214              Glyph3D.__init__(self, Cutter._getOutput(self),              Glyph3D.__init__(self, Cutter._getOutput(self),
                     #Arrow2D._getOutput(self), data_collector._getVectorRange())  
215                      Arrow2D._getOutput(self), data_collector._getScalarRange())                      Arrow2D._getOutput(self), data_collector._getScalarRange())
216          elif(arrow == Arrow.THREE_D): # Use 3D arrows.          elif(arrow == Arrow.THREE_D): # Use 3D arrows.
217              Arrow3D.__init__(self)              Arrow3D.__init__(self)
218              Glyph3D.__init__(self, Cutter._getOutput(self),              Glyph3D.__init__(self, Cutter._getOutput(self),
                     #Arrow3D._getOutput(self), data_collector._getVectorRange())  
219                      Arrow3D._getOutput(self), data_collector._getScalarRange())                      Arrow3D._getOutput(self), data_collector._getScalarRange())
220    
221          DataSetMapper.__init__(self, Glyph3D._getOutput(self),          DataSetMapper.__init__(self, Glyph3D._getOutput(self),
# Line 241  class VelocityOnPlaneCut(DataSetMapper, Line 234  class VelocityOnPlaneCut(DataSetMapper,
234          scene._addActor3D(viewport, Actor3D._getActor3D(self))          scene._addActor3D(viewport, Actor3D._getActor3D(self))
235    
236    
237    ###############################################################################
238    
239    
240  from clipper import Clipper  from clipper import Clipper
241    
242  # NOTE: DataSetMapper, Actor3D, Arrow2D, Arrow3D, Glyph3D, Transform, Plane,  # NOTE: DataSetMapper, Actor3D, Arrow2D, Arrow3D, Glyph3D, Transform, Plane,
# Line 255  class VelocityOnPlaneClip(DataSetMapper, Line 251  class VelocityOnPlaneClip(DataSetMapper,
251      # 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.
252      # 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.
253      # If no vector field is specified, the first encountered in the file will      # If no vector field is specified, the first encountered in the file will
254      # be loaded automatically.      # be loaded automatically.  If no lut is specified, the color scheme will
255        # be used.
256      def __init__(self, scene, data_collector, vector = None,      def __init__(self, scene, data_collector, vector = None,
257              viewport = Viewport.SOUTH_WEST, outline = True,              arrow = Arrow.TWO_D, color_mode = ColorMode.VECTOR,
258              arrow = Arrow.THREE_D, color_mode = ColorMode.VECTOR,              viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, outline = True):
             lut = Lut.COLOR):  
   
259          """          """
260          @type scene: L{Scene <scene.Scene>} object          @type scene: L{Scene <scene.Scene>} object
261          @param scene: Scene in which objects are to be rendered on          @param scene: Scene in which objects are to be rendered on
# Line 269  class VelocityOnPlaneClip(DataSetMapper, Line 264  class VelocityOnPlaneClip(DataSetMapper,
264          @param data_collector: Deal with source of data for visualisation          @param data_collector: Deal with source of data for visualisation
265          @type vector: String          @type vector: String
266          @param vector: Vector field to load from the source file          @param vector: Vector field to load from the source file
         @type viewport: L{Viewport <constant.Viewport>} constant  
         @param viewport: Viewport in which the object is to be rendered on  
         @type outline: Boolean  
         @param outline: Places an outline around the domain surface  
267          @type arrow: L{Arrow <constant.Arrow>} constant          @type arrow: L{Arrow <constant.Arrow>} constant
268          @param arrow: Type of arrow (two dimensional or three dimensional)          @param arrow: Type of arrow (two dimensional or three dimensional)
269          @type color_mode: L{ColorMode <constant.ColorMode>} constant          @type color_mode: L{ColorMode <constant.ColorMode>} constant
270          @param color_mode: Type of color mode          @param color_mode: Type of color mode
271            @type viewport: L{Viewport <constant.Viewport>} constant
272            @param viewport: Viewport in which objects are to be rendered on
273          @type lut : L{Lut <constant.Lut>} constant          @type lut : L{Lut <constant.Lut>} constant
274          @param lut: Lookup table color scheme          @param lut: Lookup table color scheme
275            @type outline: Boolean
276            @param outline: Places an outline around the domain surface
277          """          """
278    
279          # NOTE: Actor3D is inherited and there are two instances declared here.          # NOTE: Actor3D is inherited and there are two instances declared here.
# Line 293  class VelocityOnPlaneClip(DataSetMapper, Line 288  class VelocityOnPlaneClip(DataSetMapper,
288          # ----- Outline -----          # ----- Outline -----
289    
290          if(outline == True):          if(outline == True):
             #outline = Outline(Glyph3D._getOutput(self))  
291              outline = Outline(data_collector._getOutput())              outline = Outline(data_collector._getOutput())
292              DataSetMapper.__init__(self, outline._getOutput())              DataSetMapper.__init__(self, outline._getOutput())
293    
294              Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))              Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))
295              # Default outline color is black.              # Default outline color is black.
296              Actor3D.setColor(self, Color.BLACK)              Actor3D.setColor(self, Color.BLACK)
297    
298              # Default line width is 1.              # Default line width is 1.
299              Actor3D._setLineWidth(self, 1)              Actor3D._setLineWidth(self, 1)
300              scene._addActor3D(viewport, Actor3D._getActor3D(self))              scene._addActor3D(viewport, Actor3D._getActor3D(self))
301    
   
302          # ----- Velocity on a clipped plane -----          # ----- Velocity on a clipped plane -----
303    
304          if(vector != None):          if(vector != None):
# Line 327  class VelocityOnPlaneClip(DataSetMapper, Line 321  class VelocityOnPlaneClip(DataSetMapper,
321          Probe.__init__(self, data_collector._getOutput(),          Probe.__init__(self, data_collector._getOutput(),
322                  StructuredPoints._getStructuredPoints(self))                  StructuredPoints._getStructuredPoints(self))
323    
         #MaskPoints.__init__(self, data_collector._getOutput())  
   
324          # NOTE: Glyph3D must come before Clipper. Otherwise, the output will          # NOTE: Glyph3D must come before Clipper. Otherwise, the output will
325          # be incorrect.          # be incorrect.
326          if(arrow == Arrow.TWO_D): # Use 2D arrows.          if(arrow == Arrow.TWO_D): # Use 2D arrows.
327              Arrow2D.__init__(self)              Arrow2D.__init__(self)
328              #Glyph3D.__init__(self, data_collector._getOutput(),              #Glyph3D.__init__(self, data_collector._getOutput(),
329              Glyph3D.__init__(self, Probe._getOutput(self),              Glyph3D.__init__(self, Probe._getOutput(self),
             #Glyph3D.__init__(self, MaskPoints._getOutput(self),  
330                      Arrow2D._getOutput(self), data_collector._getScalarRange())                      Arrow2D._getOutput(self), data_collector._getScalarRange())
331          elif(arrow == Arrow.THREE_D): # Use 3D arrows.          elif(arrow == Arrow.THREE_D): # Use 3D arrows.
332              Arrow3D.__init__(self)              Arrow3D.__init__(self)
             #Glyph3D.__init__(self, data_collector._getOutput(),  
333              Glyph3D.__init__(self, Probe._getOutput(self),              Glyph3D.__init__(self, Probe._getOutput(self),
             #Glyph3D.__init__(self, MaskPoints._getOutput(self),  
334                      Arrow3D._getOutput(self), data_collector._getScalarRange())                      Arrow3D._getOutput(self), data_collector._getScalarRange())
   
335                    
336          # NOTE: Clipper must come after Glyph3D. Otherwise, the output will          # NOTE: Clipper must come after Glyph3D. Otherwise, the output will
337          # be incorrect.          # be incorrect.

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

  ViewVC Help
Powered by ViewVC 1.1.26