/[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 847 - (show annotations)
Thu Sep 14 07:54:04 2006 UTC (12 years, 11 months ago) by jongui
File MIME type: text/x-python
File size: 1265 byte(s)
Added vtkTextProperty to control the style of text and partially completed the carpet module.

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

  ViewVC Help
Powered by ViewVC 1.1.26