/usr/share/elmerfront/tcl/ecif_tk_systemInfoPanel.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 | #/*****************************************************************************/
# *
# * 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_tk_systemInfoPanel.tcl
#Language: Tcl
#Date: 04.06.99
#Version: 1.00
#Author(s): Martti Verho
#Revisions:
#
#Abstract: A panel for system and graphics environment information.
#
#************************************************************************
##################
### SystemInfo ###
##################
# This procedure displays the model statistic-info screen
#
proc SystemInfo::openPanel { } {
# Global variables
global Info
set w .infowin
set SystemInfo(winName) $w
set SystemInfo(winTitle) "System environment info"
set wgeom +420+120
set id [winfo atom $w]
set SystemInfo(winId) $id
set Info(thisWindow) $w
if { 1 == [Util::checkPanelWindow SystemInfo $id $SystemInfo(winTitle) $wgeom] } {
return
}
toplevel $w
focus $w
wm title $w $SystemInfo(winTitle)
wm geometry $w $wgeom
#-Frame padding parameters
set fpx1 $Info(framePadX1)
set fpy1 $Info(framePadY1)
set fpx2 $Info(framePadX2)
set fpy2 $Info(framePadY2)
set fpx3 $Info(framePadX3)
set fpy3 $Info(framePadY3)
set bg $Info(nonActiveBgLight)
#---Data fields
set Info(currentDirectory) [pwd]
set fieldInfos {
{ "User name: " USER }
{ "Computer name: " HOST }
{ "Machine: " machine }
{ "Operating system: " os }
{ "OS version: " osVersion }
{ "Tcl version: " tclVersion }
{ "Tcl level: " tclLevel }
{ "Tk version: " tkVersion }
{ "Tk level: " tkLevel }
{ "Tcl library path: " tclLibraryPath }
{ "Tk library path: " tkLibraryPath }
{ "Elmer Front version: " FRONT_VERSION_NBR }
{ "Elmer Front script path: " frontScriptPath }
{ "Elmer Home: " ELMER_HOME }
{ "Elmer Front Home: " ELMER_FRONT_HOME }
{ "Working directory: " workingDirectory }
}
if { $Info(ELMER_FRONT_DEBUG_TCL) } {
lappend fieldInfos { "Current directory: " currentDirectory }
}
# Create lables and entries
set index 1
foreach fi $fieldInfos {
set m [frame $w.f$index]
set lbl [lindex $fi 0]
set var [lindex $fi 1]
# Create label and entry
label $m.l -width 18 -text $lbl
entry $m.e -width 55 -textvariable Info($var) -justify left -state disabled -bg $bg
pack $m -side top -expand 0 -fill x -padx $fpx1 -pady $fpy1
pack $m.l $m.e -side left -anchor w -in $m
incr index
}
# Buttons
frame $w.fB
#-Ok button
set ok_btn [button $w.fB.ok -text OK -command "Panel::cancel $SystemInfo(winName)"]
focus $ok_btn
pack $ok_btn
pack $w.fB -side top -expand 0 -fill x -padx $fpx3 -pady $fpy3
}
# Dummy proc
proc SystemInfo::panelOk {w} {
}
####################
### RendererInfo ###
####################
# This procedure displays the model statistic-info screen
#
proc RendererInfo::openPanel { } {
# Global variables
global Info RendererInfo
set w .infowin
set RendererInfo(winName) $w
set RendererInfo(winTitle) "Graphics environment info"
set wgeom +420+120
set id [winfo atom $w]
set RendererInfo(infoWinId) $id
set Info(thisWindow) $w
if { 1 == [Util::checkPanelWindow RendererInfo $id $RendererInfo(winTitle) $wgeom] } {
return
}
toplevel $w
focus $w
wm title $w $RendererInfo(winTitle)
wm geometry $w $wgeom
#-We set each row of data into a separate frame.
frame $w.f1 ;# Line width granularity
frame $w.f2 ;# Line width range
frame $w.fB ;# Buttons
set wid1 12; set wid2 18; set wid3 24; set wid4 30
#-A header text for each data field.
label $w.f1.l -width $wid2 -anchor w -text "Line width range: "
label $w.f2.l -width $wid2 -anchor w -text "Line width granularity: "
#-Frame padding parameters
set fpx1 $Info(framePadX1)
set fpy1 $Info(framePadY1)
set fpx2 $Info(framePadX2)
set fpy2 $Info(framePadY2)
set fpx3 $Info(framePadX3)
set fpy3 $Info(framePadY3)
set bg $Info(nonActiveBgLight)
#---Data fields (as labels)
set exp 0
set start 1
set variable_count 2
set variables {
LINE_WIDTH_RANGE
LINE_WIDTH_GRANULARITY
}
set space {15 7}
set justify_left {1 1}
# Create lables and entries
for {set index 0} {$index < $variable_count} {incr index} {
set m $w.f[expr $start + $index]
set s [lindex $space $index]
set j_left [lindex $justify_left $index]
set vars [lindex $variables $index]
pack $m -side top -expand $exp -fill x -padx $fpx1 -pady $fpy1
pack $m.l -side left -anchor w -in $m
set anch c
# Should we left justify data
if {$j_left} { set just left}
# Create entries
set count 0
foreach v $vars {
incr count
set val [set RendererInfo($v)]
entry $m.d$count -width $s -textvariable RendererInfo($v) -justify $just -state disabled -bg $bg
pack $m.d$count -side left -in $m -padx $fpx1
}
}
#-Ok button
set ok_btn [button $w.fB.ok -text OK -command "Panel::cancel $RendererInfo(winName)"]
focus $ok_btn
pack $ok_btn
pack $w.fB -side top -expand $exp -fill x -padx $fpx3 -pady $fpy3
}
# Dummy proc
proc RendererInfo::panelOk {w} {
}
########################
### DEBUGGING TCL/TK ###
########################
# ================
# Sourcelist Panel
# ================
# This procedure displays all source files, you can also reload
# these files!
#
proc sourceListPanel { } {
# Global variables
global Info
set w .sourcewin
set SourceList(winName) $w
set SourceList(winTitle) "Source file list"
set wgeom +420+120
set id [winfo atom $w]
set SourceList(infoWinId) $id
set Info(thisWindow) $w
if { 1 == [Util::checkPanelWindow SourceList $id $SourceList(winTitle) $wgeom] } {
return
}
toplevel $w
focus $w
wm title $w $SourceList(winTitle)
wm geometry $w $wgeom
frame $w.fLB
frame $w.fB
set m $w.fLB
listbox $m.sourceList -relief sunken -selectmode extended -exportselection 0 \
-yscrollcommand [list $m.sy set] \
-height 30 -width 55 -font $Info(entryFont)
scrollbar $m.sy -orient vertical -command [list $m.sourceList yview]
pack $m.sourceList -side left -anchor n -fill x -expand 1
pack $m.sy -side left -anchor n -fill y
foreach pair $Info(sourceScripts) {
set nam [lindex $pair 0]
set fil [lindex $pair 1]
set tim [lindex $pair 2]
# Mark modified
if { $tim != [file mtime $fil] } {
append nam " ***"
}
$m.sourceList insert end $nam
}
#-We set each row of data into a separate frame.
#-Ok button
set ok_btn [button $w.fB.ok -text OK -command "Panel::cancel $SourceList(winName)"]
#-Load buttons
set ld_sel_btn [button $w.fB.load_sel -text "Load selected" -command "sourceListLoadSelected $m.sourceList"]
set ld_mod_btn [button $w.fB.load_mod -text "Load modified" -command "sourceListLoadModified $m.sourceList"]
set ld_all_btn [button $w.fB.load_all -text "Load all" -command "sourceListLoadAll $m.sourceList"]
focus $ok_btn
pack $ok_btn $ld_sel_btn $ld_mod_btn $ld_all_btn -side left -expand 1 -fill x
pack $w.fLB $w.fB -side top -expand 1 -fill x -padx 10 -pady 10
}
# Dummy proc
proc SourceList::panelOk {w} {
}
# Can be used without opening the widget!
#
proc updateSource {} {
sourceListLoadModified
}
proc sourceListLoadSelected {lb_wdg} {
global Info
set indices [$lb_wdg curselection]
if { $indices == "" } {
return
}
foreach index $indices {
set src_def [lindex $Info(sourceScripts) $index]
set src_file [lindex $src_def 1]
set mtime [file mtime $src_file]
set src_def [lreplace $src_def 2 2 $mtime]
set Info(sourceSripts) [lreplace $Info(sourceScripts) $index $index $src_def]
source $src_file
Message::showMessage "Source loaded: $src_file"
}
sourceListRefill $lb_wdg
}
proc sourceListLoadModified { {lb_wdg ""} } {
global Info
set new_list ""
set index 0
foreach src_def $Info(sourceScripts) {
set src_file [lindex $src_def 1]
set src_time [lindex $src_def 2]
set mtime [file mtime $src_file]
# Check if modified time has changed
if { $mtime != $src_time } {
set src_def [lreplace $src_def 2 2 $mtime]
set src_file [lindex $src_def 1]
source $src_file
Message::showMessage "Source loaded: $src_file"
}
lappend new_list $src_def
incr index
}
set Info(sourceScripts) $new_list
sourceListRefill $lb_wdg
}
proc sourceListLoadAll { {lb_wdg ""} } {
global Info
set new_list ""
set index 0
foreach src_def $Info(sourceScripts) {
set src_file [lindex $src_def 1]
set mtime [file mtime $src_file]
set src_def [lreplace $src_def 2 2 $mtime]
source $src_file
Message::showMessage "Source loaded: $src_file"
lappend new_list $src_def
incr index
}
set Info(sourceScripts) $new_list
sourceListRefill $lb_wdg
}
proc sourceListRefill {lb_wdg} {
global Info
if { $lb_wdg == "" } {
return
}
$lb_wdg delete 0 end
foreach src_def $Info(sourceScripts) {
set src_name [lindex $src_def 0]
$lb_wdg insert end $src_name
}
}
# =================
# Tcl command panel
# =================
# This procedure displays an entry and text output widget for
# evaluatin tcl commands
#
proc tclCommandPanel {} {
global Info TclCommand
set id 0
while { [winfo exists .commandwin$id] } {
incr id
}
set w .commandwin$id
set winName $w
set winTitle "Tcl command entry"
set wgeom +420+120
toplevel $w
focus $w
wm title $w $winTitle
wm geometry $w $wgeom
if { ![info exists TclCommand(cmdListIndex,$id)] } {
set TclCommand(cmdListIndex,$id) -1
}
frame $w.fT
frame $w.fE
frame $w.fB
# Command output text widget
# ==========================
set m $w.fT
set wdg [text $m.cmdOutput -relief sunken \
-height 20 -width 55 -setgrid true -wrap word \
-font $Info(entryFont) \
-xscrollcommand [list $m.xscroll set] \
-yscrollcommand [list $m.yscroll set] ]
scrollbar $m.xscroll -orient horizontal -command [list $wdg xview]
scrollbar $m.yscroll -orient vertical -command [list $wdg yview]
set TclCommand(cmdOutputWidget,$id) $wdg
pack $m.xscroll -side bottom -fill x
pack $m.yscroll -side right -fill y
pack $wdg -side left -fill both -expand true
# Command entry widget
# ====================
set m $w.fE
set wdg [entry $m.cmdEntry -width 45 -textvariable TclCommand(cmd,$id) -font $Info(entryFont)]
set TclCommand(cmdWidget,$id) $wdg
focus $wdg
bind $wdg <Control-x> "TclCommand::panelOk $id $winName"
bind $wdg <Control-c> "tclCommandOutputClear $id"
bind $wdg <KeyPress-Return> "tclCommandEval $id 1"
bind $wdg <Control-Return> "tclCommandEval $id 0"
bind $wdg <Control-t> "tclCommandCmdClear $id"
bind $wdg <Control-d> "tclCommandCmdDelete $id"
bind $wdg <Control-r> "tclCommandCmdReset $id 1"
bind $wdg <Control-R> "tclCommandCmdReset $id 2"
bind $wdg <Up> "tclCommandCmdUp $id"
bind $wdg <Down> "tclCommandCmdDown $id"
bind $wdg <Double-1> "tclCommandCmdUp $id; $TclCommand(cmdWidget,$id) selection clear"
bind $wdg <Control-1> "tclCommandEval $id 1"
bind $wdg <Double-3> "tclCommandCmdDown $id; $TclCommand(cmdWidget,$id) selection clear"
pack $wdg -side left -fill both -expand true
# Buttons
# =======
#-Ok button
set ok_btn [button $w.fB.ok -text OK -command "TclCommand::panelOk $id $winName"]
#-Clear button
set clear_btn [button $w.fB.clear -text "Clear out" -command "tclCommandOutputClear $id"]
#-Reset button
set reset_btn [button $w.fB.reset -text Reset -command "tclCommandCmdReset $id"]
#focus $ok_btn
pack $ok_btn $reset_btn $clear_btn -side left -anchor c
pack $w.fT $w.fE $w.fB -side top -expand 1 -fill x -padx 10 -pady 10
}
# Dummy proc
proc TclCommand::panelOk {id w} {
global TclCommand
#unset TclCommand(cmd,$id)
destroy $w
}
proc tclCommandOutputClear {id} {
global TclCommand
$TclCommand(cmdOutputWidget,$id) delete 0.0 end
}
proc tclCommandCmdReset {id {level 1}} {
global TclCommand
# Clear command list
set TclCommand(cmdList,$id) ""
set TclCommand(cmdListIndex,$id) -1
if { $level < 2 } {
return
}
# Clear command entry
tclCommandCmdClear $id
# Clear output
tclCommandOutputClear $id
}
proc tclCommandCmdClear {id} {
global TclCommand
set TclCommand(cmd,$id) ""
}
proc tclCommandCmdDelete {id} {
global TclCommand
set tmp $TclCommand(cmdList,$id)
set idx $TclCommand(cmdListIndex,$id)
set TclCommand(cmdList,$id) [lreplace $tmp $idx $idx]
tclCommandCmdUp $id
}
proc tclCommandCmdUp {id} {
global TclCommand
if { $TclCommand(cmdListIndex,$id) > 0 } {
incr TclCommand(cmdListIndex,$id) -1
}
set idx $TclCommand(cmdListIndex,$id)
set tmp [lindex $TclCommand(cmdList,$id) $idx]
set TclCommand(cmd,$id) $tmp
}
proc tclCommandCmdDown {id} {
global TclCommand
if { $TclCommand(cmdListIndex,$id) < \
[expr [llength $TclCommand(cmdList,$id)] - 1]
} {
incr TclCommand(cmdListIndex,$id)
}
set idx $TclCommand(cmdListIndex,$id)
set tmp [lindex $TclCommand(cmdList,$id) $idx]
set TclCommand(cmd,$id) $tmp
}
proc tclCommandEval {id {add_to_list 1} } {
global TclCommand
$TclCommand(cmdWidget,$id) selection clear
set TclCommand(cmd,$id) [string trim $TclCommand(cmd,$id)]
if { $TclCommand(cmd,$id) == "" } {
return
}
if { [catch { set eval_res [eval "$TclCommand(cmd,$id)" ] } msg] } {
set res $msg
} else {
set res $eval_res
}
append show_res "*** $TclCommand(cmd,$id) "
if { $res == "" } {
append show_res "no result"
} else {
append show_res "$res"
}
append show_res "\n"
$TclCommand(cmdOutputWidget,$id) insert end $show_res
$TclCommand(cmdOutputWidget,$id) see end
if { !$add_to_list } {
return
}
lappend TclCommand(cmdList,$id) $TclCommand(cmd,$id)
set TclCommand(cmdListIndex,$id) [llength $TclCommand(cmdList,$id)]
incr TclCommand(cmdListIndex,$id) -1
}
# Print array variable info
#
proc print_array_info { arr pattern print_values } {
global $arr
upvar #0 $arr theArr
if { ![array exists $arr] } {
return "array does not exist!"
}
if { $pattern == "" } {
set values [array get $arr]
} else {
set values [array get $arr $pattern]
}
set array_rows ""
set len [llength $values]
set counter 0
while { $counter < $len } {
set pair ""
lappend pair [lindex $values $counter]; incr counter
lappend pair [lindex $values $counter]; incr counter
lappend array_rows $pair
}
set array_rows [lsort $array_rows]
set len [llength $array_rows]
append result " ($len elements)\n"
foreach row $array_rows {
# Name
set res [lindex $row 0]
# Value
if {$print_values} {
append res " = "
set val [lindex $row 1]
if { $val != "" } {
append res $val
}
}
append res "\n"
append result $res
}
return $result
}
# Command window Tcl utiliy commands
#
# ===================================================================
# pv: print variable ( var [component] ) #
# an: print names in a array ( arrayname [varpattern]) #
# pa: print array names and their values ( arrayname [varpattern]) #
# ===================================================================
# Print global variable "part1"
# If "part2" given, we have an array!
#
proc pv { part1 { part2 ""} } {
upvar #0 $part1 thePart1
append result "\n"
if { $part2 == "" } {
append result $thePart1
} else {
append result $thePart1($part2)
}
return $result
}
# Print array names
#
proc an { arr {pattern ""} } {
print_array_info $arr $pattern 0
}
# Print array names and values
#
proc pa { arr {pattern ""} } {
print_array_info $arr $pattern 1
}
# Output linefeed
#
proc lf {} {
return "\n"
}
# Get array field property
#
proc gfp {globArray fld prop {sys_index ""} } {
return [DataField::getFieldProperty $globArray $fld $prop $sys_index]
}
# Show current stack till level "depth"
#
proc showStack { {depth 12} } {
global Info
if { !$Info(ELMER_FRONT_DEBUG_TCL_PRINT) } {
return
}
set trc "Level 1"
foreach lvl {-1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12} {
if { ![catch {set trc [info level $lvl] }] } {
MSG "$lvl: $trc"
}
if {$depth == -$lvl} {
break
}
}
MSG "$trc"
}
# Set write-trace for an array field
#
proc setTrace {globArray fld} {
upvar #0 $globArray theArray
trace variable theArray($fld) w _trace
}
# Remove op-type trace for an array field
#
proc removeTrace {globArray fld {op "w"} } {
upvar #0 $globArray theArray
trace vdelete theArray($fld) $op _trace
}
# Tracing proc for an array field tracing
# n1 array name
# n2 field name
# op traced operation (w(rite), r(ead))
#
proc _trace {n1 n2 op} {
upvar #0 $n1 theArr
MSG "----"
set val "?"
catch {set val $theArr($n2) }
MSG "$n1\($n2\) \[$op\]: \[val=$val\]"
foreach lvl {-1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12} {
if { ![catch {set trc [info level $lvl] }] } {
MSG "$lvl: $trc"
}
}
MSG "----"
}
# end ecif_tk_rendererInfoPanel.tcl
# ********************
|