Commit | Line | Data |
---|---|---|
69da6e7a | 1 | # This script is to be executed automatically at DRAWEXE start. |
2 | # | |
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 | |
6 | ||
7 | # indicate that DRAW is interactive environment | |
7fd59977 | 8 | set tcl_interactive 1 |
7fd59977 | 9 | |
69da6e7a | 10 | # define location of standard DRAW scripts; normally it is |
11 | # $CASROOT/src/DrawResources | |
7fd59977 | 12 | set dir "" |
13 | if { [info exists env(DRAWHOME) ] } { | |
14 | set dir $env(DRAWHOME) | |
15 | } else { | |
87c58d4f K |
16 | if { [info exists env(CASROOT) ] } { |
17 | set dir [file join $env(CASROOT) src DrawResources] | |
18 | } else { | |
69da6e7a | 19 | puts "Warning: CASROOT is not defined, some features may not load correctly" |
20 | set dir [file dirname [info script]] | |
87c58d4f | 21 | } |
7fd59977 | 22 | } |
23 | ||
69da6e7a | 24 | # load standard DRAW scripts |
25 | if { [file isdirectory $dir] } { | |
40093367 | 26 | foreach script {StandardCommands.tcl Geometry.tcl StandardViews.tcl TestCommands.tcl} { |
69da6e7a | 27 | if [file exist [file join $dir $script]] { |
28 | source [file join $dir $script] | |
40093367 | 29 | } else { |
30 | puts "Warning: could not find command file $script" | |
69da6e7a | 31 | } |
32 | } | |
87c58d4f | 33 | |
69da6e7a | 34 | # and TK extensions |
87c58d4f K |
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" } { | |
7fd59977 | 40 | wm iconbitmap . -default [file join $dir lamp.ico] |
87c58d4f K |
41 | } |
42 | } | |
40093367 | 43 | } else { |
44 | puts "Warning: could not find DRAW directory" | |
45 | } | |
46 | ||
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 | |
51 | } else { | |
52 | set env(CSF_TestScriptsPath) $env(CSF_TestScriptsPath)[_path_separator]$env(CASROOT)/tests | |
53 | } | |
69da6e7a | 54 | } |
a82a622b | 55 | |
69da6e7a | 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) | |
62 | } | |
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" | |
87c58d4f | 66 | } |
7fd59977 | 67 | } |
69da6e7a | 68 | |
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/. | |
72 | catch {pload FULL} | |
73 | catch {pload -DrawPluginProducts OMF CANONICALRECOGNITION EMESH PARASOLID DXF SAT } | |
74 | catch {pload QAcommands} | |
75 | catch {source $env(CSF_DrawPluginQADefaults)/QARebuildCommands} | |
76 | } | |
77 | ||
b7e76224 | 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} { | |
82 | global env | |
83 | if { $op == "unset" } { | |
84 | if { $var != "" } { | |
85 | dsetenv $var | |
86 | } else { | |
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 | |
93 | } | |
94 | } elseif { $op == "write" } { | |
95 | dsetenv $var $env($var) | |
96 | } elseif { $op == "read" } { | |
97 | return dgetenv $var | |
98 | } | |
99 | } | |
100 | #Execute "trace add ..." block from _update_c_env proc | |
101 | _update_c_env env "" "unset" | |
102 | } | |
103 | ||
69da6e7a | 104 | # silent return from the script |
105 | return |