4 |
""" |
""" |
5 |
|
|
6 |
import vtk |
import vtk |
7 |
|
from style import Style |
8 |
|
#from colormap import * |
9 |
|
|
10 |
class Text: |
class Text: |
11 |
""" |
""" |
33 |
self.vtk_text_mapper = vtk.vtkTextMapper() |
self.vtk_text_mapper = vtk.vtkTextMapper() |
34 |
self.vtk_text_mapper.SetInput(text) |
self.vtk_text_mapper.SetInput(text) |
35 |
|
|
|
#self.setFontSize(10) |
|
|
self.setFontFamily("Times") |
|
|
#self.setJustification("Right") |
|
|
self.bold() |
|
|
self.italic() |
|
|
self.shadow() |
|
|
# Default text color is black |
|
|
self.getProperty().SetColor(0, 0, 0) |
|
|
|
|
36 |
self.setActor() |
self.setActor() |
37 |
self.addActor() |
self.addActor() |
38 |
|
|
39 |
def getProperty(self): |
def setPosition(self, x_coor, y_coor): |
40 |
""" |
self.vtk_text_actor.SetDisplayPosition(x_coor, y_coor) |
|
Return the property of the text mapper. |
|
|
|
|
|
@rtype: vtkTextProperty |
|
|
@return: VTK text property |
|
|
""" |
|
|
|
|
|
return self.vtk_text_mapper.GetTextProperty() |
|
|
|
|
|
#def setFontSize(self, size): |
|
|
# eval("self.getProperty().SetFontSize(%s)" % size) |
|
|
|
|
|
def setFontFamily(self, font): |
|
|
""" |
|
|
Set the font of the text. |
|
|
|
|
|
@type font: String |
|
|
@param font: Font of the text (i.e. Times, Arial and Courier) |
|
|
""" |
|
|
|
|
|
eval("self.getProperty().SetFontFamilyTo%s()" % font) |
|
|
|
|
|
#def setJustification(self, justification): |
|
|
# eval("self.getProperty().SetJustificationTo%s()" % justification) |
|
41 |
|
|
42 |
def bold(self): |
def setStyle(self, style): |
43 |
""" |
self.vtk_text_mapper.SetTextProperty(style.getTextProperty()) |
|
Bold the text. |
|
|
""" |
|
|
|
|
|
self.getProperty().BoldOn() |
|
|
|
|
|
def italic(self): |
|
|
""" |
|
|
Italize the text. |
|
|
""" |
|
|
|
|
|
self.getProperty().ItalicOn() |
|
|
|
|
|
def shadow(self): |
|
|
""" |
|
|
Shadow the text. |
|
|
""" |
|
|
|
|
|
self.getProperty().ShadowOn() |
|
|
|
|
|
def setTextColor(self, colorMap): |
|
|
""" |
|
|
Set the color of the text. |
|
|
|
|
|
@type colorMap: L{ColorMap <colormap.ColorMap>} object |
|
|
@param colorMap: Color of the text |
|
|
""" |
|
|
|
|
|
#self.vtk_text_actor.GetProperty().SetColor(colorMap.getR(), |
|
|
# colorMap.getG(), colorMap.getB()) |
|
|
self.getProperty().SetColor(colorMap.getR(), colorMap.getG(), |
|
|
colorMap.getB()) |
|
44 |
|
|
45 |
|
|
46 |
def setActor(self): |
def setActor(self): |
50 |
|
|
51 |
self.vtk_text_actor = vtk.vtkScaledTextActor() |
self.vtk_text_actor = vtk.vtkScaledTextActor() |
52 |
self.vtk_text_actor.SetMapper(self.vtk_text_mapper) |
self.vtk_text_actor.SetMapper(self.vtk_text_mapper) |
53 |
self.vtk_text_actor.SetDisplayPosition(10, 10) |
self.vtk_text_actor.SetDisplayPosition(50, 20) |
54 |
|
|
55 |
def addActor(self): |
def addActor(self): |
56 |
""" |
""" |
58 |
""" |
""" |
59 |
|
|
60 |
self.scene.getRenderer().AddActor2D(self.vtk_text_actor) |
self.scene.getRenderer().AddActor2D(self.vtk_text_actor) |
61 |
|
|
62 |
|
|
63 |
|
|