summaryrefslogtreecommitdiffstats
path: root/tests/base.tcl
blob: 179850d95b4d6d9f0d08446d2b4c4de7eac47309 (plain)
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
set sleep 1000

proc bltPlot {w title} {
    toplevel $w
    wm title $w $title
    wm protocol $w WM_DELETE_WINDOW [list bltPlotDestroy $w]

    set mb ${w}mb
    menu $mb
    $w configure -menu $mb
}

proc bltPlotDestroy {w} {
    destroy ${w}mb
    destroy $w
}

proc bltTest {graph option value} {
    global sleep

    echo "  $option $value"
    set org [$graph cget $option]
    $graph configure $option $value
    update
    after $sleep
    $graph configure $option $org
    update
    after $sleep
}

proc bltTest2 {graph which option value} {
    global sleep

    echo "  $option $value"
    set org [$graph $which cget $option]
    $graph $which configure $option $value
    update
    after $sleep
    $graph $which configure $option $org
    update
    after $sleep
}

proc bltTest3 {graph which item option value} {
    global sleep

    echo "  $item $option $value"
    set org [$graph $which cget $item $option]
    $graph $which configure $item $option $value
    update
    after $sleep
    $graph $which configure $item $option $org
    update
    after $sleep
}

proc bltCmd {graph args} {
    global sleep

    echo " $graph $args"
    eval $graph $args
    update
    after $sleep
}

proc bltElements {graph} {
    $graph element create data1 \
	-xdata { 0.2 0.4 0.6 0.8 1.0 1.2 1.4 1.6 1.8 2.0 } \
	-ydata { 13 25 36 46 55 64 70 75 80 90}
    $graph element create data2 \
	-xdata { 0.2 0.4 0.6 0.8 1.0 1.2 1.4 1.6 1.8 2.0 } \
	-ydata { 26 50 72 92 110 128 140 150 160 180} \
 	-yerror {10 10 10 10 10 10 10 10 10 10 10}  \
	-color red
    $graph legend configure -title "Legend"
}

proc bltBarGraph {w} {
    global sleep

    set title "Bar Graph"
    bltPlot $w $title
    set graph [blt::barchart ${w}.gr \
		   -width 600 \
		   -height 500 \
		   -title $title \
		   -barwidth .2 \
		   -barmode aligned \
		  ]
    pack $graph -expand yes -fill both
    bltElements $graph

    update
    after $sleep
    return $graph
}

proc bltLineGraph {w} {
    global sleep

    set title "Line Graph"
    bltPlot $w $title
    set graph [blt::graph ${w}.gr \
		   -width 600 \
		   -height 500 \
		   -title $title \
		  ]
    pack $graph -expand yes -fill both
    bltElements $graph

    update
    after $sleep
    return $graph
}