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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 943 - (show annotations)
Mon Jan 29 07:22:43 2007 UTC (14 years, 1 month ago) by jongui
File MIME type: text/x-python
File size: 3387 byte(s)
new pyvisi files
1 """
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 from constant import Viewport, Color, Lut
10 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 class Carpet(DataSetMapper, Actor3D, Warp, Transform,
19 Plane, Cutter):
20 """
21 Class that shows a scalar field on a plance deformated along the place
22 normal.
23 """
24
25 # The SOUTH_WEST default viewport is used when there is only one viewport.
26 # This saves the user from specifying the viewport when there is only one.
27 # If no scalar field is specified, the first encountered in the file will
28 # be loaded automatically. If no lut is specified, the color scheme will
29 # be used.
30 def __init__(self, scene, data_collector, scalar = None, warp_mode = None,
31 viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, outline = True):
32 """
33 @type scene: L{Scene <scene.Scene>} object
34 @param scene: Scene in which objects are to be rendered on
35 @type data_collector: L{DataCollector <datacollector.DataCollector>}
36 object
37 @param data_collector: Deal with source of data for visualisation
38 @type scalar: String
39 @param scalar: Scalar field to load from the source file
40 @param warp_mode: L{WarpMode {<constant.WarpMode>} constant
41 @type warp_mode: Mode in which to deform the scalar data
42 @type viewport: L{Viewport <constant.Viewport>} constant
43 @param viewport: Viewport in which the object is to be rendered on
44 @type lut : L{Lut <constant.Lut>} constant
45 @param lut: Lookup table color scheme
46 @type outline: Boolean
47 @param outline: Places an outline around the domain surface
48 """
49
50 # ----- Outline -----
51
52 if(outline == True):
53 outline = Outline(data_collector._getOutput())
54 DataSetMapper.__init__(self, outline._getOutput())
55
56 Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))
57 # Default outline color is black.
58 Actor3D.setColor(self, Color.BLACK)
59 # Default line width is 1.
60 Actor3D._setLineWidth(self, 1)
61 scene._addActor3D(viewport, Actor3D._getActor3D(self))
62
63 # ----- Carpet -----
64
65 if(scalar != None):
66 data_collector._setActiveScalar(scalar)
67
68 # NOTE: Lookup table color mapping (color or grey scale) MUST be set
69 # before DataSetMapper. If it is done after DataSetMapper, no effect
70 # will take place.
71 if(lut == Lut.COLOR): # Colored lookup table.
72 lookup_table = LookupTable()
73 lookup_table._setTableValue()
74 elif(lut == Lut.GREY_SCALE): # Grey scaled lookup table.
75 lookup_table = LookupTable()
76 lookup_table._setLookupTableToGreyScale()
77
78
79 Transform.__init__(self)
80 Plane.__init__(self, Transform._getTransform(self))
81
82 Cutter.__init__(self, data_collector._getOutput(),
83 Plane._getPlane(self))
84
85 #warp = Warp(Cutter._getOutput(self), warp_mode)
86 Warp.__init__(self, Cutter._getOutput(self), warp_mode)
87
88 #DataSetMapper.__init__(self, warp._getOutput(),
89 DataSetMapper.__init__(self, Warp._getOutput(self),
90 lookup_table._getLookupTable())
91
92 DataSetMapper._setScalarRange(self, data_collector._getScalarRange())
93
94 Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))
95 scene._addActor3D(viewport, Actor3D._getActor3D(self))
96

  ViewVC Help
Powered by ViewVC 1.1.26