Update of /cvsroot/nsclspectcl/SpecTcl/contrib/calibratedparams In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12485 Modified Files: Tag: SpecTcl-2-2_development CalibrateMainGui.tcl CalibrationPoints.tcl Dialogs.tcl Makefile.am PeakStatistics.tcl Log Message: Finish inspection of the calibration gui (on to testing) Index: Makefile.am =================================================================== RCS file: /cvsroot/nsclspectcl/SpecTcl/contrib/calibratedparams/Makefile.am,v retrieving revision 1.1.2.4 retrieving revision 1.1.2.5 diff -C2 -d -r1.1.2.4 -r1.1.2.5 *** Makefile.am 2 Sep 2004 21:36:24 -0000 1.1.2.4 --- Makefile.am 24 Sep 2004 11:45:31 -0000 1.1.2.5 *************** *** 25,26 **** --- 25,30 ---- CCalibratedParameterCommand.h CCalibratedParameterManager.h + + EXTRA_DIST=CalibIO.tcl CalibIOGUI.tcl CalibrateMainGui.tcl \ + CalibrationPoints.tcl Dialogs.tcl ErrorRead.tcl FitIO.tcl \ + GlobalData.tcl PeakStatistics.tcl TkPrompt.tcl \ No newline at end of file Index: CalibrationPoints.tcl =================================================================== RCS file: /cvsroot/nsclspectcl/SpecTcl/contrib/calibratedparams/Attic/CalibrationPoints.tcl,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -C2 -d -r1.1.2.2 -r1.1.2.3 *** CalibrationPoints.tcl 14 Sep 2004 23:22:12 -0000 1.1.2.2 --- CalibrationPoints.tcl 24 Sep 2004 11:45:31 -0000 1.1.2.3 *************** *** 61,66 **** set Calibrations($point) $point } ! ! foreach point [array names Calibrations] { lappend CalibrationData $point } --- 61,67 ---- set Calibrations($point) $point } ! # Now take each of the points and append it to the final calibration ! # list. ! foreach point [lsort -real [array names Calibrations]] { lappend CalibrationData $point } *************** *** 88,92 **** } else { set fd [open $Path r] ! while {![eof]} { read $fd data if {[scan $data %d point] == 1} { --- 89,93 ---- } else { set fd [open $Path r] ! while {![eof $fd]} { read $fd data if {[scan $data %d point] == 1} { Index: PeakStatistics.tcl =================================================================== RCS file: /cvsroot/nsclspectcl/SpecTcl/contrib/calibratedparams/Attic/PeakStatistics.tcl,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -C2 -d -r1.1.2.2 -r1.1.2.3 *** PeakStatistics.tcl 15 Sep 2004 09:57:35 -0000 1.1.2.2 --- PeakStatistics.tcl 24 Sep 2004 11:45:31 -0000 1.1.2.3 *************** *** 81,87 **** # Throws: # An error if the spectrum is not a 1-d, or does not exist. ! proc ComputeCentroid {Spectrum limits] { # # Unpack the limits (these are in parameter coordinates: --- 81,91 ---- # Throws: # An error if the spectrum is not a 1-d, or does not exist. + # An error if the integration limits don't fit in the spectrum. + # Special cases: + # If there are no counts in the region, the integration returns the + # region midpoint. ! proc ComputeCentroid {Spectrum limits} { # # Unpack the limits (these are in parameter coordinates: *************** *** 99,103 **** } set AxisDefs [lindex $SpectrumInfo 4] ! set XaxisDef [lindex $SpectrumInfo 0];# Really only one. set AxisLow [lindex $XaxisDef 0] set AxisHigh [lindex $XaxisDef 1] --- 103,107 ---- } set AxisDefs [lindex $SpectrumInfo 4] ! set XaxisDef [lindex $XaxisDef 0]; # Really only one. set AxisLow [lindex $XaxisDef 0] set AxisHigh [lindex $XaxisDef 1] *************** *** 105,109 **** set ChannelHi [expr $Channels - 1] ! # Transofrm paramLow -> spectrumLow and paramHigh -> spectrumHigh # The limits of integration in spectrum channel coordinates. # --- 109,113 ---- set ChannelHi [expr $Channels - 1] ! # Transform paramLow -> spectrumLow and paramHigh -> spectrumHigh # The limits of integration in spectrum channel coordinates. # *************** *** 116,119 **** --- 120,136 ---- $paramHigh] + # Coordinates could be backwards: + + if {$spectrumLow > $spectrumHigh} { + set tmp $spectrumLow + set spectrumLow $spectrumHigh + set spectrumHigh $tmp + } + # Ensure the limits are within the spectrum: + + if {($spectrumLow < 0) || ($spectrumHigh > $ChannelHi) } { + error "Integration limits ($spectrumLow, $spectrumHigh) are not both in the spectrum (0, $ChannelHi)." + } + # Now compute the statistics in the spectrum coordinate system *************** *** 126,130 **** } if {$Area != 0.0} { ! set centroid [expr $WeightedSum/Area] } else { set centroid [expr ($spectrumLow + $spectrumHigh)/2.0] --- 143,147 ---- } if {$Area != 0.0} { ! set centroid [expr $WeightedSum/$Area] } else { set centroid [expr ($spectrumLow + $spectrumHigh)/2.0] Index: CalibrateMainGui.tcl =================================================================== RCS file: /cvsroot/nsclspectcl/SpecTcl/contrib/calibratedparams/Attic/CalibrateMainGui.tcl,v retrieving revision 1.1.2.4 retrieving revision 1.1.2.5 diff -C2 -d -r1.1.2.4 -r1.1.2.5 *** CalibrateMainGui.tcl 21 Sep 2004 22:37:53 -0000 1.1.2.4 --- CalibrateMainGui.tcl 24 Sep 2004 11:45:31 -0000 1.1.2.5 *************** *** 16,19 **** --- 16,31 ---- # Calibrate - Does the final calibrated parameter creation. # + package provide CalibrationGUI 1.0 + + + # Get my script directory and read the other files that supply namespace members. + + set FileList {GlobalData.tcl CalibrationPoints.tcl Dialogs.tcl PeakStatistics.tcl} + set me [info script] + set dir [file dirname $me] + foreach File $FileList { + source $dir/$File + } + namespace eval CalibrationGUI { *************** *** 21,24 **** --- 33,38 ---- variable RawParameter + + # CalibrateGUI: # *************** *** 59,63 **** # proc FitSelected {TopLevel ListBox} { ! # Figure out which parameter was selected: --- 73,78 ---- # proc FitSelected {TopLevel ListBox} { ! variable RawParameter ! # Figure out which parameter was selected: *************** *** 103,107 **** return; # Let the user try again or cancel. } ! if {![VliadateTargetName $TargetParameterName]} { return; # Let the user try again or cancel. } --- 118,122 ---- return; # Let the user try again or cancel. } ! if {![ValidateTargetName $TargetParameterName]} { return; # Let the user try again or cancel. } *************** *** 116,120 **** return; # User can try again or cancel. } ! if {[catch "CalibrateParameter $TargetName $RawParameter $Units \ $TargetParameterName" msg] } { tk_dialog .caliberror "Calibration failed" \ --- 131,135 ---- return; # User can try again or cancel. } ! if {[catch "CalibrateParameter $TargetParameterName $RawParameter $Units \ $TargetParameterName" msg] } { tk_dialog .caliberror "Calibration failed" \ *************** *** 294,298 **** while {1} { incr paramno ! if {[catch parameter -list -id $paramno]} { break } --- 309,313 ---- while {1} { incr paramno ! if {[!catch parameter -list -id $paramno]} { break } Index: Dialogs.tcl =================================================================== RCS file: /cvsroot/nsclspectcl/SpecTcl/contrib/calibratedparams/Attic/Dialogs.tcl,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -C2 -d -r1.1.2.2 -r1.1.2.3 *** Dialogs.tcl 20 Sep 2004 22:49:18 -0000 1.1.2.2 --- Dialogs.tcl 24 Sep 2004 11:45:31 -0000 1.1.2.3 *************** *** 151,154 **** --- 151,155 ---- label $topframe.plabel -text "New Parameter Name: " entry $topframe.target + $topframe.target insert end $Parameter_calibrated; # Default target. label $topframe.ulabel -text "Units: " entry $topframe.units *************** *** 167,172 **** if {$NumPoints < 2} { tk_dialog .error "Insufficient points" \ ! "There must be at least slices on the parameter to create a calibrated parameter" \ error 0 Dismiss return } --- 168,174 ---- if {$NumPoints < 2} { tk_dialog .error "Insufficient points" \ ! "There must be at least 2 slices on the parameter to create a calibrated parameter" \ error 0 Dismiss + destroy $top return } *************** *** 174,179 **** # The only thing left for us to do is setup the bottom frame: ! set perform [button $bottomframe.create \ ! -text "Create" \ -command "MarshallCalibrationInfo $topframe \ $middleframe \ --- 176,181 ---- # The only thing left for us to do is setup the bottom frame: ! set perform [button $bottomframe.create \ ! -text "Create" \ -command "MarshallCalibrationInfo $topframe \ $middleframe \ *************** *** 182,185 **** --- 184,190 ---- set cancel [button $bottomframe.cancel -text "Cancel" -command "destroy $top"] + pack $perform $cancel -side left + pack $topframe $middleframe $bottomframe -side top -fill x + return $top } *************** *** 227,231 **** set Units [$TopFrame.units get] if {$TargetName == ""} { ! tk_dialog .guierror "Missing target" \ "You must supply a target parameter name" \ error 0 Dismiss --- 232,236 ---- set Units [$TopFrame.units get] if {$TargetName == ""} { ! tk_dialog .guierror "Missing target" \ "You must supply a target parameter name" \ error 0 Dismiss *************** *** 239,245 **** set used [set useme_$item] if {$used} { ! set raw [$MiddleFrame.frame$item.rawdata$i cget -text] set calibrated "undefined" ! if {[array names CorrespondingPoints $item] = $item} { set calibrated $CorrespondingPoints($item) } --- 244,250 ---- set used [set useme_$item] if {$used} { ! set raw [$MiddleFrame.frame$item.rawdata$item cget -text] set calibrated "undefined" ! if {[array names CorrespondingPoints $item] == $item} { set calibrated $CorrespondingPoints($item) } *************** *** 254,263 **** # Figure out the top level widget: ! set WidgetPath [split $TopFrame "."] ! set TopLevel [lindex $WidgetPath 0] # Now we're ready to call the user callback: ! $UserCallback $TopLevevl $TargetName $Units $CalibrationList } --- 259,269 ---- # Figure out the top level widget: ! set WidgetPath [split $TopFrame "."]; # .a.b.c -> {} a b c ! set TopLevel .[lindex $WidgetPath 1]; # -> .a ! # Now we're ready to call the user callback: ! $UserCallback $TopLevel $TargetName $Units $CalibrationList } *************** *** 292,301 **** set DataPoint 0 foreach slice $SliceList { ! set Descpription [lindex $slice 3];# The slice description. set Low [lindex $Description 1] set Hi [lindex $Description 2] ! if {![catch "PeakStatistics::ComputeCentroid $SpectrumName $Low $Hi]" \ centroid]} { ! set frame [frame $Frame.line$Datapoint] checkbutton $frame.useme -variable useme_$DataPoint \ -title "Use Point" --- 298,308 ---- set DataPoint 0 foreach slice $SliceList { ! set Description [lindex $slice 3];# The slice description. set Low [lindex $Description 1] set Hi [lindex $Description 2] ! set limits "{$Low $Hi}" ! if {![catch "ComputeCentroid $SpectrumName $limits]" \ centroid]} { ! set frame [frame $Frame.frame$Datapoint] checkbutton $frame.useme -variable useme_$DataPoint \ -title "Use Point" *************** *** 403,417 **** # widget path to use for the menubutton. Note that the menu will be # called $menuname.choices ! # variable (string [in]): # Name of the variable to get the value of the menu. # ! proc MakeValueMenu {menuname variable} { variable CalibrationData menubutton $menuname set choices [menu $menuname.choices] foreach datum $CalibrationData { $choices add command -label $datum \ ! -command "set $variable $datum" } } --- 410,425 ---- # widget path to use for the menubutton. Note that the menu will be # called $menuname.choices ! # var (string [in]): # Name of the variable to get the value of the menu. # ! proc MakeValueMenu {menuname var} { variable CalibrationData menubutton $menuname set choices [menu $menuname.choices] + $choices add command -label "" -command "set $var undefined" foreach datum $CalibrationData { $choices add command -label $datum \ ! -command "set $var $datum" } } |