set ignoreValidation 0
proc fill_table {attTable char_attrib color range attribute numdecimals smooth_transition smooth_button first_colour last_colour load_styles_file default_face default_edge scan_button} {
global ignoreValidation
set macro [ GuidoSSIOption macro ]
if {!$macro} {
if  {[$attribute getCurrentValue] != ""} {
if { $scan_button == "false"} {
loadStyles $attTable $char_attrib $color $range $attribute $load_styles_file $default_face $default_edge
activate_fields $attTable $char_attrib $range $numdecimals $smooth_transition $smooth_button $first_colour $last_colour
} else {
set buffer [GuidoExecServer GetBlockModelAttributeValues [subst {attribute = [$attribute getCurrentValue] numdecimals = "[$numdecimals getCurrentValue]" smooth_transition = "[$smooth_transition getCurrentValue]" first_colour = "[$first_colour getCurrentValue]" last_colour = "[$last_colour getCurrentValue]" scan_button = $scan_button}]]
set num_values [GuidoGetParamBufferValue $buffer num_values]
set attribute_type [GuidoGetParamBufferValue $buffer type]
if {[string compare $attribute_type "double"] == 0} {
$attTable setInteractive false
$attTable setInitialRows 0 0 200
$range setCurrentValue [GuidoGetParamBufferValue $buffer minmax]
if {$num_values > 0} {
fill_labels $attTable $char_attrib $color $range $numdecimals $attribute $smooth_transition $first_colour $last_colour
} else {
$attTable setInitialRows 1 0 200
}
} elseif {[string compare $attribute_type "double"] != 0} {
$range setCurrentValue ""
$range setInputAllowed false
$numdecimals setInputAllowed false
$attTable setInteractive true
$attTable setInitialRows 0 0 200
if {$num_values > 0} {
if {$num_values > 200} {
set num_values 199
GuidoMessage warning BMCOLOUR_MAX_ROWS_ERROR
}
$attTable setInitialRows $num_values 0 200
set attributeList [GuidoGetParamBufferValue $buffer attribute_value]
set colorList [GuidoGetParamBufferValue $buffer color]
set ignoreValidation 1
for {set row_idx 0} {$row_idx < $num_values} {incr row_idx} {
$color setCurrentValue $row_idx "[lindex $colorList [expr $row_idx + 1]]"
$char_attrib setCurrentValue $row_idx "[lindex $attributeList $row_idx]"
$char_attrib setInputAllowed $row_idx true
if {[string compare $attribute_type "integer"] == 0} {
$char_attrib setFormat integer_4
$char_attrib setNullAllowed false
} else {
$char_attrib setFormat string
$char_attrib setNullAllowed true
}
}
set ignoreValidation 0
} else {
$attTable setInitialRows 1 0 200
}
}
}
}
}
}
proc loadStyles {attTable char_attrib color range attribute load_styles_file default_face default_edge} {
if {[$attribute getCurrentValue] != ""} {
set buffer [GuidoExecServer GetBlockModelAttTypes [subst {attribute = [$attribute getCurrentValue] }]]
set attribute_type [GuidoGetParamBufferValue $buffer type]
set buffer [GuidoExecServer GetBlockModelColourStyles [subst {attribute = "[$attribute getCurrentValue]" range = "[$range getCurrentValue]" stylesFile = "[$load_styles_file getCurrentValue]"}]]
set num_values [GuidoGetParamBufferValue $buffer num_values]
if {$num_values > 0} {
set defaultface [GuidoGetParamBufferValue $buffer face_color]
set defaultedge [GuidoGetParamBufferValue $buffer edge_color]
$default_face setCurrentValue $defaultface
$default_edge setCurrentValue $defaultedge
$range setCurrentValue [GuidoGetParamBufferValue $buffer range]
if {[string compare $attribute_type "double"] == 0} {
$attTable setInteractive false
$attTable setInitialRows 0 0 200
$attTable setInitialRows $num_values 0 200
set attributeList [GuidoGetParamBufferValue $buffer attribute_value]
set colorList [GuidoGetParamBufferValue $buffer color]
for {set row_idx 0} {$row_idx < $num_values} {incr row_idx} {
$color setCurrentValue $row_idx "[lindex $colorList [expr $row_idx + 1]]"
$char_attrib setCurrentValue $row_idx "[lindex $attributeList [expr $row_idx + 1]]"
$char_attrib setInputAllowed $row_idx false
}
} elseif {[string compare $attribute_type "double"] != 0} {
$attTable setInteractive true
$attTable setInitialRows 0 0 200
$attTable setInitialRows $num_values 0 200
set attributeList [GuidoGetParamBufferValue $buffer attribute_value]
set colorList [GuidoGetParamBufferValue $buffer color]
for {set row_idx 0} {$row_idx < $num_values} {incr row_idx} {
$color setCurrentValue $row_idx "[lindex $colorList [expr $row_idx + 1]]"
$char_attrib setCurrentValue $row_idx "[lindex $attributeList [expr $row_idx + 1]]"
if {[string compare $attribute_type "integer"] == 0} {
$char_attrib setFormat integer_4
$char_attrib setNullAllowed false
} else {
$char_attrib setFormat string
$char_attrib setNullAllowed true
}
}
}
} else {
$attTable setInitialRows 1 0 200
}
} else {
$attTable setInitialRows 1 0 200
}
}
proc fill_labels {attTable char_attrib color range numdecimals attribute smooth_transition first_colour last_colour} {
set buffer [GuidoExecServer GetBlockModelLegendlabels [subst {attribute = "[$attribute getCurrentValue]" range = "[$range getCurrentValue]" numdecimals = "[$numdecimals getCurrentValue]" smooth_transition = "[$smooth_transition getCurrentValue]" first_colour = "[$first_colour getCurrentValue]" last_colour = "[$last_colour getCurrentValue]"}]]
set num_values [GuidoGetParamBufferValue $buffer num_values]
$attTable setInteractive false
$attTable setInitialRows 0 0 200
if {$num_values > 0} {
$attTable setInitialRows $num_values 0 200
set attributeList [GuidoGetParamBufferValue $buffer attribute_value]
set colorList [GuidoGetParamBufferValue $buffer color]
for {set row_idx 0} {$row_idx < $num_values} {incr row_idx} {
$color setCurrentValue $row_idx "[lindex $colorList [expr $row_idx +1]]"
$char_attrib setCurrentValue $row_idx "[lindex $attributeList $row_idx]"
$char_attrib setInputAllowed $row_idx false
}
} else {
$attTable setInitialRows 1 0 200
}
}
proc smoothColourTransition {attTable color first_colour last_colour} {
if {[$attTable getRowCount] > 0} {
set buffer [GuidoExecServer GetSmoothColourTransition [subst {num_values = "[$attTable getRowCount]" first_colour = "[$first_colour getCurrentValue]" last_colour = "[$last_colour getCurrentValue]"}]]
set colorList [GuidoGetParamBufferValue $buffer color]
for {set row_idx 0} {$row_idx < [$attTable getRowCount]} {incr row_idx} {
$color setCurrentValue $row_idx "[lindex $colorList [expr $row_idx +1]]"
}
}
}
proc check_label {attTable char_attrib} {
global ignoreValidation
set valid 1
if {!$ignoreValidation} {
set usedValues [list]
for {set row_idx 0} {$row_idx < [$attTable getRowCount]} {incr row_idx} {
set value [$char_attrib getCurrentValue $row_idx]
if {$value > ""} {
set valueList [split $value ";"]
for {set index 0 } {$index < [llength $valueList]} {incr index 1} {
set listKey [lindex $valueList $index]
if {[lsearch $usedValues $listKey] == -1} {
lappend usedValues "$listKey"
} else {
GuidoMessage warning BM_LABELS_ERROR $listKey
set valid 0
}
}
}
}
}
return $valid
}
proc activate_fields { attTable char_attrib range numdecimals smooth_transition smooth_button first_colour last_colour} {
global attribute
if {[$attribute getCurrentValue] != ""} {
set buffer [GuidoExecServer GetBlockModelAttTypes [subst {attribute = [$attribute getCurrentValue] }]]
set attribute_type [GuidoGetParamBufferValue $buffer type]
if {[string compare $attribute_type "double"] == 0} {
for {set row_idx 0} {$row_idx < [$attTable getRowCount]} {incr row_idx} {
$char_attrib setInputAllowed $row_idx false
}
$range setInputAllowed true
$range setNullAllowed false
} else {
for {set row_idx 0} {$row_idx < [$attTable getRowCount]} {incr row_idx} {
$char_attrib setInputAllowed $row_idx true
if {[string compare $attribute_type "integer"] == 0} {
$char_attrib setFormat integer_4
$char_attrib setNullAllowed false
} else {
$char_attrib setFormat string
$char_attrib setNullAllowed true
}
}
$range setInputAllowed false
$range setNullAllowed false
$numdecimals setInputAllowed false
$numdecimals setNullAllowed true
}
}
}
proc validate_range { attTable range } {
set valid 1
if {[$range getCurrentValue] != ""} {
set buffer [GuidoExecServer validate_range [subst {range = [$range getCurrentValue]}]]
set return_value [GuidoGetParamBufferValue $buffer return_value]
if {$return_value < 0} {
set valid 0
}
}
return $valid
}
proc validateStylesfile {load_styles_file} {
set valid 1
if {[$load_styles_file getCurrentValue] != ""} {
set buffer [GuidoExecServer validateStylesfile [subst {load_styles_file = [$load_styles_file getCurrentValue]}]]
set return_value [GuidoGetParamBufferValue $buffer return_value]
if {$return_value < 0} {
set valid 0
}
}
return $valid
}
GuidoForm frm20504 {
-default_buttons
-help_id 1633
-label "Block Colours"
-layout BoxLayout X_AXIS
-tip "20504_TIP_001"
-action initial {[fill_table $attribute_list $char_attrib $color $range $attribute $numdecimals $smooth_transition $smooth_button $first_colour $last_colour $load_styles_file $default_face $default_edge "false"]}
GuidoPanel leftPanel {
-layout BoxLayout Y_AXIS
GuidoPanel frm20504_146 {
-layout BoxLayout Y_AXIS
GuidoPanel frm20504_146 {
-layout BoxLayout X_AXIS
-border etched true
GuidoFiller space {
-height 0.5
}
GuidoPanel setupPanel {
-layout CentrelineLayout
GuidoFileBrowserField load_styles_file {
-label "Load styles"
-validation {[validateStylesfile $load_styles_file]}
-display_length 12
-file_mask *.ssi
-default ""
-format none
-max_length FIO_MAX_FILENAME_LENGTH
-tip "For convenience, prefix the filename with SSI_STYLES: to access styles files in the system styles sub-directory"
-file_access write
-translate lower
-start_dir "SSI_STYLES:"
}
GuidoColourBrowserField default_face {
-display_length 12
-exclusive false
-format colour
-label "Default Face"
-max_length 32
-tip "20504_TIP_002"
}
GuidoColourBrowserField default_edge {
-display_length 12
-exclusive false
-label "Default Edge"
-max_length 32
-tip "The default edge colour will be used for all blocks."
}
GuidoBMAttributeBrowser attribute {
-display_length 9.65
-format none
-label "Attribute to colour by"
-max_length BM_MAX_ATT_NAME_LEN
-action valueChanged {[activate_fields $attribute_list $char_attrib $range $numdecimals $smooth_transition $smooth_button $first_colour $last_colour]}
-null true
-tip "The attribute chosen to colour by."
}
GuidoField range {
-display_length 12
-format none
-action valueChanged {[fill_labels $attribute_list $char_attrib $color $range $numdecimals $attribute $smooth_transition $first_colour $last_colour]}
-label "Ranges for colour selection"
-max_length 64
-validation {[validate_range $attribute_list $range]}
-null true
-tip "20504_TIP_005"
-translate lower
}
}
GuidoFiller space {
-width 0.5
}
GuidoPanel scan_panel {
-layout BoxLayout Y_AXIS
GuidoButton reload_button {
-caption "Reload"
-action valueChanged {[loadStyles $attribute_list $char_attrib $color $range $attribute $load_styles_file $default_face $default_edge]}
-tip "20504_TIP_008"
}
GuidoFiller f1 {
-height 2
}
$attribute getCurrentValue
GuidoButton scan_button {
-caption "Scan"
-action valueChanged {[fill_table $attribute_list $char_attrib $color $range $attribute $numdecimals $smooth_transition $smooth_button $first_colour $last_colour $load_styles_file $default_face $default_edge "true"]}
-tip "20504_TIP_008"
}
}
}
}
GuidoPanel transPanel {
-border etched true
-label "Colour Transition"
-layout BoxLayout X_AXIS
GuidoPanel trans2Panel {
-layout CentrelineLayout
GuidoCheckBox smooth_transition {
-selected_value Y
-action valueChanged {[activate_fields $attribute_list $char_attrib $range $numdecimals $smooth_transition $smooth_button $first_colour $last_colour]}
-label "Apply transition when scanning"
-unselected_value N
-tip "20504_TIP_012"
}
GuidoColourBrowserField first_colour {
-display_length 12
-exclusive false
-label "First colour"
-max_length 32
-tip "20504_TIP_009"
}
GuidoColourBrowserField last_colour {
-display_length 12
-exclusive false
-label "Last colour"
-max_length 32
-tip "20504_TIP_010"
}
}
GuidoFiller space {
-width 0.5
}
GuidoPanel hidden {
-layout BoxLayout Y_AXIS
GuidoButton smooth_button {
-caption "Refresh"
-action valueChanged {[smoothColourTransition $attribute_list $color $first_colour $last_colour]}
}
}
}
GuidoPanel styles_panel {
-layout BoxLayout Y_AXIS
GuidoPanel legend_panel {
-layout BoxLayout Y_AXIS
-border etched true
-label Legend
GuidoPanel legend_panel2 {
-layout CentrelineLayout
GuidoField numdecimals {
-display_length 2
-format none
-label "Number of decimal places"
-max_length 2
-null true
-default 2
-low_bound 0
-high_bound 6
-tip BM_NUMDECIMALS_FOR_LEGEND
}
}
}
GuidoPanel p1 {
-layout BoxLayout X_AXIS
-border etched true
-label Transparency
GuidoCheckBox block_model_transparency {
-label "Apply Transparency"
-selected_value Y
-unselected_value N
-tip BM_ENABLE_TRANSPARENCY_TIP
}
GuidoFiller f1 {
-width 2
}
GuidoLabel minLabel {
-label "0%"
}
GuidoSlider transparency_percentage {
-dependency {"[$block_model_transparency getCurrentValue]" == "Y"}
-maximum_width 10.0
-minimum 0.0
-maximum 10.0
-increment 1.0
-major_ticks 50
-minor_ticks 25
-paint_ticks true
-paint_labels false
-tip "Adjust the colour transparency for the block model"
}
GuidoLabel maxLabel {
-label "100%"
}
}
GuidoPanel save_panel {
-layout BoxLayout X_AXIS
GuidoPanel styles_file_panel {
-layout FlowLayout LEFT
GuidoCheckBox save_now {
-default false
-label "Save styles ?"
-selected_value Y
-tip "The styles can be saved to a styles file when the form is applied."
-unselected_value N
-next_focus styles_file
}
}
GuidoPanel styles_panel {
-layout FlowLayout LEFT
-dependency {"[ $save_now getCurrentValue]" == "Y"}
GuidoFileBrowserField styles_file {
-label Filename
-dependency {"[ $save_now getCurrentValue]" == "Y"}
-display_length 15
-file_mask *.ssi
-default $styles_file
-format none
-max_length FIO_MAX_FILENAME_LENGTH
-translate lower
-tip "FRM_20504_1"
-file_access write
-start_dir "SSI_STYLES:"
}
}
}
}
}
GuidoFiller f1 {
-width 0.5
}
GuidoPanel colour_panel {
-layout BoxLayout Y_AXIS
GuidoScrollPane frm20504_144 {
-height 20
-width 30
GuidoTable attribute_list {
-interactive true
GuidoColourBrowserField color {
-display_length 12
-exclusive false
-label Colour
-max_length 32
-tip "20504_TIP_011"
}
GuidoField char_attrib {
-display_length 12
-label "Attribute values"
-action valueChanged {[check_label $attribute_list $char_attrib]}
-max_length 32
-tip "20504_TIP_007"
}
}
}
}
$attribute updateBrowserList
}
