Debian Codegraph @

exciter.tcl

raw
1 ############ exciter procedures -- [email protected] #########
2
3 proc exciter_apply {id} {
4 # strip "." from the TK id to make a variable name suffix
5 set vid [string trimleft $id .]
6 # for each variable, make a local variable to hold its name...
7 set var_graph_width [concat graph_width_$vid]
8 global $var_graph_width
9 set var_graph_height [concat graph_height_$vid]
10 global $var_graph_height
11 set var_graph_nbevents [concat graph_nbevents_$vid]
12 global $var_graph_nbevents
13 set var_graph_timegrain [concat graph_timegrain_$vid]
14 global $var_graph_timegrain
15 set var_graph_loop [concat graph_loop_$vid]
16 global $var_graph_loop
17 set var_graph_save [concat graph_save_$vid]
18 global $var_graph_save
19
20 set cmd [concat $id dialog \
21 [eval concat $$var_graph_width] \
22 [eval concat $$var_graph_height] \
23 [eval concat $$var_graph_nbevents] \
24 [eval concat $$var_graph_timegrain] \
25 [eval concat $$var_graph_loop] \
26 [eval concat $$var_graph_save] \;]
27 #puts stderr $cmd
28 pdsend $cmd
29 }
30
31 proc exciter_cancel {id} {
32 set cmd [concat $id cancel \;]
33 #puts stderr $cmd
34 pdsend $cmd
35 }
36
37 proc exciter_ok {id} {
38 exciter_apply $id
39 exciter_cancel $id
40 }
41
42 proc pdtk_exciter_dialog {id width height nbevents timegrain loop save } {
43 set vid [string trimleft $id .]
44
45 set var_graph_width [concat graph_width_$vid]
46 global $var_graph_width
47 set var_graph_height [concat graph_height_$vid]
48 global $var_graph_height
49 set var_graph_nbevents [concat graph_nbevents_$vid]
50 global $var_graph_nbevents
51 set var_graph_timegrain [concat graph_timegrain_$vid]
52 global $var_graph_timegrain
53 set var_graph_loop [concat graph_loop_$vid]
54 global $var_graph_loop
55 set var_graph_save [concat graph_save_$vid]
56 global $var_graph_save
57
58 set $var_graph_width $width
59 set $var_graph_height $height
60 set $var_graph_nbevents $nbevents
61 set $var_graph_timegrain $timegrain
62 set $var_graph_loop $loop
63 set $var_graph_save $save
64
65 toplevel $id
66 wm title $id {exciter}
67 wm protocol $id WM_DELETE_WINDOW [concat exciter_cancel $id]
68
69 label $id.label -text {EXCITER PROPERTIES}
70 pack $id.label -side top
71
72 frame $id.buttonframe
73 pack $id.buttonframe -side bottom -fill x -pady 2m
74 button $id.buttonframe.cancel -text {Cancel}\
75 -command "exciter_cancel $id"
76 button $id.buttonframe.apply -text {Apply}\
77 -command "exciter_apply $id"
78 button $id.buttonframe.ok -text {OK}\
79 -command "exciter_ok $id"
80 pack $id.buttonframe.cancel -side left -expand 1
81 pack $id.buttonframe.apply -side left -expand 1
82 pack $id.buttonframe.ok -side left -expand 1
83
84 frame $id.1rangef
85 pack $id.1rangef -side top
86 label $id.1rangef.lwidth -text "Width :"
87 entry $id.1rangef.width -textvariable $var_graph_width -width 7
88 pack $id.1rangef.lwidth $id.1rangef.width -side left
89
90 frame $id.2rangef
91 pack $id.2rangef -side top
92 label $id.2rangef.lheight -text "Height :"
93 entry $id.2rangef.height -textvariable $var_graph_height -width 7
94 pack $id.2rangef.lheight $id.2rangef.height -side left
95
96 frame $id.3rangef
97 pack $id.3rangef -side top
98 label $id.3rangef.lnbevents -text "Nb Events :"
99 entry $id.3rangef.nbevents -textvariable $var_graph_nbevents -width 7
100 pack $id.3rangef.lnbevents $id.3rangef.nbevents -side left
101
102 frame $id.4rangef
103 pack $id.4rangef -side top
104 label $id.4rangef.ltimegrain -text "Time Grain (seconds) :"
105 entry $id.4rangef.timegrain -textvariable $var_graph_timegrain -width 7
106 pack $id.4rangef.ltimegrain $id.4rangef.timegrain -side left
107
108 checkbutton $id.loop -text {Loop} -variable $var_graph_loop \
109 -anchor w
110 pack $id.loop -side top
111
112 checkbutton $id.save -text {Save contents} -variable $var_graph_save \
113 -anchor w
114 pack $id.save -side top
115
116 bind $id.1rangef.width <KeyPress-Return> [concat exciter_ok $id]
117 bind $id.2rangef.height <KeyPress-Return> [concat exciter_ok $id]
118 bind $id.3rangef.nbevents <KeyPress-Return> [concat exciter_ok $id]
119 bind $id.4rangef.timegrain <KeyPress-Return> [concat exciter_ok $id]
120 focus $id.1rangef.width
121 }
122
123 ############ exciter procedures END -- [email protected] #########