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