/usr/share/elmerfront/tcl/ecif_tcl_mainScript.tcl is in elmer-common 6.1.0.svn.5396.dfsg2-4ubuntu4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 | #/*****************************************************************************/
# *
# * Elmer, A Finite Element Software for Multiphysical Problems
# *
# * Copyright 1st April 1995 - , CSC - IT Center for Science Ltd., Finland
# *
# * This program is free software; you can redistribute it and/or
# * modify it under the terms of the GNU General Public License
# * as published by the Free Software Foundation; either version 2
# * of the License, or (at your option) any later version.
# *
# * This program is distributed in the hope that it will be useful,
# * but WITHOUT ANY WARRANTY; without even the implied warranty of
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# * GNU General Public License for more details.
# *
# * You should have received a copy of the GNU General Public License
# * along with this program (in file fem/GPL-2); if not, write to the
# * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# * Boston, MA 02110-1301, USA.
# *
# *****************************************************************************/
#***********************************************************************
#Program: ELMER Front
#Module: ecif_tcl_mainScript.tcl
#Language: Tcl
#Date: 19.10.98
#Version: 1.00
#Author(s): Martti Verho
#Revisions:
#
#Abstract: Starting script for the user interface (Tk)
#
#************************************************************************
# Set current version number
# ==========================
#
proc setFrontVersionNumber {} {
global Info
# NOTE: Version main-number is meant for major changes in Front input format etc.
# It is set in ECIF_CONST.CPP
#
# NOTE: Version sub-number is meant for minor changes and bug fixes
# It is set HERE!
#
# NOTE: Current version sub-number is for main version nbr 9
# Reset sub-number (--> .0) whenever the main version changes
#
# Set current sub-number
# ----------------------
#
# *******************************
# This number must match the main
# version number set in cpp-side.
# Normally, do NOT change this!!!
# *******************************
#
set main_nbr_txt "9"
# ***************************************************************************
# ***************************************************************************
# Update this for 'minor' changes !!!
# ***************************************************************************
# ***************************************************************************
#
# Last change: (.0 --> .0a), 12.06.03, MVe
# Last change: (.0a --> .1a), 21.10.03, MVe
# Last change: (.1a --> .2a), 10.03.04, MVe
# Last change: (.2a --> .3a), 02.06.04, MVe; Boundary selection bug fix
# Last change: (.3a --> .3b), 02.07.04, MVe; ELMER_FRONT_FONT_SIZE env added
#
set sub_nbr_txt ".3b"
#
# ----------------------
if { $Info(FRONT_MAIN_VERSION_NBR) == $main_nbr_txt } {
set Info(FRONT_SUB_VERSION_NBR) $sub_nbr_txt
} else {
set Info(FRONT_SUB_VERSION_NBR) ""
}
set Info(FRONT_VERSION_NBR) $Info(FRONT_MAIN_VERSION_NBR)$Info(FRONT_SUB_VERSION_NBR)
}
############################
### Front initialization ###
############################
# Message box proc
# NOTE: This can be called anywhere, no
# loaded source needed!
#
proc my_box { {msg ""} } {
tk_messageBox -message $msg
}
# Globals
global Info Model ModelProperty UserSetting
# CAREFULLY, these are for debugging !!!###!!!
# Debug: 0
# Release: 1
#
set Info(SAVE_PANEL_DATA) 1
set Info(DO_CATCH) 1
proc my_catch {block messu} {
global Info
upvar $messu msg
if { $Info(DO_CATCH) } {
return [catch {$block} msg]
} else {
eval $block
return 0
}
}
set Info(commandLineArgs) ""
set Info(commandLineInfo) ""
set Info(wrnMsgColor) red
set Info(errMsgColor) red
set Info(remMsgColor) brown
##################################
# Main proc to start Elmer Front #
##################################
proc startGUI {} {
global Info Model ModelProperty
set Info(userSettingFiles) ""
set Info(userSettingFilesReadInfo) ""
set Info(userSettingFilesErrorInfo) ""
set Model(defaultDefinitionFiles) ""
set Model(defaultDefinitions) ""
set Model(inDefinitionFile) ""
#-Init environment variables
initEnvironment
# Check possible default setting files
# =======================================
checkDefaultSettingFiles
# Check possible default definition files
# =======================================
checkDefaultDefinitionFiles
# Check command line arguments
# ============================
handleCommandLineArgs 1
# Read possible setting files (via cpp)
# ===========================
if { $Info(userSettingFiles) != "" } {
cpp_readUserSettingFiles
}
# Call start procs
# ================
#-Init screen parameters
initScreen
#-Load tcl source files
loadSource
#-Set complete (main+sub) version number
#
setFrontVersionNumber
#-Start (init glob arries, build menus)
startFront
}
proc setElmerFrontPaths {} {
global Info env
set Info(ELMER_FRONT_INSTALL_LIB) "/usr/share/elmerfront/lib"
set Info(ELMER_FRONT_INSTALL_TCL) "/usr/share/elmerfront/tcl"
if { [info exists env(ELMER_HOME)] } {
set Info(ELMER_FRONT_INSTALL_LIB) "$env(ELMER_HOME)/share/elmerfront/lib"
set Info(ELMER_FRONT_INSTALL_TCL) "$env(ELMER_HOME)/share/elmerfront/tcl"
}
if { [info exists env(ELMER_FRONT_HOME)] } {
set Info(ELMER_FRONT_INSTALL_LIB) "$env(ELMER_FRONT_HOME)/lib"
set Info(ELMER_FRONT_INSTALL_TCL) "$env(ELMER_FRONT_HOME)/tcl"
}
set Info(ELMER_FRONT_BUILD_LIB) "./lib"
set Info(ELMER_FRONT_BUILD_TCL) "./tcl"
}
#####################
# Set platform info #
#####################
proc initEnvironment {} {
global Info
global env tcl_platform
global tcl_version tcl_patchLevel tcl_library
global tk_version tk_patchLevel tk_library
#---Program name and version
set Info(PROJECT) "ELMER"
set Info(MODULE) "Front"
set Info(FRONT_NAME) "ELMER Front"
set Info(VERSION) ""
#---Machine info info
set Info(PID) [pid]
set Info(machine) $tcl_platform(machine)
set Info(os) $tcl_platform(os)
set Info(osVersion) $tcl_platform(osVersion)
set Info(platform) $tcl_platform(platform)
#---Windows platform and OS names used in Tcl
set Info(platform,Windows) "windows"
set Info(os,WindowsNT) "Windows NT"
set Info(os,Windows95) "Windows 95"
set Info(os,Windows98) "Windows 98" ;# This is a guess!
set Info(os,Windows2K) "Windows NT"
#---Tcl version info
set Info(tclVersion) $tcl_version
set Info(tclLevel) $tcl_patchLevel
set Info(tclLibraryPath) $tcl_library
set Info(tkVersion) $tk_version
set Info(tkLevel) $tk_patchLevel
set Info(tkLibraryPath) $tk_library
#---Win32:
#-Uses dde for "send"
#-File names not case sensitive
if { $Info(platform) == "windows" } {
set Info(FNCS) 0
if { [catch {package require dde 1.0} msg] } {
tk_messageBox -message $msg
}
#---Unix
#-File names are case sensitive
} else {
set Info(FNCS) 1
}
# Buttons: press enter <==> pressing space key
bind Button <KeyPress-Return> "+event generate %W <KeyPress-space>"
event add <<MenuPick>> <Button-1>
# Set working directory
# =====================
set Info(workingDirectory) [pwd] ;# This is the PWD when it is needed
set Info(currentDirectory) [pwd] ;# This is for "debugging" (monitoring)
puts "Setting up paths"
setElmerFrontPaths
# Init script-path if not defined
if { 0 == [info exists Info(frontScriptPath)] } {
set Info(frontScriptPath) ""
}
# Make scriptpath absolute
if { "relative" == [file pathtype $Info(frontScriptPath)] } {
set tmp [file split $Info(frontScriptPath)]
set tmp [lrange $tmp 1 end]
set Info(frontScriptPath) [file join $Info(workingDirectory) $tmp]
}
# All needed images are here
set Info(imagePath) [file join $Info(frontScriptPath) "images"]
# ElmerHome
# =========
# This is the parent path for /bin etc.
if { [info exists env(ELMER_HOME)] } {
set Info(ELMER_HOME) $env(ELMER_HOME)
if { ![file isdirectory $Info(ELMER_HOME)] } {
set Info(ELMER_HOME) "/usr"
}
} else {
set Info(ELMER_HOME) "/usr"
}
# ElmerUserHome
# =============
# This is one of the paths for color tables, matc defs etc.
if { [info exists env(ELMER_USER_HOME)] } {
set Info(ELMER_USER_HOME) $env(ELMER_USER_HOME)
if { ![file isdirectory $Info(ELMER_USER_HOME)] } {
set Info(ELMER_USER_HOME) ""
}
} else {
set Info(ELMER_USER_HOME) ""
}
# Elmer version
# ==================
set version_file [file join $Info(ELMER_HOME) lib "version.dat"]
if { [file exist $version_file] } {
set msg ""
if { ![catch {set ch [open $version_file "r"] } msg] } {
set Info(VERSION) [string trim [gets $ch] ]
}
}
# ElmerFrontHome
# ==============
if { [info exists env(ELMER_FRONT_HOME)] } {
set Info(ELMER_FRONT_HOME) $env(ELMER_FRONT_HOME)
} else {
set Info(ELMER_FRONT_HOME) "$Info(ELMER_HOME)/Front"
}
if { ![file isdirectory $Info(ELMER_FRONT_HOME)] } {
set Info(ELMER_FRONT_HOME) "."
}
# Temporary directory
# ===========================
set Info(LOG_DIRECTORY) ""
# Predefined alternatives in search order!
#set tmpdir_names {
# ELMER_FRONT_TMP ELMER_FRONT_TEMP
# ELMER_TMP ELMER_TEMP
# TMPDIR TEMPDIR TMP TEMP
#}
set tmpdir_names {
ELMER_FRONT_TMP ELMER_FRONT_TEMP
}
foreach vn $tmpdir_names {
if { 1 == [info exists env($vn)] } {
set Info(LOG_DIRECTORY) $env($vn)
break
}
}
# User name
# =========
set Info(USER) ""
# Predefined alternatives in search order!
set user_names {
ELMER_FRONT_USER ELMER_USER
USER USERNAME user username
}
foreach vn $user_names {
if { [info exists env($vn)] } {
set Info(USER) $env($vn)
break
}
}
# Computer name
# =============
set Info(HOST) ""
# Predefined alternatives in search order!
set host_names {
ELMER_FRONT_HOST ELMER_HOST
HOST host COMPUTERNAME
}
foreach vn $host_names {
if { [info exists env($vn)] } {
set Info(HOST) $env($vn)
break
}
}
# Elmer Variable values
# =====================
# Names and default values
set defs {
{ ELMER_MODEL_NAME "" }
{ ELMER_MODEL_DIRECTORY "" }
{ ELMER_INCLUDE_PATH "" }
{ ELMER_RESULTS_DIRECTORY "" }
{ ELMER_FRONT_DEFINITIONS "" }
{ ELMER_FRONT_SETTINGS "" }
{ ELMER_FRONT_FONT_SIZE "" }
}
# If environment variable defined, use it
foreach def $defs {
set vn [lindex $def 0] ;# variable name
set vv [lindex $def 1] ;# default value
if { [info exists env($vn)] } {
set Info($vn) $env($vn)
} else {
set Info($vn) $vv
}
}
# These control "special" features!
# =============================
set specials {
ELMER_FRONT_THETIS_SUPPORT
ELMER_FRONT_DEBUG_TCL
ELMER_FRONT_DEBUG_TCL_PRINT
ELMER_FRONT_DEBUG_TCL_STACK
}
# NOTE: These have 0/1 values!
foreach special $specials {
if { [info exists env($special)] && 1 == $env($special) } {
set Info($special) 1
} else {
set Info($special) 0
}
}
} ;# End initEnvironment
###################################
# Check default UserSetting files #
###################################
#
# Collect possible setting file names:
# elmer/lib/elmerFrontSettings.esf
# from env-var ELMER_FRONT_SETTINGS
# to a list for later loading
#
proc checkDefaultSettingFiles {} {
global Info Model UserSetting
set evs {ELMER_FRONT_SETTINGS ELMER_USER_HOME}
set fn "front.esf"
if { [info exists Info(ELMER_HOME)] &&
$Info(ELMER_HOME) != ""
} {
set path [file join $Info(ELMER_HOME) lib $fn]
if { [file exist $path] } {
lappend Info(userSettingFiles) $path
}
# NOTE: This is the default file from now on, for saving etc.!
set UserSetting(filePath) $path
}
foreach ev $evs {
if { [info exists Info($ev)] && $Info($ev) != "" } {
set path [file join $Info($ev) $fn]
if { [file exist $path] } {
lappend Info(userSettingFiles) $path
# NOTE: This is the default file from now on, for saving etc.!
set UserSetting(filePath) $path
}
}
}
}
##################################
# Check default definition files #
##################################
#
# Collect possible definition file names:
# elmer/lib/elmerFrontDefinitions.def
# from env-var ELMER_FRONT_DEFINITIONS
# to a list for later loading
#
proc checkDefaultDefinitionFiles {} {
global Info Model
set evs {ELMER_FRONT_DEFINITIONS ELMER_USER_HOME ELMER_FRONT_BUILD_LIB ELMER_FRONT_INSTALL_LIB}
set fn "front.edf"
if { [info exists Info(ELMER_HOME)] &&
$Info(ELMER_HOME) != ""
} {
set path [file join $Info(ELMER_HOME) lib $fn]
if { [file exist $path] } {
lappend Model(defaultDefinitionFiles) $path
}
}
foreach ev $evs {
if { [info exists Info($ev)] && $Info($ev) != "" } {
set path [file join $Info($ev) $fn]
if { [file exist $path] } {
lappend Model(defaultDefinitionFiles) $path
}
}
}
}
######################
# Create main window #
######################
proc initScreen {} {
global Info
# Create main window
# ==================
set mainWindow .
set Info(mainWindow) $mainWindow
# Main window position from the NW-corner
wm geometry $mainWindow -20+10
#---Window killing should send exit also to cpp-side
# This way ce can catch exit when debugging!!!###!!!
if { $Info(ELMER_FRONT_DEBUG_TCL) } {
wm protocol $mainWindow WM_DELETE_WINDOW "MenuExec::cifExit"
# This always kills Front in user mode!!!###!!!
} else {
wm protocol $mainWindow WM_DELETE_WINDOW "cpp_exit"
}
#wm protocol $mainWindow WM_TAKE_FOCUS "Util::setMainWindowTitle"
# Window settings
# ===============
# Main window title
wm title $mainWindow "$Info(PROJECT) $Info(MODULE) - No model name"
# Just testing, icon for a window does not seem to work in Windows32
#image create photo FRONT_ICON -file [file join $Info(imagePath) display.gif]
#image create bitmap FRONT_ICON -file [file join $Info(imagePath) cygnus.ico]
#wm iconbitmap $mainWindow $FRONT_ICON
#wm iconbitmap $mainWindow ""
#wm iconname $mainWindow "Front"
# Main window max size ( = screen resolution)
set maxWinSize [wm maxsize $mainWindow]
set Info(maxWinSizeX) [lindex $maxWinSize 0]
set Info(maxWinSizeY) [lindex $maxWinSize 1]
} ;# End initScreen
#####################
# Load source files #
#####################
proc loadSource {} {
global Info
set ext tcl
set sourceScripts {
ecif_tcl_namespaces
ecif_tk_aboutBox
ecif_tk_bodyDisplayPanel
ecif_tk_bodyInfoPanel
ecif_tk_bodyPropertiesPanel
ecif_tk_boundariesPanel
ecif_tk_boundaryDisplayPanel
ecif_tk_calculatorPanel
ecif_tk_constantPanel
ecif_tk_coordinatePanel
ecif_tk_datafilePanel
ecif_tk_equationVariablesPanel
ecif_tk_initGlobalArries
ecif_tk_initMenus
ecif_tk_inputFileInfoPanel
ecif_tk_labelDisplayPanel
ecif_tk_matcDefinitionsPanel
ecif_tk_meshDefinePanel
ecif_tk_meshSelectPanel
ecif_tk_modelInfoPanel
ecif_tk_modelParameterPanel
ecif_tk_modelPropertiesPanel
ecif_tk_postFileSelectPanel
ecif_tk_procedureEntryPanel
ecif_tk_processorPanel
ecif_tk_processTablePanel
ecif_tk_procsDataField
ecif_tk_procsInterface
ecif_tk_procsList
ecif_tk_procsListBox
ecif_tk_procsMenuExec
ecif_tk_procsMessage
ecif_tk_procsObject
ecif_tk_procsPanel
ecif_tk_procsPanelCheck
ecif_tk_procsUserDefined
ecif_tk_procsUtil
ecif_tk_procsWidget
ecif_tk_screenParams
ecif_tk_simulationParameterPanel
ecif_tk_solverOrderPanel
ecif_tk_solverParameterPanel
ecif_tk_solverControlPanel
ecif_tk_standardPanelCheck
ecif_tk_standardPanelCreate
ecif_tk_standardPanelExec
ecif_tk_standardPanelInit
ecif_tk_systemInfoPanel
ecif_tk_tableEntryPanel
ecif_tk_timestepPanel
ecif_tk_userSettingsPanel
ecif_tk_vertexDisplayPanel
tkgetdir
}
# Load source code
# ================
#--Front own source code
if { [catch {
foreach src_name $sourceScripts {
set src_file [file join $Info(frontScriptPath) $src_name.$ext]
lappend Info(sourceScripts) [list $src_name $src_file [file mtime $src_file]]
source $src_file
} } msg]
} {
#set err_msg "Elmer Front ERROR loading Tcl source file: $src_file ($errorInfo)"
set err_msg "Elmer Front ERROR when loading Tcl source file: $src_file"
my_box $err_msg
cpp_exec_ "cpp_exit"
}
#--Possible user source code
set user_src_file [file join $Info(ELMER_HOME) lib "front_user_src.tcl"]
if { [file exist $user_src_file] } {
set msg ""
if { [catch {source $front_user_src} msg] } {
set err_msg "Elmer Front ERROR when loading user Tcl source file: $front_user_src"
my_box $err_msg
cpp_exec_ "cpp_exit"
}
}
# Post process
# ============
if { $Info(platform) == "windows" } {
rename MenuExec::send_WIN32 send
}
} ;# End loadSource
###############
# Start Front #
###############
proc startFront {} {
global Info
#--Call data init proc (in ecif_tk_initGlobalArries.tcl)
#
if { [my_catch FRONT_INIT msg] } {
#set err_msg "Elmer Front ERROR (FRONT_INIT proc): $errorInfo"
set err_msg "Elmer Front ERROR (FRONT_INIT proc)"
my_box "$err_msg \n\n$msg"
cpp_exec_ "cpp_exit"
}
#--Call menu init proc (in ecif_tk_initMenus.tcl)
#
if { [my_catch INIT_MENUS msg] } {
#set err_msg "ELMER FRONT ERROR (INIT_MENUS proc): $errorInfo"
set err_msg "ELMER FRONT ERROR (INIT_MENUS proc)"
my_box "$err_msg \n\n$msg"
return
}
#--Call post init proc (in ecif_tk_initGLobArries.tcl)
#
if { [my_catch FRONT_POST_INIT msg] } {
#set err_msg "ELMER FRONT ERROR (FRONT_POST_INIT proc): $errorInfo"
set err_msg "ELMER FRONT ERROR (FRONT_POST_INIT proc)"
my_box "$err_msg \n\n$msg"
return
}
#--Read possible fields' help file
# Default fields' help file name
set filename [file join $Info(ELMER_HOME)/lib "front.ehf"]
if { [file exists $filename] } {
if { [catch {FRONT_READ_FIELD_HELP_FILE $filename 1} msg] } {
set err_msg "ELMER FRONT ERROR (FRONT_READ_FIELD_HELP_FILE proc)"
my_box "$err_msg \n\n$msg"
#return
}
}
#--Show possible init-messages (cmd-line args stuf etc) (in ecif_tk_initGlobalArries.tcl)
# NOTE: We show these last because then it is easier for the user to see possible
# error messages
#
if { [my_catch FRONT_SHOW_INIT_MESSAGES msg] } {
set err_msg "ELMER FRONT ERROR (FRONT_SHOW_INIT_MESSAGES proc)"
my_box "$err_msg \n\n$msg"
#return
}
#Message::showMessage "$Info(FRONT_NAME) started!" blue 1
} ;# End proc startFront
#====================================#
# handleCommandLineArguments #
#====================================#
#
# Read possible command line arguments for command ElmerFront
# currently available with example values:
#
# --model-directory=/elmer/MODELS
# --model-name=stepflow
# --include-path=/elmer/Materials;/elmer/Conditions
# --results-directory=c:/temp
# --tmp-directory=c:/temp
# --settings-file=/elmer/ElmerFrontSettings.txt
#
# NOTE: settings-file argument value is called back by cpp-side!
# ===> this proc must be called first by cpp-side
#
# NOTE: these value overwrite UserSettings environment case directory values, but
# they do NOT overwrite model-file case direcrory values !!!
# Case dirs here are: INCLUDE-PATH, RESULTS-DIRECTORY, LOG-DIRECTORY
#
proc handleCommandLineArgs { {do_msg 0} } {
global Info Model ModelProperty UserSetting
set Info(MODEL_DIRECTORY) ""
set Info(MODEL_NAME) ""
set Info(PROBLEM_NAME) ""
set arg_line $Info(commandLineArgs)
if {$arg_line == ""} {
return
}
set Info(commandLineInfo) $arg_line
lappend Info(commandLineInfo) ""
# This will repalce "--" in the
# original argument line
set sep ";"
regsub -all (--) $arg_line $sep arg_line1
set arg_list [split [string trimleft $arg_line1 $sep] $sep]
foreach arg $arg_list {
set data [split $arg "="]
#-Inproper argument
if { 2 != [llength $data] } {
if {$do_msg} {
lappend Info(commandLineInfo) [list $data $Info(errMsgColor)]
lappend Info(commandLineInfo) [list "INCORRECT command line argument: $data"]
lappend Info(commandLineInfo) ""
}
continue
}
set cmd [lindex $data 0]
set cmdUC [string toupper $cmd]
set value [lindex $data 1]
set value [string trim $value]
switch $cmdUC {
MODEL-DIRECTORY {
if { [file isdirectory $value] } {
set UserSetting(DEFAULT_MODEL_DIRECTORY) $value
set Info(MODEL_DIRECTORY) $value
} else {
if {$do_msg} {
lappend Info(commandLineInfo) [list "--$cmd = $value" $Info(wrnMsgColor)]
lappend Info(commandLineInfo) [list "CANNOT FIND the model-directory: $value"]
lappend Info(commandLineInfo) ""
}
}
}
MODEL-NAME {
set Info(MODEL_NAME) $value
}
PROBLEM-NAME {
set Info(PROBLEM_NAME) $value
}
INCLUDE-PATH {
set UserSetting(DEFAULT_RESULTS_DIRECTORY) $value
}
RESULTS-DIRECTORY {
set UserSetting(DEFAULT_RESULTS_DIRECTORY) $value
}
LOG-DIRECTORY {
set UserSetting(DEFAULT_LOG_DIRECTORY) $value
}
SETTINGS-FILE {
if { [file exists $value] } {
lappend Info(userSettingFiles) $value
# NOTE: This is the default file from now on, for saving etc.!
set UserSetting(filePath) $value
} else {
lappend Info(commandLineInfo) [list "--$cmd = $value" $Info(wrnMsgColor)]
lappend Info(commandLineInfo) [list "CANNOT FIND the settings file: $value"]
lappend Info(commandLineInfo) ""
}
}
DEFINITION-FILE {
if { [file exists $value] } {
lappend Model(defaultDefinitionFiles) $value
} else {
lappend Info(commandLineInfo) [list "--$cmd = $value" $Info(wrnMsgColor)]
lappend Info(commandLineInfo) [list "CANNOT FIND the definitions file: $value"]
lappend Info(commandLineInfo) ""
}
}
default {
if {$do_msg} {
lappend Info(commandLineInfo) [list "--$cmd" $Info(errMsgColor)]
lappend Info(commandLineInfo) [list "UNKNOWN command line argument: $cmd"]
lappend Info(commandLineInfo) ""
}
}
}
}
} ;# End handleCommandLineArguments
################################
# Interface procs Tcl <--> Cpp #
################################
set Info(arguments) ""
set Info(results) ""
set Info(cmdSeparator) @
set Info(argSeparator) ^
# Send commands to Cpp
#
proc cpp_exec_ { cmd {arg ""} } {
set catch_msg ""
set code [catch {
#
global Info __x__
set Info(arguments) $arg
if { [string equal -nocase $cmd "cpp_exit"] } {
cpp_exit
set __x__ done
} else {
set cmd "cpp_$cmd"
eval $cmd
Util::updateMainWindowTitle
}
} catch_msg]
return $catch_msg
}
# Execute commands from Cpp
#
proc gui_exec {s} {
global Info __x__
set do_eval 1
if { [catch { set clist [split $s $Info(cmdSeparator)];
set cmd [lindex $clist 0];
set Info(arguments) [lindex $clist 1];
}
] } {
set do_eval 0
catch { MSG "Gui: cannot parse and exec script: $" }
}
if { [string equal -nocase $cmd "gui_exit"] } {
do_exit
set __x__ done
} else {
if { $do_eval } {
eval $cmd
}
}
return ""
}
#====================================#
# These are NOT in use currently !!! #
# ===================================#
# ReadFromCpp procs
# -----------------
#---A proc to read commands from clients
proc __readAndExec_cpp {s} {
global Info __x__
set clist [split $s $Info(cmdSeparator)]
set l [lindex $clist 0]
set Info(arguments) [lindex $clist 1]
if { [string compare $l "cpp_exit"] == 0} {
cpp_exit
set __x__ done
} else {
# eval $l
after idle $l
}
}
#---A proc to read commands from clients
#NOTE This is used when calling function directly
#in dll- and slave-implementations
proc cpp_readAndExec {s} {
global Info __x__
set clist [split $s $Info(cmdSeparator)]
set l [lindex $clist 0]
set Info(arguments) [lindex $clist 1]
if { [string compare $l "cpp_exit"] == 0} {
# interp eval my_slave cpp_exit
cpp_exit
set __x__ done
} else {
eval $l
# after idle interp eval my_slave $l
}
}
#---A proc to send an error message to be displayed by Gui.
proc __sendErrorMsg {} {
global Info
set sep $Info(cmdSeparator)
set msg $Info(errorMsg)
__writeForExec2GUI "Interface::displayErrorMsg$sep$msg"
}
#---A proc to send commands to GUI-server
proc __writeForExec2GUI {msg} {
set code [catch { GUI_readAndExec $msg } catch_msg]
}
# WriteToCpp procs
# ----------------
#---A proc to send commands to the client
proc __writeForExec2cpp {msg} {
set code [catch { cpp_readAndExec $msg } catch_msg]
# cpp_readAndExec $msg
}
#---A proc to execute commands from the clients
proc __readAndExec_GUI {s} {
global Info __x__
set clist [split $s $Info(cmdSeparator)]
set l [lindex $clist 0]
set Info(arguments) [lindex $clist 1]
if { [string compare $l "GUI_exit"] == 0} {
do_exit
set __x__ done
} else {
eval $l
}
}
#---A proc to execute commands from the clients
proc GUI_readAndExec {s} {
global Info __x__
set clist [split $s $Info(cmdSeparator)]
set l [lindex $clist 0]
set Info(arguments) [lindex $clist 1]
if { [string compare $l "GUI_exit"] == 0} {
do_exit
set __x__ done
} else {
eval $l
}
}
# End not in use
# ==============
# end ecif_tk_mainScript.tcl
# ********************
|