/[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 860 - (show annotations)
Thu Sep 28 08:17:29 2006 UTC (14 years, 2 months ago) by jongui
File MIME type: text/x-python
File size: 1436 byte(s)
- added sample drivers on how to use all of the currently available modules.
- completed the epydocs for all the currently available modules.
- added the rotation feature for camera and plane cutting.


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 Set up the text mapper.
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 """
54 Set the display position of the text.
55 @type x_coor: Number
56 @param x_coor: Coordinate along the x-axis
57 @type y_coor: Number
58 @param y_coor: Coordinate along the y-axis
59 """
60
61 self.vtk_text_actor.SetDisplayPosition(x_coor, y_coor)
62
63 def setStyle(self, style):
64 """
65 Set the style of the text.
66 @type style: L{Style <style.Style>} object
67 @param style: Style of the text
68 """
69
70 self.vtk_text_mapper.SetTextProperty(style.getStyle())
71

  ViewVC Help
Powered by ViewVC 1.1.26