/*---------------------------------------------------------------------------- File name : jitter_gui.c Author : Y. Jung Created on : June 2001 Description : Graphical user interface for the jitter ---------------------------------------------------------------------------*/ /* $Id: jitter_gui.c,v 1.4 2001/06/12 13:35:46 yjung Exp $ $Author: yjung $ $Date: 2001/06/12 13:35:46 $ $Revision: 1.4 $ */ /*---------------------------------------------------------------------------- Includes ---------------------------------------------------------------------------*/ #include #include #include #include /*---------------------------------------------------------------------------- Static TCL code ---------------------------------------------------------------------------*/ static char tcl_code[] = "proc errorMessage { string_arg } {global var\n" "global but_font\n" "set win [toplevel .window]\n" "wm title .window \"Error message\"\n" "frame $win.err -background white -borderwidth 10 -cursor pirate -height 100 -width 60\n" "label $win.err.lab -background black -borderwidth 5 -font $but_font -foreground white -relief sunken -text $string_arg -width 60 -wraplength 500\n" "button $win.err.but -activebackground red -activeforeground black -background blue -borderwidth 5 -command \"set var 1\" -font $but_font -foreground white -relief groove -text Ok\n" "pack $win.err -side top\n" "pack $win.err.lab -side top\n" "pack $win.err.but\n" "tkwait variable var\n" "destroy $win\n" "return}\n" "catch {exec rm tclIndex}\n" "lappend auto_path [exec dirname [exec which $argv0]]\n" "proc mainProg {} {global but_act_back_col\n" "global but_back_col\n" "global but_fore_col\n" "global lab_back_col\n" "global but_font\n" "global argv\n" "global argc\n" "global currentfile\n" "global topc\n" "set but_act_back_col cyan3\n" "set but_back_col cyan2\n" "set but_fore_col blue\n" "set lab_back_col SkyBlue1\n" "set but_font 8x13bold\n" "set currentfile \"No Name\"\n" "wm title . \"Jitter.ini configuration\"\n" "frame .mbar -relief raised -background $lab_back_col -borderwidth 2\n" "menubutton .mbar.file -activebackground $but_act_back_col -activeforeground black -background $but_back_col -font $but_font -foreground $but_fore_col -relief raised -text File -menu .mbar.file.menu\n" "menu .mbar.file.menu -tearoff 0\n" ".mbar.file.menu add command -label \"Open...\" -command \"openFile\"\n" ".mbar.file.menu add command -label \"New\" -command \"newFile\"\n" ".mbar.file.menu add command -label \"Save\" -command \"saveFile\"\n" ".mbar.file.menu add command -label \"Save as...\" -command \"saveAsFile\"\n" ".mbar.file.menu add separator\n" ".mbar.file.menu add command -label \"Exit\" -command exit\n" "menubutton .mbar.opti -activebackground $but_act_back_col -activeforeground black -background $but_back_col -font $but_font -foreground $but_fore_col -relief raised -text \"Options\" -menu .mbar.opti.menu\n" "menu .mbar.opti.menu -tearoff 0\n" ".mbar.opti.menu add cascade -label \"Fonts\" -menu .mbar.opti.menu.fonts\n" ".mbar.opti.menu add cascade -label \"Colors\" -menu .mbar.opti.menu.color\n" "menu .mbar.opti.menu.fonts -tearoff 0\n" ".mbar.opti.menu.fonts add command -label \"Fixed\" -command \"modFont fixed .\"\n" ".mbar.opti.menu.fonts add command -label \"Helvetica\" -command {\n" " if {[catch {modFont -*-helvetica-medium-r-normal-*-14-*-*-*-*-*-iso8859-* .}] == 1 } {\n" " modFont fixed .\n" " }\n" " }\n" ".mbar.opti.menu.fonts add command -label \"HelveticaBold\" -command {\n" " if {[catch { modFont -adobe-helvetica-bold-r-normal--14-140-75-75-p-82-iso8859-1 .}] == 1 } {\n" " modFont fixed .\n" " }\n" " }\n" ".mbar.opti.menu.fonts add command -label \"Lucida\" -command {\n" " if {[catch { modFont -b&h-lucidatypewriter-bold-r-normal-sans-14-140-75-75-m-90-iso8859-1 .}] == 1 } {\n" " modFont fixed .\n" " }\n" " }\n" ".mbar.opti.menu.fonts add command -label \"Fixed2\" -command {\n" " if {[catch { modFont -misc-fixed-medium-r-normal--14-110-100-100-c-70-iso8859-1 .}] == 1 } {\n" " modFont fixed .\n" " }\n" " }\n" "menu .mbar.opti.menu.color -tearoff 0\n" ".mbar.opti.menu.color add command -label \"Black & White\" -command {modCol b&w}\n" ".mbar.opti.menu.color add command -label \"Color\" -command {modCol col}\n" "button .mbar.help -activebackground $but_act_back_col -activeforeground black -background $but_back_col -font $but_font -foreground $but_fore_col -relief raised -text Help -command {\n" " if { $jitter_install == 0 } {\n" " errorMessage \"Cannot execute jitter => no help file\"\n" " return\n" " }\n" " catch {exec jitter -f help_gui.ini -g}\n" " ini2Help help_gui.ini help_gui.txt\n" " roWin \"Help file\" help_gui.txt \n" " exec rm -f help_gui.txt\n" " exec rm -f help_gui.ini\n" " }\n" "label .file_selected -background $lab_back_col -borderwidth 2 -font $but_font -foreground black -relief flat -textvariable currentfile\n" "set topc [canvas .canv -yscrollcommand \".scrolly set\"]\n" "scrollbar .scrolly -orient vertical -command \"$topc yview\"\n" "pack .scrolly -fill y -side right\n" "pack $topc -fill both -expand true -side bottom\n" "pack .mbar -side top -fill x\n" "pack .mbar.file -side left\n" "pack .mbar.opti -side left\n" "pack .mbar.help -side right\n" "pack .file_selected -side top -fill x\n" "if { $argc > 0 } {if { [lindex $argv 0] == \"-\" } {if { $argc > 1 } {set currentfile [lindex $argv 1]\n" "pack .file_selected\n" "file2Array\n" "displayArray}} else {set currentfile [lindex $argv 0]\n" "pack .file_selected\n" "file2Array\n" "displayArray}}}\n" "proc Start {} {global jitter_install\n" "global but_font\n" "set lit_font 8x13\n" "set but_font 8x13bold\n" "set jitter_install 1\n" "if [catch {set ecl_version [exec jitter --version]} resId] {errorMessage \"Cannot execute jitter --version\"\n" "set jitter_install 0\n" "set ecl_version \"?\"}\n" "frame .f\n" "label .f.l -text \"Welcome to GUI for the jitter\"\n" "pack .f.l -in .f -side top\n" "label .f.l2 -text \"This GUI supports eclipse version 4.0.1\" -font $lit_font\n" "pack .f.l2 -in .f -side top\n" "label .f.l3 -text \"Actual eclipse version: $ecl_version\" -font $lit_font\n" "pack .f.l3 -in .f -side top\n" "button .f.b -text \"Start GUI\" -command {\n" " destroy .f\n" " mainProg\n" " }\n" "pack .f.b -in .f -side top -expand 1 -fill both\n" "button .f.b2 -text \"Exit\" -command exit\n" "pack .f.b2 -in .f -side top\n" "pack .f}\n" "Start\n" "proc bindDelEnt {widget} {set child [winfo children $widget]\n" "foreach x $child {if { ([winfo class $x] == \"Entry\") } {bind $x {\n" " }}\n" "if { ([winfo class $x] == \"Frame\") } {bindDelEnt $x}\n" "if { ([winfo class $x] == \"Canvas\") } {bindDelEnt $x}}\n" "return}\n" "proc roWin {title file} {if { ![file exists $file] } {errorMessage \"Cannot find $file\"\n" "return}\n" "if { [winfo exists .rowindow] == 1 } {destroy .rowindow}\n" "toplevel .rowindow\n" "wm title .rowindow $title\n" "frame .rowindow.t\n" "text .rowindow.t.text -relief sunken -bd 2 -yscrollcommand \".rowindow.t.scr_help set\"\n" "scrollbar .rowindow.t.scr_help -command \".rowindow.t.text yview\"\n" "pack .rowindow.t.scr_help -side right -fill y\n" "pack .rowindow.t.text -fill both -side left -expand true\n" "pack .rowindow.t -fill both -side top -expand true\n" "loadFile .rowindow.t.text $file\n" "button .rowindow.b -text Dismiss -command { destroy .rowindow }\n" "pack .rowindow.b -side bottom -anchor s}\n" "proc loadFile {win file} {$win delete 1.0 end\n" "set f [open $file]\n" "while {![eof $f]} {$win insert end [read $f 1000]}\n" "close $f}\n" "proc modFont {font widget} {set child [winfo children $widget]\n" "foreach x $child {if { ([winfo class $x] == \"Label\") } {$x config -font $font} elseif {[winfo class $x] == \"Entry\"} {$x config -font $font} elseif {[winfo class $x] == \"Button\"} {$x config -font $font} elseif {[winfo class $x] == \"Checkbutton\"} {$x config -font $font} elseif {[winfo class $x] == \"Radiobutton\"} {$x config -font $font} elseif {[winfo class $x] == \"Frame\"} {modFont $font $x} elseif {[winfo class $x] == \"Canvas\"} {modFont $font $x}}\n" "return}\n" "proc modCol { col_type } {global but_act_back_col\n" "global but_back_col\n" "global but_fore_col\n" "global lab_back_col\n" "if { $col_type == \"col\" } {set but_act_back_col cyan3\n" "set but_back_col cyan2\n" "set but_fore_col blue\n" "set lab_back_col SkyBlue1} elseif {$col_type == \"b&w\"} {set but_act_back_col white\n" "set but_back_col white\n" "set but_fore_col black\n" "set lab_back_col white}\n" ".mbar config -background $lab_back_col\n" ".mbar.file config -activebackground $but_act_back_col -background $but_back_col -foreground $but_fore_col\n" ".mbar.opti config -activebackground $but_act_back_col -background $but_back_col -foreground $but_fore_col\n" ".mbar.help config -activebackground $but_act_back_col -background $but_back_col -foreground $but_fore_col\n" ".file_selected config -background $lab_back_col\n" "return}\n" "proc greyOut {widget} {global children\n" "set children [winfo children $widget]\n" "foreach x $children {if { ([winfo class $x] == \"Label\") } {$x config -foreground grey50} elseif {[winfo class $x] == \"Entry\"} {$x config -state disabled\n" "$x config -foreground grey50} elseif {[winfo class $x] == \"Button\"} {$x config -state disabled} elseif {[winfo class $x] == \"Checkbutton\"} {$x config -state disabled} elseif {[winfo class $x] == \"Radiobutton\"} {$x config -state disabled} elseif {[winfo class $x] == \"Frame\"} {greyOut $x} elseif {[winfo class $x] == \"Canvas\"} {} elseif {[winfo class $x] == \"Scrollbar\"} {}}\n" "return}\n" "proc greyIn {widget} {global topc\n" "global children\n" "global refine\n" "global pp3_start\n" "global input_offset\n" "global source_type\n" "set children [winfo children $widget]\n" "foreach x $children {if { ([winfo class $x] == \"Label\") } {$x config -foreground black} elseif {[winfo class $x] == \"Entry\"} {$x config -state normal\n" "$x config -foreground black} elseif {[winfo class $x] == \"Button\"} {$x config -state normal} elseif {[winfo class $x] == \"Checkbutton\"} {$x config -state normal} elseif {[winfo class $x] == \"Radiobutton\"} {$x config -state normal} elseif {[winfo class $x] == \"Frame\"} {greyIn $x} elseif {[winfo class $x] == \"Canvas\"} {} elseif {[winfo class $x] == \"Scrollbar\"} {}}\n" "if { $refine == 0 } {greyOut $topc.saa.asaa.file.refine}\n" "if { $pp3_start == 0 } {greyOut $topc.post.activ.start.command}\n" "if { $input_offset != \"header\" } {greyOut $topc.saa.asaa.header}\n" "if { $input_offset != \"file\" } {greyOut $topc.saa.asaa.file}\n" "if { $source_type != \"auto\" } {greyOut $topc.saa.asaa.peak}\n" "if { $source_type != \"file\" } {greyOut $topc.saa.asaa.userobj}\n" "return}\n" "proc drawHLine { widget ypos line_width} {global topc\n" "$widget create line 0 $ypos [winfo screenmmwidth .] $ypos -width $line_width}\n" "proc blockLabEnt { widget lab ent_size section keyword } {global keyarray\n" "global found_pos\n" "global found_val\n" "global ent_sec\n" "global ent_key\n" "set ent_sec($widget.ent) $section\n" "set ent_key($widget.ent) $keyword\n" "frame $widget\n" "label $widget.lab -text $lab\n" "entry $widget.ent -width $ent_size\n" "bind $widget.ent {\n" " findInArray $ent_sec(%W) $ent_key(%W)\n" " set keyarray($found_pos) [%W get]\n" " }\n" "findInArray $section $keyword\n" "$widget.ent insert 0 $found_val\n" "pack $widget.lab -side left\n" "pack $widget.ent -side right\n" "return}\n" "proc displayArray {} {global keyarray\n" "global found_val\n" "global found_pos\n" "global currentfile\n" "global topc\n" "global ent_sec\n" "global ent_key\n" "global enable\n" "global disable\n" "global indent\n" "global jitter_install\n" "global children\n" "global g_extch\n" "global d_subt\n" "global bp_rep\n" "global ff_div\n" "global se1_est\n" "global se4_diff\n" "global saa_apply\n" "global source_type\n" "global input_offset\n" "global detect_image\n" "global out_obj\n" "global refine\n" "global o1_offs\n" "global pp1_post\n" "global pp2_subt\n" "global pp3_start\n" "set xpos 2\n" "set ypos 2\n" "set line_height 28\n" "set line_width 600\n" "set std_entry_size 20\n" "set keyw_ent_size 45\n" "set lit_entry_size 5\n" "set disable greyOut\n" "set enable greyIn\n" "set indent [expr [winfo screenmmwidth .]/10]\n" "set array_size [array size keyarray]\n" "if {$array_size == 0} return\n" "if { [info exists topc] } {destroy $topc\n" "destroy .scrolly\n" "set topc [canvas .canv -yscrollcommand \".scrolly set\"]\n" "scrollbar .scrolly -orient vertical -command \"$topc yview\"\n" "pack .scrolly -fill y -side right\n" "pack $topc -fill both -expand true -side top}\n" "if { [winfo exists .launch] } {destroy .launch}\n" "frame $topc.g -height [expr 3*$line_height] -width $line_width\n" "$topc create window $xpos $ypos -window $topc.g -anchor nw\n" "incr ypos [winfo reqheight $topc.g]\n" "label $topc.g.lab -text \"General -\"\n" "pack $topc.g.lab -side top -anchor nw\n" "findInArray General Eclipse\n" "label $topc.g.lab2 -text \"Eclipse version: $found_val\"\n" "pack $topc.g.lab2 -side top -anchor nw -padx $indent -fill x\n" "findInArray General ExtendedChecks\n" "if { $found_val == \"yes\" } {set g_extch 1} else {set g_extch 0}\n" "checkbutton $topc.g.extche -text \"Extended checks\" -variable g_extch -command {\n" " findInArray General ExtendedChecks\n" " if { $g_extch == 0 } {\n" " set keyarray($found_pos) \"no\"\n" " } else {\n" " set keyarray($found_pos) \"yes\"\n" " }\n" " }\n" "pack $topc.g.extche -side top -anchor nw -padx $indent\n" "drawHLine $topc $ypos 1\n" "incr ypos\n" "frame $topc.f -height [expr 2*$line_height] -width $line_width\n" "$topc create window $xpos $ypos -window $topc.f -anchor nw\n" "incr ypos [winfo reqheight $topc.f]\n" "label $topc.f.lab1 -text \"Frames -\"\n" "label $topc.f.lab2 -text \"FileList\"\n" "entry $topc.f.ent -width $std_entry_size\n" "bind $topc.f.ent {\n" " findInArray Frames FileList\n" " set keyarray($found_pos) [$topc.f.ent get] \n" " }\n" "findInArray Frames FileList\n" "$topc.f.ent insert 0 $found_val\n" "set ent_sec($topc.f.ent) \"Frames\"\n" "set ent_key($topc.f.ent) \"FileList\"\n" "button $topc.f.but -text View -command {\n" " roWin \"List of frames\" [pwd]/[$topc.f.ent get]\n" " }\n" "pack $topc.f.lab1 -side left\n" "pack $topc.f.lab2 -side left\n" "pack $topc.f.ent -side left\n" "pack $topc.f.but -side left\n" "drawHLine $topc $ypos 1\n" "incr ypos\n" "frame $topc.dffbp -height [expr 3*$line_height] -width $line_width\n" "$topc create window $xpos $ypos -window $topc.dffbp -anchor nw\n" "incr ypos [winfo reqheight $topc.dffbp]\n" "frame $topc.dffbp.d\n" "findInArray CalibrationData Dark\n" "if { $found_val == \"none\" } {set d_subt 0} else {set d_subt 1}\n" "checkbutton $topc.dffbp.d.cbut -text \"Dark subtract -\" -variable d_subt -command { \n" " findInArray CalibrationData Dark\n" " if { $d_subt == 0 } {\n" " set keyarray($found_pos) \"no\"\n" " $disable $topc.dffbp.d.file\n" " } else {\n" " set keyarray($found_pos) \"yes\"\n" " $enable $topc.dffbp.d.file\n" " }\n" " }\n" "blockLabEnt $topc.dffbp.d.file \"Filename\" $std_entry_size CalibrationData Dark\n" "pack $topc.dffbp.d.cbut -side left\n" "pack $topc.dffbp.d.file -side right\n" "if { $d_subt == 0 } {$disable $topc.dffbp.d.file}\n" "pack $topc.dffbp.d -side top -anchor nw -fill x\n" "frame $topc.dffbp.ff\n" "findInArray CalibrationData FlatField\n" "if { $found_val == \"none\" } {set ff_div 0} else {set ff_div 1}\n" "checkbutton $topc.dffbp.ff.cbut -text \"Flat-field divide -\" -variable ff_div -command { \n" " findInArray CalibrationData FlatField\n" " if { $ff_div == 0 } {\n" " set keyarray($found_pos) \"no\"\n" " $disable $topc.dffbp.ff.file\n" " } else {\n" " set keyarray($found_pos) \"yes\"\n" " $enable $topc.dffbp.ff.file\n" " }\n" " }\n" "blockLabEnt $topc.dffbp.ff.file \"Filename\" $std_entry_size CalibrationData FlatField\n" "pack $topc.dffbp.ff.cbut -side left\n" "pack $topc.dffbp.ff.file -side right\n" "if { $ff_div == 0 } {$disable $topc.dffbp.ff.file}\n" "pack $topc.dffbp.ff -side top -anchor nw -fill x\n" "frame $topc.dffbp.bp\n" "findInArray CalibrationData BadPixelMap\n" "if { $found_val == \"none\" } {set bp_rep 0} else {set bp_rep 1}\n" "checkbutton $topc.dffbp.bp.cbut -text \"Bad pixel replace -\" -variable bp_rep -command { \n" " findInArray CalibrationData BadPixelMap\n" " if { $bp_rep == 0 } {\n" " set keyarray($found_pos) \"no\"\n" " $disable $topc.dffbp.bp.file\n" " } else {\n" " set keyarray($found_pos) \"yes\"\n" " $enable $topc.dffbp.bp.file\n" " }\n" " }\n" "blockLabEnt $topc.dffbp.bp.file \"Filename\" $std_entry_size CalibrationData BadPixelMap\n" "pack $topc.dffbp.bp.cbut -side left\n" "pack $topc.dffbp.bp.file -side right\n" "if { $bp_rep == 0 } {$disable $topc.dffbp.bp.file}\n" "pack $topc.dffbp.bp -side top -anchor nw -fill x\n" "drawHLine $topc $ypos 1\n" "incr ypos\n" "frame $topc.se -height [expr 6*$line_height] -width $line_width\n" "$topc create window $xpos $ypos -window $topc.se -anchor nw\n" "incr ypos [winfo reqheight $topc.se]\n" "findInArray SkyEngine EstimateSky\n" "if { $found_val == \"yes\" } {set se1_est 1} else {set se1_est 0}\n" "checkbutton $topc.se.cbut -text \"Activate sky engine\" -variable se1_est -command {\n" " findInArray SkyEngine EstimateSky\n" " if { $se1_est == 0 } {\n" " set keyarray($found_pos) \"no\"\n" " $disable $topc.se.ase\n" " } else {\n" " set keyarray($found_pos) \"yes\"\n" " $enable $topc.se.ase\n" " }\n" " }\n" "pack $topc.se.cbut -side top -anchor nw\n" "frame $topc.se.ase\n" "findInArray SkyEngine OutputDiff\n" "if { $found_val == \"yes\" } {set se4_diff 1} else {set se4_diff 0}\n" "checkbutton $topc.se.ase.out_cbut -text \"Output difference frames\" -variable se4_diff -command {\n" " findInArray SkyEngine OutputDiff\n" " if { $se4_diff == 0 } {\n" " set keyarray($found_pos) \"no\"\n" " } else {\n" " set keyarray($found_pos) \"yes\"\n" " }\n" " }\n" "pack $topc.se.ase.out_cbut -side top -anchor nw -padx $indent\n" "label $topc.se.ase.lab -text \"Sky Combination\"\n" "pack $topc.se.ase.lab -side top -anchor nw\n" "blockLabEnt $topc.se.ase.mnf \"Minimum Number of frames\" $std_entry_size SkyCombine MinNumberOfFrames\n" "pack $topc.se.ase.mnf -side top -anchor nw -fill x -padx $indent -fill x\n" "blockLabEnt $topc.se.ase.rej_hal \"Reject HalfWidth\" $std_entry_size SkyCombine RejectHalfWidth\n" "pack $topc.se.ase.rej_hal -side top -anchor nw -padx $indent -fill x\n" "blockLabEnt $topc.se.ase.rej_min \"Reject Min\" $std_entry_size SkyCombine RejectMin\n" "pack $topc.se.ase.rej_min -side top -anchor nw -padx $indent -fill x\n" "blockLabEnt $topc.se.ase.rej_max \"Reject Max\" $std_entry_size SkyCombine RejectMax\n" "pack $topc.se.ase.rej_max -side top -anchor nw -padx $indent -fill x\n" "label $topc.se.ase.emptylab2 -text \"\"\n" "pack $topc.se.ase.emptylab2 -side top\n" "pack $topc.se.ase -side top -anchor nw -padx $indent\n" "if { $se1_est == 0 } {$disable $topc.se.ase}\n" "drawHLine $topc $ypos 1\n" "incr ypos\n" "frame $topc.saa -height [expr 25*$line_height] -width $line_width\n" "$topc create window $xpos $ypos -window $topc.saa -anchor nw\n" "incr ypos [winfo reqheight $topc.saa]\n" "findInArray ShiftAndAdd Activate\n" "if { $found_val == \"yes\" } {set saa_apply 1} else {set saa_apply 0}\n" "checkbutton $topc.saa.cbut -text \"Activate Shift and Add\" -variable saa_apply -command {\n" " findInArray ShiftAndAdd Activate \n" " if { $saa_apply == 0 } {\n" " set keyarray($found_pos) \"no\"\n" " $disable $topc.saa.asaa \n" " } else {\n" " set keyarray($found_pos) \"yes\"\n" " $enable $topc.saa.asaa\n" " }\n" " }\n" "pack $topc.saa.cbut -side top -anchor nw\n" "frame $topc.saa.asaa\n" "frame $topc.saa.asaa.source\n" "findInArray ShiftAndAdd ObjectSource\n" "set source_type $found_val\n" "label $topc.saa.asaa.lab1 -text \"Cross-correlation object source:\"\n" "pack $topc.saa.asaa.lab1 -side top -anchor nw\n" "radiobutton $topc.saa.asaa.au_rbut -text \"auto\" -variable source_type -value auto -command {\n" " findInArray ShiftAndAdd ObjectSource \n" " set keyarray($found_pos) \"auto\"\n" " $enable $topc.saa.asaa.peak\n" " $disable $topc.saa.asaa.userobj\n" " }\n" "pack $topc.saa.asaa.au_rbut -side top -anchor nw\n" "frame $topc.saa.asaa.peak\n" "label $topc.saa.asaa.peak.lab -text \"Peak detection settings\"\n" "pack $topc.saa.asaa.peak.lab -side top -anchor nw\n" "frame $topc.saa.asaa.peak.detim\n" "findInArray ShiftAndAdd AutoDetectImage\n" "set detect_image $found_val\n" "label $topc.saa.asaa.peak.detim.lab -text \"Detect image\"\n" "radiobutton $topc.saa.asaa.peak.detim.diff_rbut -text diff -variable detect_image -value diff -command {\n" " findInArray ShiftAndAdd AutoDetectImage \n" " set keyarray($found_pos) \"diff\"\n" " }\n" "radiobutton $topc.saa.asaa.peak.detim.first_rbut -text first -variable detect_image -value first -command { \n" " findInArray ShiftAndAdd AutoDetectImage\n" " set keyarray($found_pos) \"first\"\n" " }\n" "pack $topc.saa.asaa.peak.detim.lab -side left\n" "pack $topc.saa.asaa.peak.detim.diff_rbut -side left\n" "pack $topc.saa.asaa.peak.detim.first_rbut -side left\n" "pack $topc.saa.asaa.peak.detim -side top -anchor nw -padx $indent -fill x\n" "blockLabEnt $topc.saa.asaa.peak.thres \"Threshold\" $std_entry_size ShiftAndAdd AutoThreshold\n" "pack $topc.saa.asaa.peak.thres -side top -anchor nw -padx $indent -fill x\n" "blockLabEnt $topc.saa.asaa.peak.mindet \"MinDetectPoints\" $std_entry_size ShiftAndAdd AutoMinPoints\n" "pack $topc.saa.asaa.peak.mindet -side top -anchor nw -padx $indent -fill x\n" "blockLabEnt $topc.saa.asaa.peak.maxdet \"MaxDetectPoints\" $std_entry_size ShiftAndAdd AutoMaxPoints\n" "pack $topc.saa.asaa.peak.maxdet -side top -anchor nw -padx $indent -fill x\n" "frame $topc.saa.asaa.peak.outobj\n" "findInArray ShiftAndAdd AutoOutputObjects\n" "if { $found_val == \"yes\" } {set out_obj 1} else {set out_obj 0}\n" "checkbutton $topc.saa.asaa.peak.outobj.cbut -text \"Output objects\" -variable out_obj -command {\n" " findInArray ShiftAndAdd AutoOutputObjects \n" " if { $out_obj == 0 } {\n" " set keyarray($found_pos) \"no\"\n" " } else {\n" " set keyarray($found_pos) \"yes\"\n" " }\n" " }\n" "pack $topc.saa.asaa.peak.outobj.cbut -side left\n" "pack $topc.saa.asaa.peak.outobj -side top -anchor nw -padx $indent -fill x\n" "if { $source_type != \"auto\" } {$disable $topc.saa.asaa.peak}\n" "pack $topc.saa.asaa.peak -side top -anchor nw -padx $indent\n" "radiobutton $topc.saa.asaa.fi_rbut -text \"file\" -variable source_type -value file -command {\n" " findInArray ShiftAndAdd ObjectSource \n" " set keyarray($found_pos) \"file\"\n" " $enable $topc.saa.asaa.userobj\n" " $disable $topc.saa.asaa.peak\n" " }\n" "pack $topc.saa.asaa.fi_rbut -side top -anchor nw\n" "frame $topc.saa.asaa.userobj\n" "label $topc.saa.asaa.userobj.lab -text \"User objects File Name\"\n" "entry $topc.saa.asaa.userobj.ent -width $std_entry_size\n" "bind $topc.saa.asaa.userobj.ent {\n" " findInArray ShiftAndAdd ObjectFileName \n" " set keyarray($found_pos) [$topc.saa.asaa.userobj.ent get]\n" " }\n" "findInArray ShiftAndAdd ObjectFileName\n" "$topc.saa.asaa.userobj.ent insert 0 $found_val\n" "set ent_sec($topc.saa.asaa.userobj.ent) \"ShiftAndAdd\"\n" "set ent_key($topc.saa.asaa.userobj.ent) \"ObjectFileName\"\n" "button $topc.saa.asaa.userobj.but -text View -command {\n" " roWin \"Input object file\" [pwd]/[$topc.saa.asaa.userobj.ent get]\n" " }\n" "pack $topc.saa.asaa.userobj.lab -side left\n" "pack $topc.saa.asaa.userobj.ent -side left\n" "pack $topc.saa.asaa.userobj.but -side left\n" "if { $source_type != \"file\" } {$disable $topc.saa.asaa.userobj}\n" "pack $topc.saa.asaa.userobj -side top -anchor nw -padx $indent -fill x\n" "findInArray ShiftAndAdd OffsetInput\n" "set input_offset $found_val\n" "label $topc.saa.asaa.emptylab1 -text \"\"\n" "pack $topc.saa.asaa.emptylab1 -side top\n" "label $topc.saa.asaa.lab2 -text \"Cross-correlation offset source:\"\n" "pack $topc.saa.asaa.lab2 -side top -anchor nw\n" "radiobutton $topc.saa.asaa.head_rbut -text \"Header\" -variable input_offset -value header -command {\n" " findInArray ShiftAndAdd OffsetInput\n" " set keyarray($found_pos) \"header\"\n" " $enable $topc.saa.asaa.header\n" " $disable $topc.saa.asaa.file\n" " }\n" "pack $topc.saa.asaa.head_rbut -side top -anchor nw\n" "frame $topc.saa.asaa.header\n" "blockLabEnt $topc.saa.asaa.header.xoff \"X Offset Keyword\" $keyw_ent_size ShiftAndAdd OffsetXKeyword\n" "pack $topc.saa.asaa.header.xoff -side top -anchor nw -fill x\n" "blockLabEnt $topc.saa.asaa.header.yoff \"Y Offset Keyword\" $keyw_ent_size ShiftAndAdd OffsetYKeyword\n" "pack $topc.saa.asaa.header.yoff -side top -anchor nw -fill x\n" "pack $topc.saa.asaa.header -side top -anchor nw -padx $indent\n" "if { $input_offset != \"header\" } {$disable $topc.saa.asaa.header}\n" "radiobutton $topc.saa.asaa.file_rbut -text \"File\" -variable input_offset -value file -command {\n" " findInArray ShiftAndAdd OffsetInput \n" " set keyarray($found_pos) \"file\"\n" " $disable $topc.saa.asaa.header\n" " $enable $topc.saa.asaa.file\n" " }\n" "pack $topc.saa.asaa.file_rbut -side top -anchor nw\n" "frame $topc.saa.asaa.file\n" "frame $topc.saa.asaa.file.input\n" "label $topc.saa.asaa.file.input.lab -text \"Input File Name\"\n" "entry $topc.saa.asaa.file.input.ent -width $std_entry_size\n" "bind $topc.saa.asaa.file.input.ent {\n" " findInArray ShiftAndAdd OffsetInputFile\n" " set keyarray($found_pos) [$topc.saa.asaa.file.input.ent get]\n" " }\n" "findInArray ShiftAndAdd OffsetInputFile\n" "$topc.saa.asaa.file.input.ent insert 0 $found_val\n" "set ent_sec($topc.saa.asaa.file.input.ent) \"ShiftAndAdd\"\n" "set ent_key($topc.saa.asaa.file.input.ent) \"OffsetInputFile\"\n" "button $topc.saa.asaa.file.input.but -text View -command {\n" " roWin \"List of frames\" [pwd]/[$topc.saa.asaa.file.input.ent get]\n" " }\n" "pack $topc.saa.asaa.file.input.lab -side left\n" "pack $topc.saa.asaa.file.input.ent -side left\n" "pack $topc.saa.asaa.file.input.but -side left\n" "pack $topc.saa.asaa.file.input -side top -anchor nw -fill x\n" "pack $topc.saa.asaa.file -side top -anchor nw -padx $indent\n" "if { $input_offset != \"file\" } {$disable $topc.saa.asaa.file}\n" "radiobutton $topc.saa.asaa.auto_rbut -text \"Auto\" -variable input_offset -value auto -command {\n" " findInArray ShiftAndAdd OffsetInput\n" " set keyarray($found_pos) \"auto\"\n" " $disable $topc.saa.asaa.header\n" " $disable $topc.saa.asaa.file\n" " }\n" "pack $topc.saa.asaa.auto_rbut -side top -anchor nw\n" "label $topc.saa.asaa.emptylab2 -text \"\"\n" "pack $topc.saa.asaa.emptylab2 -side top\n" "findInArray ShiftAndAdd OffsetRefine\n" "if { $found_val == \"yes\" } {set refine 1} else {set refine 0}\n" "checkbutton $topc.saa.asaa.cbut -text \"Refine inputs\" -variable refine -command {\n" " findInArray ShiftAndAdd OffsetRefine\n" " if { $refine == 0 } {\n" " set keyarray($found_pos) \"no\"\n" " $disable $topc.saa.asaa.refine\n" " } else {\n" " set keyarray($found_pos) \"yes\"\n" " $enable $topc.saa.asaa.refine\n" " }\n" " }\n" "pack $topc.saa.asaa.cbut -side top -anchor nw\n" "frame $topc.saa.asaa.refine\n" "label $topc.saa.asaa.refine.lab1 -text \"Search box half size\"\n" "pack $topc.saa.asaa.refine.lab1 -side top -anchor nw\n" "blockLabEnt $topc.saa.asaa.refine.width1 \"Width\" $lit_entry_size ShiftAndAdd OffsetSearchSizeX\n" "pack $topc.saa.asaa.refine.width1 -side top -anchor nw -padx $indent -fill x\n" "blockLabEnt $topc.saa.asaa.refine.height1 \"Height\" $lit_entry_size ShiftAndAdd OffsetSearchSizeY\n" "pack $topc.saa.asaa.refine.height1 -side top -anchor nw -padx $indent -fill x\n" "label $topc.saa.asaa.refine.lab2 -text \"Measure box half size\"\n" "pack $topc.saa.asaa.refine.lab2 -side top -anchor nw\n" "blockLabEnt $topc.saa.asaa.refine.width2 \"Width\" $lit_entry_size ShiftAndAdd OffsetMeasureSizeX\n" "pack $topc.saa.asaa.refine.width2 -side top -anchor nw -padx $indent -fill x\n" "blockLabEnt $topc.saa.asaa.refine.height2 \"Height\" $lit_entry_size ShiftAndAdd OffsetMeasureSizeY\n" "pack $topc.saa.asaa.refine.height2 -side top -anchor nw -padx $indent -fill x\n" "pack $topc.saa.asaa.refine -side top -anchor nw -padx $indent\n" "if { $refine == 0 } {$disable $topc.saa.asaa.refine}\n" "findInArray ShiftAndAdd OffsetFileOutput\n" "if { $found_val == \"yes\" } {set o1_offs 1} else {set o1_offs 0}\n" "checkbutton $topc.saa.asaa.out_cbut -text \"Output used offsets to file\" -variable o1_offs -command { \n" " findInArray ShiftAndAdd OffsetFileOutput \n" " if { $o1_offs == 0 } {\n" " set keyarray($found_pos) \"no\"\n" " } else {\n" " set keyarray($found_pos) \"yes\"\n" " }\n" " }\n" "pack $topc.saa.asaa.out_cbut -side top -anchor nw\n" "label $topc.saa.asaa.emptylab3 -text \"\"\n" "pack $topc.saa.asaa.emptylab3 -side top\n" "frame $topc.saa.asaa.frameav\n" "label $topc.saa.asaa.frameav.lab -text \"Frame average\"\n" "pack $topc.saa.asaa.frameav.lab -side top -anchor nw\n" "blockLabEnt $topc.saa.asaa.frameav.min \"Min Reject\" $std_entry_size ShiftAndAdd AverageRejectMin\n" "pack $topc.saa.asaa.frameav.min -side top -anchor nw -fill x\n" "blockLabEnt $topc.saa.asaa.frameav.max \"Max Rejact\" $std_entry_size ShiftAndAdd AverageRejectMax\n" "pack $topc.saa.asaa.frameav.max -side top -anchor nw -fill x\n" "pack $topc.saa.asaa.frameav -side top -anchor nw\n" "pack $topc.saa.asaa -side top -anchor nw -padx $indent\n" "if { $saa_apply == 0 } {$disable $topc.saa.asaa}\n" "drawHLine $topc $ypos 1\n" "incr ypos\n" "frame $topc.post -height [expr 3*$line_height] -width $line_width\n" "$topc create window $xpos $ypos -window $topc.post -anchor nw\n" "incr ypos [winfo reqheight $topc.post]\n" "findInArray PostProcessing Activate\n" "if { $found_val == \"yes\" } {set pp1_post 1} else {set pp1_post 0}\n" "checkbutton $topc.post.cbut -text \"Activate post-processing\" -variable pp1_post -command {\n" " findInArray PostProcessing Activate \n" " if { $pp1_post == 0 } {\n" " set keyarray($found_pos) \"no\"\n" " $disable $topc.post.activ\n" " } else {\n" " set keyarray($found_pos) \"yes\"\n" " $enable $topc.post.activ\n" " }\n" " }\n" "pack $topc.post.cbut -side top -anchor nw\n" "frame $topc.post.activ\n" "findInArray PostProcessing RowSubtractMedian\n" "if { $found_val == \"yes\" } {set pp2_subt 1} else {set pp2_subt 0}\n" "checkbutton $topc.post.activ.cbut -text \"Subtract row medians\" -variable pp2_subt -command {\n" " findInArray PostProcessing RowSubtractMedian\n" " if { $pp2_subt == 0 } {\n" " set keyarray($found_pos) \"no\"\n" " } else {\n" " set keyarray($found_pos) \"yes\"\n" " }\n" " }\n" "pack $topc.post.activ.cbut -side top -anchor nw\n" "frame $topc.post.activ.start\n" "findInArray PostProcessing StartViewer\n" "if { $found_val == \"yes\" } {set pp3_start 1} else {set pp3_start 0}\n" "checkbutton $topc.post.activ.start.cbut -text \"Start viewer -\" -variable pp3_start -command {\n" " findInArray PostProcessing StartViewer\n" " if { $pp3_start == 0 } {\n" " set keyarray($found_pos) \"no\"\n" " $disable $topc.post.activ.start.command\n" " } else {\n" " set keyarray($found_pos) \"yes\"\n" " $enable $topc.post.activ.start.command\n" " }\n" " }\n" "blockLabEnt $topc.post.activ.start.command \"command\" $std_entry_size PostProcessing StartCommand\n" "pack $topc.post.activ.start.cbut -side left\n" "pack $topc.post.activ.start.command -side top -anchor nw\n" "if { $pp3_start == 0 } {$disable $topc.post.activ.start.command}\n" "pack $topc.post.activ.start -side top -anchor nw\n" "pack $topc.post.activ -side top -anchor nw -padx $indent\n" "if { $pp1_post == 0 } {$disable $topc.post.activ}\n" "drawHLine $topc $ypos 1\n" "incr ypos\n" "frame $topc.out -height $line_height -width $line_width\n" "$topc create window $xpos $ypos -window $topc.out -anchor nw\n" "incr ypos [winfo reqheight $topc.out]\n" "blockLabEnt $topc.out.out \"Output file base name\" $std_entry_size Output BaseName\n" "pack $topc.out.out -side top -anchor nw -fill x\n" "$topc config -scrollregion \"0 0 [winfo reqwidth $topc.se] $ypos\" -width [winfo reqwidth $topc.se]\n" "button .launch -text \"Save and launch jitter with this config\" -background grey70 -command {\n" " if { $jitter_install == 0 } { \n" " errorMessage \"Cannot execute jitter\"\n" " return\n" " }\n" " saveFile \n" " wm iconify . \n" " toplevel .waitwin\n" " label .waitwin.t -text \"Jitter is running - please wait ... \"\n" " pack .waitwin.t -side top\n" " tkwait visibility .waitwin.t\n" " exec jitter -f $currentfile >&@ stdout\n" " destroy .waitwin\n" " wm deiconify .\n" " }\n" "pack .launch -side bottom -fill x\n" "modFont fixed .\n" "bindDelEnt .\n" "return}\n" "proc saveFile {} {global keyarray\n" "global currentfile\n" "if { [array size keyarray] == 0 } {errorMessage \"No data to save\"\n" "return}\n" "if { $currentfile == \"No name\" } {errorMessage \"No file name specified\"\n" "return}\n" "updateEntries .\n" "if [catch {open $currentfile w} fileId] {errorMessage \"Cannot open file $currentfile\"} else {set i 0\n" "set j 1\n" "set k 2\n" "set array_size [array size keyarray]\n" "set section $keyarray($i)\n" "puts $fileId \"\\[$section\\]\"\n" "puts $fileId \"$keyarray($j) = $keyarray($k)\"\n" "while {$k<[expr $array_size-3]} {incr i 3\n" "incr j 3\n" "incr k 3\n" "if {$section == $keyarray($i)} {puts $fileId \"$keyarray($j) = $keyarray($k)\"} else {set section $keyarray($i)\n" "puts $fileId \"\\[$section\\]\"\n" "puts $fileId \"$keyarray($j) = $keyarray($k)\"}}\n" "close $fileId}\n" "return}\n" "proc openFile {} {global currentfile\n" "global fileselect\n" "global keyarray\n" "catch { fileSelect }\n" "if {$fileselect(path)==\"\"} return\n" "set currentfile $fileselect(path)\n" "pack .file_selected\n" "file2Array\n" "displayArray\n" "return}\n" "proc newFile {} {global keyarray\n" "global currentfile\n" "global jitter_install\n" "if { $jitter_install == 0 } {errorMessage \"Cannot execute jitter -g\"\n" "return}\n" "catch { exec jitter -g }\n" "set currentfile \"jitter.ini\"\n" "file2Array\n" "pack .file_selected\n" "displayArray\n" "return}\n" "proc saveAsFile {} {global currentfile\n" "global keyarray\n" "global fileselect\n" "global cont\n" "catch { fileSelect \"File entry\" {} 0 }\n" "if {$fileselect(path)==\"\"} return\n" "if {[file exists $fileselect(path)]} {set cnf [toplevel .confirm]\n" "wm title $cnf \"Confirmation\"\n" "frame $cnf.que -width 500 -background white -borderwidth 5 -cursor hand2 -relief ridge\n" "message $cnf.que.msg -width 500 -background black -borderwidth 5 -cursor hand2 -font 9x15bold -foreground white -justify center -relief ridge -text \"Do you want to overwrite the file $fileselect(path)?\"\n" "button $cnf.que.ok -activebackground red -activeforeground black -background blue -borderwidth 5 -command \"set cont 1\" -font 8x13bold -foreground cyan -relief groove -text Yes\n" "button $cnf.que.no -activebackground red -activeforeground black -background blue -borderwidth 5 -command \"set cont 0\" -font 8x13bold -foreground cyan -relief groove -text No\n" "pack $cnf.que -side top -fill x\n" "pack $cnf.que.msg\n" "pack $cnf.que.ok -side left\n" "pack $cnf.que.no -side right\n" "tkwait variable cont\n" "if {$cont} {destroy $cnf} else {destroy $cnf\n" "return}}\n" "if { [array size keyarray] == 0 } {errorMessage \"No data to save\"\n" "return}\n" "set currentfile $fileselect(path)\n" "pack .file_selected\n" "saveFile\n" "return}\n" "proc fileselectResources {} {option add *Fileselect*path.relief sunken startup\n" "option add *Fileselect*path.background white startup\n" "option add *Fileselect*path.foreground black startup\n" "option add *Fileselect*l.text File: startup\n" "option add *Fileselect*ok*text OK startup\n" "option add *Fileselect*ok*underline 0 startup\n" "option add *Fileselect*cancel.text Cancel startup\n" "option add *Fileselect*cancel.underline 0 startup\n" "option add *Fileselect*list.width 20 startup\n" "option add *Fileselect*list.height 10 startup}\n" "proc fileSelect {{why \"File Selection\"} {default {}} {mustExist 1} } {global fileselect\n" "set t [toplevel .fileselect -bd 4 -class Fileselect]\n" "fileselectResources\n" "message $t.msg -aspect 1000 -text $why\n" "pack $t.msg -side top -fill x\n" "set fileselect(dirEnt) [entry $t.dir -width 15 -relief flat -state disabled]\n" "pack $t.dir -side top -fill x\n" "frame $t.top\n" "label $t.top.l -padx 0\n" "set e [entry $t.top.path -textvariable fileselect(path)]\n" "pack $t.top -side top -fill x\n" "pack $t.top.l -side left\n" "pack $t.top.path -side right -fill x -expand true\n" "set lb [listbox $t.list -yscrollcommand [list $t.scroll set]]\n" "scrollbar $t.scroll -command [list $lb yview]\n" "frame $t.buttons -bd 10\n" "frame $t.buttons.ok -bd 2 -relief sunken\n" "set ok [button $t.buttons.ok.b -command fileselectOK]\n" "set can [button $t.buttons.cancel -command fileselectCancel]\n" "pack $t.list -side left -fill both -expand true\n" "pack $t.scroll -side left -fill y\n" "pack $t.buttons -side left -fill both\n" "pack $t.buttons.ok $t.buttons.cancel -side top -padx 10 -pady 5\n" "pack $t.buttons.ok.b -padx 4 -pady 4\n" "fileselectBindings $t $e $lb $ok $can\n" "if {[string length $default] == 0} {set fileselect(path) {}\n" "set dir [pwd]} else {set fileselect(path) [file tail $default]\n" "set dir [file dirname $default]}\n" "set fileselect(dir) {}\n" "set fileselect(done) 0\n" "set fileselect(mustExist) $mustExist\n" "tkwait visibility .fileselect.list\n" "fileselectList $dir\n" "tkwait variable fileselect(done)\n" "destroy $t\n" "return $fileselect(path)}\n" "proc fileselectBindings { t e lb ok can } {foreach w [list $e $lb $ok $can] {bindtags $w [list $t [winfo class $w] $w]}\n" "bind $t fileselectCancel\n" "bind $e fileselectOK\n" "bind $e fileselectComplete\n" "bind $lb \"fileselectTake $%W ; focus $e\"\n" "bind $lb \"fileselectClick %W %y ; focus $e\"\n" "bind $lb \"fileselectTake %W ; fileselectOK\"\n" "bind $lb \"fileselectClick %W %y ; fileselectOK\"\n" "bind $e \"focus $lb ; $lb select set 0\"\n" "bind $lb \"focus $e\"\n" "foreach but [list $ok $can] {set char [string tolower [string index [$but cget -text] [$but cget -underline]]]\n" "bind $t \"focus $but ; break\"}\n" "bind $ok \"focus $can\"\n" "bind $can \"focus $ok\"\n" "focus $e}\n" "proc fileselectList { dir {files {}} } {global fileselect\n" "set e $fileselect(dirEnt)\n" "$e config -state normal\n" "$e delete 0 end\n" "$e insert 0 $dir\n" "$e config -state disabled\n" "$e xview moveto 1\n" ".fileselect.list delete 0 end\n" "set fileselect(dir) $dir\n" "if ![file isdirectory $dir] {.fileselect.list insert 0 \"Bad Directory\"\n" "return}\n" ".fileselect.list insert 0 Listing...\n" "update idletasks\n" ".fileselect.list delete 0\n" "if {[string length $files] == 0} {set err [catch {set files [glob -nocomplain $fileselect(dir)/*]}]\n" ".fileselect.list insert end ../}\n" "set dirs {}\n" "set others {}\n" "foreach f [lsort $files] {if [file isdirectory $f] {lappend dirs [file tail $f]/} else {lappend others [file tail $f]}}\n" "foreach f [concat $dirs $others] {.fileselect.list insert end $f}}\n" "proc fileselectOK {} {global fileselect\n" "if {[regsub {^\\.\\./?} $fileselect(path) {} newpath] != 0} {set fileselect(path) $newpath\n" "set fileselect(dir) [file dirname $fileselect(dir)]\n" "fileselectOK\n" "return}\n" "set path [string trimright $fileselect(dir)/$fileselect(path) /]\n" "if [file isdirectory $path] {set fileselect(path) {}\n" "fileselectList $path\n" "return}\n" "if [file exists $path] {set fileselect(path) $path\n" "set fileselect(done) 1\n" "return}\n" "if [catch {glob $path} files] {if [catch {glob $fileselect(path)} path] {if {$fileselect(mustExist)} {fileselectComplete} elseif [file isdirectory [file dirname $fileselect(path)]] {set fileselect(done) 1}\n" "return} else {set fileselect(dir) [file dirname $fileselect(path)]\n" "set fileselect(path) [file tail $fileselect(path)]\n" "fileselectOK\n" "return}} else {if {[llength [split $files]] == 1} {set fileselect(path) $files\n" "fileselectOK} else {set fileselect(dir) [file dirname [lindex $files 0]]\n" "fileselectList $fileselect(dir) $files}}}\n" "proc fileselectCancel {} {global fileselect\n" "set fileselect(done) 1\n" "set fileselect(path) {}}\n" "proc fileselectClick { lb y } {global fileselect\n" "set fileselect(path) [$lb get [$lb nearest $y]]}\n" "proc fileselectTake { lb } {global fileselect\n" "set fileselect(path) [$lb get [$lb curselection]]}\n" "proc fileselectComplete {} {global fileselect\n" "set fileselect(path) [string trim $fileselect(path) \\t\\ ]\n" "if {[string match /* $fileselect(path)]} {set dir [file dirname $fileselect(path)]\n" "set tail [file tail $fileselect(path)]} elseif [string match ~* $fileselect(path)] {if [catch {file dirname $fileselect(path)} dir] {return}\n" "set tail [file tail $fileselect(path)]} else {set path $fileselect(dir)/$fileselect(path)\n" "set dir [file dirname $path]\n" "set tail [file tail $path]}\n" "set files [glob -nocomplain $dir/$tail*]\n" "if {[llength [split $files]] == 1} {set fileselect(dir) $dir\n" "set fileselect(path) [file tail $files]} else {if {[llength [split $files]] > 1} {set l [expr [string length $tail]-1]\n" "set miss 0\n" "set file1 [file tail [lindex $files 0]]\n" "while {!$miss} {incr l\n" "if {$l == [string length $file1]} {break}\n" "set new [string range $file1 0 $l]\n" "foreach f $files {if ![string match $new* [file tail $f]] {set miss 1\n" "incr l -1\n" "break}}}\n" "set fileselect(path) [string range $file1 0 $l]}\n" "fileselectList $dir $files}}\n" "proc file2Array {} {global keyarray\n" "global currentfile\n" "set i 0\n" "if {[array exists keyarray]} {unset keyarray}\n" "if [catch {open $currentfile r} fileId] {errorMessage \"Cannot open file $currentfile\"} else {set section \"Unknown section\"\n" "while {![eof $fileId]} {gets $fileId curr_line\n" "if {[regsub {^\\[[A-Z][a-zA-Z]*\\]} $curr_line {&} section_line]} {regsub {\\[} $section_line {} section\n" "regsub {\\]} $section {} section}\n" "if {[regsub {^[A-Z][A-Za-z]*} $curr_line {&} keyword_line]} {if {![regsub {=.*} $keyword_line {} keyword]} {errorMessage \"Sign = missing after a keyword in INI file.\"} else {regsub {( )*$} $keyword {} keyword\n" "regsub {;.*} $keyword_line {} value_line\n" "regsub {.*= } $value_line {} value\n" "regsub {( )*$} $value {} value\n" "set keyarray($i) $section\n" "incr i\n" "set keyarray($i) $keyword\n" "incr i\n" "set keyarray($i) $value\n" "incr i}}}\n" "close $fileId\n" "if {[array size keyarray] == 0} {errorMessage \"No INI data in the file $currentfile\"}}\n" "return}\n" "proc ini2Help { inifile helpfile } {if [catch {open $inifile r} fileId] {errorMessage \"Cannot open file $inifile\"} else {if [catch {open $helpfile w} fileId2] {errorMessage \"Cannot open file $helpfile\"} else {while {![eof $fileId]} {gets $fileId curr_line\n" "if {[regsub {^\\#} $curr_line {} help_line]} {puts $fileId2 $help_line}}}\n" "close $fileId\n" "close $fileId2}\n" "return}\n" "proc findInArray { section keyword } {global keyarray\n" "global found_val\n" "global found_pos\n" "set found_val 0\n" "set found_pos 0\n" "set array_size [array size keyarray]\n" "set i 0\n" "set j 1\n" "set k 2\n" "while {$k<$array_size} {if {($keyarray($i) == $section) && ($keyarray($j) == $keyword)} {set found_pos $k\n" "set found_val $keyarray($k)\n" "return}\n" "incr i 3\n" "incr j 3\n" "incr k 3}\n" "if {$section != \"General\"} {errorMessage \"Value of \\[$section\\], $keyword not found in the array\"}\n" "set found_pos -1\n" "set found_val -1\n" "return}\n" "proc updateEntries { widget } {global keyarray\n" "global found_pos\n" "global ent_sec\n" "global ent_key\n" "global topc\n" "set children [winfo children $widget]\n" "foreach x $children {if { ([winfo class $x] == \"Entry\") } {findInArray $ent_sec($x) $ent_key($x)\n" "set keyarray($found_pos) [$x get]} else {updateEntries $x}}\n" "return}\n" "\n"; /*---------------------------------------------------------------------------- Functions ---------------------------------------------------------------------------*/ int jitter_gui() { FILE * wish ; if ((wish=popen("wish", "w"))==NULL) { printf("cannot run wish?\n"); return -1 ; } fprintf(wish, "%s\n", tcl_code); fflush(wish); pclose(wish); return 0 ; }