File: TestFreetypeTextOverlay.tcl

package info (click to toggle)
vtk6 6.3.0%2Bdfsg2-8.1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 118,972 kB
  • sloc: cpp: 1,442,790; ansic: 113,395; python: 72,383; tcl: 46,998; xml: 8,119; yacc: 4,525; java: 4,239; perl: 3,108; lex: 1,694; sh: 1,093; asm: 154; makefile: 68; objc: 17
file content (89 lines) | stat: -rw-r--r-- 2,086 bytes parent folder | download | duplicates (8)
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package require vtk
package require vtkinteraction

set current_font_size 16

set default_text "ABCDEFGHIJKLMnopqrstuvwxyz"

set text_color [list [expr 246 / 255.0] [expr 255 / 255.0] [expr 11 / 255.0]]
set bg_color [list [expr 56 / 255.0] [expr 56 / 255.0] [expr 154 / 255.0]]

vtkRenderWindow renWin
    renWin SetSize 386 120

vtkRenderer ren1
    eval ren1 SetBackground $bg_color
    renWin AddRenderer ren1

vtkRenderWindowInteractor iren
    iren SetRenderWindow renWin
iren AddObserver UserEvent {wm deiconify .vtkInteract}

set i 0

# another actor to test occlusion
vtkPlaneSource plane
plane SetOrigin 120 10 0
plane SetPoint1 220 10 0
plane SetPoint2 120 110 0

vtkPolyDataMapper2D mapper
mapper SetInputConnection [plane GetOutputPort]

vtkActor2D actor
actor SetMapper mapper
[actor GetProperty] SetColor 0.5 0.5 0.5

ren1 AddActor actor

foreach family {
    Arial
} {
    foreach {bold italic shadow} {
        0 0 0
        0 0 1
        1 0 0
        0 1 0
        1 1 0
    } {
        incr i

        set attribs {}
        if {$bold} {
            lappend attribs "b"
        }
        if {$italic} {
            lappend attribs "i"
        }
        if {$shadow} {
            lappend attribs "s"
        }
        set face_name "$family"
        if {[llength $attribs]} {
            set face_name "$face_name ([join $attribs ,])"
        }

        set mapper [vtkTextMapper mapper_${family}_${bold}_${italic}_${shadow}]
        $mapper SetInput "$face_name: $default_text"

        set tprop [$mapper GetTextProperty]
        eval $tprop SetFontFamilyTo$family
        eval $tprop SetColor $text_color
        $tprop SetBold $bold
        $tprop SetItalic $italic
        $tprop SetShadow $shadow
        $tprop SetFontSize $current_font_size

        set actor [vtkActor2D actor_${family}_${bold}_${italic}_${shadow}]
        $actor SetMapper $mapper
        $actor SetDisplayPosition 10 [expr $i * ($current_font_size + 5)]

        ren1 AddActor $actor
    }
}

renWin Render

# prevent the tk window from showing up then start the event loop
wm withdraw .