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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1158 - (hide annotations)
Tue May 22 04:24:01 2007 UTC (13 years, 10 months ago) by jongui
File MIME type: text/x-python
File size: 2372 byte(s)
Made some changes to fix the memory leak problem. However, the problem still persists for run_escript_with_lazy_evaluation.py, run_streamline.py and run_streamline_with_lazy_evaluation.py.

1 ksteube 1147 """
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. A two-dimensional text is used to
14 jongui 1154 annotate the rendered object (i.e. inserting titles, authors and labels).
15 ksteube 1147 """
16    
17     def __init__(self, scene, text, viewport = Viewport.SOUTH_WEST):
18     """
19     Initialise the 2D text actor.
20    
21     @type scene: L{Scene <scene.Scene>} object
22     @param scene: Scene in which objects are to be rendered on
23     @type text: String
24     @param text: 2D text to be displayed
25     @type viewport: L{Viewport <constant.Viewport>} constant
26     @param viewport: Viewport in which objects are to be rendered on
27     """
28    
29     self.__text = text
30     self.__viewport = viewport
31     self._vtk_actor2D = vtk.vtkTextActor()
32    
33 jongui 1158 self.__setupText2D(scene)
34 ksteube 1147
35 jongui 1158 def __setupText2D(self, scene):
36 ksteube 1147 """
37     Setup the 2D text.
38 jongui 1158
39     @type scene: L{Scene <scene.Scene>} object
40     @param scene: Scene in which objects are to be rendered on
41 ksteube 1147 """
42    
43     self.__setInput()
44     # Add the 2D text to the appropriate renderer.
45 jongui 1158 scene._addActor2D(self.__viewport, self._vtk_actor2D)
46 ksteube 1147
47     def __setInput(self):
48     """
49     Set the input for the 2D text.
50     """
51    
52     self._vtk_actor2D.SetInput(self.__text)
53    
54     def setFontSize(self, size):
55     """
56     Set the 2D text size.
57    
58     @type size: Number
59     @param size: Size of the 2D text
60     """
61    
62     self._vtk_actor2D.GetTextProperty().SetFontSize(size)
63    
64     def setFontToTimes(self):
65     """
66     Set the 2D text font type to Times New Roman.
67     """
68    
69     self._vtk_actor2D.GetTextProperty().SetFontFamilyToTimes()
70    
71     def setFontToArial(self):
72     """
73     Set the 2D text font type to Arial.
74     """
75    
76     self._vtk_actor2D.GetTextProperty().SetFontFamilyToArial()
77    
78     def setFontToCourier(self):
79     """
80     Set the 2D text front type to Courier.
81     """
82    
83     self._vtk_actor2D.GetTextProperty().SetFontFamilyToCourier()
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 2D 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