1 # This script is to be executed automatically at DRAWEXE start.
3 # For that to happen, either environment DRAWDEFAULT should be set pointing
4 # to this file, or CASROOT variable should be set, so that the script is
5 # found as $CASROOT/src/DrawResources/DrawDefault
7 # indicate that DRAW is interactive environment
10 # define location of standard DRAW scripts; normally it is
11 # $CASROOT/src/DrawResources
13 if { [info exists env(DRAWHOME) ] } {
14 set dir $env(DRAWHOME)
16 if { [info exists env(CASROOT) ] } {
17 set dir [file join $env(CASROOT) src DrawResources]
19 puts "Warning: CASROOT is not defined, some features may not load correctly"
20 set dir [file dirname [info script]]
24 # load standard DRAW scripts
25 if { [file isdirectory $dir] } {
26 foreach script {StandardCommands.tcl Geometry.tcl StandardViews.tcl TestCommands.tcl} {
27 if [file exist [file join $dir $script]] {
28 source [file join $dir $script]
30 puts "Warning: could not find command file $script"
35 set stationname $tcl_platform(platform)
36 if [info exists tk_version] {
37 source [file join $dir DrawTK.tcl]
38 # setup the icon for main window
39 if { ${stationname} == "windows" } {
40 wm iconbitmap . -default [file join $dir lamp.ico]
44 puts "Warning: could not find DRAW directory"
47 # set default testing environment
48 if { [info exists env(CASROOT)] && [file isdirectory $env(CASROOT)/tests] } {
49 if { ! [info exists env(CSF_TestScriptsPath)] } {
50 set env(CSF_TestScriptsPath) $env(CASROOT)/tests
52 set env(CSF_TestScriptsPath) $env(CSF_TestScriptsPath)[_path_separator]$env(CASROOT)/tests
56 # load application-defined initialization script, which is expected to
57 # be found either in the file pointed by environment variable CSF_DrawAppliInit,
58 # or in the file DrawAppliInit in the current directory
59 set draw_appli_init_file DrawAppliInit
60 if { [info exists env(CSF_DrawAppliInit)] } {
61 set draw_appli_init_file $env(CSF_DrawAppliInit)
63 if { [file readable $draw_appli_init_file] } {
64 if { [catch {source $draw_appli_init_file} res] } {
65 puts "Warning: problem while loading file $draw_appli_init_file: $res"
69 # Temporary: load specific QA commands and handlers
70 if {[array get env QA_DUMP] != "" && $env(QA_DUMP) == "1"} {
71 set env(CSF_DrawPluginQADefaults) $env(CASROOT)/src/DrawResources/.
73 catch {pload -DrawPluginProducts OMF CANONICALRECOGNITION EMESH PARASOLID DXF SAT }
74 catch {pload QAcommands}
75 catch {source $env(CSF_DrawPluginQADefaults)/QARebuildCommands}
78 # on Windows, set special handler to update automatically environment variables
79 # in C subsystem when Tcl environment changes (see Mantis issue #23197)
80 if { $tcl_platform(platform) == "windows" && ! [catch {dgetenv PATH} res] } {
81 proc _update_c_env {envenv var op} {
83 if { $op == "unset" } {
87 #"array get env varname" command calls _update_c_env with op="unset" and var=""
88 #It leads to detach of trace from env array
89 trace add variable env array _update_c_env
90 trace add variable env read _update_c_env
91 trace add variable env write _update_c_env
92 trace add variable env unset _update_c_env
94 } elseif { $op == "write" } {
95 dsetenv $var $env($var)
96 } elseif { $op == "read" } {
100 #Execute "trace add ..." block from _update_c_env proc
101 _update_c_env env "" "unset"
104 # silent return from the script