DrawDefault 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. # Copyright (c) 1999-2014 OPEN CASCADE SAS
  2. #
  3. # This file is part of Open CASCADE Technology software library.
  4. #
  5. # This library is free software; you can redistribute it and/or modify it under
  6. # the terms of the GNU Lesser General Public License version 2.1 as published
  7. # by the Free Software Foundation, with special exception defined in the file
  8. # OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
  9. # distribution for complete text of the license and disclaimer of any warranty.
  10. #
  11. # Alternatively, this file may be used under the terms of Open CASCADE
  12. # commercial license or contractual agreement.
  13. # This script is to be executed automatically at DRAWEXE start.
  14. #
  15. # For that to happen, either environment DRAWDEFAULT should be set pointing
  16. # to this file, or CASROOT variable should be set, so that the script is
  17. # found as $CASROOT/src/DrawResources/DrawDefault
  18. # indicate that DRAW is interactive environment
  19. set tcl_interactive 1
  20. # define location of standard DRAW scripts; normally it is
  21. # $CASROOT/src/DrawResources
  22. set dir ""
  23. if { [info exists env(DRAWHOME) ] } {
  24. set dir $env(DRAWHOME)
  25. } else {
  26. if { [info exists env(CASROOT) ] } {
  27. set dir [file join $env(CASROOT) src DrawResources]
  28. } else {
  29. puts "Warning: CASROOT is not defined, some features may not load correctly"
  30. set dir [file dirname [info script]]
  31. }
  32. }
  33. # load standard DRAW scripts
  34. if { [file isdirectory $dir] } {
  35. foreach script {StandardCommands.tcl Geometry.tcl StandardViews.tcl
  36. TestCommands.tcl CheckCommands.tcl Vector.tcl} {
  37. if [file exist [file join $dir $script]] {
  38. source [file join $dir $script]
  39. } else {
  40. puts "Warning: could not find command file $script"
  41. }
  42. }
  43. # and TK extensions
  44. set stationname $tcl_platform(platform)
  45. if [info exists tk_version] {
  46. source [file join $dir DrawTK.tcl]
  47. # setup the icon for main window
  48. if { ${stationname} == "windows" } {
  49. wm iconbitmap . -default [file join $dir lamp.ico]
  50. }
  51. wm title . Draw
  52. }
  53. } else {
  54. puts "Warning: could not find DRAW directory"
  55. }
  56. # set default testing environment (unless already defined before)
  57. if { ! [info exists env(CSF_TestScriptsPath)] } {
  58. if {[info exists ::env(CSF_OCCTTestsPath)] && [file isdirectory $env(CSF_OCCTTestsPath)]} {
  59. set env(CSF_TestScriptsPath) $env(CSF_OCCTTestsPath)
  60. } elseif { [info exists env(CASROOT)] && [file isdirectory $env(CASROOT)/tests] } {
  61. set env(CSF_TestScriptsPath) $env(CASROOT)/tests
  62. }
  63. }
  64. if {[info exists ::env(CSF_OCCTDataPath)] && [file isdirectory $env(CSF_OCCTDataPath)]} {
  65. if { ! [info exists env(CSF_TestDataPath)] } {
  66. set env(CSF_TestDataPath) $env(CSF_OCCTDataPath)
  67. } else {
  68. set env(CSF_TestDataPath) $env(CSF_TestDataPath)[_path_separator]$env(CSF_OCCTDataPath)
  69. }
  70. } elseif { [info exists env(CASROOT)] && [file isdirectory $env(CASROOT)/tests] } {
  71. if { ! [info exists env(CSF_TestDataPath)] } {
  72. set env(CSF_TestDataPath) $env(CASROOT)/data
  73. } else {
  74. set env(CSF_TestDataPath) $env(CSF_TestDataPath)[_path_separator]$env(CASROOT)/data
  75. }
  76. }
  77. # load application-defined initialization script, which is expected to
  78. # be found either in the file pointed by environment variable CSF_DrawAppliInit,
  79. # or in the file DrawAppliInit in the current directory
  80. set draw_appli_init_file DrawAppliInit
  81. if { [info exists env(CSF_DrawAppliInit)] } {
  82. set draw_appli_init_file $env(CSF_DrawAppliInit)
  83. }
  84. if { [file readable $draw_appli_init_file] } {
  85. if { [catch {source $draw_appli_init_file} res] } {
  86. puts "Warning: problem while loading file $draw_appli_init_file: $res"
  87. }
  88. }
  89. # on Windows, set special handler to update automatically environment variables
  90. # in C subsystem when Tcl environment changes (see Mantis issue #23197)
  91. if { $tcl_platform(platform) == "windows" && ! [catch {dgetenv PATH}] } {
  92. proc _update_c_env {envenv var op} {
  93. global env
  94. if { $op == "unset" } {
  95. if { $var != "" } {
  96. dsetenv $var
  97. } else {
  98. #"array get env varname" command calls _update_c_env with op="unset" and var=""
  99. #It leads to detach of trace from env array
  100. trace add variable env array _update_c_env
  101. trace add variable env read _update_c_env
  102. trace add variable env write _update_c_env
  103. trace add variable env unset _update_c_env
  104. }
  105. } elseif { $op == "write" } {
  106. dsetenv $var $env($var)
  107. } elseif { $op == "read" } {
  108. return dgetenv $var
  109. }
  110. }
  111. #Execute "trace add ..." block from _update_c_env proc
  112. _update_c_env env "" "unset"
  113. }
  114. # arm signal handler with default FPE setting
  115. dsetsignal
  116. # silent return from the script
  117. return