#
# Startup Script for VisageCS
#
# TODO set to 0 in final version
limit coredumpsize 999m

# theMsg show
# theMain show

# This function should not be defined. Otherwise amira doesn't report
# errors properly. Tcl will pass them automatically to this function and
# the return value will be thrown away in most cases.
# proc unknown {args} {
#     return "invalid command name \"$args\""
# }

# Load Resource Files
#   1. $AMIRA_ROOT/share/resources/[A-z]*.rc

foreach file [glob -nocomplain \
    ${AMIRA_ROOT}/share/resources/\[A-z\]*.rc \
    ${AMIRA_ROOT}/share/script-objects/*.rc] { source $file 0 }

set hideNewModules 1
load ${AMIRA_ROOT}/data/colormaps/Sky
load ${AMIRA_ROOT}/data/colormaps/Earth
load ${AMIRA_ROOT}/data/colormaps/RedIron
load ${AMIRA_ROOT}/data/colormaps/Ocean
load ${AMIRA_ROOT}/data/colormaps/Temperature
set hideNewModules 0

proc exists { cmd } { llength [ info commands $cmd ] }

# This procedure is always called before a Tcl-script is parsed. It removes
# global variables matching TMPIO*. These variables are used by the LoadCmd
# mechanism when multiple data objects are created from a single file.
proc remove_tmpio { } {
    set var [ info globals ]
    set n [ llength $var ]
    for { set i 0 } { $i<$n } { incr i } {
        if { [ string match TMPIO* [ lindex $var $i ] ] } {
            global [ lindex $var $i ]
            unset [ lindex $var $i ]
        }
    }
}

foreach file [glob -nocomplain \
   ${AMIRA_ROOT}/share/resources/\[A-z\]*.rc2 \
   ${AMIRA_ROOT}/share/scro/*.rc2] { source $file 0 }

set ExamineNoBorder 1
set ExamineConsole 0

if { [catch {create HxExamine Examine} res] } {
    echo "Could not create HxExamine module, check shared libraries!"

    set sessionId 0
    if { [info exists env(EXAMINE_SESSIONID)] } {
        set sessionId $env(EXAMINE_SESSIONID)
    }
    
    set filename "/tmp/STATUS.$sessionId"
    if { [catch {open $filename w} f] } { set f stdout }
    puts $f "error: Could not create HxExamine module, check shared libraries!"
    close $f
    exit
}

Examine setIconPosition 240 10

