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

Annotation of /trunk/pyvisi/py_src/streamline.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 949 - (hide annotations)
Fri Feb 2 05:33:05 2007 UTC (12 years, 7 months ago) by jongui
File MIME type: text/x-python
File size: 3835 byte(s)
Fixed some more bugs and added more epydocs. Testing remains outstanding.
1 jongui 943 """
2     @author: John NGUI
3     """
4    
5     import vtk
6     from mapper import DataSetMapper
7     from lookuptable import LookupTable
8     from actor import Actor3D
9 jongui 946 from constant import Viewport, Color, Lut, ColorMode
10 jongui 943 from streamlinemodule import StreamLineModule
11     from tube import Tube
12     from point import PointSource
13     from outline import Outline
14    
15 jongui 949 # NOTE: DataSetMapper, Actor3D, PointSource, StreamLineModule and Tube were
16     # inherited to allow access to their public methods from the driver.
17 jongui 943 class StreamLine(DataSetMapper, Actor3D, PointSource, StreamLineModule, Tube):
18    
19     """
20     Class that show a vector field using streamline.
21     """
22    
23     # The SOUTH_WEST default viewport is used when there is only one viewport.
24     # This saves the user from specifying the viewport when there is only one.
25     # If no vector field is specified, the first encountered in the file will
26     # be loaded automatically. If no lut is specified, the color scheme will
27     # be used.
28     def __init__(self, scene, data_collector, viewport = Viewport.SOUTH_WEST,
29 jongui 949 lut = Lut.COLOR, color_mode = ColorMode.VECTOR, outline = True):
30 jongui 943
31     """
32     @type scene: L{Scene <scene.Scene>} object
33     @param scene: Scene in which objects are to be rendered on
34     @type data_collector: L{DataCollector <datacollector.DataCollector>}
35     object
36     @param data_collector: Deal with source of data for visualisation
37     @type viewport: L{Viewport <constant.Viewport>} constant
38     @param viewport: Viewport in which the object is to be rendered on
39     @type lut : L{Lut <constant.Lut>} constant
40     @param lut: Lookup table color scheme
41 jongui 949 @type color_mode: L{ColorMode <constant.ColorMode>} constant
42     @param color_mode: Type of color mode
43 jongui 943 @type outline: Boolean
44     @param outline: Places an outline around the domain surface
45     """
46    
47     # NOTE: Actor3D is inherited and there are two instances declared here.
48     # As a result, when methods from Actor3D is invoked from the driver,
49     # only the methods associated with the latest instance (which in this
50     # case is the Actor3D for the Tube) can be executed. Actor3D
51     # methods associated with Outline cannot be invoked from the driver.
52     # They can only be called within here, which is why Outline must be
53     # place before Tube as there is unlikely to be any changes
54     # made to the Outline's Actor3D.
55    
56     # ----- Outline -----
57    
58     if(outline == True):
59     outline = Outline(data_collector._getOutput())
60     DataSetMapper.__init__(self, outline._getOutput())
61    
62     Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))
63     # Default outline color is black.
64     Actor3D.setColor(self, Color.BLACK)
65     # Default line width is 1.
66     Actor3D._setLineWidth(self, 1)
67     scene._addActor3D(viewport, Actor3D._getActor3D(self))
68    
69     # ----- Streamline -----
70    
71     # NOTE: Lookup table color mapping (color or grey scale) MUST be set
72     # before DataSetMapper. If it is done after DataSetMapper, no effect
73     # will take place.
74     if(lut == Lut.COLOR): # Colored lookup table.
75     lookup_table = LookupTable()
76     lookup_table._setTableValue()
77     elif(lut == Lut.GREY_SCALE): # Grey scaled lookup table.
78     lookup_table = LookupTable()
79     lookup_table._setLookupTableToGreyScale()
80    
81     PointSource.__init__(self, data_collector._getOutput())
82     StreamLineModule.__init__(self, data_collector._getOutput(),
83     PointSource._getOutput(self))
84    
85     Tube.__init__(self, StreamLineModule._getOutput(self))
86     DataSetMapper.__init__(self, Tube._getOutput(self),
87     lookup_table._getLookupTable())
88    
89 jongui 946 if(color_mode == ColorMode.VECTOR): # Color velocity by vector.
90     DataSetMapper._setScalarRange(self,
91     data_collector._getVectorRange())
92     elif(color_mode == ColorMode.SCALAR): # Color velocity by scalar.
93     DataSetMapper._setScalarRange(self,
94     data_collector._getScalarRange())
95 jongui 949
96 jongui 943 Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))
97     scene._addActor3D(viewport, Actor3D._getActor3D(self))
98    

  ViewVC Help
Powered by ViewVC 1.1.26