Overview
Comment:Added the ability to load and save gnuplot instructions to file.
Added grid and co-ordinate options.
Moved print option into menubar (under File).
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: 91b064b13c8bda98c9955efc0406986851f027a5997522fabba0d2dd5873d0aa
User & Date: geraint@users.sourceforge.net on 2002-07-12 15:13:17
Other Links: branch diff | manifest | tags
Context
2002-07-12
15:18:55
Added xMTT to menubar. check-in: 1edc1e6509 user: geraint@users.sourceforge.net tags: origin/master, trunk
15:13:17
Added the ability to load and save gnuplot instructions to file.
Added grid and co-ordinate options.
Moved print option into menubar (under File).
check-in: 91b064b13c user: geraint@users.sourceforge.net tags: origin/master, trunk
2002-07-11
20:46:37
Added multiplot feature allowing graphs to be overlaid. check-in: 66b3b0123f user: geraint@users.sourceforge.net tags: origin/master, trunk
Changes

Modified mttroot/mtt/bin/trans/struc2gnuplot_txt2wish from [a8ed17a5f7] to [f6030bf2a3].

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
#! /bin/sh

sys=$1

out=${sys}_gnuplot.wish
tmp=${sys}_gnuplot.tmp

struc=${sys}_struc.txt
dat2=${sys}_odes.dat2

Nx=`mtt_getsize ${sys} x`
Ny=`mtt_getsize ${sys} y`


## write header
cat <<EOF > ${out}
#!/bin/sh
# Next line replaces shell with wish\\
exec wish "\$0" "\$@"

## main window
wm title . "MTT Viewer: ${sys}"

set parameter ""
button .print -text "Print" -command { 
    global parameter;

    if {"\$parameter"==""} {








	tk_dialog ".mtt_Print_Error" "Print Error" "Select a parameter!" "" "0" "Try Again"

    } else {


	print \$parameter


    }


}



button .quit  -text "Quit"  -command exit






## states canvas
canvas		.cx
listbox		.cx.l
scrollbar	.cx.sy	-orient v
checkbutton    	.cx.t	-text		"States"

## outputs canvas
canvas		.cy
listbox		.cy.l
scrollbar	.cy.sy	-orient v
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"






<
















<

|
|
>
|
>
>
>
>
>
>
>
>
|
>
|
>
>
|
>
>
|
>
>
|
>
>
>
|
>
>
>
>
>





|





|







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
#! /bin/sh

sys=$1

out=${sys}_gnuplot.wish


struc=${sys}_struc.txt
dat2=${sys}_odes.dat2

Nx=`mtt_getsize ${sys} x`
Ny=`mtt_getsize ${sys} y`


## write header
cat <<EOF > ${out}
#!/bin/sh
# Next line replaces shell with wish\\
exec wish "\$0" "\$@"

## main window
wm title . "MTT Viewer: ${sys}"

set parameter ""

# menu bar
canvas .menubar

menubutton .menubar.file -text "File" -menu .menubar.file.menu
menu .menubar.file.menu
.menubar.file.menu add command -label "Open  (Gnuplot plot file)"    -command open_plotfile
.menubar.file.menu add command -label "Save  (Gnuplot plot file)"    -command save_plotfile
.menubar.file.menu add separator
.menubar.file.menu add command -label "Print (PostScript file)"	     -command print_postscript
.menubar.file.menu add separator
.menubar.file.menu add command -label "Quit"			     -command exit

button .menubar.quit  -text "Quit" -relief flat		 -command exit 

pack .menubar.file    -expand false -fill x -side left
pack .menubar.quit    -expand false -fill x -side right

# status bar
canvas .statusbar

radiobutton .statusbar.states  -text "States"      -value states  -variable view      -relief solid -command { raise .cx }
radiobutton .statusbar.outputs -text "Outputs"     -value outputs -variable view      -relief solid -command { raise .cy }

tk_optionMenu .statusbar.plot  plottype "Single Plot" "Multi Plot" "New Window"
tk_optionMenu .statusbar.grid  grid     "Grid On" "Grid Off"
tk_optionMenu .statusbar.coord coord	"Cartesian" "Polar"

pack .statusbar.states  -expand false -fill x -side left
pack .statusbar.outputs -expand false -fill x -side left
pack .statusbar.plot    -expand false -fill x -side right
pack .statusbar.coord   -expand false -fill x -side right
pack .statusbar.grid    -expand false -fill x -side right

## states canvas
canvas		.cx
listbox		.cx.l
scrollbar	.cx.sy	-orient v
checkbutton    	.cx.t	-text		"States"	-relief flat

## outputs canvas
canvas		.cy
listbox		.cy.l
scrollbar	.cy.sy	-orient v
checkbutton    	.cy.t	-text		"Outputs"	-relief flat

## 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"

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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
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      -relief solid -command { raise .cx }
radiobutton .outputs -text "Outputs"     -value outputs -variable view      -relief solid -command { raise .cy }

#menubutton .plottype -text "Plot type" -menu .plottype.plottype

