proc changeCombo { } {
global attAction
global attType
global atts
set rowNum [$atts getEditingRow]
set rowType [$attType getCurrentValue $rowNum]
if {$rowType == "character"} {
$attAction setValues "Mode" "Concatenate"
} elseif {$rowType == "integer"} {
$attAction setValues "Mode" "Integer Mean" "Minimum" "Maximum" "Real Mean" "Sum" "Concatenate"
} elseif {$rowType == "calculated"} {
$attAction setValues "No Action Required"
} else {
$attAction setValues "Mean - negative values as 0" "Mean - negative values included" "Mean - negative values ignored" "Sum"
}
}
proc blockAttributeList { } {
global att
global attType
global atts
global attAction
set buffer [ GuidoExecServer GetAttributeValueList {} ]
set num_atts [ GuidoGetParamBufferValue $buffer attributeNumber ]
if { $num_atts > 0} {
set attributeList [ GuidoGetParamBufferValue $buffer attribute ]
set attributeFormatList [ GuidoGetParamBufferValue $buffer attributeFormat ]
$atts addRows $num_atts
for { set i 0} {$i < $num_atts} {incr i} {
set attFormat [lindex $attributeFormatList $i]
$att setCurrentValue $i [lindex $attributeList $i]
if { [string match "calculated*" $attFormat] } {
$attType setCurrentValue $i "calculated"
$attAction setCurrentValue $i "No Action Required"
} else {
$attType setCurrentValue $i $attFormat
if {$attFormat == "character"} {
$attAction setCurrentValue $i "Mode"
} elseif {$attFormat == "integer"} {
$attAction setCurrentValue $i "Mode"
} else {
$attAction setCurrentValue $i "Mean - negative values as 0"
}
}
}
}
}
proc loadModelValues { } {
global standardSize
global blockSizeList
global x
global y
global z
global xmin
global ymin
global zmin
global dataBuffer
set dataBuffer [ GuidoExecServer GetBlockModelParameters {} ]
set blockSizeList [ GuidoGetParamBufferValue $dataBuffer blockSizes ]
eval [concat {$standardSize} {setValues} $blockSizeList ]
set minBlockSize [ GuidoGetParamBufferValue $dataBuffer MinimumBlock ]
set xmin [lindex $minBlockSize 0]
set ymin [lindex $minBlockSize 1]
set zmin [lindex $minBlockSize 2]
$x removeAllItems
$y removeAllItems
$z removeAllItems
for { set i 1 } { $i < 20 } { incr i } {
$x addItem [expr $xmin * $i]
$y addItem [expr $ymin * $i]
$z addItem [expr $zmin * $i]
}
}
proc validateField { minField minValue } {
global dataBuffer
global newMinSize
set returnCode 1
set minBlockSize [ GuidoGetParamBufferValue $dataBuffer MinimumBlock ]
set minimumValue [lindex $minBlockSize $minValue]
set currValue [$minField getCurrentValue]
if { [expr fmod($currValue, $minimumValue)] > 0.0001 } {
GuidoMessage warning BM_INVALID_BLOCK_SIZE [$minField getLabelText]
set returnCode 0
}
set currSize [$newMinSize getCurrentValue]
if { $currSize == "More..." } {
set returnCode 0
}
return $returnCode
}
proc loadValues { } {
global SGAtt
global attSGAlternative
global dataBuffer
global numLevels
global atts
blockAttributeList
loadModelValues
$SGAtt updateBrowserList
$attSGAlternative updateBrowserList
set MaxRes [ GuidoGetParamBufferValue $dataBuffer MaxRes ]
set UserRes [ GuidoGetParamBufferValue $dataBuffer UserRes ]
set numLevels [expr $UserRes-$MaxRes+2]
set buffer [ GuidoExecServer GetAttributeValueList {} ]
set noOfAttributes [GuidoGetParamBufferValue $buffer attributeNumber]
if {$noOfAttributes > 0} {
$atts setInitialRows $noOfAttributes $noOfAttributes $noOfAttributes
} else {
$atts setInitialRows 1 1 1
}
}
proc levelCallback { } {
global numLevels
global newMinSize
set numLevels 6
resetAdvMinimum
}
proc resetAdvMinimum { } {
global x
global y
global z
global newMinSize
global dataBuffer
global numLevels
global reblock_type
set xcurr [$x getCurrentValue]
set ycurr [$y getCurrentValue]
set zcurr [$z getCurrentValue]
set reblockType [$reblock_type getCurrentValue]
if {$reblockType == "Advanced Reblocking"} {
set tempList {}
for { set i 0 } { $i < $numLevels } {incr i} {
set power [expr pow(2, $i)]
set xmin [expr $xcurr / $power]
set ymin [expr $ycurr / $power]
set zmin [expr $zcurr / $power]
set val "$xmin,$ymin,$zmin"
lappend tempList $val
}
eval [concat {$newMinSize} {setValues} $tempList ]
}
}
proc resetMinimum { } {
global standardSize
global newMinSize
global dataBuffer
global reblock_type
set reblockType [$reblock_type getCurrentValue]
if {$reblockType == "Standard Reblocking"} {
set blockSizeList [ GuidoGetParamBufferValue $dataBuffer blockSizes ]
set tempList $blockSizeList
set listSize [llength $tempList]
set currValue [$standardSize getCurrentValue]
set i 0
for { } {$i < $listSize} {incr i} {
set value [lindex $tempList $i]
if { [string match $value $currValue] } {
incr i
break
}
}
if { $i < $listSize } {
set tempList [lreplace $tempList $i $listSize]
}
eval [concat {$newMinSize} {setValues} $tempList ]
}
}
GuidoForm bmReblockForm {
-action initial {[loadValues]}
-default_buttons
-label "Block Model Reblock"
-layout BoxLayout Y_AXIS
-help_id 1044
-defaults_management false
GuidoPanel newNamePanel {
-layout CentreLineLayout
GuidoFileBrowserField newModelName {
-display_length 32
-file_mask *.mdl
-format none
-max_length "FIO_MAX_FILENAME_LENGTH"
-null false
-translate lower
-tip BM_REBLOCK_NEW_MODEL
-label "Output model name"
-file_access write
}
GuidoScrollPane desc_panel {
-label "Description"
-height 3
GuidoTextArea description {
-linewrap true
-wrap_style_word true
-tip BM_REBLOCK_NEW_DESC
}
}
}
GuidoFiller space {
-height 0.5
}
GuidoPanel type_panel {
-layout CentrelineLayout
GuidoComboBox reblock_type {
-action focusGained {[levelCallback]}
-display_length 12
-format none
-label "Reblocking type"
-max_length 30
-null false
-value_in "Standard Reblocking" "Advanced Reblocking"
-tip BM_REBLOCK_TYPE
}
}
GuidoFiller space {
-height 0.5
}
GuidoPanel resizePanel {
-layout BoxLayout X_AXIS
GuidoLabel userSizeLabel {
-label "New user block size (X, Y, Z)"
}
GuidoFiller space {
-width 2
}
GuidoPanel reblockingPanel {
-layout OverlayLayout
GuidoPanel standard {
-layout CentrelineLayout
-dependency { "[$reblock_type getCurrentValue]" == "Standard Reblocking" }
GuidoComboBox standardSize {
-action valueChanged {[resetMinimum]}
-display_length 10
-max_length 50
-null false
-exclusive true
-tip BM_REBLOCK_USER_BLOCK_STANDARD
}
}
GuidoPanel advanced {
-dependency { "[$reblock_type getCurrentValue]" == "Advanced Reblocking" }
-layout CentrelineLayout
GuidoComboBox x {
-validation {[validateField $x 0]}
-action valueChanged {[resetAdvMinimum]}
-label "X"
-display_length 5
-max_length 10
-null false
-exclusive false
-tip BM_REBLOCK_USER_BLOCK_X
}
GuidoComboBox y {
-validation {[validateField $y 1]}
-action valueChanged {[resetAdvMinimum]}
-label "Y"
-display_length 5
-max_length 10
-null false
-exclusive false
-tip BM_REBLOCK_USER_BLOCK_Y
}
GuidoComboBox z {
-validation {[validateField $z 2]}
-action valueChanged {[resetAdvMinimum]}
-label "Z"
-display_length 5
-max_length 10
-null false
-exclusive false
-tip BM_REBLOCK_USER_BLOCK_Z
}
}
}
}
GuidoFiller space {
-height 0.5
}
GuidoPanel newMinSizePanel {
-layout CentrelineLayout
GuidoComboBox newMinSize {
-label "New minimum block size (Y, X, Z)"
-display_length 10
-max_length 50
-null false
-exclusive true
-tip BM_REBLOCK_MIN_BLOCK
}
GuidoBMAttributeBrowser SGAtt {
-label "SG Attribute (optional) "
-display_length 10
-max_length 50
-null true
-format none
-translate none
-exclusive true
-attribute_types real integer calculated
-tip BM_REBLOCK_VOL_ATT
}
}
GuidoFiller space {
-height 0.5
}
GuidoScrollPane frm20515_11 {
-scroll_size 50 8
GuidoTable atts {
-interactive false
GuidoField att {
-display_length 13
-format none
-label "Attribute Name"
-max_length 30
-null false
-input false
}
GuidoField attType {
-display_length 7
-format none
-label Type
-max_length 64
-translate none
-input false
}
GuidoCheckBox attImport {
-label "Include?"
-default true
-tip BM_REBLOCK_ATT_INCLUDE
}
GuidoComboBox attAction {
-action focusGained {[changeCombo]}
-display_length 15
-format none
-label "Reblocking method"
-max_length 64
-translate none
-exclusive true
-null false
-tip BM_REBLOCK_ATT_METHOD
}
GuidoBMAttributeBrowser attSGAlternative {
-label "SG Attribute"
-display_length 10
-max_length 50
-null true
-format none
-translate none
-exclusive true
-attribute_types real integer calculated
-tip BM_REBLOCK_ALT_ATT
}
}
}
}
GuidoApp check_bm "CHECK BM CONNECTED"
$check_bm setParam functionName "BM REBLOCK"
set result [$check_bm invoke]
$check_bm destroy
if {$result == "0"} {
set formStatus [$bmReblockForm interact]
GuidoApp appHandle "BM REBLOCK"
set reblockType [$reblock_type getCurrentValue]
$appHandle setParam modelName [$newModelName getCurrentValue]
$appHandle setParam modelDesc [$description getCurrentValue]
$appHandle setParam reblockType $reblockType
if { $reblockType == "Standard Reblocking" } {
$appHandle setParam userBlock [$standardSize getCurrentValue]
} else {
$appHandle setParam userBlock(0) [$x getCurrentValue]
$appHandle setParam userBlock(1) [$y getCurrentValue]
$appHandle setParam userBlock(2) [$z getCurrentValue]
}
$appHandle setParam minBlock [$newMinSize getCurrentValue]
$appHandle setParam sgAtt [$SGAtt getCurrentValue]
set numAtts [$atts getInstances]
set includeIndex 0
for { set idx 0 } { $idx < $numAtts } {incr idx} {
if { [$attImport getCurrentValue $idx] } {
$appHandle setParam att($includeIndex) [$att getCurrentValue $idx]
$appHandle setParam attAction($includeIndex) [$attAction getCurrentValue $idx]
$appHandle setParam attSGAlternative($includeIndex) [$attSGAlternative getCurrentValue $idx]
incr includeIndex
}
}
$appHandle setParam numAtts $includeIndex
$bmReblockForm destroy
if {$formStatus == "apply"} {
set appStatus [$appHandle invoke]
}
$appHandle destroy
}
