proc validateDepths {depth_from depth_to} {
set dt [$depth_to getCurrentValue]
set df [$depth_from getCurrentValue]
if [catch {
if {[expr $dt - $df] < 0.001} {
GuidoMessage warning DB_DTO_LT_DFROM
return false
}
} result] {
return false
}
return true
}
set databuf [ GuidoExecServer GetComposites {} ]
set status [GuidoGetParamBufferValue $databuf status]
if {$status >= 0} {
set num_composite_rows [GuidoGetParamBufferValue $databuf "num_composite_rows"]
} else {
set num_composite_rows 0
}
proc recalculate_composites {depth_from depth_to composite num_composite_rows hole_id_field} {
set dt [$depth_to getCurrentValue]
set df [$depth_from getCurrentValue]
set hole_id [$hole_id_field getCurrentValue]
if [catch {
if {[expr $dt - $df] < 0.001} {
for {set i 0} {$i < $num_composite_rows} {incr i} {
$composite setCurrentValue $i "-"
}
return
}
} result] {
for {set i 0} {$i < $num_composite_rows} {incr i} {
$composite setCurrentValue $i "-"
}
return
}
set compositedatabuf [ GuidoExecServer CalculateComposite [subst {hole_id = $hole_id depth_from = $df depth_to = $dt}]]
set status [GuidoGetParamBufferValue $compositedatabuf status]
if {$status >= 0} {
for {set i 0} {$i < $num_composite_rows} {incr i} {
$composite setCurrentValue $i [GuidoGetParamBufferValue $compositedatabuf "value($i)"]
}
} else {
for {set i 0} {$i < $num_composite_rows} {incr i} {
$composite setCurrentValue $i "-"
}
}
}
GuidoForm frm_editComposite {
-default_buttons
-defaults_management false
-label "Edit Composite"
-tip DB_COMPOSITE_EDIT_TIP
-layout CentreLineLayout
GuidoPanel main {
-layout CentreLineLayout
GuidoPanel left {
-layout CentreLineLayout
GuidoFiller filler1 {
-height 1
}
GuidoFiller filler2 {
-height 1
}
GuidoLabel hole_id_label {
-label "Hole ID"
}
GuidoLabel hole_id {
-display_length 12
}
GuidoField depth_from {
-label "Depth from"
-display_length 12
-format double
-max_length 20
-null false
-decimals 3
-tip DB_COMPOSITE_EDIT_MIN_TIP
-validation {[validateDepths $depth_from $depth_to]}
-action keyReleased {[
set df [$depth_from getCurrentValue]
set dt [$depth_to getCurrentValue]
if [catch {
$width_field setCurrentValue "[format %.3f [expr $dt - $df]]"
} result] {
$width_field setCurrentValue "0.000"
}
if {$num_composite_rows > 0} {
recalculate_composites $depth_from $depth_to $composite $num_composite_rows $hole_id
}
]}
}
GuidoField depth_to {
-label "Depth to"
-display_length 12
-format double
-max_length 20
-null false
-decimals 3
-tip DB_COMPOSITE_EDIT_MAX_TIP
-validation {[validateDepths $depth_from $depth_to]}
-action keyReleased {[
set df [$depth_from getCurrentValue]
set dt [$depth_to getCurrentValue]
if [catch {
$width_field setCurrentValue "[format %.3f [expr $dt - $df]]"
} result] {
$width_field setCurrentValue "0.000"
}
if {$num_composite_rows > 0} {
recalculate_composites $depth_from $depth_to $composite $num_composite_rows $hole_id
}
]}
}
GuidoLabel width_label {
-label "Width"
}
GuidoLabel width_field {
-display_length 12
}
GuidoField code {
-label "Code"
-display_length 12
-format string
-max_length 20
-null true
-tip DB_COMPOSITE_EDIT_CODE_TIP
}
GuidoFiller filler3 {
-height 1
}
GuidoFiller filler4 {
-height 1
}
}
if {$num_composite_rows > 0} {
GuidoScrollPane composite_values_scroll {
-label "Composite values"
-height 7
-border etched true
GuidoTable composite_values {
-instances 1 1 200
-interactive false
GuidoLabel composite_name {
-label "Name"
-width 10
}
GuidoLabel composite {
-label "Value"
-width 10
}
}
}
}
}
}
