/[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 852 - (show annotations)
Wed Sep 20 03:23:16 2006 UTC (12 years, 9 months ago) by jongui
File MIME type: text/x-python
File size: 1179 byte(s)
added carpet and isosurface


1 """
2 @author: John Ngui
3 @author: Lutz Gross
4 """
5
6 import vtk
7 from style import Style
8
9 class Text:
10 """
11 Class that displays text.
12 """
13
14 def __init__(self, scene):
15 """
16 @type scene: L{Scene <scene.Scene>} object
17 @param scene: Scene in which components are to be added to
18 """
19
20 self.scene = scene
21 self.vtk_text_mapper = vtk.vtkTextMapper()
22 self.vtk_text_actor = vtk.vtkScaledTextActor()
23
24 def setText(self, text):
25 """
26 Setup the text mapper and its input together with the default settings.
27
28 @type text: String
29 @param text: Text to be displayed
30 """
31
32 self.vtk_text_mapper.SetInput(text)
33
34 self.setActor()
35 self.addActor()
36
37 def setActor(self):
38 """
39 Set up the 2D text actor, its mapper and its display position.
40 """
41
42 self.vtk_text_actor.SetMapper(self.vtk_text_mapper)
43 self.setPosition(50, 20) # Default text position
44
45 def addActor(self):
46 """
47 Add the 2D text actor to the renderer.
48 """
49
50 self.scene.getRenderer().AddActor2D(self.vtk_text_actor)
51
52 def setPosition(self, x_coor, y_coor):
53 self.vtk_text_actor.SetDisplayPosition(x_coor, y_coor)
54
55 def setStyle(self, style):
56 self.vtk_text_mapper.SetTextProperty(style.getStyle())
57
58
59
60
61
62

  ViewVC Help
Powered by ViewVC 1.1.26