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
|
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
115
116
117
118
119
120
121
122
123
124
125
126
|
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
+
+
+
+
+
-
-
+
+
|
button .print -text "Print" -command print
button .quit -text "Quit" -command exit
## states canvas
canvas .cx
listbox .cx.l
scrollbar .cx.sy -orient v
label .cx.t -text "States"
checkbutton .cx.t -text "States"
## outputs canvas
canvas .cy
listbox .cy.l
scrollbar .cy.sy -orient v
label .cy.t -text "Outputs"
checkbutton .cy.t -text "Outputs"
## configure scrollbars
.cx.sy configure -command ".cx.l yview"
.cy.sy configure -command ".cy.l yview"
.cx.l configure -yscrollcommand ".cx.sy set"
.cy.l configure -yscrollcommand ".cy.sy set"
## bind lists
bind .cx.l <<ListboxSelect>> { plot [ .cx.l get anchor ] }
bind .cy.l <<ListboxSelect>> { plot [ .cy.l get anchor ] }
proc "reverse_name" "name" {
set delim "_"
set split_name [split \$name \$delim]
set reversed_name [lindex \$split_name 0]
for {set i 1} {\$i<[llength \$split_name]} {incr i} {
set reversed_name [lindex \$split_name \$i]\$delim\$reversed_name
}
return \$reversed_name
}
proc "reverse_sort" "list" {
set temp_list {}
set delim " "
foreach name [split \$list \$delim] {
set temp_list \$temp_list\$delim[reverse_name \$name]
}
set temp_list [lsort -ascii \$temp_list]
set list {}
foreach name [split \$temp_list \$delim] {
set list \$list\$delim[reverse_name \$name]
}
return \$list
}
proc "sort_list" "list sortorder" {
puts "sortorder: \$sortorder"
if ("\$sortorder"=="normal") {
return [lsort -ascii \$list]
}
if ("\$sortorder"=="reverse") {
return [reverse_sort \$list]
}
}
EOF
## create states and outputs lists
awk '
($1 == "state") {
printf ".cx.l insert end state:%s\n", $4
printf "lappend xl state:%s\n", $4
}
($1 == "output") {
printf ".cy.l insert end output:%s\n", $4
printf "lappend yl output:%s\n", $4
}' ${struc} >> ${out}
cat <<EOF >> ${out}
.cx.l configure -listvar xl
.cy.l configure -listvar yl
.cx.t configure -command { set xl [sort_list \$xl \$xsortorder] } -indicatoron false -onvalue "reverse" -offvalue "normal" -variable xsortorder
.cy.t configure -command { set yl [sort_list \$yl \$ysortorder] } -indicatoron false -onvalue "reverse" -offvalue "normal" -variable ysortorder
pack .cx.t -expand false -fill x -side top
pack .cy.t -expand false -fill x -side top
pack .cx.sy -expand false -fill y -side right
pack .cy.sy -expand false -fill y -side right
pack .cx.l -expand true -fill both -side left
pack .cy.l -expand true -fill both -side left
pack .cx -expand true -fill both
place .cy -in .cx -relx 0 -rely 0 -relwidth 1 -relheight 1 -anchor nw -bordermode outside
radiobutton .states -text "States" -value states -variable view -command { raise .cx } -relief solid
radiobutton .outputs -text "Outputs" -value outputs -variable view -command { raise .cy } -relief solid
pack .states .outputs -side left
pack .quit -expand false -fill x -side right
pack .print -expand false -fill x -side right
pack .quit -expand false -fill x -side right
pack .print -expand false -fill x -side right
## map names to column numbers
EOF
awk '
BEGIN {
|
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
|
-
+
-
+
|
' Title=\$title Ny=${Ny} ${struc} >> ${out}
cat <<EOF >> ${out}
## call gnuplot
proc "plot_var" "title column" {
exec echo plot \\\"${dat2}\\\" using 1:\$column title \\\"\$title\\\" with lines > ${tmp}
exec echo plot \"${dat2}\" using 1:\$column title \"\$title\" with lines > ${tmp}
exec echo pause -1 >> ${tmp}
exec gnuplot -title "\$title" ${tmp} &
}
## print output
proc "print" "" {
exec echo set term postscript > ${tmp}.print
exec echo set output \\\"../${sys}_gnuplot.ps\\\" >> ${tmp}.print
exec echo set output \"../${sys}_gnuplot.ps\" >> ${tmp}.print
exec grep -v pause ${tmp} >> ${tmp}.print
exec gnuplot ${tmp}.print
puts "Graph printed to ${sys}_gnuplot.ps"
}
EOF
chmod +x ${out}
|