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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1199 - (hide annotations)
Wed Jun 20 05:01:30 2007 UTC (13 years, 9 months ago) by jongui
File MIME type: text/x-python
File size: 4788 byte(s)
- Updated the epydocs and guide.
Deleted redundant files and methods.
Tidied up the codes.
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 jongui 1199 # Set the default number of labels on the scalar bar to 8.
45 jongui 1189 self.setNumberOfLabels(8)
46     # Set the default color of the scalar bar's title and label to black.
47     self.setTitleColor(Color.BLACK)
48     self.setLabelColor(Color.BLACK)
49 jongui 1194 self.titleBoldOff()
50     self.labelBoldOff()
51 jongui 1189
52     def _setScalarBarLookupTable(self, lookup_table):
53     """
54     Set the scalar bar's lookup table.
55    
56     @type lookup_table: vtkScalarsToColors
57     @param lookup_table: Converts scalar data to colors
58     """
59    
60     self.__vtk_scalar_bar.SetLookupTable(lookup_table)
61    
62     def setNumberOfLabels(self, labels):
63     """
64 jongui 1199 Set the number of labels on the scalar bar.
65 jongui 1189
66     @type labels: Number
67     @param labels: Number of labels on the scalar bar
68     """
69    
70     self.__vtk_scalar_bar.SetNumberOfLabels(labels)
71    
72     def setTitle(self, title):
73     """
74     Set the title on the scalar bar.
75    
76     @type title: String
77     @param title: Title on the scalar bar
78     """
79    
80     self.__vtk_scalar_bar.SetTitle(title)
81    
82     def setPosition(self, position):
83     """
84     Set the local position of the scalar bar.
85    
86     @type position: L{LocalPosition <position.LocalPosition>} object
87     @param position: Position of the scalar bar
88     """
89    
90     self.__vtk_scalar_bar.SetPosition(position._getXCoor(), \
91     position._getYCoor())
92    
93     def setOrientationToHorizontal(self):
94     """
95     Set the orientation of the scalar bar to horizontal.
96     """
97    
98     self.__vtk_scalar_bar.SetOrientationToHorizontal()
99 jongui 1199 # Default width, height and position for a horizontal scalar bar.
100 jongui 1189 self.setWidth(0.8)
101 jongui 1194 self.setHeight(0.10)
102 jongui 1189 self.setPosition(LocalPosition(130,5))
103    
104     def setOrientationToVertical(self):
105     """
106     Set the orientation of the scalar bar to vertical.
107     """
108    
109     self.__vtk_scalar_bar.SetOrientationToVertical()
110 jongui 1199 # Default width, height and position for a vertical scalar bar.
111 jongui 1189 self.setWidth(0.14)
112     self.setHeight(0.85)
113     self.setPosition(LocalPosition(5,150))
114    
115     def setHeight(self, height):
116     """
117     Set the height of the scalar bar.
118    
119     @type height: Number
120     @param height: Height of the scalar bar
121     """
122    
123     self.__vtk_scalar_bar.SetHeight(height)
124    
125     def setWidth(self, width):
126     """
127     Set the width of the scalar bar.
128    
129     @type width: Number
130     @param width: Width of the scalar bar.
131     """
132    
133     self.__vtk_scalar_bar.SetWidth(width)
134    
135     def setLabelColor(self, color):
136     """
137     Set the color of the scalar bar's label.
138    
139     @type color: L{Color <constant.Color>} constant
140     @param color: Color of the scalar bar label
141     """
142    
143     self.__getLabelProperty().SetColor(color)
144    
145     def labelBoldOn(self):
146     """
147     Enable the bold on the scalar bar's label.
148     """
149    
150     self.__getLabelProperty().BoldOn()
151    
152     def labelBoldOff(self):
153     """
154     Disable the bold on the scalar bar's label.
155     """
156    
157     self.__getLabelProperty().BoldOff()
158    
159     def setTitleColor(self, color):
160     """
161     Set the color of the scalar bar's title.
162    
163     @type color: L{Color <constant.Color>} constant
164     @param color: Color of the scalar bar title
165     """
166    
167     self.__getTitleProperty().SetColor(color)
168    
169     def titleBoldOn(self):
170     """
171     Enable the bold on the scalar bar's title.
172     """
173    
174     self.__getTitleProperty().BoldOn()
175    
176     def titleBoldOff(self):
177     """
178     Disable the bold on the scalar bar's title.
179     """
180    
181     self.__getTitleProperty().BoldOff()
182    
183     def __getLabelProperty(self):
184     """
185     Return the scalar bar's label property.
186    
187     @rtype: vtkTextPorperty
188     @return: Scalar bar's label property
189     """
190    
191     return self.__vtk_scalar_bar.GetLabelTextProperty()
192    
193     def __getTitleProperty(self):
194     """
195     Return the scalar bar's title property.
196    
197     @rtype: vtkTextPorperty
198     @return: Scalar bar's title property
199     """
200    
201     return self.__vtk_scalar_bar.GetTitleTextProperty()
202    
203     def _getScalarBar(self):
204     """
205     Return the scalar bar.
206    
207     @rtype: vtkScalarBarActor
208     @return: Scalar bar actor
209     """
210    
211     return self.__vtk_scalar_bar
212    

  ViewVC Help
Powered by ViewVC 1.1.26