/usr/share/oce-0.18/src/DrawResources/DrawTK.tcl is in oce-draw 0.18.2-2build1.
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 | # Copyright (c) 1999-2014 OPEN CASCADE SAS
#
# This file is part of Open CASCADE Technology software library.
#
# This library is free software; you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License version 2.1 as published
# by the Free Software Foundation, with special exception defined in the file
# OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
# distribution for complete text of the license and disclaimer of any warranty.
#
# Alternatively, this file may be used under the terms of Open CASCADE
# commercial license or contractual agreement.
#
# TK features for Draw
#
# reload bindings
if { [info exists tk_library] } {
set version [split [info tclversion] "."]
set major [lindex ${version} 0]
set minor [lindex ${version} 1]
if { (${major} > 8) || (${major} >= 8 && ${minor} >= 4) } {
#source $tk_library/tk.tcl
} else {
source $tk_library/tk.tcl
}
}
#fills menu "Load" with submenus
proc fillloadmenu {} {
set chan [open [file nativename $::env(CASROOT)/src/DrawResources/DrawPlugin]]
while {[gets $chan line] >= 0} {
if {[lindex [split $line ""] 0] != "!"} {
if {[lindex [split $line ""] 0] == ""} {continue}
set plugname [lindex [split $line " "] 0]
addmenu Load "pload $plugname" "pload $plugname"
}
}
close $chan
}
wm geometry . +10+10
bind . <F1> {vcommands}
frame .mbar -relief raised -bd 2
pack .mbar -side top -fill x
focus .mbar
set theMenus("") ""
set Draw_MenuIndex 0
proc addmenuitem {menu options} {
global theMenus Draw_MenuIndex
if {![info exists theMenus($menu)]} {
incr Draw_MenuIndex
set m .mbar.m$Draw_MenuIndex.menu
menubutton .mbar.m$Draw_MenuIndex -text $menu -menu $m
pack .mbar.m$Draw_MenuIndex -side left
menu $m
set theMenus($menu) $m
} else {set m $theMenus($menu)}
eval $m add $options
}
proc addmenu {menu submenu {command ""}} {
if {$command == ""} {set command $submenu}
addmenuitem $menu "command -label {$submenu} -command {$command}"
}
#################################
# Menus definition
#################################
# the file menu
addmenu File "Choose Data Directory" vdatadir
addmenu File "Load Shape (restore)" vrestore
addmenu File "Load Script (source)" vsource
addmenu File Exit exit
# the Load menu
fillloadmenu
# the view menu
addmenu Views axo {smallview AXON}
addmenu Views top {smallview +X+Y}
addmenu Views front {smallview +X+Z}
addmenu Views left {smallview +Y+Z}
addmenu Views 2d {smallview -2D-}
addmenuitem Views "separator"
addmenu Views mu4
addmenu Views av2d
addmenu Views axo
addmenu Views pers
# the display menu
addmenu Display fit "fit; repaint"
addmenu Display 2dfit "2dfit; repaint"
addmenu Display clear
addmenu Display 2dclear
# the samples menu
addmenu Samples "View samples" vsample
# the help menu
addmenu Help "System Info" sysinfo
addmenu Help Commands vcommands
addmenu Help About about
addmenu Help "User Guide" openuserguide
#redraw help submenu in the end of menu
proc redrawhelp {} {
global theMenus
set m $theMenus(Help)
destroy [string trimright $m ".menu"]
if [info exists theMenus(Help)] {unset theMenus(Help)}
addmenu Help "System Info" sysinfo
addmenu Help Commands vcommands
addmenu Help About about
addmenu Help "User Guide" openuserguide
}
#################################
# Modal dialog box
# add OK, help, cancel buttons
#################################
proc modaldialog {box okproc {helpproc ""} {cancelproc ""}} {
wm geometry $box +10+60
button $box.ok -text ok -command "$okproc ; destroy $box"
pack $box.ok -side left
button $box.ko -text Cancel -command "$cancelproc ; destroy $box"
pack $box.ko -side right
if {$helpproc != ""} {
button $box.help -text Help -command $helpproc
pack $box.help -side right
}
grab set $box
}
#################################
# File menu procedures
#################################
##############################
#
# dialbox command arg1 val1 arg2 val2 ...
#
##############################
proc dialbox args {
set com [lindex $args 0]
toplevel .d
wm title .d $com
# com will be the command
set com "eval $com"
# create entries for the arguments
set n [llength $args]
for {set i 1} {$i < $n} {incr i 2} {
frame .d.a$i
label .d.a$i.l -text [lindex $args $i]
entry .d.a$i.e -relief sunken
.d.a$i.e insert end [lindex $args [expr $i+1]]
pack .d.a$i.l -side left
pack .d.a$i.e -side right
pack .d.a$i -side top -fill x
append com { [} ".d.a$i.e get" {]}
}
append com ";repaint"
modaldialog .d $com "help [lindex $args 0]"
}
proc sdatadir {d} {
global Draw_DataDir
set Draw_DataDir $d
}
proc vdatadir {} {
global Draw_DataDir
sdatadir [tk_chooseDirectory -title "Data Directory" -initialdir $Draw_DataDir]
}
proc rresto {f} {
if {[file exists $f]} {
if {! [file isdirectory $f]} {
puts "restore $f [file tail $f]"
uplevel \#0 "restore $f [file tail $f]"
repaint
}
}
}
proc vrestore {} {
global Draw_DataDir
rresto [tk_getOpenFile -title "Load Shape (restore)" -filetypes {{{BREP} {.brep}}} -initialdir $Draw_DataDir]
}
proc ssour {f} {
global Draw_Source
if {[file exists $f]} {
set Draw_Source $f
if {! [file isdirectory $f]} {
puts "source $f [file tail $f]"
uplevel \#0 "source $f"
}
}
}
set Draw_Source [pwd]
proc vsource {} {
global Draw_Source
ssour [tk_getOpenFile -title "Load Script (source)" -filetypes {{{All Files} *}} -initialdir Draw_Source]
}
#Creates a "Samples" window
proc vsamples {} {
#create list {{category} {title} {filename}}
set alistofthree ""
foreach fname [file nativename [glob -path $::env(CASROOT)/samples/tcl/ *]] {
if {[lindex [split $fname "."] end] != "tcl"} {continue}
set chan [open $fname]
set istitlefound 0
while {[gets $chan line] >= 0} {
if {[lindex [split $line " "] 0] == "#Category:"} {
set acategory [string trim [string trimleft $line "#Category: "]]
}
if {[lindex [split $line " "] 0] == "#Title:"} {
set atitle [string trim [string trimleft $line "#Title: "]]
lappend alistofthree $acategory $atitle $fname
incr istitlefound
break
}
}
close $chan
if {$istitlefound == 0} {
lappend alistofthree Other "[lindex [split $fname \\] end]" $fname
}
}
#create window
toplevel .samples
wm title .samples "Samples"
wm geometry .samples +0+0
wm minsize .samples 800 600
frame .samples.right
frame .samples.left
frame .samples.right.textframe
frame .samples.right.botframe
ttk::treeview .samples.left.tree -selectmode browse -yscrollcommand {.samples.left.treescroll set}
pack .samples.left.tree -fill both -expand 1 -side left
.samples.left.tree column #0 -minwidth 200
.samples.left.tree heading #0 -text "Samples"
pack .samples.right -side right -fill both -expand 1 -padx 10 -pady 10
pack .samples.left -side left -padx 10 -pady 10 -fill both
pack .samples.right.textframe -side top -fill both -expand 1
pack .samples.right.botframe -side bottom -fill both -expand 1
text .samples.right.textframe.text -yscrollcommand {.samples.right.textframe.scroll set} -xscrollcommand {.samples.right.botframe.scrollx set} -wrap none -width 40 -height 32
pack .samples.right.textframe.text -fill both -side left -expand 1
.samples.right.textframe.text delete 0.0 end
.samples.right.textframe.text configure -state disabled
set i 1
foreach {acat title fnam} $alistofthree {
if [.samples.left.tree exists $acat] {
.samples.left.tree insert $acat end -id $title -text $title -tags "selected$i"
.samples.left.tree tag bind selected$i <1> "fillsampletext {$fnam}"
incr i
continue
} else {
.samples.left.tree insert {} end -id $acat -text $acat
.samples.left.tree insert $acat end -id $title -text $title -tags "selected$i"
.samples.left.tree tag bind selected$i <1> "fillsampletext {$fnam}"
incr i
}
}
scrollbar .samples.right.textframe.scroll -command {.samples.right.textframe.text yview}
scrollbar .samples.left.treescroll -command {.samples.left.tree yview}
scrollbar .samples.right.botframe.scrollx -command {.samples.right.textframe.text xview} -orient horizontal
pack .samples.right.textframe.scroll -side right -fill y
pack .samples.right.botframe.scrollx -side top -fill x
pack .samples.left.treescroll -side right -fill y
button .samples.right.botframe.button -text "Run sample" -state disabled
pack .samples.right.botframe.button -fill none -pady 10
}
#Fills the textbox in "Samples" window
proc fillsampletext {fname} {
.samples.right.botframe.button configure -state normal -command "lower .samples;catch {vclose ALL};catch {vremove -all}; catch {vclear}; source {$fname}"
.samples.right.textframe.text configure -state normal
.samples.right.textframe.text delete 0.0 end
set chan [open "$fname"]
while {[gets $chan line] >= 0} {
.samples.right.textframe.text insert end "$line\n"
}
close $chan
.samples.right.textframe.text configure -state disabled
}
#Creates a "Commands help" window
proc vcommands {} {
global Draw_Groups Find_Button_Click_Count Entry_Cache
set Find_Button_Click_Count 0
set Entry_Cache ""
toplevel .commands
focus .commands
wm minsize .commands 800 600
wm title .commands "Commands help"
wm geometry .commands +0+0
frame .commands.t
frame .commands.left
ttk::treeview .commands.left.tree -selectmode browse -yscrollcommand {.commands.left.treescroll set}
.commands.left.tree column #0 -width 300
.commands.left.tree heading #0 -text "Help treeview"
pack .commands.left.tree -expand 1 -fill both -side left
pack .commands.t -side right -fill both -expand 1 -padx 10 -pady 10
pack .commands.left -side left -fill both -padx 10 -pady 10
pack [frame .commands.t.top] -side top -fill x -padx 10 -pady 10
text .commands.t.text -yscrollcommand {.commands.t.scroll set} -width 40
.commands.t.text delete 0.0 end
pack .commands.t.text -fill both -side left -expand 1
.commands.t.text configure -state disabled
pack [entry .commands.t.top.e -width 20] -side left
pack [button .commands.t.top.findcom -text "Find command" -command vhelpsearch] -side left -padx 10
pack [button .commands.t.top.textfind -text "Find in text" -command "vhelptextsearch; incr Find_Button_Click_Count"] -side left
set i 1
set j 100
set newgroupinx 0
foreach h [lsort [array names Draw_Groups]] {
.commands.left.tree insert {} end -id $i -text $h -tags "info$i"
.commands.left.tree tag bind info$i <1> "vcomhelp {$h}"
set newgroupinx $j
foreach f [lsort $Draw_Groups($h)] {
.commands.left.tree insert $i end -id $j -text $f -tags "selected$j"
.commands.left.tree tag bind selected$j <1> "vcomhelp {$h} $j $newgroupinx"
incr j
}
incr i
}
scrollbar .commands.t.scroll -command {.commands.t.text yview}
scrollbar .commands.left.treescroll -command {.commands.left.tree yview}
pack .commands.t.scroll -side right -fill y
pack .commands.left.treescroll -side right -fill y -expand 1
#hotkeys
bind .commands.t.top.e <Return> {vhelpsearch}
bind .commands <Control-f> {focus .commands.t.top.e}
bind .commands <Control-F> {focus .commands.t.top.e}
bind .commands <Escape> {destroy .commands}
}
############################################################
# Fills the textbox in "Commands help" window
# $h -group of commands to display
# $selindex - index of selected item in the treeview
# $startindex - index of item int the treeview to start from
############################################################
proc vcomhelp {h {selindex -1} {startindex 0}} {
global Draw_Helps Draw_Groups
set highlighted false
.commands.t.text configure -state normal
.commands.t.text delete 1.0 end
foreach f [lsort $Draw_Groups($h)] {
if {$startindex == $selindex} {
.commands.t.text insert end "$f : $Draw_Helps($f)\n\n" "highlightline"
incr startindex
set highlighted true
continue
}
.commands.t.text insert end "$f : $Draw_Helps($f)\n\n"
incr startindex
}
.commands.t.text tag configure highlightline -background yellow -relief raised
.commands.t.text configure -state disabled
if {$highlighted == true} {.commands.t.text see highlightline.last}
}
#Creates a "About" window
proc about {} {
toplevel .about
focus .about
wm resizable .about 0 0
wm title .about "About"
set screenheight [expr {int([winfo screenheight .]*0.5-200)}]
set screenwidth [expr {int([winfo screenwidth .]*0.5-200)}]
wm geometry .about 400x200+$screenwidth+$screenheight
image create photo occlogo -file $::env(CASROOT)/src/DrawResources/OCC_logo.png -format png
frame .about.logo -bg red
frame .about.links -bg blue
frame .about.copyright
pack .about.logo -side top -fill both
pack .about.links -fill both
pack .about.copyright -side top -fill both
label .about.logo.img -image occlogo
pack .about.logo.img -fill both
text .about.links.text -bg lightgray -fg blue -height 1 -width 10
.about.links.text insert end "http://www.opencascade.com/" "link1"
.about.links.text tag bind link1 <1> "_launchBrowser http://www.opencascade.com/"
.about.links.text tag bind link1 <Enter> ".about.links.text configure -cursor hand2"
.about.links.text tag bind link1 <Leave> ".about.links.text configure -cursor arrow"
.about.links.text tag configure link1 -underline true -justify center
pack .about.links.text -fill both
label .about.copyright.text -text "Copyright (c) 1999-2014 OPEN CASCADE SAS"
button .about.button -text "OK" -command "destroy .about"
pack .about.button -padx 10 -pady 10
pack .about.copyright.text
.about.links.text configure -state disabled
grab .about
bind .about <Return> {destroy .about}
}
#Executes files and hyperlinks
proc launchBrowser url {
global tcl_platform
if {$tcl_platform(platform) eq "windows"} {
set command [list {*}[auto_execok start] {}]
} elseif {$tcl_platform(os) eq "Darwin"} {
set command [list open]
} else {
set command [list xdg-open]
}
exec {*}$command $url &
}
#Safe execution of files and hyperlinks
proc _launchBrowser {url} {
if [catch {launchBrowser $url} err] {
tk_messageBox -icon error -message "error '$err' with '$command'"
}
}
################################################################
# This procedure tries to open an userguide on Draw Harness in pdf format
# If there is no a such one, then tries to open it in html format
# Else opens a site with this guide
################################################################
proc openuserguide {} {
if [file exists $::env(CASROOT)/doc/pdf/user_guides/occt_test_harness.pdf] {
_launchBrowser $::env(CASROOT)/doc/pdf/user_guides/occt_test_harness.pdf
} elseif [file exists $::env(CASROOT)/doc/overview/html/occt_user_guides__test_harness.html] {
_launchBrowser $::env(CASROOT)/doc/overview/html/occt_user_guides__test_harness.html
} else {
_launchBrowser {http://dev.opencascade.org/doc/overview/html/occt_user_guides__test_harness.html}
}
}
#Search through commands and display the result
proc vhelpsearch {} {
global Draw_Groups Entry_Cache
set searchstring [.commands.t.top.e get]
set i 1
set j 100
set newgroupinx 0
set isfound 0
foreach h [lsort [array names Draw_Groups]] {
set newgroupinx $j
foreach f [lsort $Draw_Groups($h)] {
if {$f == $searchstring} {
incr isfound
.commands.left.tree see $j
.commands.left.tree selection set $j
vcomhelp $h $j $newgroupinx
break
}
incr j
}
incr i
}
if {$isfound == 0} {
errorhelp "No help found for '$searchstring'!"
} else {set Entry_Cache ""}
}
#Displays an error window with $errstring inside
proc errorhelp {errstring} {
toplevel .errorhelp
focus .errorhelp
wm resizable .errorhelp 0 0
wm title .errorhelp "Error"
set screenheight [expr {int([winfo screenheight .]*0.5-200)}]
set screenwidth [expr {int([winfo screenwidth .]*0.5-200)}]
wm geometry .errorhelp +$screenwidth+$screenheight
text .errorhelp.t -width 40 -height 5
.errorhelp.t insert end $errstring
button .errorhelp.button -text "OK" -command "destroy .errorhelp"
pack .errorhelp.t
.errorhelp.t configure -state disabled
pack .errorhelp.button -padx 10 -pady 10
bind .errorhelp <Return> {destroy .errorhelp}
grab .errorhelp
}
#Search through text of help and display the result
proc vhelptextsearch {} {
global Draw_Helps Draw_Groups Find_Button_Click_Count Entry_Cache End_of_Search
set searchstring [.commands.t.top.e get]
if {$Entry_Cache != $searchstring} {
set Find_Button_Click_Count 0
set End_of_Search 0
set Entry_Cache $searchstring
}
if {$End_of_Search} {
errorhelp "No more '$searchstring' found!"
return
}
.commands.t.text configure -state normal
.commands.t.text delete 0.0 end
set i 0
set isfound 0
foreach h [lsort [array names Draw_Groups]] {
foreach f [lsort $Draw_Groups($h)] {
if [string match *$searchstring* $Draw_Helps($f)] {
incr i
if {$i > $Find_Button_Click_Count+1} {incr isfound; break}
.commands.t.text insert end "$f : "
foreach line [list $Draw_Helps($f)] {
foreach word [split $line " "] {
if [string match *$searchstring* $word] {
.commands.t.text insert end "$word" "highlightword"
.commands.t.text insert end " "
continue
}
.commands.t.text insert end "$word "
}
}
.commands.t.text insert end \n\n
}
}
}
if {!$isfound} {
incr End_of_Search
}
.commands.t.text tag configure highlightword -background yellow -relief raised
.commands.t.text see end
}
#Create a "System information" window
proc sysinfo {} {
toplevel .info
wm title .info "System information"
wm resizable .info 0 0
pack [frame .info.top] -side top -fill both -padx 5 -pady 10
pack [frame .info.bot] -side bottom -fill both -padx 5 -pady 10
pack [frame .info.top.left] -side left -fill both -padx 5 -pady 10
pack [frame .info.top.mid] -side left -fill both -padx 5 -pady 10
pack [frame .info.top.right] -side left -fill both -padx 5 -pady 10
pack [label .info.top.left.label -text "OCCT build configuration "]
pack [label .info.top.mid.label -text "Memory info"]
pack [label .info.top.right.label -text "OpenGL info"]
pack [text .info.top.left.text -width 50 -height 20]
pack [text .info.top.mid.text -width 50 -height 20]
pack [text .info.top.right.text -width 50 -height 20]
pack [button .info.bot.button -text "Update" -command rescaninfo]
pack [button .info.bot.close -text "Close" -command "destroy .info"] -pady 10
rescaninfo
}
#Updates information in "System information" window
proc rescaninfo {} {
.info.top.left.text configure -state normal
.info.top.mid.text configure -state normal
.info.top.right.text configure -state normal
.info.top.left.text delete 0.0 end
.info.top.mid.text delete 0.0 end
.info.top.right.text delete 0.0 end
.info.top.left.text insert end [dversion]
.info.top.mid.text insert end [meminfo]
set glinfo ""
if [catch {vglinfo} err] {
if {$err == ""} {
.info.top.right.text insert end "No active view. Please call vinit."
} else {
.info.top.right.text insert end "VISUALIZATION is not loaded. Please call pload VISUALIZATION"
}
} else {
.info.top.right.text insert end [vglinfo]
}
.info.top.left.text configure -state disabled
.info.top.mid.text configure -state disabled
.info.top.right.text configure -state disabled
}
|