0030575: Tests - v3d/materials unstable image screenshots of alpha-blending on GeForc...
[occt.git] / src / DrawResources / DrawDefault
CommitLineData
d5f74e42 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
69da6e7a 14# This script is to be executed automatically at DRAWEXE start.
15#
16# For that to happen, either environment DRAWDEFAULT should be set pointing
17# to this file, or CASROOT variable should be set, so that the script is
18# found as $CASROOT/src/DrawResources/DrawDefault
19
20# indicate that DRAW is interactive environment
7fd59977 21set tcl_interactive 1
7fd59977 22
69da6e7a 23# define location of standard DRAW scripts; normally it is
24# $CASROOT/src/DrawResources
7fd59977 25set dir ""
26if { [info exists env(DRAWHOME) ] } {
27 set dir $env(DRAWHOME)
28} else {
87c58d4f
K
29 if { [info exists env(CASROOT) ] } {
30 set dir [file join $env(CASROOT) src DrawResources]
31 } else {
69da6e7a 32 puts "Warning: CASROOT is not defined, some features may not load correctly"
33 set dir [file dirname [info script]]
87c58d4f 34 }
7fd59977 35}
36
69da6e7a 37# load standard DRAW scripts
38if { [file isdirectory $dir] } {
472634fa 39 foreach script {StandardCommands.tcl Geometry.tcl StandardViews.tcl
40 TestCommands.tcl CheckCommands.tcl Vector.tcl} {
69da6e7a 41 if [file exist [file join $dir $script]] {
42 source [file join $dir $script]
40093367 43 } else {
44 puts "Warning: could not find command file $script"
69da6e7a 45 }
46 }
87c58d4f 47
69da6e7a 48 # and TK extensions
87c58d4f
K
49 set stationname $tcl_platform(platform)
50 if [info exists tk_version] {
51 source [file join $dir DrawTK.tcl]
52 # setup the icon for main window
53 if { ${stationname} == "windows" } {
7fd59977 54 wm iconbitmap . -default [file join $dir lamp.ico]
87c58d4f 55 }
262bf46d 56 wm title . Draw
87c58d4f 57 }
40093367 58} else {
59 puts "Warning: could not find DRAW directory"
60}
61
2fa4d230 62# set default testing environment (unless already defined before)
63if { ! [info exists env(CSF_TestScriptsPath)] } {
64 if {[info exists ::env(CSF_OCCTTestsPath)] && [file isdirectory $env(CSF_OCCTTestsPath)]} {
4b3541c6 65 set env(CSF_TestScriptsPath) $env(CSF_OCCTTestsPath)
2fa4d230 66 } elseif { [info exists env(CASROOT)] && [file isdirectory $env(CASROOT)/tests] } {
4b3541c6 67 set env(CSF_TestScriptsPath) $env(CASROOT)/tests
4b3541c6 68 }
69}
70if {[info exists ::env(CSF_OCCTDataPath)] && [file isdirectory $env(CSF_OCCTDataPath)]} {
71 if { ! [info exists env(CSF_TestDataPath)] } {
72 set env(CSF_TestDataPath) $env(CSF_OCCTDataPath)
096ef695 73 } else {
4b3541c6 74 set env(CSF_TestDataPath) $env(CSF_TestDataPath)[_path_separator]$env(CSF_OCCTDataPath)
096ef695 75 }
4b3541c6 76} elseif { [info exists env(CASROOT)] && [file isdirectory $env(CASROOT)/tests] } {
096ef695 77 if { ! [info exists env(CSF_TestDataPath)] } {
4b3541c6 78 set env(CSF_TestDataPath) $env(CASROOT)/data
096ef695 79 } else {
4b3541c6 80 set env(CSF_TestDataPath) $env(CSF_TestDataPath)[_path_separator]$env(CASROOT)/data
096ef695 81 }
69da6e7a 82}
a82a622b 83
69da6e7a 84# load application-defined initialization script, which is expected to
85# be found either in the file pointed by environment variable CSF_DrawAppliInit,
86# or in the file DrawAppliInit in the current directory
87set draw_appli_init_file DrawAppliInit
88if { [info exists env(CSF_DrawAppliInit)] } {
89 set draw_appli_init_file $env(CSF_DrawAppliInit)
90}
91if { [file readable $draw_appli_init_file] } {
92 if { [catch {source $draw_appli_init_file} res] } {
93 puts "Warning: problem while loading file $draw_appli_init_file: $res"
87c58d4f 94 }
7fd59977 95}
69da6e7a 96
b7e76224 97# on Windows, set special handler to update automatically environment variables
98# in C subsystem when Tcl environment changes (see Mantis issue #23197)
30a73087 99if { $tcl_platform(platform) == "windows" && ! [catch {dgetenv PATH}] } {
b7e76224 100 proc _update_c_env {envenv var op} {
101 global env
102 if { $op == "unset" } {
103 if { $var != "" } {
104 dsetenv $var
105 } else {
106 #"array get env varname" command calls _update_c_env with op="unset" and var=""
107 #It leads to detach of trace from env array
108 trace add variable env array _update_c_env
109 trace add variable env read _update_c_env
110 trace add variable env write _update_c_env
111 trace add variable env unset _update_c_env
112 }
113 } elseif { $op == "write" } {
114 dsetenv $var $env($var)
115 } elseif { $op == "read" } {
116 return dgetenv $var
117 }
118 }
119 #Execute "trace add ..." block from _update_c_env proc
120 _update_c_env env "" "unset"
121}
122
f4dee9bb 123# arm signal handler with default FPE setting
124dsetsignal
125
69da6e7a 126# silent return from the script
127return