--- tkgnuplot.org Thu Sep 19 09:53:52 2002 +++ tkgnuplot Thu Sep 19 20:20:52 2002 @@ -44,9 +44,11 @@ set gp_initfile "$env(HOME)/.tkgprc" set gp_savescriptfilename "tkgnuplot_tmp.gpt" set gp_termname tgif +set gp_termopt "" set gp_use_tmpfile 1 set gp_x11_size "350x240" set gp_x11_sizesub "150x150" +set gp_datafilemgr_window 0 ############################################################ # Load user setting file @@ -147,6 +149,7 @@ set m .m.file.menu menu $m $m add command -label "Data File Open" -underline 0 -command openPlotFile +$m add command -label "Open Datafile Manager" -command openDatafileManager $m add command -label "Load Script" -underline 0 -command loadScriptFile $m add command -label "Save Script" -underline 0 -command {gprollSaveScriptPre} $m add command -label "" @@ -173,6 +176,8 @@ set m .m.option.menu menu $m +menu $m.keymenu +$m add cascade -label "Key positon" -menu $m.keymenu $m add checkbutton -label "Grid" -underline 0 -onvalue grid -offvalue nogrid -variable chkgri -command {updateCanvas [list "set $chkgri" rep]} $m add separator $m add checkbutton -label "Parametric" -underline 0 -onvalue parametric -offvalue noparametric -variable chkpar -command {updateCanvas [list "set $chkpar" rep]} @@ -184,6 +189,14 @@ $m add command -label "Range" -underline 0 -state disabled $m add command -label "Data Using" -underline 0 -state disabled +$m.keymenu add command -label "Upper Left" -command {updateCanvas [list "set key left top" rep]} +$m.keymenu add command -label "Upper Right" -command {updateCanvas [list "set key right top" rep]} +$m.keymenu add command -label "Lower Left" -command {updateCanvas [list "set key left bottom" rep]} +$m.keymenu add command -label "Lower Right" -command {updateCanvas [list "set key right bottom" rep]} +$m.keymenu add command -label "Outside" -command {updateCanvas [list "set key outside" rep]} +$m.keymenu add command -label "None" -command {updateCanvas [list "set nokey" rep]} + + set m .m.style.menu menu $m $m add radiobutton -label "Lines" -underline 0 -value "data style lines" -variable chkstl -command {updateCanvas [list "set $chkstl" rep]} @@ -378,10 +391,10 @@ ############################################################ # print proc gprollPrint {} { - global gp_termname gp_outputfilename + global gp_termname gp_termopt gp_outputfilename if {$gp_outputfilename==""} {return} - foreach c [list "set term $gp_termname" \ + foreach c [list "set term $gp_termname $gp_termopt" \ "set output '$gp_outputfilename'" \ "rep" "set output"] { exp_send "$c\r" @@ -390,10 +403,10 @@ } proc gprollPrintPre {} { - global gp_termname gp_outputfilename + global gp_termname gp_termopt gp_outputfilename - toplevel .p set t .p + toplevel $t wm title $t "tkgnuplot: Print" frame $t.t @@ -434,18 +447,20 @@ set cur $gp_termname set fname $gp_outputfilename set curExt $gp_termext($cur) + set t .p regsub "\." $gp_preext "\\." gp_preext regsub "$gp_preext$" $fname "" fname append fname "$curExt" - .p.t.l config -text "Term: $cur" - .p.f.e delete 0 end - .p.f.e insert 0 $fname + $t.t.l config -text "Term: $cur" + $t.f.e delete 0 end + $t.f.e insert 0 $fname } proc gprollTermSelector {} { global gp_termlist gp_termname gp_outputfilename + global gp_termopt global gp_termext global gp_preext @@ -455,22 +470,30 @@ set gp_preext $gp_termext($gp_termname) label .t.l -text "Terminals" -borderwidth 2 -relief raise - listbox .t.lb -width 10 -selectmode single -borderwidth 0 \ + frame .t.f1 + label .t.f1.l -text "Option:" + entry .t.f1.opt -width 40 + .t.f1.opt insert end $gp_termopt + listbox .t.lb -width 10 -selectmode single -borderwidth 0 -bg "#ffffff" \ -relief sunken -yscrollcommand ".t.scl set" - listbox .t.lb_comment -borderwidth 0 + listbox .t.lb_comment -width 20 -borderwidth 0 -bg "#ffffff" set selcom gprollTermSelectorCommand scrollbar .t.scl -orient vertical \ -command "$selcom .t.lb .t.lb_comment yview" frame .t.p - label .t.p.cur -text $gp_termname + label .t.p.cur -text "$gp_termname" button .t.p.o -text ok \ -command {set gp_termname [.t.lb get [.t.lb curselection]]; \ + set gp_termopt [.t.f1.opt get]; \ destroy .t; gprollPrintPreUpdate} button .t.p.c -text cancel -command "destroy .t" - + button .t.p.h -text help -command terminalHelpCommand pack .t.l -side top -fill x + pack .t.f1 -side top -fill x + pack .t.f1.l -side left + pack .t.f1.opt -side left pack .t.lb .t.lb_comment .t.scl -side left -fill y - pack .t.p.cur .t.p.o .t.p.c -side top -expand yes -fill x + pack .t.p.cur .t.p.o .t.p.c .t.p.h -side top -expand yes -fill x pack .t.p -side top -anchor n foreach m $gp_termlist { @@ -497,6 +520,14 @@ eval $w2 $type $args } +proc terminalHelpCommand {} { + global gp_termname + global gp_helptopic gp_helpwindow + + set gp_termname [.t.p.cur cget -text] + displayHelp [list [list set terminal $gp_termname] 0] +} + ############################################################ # save script proc gprollSetSaveScriptFileName {{w}} { @@ -1839,6 +1870,7 @@ return } update + set gp_helptopic [list $topic $cur_yview] set t_cursor [lindex [$t configure -cursor] 3] set t_t_cursor [lindex [$t.text configure -cursor] 3] set t_e_cursor [lindex [$t.entry configure -cursor] 3] @@ -2040,6 +2072,127 @@ } ############################################################ +# data file manager for multiple file plotting + +proc setupDatafileManager {} { + global gp_datafilemgr_window + set t .datafile_manager + toplevel $t + label $t.l0 -text "Filename" + label $t.l1 -text "Column" + label $t.l2 -text "Title" + label $t.l3 -text "Style" + label $t.l4 -text "pt type" + label $t.l5 -text "pt size" + label $t.l6 -text "ln type" + label $t.l7 -text "ln size" + for {set i 0} {$i <= 7} {incr i} { + grid $t.l$i -row 0 -column $i + } + for {set j 1} {$j <= 6} {incr j} { + frame $t.f$j + entry $t.f$j.e + button $t.f$j.b -text "select" -command "datafileMgrSelect $j" + entry $t.using$j + entry $t.title$j + tk_optionMenu $t.style$j cur_style$j points lines linespoints dots steps impulses errorbars boxes boxerrorbars + entry $t.ptype$j -width 2 + entry $t.psize$j -width 2 + entry $t.ltype$j -width 2 + entry $t.lsize$j -width 2 + grid $t.f$j -row $j -column 0 + pack $t.f$j.e -side left + pack $t.f$j.b -side left + grid $t.using$j -row $j -column 1 + grid $t.title$j -row $j -column 2 + grid $t.style$j -row $j -column 3 + grid $t.ptype$j -row $j -column 4 + grid $t.psize$j -row $j -column 5 + grid $t.ltype$j -row $j -column 6 + grid $t.lsize$j -row $j -column 7 + } + frame $t.ff + grid $t.ff -row $j -column 0 -columnspan 5 + button $t.ff.plot -text plot -command datafileMgrPlot + checkbutton $t.ff.threeD -text "3D plot" -variable dfmgr_3D + button $t.ff.close -text close -command {set gp_datafilemgr_window 0; destroy .datafile_manager} + pack $t.ff.plot -side left + pack $t.ff.threeD -side left + pack $t.ff.close -side left + set gp_datafilemgr_window 1 +} + +proc openDatafileManager {} { + global gp_datafilemgr_window + if {$gp_datafilemgr_window} { + focus .datafile_manager + } else { + setupDatafileManager + } +} + +proc datafileMgrSelect {n} { + set tmp [tk_getOpenFile \ + -title {tkgnuplot: Open File} \ + -filetypes {{DAT {.dat}} {ALL {*}}}] + if {$tmp != ""} { + .datafile_manager.f$n.e insert end $tmp + .datafile_manager.f$n.e xview end + } + focus .datafile_manager +} + +proc datafileMgrPlot {} { + global dfmgr_3D + for {set i 1} {$i <= 6} {incr i} { + global cur_style$i + } + set plotfilespec "" + set t .datafile_manager + for {set j 1} {$j <= 6} {incr j} { + set file [$t.f$j.e get] + if {$file == ""} { continue } + if {$plotfilespec != ""} { + set plotfilespec "$plotfilespec," + } + set plotfilespec [concat $plotfilespec "\"$file\""] + set using [$t.using$j get] + if {$using != ""} { + set plotfilespec [concat $plotfilespec "using $using"] + } + set title [$t.title$j get] + if {$title != ""} { + set plotfilespec [concat $plotfilespec "title \"$title\""] + } + set plotfilespec [concat $plotfilespec with [eval set cur_style$j]] + set p [$t.ltype$j get] + if {$p != ""} { + set plotfilespec [concat $plotfilespec lt $p] + } + set p [$t.lsize$j get] + if {$p != ""} { + set plotfilespec [concat $plotfilespec lw $p] + } + set p [$t.ptype$j get] + if {$p != ""} { + set plotfilespec [concat $plotfilespec pt $p] + } + set p [$t.psize$j get] + if {$p != ""} { + set plotfilespec [concat $plotfilespec ps $p] + } + } + if {$dfmgr_3D} { + set plotcmd splot + } else { + set plotcmd plot + } + updateCanvas [list "$plotcmd $plotfilespec"] +} + + + +############################################################ # set gp_canvas .fc.c $gp_canvas create text [expr $width/2] [expr $height/2] -font {Helvetica 14} -text "Tkgnuplot: GNUPLOT graphical user interface" -justify center