-
Notifications
You must be signed in to change notification settings - Fork 1
/
mylib_text.py
executable file
·43 lines (35 loc) · 1.41 KB
/
mylib_text.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env python
#
# Author: Patrick Brockmann
# Contact: [email protected]
# $Date: $
# $Name: $
# $Revision: $
# History:
# Modification:
#
import vtk
##################################
def CreateTextActor(text, textprop, xpos, ypos,
justification="left", fontsize=12,
verticaljustification="bottom"):
textactor = vtk.vtkTextActor()
textactor.SetInput(text)
textactor.GetPositionCoordinate().SetCoordinateSystemToNormalizedViewport()
textactor.SetPosition(xpos, ypos)
textactor.GetTextProperty().SetFontFamily(textprop.GetFontFamily())
textactor.GetTextProperty().SetColor(textprop.GetColor())
textactor.GetTextProperty().SetFontSize(fontsize)
if justification in (-1, "left"):
textactor.GetTextProperty().SetJustificationToLeft()
elif justification in (0, "center", "middle"):
textactor.GetTextProperty().SetJustificationToCentered()
elif justification in (1, "right"):
textactor.GetTextProperty().SetJustificationToRight()
if verticaljustification in (-1, "bottom"):
textactor.GetTextProperty().SetVerticalJustificationToBottom()
elif verticaljustification in (0, "center", "middle"):
textactor.GetTextProperty().SetVerticalJustificationToCentered()
elif verticaljustification in (1, "top"):
textactor.GetTextProperty().SetVerticalJustificationToTop()
return textactor