GuidoScript forms/SurveyInstrumentCommon.tcl
proc setChart { cht number xvals_r yvals_r } {
upvar $xvals_r xvals
upvar $yvals_r yvals
$cht setVisible true
$cht clearChart
set category "Face left"
for { set i 0} {$i < $number} {incr i} {
set y $yvals($i)
set x $xvals($i)
$cht setCategoryValue $category $x $y
}
$cht drawChart
}
proc setChartDoubleFace { cht number xvals_r yvals_r yvalsFR_r} {
upvar $xvals_r xvals
upvar $yvals_r yvals
upvar $yvalsFR_r yvalsFR
$cht setVisible true
$cht clearChart
set category "Face left"
for { set i 0} {$i < $number} {incr i} {
set y $yvals($i)
set x $xvals($i)
$cht setCategoryValue $category $x $y
}
set category "Face right"
for { set i 0} {$i < $number} {incr i} {
set y $yvalsFR($i)
set x $xvals($i)
$cht setCategoryValue $category $x $y
}
$cht drawChart
}
GuidoApp check_db "CHECK SURVEY DATABASE EXISTS"
set result [$check_db invoke]
$check_db destroy
if {$result == "0"} {
GuidoApp check_station_errors "CHECK STATION ERRORS EXISTS"
$check_station_errors setParam "displayMessages" "false"
set station_errors_exists [$check_station_errors invoke]
$check_station_errors destroy
GuidoApp get_handle "GET DATABASE HANDLE"
$get_handle setParam sessionType "SurveyDatabase"
set result [$get_handle invoke]
set dbHandle [$get_handle getParam DatabaseHandle]
$get_handle destroy
GuidoForm resectionObservations {
-default_buttons
-label "Use existing resection observations file?"
-tip RES_EXISTING_OBS_FILE_TIP
-help_id 1597
GuidoCheckBox useExistingObsFile {
-default false
-label "Use existing resection observations file?"
-selected_value Y
-tip RES_USE_EXISTING_OBS_TIP
-unselected_value N
}
GuidoFileBrowserField obsfile {
-label "Observations file"
-dependency {"[$useExistingObsFile getCurrentValue]" == "Y"}
-display_length 15
-format none
-max_length 256
-null false
-translate lower
-extension false
-file_mask *.mrs
-tip RES_EXISTING_OBS_NAME_TIP
}
}
GuidoForm current_obs {
proc ssiforminitialisedvalue { } {
global ssiforminitialised
return $ssiforminitialised
}
set ssiforminitialised 0
-default_buttons
-label "Resection Observations"
-layout BoxLayout Y_AXIS
-tip RES_MANUAL_RESECTION_TIP
-help_id 1597
GuidoPanel frm_96 {
-border etched true
-label "Options"
-layout BoxLayout Y_AXIS
GuidoPanel frm_100 {
-layout CentreLineLayout
GuidoButtonGroupPanel single_or_double {
-label RES_SINGLE_OR_DOUBLE_FACE_TEXT
GuidoRadioButton singleFace {
-caption RESECTION_SINGLE
-default true
-selected_value single_face
-tip RES_SINGLE_OR_DOUBLE_FACE_TIP
}
GuidoRadioButton doubleFace {
-caption "Double"
-selected_value double_face
-tip RES_SINGLE_OR_DOUBLE_FACE_TIP
}
}
GuidoColumnValueBrowser resection_station {
-display_length 14
-format none
-label "Resection station"
-max_length 16
-translate upper
-exclusive false
-sorted_list true
-database_handle $dbHandle
-table_handle survey_stations
-column_handle station_id
-tip RES_RESECTION_STATION_TIP
}
$resection_station updateBrowserList
GuidoField inst_ht {
-default 0.0
-display_length 5
-format double
-decimals 3
-label "Height"
-max_length 7
-null false
-tip RES_INSTRUMENT_HEIGHT_TIP
}
GuidoFileBrowserField obs_file {
-label "Observations file"
-display_length 15
-format none
-max_length FIO_MAX_FILENAME_LENGTH
-null false
-translate lower
-extension false
-file_mask *.mrs
-file_access write
-tip RES_SAVE_OBSERVATIONS_FILENAME_TIP
}
GuidoFileBrowserField report_file {
-label "Resection report file"
-display_length 15
-format none
-max_length FIO_MAX_FILENAME_LENGTH
-null false
-translate lower
-extension false
-file_mask "*.not *.csv *.htm *.html *.rtf *.pdf *.ps"
-file_access write
-tip RES_REPORT_FILE_TIP
}
GuidoComboBox report_format {
-display_length 21
-format none
-label "Report file format"
-max_length 50
-null false
-value_in ".not - Surpac Note File" ".csv - Comma Separated (Spreadsheet)" ".htm - Hypertext Markup Language (Web)" ".html - Hypertext Markup Language (Web)" ".rtf - Rich Text Format (Microsoft Word)" ".pdf - Adobe Acrobat" ".ps - Postscript"
-tip RES_REPORT_FORMAT_TIP
}
}
}
GuidoFiller f1 {
-height 1
}
GuidoTabbedPane inputs {
GuidoPanel observations_panel {
-layout FlowLayout Left
-font_style bold
-label "Observations"
GuidoScrollPane frm_69 {
-height 20
-width 80
GuidoTable observations {
-instances 1 1 500
-interactive true
GuidoCheckBox include_row {
-default true
-label Include
-selected_value Y
-unselected_value N
-tip RES_INCLUDE_TIP
}
GuidoColumnValueBrowser obs_station {
-display_length 14
-format none
-label "Station"
-max_length 16
-translate upper
-exclusive false
-sorted_list true
-shared_list resection_station
-tip RES_OBSERVATION_STATION_TIP
}
GuidoField target_ht {
-default 0
-display_length 5
-format double
-decimals 3
-label "Target Ht"
-max_length 10
-null false
-tip RES_TARGET_HEIGHT_TIP
}
GuidoField fl_ha_angle {
-decimals 4
-default 0.0
-low_bound 0.0
-high_bound 6.28318530718
-display_length 10
-format dms_angle
-label "FL Hz Angle"
-max_length 12
-null false
-tip RES_FL_HORIZ_ANGLE_TIP
}
GuidoField fl_va_angle {
-decimals 4
-default 0.0
-low_bound 0.0
-high_bound 6.28318530718
-display_length 10
-format dms_angle
-label "FL Vert Angle"
-max_length 12
-null false
-tip RES_FL_VERT_ANGLE_TIP
}
GuidoField fl_dist {
-default 0
-low_bound 0.0
-display_length 10
-format double
-decimals 3
-label "FL Slope Dist"
-max_length 12
-null true
-tip RES_FL_SLOPE_DISTANCE_TIP
}
GuidoField fr_ha_angle {
-dependency {"[$single_or_double getCurrentValue]" == "double_face"}
-decimals 4
-default 0.0
-low_bound 0.0
-high_bound 6.28318530718
-display_length 10
-format dms_angle
-label "FR Hz Angle"
-max_length 12
-null false
-tip RES_FR_HORIZ_ANGLE_TIP
}
GuidoField fr_va_angle {
-dependency {"[$single_or_double getCurrentValue]" == "double_face"}
-decimals 4
-default 0.0
-low_bound 0.0
-high_bound 6.28318530718
-display_length 10
-format dms_angle
-label "FR Vert Angle"
-max_length 12
-null false
-tip RES_FR_VERT_ANGLE_TIP
}
GuidoField fr_dist {
-dependency {"[$single_or_double getCurrentValue]" == "double_face"}
-default 0
-low_bound 0.0
-display_length 10
-format double
-decimals 3
-label "FR Slope Dist"
-max_length 12
-null true
-tip RES_FR_SLOPE_DISTANCE_TIP
}
}
}
}
GuidoPanel accuracies_panel {
-font_style bold
-layout BoxLayout Y_AXIS
-label "Defaults"
GuidoFiller accs_45_1a {
-height 0.5
}
GuidoPanel accuracies_panel {
-layout CentreLineLayout
GuidoComboBox instrument {
-display_length 10
-format none
-max_length 128
-null true
-exclusive false
-label "Instrument type"
-tip INSTRUMENT_TYPE
-action valueChanged {[instrumentChanged $instrument $angle_accuracy $inst_height_accuracy $targ_height_accuracy $dist_accuracy $inst_centring_accuracy $targ_centring_accuracy $dist_parts_per_million]}
}
}
-action initial {[initializeInstrumentList $instrument]}
GuidoFiller accs_45_1a {
-height 0.5
}
GuidoPanel accs_52 {
-border etched true
-label RESECTION_ACCS_TEXT
-layout CentreLineLayout
GuidoPanel accs_49 {
-layout BoxLayout X_AXIS
GuidoPanel accs_51 {
-layout CentreLineLayout
GuidoField dist_accuracy {
-default 0.005
-display_length 5
-format double
-label "Distance standard deviation"
-low_bound 0
-max_length 10
-next_focus dist_parts_per_million
-null false
-tip SRV_RESEC_ACCS_DIST_TIP
-translate upper
-decimals 3
}
GuidoFiller accs_45_4 {
-height 0.5
}
GuidoFiller accs_45_4a {
-height 0.5
}
GuidoField angle_accuracy {
-default 3
-display_length 5
-format double
-label "Angle standard deviation"
-low_bound 0
-max_length 10
-next_focus dist_accuracy
-null false
-tip SRV_RESEC_ACCS_ANGLE_TIP
-translate upper
-decimals 3
}
GuidoFiller accs_45_2 {
-height 0.5
}
GuidoFiller accs_45_a {
-height 0.5
}
GuidoField inst_height_accuracy {
-default 0.003
-display_length 5
-format double
-label "Instrument height sd"
-low_bound 0
-max_length 10
-next_focus inst_centring_accuracy
-null false
-tip SRV_RESEC_ACCS_INST_HT_TIP
-translate upper
-decimals 3
}
GuidoFiller accs_45_2 {
-height 0.5
}
GuidoFiller accs_45_a {
-height 0.5
}
GuidoField targ_height_accuracy {
-default 0.003
-display_length 5
-format double
-label "Target height sd"
-low_bound 0
-max_length 10
-next_focus targ_centring_accuracy
-null false
-tip SRV_RESEC_ACCS_TARG_HT_TIP
-translate upper
-decimals 3
}
}
GuidoFiller accs_45 {
-width 1
}
GuidoPanel accs_53 {
-layout CentreLineLayout
GuidoField dist_parts_per_million {
-default 2
-display_length 5
-format double
-label "Distance error (ppm)"
-low_bound 0
-max_length 10
-next_focus inst_height_accuracy
-null false
-tip SRV_RESEC_ACCS_DIST_PPM_TIP1
-translate upper
-decimals 3
}
GuidoFiller accs_45_6 {
-height 0.5
}
GuidoFiller accs_45_6a {
-height 0.5
}
GuidoField hiddenfield {
-visible false
-label " "
}
GuidoFiller accs_45_6 {
-height 0.5
}
GuidoFiller accs_45_6a {
-height 0.5
}
GuidoField inst_centring_accuracy {
-default 0.003
-display_length 5
-format double
-label "Instrument centring sd"
-low_bound 0
-max_length 10
-next_focus targ_height_accuracy
-null false
-tip SRV_RESEC_ACCS_INST_CENT_TIP
-translate upper
-decimals 3
}
GuidoFiller accs_45_5 {
-height 0.5
}
GuidoFiller accs_45_5a {
-height 0.5
}
GuidoField targ_centring_accuracy {
-default 0.003
-display_length 5
-format double
-label "Target centring sd"
-low_bound 0
-max_length 10
-next_focus port
-null false
-tip SRV_RESEC_ACCS_TARG_CENT_TIP
-translate upper
-decimals 3
}
}
}
}
}
GuidoPanel checks_panel {
-layout FlowLayout Left
-font_style bold
-label "Results check"
GuidoPanel p11 {
-layout Boxlayout Y_AXIS
GuidoScrollPane sp {
-height 20
-width 60
GuidoHTMLPane checks_text {
}
}
GuidoFiller checks_45_7 {
-height 1.0
}
GuidoButton checks {
-caption "Do checks"
-selected_value "checks"
-legacy_button
-width 10
}
}
}
GuidoPanel chartPanel1 {
-font_style bold
-label "Horiz Ang chart"
GuidoChart cht0 {
-width 70
-height 20
-legend true
-chartType "Bar"
-chartTitle "Horizontal Angle Adjustments"
-xAxisLabel "Station"
-yAxisLabel "Adjustment (seconds)"
-simpleChartContextMenu true
}
}
GuidoPanel chartPanel2 {
-font_style bold
-label "Vert Ang chart"
GuidoChart cht1 {
-width 70
-height 20
-legend true
-chartType "Bar"
-chartTitle "Vertical Angle Adjustments"
-xAxisLabel "Station"
-yAxisLabel "Adjustment (seconds)"
-simpleChartContextMenu true
}
}
GuidoPanel chartPanel3 {
-font_style bold
-label "Slope Dist chart"
GuidoChart cht2 {
-width 70
-height 20
-legend true
-chartType "Bar"
-chartTitle "Distance Adjustments"
-xAxisLabel "Station"
-yAxisLabel "Distance adjustment"
-simpleChartContextMenu true
}
}
}
}
set return_code [$resectionObservations interact]
if {$return_code == "apply"} {
set use_existing_file [$useExistingObsFile getCurrentValue]
if {$use_existing_file == "Y"} {
set databuf [ GuidoExecServer GetResectionObservations [subst {textFile = [$obsfile getCurrentValue]}] ]
set file_ok [GuidoGetParamBufferValue $databuf FileOK]
if {$file_ok == "true"} {
$single_or_double setCurrentValue [GuidoGetParamBufferValue $databuf "SingleOrDoubleFace"]
$resection_station setCurrentValue [GuidoGetParamBufferValue $databuf "ResectionStation"]
$inst_ht setCurrentValue [GuidoGetParamBufferValue $databuf "InstHt"]
set num_initial_observations [GuidoGetParamBufferValue $databuf "NumObservations"]
$observations setInitialRows $num_initial_observations 1 500
for {set i 0} {$i < $num_initial_observations} {incr i} {
$include_row setCurrentValue $i [GuidoGetParamBufferValue $databuf "IncludeObs($i)"]
$obs_station setCurrentValue $i [GuidoGetParamBufferValue $databuf "TargStation($i)"]
$target_ht setCurrentValue $i [GuidoGetParamBufferValue $databuf "TargHt($i)"]
$fl_ha_angle setCurrentValue $i [GuidoGetParamBufferValue $databuf "FLHorizAng($i)"]
$fl_va_angle setCurrentValue $i [GuidoGetParamBufferValue $databuf "FLVertAng($i)"]
set distanceFLVal [GuidoGetParamBufferValue $databuf "FLDist($i)"]
if {$distanceFLVal < -0.001} {
$fl_dist setCurrentValue $i ""
} else {
$fl_dist setCurrentValue $i $distanceFLVal
}
$fr_ha_angle setCurrentValue $i [GuidoGetParamBufferValue $databuf "FRHorizAng($i)"]
$fr_va_angle setCurrentValue $i [GuidoGetParamBufferValue $databuf "FRVertAng($i)"]
set distanceFRVal [GuidoGetParamBufferValue $databuf "FRDist($i)"]
if {$distanceFRVal < -0.001} {
$fr_dist setCurrentValue $i ""
} else {
$fr_dist setCurrentValue $i $distanceFRVal
}
}
}
}
if {$use_existing_file == "N" || $file_ok == "true"} {
while {1} {
set return_status "0"
set return_code1 [$current_obs interact]
if {$return_code1 != "cancel"} {
saveInstruments $instrument $angle_accuracy $inst_height_accuracy $targ_height_accuracy $dist_accuracy $inst_centring_accuracy $targ_centring_accuracy $dist_parts_per_million
GuidoApp app "RESECTION"
$app setParam function $return_code1
$app setParam "SingleOrDoubleFace" [$single_or_double getCurrentValue]
$app setParam "ResectionStation" [$resection_station getCurrentValue]
$app setParam "InstHt" [$inst_ht getCurrentValue]
$app setParam "ObsFile" [$obs_file getCurrentValue]
$app setParam "ReportFile" [$report_file getCurrentValue]
$app setParam "FileFormat" [$report_format getCurrentValue]
$app setParam "AngleSD" [$angle_accuracy getCurrentValue]
$app setParam "InstHtSD" [$inst_height_accuracy getCurrentValue]
$app setParam "TargHtSD" [$targ_height_accuracy getCurrentValue]
$app setParam "DistanceSD" [$dist_accuracy getCurrentValue]
$app setParam "InstCentrSD" [$inst_centring_accuracy getCurrentValue]
$app setParam "TargCentrSD" [$targ_centring_accuracy getCurrentValue]
$app setParam "DistancePPM" [$dist_parts_per_million getCurrentValue]
set num_observations [$observations getRowCount]
$app setParam "NumObservations" $num_observations
for {set i 0} {$i < $num_observations} {incr i} {
$app setParam "IncludeObs($i)" [$include_row getCurrentValue $i]
$app setParam "TargStation($i)" [$obs_station getCurrentValue $i]
$app setParam "TargHt($i)" [$target_ht getCurrentValue $i]
$app setParam "FLHorizAng($i)" [$fl_ha_angle getCurrentValue $i]
$app setParam "FLVertAng($i)" [$fl_va_angle getCurrentValue $i]
if {[$fl_dist getCurrentValue $i] == ""} {
$app setParam "FLDist($i)" "-1.0"
} else {
$app setParam "FLDist($i)" [$fl_dist getCurrentValue $i]
}
$app setParam "FRHorizAng($i)" [$fr_ha_angle getCurrentValue $i]
$app setParam "FRVertAng($i)" [$fr_va_angle getCurrentValue $i]
if {[$fr_dist getCurrentValue $i] == ""} {
$app setParam "FRDist($i)" "-1.0"
} else {
$app setParam "FRDist($i)" [$fr_dist getCurrentValue $i]
}
}
set return_status [$app invoke]
if {$return_code1 == "checks" && $return_status == "0"} {
set checkingText [$app getParam "TextForChecks"]
$checks_text setCurrentValue $checkingText
set NoOfStations [$app getParam "NumberOfStations"]
if {"[$single_or_double getCurrentValue]" == "single_face"} {
for {set i 0} {$i < $NoOfStations} {incr i} {
set stationval [$app getParam "StationVal($i)"]
set stations($i) $stationval
set adjval [$app getParam "HaAdj($i)"]
set values($i) $adjval
}
setChart $cht0 $NoOfStations stations values
for {set i 0} {$i < $NoOfStations} {incr i} {
set stationval [$app getParam "StationVal($i)"]
set stations($i) $stationval
set adjval [$app getParam "VaAdj($i)"]
set values($i) $adjval
}
setChart $cht1 $NoOfStations stations values
for {set i 0} {$i < $NoOfStations} {incr i} {
set stationval [$app getParam "StationVal($i)"]
set stations($i) $stationval
set adjval [$app getParam "SDAdj($i)"]
set values($i) $adjval
}
setChart $cht2 $NoOfStations stations values
} else {
for {set i 0} {$i < $NoOfStations} {incr i} {
set stationval [$app getParam "StationVal($i)"]
set stations($i) $stationval
set adjval [$app getParam "HaAdj($i)"]
set values($i) $adjval
set adjvalFR [$app getParam "HaFRAdj($i)"]
set valuesFR($i) $adjvalFR
}
setChartDoubleFace $cht0 $NoOfStations stations values valuesFR
for {set i 0} {$i < $NoOfStations} {incr i} {
set stationval [$app getParam "StationVal($i)"]
set stations($i) $stationval
set adjval [$app getParam "VaAdj($i)"]
set values($i) $adjval
set adjvalFR [$app getParam "VaFRAdj($i)"]
set valuesFR($i) $adjvalFR
}
setChartDoubleFace $cht1 $NoOfStations stations values valuesFR
for {set i 0} {$i < $NoOfStations} {incr i} {
set stationval [$app getParam "StationVal($i)"]
set stations($i) $stationval
set adjval [$app getParam "SDAdj($i)"]
set values($i) $adjval
set adjvalFR [$app getParam "SDFRAdj($i)"]
set valuesFR($i) $adjvalFR
}
setChartDoubleFace $cht2 $NoOfStations stations values valuesFR
}
}
$app destroy
} else {
GuidoExecServer SaveInstrumentParams {}
break
}
if {$return_code1 == "apply" && $return_status != "-2"} {
break
} elseif {$return_code1 == "checks" && $return_status != "0"} {
if {$return_status != "-2"} {
break
} else {
$cht0 setVisible false
$cht1 setVisible false
$cht2 setVisible false
$checks_text setCurrentValue ""
}
}
}
}
$form destroy
}
$resectionObservations destroy
}
