/[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 946 - (show annotations)
Wed Jan 31 03:08:04 2007 UTC (12 years, 6 months ago) by jongui
File MIME type: text/x-python
File size: 2093 byte(s)
added colouring option to use either scalar data or vector data.
1 """
2 @author: John NGUI
3 """
4
5 import vtk
6 from actor import Actor2D
7 from constant import Viewport, Color
8
9 class Text2D(Actor2D):
10 """
11 Class that defines a 2D text actor.
12 """
13
14 def __init__(self, scene, text, viewport = Viewport.SOUTH_WEST):
15 """
16 Initialise the 2D text actor.
17
18 @type text: String
19 @param text: 2D text to be displayed
20 """
21
22 self.__scene = scene
23 self.__text = text
24 self.__viewport = viewport
25 self._vtk_actor2D = vtk.vtkTextActor()
26
27 self.__setupText2D()
28
29 def __setupText2D(self):
30 """
31 Setup the 2D text.
32 """
33
34 self.__setInput()
35 # Add the 2D text to the appropriate renderer.
36 self.__scene._addActor2D(self.__viewport, self._vtk_actor2D)
37
38 def __setInput(self):
39 """
40 Set the 2D text to be displayed.
41 """
42
43 self._vtk_actor2D.SetInput(self.__text)
44 # self._vtk_actor2D.GetPositionCoordinate().SetCoordinateSystemToViewport()
45
46
47 def setFontSize(self, size):
48 """
49 Set the 2D text size.
50
51 @type size: Number
52 @param size: Size of the 2D text
53 """
54
55 self._vtk_actor2D.GetTextProperty().SetFontSize(size)
56
57 def setFontToTimes(self):
58 """
59 Set the 2D text font type to times new roman.
60 """
61
62 self._vtk_actor2D.GetTextProperty().SetFontFamilyToTimes()
63
64 def setFontToArial(self):
65 """
66 Set the 2D text font type to arial.
67 """
68
69 self._vtk_actor2D.GetTextProperty().SetFontFamilyToArial()
70
71 def setFontToCourier(self):
72 """
73 Set the 2D text front type to courier.
74 """
75
76 self._vtk_actor2D.GetTextProperty().SetFontFamilyToCourier()
77
78 def setJustificationToCenter(self):
79 """
80 Set the 2D text to center justification.
81 """
82
83 self._vtk_actor2D.GetTextProperty().SetJustificationToCentered()
84
85 def boldOn(self):
86 """
87 Bold the 2D text.
88 """
89
90 self._vtk_actor2D.GetTextProperty().BoldOn()
91
92 def shadowOn(self):
93 """
94 Apply shadow onto the 2D text to ease visibility.
95 """
96
97 self._vtk_actor2D.GetTextProperty().ShadowOn()
98
99 def setColor(self, color):
100 """
101 Set the color of the text.
102
103 @type color: L{Color <constant.Color>} constant
104 @param color: 2D text color
105 """
106
107 self._vtk_actor2D.GetTextProperty().SetColor(color)
108

  ViewVC Help
Powered by ViewVC 1.1.26