/[escript]/branches/more_shared_ptrs_from_1812/pyvisi/py_src/scalarbar.py
ViewVC logotype

Contents of /branches/more_shared_ptrs_from_1812/pyvisi/py_src/scalarbar.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1813 - (show annotations)
Fri Sep 26 00:58:05 2008 UTC (10 years, 7 months ago) by jfenwick
File MIME type: text/x-python
File size: 5182 byte(s)
Branching to experiment with proxies and shared pointers.

1
2 ########################################################
3 #
4 # Copyright (c) 2003-2008 by University of Queensland
5 # Earth Systems Science Computational Center (ESSCC)
6 # http://www.uq.edu.au/esscc
7 #
8 # Primary Business: Queensland, Australia
9 # Licensed under the Open Software License version 3.0
10 # http://www.opensource.org/licenses/osl-3.0.php
11 #
12 ########################################################
13
14 __copyright__="""Copyright (c) 2003-2008 by University of Queensland
15 Earth Systems Science Computational Center (ESSCC)
16 http://www.uq.edu.au/esscc
17 Primary Business: Queensland, Australia"""
18 __license__="""Licensed under the Open Software License version 3.0
19 http://www.opensource.org/licenses/osl-3.0.php"""
20 __url__="http://www.uq.edu.au/esscc/escript-finley"
21
22 """
23 @var __author__: name of author
24 @var __copyright__: copyrights
25 @var __license__: licence agreement
26 @var __url__: url entry point on documentation
27 @var __version__: version
28 @var __date__: date of the version
29 """
30
31 __author__="John Ngui, john.ngui@uq.edu.au"
32
33
34 import vtk
35 from position import LocalPosition
36 from constant import Color
37
38 class ScalarBar:
39 """
40 Class that defines a scalar bar.
41 """
42
43 def __init__(self):
44 """
45 Initialise the scalar bar.
46 """
47
48 self.__vtk_scalar_bar = vtk.vtkScalarBarActor()
49 self.__setupScalarBar()
50
51 def __setupScalarBar(self):
52 """
53 Setup the scalar bar.
54 """
55
56 self.__vtk_scalar_bar.GetPositionCoordinate().SetCoordinateSystemToViewport()
57 # Set the default number of labels on the scalar bar to 8.
58 self.setNumberOfLabels(8)
59 # Set the default color of the scalar bar's title and label to black.
60 self.setTitleColor(Color.BLACK)
61 self.setLabelColor(Color.BLACK)
62 self.titleBoldOff()
63 self.labelBoldOff()
64
65 def _setScalarBarLookupTable(self, lookup_table):
66 """
67 Set the scalar bar's lookup table.
68
69 @type lookup_table: vtkScalarsToColors
70 @param lookup_table: Converts scalar data to colors
71 """
72
73 self.__vtk_scalar_bar.SetLookupTable(lookup_table)
74
75 def setNumberOfLabels(self, labels):
76 """
77 Set the number of labels on the scalar bar.
78
79 @type labels: Number
80 @param labels: Number of labels on the scalar bar
81 """
82
83 self.__vtk_scalar_bar.SetNumberOfLabels(labels)
84
85 def setTitle(self, title):
86 """
87 Set the title on the scalar bar.
88
89 @type title: String
90 @param title: Title on the scalar bar
91 """
92
93 self.__vtk_scalar_bar.SetTitle(title)
94
95 def setPosition(self, position):
96 """
97 Set the local position of the scalar bar.
98
99 @type position: L{LocalPosition <position.LocalPosition>} object
100 @param position: Position of the scalar bar
101 """
102
103 self.__vtk_scalar_bar.SetPosition(position._getXCoor(), \
104 position._getYCoor())
105
106 def setOrientationToHorizontal(self):
107 """
108 Set the orientation of the scalar bar to horizontal.
109 """
110
111 self.__vtk_scalar_bar.SetOrientationToHorizontal()
112 # Default width, height and position for a horizontal scalar bar.
113 self.setWidth(0.8)
114 self.setHeight(0.10)
115 self.setPosition(LocalPosition(130,5))
116
117 def setOrientationToVertical(self):
118 """
119 Set the orientation of the scalar bar to vertical.
120 """
121
122 self.__vtk_scalar_bar.SetOrientationToVertical()
123 # Default width, height and position for a vertical scalar bar.
124 self.setWidth(0.14)
125 self.setHeight(0.85)
126 self.setPosition(LocalPosition(5,150))
127
128 def setHeight(self, height):
129 """
130 Set the height of the scalar bar.
131
132 @type height: Number
133 @param height: Height of the scalar bar
134 """
135
136 self.__vtk_scalar_bar.SetHeight(height)
137
138 def setWidth(self, width):
139 """
140 Set the width of the scalar bar.
141
142 @type width: Number
143 @param width: Width of the scalar bar.
144 """
145
146 self.__vtk_scalar_bar.SetWidth(width)
147
148 def setLabelColor(self, color):
149 """
150 Set the color of the scalar bar's label.
151
152 @type color: L{Color <constant.Color>} constant
153 @param color: Color of the scalar bar label
154 """
155
156 self.__getLabelProperty().SetColor(color)
157
158 def labelBoldOn(self):
159 """
160 Enable the bold on the scalar bar's label.
161 """
162
163 self.__getLabelProperty().BoldOn()
164
165 def labelBoldOff(self):
166 """
167 Disable the bold on the scalar bar's label.
168 """
169
170 self.__getLabelProperty().BoldOff()
171
172 def setTitleColor(self, color):
173 """
174 Set the color of the scalar bar's title.
175
176 @type color: L{Color <constant.Color>} constant
177 @param color: Color of the scalar bar title
178 """
179
180 self.__getTitleProperty().SetColor(color)
181
182 def titleBoldOn(self):
183 """
184 Enable the bold on the scalar bar's title.
185 """
186
187 self.__getTitleProperty().BoldOn()
188
189 def titleBoldOff(self):
190 """
191 Disable the bold on the scalar bar's title.
192 """
193
194 self.__getTitleProperty().BoldOff()
195
196 def __getLabelProperty(self):
197 """
198 Return the scalar bar's label property.
199
200 @rtype: vtkTextPorperty
201 @return: Scalar bar's label property
202 """
203
204 return self.__vtk_scalar_bar.GetLabelTextProperty()
205
206 def __getTitleProperty(self):
207 """
208 Return the scalar bar's title property.
209
210 @rtype: vtkTextPorperty
211 @return: Scalar bar's title property
212 """
213
214 return self.__vtk_scalar_bar.GetTitleTextProperty()
215
216 def _getScalarBar(self):
217 """
218 Return the scalar bar.
219
220 @rtype: vtkScalarBarActor
221 @return: Scalar bar actor
222 """
223
224 return self.__vtk_scalar_bar
225

  ViewVC Help
Powered by ViewVC 1.1.26