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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 996 - (hide annotations)
Mon Feb 26 03:43:13 2007 UTC (13 years, 7 months ago) by jongui
File MIME type: text/x-python
File size: 3627 byte(s)
Updated the drivers. Setting the active scalar/vector/tensor is now done in the DataCollector. i.e. 
dc = DataCollector(...)
dc.setFileName(...)
dc.setActiveScalar(...)

The use of setActiveScalar / setActiveVector / setActiveTensor have to be done after the setFileName.
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 947 from constant import Viewport, Color, Lut, WarpMode
10 jongui 943 from warp import Warp
11     from outline import Outline
12     from transform import Transform
13     from plane import Plane
14     from cutter import Cutter
15    
16     # NOTE: DataSetMapper, Actor3D, Warp, Transform, Plane and Cutter were
17     # inherited to allow access to their public methods from the driver.
18 jongui 947 class Carpet(DataSetMapper, Actor3D, Warp, Transform, Plane, Cutter):
19 jongui 943 """
20 jongui 947 Class that shows a scalar field on a plane deformated along the normal.
21 jongui 943 """
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 jongui 947 # If no warp_mode is specified, the data will be deformated using scalar
26 jongui 996 # data. If no lut is specified, the color scheme will be used.
27     def __init__(self, scene, data_collector, warp_mode = WarpMode.SCALAR,
28     viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, outline = True):
29 jongui 943 """
30     @type scene: L{Scene <scene.Scene>} object
31     @param scene: Scene in which objects are to be rendered on
32     @type data_collector: L{DataCollector <datacollector.DataCollector>}
33     object
34     @param data_collector: Deal with source of data for visualisation
35 jongui 947 @param warp_mode: L{WarpMode <constant.WarpMode>} constant
36 jongui 943 @type warp_mode: Mode in which to deform the scalar data
37     @type viewport: L{Viewport <constant.Viewport>} constant
38 jongui 947 @param viewport: Viewport in which objects are to be rendered on
39 jongui 943 @type lut : L{Lut <constant.Lut>} constant
40     @param lut: Lookup table color scheme
41     @type outline: Boolean
42     @param outline: Places an outline around the domain surface
43     """
44    
45 jongui 947 # NOTE: Actor3D is inherited and there are two instances declared here.
46     # As a result, when methods from Actor3D is invoked from the driver,
47     # only the methods associated with the latest instance (which in this
48     # case is the Actor3D for the carpet) can be executed. Actor3D
49     # methods associated with Outline cannot be invoked from the driver.
50     # They can only be called within here, which is why Outline must
51     # be place before the carpet as there is unlikely to be any changes
52     # made to the Outline's Actor3D.
53    
54 jongui 943 # ----- Outline -----
55    
56     if(outline == True):
57     outline = Outline(data_collector._getOutput())
58     DataSetMapper.__init__(self, outline._getOutput())
59    
60     Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))
61     # Default outline color is black.
62     Actor3D.setColor(self, Color.BLACK)
63 jongui 947
64 jongui 943 # Default line width is 1.
65     Actor3D._setLineWidth(self, 1)
66     scene._addActor3D(viewport, Actor3D._getActor3D(self))
67    
68     # ----- Carpet -----
69    
70     # NOTE: Lookup table color mapping (color or grey scale) MUST be set
71     # before DataSetMapper. If it is done after DataSetMapper, no effect
72     # will take place.
73     if(lut == Lut.COLOR): # Colored lookup table.
74     lookup_table = LookupTable()
75     lookup_table._setTableValue()
76     elif(lut == Lut.GREY_SCALE): # Grey scaled lookup table.
77     lookup_table = LookupTable()
78     lookup_table._setLookupTableToGreyScale()
79    
80     Transform.__init__(self)
81     Plane.__init__(self, Transform._getTransform(self))
82    
83     Cutter.__init__(self, data_collector._getOutput(),
84     Plane._getPlane(self))
85     Warp.__init__(self, Cutter._getOutput(self), warp_mode)
86    
87     DataSetMapper.__init__(self, Warp._getOutput(self),
88     lookup_table._getLookupTable())
89     DataSetMapper._setScalarRange(self, data_collector._getScalarRange())
90    
91     Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))
92     scene._addActor3D(viewport, Actor3D._getActor3D(self))
93    

  ViewVC Help
Powered by ViewVC 1.1.26