/[escript]/tags/trunk_2172_checkpoint/pyvisi/py_src/text.py
ViewVC logotype

Contents of /tags/trunk_2172_checkpoint/pyvisi/py_src/text.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2175 - (show annotations)
Wed Dec 17 09:22:40 2008 UTC (12 years, 2 months ago) by phornby
File MIME type: text/x-python
File size: 3454 byte(s)
Try again at conforming to naming convention.
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 actor import Actor2D
36 from constant import Viewport, Color
37
38 # NOTE: Actor2D was inherited to allow access to its public methods from
39 # the driver.
40 class Text2D(Actor2D):
41 """
42 Class that defines a 2D text actor. A two-dimensional text is used to
43 annotate the rendered object (i.e. inserting titles, authors and labels).
44 """
45
46 def __init__(self, scene, text, viewport = Viewport.SOUTH_WEST):
47 """
48 Initialise the 2D text actor.
49
50 @type scene: L{Scene <scene.Scene>} object
51 @param scene: Scene in which objects are to be rendered on
52 @type text: String
53 @param text: 2D text to be displayed
54 @type viewport: L{Viewport <constant.Viewport>} constant
55 @param viewport: Viewport in which objects are to be rendered on
56 """
57
58 self.__text = text
59 self.__viewport = viewport
60 self._vtk_actor2D = vtk.vtkTextActor()
61
62 self.__setupText2D(scene)
63
64 def __setupText2D(self, scene):
65 """
66 Setup the 2D text.
67
68 @type scene: L{Scene <scene.Scene>} object
69 @param scene: Scene in which objects are to be rendered on
70 """
71
72 self.__setInput()
73 # Set the color of the 2D text to black by default.
74 self.setColor(Color.BLACK)
75 # Add the 2D text to the appropriate renderer.
76 scene._addActor2D(self.__viewport, self._vtk_actor2D)
77
78 def __setInput(self):
79 """
80 Set the input for the 2D text.
81 """
82
83 self._vtk_actor2D.SetInput(self.__text)
84
85 def setFontSize(self, size):
86 """
87 Set the 2D text size.
88
89 @type size: Number
90 @param size: Size of the 2D text
91 """
92
93 self._vtk_actor2D.GetTextProperty().SetFontSize(size)
94
95 def setFontToTimes(self):
96 """
97 Set the 2D text font type to Times New Roman.
98 """
99
100 self._vtk_actor2D.GetTextProperty().SetFontFamilyToTimes()
101
102 def setFontToArial(self):
103 """
104 Set the 2D text font type to Arial.
105 """
106
107 self._vtk_actor2D.GetTextProperty().SetFontFamilyToArial()
108
109 def setFontToCourier(self):
110 """
111 Set the 2D text front type to Courier.
112 """
113
114 self._vtk_actor2D.GetTextProperty().SetFontFamilyToCourier()
115
116 def boldOn(self):
117 """
118 Bold the 2D text.
119 """
120
121 self._vtk_actor2D.GetTextProperty().BoldOn()
122
123 def shadowOn(self):
124 """
125 Apply shadow onto the 2D text to ease visibility.
126 """
127
128 self._vtk_actor2D.GetTextProperty().ShadowOn()
129
130 def setColor(self, color):
131 """
132 Set the color of the 2D text.
133
134 @type color: L{Color <constant.Color>} constant
135 @param color: 2D text color
136 """
137
138 self._vtk_actor2D.GetTextProperty().SetColor(color)
139

  ViewVC Help
Powered by ViewVC 1.1.26