DrawTK.tcl 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  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. #
  14. # TK features for Draw
  15. #
  16. # reload bindings
  17. if { [info exists tk_library] } {
  18. set version [split [info tclversion] "."]
  19. set major [lindex ${version} 0]
  20. set minor [lindex ${version} 1]
  21. if { (${major} > 8) || (${major} >= 8 && ${minor} >= 4) } {
  22. #source $tk_library/tk.tcl
  23. } else {
  24. source $tk_library/tk.tcl
  25. }
  26. }
  27. #fills menu "Load" with submenus
  28. proc fillloadmenu {} {
  29. set drawplugpath ""
  30. if {[array names ::env CSF_OCCTResourcePath] != "" && "$::env(CSF_OCCTResourcePath)" != "" && [file exists $::env(CSF_OCCTResourcePath)/DrawResources/DrawPlugin]} {
  31. set drawplugpath "$::env(CSF_OCCTResourcePath)/DrawResources/DrawPlugin"
  32. } elseif {[array names ::env CASROOT] != "" && "$::env(CASROOT)" != "" && [file exists $::env(CASROOT)/src/DrawResources/DrawPlugin]} {
  33. set drawplugpath "$::env(CASROOT)/src/DrawResources/DrawPlugin"
  34. }
  35. set chan [open [file nativename $drawplugpath]]
  36. while {[gets $chan line] >= 0} {
  37. if {[lindex [split $line ""] 0] != "!"} {
  38. if {[lindex [split $line ""] 0] == ""} {continue}
  39. set plugname [lindex [split $line " "] 0]
  40. addmenu Load "pload $plugname" "pload $plugname"
  41. }
  42. }
  43. close $chan
  44. }
  45. wm geometry . +10+10
  46. bind . <F1> {vcommands}
  47. frame .mbar -relief raised -bd 2
  48. pack .mbar -side top -fill x
  49. focus .mbar
  50. set theMenus("") ""
  51. set Draw_MenuIndex 0
  52. proc addmenuitem {menu options} {
  53. global theMenus Draw_MenuIndex
  54. if {![info exists theMenus($menu)]} {
  55. incr Draw_MenuIndex
  56. set m .mbar.m$Draw_MenuIndex.menu
  57. menubutton .mbar.m$Draw_MenuIndex -text $menu -menu $m
  58. pack .mbar.m$Draw_MenuIndex -side left
  59. menu $m
  60. set theMenus($menu) $m
  61. } else {set m $theMenus($menu)}
  62. eval $m add $options
  63. }
  64. proc addmenu {menu submenu {command ""}} {
  65. if {$command == ""} {set command $submenu}
  66. addmenuitem $menu "command -label {$submenu} -command {$command}"
  67. }
  68. #################################
  69. # Menus definition
  70. #################################
  71. # the file menu
  72. addmenu File "Choose Data Directory" vdatadir
  73. addmenu File "Load Shape (restore)" vrestore
  74. addmenu File "Load Script (source)" vsource
  75. addmenu File Exit exit
  76. # the Load menu
  77. fillloadmenu
  78. # the view menu
  79. source [file join $dir Move.tcl]
  80. addmenuitem Views {checkbutton -label "Extended view commands" \
  81. -command ShowHideExtCommands -variable ShowExtCommands -onvalue 1 -offvalue 0}
  82. addmenuitem Views "separator"
  83. addmenu Views axo {smallview AXON}
  84. addmenu Views top {smallview +X+Y}
  85. addmenu Views front {smallview +X+Z}
  86. addmenu Views left {smallview +Y+Z}
  87. addmenu Views 2d {smallview -2D-}
  88. addmenuitem Views "separator"
  89. addmenu Views mu4
  90. addmenu Views av2d
  91. addmenu Views axo
  92. addmenu Views pers
  93. # the display menu
  94. addmenu Display fit "fit; repaint"
  95. addmenu Display 2dfit "2dfit; repaint"
  96. addmenu Display clear
  97. addmenu Display 2dclear
  98. # the samples menu
  99. addmenu Samples "View samples" vsample
  100. # the help menu
  101. addmenu Help "System Info" sysinfo
  102. addmenu Help Commands vcommands
  103. addmenu Help About about
  104. addmenu Help "User Guide" openuserguide
  105. #redraw help submenu in the end of menu
  106. proc redrawhelp {} {
  107. global theMenus
  108. set m $theMenus(Help)
  109. destroy [string trimright $m ".menu"]
  110. if [info exists theMenus(Help)] {unset theMenus(Help)}
  111. addmenu Help "System Info" sysinfo
  112. addmenu Help Commands vcommands
  113. addmenu Help About about
  114. addmenu Help "User Guide" openuserguide
  115. }
  116. #################################
  117. # Modal dialog box
  118. # add OK, help, cancel buttons
  119. #################################
  120. proc modaldialog {box okproc {helpproc ""} {cancelproc ""}} {
  121. wm geometry $box +10+60
  122. button $box.ok -text ok -command "$okproc ; destroy $box"
  123. pack $box.ok -side left
  124. button $box.ko -text Cancel -command "$cancelproc ; destroy $box"
  125. pack $box.ko -side right
  126. if {$helpproc != ""} {
  127. button $box.help -text Help -command $helpproc
  128. pack $box.help -side right
  129. }
  130. grab set $box
  131. }
  132. #################################
  133. # File menu procedures
  134. #################################
  135. ##############################
  136. #
  137. # dialbox command arg1 val1 arg2 val2 ...
  138. #
  139. ##############################
  140. proc dialbox args {
  141. set com [lindex $args 0]
  142. toplevel .d
  143. wm title .d $com
  144. # com will be the command
  145. set com "eval $com"
  146. # create entries for the arguments
  147. set n [llength $args]
  148. for {set i 1} {$i < $n} {incr i 2} {
  149. frame .d.a$i
  150. label .d.a$i.l -text [lindex $args $i]
  151. entry .d.a$i.e -relief sunken
  152. .d.a$i.e insert end [lindex $args [expr $i+1]]
  153. pack .d.a$i.l -side left
  154. pack .d.a$i.e -side right
  155. pack .d.a$i -side top -fill x
  156. append com { [} ".d.a$i.e get" {]}
  157. }
  158. append com ";repaint"
  159. modaldialog .d $com "help [lindex $args 0]"
  160. }
  161. proc sdatadir {d} {
  162. global Draw_DataDir
  163. set Draw_DataDir $d
  164. }
  165. proc vdatadir {} {
  166. global Draw_DataDir
  167. sdatadir [tk_chooseDirectory -title "Data Directory" -initialdir $Draw_DataDir]
  168. }
  169. proc rresto {f} {
  170. if {[file exists $f]} {
  171. if {! [file isdirectory $f]} {
  172. puts "restore $f [file tail $f]"
  173. uplevel \#0 "restore $f [file tail $f]"
  174. repaint
  175. }
  176. }
  177. }
  178. proc vrestore {} {
  179. global Draw_DataDir
  180. rresto [tk_getOpenFile -title "Load Shape (restore)" -filetypes {{{BREP} {.brep}}} -initialdir $Draw_DataDir]
  181. }
  182. proc ssour {f} {
  183. global Draw_Source
  184. if {[file exists $f]} {
  185. set Draw_Source $f
  186. if {! [file isdirectory $f]} {
  187. puts "source $f [file tail $f]"
  188. uplevel \#0 "source $f"
  189. }
  190. }
  191. }
  192. set Draw_Source [pwd]
  193. proc vsource {} {
  194. global Draw_Source
  195. ssour [tk_getOpenFile -title "Load Script (source)" -filetypes {{{All Files} *}} -initialdir Draw_Source]
  196. }
  197. #Creates a "Samples" window
  198. proc vsamples {} {
  199. #create list {{category} {title} {filename}}
  200. set alistofthree ""
  201. set samplespath ""
  202. if { [array names ::env CSF_OCCTSamplesPath] != "" && "$::env(CSF_OCCTSamplesPath)" != "" && [file exists $::env(CSF_OCCTSamplesPath)/tcl/]} {
  203. set samplespath "$::env(CSF_OCCTSamplesPath)/tcl/"
  204. } elseif { [array names ::env CASROOT] != "" && "$::env(CASROOT)" != "" && [file exists $::env(CASROOT)/samples/tcl/]} {
  205. set samplespath "$::env(CASROOT)/samples/tcl/"
  206. }
  207. foreach fname [glob -path "${samplespath}" *.tcl] {
  208. set chan [open $fname]
  209. set istitlefound 0
  210. while {[gets $chan line] >= 0} {
  211. if {[lindex [split $line " "] 0] == "#Category:"} {
  212. set acategory [string trim [string trimleft $line "#Category: "]]
  213. }
  214. if {[lindex [split $line " "] 0] == "#Title:"} {
  215. set atitle [string trim [string trimleft $line "#Title: "]]
  216. lappend alistofthree $acategory $atitle $fname
  217. incr istitlefound
  218. break
  219. }
  220. }
  221. close $chan
  222. if {$istitlefound == 0} {
  223. lappend alistofthree Other "[lindex [split $fname \\] end]" $fname
  224. }
  225. }
  226. #create window
  227. toplevel .samples
  228. wm title .samples "Samples"
  229. wm geometry .samples +0+0
  230. wm minsize .samples 800 600
  231. frame .samples.right
  232. frame .samples.left
  233. frame .samples.right.textframe
  234. frame .samples.right.botframe
  235. ttk::treeview .samples.left.tree -selectmode browse -yscrollcommand {.samples.left.treescroll set}
  236. pack .samples.left.tree -fill both -expand 1 -side left
  237. .samples.left.tree column #0 -minwidth 200
  238. .samples.left.tree heading #0 -text "Samples"
  239. pack .samples.right -side right -fill both -expand 1 -padx 10 -pady 10
  240. pack .samples.left -side left -padx 10 -pady 10 -fill both
  241. pack .samples.right.textframe -side top -fill both -expand 1
  242. pack .samples.right.botframe -side bottom -fill both -expand 1
  243. text .samples.right.textframe.text -yscrollcommand {.samples.right.textframe.scroll set} -xscrollcommand {.samples.right.botframe.scrollx set} -wrap none -width 40 -height 32
  244. pack .samples.right.textframe.text -fill both -side left -expand 1
  245. .samples.right.textframe.text delete 0.0 end
  246. .samples.right.textframe.text configure -state disabled
  247. set i 1
  248. foreach {acat title fnam} $alistofthree {
  249. if [.samples.left.tree exists $acat] {
  250. .samples.left.tree insert $acat end -id $title -text $title -tags "selected$i"
  251. .samples.left.tree tag bind selected$i <1> "fillsampletext {$fnam}"
  252. incr i
  253. continue
  254. } else {
  255. .samples.left.tree insert {} end -id $acat -text $acat
  256. .samples.left.tree insert $acat end -id $title -text $title -tags "selected$i"
  257. .samples.left.tree tag bind selected$i <1> "fillsampletext {$fnam}"
  258. incr i
  259. }
  260. }
  261. scrollbar .samples.right.textframe.scroll -command {.samples.right.textframe.text yview}
  262. scrollbar .samples.left.treescroll -command {.samples.left.tree yview}
  263. scrollbar .samples.right.botframe.scrollx -command {.samples.right.textframe.text xview} -orient horizontal
  264. pack .samples.right.textframe.scroll -side right -fill y
  265. pack .samples.right.botframe.scrollx -side top -fill x
  266. pack .samples.left.treescroll -side right -fill y
  267. button .samples.right.botframe.button -text "Run sample" -state disabled
  268. pack .samples.right.botframe.button -fill none -pady 10
  269. }
  270. #Fills the textbox in "Samples" window
  271. proc fillsampletext {fname} {
  272. .samples.right.botframe.button configure -state normal -command "lower .samples;catch {vclose ALL};catch {vremove -all}; catch {vclear}; source {$fname}"
  273. .samples.right.textframe.text configure -state normal
  274. .samples.right.textframe.text delete 0.0 end
  275. set chan [open "$fname"]
  276. while {[gets $chan line] >= 0} {
  277. .samples.right.textframe.text insert end "$line\n"
  278. }
  279. close $chan
  280. .samples.right.textframe.text configure -state disabled
  281. }
  282. #Creates a "Commands help" window
  283. proc vcommands {} {
  284. global Draw_Groups Find_Button_Click_Count Entry_Cache
  285. set Find_Button_Click_Count 0
  286. set Entry_Cache ""
  287. toplevel .commands
  288. focus .commands
  289. wm minsize .commands 800 600
  290. wm title .commands "Commands help"
  291. wm geometry .commands +0+0
  292. frame .commands.t
  293. frame .commands.left
  294. ttk::treeview .commands.left.tree -selectmode browse -yscrollcommand {.commands.left.treescroll set}
  295. .commands.left.tree column #0 -width 300
  296. .commands.left.tree heading #0 -text "Help treeview"
  297. pack .commands.left.tree -expand 1 -fill both -side left
  298. pack .commands.t -side right -fill both -expand 1 -padx 10 -pady 10
  299. pack .commands.left -side left -fill both -padx 10 -pady 10
  300. pack [frame .commands.t.top] -side top -fill x -padx 10 -pady 10
  301. text .commands.t.text -yscrollcommand {.commands.t.scroll set} -width 40
  302. .commands.t.text delete 0.0 end
  303. pack .commands.t.text -fill both -side left -expand 1
  304. .commands.t.text configure -state disabled
  305. pack [entry .commands.t.top.e -width 20] -side left
  306. pack [button .commands.t.top.findcom -text "Find command" -command vhelpsearch] -side left -padx 10
  307. pack [button .commands.t.top.textfind -text "Find in text" -command "vhelptextsearch; incr Find_Button_Click_Count"] -side left
  308. set i 1
  309. set j 100
  310. set newgroupinx 0
  311. foreach h [lsort [array names Draw_Groups]] {
  312. .commands.left.tree insert {} end -id $i -text $h -tags "info$i"
  313. .commands.left.tree tag bind info$i <1> "vcomhelp {$h}"
  314. set newgroupinx $j
  315. foreach f [lsort $Draw_Groups($h)] {
  316. .commands.left.tree insert $i end -id $j -text $f -tags "selected$j"
  317. .commands.left.tree tag bind selected$j <1> "vcomhelp {$h} $j $newgroupinx"
  318. incr j
  319. }
  320. incr i
  321. }
  322. scrollbar .commands.t.scroll -command {.commands.t.text yview}
  323. scrollbar .commands.left.treescroll -command {.commands.left.tree yview}
  324. pack .commands.t.scroll -side right -fill y
  325. pack .commands.left.treescroll -side right -fill y -expand 1
  326. #hotkeys
  327. bind .commands.t.top.e <Return> {vhelpsearch}
  328. bind .commands <Control-f> {focus .commands.t.top.e}
  329. bind .commands <Control-F> {focus .commands.t.top.e}
  330. bind .commands <Escape> {destroy .commands}
  331. }
  332. ############################################################
  333. # Fills the textbox in "Commands help" window
  334. # $h -group of commands to display
  335. # $selindex - index of selected item in the treeview
  336. # $startindex - index of item int the treeview to start from
  337. ############################################################
  338. proc vcomhelp {h {selindex -1} {startindex 0}} {
  339. global Draw_Helps Draw_Groups
  340. set highlighted false
  341. .commands.t.text configure -state normal
  342. .commands.t.text delete 1.0 end
  343. foreach f [lsort $Draw_Groups($h)] {
  344. if {$startindex == $selindex} {
  345. .commands.t.text insert end "$f : $Draw_Helps($f)\n\n" "highlightline"
  346. incr startindex
  347. set highlighted true
  348. continue
  349. }
  350. .commands.t.text insert end "$f : $Draw_Helps($f)\n\n"
  351. incr startindex
  352. }
  353. .commands.t.text tag configure highlightline -background yellow -relief raised
  354. .commands.t.text configure -state disabled
  355. if {$highlighted == true} {.commands.t.text see highlightline.last}
  356. }
  357. #Creates a "About" window
  358. proc about {} {
  359. toplevel .about
  360. focus .about
  361. wm resizable .about 0 0
  362. wm title .about "About"
  363. set screenheight [expr {int([winfo screenheight .]*0.5-200)}]
  364. set screenwidth [expr {int([winfo screenwidth .]*0.5-200)}]
  365. wm geometry .about 400x200+$screenwidth+$screenheight
  366. set logopath ""
  367. if {[array names ::env CSF_OCCTResourcePath] != "" && "$::env(CSF_OCCTResourcePath)" != "" && [file exists $::env(CSF_OCCTResourcePath)/DrawResources/OCC_logo.png]} {
  368. set logopath "$::env(CSF_OCCTResourcePath)/DrawResources/OCC_logo.png"
  369. } elseif {[array names ::env CASROOT] != "" && "$::env(CASROOT)" != "" && [file exists $::env(CASROOT)/src/DrawResources/OCC_logo.png]} {
  370. set logopath "$::env(CASROOT)/src/DrawResources/OCC_logo.png"
  371. }
  372. image create photo occlogo -file $logopath -format png
  373. frame .about.logo -bg red
  374. frame .about.links -bg blue
  375. frame .about.copyright
  376. pack .about.logo -side top -fill both
  377. pack .about.links -fill both
  378. pack .about.copyright -side top -fill both
  379. label .about.logo.img -image occlogo
  380. pack .about.logo.img -fill both
  381. text .about.links.text -bg lightgray -fg blue -height 1 -width 10
  382. .about.links.text insert end "http://www.opencascade.com/" "link1"
  383. .about.links.text tag bind link1 <1> "_launchBrowser http://www.opencascade.com/"
  384. .about.links.text tag bind link1 <Enter> ".about.links.text configure -cursor hand2"
  385. .about.links.text tag bind link1 <Leave> ".about.links.text configure -cursor arrow"
  386. .about.links.text tag configure link1 -underline true -justify center
  387. pack .about.links.text -fill both
  388. label .about.copyright.text -text "Copyright (c) 1999-2019 OPEN CASCADE SAS"
  389. button .about.button -text "OK" -command "destroy .about"
  390. pack .about.button -padx 10 -pady 10
  391. pack .about.copyright.text
  392. .about.links.text configure -state disabled
  393. grab .about
  394. bind .about <Return> {destroy .about}
  395. }
  396. #Executes files and hyperlinks
  397. proc launchBrowser url {
  398. global tcl_platform
  399. if {$tcl_platform(platform) eq "windows"} {
  400. set command [list {*}[auto_execok start] {}]
  401. } elseif {$tcl_platform(os) eq "Darwin"} {
  402. set command [list open]
  403. } else {
  404. set command [list xdg-open]
  405. }
  406. exec {*}$command $url &
  407. }
  408. #Safe execution of files and hyperlinks
  409. proc _launchBrowser {url} {
  410. if [catch {launchBrowser $url} err] {
  411. tk_messageBox -icon error -message "error '$err' with '$command'"
  412. }
  413. }
  414. ################################################################
  415. # This procedure tries to open an userguide on Draw Harness in pdf format
  416. # If there is no a such one, then tries to open it in html format
  417. # Else opens a site with this guide
  418. ################################################################
  419. proc openuserguide {} {
  420. if { [array names ::env CSF_OCCTDocPath] != "" && "$::env(CSF_OCCTDocPath)" != "" && [file exists $::env(CSF_OCCTDocPath)/pdf/user_guides/occt_test_harness.pdf]} {
  421. _launchBrowser $::env(CSF_OCCTDocPath)/pdf/user_guides/occt_test_harness.pdf
  422. } elseif { [array names ::env CSF_OCCTDocPath] != "" && "$::env(CSF_OCCTDocPath)" != "" && [file exists $::env(CSF_OCCTDocPath)/overview/html/occt_user_guides__test_harness.html]} {
  423. _launchBrowser $::env(CSF_OCCTDocPath)/overview/html/occt_user_guides__test_harness.html
  424. } elseif { [array names ::env CASROOT] != "" && "$::env(CASROOT)" != "" && [file exists $::env(CASROOT)/doc/pdf/user_guides/occt_test_harness.pdf]} {
  425. _launchBrowser $::env(CASROOT)/doc/pdf/user_guides/occt_test_harness.pdf
  426. } elseif { [array names ::env CASROOT] != "" && "$::env(CASROOT)" != "" && [file exists $::env(CASROOT)/doc/overview/html/occt_user_guides__test_harness.html]} {
  427. _launchBrowser $::env(CASROOT)/doc/overview/html/occt_user_guides__test_harness.html
  428. } else {
  429. launchBrowser {http://dev.opencascade.org/doc/overview/html/occt_user_guides__test_harness.html}
  430. }
  431. }
  432. #Search through commands and display the result
  433. proc vhelpsearch {} {
  434. global Draw_Groups Entry_Cache
  435. set searchstring [.commands.t.top.e get]
  436. set i 1
  437. set j 100
  438. set newgroupinx 0
  439. set isfound 0
  440. foreach h [lsort [array names Draw_Groups]] {
  441. set newgroupinx $j
  442. foreach f [lsort $Draw_Groups($h)] {
  443. if {$f == $searchstring} {
  444. incr isfound
  445. .commands.left.tree see $j
  446. .commands.left.tree selection set $j
  447. vcomhelp $h $j $newgroupinx
  448. break
  449. }
  450. incr j
  451. }
  452. incr i
  453. }
  454. if {$isfound == 0} {
  455. errorhelp "No help found for '$searchstring'!"
  456. } else {set Entry_Cache ""}
  457. }
  458. #Displays an error window with $errstring inside
  459. proc errorhelp {errstring} {
  460. toplevel .errorhelp
  461. focus .errorhelp
  462. wm resizable .errorhelp 0 0
  463. wm title .errorhelp "Error"
  464. set screenheight [expr {int([winfo screenheight .]*0.5-200)}]
  465. set screenwidth [expr {int([winfo screenwidth .]*0.5-200)}]
  466. wm geometry .errorhelp +$screenwidth+$screenheight
  467. text .errorhelp.t -width 40 -height 5
  468. .errorhelp.t insert end $errstring
  469. button .errorhelp.button -text "OK" -command "destroy .errorhelp"
  470. pack .errorhelp.t
  471. .errorhelp.t configure -state disabled
  472. pack .errorhelp.button -padx 10 -pady 10
  473. bind .errorhelp <Return> {destroy .errorhelp}
  474. grab .errorhelp
  475. }
  476. #Search through text of help and display the result
  477. proc vhelptextsearch {} {
  478. global Draw_Helps Draw_Groups Find_Button_Click_Count Entry_Cache End_of_Search
  479. set searchstring [.commands.t.top.e get]
  480. if {$Entry_Cache != $searchstring} {
  481. set Find_Button_Click_Count 0
  482. set End_of_Search 0
  483. set Entry_Cache $searchstring
  484. }
  485. if {$End_of_Search} {
  486. errorhelp "No more '$searchstring' found!"
  487. return
  488. }
  489. .commands.t.text configure -state normal
  490. .commands.t.text delete 0.0 end
  491. set i 0
  492. set isfound 0
  493. foreach h [lsort [array names Draw_Groups]] {
  494. foreach f [lsort $Draw_Groups($h)] {
  495. if [string match *$searchstring* $Draw_Helps($f)] {
  496. incr i
  497. if {$i > $Find_Button_Click_Count+1} {incr isfound; break}
  498. .commands.t.text insert end "$f : "
  499. foreach line [list $Draw_Helps($f)] {
  500. foreach word [split $line " "] {
  501. if [string match *$searchstring* $word] {
  502. .commands.t.text insert end "$word" "highlightword"
  503. .commands.t.text insert end " "
  504. continue
  505. }
  506. .commands.t.text insert end "$word "
  507. }
  508. }
  509. .commands.t.text insert end \n\n
  510. }
  511. }
  512. }
  513. if {!$isfound} {
  514. incr End_of_Search
  515. }
  516. .commands.t.text tag configure highlightword -background yellow -relief raised
  517. .commands.t.text see end
  518. }
  519. #Create a "System information" window
  520. proc sysinfo {} {
  521. toplevel .info
  522. wm title .info "System information"
  523. wm resizable .info 0 0
  524. pack [frame .info.top] -side top -fill both -padx 5 -pady 10
  525. pack [frame .info.bot] -side bottom -fill both -padx 5 -pady 10
  526. pack [frame .info.top.left] -side left -fill both -padx 5 -pady 10
  527. pack [frame .info.top.mid] -side left -fill both -padx 5 -pady 10
  528. pack [frame .info.top.right] -side left -fill both -padx 5 -pady 10
  529. pack [label .info.top.left.label -text "OCCT build configuration "]
  530. pack [label .info.top.mid.label -text "Memory info"]
  531. pack [label .info.top.right.label -text "OpenGL info"]
  532. pack [text .info.top.left.text -width 50 -height 20]
  533. pack [text .info.top.mid.text -width 50 -height 20]
  534. pack [text .info.top.right.text -width 50 -height 20]
  535. pack [button .info.bot.button -text "Update" -command rescaninfo]
  536. pack [button .info.bot.close -text "Close" -command "destroy .info"] -pady 10
  537. rescaninfo
  538. }
  539. #Updates information in "System information" window
  540. proc rescaninfo {} {
  541. .info.top.left.text configure -state normal
  542. .info.top.mid.text configure -state normal
  543. .info.top.right.text configure -state normal
  544. .info.top.left.text delete 0.0 end
  545. .info.top.mid.text delete 0.0 end
  546. .info.top.right.text delete 0.0 end
  547. .info.top.left.text insert end [dversion]
  548. .info.top.mid.text insert end [meminfo]
  549. set glinfo ""
  550. if [catch {vglinfo} err] {
  551. if {$err == ""} {
  552. .info.top.right.text insert end "No active view. Please call vinit."
  553. } else {
  554. .info.top.right.text insert end "VISUALIZATION is not loaded. Please call pload VISUALIZATION"
  555. }
  556. } else {
  557. .info.top.right.text insert end [vglinfo]
  558. }
  559. .info.top.left.text configure -state disabled
  560. .info.top.mid.text configure -state disabled
  561. .info.top.right.text configure -state disabled
  562. }