proc getFormatNames { buffer values_ alt_values_ } {
upvar $values_ values
upvar $alt_values_ alt_values
set numFormats [ GuidoGetParamBufferValue $buffer numReaderPlugins ]
if {$numFormats >= 1} {
set formats [ GuidoGetParamBufferValue $buffer readerPluginNames ]
set displayformats [ GuidoGetParamBufferValue $buffer readerPluginDisplayNames ]
for {set index 0} {$index < $numFormats} {incr index} {
set type [lindex $formats $index]
lappend values $type
set displaytype [lindex $displayformats $index]
lappend alt_values "$displaytype"
}
}
return $numFormats
}
proc getFormats { filename values_ alt_values_ } {
upvar $values_ values
upvar $alt_values_ alt_values
set buffer [ GuidoExecServer getReaderPluginsFriendlyNameForFile [subst { FileName = "$filename" } ] ]
return [getFormatNames $buffer values alt_values]
}
proc getSurpacFormats { values_ alt_values_ } {
upvar $values_ values
upvar $alt_values_ alt_values
set buffer [ GuidoExecServer getReaderPluginsFriendlyName [subst { SurpacOnly = "true" } ] ]
return [getFormatNames $buffer values alt_values]
}
proc locationChanged { initialization } {
global inputType
global location
global styles_file
global {Surpac.IDRange}
if {$initialization == "false"} {
set filenames [$location getCurrentValue]
} else {
set buffer [ GuidoExecServer GetLayerFileName {} ]
set fileName [GuidoGetParamBufferValue $buffer FileName ]
set filenames $fileName
$location setCurrentValue $filenames
}
set commaPos [string first ";" $filenames]
set filename ""
if {$commaPos <= 0} {
set filename $filenames
} else {
incr commaPos -1
set filename [string range $filenames 0 $commaPos]
}
if {$filename != ""} {
set values [list]
set alternate_values [list]
set surpacOnly 0
set stylesfile ""
set numFormats [getFormats $filename values alternate_values]
if {$numFormats == 0} {
getSurpacFormats values alternate_values
set surpacOnly 1
}
if { [string match "*.str" $filename ] == 1 || [string match "*.dtm" $filename ] == 1} {
set buffer [ GuidoExecServer GetStylesFileName [subst { FileName = "$filename" } ] ]
set stylesfile [ GuidoGetParamBufferValue $buffer stylesFile]
}
$styles_file setCurrentValue $stylesfile
eval [concat {$inputType} {setValues} $values ]
eval [concat {$inputType} {setAlternativeValues} $alternate_values ]
if {$surpacOnly == 1} {
$inputType setCurrentValue [lindex $values 1]
${Surpac.IDRange} setInputAllowed true
} else {
${Surpac.IDRange} setInputAllowed false
}
}
}
proc initForm { } {
global swa_name
set buffer [ GuidoExecServer "GetLayerNames" {} ]
set layernames [GuidoGetParamBufferValue $buffer layers]
set layernameslist [split $layernames "\n"]
eval [concat {$swa_name} {setValues} $layernameslist ]
set activeLayer [GuidoGetParamBufferValue $buffer activelayer]
$swa_name setCurrentValue $activeLayer
}
GuidoForm OpenFile {
-help_id 1586
-default_buttons
-label "Open File"
-next_focus location
-layout BoxLayout Y_AXIS
-action initial {[initForm]}
-action initial {[locationChanged true]}
-tip "OPENFILE_FORM_HELP"
GuidoFiller space {
-height 0.5
}
GuidoPanel name {
-layout CentrelineLayout
GuidoComboBox swa_name {
-null false
-display_length 23.5
-exclusive false
-format none
-label Layer
-max_length "APP_MAX_LAYER_NAME_LENGTH"
-tip "00236_TIP_002"
}
GuidoFileBrowserField location {
-display_length 26
-file_mask "str_plugins obj_plugins"
-multiple_selection "true"
-format none
-label Location
-max_length 2048
-translate none
-action valueChanged {[locationChanged false]}
-tip "OPENFILE_LOCATION_TIP"
}
GuidoComboBox inputType {
-label "Load file as"
-display_length 23.5
-format none
-max_length 256
-null false
-tip "OPENFILE_FORMAT_TIP"
}
}
GuidoFiller space {
-height 0.5
}
GuidoPanel pluginOptions {
-border etched true
-label "Options..."
-layout OverlayLayout
GuidoScript scripts/pluginOptionsLoad.tcl
}
GuidoFiller space {
-height 0.5
}
GuidoPanel advanced {
-layout CentreLineLayout
-border etched true
-label "Data loading options"
GuidoFileBrowserField styles_file {
-display_length 16
-file_mask *.ssi
-format none
-label "Drawing styles file"
-max_length 256
-translate none
-start_dir "SSI_STYLES:"
-tip "00236_TIP_006"
}
GuidoCheckBox replace {
-default true
-label "Replace current data"
-tip "OPENFILE_REPLACE_TIP"
}
GuidoCheckBox rescale {
-default true
-label "Rescale display"
-tip "OPENFILE_RESCALE_TIP"
}
}
}
GuidoScript scripts/pluginOptionsLoadBeforeForm.tcl
set return_code [$OpenFile interact]
if {$return_code == "apply"} {
GuidoApp app "OPEN FILE"
$app setParam layer [$swa_name getCurrentValue]
$app setParam location [$location getCurrentValue]
$app setParam plugin [$inputType getCurrentValue]
GuidoScript scripts/pluginOptionsLoadAfterForm.tcl
$app setParam styles [$styles_file getCurrentValue]
$app setParam replace [$replace getCurrentValue]
$app setParam rescale [$rescale getCurrentValue]
set appStatus [$app invoke]
$app destroy
}
