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

Contents of /trunk/pyvisi/py_src/text.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 949 - (show annotations)
Fri Feb 2 05:33:05 2007 UTC (13 years, 5 months ago) by jongui
File MIME type: text/x-python
File size: 2171 byte(s)
Fixed some more bugs and added more epydocs. Testing remains outstanding.
1 """
2 @author: John NGUI
3 """
4
5 import vtk
6 from actor import Actor2D
7 from constant import Viewport, Color
8
9 # NOTE: Actor2D was inherited to allow access to its public methods from
10 # the driver.
11 class Text2D(Actor2D):
12 """
13 Class that defines a 2D text actor.
14 """
15
16 def __init__(self, scene, text, viewport = Viewport.SOUTH_WEST):
17 """
18 Initialise the 2D text actor.
19
20 @type scene: L{Scene <scene.Scene>} object
21 @param scene: Scene in which objects are to be rendered on
22 @type text: String
23 @param text: 2D text to be displayed
24 @type viewport: L{Viewport <constant.Viewport>} constant
25 @param viewport: Viewport in which objects are to be rendered on
26 """
27
28 self.__scene = scene
29 self.__text = text
30 self.__viewport = viewport
31 self._vtk_actor2D = vtk.vtkTextActor()
32
33 self.__setupText2D()
34
35 def __setupText2D(self):
36 """
37 Setup the 2D text.
38 """
39
40 self.__setInput()
41 # Add the 2D text to the appropriate renderer.
42 self.__scene._addActor2D(self.__viewport, self._vtk_actor2D)
43
44 def __setInput(self):
45 """
46 Set the input for the 2D text.
47 """
48
49 self._vtk_actor2D.SetInput(self.__text)
50
51 def setFontSize(self, size):
52 """
53 Set the 2D text size.
54
55 @type size: Number
56 @param size: Size of the 2D text
57 """
58
59 self._vtk_actor2D.GetTextProperty().SetFontSize(size)
60
61 def setFontToTimes(self):
62 """
63 Set the 2D text font type to times new roman.
64 """
65
66 self._vtk_actor2D.GetTextProperty().SetFontFamilyToTimes()
67
68 def setFontToArial(self):
69 """
70 Set the 2D text font type to arial.
71 """
72
73 self._vtk_actor2D.GetTextProperty().SetFontFamilyToArial()
74
75 def setFontToCourier(self):
76 """
77 Set the 2D text front type to courier.
78 """
79
80 self._vtk_actor2D.GetTextProperty().SetFontFamilyToCourier()
81
82 def boldOn(self):
83 """
84 Bold the 2D text.
85 """
86
87 self._vtk_actor2D.GetTextProperty().BoldOn()
88
89 def shadowOn(self):
90 """
91 Apply shadow onto the 2D text to ease visibility.
92 """
93
94 self._vtk_actor2D.GetTextProperty().ShadowOn()
95
96 def setColor(self, color):
97 """
98 Set the color of the text.
99
100 @type color: L{Color <constant.Color>} constant
101 @param color: 2D text color
102 """
103
104 self._vtk_actor2D.GetTextProperty().SetColor(color)
105

  ViewVC Help
Powered by ViewVC 1.1.26