/*---------------------------------------------------------------------------- File name : sw_spjitter_gui.c Author : Y. Jung Created on : June 2001 Description : Graphical user interface for the sw_spjitter ---------------------------------------------------------------------------*/ /* $Id: sw_spjitter_gui.c,v 1.4 2001/09/21 08:16:30 yjung Exp $ $Author: yjung $ $Date: 2001/09/21 08:16:30 $ $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 . \"sw_spjitter.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 { $sw_spjitter_install == 0 } {\n" " errorMessage \"Cannot execute sw_spjitter => no help file\"\n" " return\n" " }\n" " catch {exec isaacp sw_spjitter -g help_gui.ini}\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 sw_spjitter_install\n" "global but_font\n" "set lit_font 8x13\n" "set but_font 8x13bold\n" "set sw_spjitter_install 1\n" "if [catch {set ecl_version [exec isaacp version]} resId] {errorMessage \"Cannot execute isaacp version\"\n" "set sw_spjitter_install 0\n" "set ecl_version \"?\"}\n" "frame .f\n" "label .f.l -text \"Welcome to GUI for the sw_spjitter\"\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 \"$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 classi_source\n" "global wavecal_arc\n" "global pp3_start\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 { $pp3_start == 0 } {greyOut $topc.post.activ.start.command}\n" "if { $classi_source != \"header\" } {greyOut $topc.classi.head.ent}\n" "if { $classi_source != \"file\" } {greyOut $topc.classi.file.ent}\n" "if { $wavecal_arc == 0 } {greyOut $topc.wavecal.group.arc.file}\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 sw_spjitter_install\n" "global children\n" "global cal_arc\n" "global cal_sttr\n" "global cal_flat\n" "global classi_source\n" "global wavecal_sel\n" "global wavecal_arc\n" "global comb_meth\n" "global disto_sel\n" "global autodark\n" "global ext_sel\n" "global apply_filter\n" "global out_diff\n" "global out_aver\n" "global pp1_post\n" "global stat_rep\n" "global plot\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 1*$line_height] -width $line_width\n" "$topc create window $xpos $ypos -window $topc.g -anchor nw\n" "incr ypos [winfo reqheight $topc.g]\n" "findInArray Eclipse Version\n" "label $topc.g.lab -text \"Eclipse version: $found_val\"\n" "pack $topc.g.lab -side top -anchor nw\n" "drawHLine $topc $ypos 1\n" "incr ypos\n" "frame $topc.f -height [expr 3*$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.lab -text \"Frames section\"\n" "pack $topc.f.lab -side top -anchor nw\n" "frame $topc.f.list\n" "label $topc.f.list.lab -text \"Frames list -\"\n" "entry $topc.f.list.ent -width $std_entry_size\n" "bind $topc.f.list.ent {\n" " findInArray InputFileList InputFileList\n" " set keyarray($found_pos) [$topc.f.list.ent get] \n" " }\n" "findInArray InputFileList InputFileList\n" "$topc.f.list.ent insert 0 $found_val\n" "set ent_sec($topc.f.list.ent) \"InputFileList\"\n" "set ent_key($topc.f.list.ent) \"InputFileList\"\n" "button $topc.f.list.but -text View -command {\n" " roWin \"List of frames\" [pwd]/[$topc.f.list.ent get]\n" " }\n" "pack $topc.f.list.lab -side left\n" "pack $topc.f.list.ent -side left\n" "pack $topc.f.list.but -side left\n" "pack $topc.f.list -side top -anchor nw -padx $indent -fill x\n" "drawHLine $topc $ypos 1\n" "incr ypos\n" "frame $topc.calib -height [expr 4*$line_height] -width $line_width\n" "$topc create window $xpos $ypos -window $topc.calib -anchor nw\n" "incr ypos [winfo reqheight $topc.calib]\n" "label $topc.calib.lab -text \"Calibration files\"\n" "pack $topc.calib.lab -side top -anchor nw\n" "frame $topc.calib.arc\n" "findInArray Calibration ArcTable\n" "if { $found_val == \"none\" } {set cal_arc 0} else {set cal_arc 1}\n" "checkbutton $topc.calib.arc.cbut -text \"Arc file -\" -variable cal_arc -command { \n" " findInArray Calibration ArcTable\n" " if { $cal_arc == 0 } {\n" " set keyarray($found_pos) \"no\"\n" " $disable $topc.calib.arc.file\n" " } else {\n" " set keyarray($found_pos) \"yes\"\n" " $enable $topc.calib.arc.file\n" " }\n" " }\n" "blockLabEnt $topc.calib.arc.file \"Filename\" $std_entry_size Calibration ArcTable\n" "pack $topc.calib.arc.cbut -side left\n" "pack $topc.calib.arc.file -side right\n" "if { $cal_arc == 0 } {$disable $topc.calib.arc.file}\n" "pack $topc.calib.arc -side top -anchor nw -fill x -padx $indent\n" "frame $topc.calib.sttr\n" "findInArray Calibration StarTraceTable\n" "if { $found_val == \"none\" } {set cal_sttr 0} else {set cal_sttr 1}\n" "checkbutton $topc.calib.sttr.cbut -text \"Startrace file -\" -variable cal_sttr -command { \n" " findInArray Calibration StarTraceTable \n" " if { $cal_sttr == 0 } {\n" " set keyarray($found_pos) \"no\"\n" " $disable $topc.calib.sttr.file\n" " } else {\n" " set keyarray($found_pos) \"yes\"\n" " $enable $topc.calib.sttr.file\n" " }\n" " }\n" "blockLabEnt $topc.calib.sttr.file \"Filename\" $std_entry_size Calibration StarTraceTable\n" "pack $topc.calib.sttr.cbut -side left\n" "pack $topc.calib.sttr.file -side right\n" "if { $cal_sttr == 0 } {$disable $topc.calib.sttr.file}\n" "pack $topc.calib.sttr -side top -anchor nw -fill x -padx $indent\n" "frame $topc.calib.flat\n" "findInArray Calibration MasterSpFlat\n" "if { $found_val == \"none\" } {set cal_flat 0} else {set cal_flat 1}\n" "checkbutton $topc.calib.flat.cbut -text \"Master flat -\" -variable cal_flat -command { \n" " findInArray Calibration MasterSpFlat\n" " if { $cal_flat == 0 } {\n" " set keyarray($found_pos) \"no\"\n" " $disable $topc.calib.flat.file\n" " } else {\n" " set keyarray($found_pos) \"yes\"\n" " $enable $topc.calib.flat.file\n" " }\n" " }\n" "blockLabEnt $topc.calib.flat.file \"Filename\" $std_entry_size Calibration MasterSpFlat\n" "pack $topc.calib.flat.cbut -side left\n" "pack $topc.calib.flat.file -side right\n" "if { $cal_flat == 0 } {$disable $topc.calib.flat.file}\n" "pack $topc.calib.flat -side top -anchor nw -fill x -padx $indent\n" "drawHLine $topc $ypos 1\n" "incr ypos\n" "frame $topc.classi -height [expr 3*$line_height] -width $line_width\n" "$topc create window $xpos $ypos -window $topc.classi -anchor nw\n" "incr ypos [winfo reqheight $topc.classi]\n" "label $topc.classi.lab -text \"Classification section\"\n" "pack $topc.classi.lab -side top -anchor nw\n" "findInArray Classification Select\n" "set classi_source $found_val\n" "frame $topc.classi.head\n" "radiobutton $topc.classi.head.rbut_head -text \"Header\" -variable classi_source -value header -command {\n" " findInArray Classification Select\n" " set keyarray($found_pos) \"header\"\n" " $enable $topc.classi.head.ent\n" " $disable $topc.classi.file.ent\n" " }\n" "pack $topc.classi.head.rbut_head -side left\n" "blockLabEnt $topc.classi.head.ent \"Offsets keyword\" $std_entry_size Classification OffsetKeyword\n" "pack $topc.classi.head.ent -side right\n" "if { $classi_source != \"header\" } {$disable $topc.classi.head.ent}\n" "pack $topc.classi.head -side top -anchor nw -padx $indent -fill x\n" "frame $topc.classi.file\n" "radiobutton $topc.classi.file.rbut_file -text \"File\" -variable classi_source -value file -command {\n" " findInArray Classification Select\n" " set keyarray($found_pos) \"file\"\n" " $disable $topc.classi.head.ent\n" " $enable $topc.classi.file.ent\n" " }\n" "pack $topc.classi.file.rbut_file -side left\n" "blockLabEnt $topc.classi.file.ent \"Offsets file\" $std_entry_size Classification OffsetFile\n" "pack $topc.classi.file.ent -side right\n" "if { $classi_source != \"file\" } {$disable $topc.classi.file.ent}\n" "pack $topc.classi.file -side top -anchor nw -padx $indent -fill x\n" "drawHLine $topc $ypos 1\n" "incr ypos\n" "frame $topc.wavecal -height [expr 7*$line_height] -width $line_width\n" "$topc create window $xpos $ypos -window $topc.wavecal -anchor nw\n" "incr ypos [winfo reqheight $topc.wavecal]\n" "findInArray WavelengthCalibration Select\n" "if { $found_val == \"yes\" } {set wavecal_sel 1} else {set wavecal_sel 0}\n" "checkbutton $topc.wavecal.cbut -text \"Wavelength calibration\" -variable wavecal_sel -command {\n" " findInArray WavelengthCalibration Select\n" " if { $wavecal_sel == 0 } {\n" " set keyarray($found_pos) \"no\"\n" " $disable $topc.wavecal.group\n" " } else {\n" " set keyarray($found_pos) \"yes\"\n" " $enable $topc.wavecal.group\n" " }\n" " }\n" "pack $topc.wavecal.cbut -side top -anchor nw\n" "frame $topc.wavecal.group\n" "frame $topc.wavecal.group.arc\n" "findInArray WavelengthCalibration WavecalArcFile\n" "if { $found_val == \"none\" } {set wavecal_arc 0} else {set wavecal_arc 1}\n" "checkbutton $topc.wavecal.group.arc.cbut -text \"Arc file -\" -variable wavecal_arc -command { \n" " findInArray WavelengthCalibration WavecalArcFile\n" " if { $wavecal_arc == 0 } {\n" " set keyarray($found_pos) \"no\"\n" " $disable $topc.wavecal.group.arc.file\n" " } else {\n" " set keyarray($found_pos) \"yes\"\n" " $enable $topc.wavecal.group.arc.file\n" " }\n" " }\n" "blockLabEnt $topc.wavecal.group.arc.file \"Filename\" $std_entry_size WavelengthCalibration WavecalArcFile\n" "pack $topc.wavecal.group.arc.cbut -side left\n" "pack $topc.wavecal.group.arc.file -side right\n" "if { $wavecal_arc == 0 } {$disable $topc.wavecal.group.arc.file}\n" "pack $topc.wavecal.group.arc -side top -anchor nw -fill x\n" "blockLabEnt $topc.wavecal.group.dishi \"DiscardHigh\" $lit_entry_size WavelengthCalibration DiscardHigh\n" "pack $topc.wavecal.group.dishi -side top -anchor nw -fill x\n" "blockLabEnt $topc.wavecal.group.dislo \"DiscardLow\" $lit_entry_size WavelengthCalibration DiscardLow\n" "pack $topc.wavecal.group.dislo -side top -anchor nw -fill x\n" "blockLabEnt $topc.wavecal.group.disle \"DiscardLeft\" $lit_entry_size WavelengthCalibration DiscardLeft\n" "pack $topc.wavecal.group.disle -side top -anchor nw -fill x\n" "blockLabEnt $topc.wavecal.group.disri \"DiscardRight\" $lit_entry_size WavelengthCalibration DiscardRight\n" "pack $topc.wavecal.group.disri -side top -anchor nw -fill x\n" "blockLabEnt $topc.wavecal.group.nbcoeff \"Nb coeffs\" $lit_entry_size WavelengthCalibration WavecalNbCoeff\n" "pack $topc.wavecal.group.nbcoeff -side top -anchor nw -fill x\n" "pack $topc.wavecal.group -side top -anchor nw -padx $indent\n" "if { $wavecal_sel == 0 } {$disable $topc.wavecal.group}\n" "drawHLine $topc $ypos 1\n" "incr ypos\n" "frame $topc.comb -height [expr 13*$line_height] -width $line_width\n" "$topc create window $xpos $ypos -window $topc.comb -anchor nw\n" "incr ypos [winfo reqheight $topc.comb]\n" "label $topc.comb.lab -text \"Combination section\"\n" "pack $topc.comb.lab -side top -anchor nw\n" "findInArray Combination CircularShift\n" "if { $found_val == \"no\" } {set circ_shift 0} else {set circ_shift 1}\n" "checkbutton $topc.comb.cshift -text \"Use circular shift\" -variable circ_shift -command {\n" " findInArray Combination CircularShift\n" " if { $circ_shift == 0 } {\n" " set keyarray($found_pos) \"no\"\n" " } else {\n" " set keyarray($found_pos) \"yes\"\n" " }\n" " }\n" "pack $topc.comb.cshift -side top -anchor nw -padx $indent\n" "label $topc.comb.emptylab -text \"\"\n" "pack $topc.comb.emptylab -side top\n" "frame $topc.comb.method\n" "findInArray CombinationMethod Select\n" "set comb_meth $found_val\n" "radiobutton $topc.comb.method.med_rbut -text \"Median\" -variable comb_meth -value \"median\" -command {\n" " findInArray CombinationMethod Select\n" " set keyarray($found_pos) \"median\"\n" " $disable $topc.comb.method.rej\n" " }\n" "pack $topc.comb.method.med_rbut -side top -anchor nw\n" "radiobutton $topc.comb.method.rej_rbut -text \"Rejection\" -variable comb_meth -value \"rejection\" -command {\n" " findInArray CombinationMethod Select\n" " set keyarray($found_pos) \"rejection\"\n" " $enable $topc.comb.method.rej\n" " }\n" "pack $topc.comb.method.rej_rbut -side top -anchor nw\n" "frame $topc.comb.method.rej\n" "blockLabEnt $topc.comb.method.rej.hi \"AverageHiRejection\" $lit_entry_size CombinationMethod AverageHiRejection\n" "pack $topc.comb.method.rej.hi -side top -anchor nw -fill x\n" "blockLabEnt $topc.comb.method.rej.lo \"AverageLoRejection\" $lit_entry_size CombinationMethod AverageLoRejection\n" "pack $topc.comb.method.rej.lo -side top -anchor nw -fill x\n" "pack $topc.comb.method.rej -side top -anchor nw -padx $indent\n" "if { $comb_meth != \"rejection\" } {$disable $topc.comb.method.rej}\n" "radiobutton $topc.comb.method.lin_rbut -text \"Linear\" -variable comb_meth -value \"linear\" -command {\n" " findInArray CombinationMethod Select\n" " set keyarray($found_pos) \"linear\"\n" " $disable $topc.comb.method.rej\n" " }\n" "pack $topc.comb.method.lin_rbut -side top -anchor nw\n" "pack $topc.comb.method -side top -anchor nw -fill x -padx $indent\n" "label $topc.comb.emptylab2 -text \"\"\n" "pack $topc.comb.emptylab2 -side top\n" "frame $topc.comb.disto\n" "findInArray CombinationDistortion Select\n" "if { $found_val == \"yes\" } {set disto_sel 1} else {set disto_sel 0}\n" "checkbutton $topc.comb.disto.cbut -text \"Distortion correction\" -variable disto_sel -command {\n" " findInArray CombinationDistortion Select\n" " if { $disto_sel == 0 } {\n" " set keyarray($found_pos) \"no\"\n" " $disable $topc.comb.disto.group\n" " } else {\n" " set keyarray($found_pos) \"yes\"\n" " $enable $topc.comb.disto.group\n" " }\n" " }\n" "pack $topc.comb.disto.cbut -side top -anchor nw\n" "frame $topc.comb.disto.group\n" "findInArray CombinationDistortion AutoDarkSubtraction\n" "if { $found_val == \"no\" } {set autodark 0} else {set autodark 1}\n" "checkbutton $topc.comb.disto.group.cbut -text \"Auto dark subtraction\" -variable autodark -command {\n" " findInArray CombinationDistortion AutoDarkSubtraction \n" " if { $autodark == 0 } {\n" " set keyarray($found_pos) \"no\"\n" " } else {\n" " set keyarray($found_pos) \"yes\"\n" " }\n" " }\n" "pack $topc.comb.disto.group.cbut -side top -anchor nw -fill x\n" "blockLabEnt $topc.comb.disto.group.xmin \"XMin\" $lit_entry_size CombinationDistortion XMin\n" "pack $topc.comb.disto.group.xmin -side top -anchor nw -fill x\n" "blockLabEnt $topc.comb.disto.group.ymin \"YMin\" $lit_entry_size CombinationDistortion YMin\n" "pack $topc.comb.disto.group.ymin -side top -anchor nw -fill x\n" "blockLabEnt $topc.comb.disto.group.xmax \"XMax\" $lit_entry_size CombinationDistortion XMax\n" "pack $topc.comb.disto.group.xmax -side top -anchor nw -fill x\n" "blockLabEnt $topc.comb.disto.group.ymax \"YMax\" $lit_entry_size CombinationDistortion YMax\n" "pack $topc.comb.disto.group.ymax -side top -anchor nw -fill x\n" "pack $topc.comb.disto.group -side top -anchor nw -padx $indent\n" "if { $disto_sel == 0 } {$disable $topc.comb.disto.group}\n" "pack $topc.comb.disto -side top -anchor nw -fill x -padx $indent\n" "drawHLine $topc $ypos 1\n" "incr ypos\n" "frame $topc.ext -height [expr 11*$line_height] -width $line_width\n" "$topc create window $xpos $ypos -window $topc.ext -anchor nw\n" "incr ypos [winfo reqheight $topc.ext]\n" "findInArray SpectrumExtraction Select\n" "if { $found_val == \"yes\" } {set ext_sel 1} else {set ext_sel 0}\n" "checkbutton $topc.ext.cbut -text \"Extract the spectrum\" -variable ext_sel -command {\n" " findInArray SpectrumExtraction Select\n" " if { $ext_sel == 0 } {\n" " set keyarray($found_pos) \"no\"\n" " $disable $topc.ext.group\n" " } else {\n" " set keyarray($found_pos) \"yes\"\n" " $enable $topc.ext.group\n" " }\n" " }\n" "pack $topc.ext.cbut -side top -anchor nw\n" "frame $topc.ext.group\n" "blockLabEnt $topc.ext.group.specw \"SpectrumWidth\" $lit_entry_size SpectrumExtraction SpectrumWidth\n" "pack $topc.ext.group.specw -side top -anchor nw -fill x\n" "blockLabEnt $topc.ext.group.badtop \"BadTop\" $lit_entry_size SpectrumExtraction BadTop\n" "pack $topc.ext.group.badtop -side top -anchor nw -fill x\n" "blockLabEnt $topc.ext.group.badleft \"BadLeft\" $lit_entry_size SpectrumExtraction BadLeft\n" "pack $topc.ext.group.badleft -side top -anchor nw -fill x\n" "blockLabEnt $topc.ext.group.badright \"BadTop\" $lit_entry_size SpectrumExtraction BadRight\n" "pack $topc.ext.group.badright -side top -anchor nw -fill x\n" "blockLabEnt $topc.ext.group.badbot \"BadBot\" $lit_entry_size SpectrumExtraction BadBot\n" "pack $topc.ext.group.badbot -side top -anchor nw -fill x\n" "blockLabEnt $topc.ext.group.skyhw \"ResSkyHiWidth\" $lit_entry_size SpectrumExtraction ResSkyHiWidth\n" "pack $topc.ext.group.skyhw -side top -anchor nw -fill x\n" "blockLabEnt $topc.ext.group.skyhd \"ResSkyHiDist\" $lit_entry_size SpectrumExtraction ResSkyHiDist\n" "pack $topc.ext.group.skyhd -side top -anchor nw -fill x\n" "blockLabEnt $topc.ext.group.skylw \"ResSkyLoWidth\" $lit_entry_size SpectrumExtraction ResSkyLoWidth\n" "pack $topc.ext.group.skylw -side top -anchor nw -fill x\n" "blockLabEnt $topc.ext.group.skyld \"ResSkyLoDist\" $lit_entry_size SpectrumExtraction ResSkyLoDist\n" "pack $topc.ext.group.skyld -side top -anchor nw -fill x\n" "findInArray SpectrumExtraction ApplyFilter\n" "if { $found_val == \"yes\" } {set apply_filter 1} else {set apply_filter 0}\n" "checkbutton $topc.ext.group.cbut -text \"Apply filter\" -variable apply_filter -command {\n" " findInArray SpectrumExtraction ApplyFilter\n" " if { $apply_filter == 0 } {\n" " set keyarray($found_pos) \"no\"\n" " } else {\n" " set keyarray($found_pos) \"yes\"\n" " } \n" " }\n" "pack $topc.ext.group.cbut -side top -anchor nw\n" "blockLabEnt $topc.ext.group.specpos \"SpectrumPosition\" $lit_entry_size SpectrumExtraction SpectrumPosition\n" "pack $topc.ext.group.specpos -side top -anchor nw -fill x\n" "pack $topc.ext.group -side top -anchor nw -fill x -padx $indent\n" "drawHLine $topc $ypos 1\n" "incr ypos\n" "frame $topc.out -height [expr 4*$line_height] -width $line_width\n" "$topc create window $xpos $ypos -window $topc.out -anchor nw\n" "incr ypos [winfo reqheight $topc.out]\n" "label $topc.out.label -text \"Output section\"\n" "pack $topc.out.label -side top -anchor nw\n" "frame $topc.out.group\n" "blockLabEnt $topc.out.group.outfile \"Output file\" $std_entry_size OutputFile OutputFile\n" "pack $topc.out.group.outfile -side top -anchor nw\n" "findInArray Output OutAveraged\n" "if { $found_val == \"yes\" } {set out_aver 1} else {set out_aver 0}\n" "checkbutton $topc.out.group.av_cbut -text \"Output averaged images\" -variable out_aver -command {\n" " findInArray Output OutAveraged\n" " if { $out_aver == 0 } {\n" " set keyarray($found_pos) \"no\"\n" " } else {\n" " set keyarray($found_pos) \"yes\"\n" " }\n" " }\n" "pack $topc.out.group.av_cbut -side top -anchor nw\n" "findInArray Output OutDifference\n" "if { $found_val == \"yes\" } {set out_diff 1} else {set out_diff 0}\n" "checkbutton $topc.out.group.di_cbut -text \"Output difference images\" -variable out_diff -command {\n" " findInArray Output OutDifference\n" " if { $out_diff == 0 } {\n" " set keyarray($found_pos) \"no\"\n" " } else {\n" " set keyarray($found_pos) \"yes\"\n" " }\n" " }\n" "pack $topc.out.group.di_cbut -side top -anchor nw\n" "pack $topc.out.group -side top -anchor nw -fill x -padx $indent\n" "drawHLine $topc $ypos 1\n" "incr ypos\n" "frame $topc.post -height [expr 4*$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 Select\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 Select \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 ProduceStatusReport\n" "if { $found_val == \"yes\" } {set stat_rep 1} else {set stat_rep 0}\n" "checkbutton $topc.post.activ.rep_cbut -text \"Produce status report\" -variable stat_rep -command {\n" " findInArray PostProcessing ProduceStatusReport \n" " if { $stat_rep == 0 } {\n" " set keyarray($found_pos) \"no\"\n" " } else {\n" " set keyarray($found_pos) \"yes\"\n" " }\n" " }\n" "pack $topc.post.activ.rep_cbut -side top -anchor nw\n" "findInArray PostProcessing PlotSpectrum\n" "if { $found_val == \"yes\" } {set plot 1} else {set plot 0}\n" "checkbutton $topc.post.activ.plot -text \"Plot spectrum\" -variable plot -command {\n" " findInArray PostProcessing PlotSpectrum\n" " if { $plot == 0 } {\n" " set keyarray($found_pos) \"no\"\n" " } else {\n" " set keyarray($found_pos) \"yes\"\n" " }\n" " }\n" "pack $topc.post.activ.plot -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" "$topc config -scrollregion \"0 0 [winfo reqwidth $topc.wavecal] $ypos\" -width [winfo reqwidth $topc.wavecal]\n" "button .launch -text \"Save and launch sw_spjitter with this config\" -background grey70 -command {\n" " if { $sw_spjitter_install == 0 } { \n" " errorMessage \"Cannot execute sw_spjitter\"\n" " return\n" " }\n" " saveFile \n" " wm iconify . \n" " toplevel .waitwin\n" " label .waitwin.t -text \"sw_spjitter is running - please wait ... \"\n" " pack .waitwin.t -side top\n" " tkwait visibility .waitwin.t\n" " findInArray OutputFile OutputFile\n" " set outfile $found_val\n" " findInArray InputFileList InputFileList\n" " exec isaacp sw_spjitter -f $currentfile -o $outfile $found_val >&@ 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 6\n" "set j 7\n" "set k 8\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 sw_spjitter_install\n" "if { $sw_spjitter_install == 0 } {errorMessage \"Cannot execute isaacp sw_spjitter -g spjitter.ini\"\n" "return}\n" "catch { exec isaacp sw_spjitter -g spjitter.ini}\n" "set currentfile \"spjitter.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" "set keyarray($i) \"InputFileList\"\n" "incr i\n" "set keyarray($i) \"InputFileList\"\n" "incr i\n" "set keyarray($i) \"framelist.ascii\"\n" "incr i\n" "set keyarray($i) \"OutputFile\"\n" "incr i\n" "set keyarray($i) \"OutputFile\"\n" "incr i\n" "set keyarray($i) \"spjitter_result\"\n" "incr i\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" "regsub {^( |\\t)*} $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] == 6} {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 sw_spjitter_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 ; }