#menu .plottype.plottype
tk_optionMenu .plottype plottype "Single Plot"\
                                 "Multi Plot "\
                                 "New Window "

pack .states .outputs -side left

pack .quit   -expand false -fill x -side right
pack .print  -expand false -fill x -side right
pack .plottype   -expand false -fill x -side top

## map names to column numbers
EOF

gawk '
BEGIN {
    print "proc \"plot\" \"title\" {";
}







>
>
>












<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
















145
146
147
148
149
150
151
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 .menubar	      -expand false -fill x -side top
pack .statusbar	      -expand false -fill x -side bottom

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

















## map names to column numbers
EOF

gawk '
BEGIN {
    print "proc \"plot\" \"title\" {";
}
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170























































171

172



173
174
175
176
177
178
179
180
181
182
183
184
185
186

187
188
189
190
191
' Title=\$title Ny=${Ny} ${struc} >> ${out}


cat <<EOF >> ${out}

## call gnuplot
proc "plot_var" "title column" {
    puts "set grid"
    puts "set term X11"
    global plottype
    if {"\$plottype" == "Multi Plot "} {
	puts "replot '${dat2}' using 1:\$column title '\$title' with lines"
    } elseif {"\$plottype" == "New Window "} {
	puts "! echo \"plot '${dat2}' using 1:\$column title '\$title' with lines\" | gnuplot -geometry 400x300 -persist"
    } else {
	puts "plot '${dat2}' using 1:\$column title '\$title' with lines"
    }
}
























































## print output

proc "print" "parameter" {



    set filename [tk_getSaveFile\
	-initialdir ".."\
	-initialfile "\$parameter.ps"\
	-defaultextension ".ps"\
	-filetypes {
	    {{Postscript} {.ps}}
	    {{All files} {*}}
	}
    ]
    if {\$filename != ""} {
	puts "set term postscript"
	puts "set output \"\$filename\""
	puts "replot"
	tk_dialog ".printed" "Graph Printed!" "PostScript saved as \$filename" "" "0" "Close"

    }
}

EOF
chmod +x ${out}







|


|

|






>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
|
>
>
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>





161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
' Title=\$title Ny=${Ny} ${struc} >> ${out}


cat <<EOF >> ${out}

## call gnuplot
proc "plot_var" "title column" {
    set_plot_options
    puts "set term X11"
    global plottype
    if {"\$plottype" == "Multi Plot"} {
	puts "replot '${dat2}' using 1:\$column title '\$title' with lines"
    } elseif {"\$plottype" == "New Window"} {
	puts "! echo \"plot '${dat2}' using 1:\$column title '\$title' with lines\" | gnuplot -geometry 400x300 -persist"
    } else {
	puts "plot '${dat2}' using 1:\$column title '\$title' with lines"
    }
}

proc "set_plot_options" "" {
    global coord;			# "Cartesian", "Polar"
    global grid;			# "Grid On", "Grid Off"
    if {"\$coord" == "Cartesian"} {
	puts "set nopolar"
    } else {
	puts "set polar"
    }
    if {"\$grid" == "Grid On"} {
	puts "set grid"
    } else {
	puts "set nogrid"
    }
}

## open gnuplot plot file
proc "open_plotfile" "" {
    global parameter
    if {"\$parameter"==""} {
	set name "${sys}.plt"
    } else {
	set name "\$parameter.plt"
    }
    set filename [tk_getOpenFile\
	-initialdir ".."\
	-initialfile "\$name"\
	-defaultextension ".plt"\
	-filetypes {
	    {{Gnuplot} {.plt}}
	    {{All files} {*}}
	}
    ]
    puts "load '\$filename'"
}

## save gnuplot plot file
proc "save_plotfile" "" {
    global parameter
    if {"\$parameter"==""} {
	set name "${sys}.plt"
    } else {
	set name "\$parameter.plt"
    }
    set filename [tk_getSaveFile\
	-initialdir ".."\
	-initialfile "\$name"\
	-defaultextension ".plt"\
	-filetypes {
	    {{Gnuplot} {.plt}}
	    {{All files} {*}}
	}
    ]
    puts "save '\$filename'"
}

## print output to postscript
proc "print_postscript" "" {
    global parameter;
    if {"\$parameter"==""} {
	tk_dialog ".mtt_Print_Error" "Print Error" "Select a parameter!" "" "0" "Try Again"
    } else {
	set filename [tk_getSaveFile\
		-initialdir ".."\
		-initialfile "\$parameter.ps"\
		-defaultextension ".ps"\
		-filetypes {
		    {{Postscript} {.ps}}
		    {{All files} {*}}
		}
	]
	if {\$filename != ""} {
	    puts "set term postscript"
	    puts "set output '\$filename'"
	    puts "replot"
	    tk_dialog ".printed" "Graph Printed!" "PostScript saved as \$filename" "" "0" "Close"
	}
    }
}

EOF
chmod +x ${out}


MTT: Model Transformation Tools
GitHub | SourceHut | Sourceforge | Fossil RSS ]