Salome HOME
Merge from BR_PARAVIS_DEV 29Dec09
[modules/paravis.git] / test / demo2.py
1
2 if not ('servermanager' in dir()):
3   from pvsimple import *
4
5 import os
6
7 def demo2(fname, impth):
8     """This demo shows the use of readers, data information and display properties."""
9    
10  # The view
11     v = GetRenderView()
12     if not v:
13        v = CreateRenderView()
14     v.CameraPosition = [-20, -9, -45]
15     v.CameraFocalPoint = [0.7, 0.3, 1.7]
16     v.CameraViewUp = [-0.75, -0.6, 0.25]
17     v.CameraViewAngle = [30]
18     v.StillRender()
19
20     # Create the exodus reader and specify a file name
21     reader = ExodusIIReader(FileName=fname)
22
23     # Get the list of point arrays.
24     avail = reader.PointVariables.Available
25     print avail
26
27     # Select all arrays
28     reader.PointVariables = avail
29
30     # Turn on the visibility of the reader
31     Show(reader)
32
33     # Set representation to wireframe
34     SetDisplayProperties(Representation = "Wireframe")
35    
36     # Black background
37     SetViewProperties(Background = [0., 0., 0.])
38     Render()
39
40     # Change the elevation of the camera.
41     GetActiveCamera().Elevation(45)
42     Render()
43
44     # Now that the reader executed, let's get some information about it's output.
45     pdi = reader[0].PointData
46
47     # This prints a list of all read point data arrays as well as their value ranges.
48     print 'Number of point arrays:', len(pdi)
49     for i in range(len(pdi)):
50         ai = pdi[i]
51         print "----------------"
52         print "Array:", i, " ", ai.Name, ":"
53         numComps = ai.GetNumberOfComponents()
54         print "Number of components:", numComps
55         for j in range(numComps):
56             print "Range:", ai.GetRange(j)
57
58     # White is boring. Let's color the geometry using a variable. First create a lookup table. This object controls how scalar values are mapped to colors. 
59     SetDisplayProperties(LookupTable = MakeBlueToRedLT(0.00678, 0.0288))
60
61     # Color by point array called Pres
62     SetDisplayProperties(ColorAttributeType = "POINT_DATA")
63     SetDisplayProperties(ColorArrayName = "Pres")
64
65     WriteImage(filename = (impth + "demo2_1.png"), view=v, Magnification=2)
66
67     # Set representation to surface
68     SetDisplayProperties(Representation = "Surface")
69
70     # Scalar Bar
71     lt = MakeBlueToRedLT(0.00678, 0.0288)
72     ScalarBar = CreateScalarBar(LookupTable = lt, Title = "Sample")
73     GetRenderView().Representations.append(ScalarBar)
74     WriteImage(filename = (impth + "demo2_2.png"), view=v, Magnification=2)
75     Render()
76
77
78 testdir = os.getenv("TESTDIR")
79 pvdata = os.getenv("PVDATA")
80
81 if __name__ == "__main__":
82  demo2(fname=pvdata+"/Data/disk_out_ref.ex2", impth=testdir+"/Pic/")
83