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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1112 - (show annotations)
Thu Apr 19 06:31:49 2007 UTC (15 years, 3 months ago) by jongui
File MIME type: text/x-python
File size: 2292 byte(s)
Made some updates to the guide.
1 """
2 @author: John NGUI
3 """
4
5 import vtk
6
7 class DataSetMapper:
8 """
9 Class that defines a data set mapper.
10 """
11
12 # 'lookup_table = None' is used only by the outline.
13 def __init__(self, object, lookup_table = None):
14 """
15 Initialise the data set mapper.
16
17 @type object: vtkDataSet (i.e. vtkUnstructuredGrid, vtkPolyData, etc)
18 @param object: Data source map
19 @type lookup_table: vtkLookupTable
20 @param lookup_table: Maps scalar values to colors
21 """
22
23 self.__object = object
24 self.__vtk_data_set_mapper = vtk.vtkDataSetMapper()
25 self.__setInput()
26
27 if(lookup_table != None): # False for the outline.
28 self.__setLookupTable(lookup_table)
29
30 def __setInput(self):
31 """
32 Set the input for the data set mapper.
33 """
34
35 self.__vtk_data_set_mapper.SetInput(self.__object)
36
37 def __setLookupTable(self, lookup_table):
38 """
39 Set the lookup table for the data set mapper.
40
41 @type lookup_table: vtkLookupTable
42 @param lookup_table: Map scalar values to colors
43 """
44
45 self.__vtk_data_set_mapper.SetLookupTable(lookup_table)
46
47 def _setScalarRange(self, range):
48 """
49 Set the minimum and maximum scalar range for the data set mapper.
50
51 @type range: Two column tuple containing numbers
52 @param range: Minimum and maximum data set mapper scalar range
53 """
54
55 self.__vtk_data_set_mapper.SetScalarRange(range)
56
57 def _setScalarVisibilityOn(self):
58 """
59 Scalar data is used to color the rendered object.
60 """
61
62 self.__vtk_data_set_mapper.ScalarVisibilityOn()
63
64 def _getDataSetMapper(self):
65 """
66 Return the data set mapper.
67
68 @rtype: vtkDataSetMapper
69 @return: Data set mapper
70 """
71
72 return self.__vtk_data_set_mapper
73
74
75 ###############################################################################
76
77
78 class ImageMapper:
79 def __init__(self, object):
80 self.__object = object
81 self.__vtk_image_mapper = vtk.vtkImageMapper()
82
83 self.__setupImageMapper()
84
85 def __setupImageMapper(self):
86 self.__setInput()
87 self.__setColorWindow(255)
88 self.__setColorLevel(127.5)
89
90 def __setInput(self):
91 self.__vtk_image_mapper.SetInput(self.__object)
92
93 def __setColorWindow(self, color):
94 self.__vtk_image_mapper.SetColorWindow(color)
95
96 def __setColorLevel(self, color):
97 self.__vtk_image_mapper.SetColorLevel(color)
98
99 def _getImageMapper(self):
100 return self.__vtk_image_mapper

  ViewVC Help
Powered by ViewVC 1.1.26