/[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 1387 - (hide annotations)
Fri Jan 11 07:45:26 2008 UTC (13 years, 3 months ago) by trankine
Original Path: temp/pyvisi/py_src/text.py
File MIME type: text/x-python
File size: 3060 byte(s)
Restore the trunk that existed before the windows changes were committed to the (now moved to branches) old trunk.
1 ksteube 1147 """
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 ksteube 1147 """
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 ksteube 1147 import vtk
22     from actor import Actor2D
23     from constant import Viewport, Color
24    
25     # NOTE: Actor2D was inherited to allow access to its public methods from
26     # the driver.
27     class Text2D(Actor2D):
28     """
29     Class that defines a 2D text actor. A two-dimensional text is used to
30 jongui 1154 annotate the rendered object (i.e. inserting titles, authors and labels).
31 ksteube 1147 """
32    
33     def __init__(self, scene, text, viewport = Viewport.SOUTH_WEST):
34     """
35     Initialise the 2D text actor.
36    
37     @type scene: L{Scene <scene.Scene>} object
38     @param scene: Scene in which objects are to be rendered on
39     @type text: String
40     @param text: 2D text to be displayed
41     @type viewport: L{Viewport <constant.Viewport>} constant
42     @param viewport: Viewport in which objects are to be rendered on
43     """
44    
45     self.__text = text
46     self.__viewport = viewport
47     self._vtk_actor2D = vtk.vtkTextActor()
48    
49 jongui 1158 self.__setupText2D(scene)
50 ksteube 1147
51 jongui 1158 def __setupText2D(self, scene):
52 ksteube 1147 """
53     Setup the 2D text.
54 jongui 1158
55     @type scene: L{Scene <scene.Scene>} object
56     @param scene: Scene in which objects are to be rendered on
57 ksteube 1147 """
58    
59     self.__setInput()
60 jongui 1199 # Set the color of the 2D text to black by default.
61 jongui 1189 self.setColor(Color.BLACK)
62 ksteube 1147 # Add the 2D text to the appropriate renderer.
63 jongui 1158 scene._addActor2D(self.__viewport, self._vtk_actor2D)
64 ksteube 1147
65     def __setInput(self):
66     """
67     Set the input for the 2D text.
68     """
69    
70     self._vtk_actor2D.SetInput(self.__text)
71    
72     def setFontSize(self, size):
73     """
74     Set the 2D text size.
75    
76     @type size: Number
77     @param size: Size of the 2D text
78     """
79    
80     self._vtk_actor2D.GetTextProperty().SetFontSize(size)
81    
82     def setFontToTimes(self):
83     """
84     Set the 2D text font type to Times New Roman.
85     """
86    
87     self._vtk_actor2D.GetTextProperty().SetFontFamilyToTimes()
88    
89     def setFontToArial(self):
90     """
91     Set the 2D text font type to Arial.
92     """
93    
94     self._vtk_actor2D.GetTextProperty().SetFontFamilyToArial()
95    
96     def setFontToCourier(self):
97     """
98     Set the 2D text front type to Courier.
99     """
100    
101     self._vtk_actor2D.GetTextProperty().SetFontFamilyToCourier()
102    
103     def boldOn(self):
104     """
105     Bold the 2D text.
106     """
107    
108     self._vtk_actor2D.GetTextProperty().BoldOn()
109    
110     def shadowOn(self):
111     """
112     Apply shadow onto the 2D text to ease visibility.
113     """
114    
115     self._vtk_actor2D.GetTextProperty().ShadowOn()
116    
117     def setColor(self, color):
118     """
119     Set the color of the 2D text.
120    
121     @type color: L{Color <constant.Color>} constant
122     @param color: 2D text color
123     """
124    
125     self._vtk_actor2D.GetTextProperty().SetColor(color)
126    

  ViewVC Help
Powered by ViewVC 1.1.26