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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 845 by jongui, Fri Sep 8 07:13:01 2006 UTC revision 846 by jongui, Mon Sep 11 07:40:09 2006 UTC
# Line 3  Line 3 
3  @author: Lutz Gross  @author: Lutz Gross
4  """  """
5    
6  from common import Common  import vtk
7    
8  class Text(Common):  class Text:
9      """      """
10      Class that shows some text.      Class that displays text.
11      """      """
12    
13        def __init__(self, scene):
14            """
15            @type scene: L{Scene <scene.Scene>} object
16            @param scene: Scene in which components are to be added to
17            """
18    
19            self.scene = scene
20            self.vtk_text_mapper = None
21            self.vtk_text_actor = None
22    
23        def setText(self, text):
24            """
25            Setup the text mapper and its input together with the default settings.
26    
27            @type text: String
28            @param text: Text to be displayed  
29            """
30    
31            self.vtk_text_mapper = vtk.vtkTextMapper()
32            self.vtk_text_mapper.SetInput(text)
33            
34            #self.setFontSize(10)
35            self.setFontFamily("Times")
36            #self.setJustification("Right")
37            self.bold()
38            self.italic()
39            self.shadow()
40            # Default text color is black
41            self.getProperty().SetColor(0, 0, 0)
42        
43            self.setActor()
44            self.addActor()
45    
46        def getProperty(self):
47            """
48            Return the property of the text mapper.
49    
50            @rtype: vtkTextProperty
51            @return: VTK text property
52            """
53    
54            return self.vtk_text_mapper.GetTextProperty()
55    
56        #def setFontSize(self, size):
57        #   eval("self.getProperty().SetFontSize(%s)" % size)
58    
59        def setFontFamily(self, font):
60            """
61            Set the font of the text.
62    
63            @type font: String
64            @param font: Font of the text (i.e. Times, Arial and Courier)
65            """
66    
67            eval("self.getProperty().SetFontFamilyTo%s()" % font)
68        
69        #def setJustification(self, justification):
70        #   eval("self.getProperty().SetJustificationTo%s()" % justification)
71    
72        def bold(self):
73            """
74            Bold the text.
75            """
76    
77            self.getProperty().BoldOn()
78    
79        def italic(self):
80            """
81            Italize the text.
82            """
83    
84            self.getProperty().ItalicOn()
85    
86        def shadow(self):
87            """
88            Shadow the text.
89            """
90    
91            self.getProperty().ShadowOn()
92    
93        def setTextColor(self, colorMap):
94            """
95            Set the color of the text.
96    
97            @type colorMap: L{ColorMap <colormap.ColorMap>} object
98            @param colorMap: Color of the text
99            """
100    
101            #self.vtk_text_actor.GetProperty().SetColor(colorMap.getR(),
102            #   colorMap.getG(), colorMap.getB())
103            self.getProperty().SetColor(colorMap.getR(), colorMap.getG(),
104                colorMap.getB())
105    
106    
107        def setActor(self):
108            """
109            Set up the 2D text actor, its mapper and its display position.
110            """
111    
112            self.vtk_text_actor = vtk.vtkScaledTextActor()
113            self.vtk_text_actor.SetMapper(self.vtk_text_mapper)
114            self.vtk_text_actor.SetDisplayPosition(10, 10)
115    
116        def addActor(self):
117            """
118            Add the 2D text actor to the renderer.
119            """
120    
121            self.scene.getRenderer().AddActor2D(self.vtk_text_actor)

Legend:
Removed from v.845  
changed lines
  Added in v.846

  ViewVC Help
Powered by ViewVC 1.1.26