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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1113 - (hide annotations)
Thu Apr 19 08:53:24 2007 UTC (12 years, 3 months ago) by jongui
File MIME type: text/x-python
File size: 2894 byte(s)
Added some epydocs.
1 jongui 1037 """
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 jongui 1108
75     ###############################################################################
76    
77    
78     class ImageMapper:
79 jongui 1113 """
80     Class that defines a image mapper.
81     """
82    
83 jongui 1108 def __init__(self, object):
84 jongui 1113 """
85     Initialise the image mapper.
86    
87     @type object: vtkImageData
88     @param object: Image data
89     """
90    
91 jongui 1108 self.__object = object
92     self.__vtk_image_mapper = vtk.vtkImageMapper()
93    
94     self.__setupImageMapper()
95    
96     def __setupImageMapper(self):
97 jongui 1113 """
98     Setup the image mapper.
99     """
100    
101 jongui 1108 self.__setInput()
102 jongui 1113 # Both color window and color level needs to be set, otherwise only
103     # a black image will be produced. Both values were obtained from
104     # an example found on the VTK site.
105 jongui 1112 self.__setColorWindow(255)
106     self.__setColorLevel(127.5)
107 jongui 1108
108     def __setInput(self):
109 jongui 1113 """
110     Set the input for the image mapper.
111     """
112    
113 jongui 1108 self.__vtk_image_mapper.SetInput(self.__object)
114    
115 jongui 1112 def __setColorWindow(self, color):
116 jongui 1113 """
117     Set the color of the window.
118     """
119    
120 jongui 1108 self.__vtk_image_mapper.SetColorWindow(color)
121    
122 jongui 1112 def __setColorLevel(self, color):
123 jongui 1113 """
124     Set the color level of the window.
125     """
126    
127 jongui 1108 self.__vtk_image_mapper.SetColorLevel(color)
128    
129     def _getImageMapper(self):
130 jongui 1113 """
131     Return the image mapper.
132    
133     @rtype: vtkImageMapper
134     @return: Image mapper
135     """
136    
137 jongui 1108 return self.__vtk_image_mapper

  ViewVC Help
Powered by ViewVC 1.1.26