bem_view.tcl 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071
  1. #! /bin/sh
  2. #----------------------------------------------------------------
  3. #
  4. # bem_view.tcl
  5. #
  6. # Displays BEM MMTL results using graphs
  7. #
  8. # Copyright 2002-2004 Mayo Foundation. All Rights Reserved.
  9. # $Id: bem_view.tcl,v 1.3 2004/02/12 22:28:28 techenti Exp $
  10. #
  11. #----------------------------------------------------------------
  12. # restart using wish \
  13. exec wish "$0" "$@"
  14. set auto_path [linsert $auto_path 0 /users/zahn/lib]
  15. package require Itcl
  16. package require BWidget
  17. package require BLT
  18. package require gui
  19. namespace import ::gui::*
  20. package provide bem 1.0
  21. source [file join $env(BEM_LIBRARY) bem_graphs.itcl]
  22. # --------------------------------------------------------------------------
  23. # Starting with Tcl 8.x, the BLT commands are stored in their own
  24. # namespace called "blt". The idea is to prevent name clashes with
  25. # Tcl commands and variables from other packages, such as a "table"
  26. # command in two different packages.
  27. #
  28. # You can access the BLT commands in a couple of ways. You can either
  29. # prefix all the BLT commands with the namespace qualifier "blt:"
  30. #
  31. # blt::graph .g
  32. # blt::table . .g -resize both
  33. #
  34. # or you can import all the command into the global namespace.
  35. #
  36. # namespace import blt::*
  37. # graph .g
  38. # table . .g -resize both
  39. #
  40. # --------------------------------------------------------------------------
  41. if { $tcl_version >= 8.0 } {
  42. namespace import blt::*
  43. namespace import -force blt::tile::*
  44. }
  45. ##################################################################
  46. # Select the results file to display.
  47. ##################################################################
  48. proc _getResultsFile {} {
  49. global infofile
  50. set typelist {
  51. {{information files} {.swept_result .iterate_result} }
  52. {{All Files} * }
  53. }
  54. set infofile [tk_getOpenFile -filetypes $typelist \
  55. -title "swept_results or iterate_results:" \
  56. -initialdir "." ]
  57. if { [string length $infofile] < 1 } {
  58. return
  59. }
  60. # Read the file.
  61. _collectData
  62. }
  63. ##################################################################
  64. # Create the gui window.
  65. ##################################################################
  66. proc createMain { } {
  67. global mainframe
  68. global outputdir
  69. global infofile
  70. global _buttoncount
  71. global _fxtNameList
  72. global _fxtDataList
  73. global _bxtNameList
  74. global _bxtDataList
  75. global _printerName
  76. global _colorMode
  77. global _xaxis
  78. global _yaxis
  79. set _xaxis "width/diameter"
  80. set _yaxis "impedance"
  81. set _printerName "princess"
  82. set _colorMode "gray"
  83. set _fxtNameList ""
  84. set _fxtDataList ""
  85. set _bxtNameList ""
  86. set _bxtDataList ""
  87. set _bxtNameList ""
  88. set _buttoncount 1
  89. set outputdir [pwd]
  90. # Menu description
  91. set descmenu {
  92. "&File" all file 0 {
  93. {command "&Print" {} \
  94. "Generate a Postscript file and print the graph" {Ctrl g} \
  95. -command _printPS }
  96. {command "&Exit" {} "Exit the program" {Ctrl e} \
  97. -command _exit }
  98. }
  99. "&Setup" all setup 0 {
  100. {command "Setup Printer" {} "Set printer options" {} \
  101. -command _setupPrinter}
  102. {command "Toggle Grid Display" {} "Toggle visibility of grid" {} \
  103. -command _toggleGrid}
  104. }
  105. }
  106. set mainframe [MainFrame .mainframe \
  107. -menu $descmenu \
  108. -textvariable status]
  109. set allf [$mainframe getframe]
  110. set topf [frame $allf.topf -relief sunken -borderwidth 4]
  111. pack $topf -expand true -fill both
  112. set cfrme [frame $topf.cfrme -relief sunken -borderwidth 2]
  113. set f2 [frame $cfrme.f2 -relief sunken -borderwidth 2]
  114. set b1b [::gui::guiBuildButton $f2 "Input:" \
  115. _getResultsFile \
  116. "Pick the file containing the swept_results information"]
  117. set e1b [entry $f2.e1b -width 75 -textvariable infofile]
  118. pack $b1b $e1b -side left -fill both -expand yes
  119. pack $f2 -side top -fill x -expand yes
  120. set bfrme [frame $cfrme.f3]
  121. set p1 [ComboBox $bfrme.p1 -labelanchor e \
  122. -textvariable _xaxis \
  123. -values { width/diameter height conductivity pitch x-offset \
  124. y-offset } \
  125. -label "X-axis:" ]
  126. set p2 [ComboBox $bfrme.p2 -labelanchor e \
  127. -textvariable _yaxis \
  128. -values { impedance odd-impedance even-impedance \
  129. dielectric-constant velocity delay Rdc \
  130. FXT BXT } \
  131. -label "Y-axis:" ]
  132. set bdraw [::gui::guiBuildButton $bfrme "Draw" \
  133. "_drawTheGraph 1" \
  134. "Draw the graph with selected x-axis and y-axis values" ]
  135. pack $bdraw $p1 $p2 -side left -fill both -expand yes
  136. pack $bfrme -side top -expand yes -fill x
  137. pack $cfrme -side top -expand yes -fill x
  138. _createGraph $topf
  139. pack $mainframe -fill both -expand yes
  140. if { [string length $infofile] > 0 } {
  141. _collectData
  142. }
  143. }
  144. ##################################################################
  145. # Generate hardcopy.
  146. ##################################################################
  147. proc _printPS {} {
  148. global infofile
  149. global grph1
  150. global _printerName
  151. global _colorMode
  152. set nme [file tail $infofile]
  153. $grph1 postscript output $nme.ps -landscape yes \
  154. -colormode $_colorMode \
  155. -maxpect yes -decorations true
  156. set cmd {lp -d$_printerName $nme.ps}
  157. eval exec $cmd
  158. }
  159. ##################################################################
  160. # Exit.
  161. ##################################################################
  162. proc _exit {} {
  163. exit
  164. }
  165. ##################################################################
  166. # Build a conductor object.
  167. ##################################################################
  168. proc _buildConductor { num conductor type wdth diam } {
  169. for { set i 0 } { $i < $num } { incr i } {
  170. set nme "$conductor$i"
  171. #
  172. # Create a graphs object for each conductor in the
  173. # set.
  174. #
  175. Graphs $nme -name $conductor -type $type
  176. eval [$nme configure -number $num]
  177. #
  178. # Check if need to save the width or diameter.
  179. #
  180. if { [string compare $type "width"] == \
  181. 0 } {
  182. $nme addWidth $wdth
  183. } else {
  184. $nme addWidth $diam
  185. }
  186. }
  187. }
  188. ##################################################################
  189. # Read the swept_result or the iterate_result file.
  190. ##################################################################
  191. proc _collectData {} {
  192. global outputdir
  193. global infofile
  194. global graph_title
  195. global _fxtNameList
  196. global _fxtDataList
  197. global _fxtXList
  198. global _bxtNameList
  199. global _bxtDataList
  200. global _bxtXList
  201. global _oddImpList
  202. global _evenImpList
  203. #
  204. # Delete any objects created for a previous graph.
  205. #
  206. foreach itm [itcl::find objects] {
  207. itcl::delete object $itm
  208. }
  209. _deleteVectors
  210. #
  211. # Initialization.
  212. #
  213. set _fxtNameList ""
  214. set _fxtDataList ""
  215. set _fxtXList ""
  216. set _bxtNameList ""
  217. set _bxtDataList ""
  218. set _bxtNameList ""
  219. set _bxtXList ""
  220. set _oddImpList ""
  221. set _evenImpList ""
  222. set gotFXT 0
  223. set gotBXT 0
  224. set countProcessed 0
  225. set firstSet 1
  226. set strg [file extension $infofile]
  227. set graph_title [string range $strg 1 [string length $strg]]
  228. set xp -1
  229. set diam 0
  230. set wdth 0
  231. #
  232. # Open the results file and collect the data needed.
  233. #
  234. set fp [open $infofile r]
  235. while {1} {
  236. set lne [gets $fp]
  237. if { [eof $fp] } {
  238. break
  239. }
  240. if { [string length $lne] == 0 } {
  241. continue
  242. }
  243. #
  244. # Check when have read the first design definition.
  245. #
  246. if { ([string first MMTL $lne] > 1) } {
  247. set firstSet 0
  248. }
  249. #--------------------------------------------------------
  250. # Is this a RectangleConductors, TrapezoidConductors or a
  251. # CircleConductors?
  252. #--------------------------------------------------------
  253. if { ([string first RectangleConductors $lne] > 1) ||\
  254. ([string first CircleConductors $lne] > 1) ||\
  255. ([string first TrapezoidConductors $lne] > 1) } {
  256. set nme [lindex $lne 0]
  257. set conductor [string range $nme 0 [expr { [string length $nme] \
  258. - 2 }]]
  259. #
  260. # Loop until collected needed attribute values.
  261. #
  262. while { 1 } {
  263. set lne [gets $fp]
  264. #
  265. # 'diameter' attribute?
  266. #
  267. if { [string first iameter $lne] > 0 } {
  268. set indx [string first ":" $lne]
  269. if { $indx > 1 } {
  270. set strg [string range $lne [expr { $indx + 1 }] \
  271. [string length $lne]]
  272. scan $strg "%g" diam
  273. set type "diameter"
  274. set chr C
  275. }
  276. }
  277. #
  278. # 'width' attribute?
  279. #
  280. if { [string first idth $lne] > 0 } {
  281. set indx [string first ":" $lne]
  282. if { $indx > 1 } {
  283. set strg [string range $lne [expr { $indx + 1 }] \
  284. [string length $lne]]
  285. scan $strg "%g" wdth
  286. set type "width"
  287. if { [string first Width $lne] > 0 } {
  288. set chr T
  289. } else {
  290. set chr R
  291. }
  292. }
  293. }
  294. #
  295. # 'height' attribute?
  296. #
  297. if { [string first eight $lne] > 0 } {
  298. set indx [string first ":" $lne]
  299. if { $indx > 1 } {
  300. set strg [string range $lne [expr { $indx + 1 }] \
  301. [string length $lne]]
  302. scan $strg "%g" hght
  303. }
  304. }
  305. #
  306. # 'conductivity' attribute?
  307. #
  308. if { [string first onductiv $lne] > 0 } {
  309. set indx [string first ":" $lne]
  310. if { $indx > 1 } {
  311. set strg [string range $lne [expr { $indx + 1 }] \
  312. [string length $lne]]
  313. scan $strg "%g" conductivity
  314. }
  315. }
  316. #
  317. # 'number' attribute?
  318. #
  319. if { [string first umber $lne] > 0 } {
  320. set indx [string first ":" $lne]
  321. if { $indx > 1 } {
  322. set strg [string range $lne [expr { $indx + 1 }] \
  323. [string length $lne]]
  324. scan $strg "%d" num
  325. if { $firstSet } {
  326. set conductor [format {%s%s} $conductor $chr]
  327. _buildConductor $num $conductor $type \
  328. $wdth $diam
  329. incr countProcessed
  330. } else {
  331. set conductor [format {%s%s} $conductor $chr]
  332. for { set i 0 } { $i < $num } { incr i } {
  333. if { [string compare $type "width"] == \
  334. 0 } {
  335. $conductor$i addHeight $hght
  336. $conductor$i addWidth $wdth
  337. } else {
  338. $conductor$i addWidth $diam
  339. set wdth $diam
  340. }
  341. $conductor$i addConductivity $conductivity
  342. }
  343. }
  344. }
  345. }
  346. #
  347. # 'ptich' attribute?
  348. #
  349. if { [string first itch $lne] > 0 } {
  350. set indx [string first ":" $lne]
  351. if { $indx > 1 } {
  352. set strg [string range $lne [expr { $indx + 1 }] \
  353. [string length $lne]]
  354. scan $strg "%g" pitch
  355. }
  356. for { set i 0 } { $i < $num } { incr i } {
  357. $conductor$i addPitch $pitch
  358. }
  359. }
  360. #
  361. # 'x-offset' attribute?
  362. #
  363. if { [string first offset $lne] > 0 } {
  364. set indx [string first ":" $lne]
  365. if { $indx > 1 } {
  366. set strg [string range $lne [expr { $indx + 1 }] \
  367. [string length $lne]]
  368. scan $strg "%g" xoff
  369. }
  370. for { set i 0 } { $i < $num } { incr i } {
  371. $conductor$i addXoff $xoff
  372. }
  373. #
  374. # 'y-offset' attribute
  375. #
  376. set lne [gets $fp]
  377. set indx [string first ":" $lne]
  378. if { $indx > 1 } {
  379. set strg [string range $lne [expr { $indx + 1 }] \
  380. [string length $lne]]
  381. scan $strg "%g" yoff
  382. }
  383. for { set i 0 } { $i < $num } { incr i } {
  384. $conductor$i addYoff $yoff
  385. }
  386. #
  387. # Break out of this loop since no more attribute
  388. # values need to be saved.
  389. #
  390. break
  391. }
  392. }
  393. }
  394. #
  395. ################ parse for the impedance values #################
  396. #
  397. if { ([string first Impedance $lne] > 1) } {
  398. incr xp
  399. set lne [gets $fp]
  400. while { ( [string first "Odd/Even" $lne] < 1 ) &&
  401. ( [string first "Dielectric Constant" $lne] < 1 ) } {
  402. set indx [string first "::" $lne]
  403. if { $indx > 1 } {
  404. set indx2 [string first "=" $lne]
  405. set conductor [string range $lne [expr { $indx + 2 }] \
  406. [expr { $indx2 - 1}]]
  407. set strg [string range $lne $indx2 [string length $lne]]
  408. scan $strg "%*c %g" imp
  409. if {[lsearch -exact [itcl::find objects] $conductor] > -1} {
  410. $conductor addImpedance $imp
  411. $conductor addX $xp
  412. }
  413. }
  414. set lne [gets $fp]
  415. }
  416. if { [string first "Odd/Even" $lne] > 0 } {
  417. set lne [gets $fp]
  418. scan $lne {%*s %f} imp
  419. lappend _oddImpList $imp
  420. set lne [gets $fp]
  421. scan $lne {%*s %f} imp
  422. lappend _evenImpList $imp
  423. set lne [gets $fp]
  424. set lne [gets $fp]
  425. }
  426. #
  427. ######## parse for the delectric constant values #############
  428. #
  429. set lne [gets $fp]
  430. while { [string first "ation Velocity" $lne] < 1 } {
  431. set indx [string first "::" $lne]
  432. if { $indx > 1 } {
  433. set indx2 [string first "=" $lne]
  434. set conductor [string range $lne [expr { $indx + 2 }] \
  435. [expr { $indx2 - 1}]]
  436. set strg [string range $lne $indx2 [string length $lne]]
  437. scan $strg "%*c %g" dielC
  438. if {[lsearch -exact [itcl::find objects] $conductor] > -1} {
  439. $conductor addDielectricConstant $dielC
  440. }
  441. }
  442. set lne [gets $fp]
  443. }
  444. #
  445. ######## parse for the velocity values #############
  446. #
  447. set lne [gets $fp]
  448. while { [string first "ation Delay" $lne] < 1 } {
  449. set indx [string first "::" $lne]
  450. if { $indx > 1 } {
  451. set indx2 [string first "=" $lne]
  452. set conductor [string range $lne [expr { $indx + 2 }] \
  453. [expr { $indx2 - 1}]]
  454. set strg [string range $lne $indx2 [string length $lne]]
  455. scan $strg "%*c %g" velocity
  456. if {[lsearch -exact [itcl::find objects] $conductor] > -1} {
  457. $conductor addVelocity $velocity
  458. }
  459. }
  460. set lne [gets $fp]
  461. }
  462. #
  463. ######## parse for the delay values #############
  464. #
  465. set lne [gets $fp]
  466. while { [string first "dc:" $lne] < 1 } {
  467. set indx [string first "::" $lne]
  468. if { $indx > 1 } {
  469. set indx2 [string first "=" $lne]
  470. set conductor [string range $lne [expr { $indx + 2 }] \
  471. [expr { $indx2 - 1}]]
  472. set strg [string range $lne $indx2 [string length $lne]]
  473. scan $strg "%*c %g" delay
  474. if {[lsearch -exact [itcl::find objects] $conductor] > -1} {
  475. $conductor addDelay $delay
  476. }
  477. }
  478. set lne [gets $fp]
  479. }
  480. #
  481. ######## parse for the rdc values #############
  482. #
  483. while { 1 } {
  484. set lne [gets $fp]
  485. if { [string first "(Active Sign" $lne] > 0 } {
  486. break
  487. }
  488. }
  489. set lne [gets $fp]
  490. while { [string first "(Forward" $lne] < 1 } {
  491. set indx [string first "::" $lne]
  492. if { $indx > 1 } {
  493. set indx2 [string first ", " $lne]
  494. set conductor [string range $lne [expr { $indx + 2 }] \
  495. [expr { $indx2 - 2}]]
  496. set strg [string range $lne $indx2 [string length $lne]]
  497. set indx [string first "::" $strg]
  498. if { $indx < 1 } {
  499. puts "Trouble"
  500. return
  501. }
  502. set indx2 [string first " )" $strg]
  503. set cnd2 [string range $strg [expr { $indx + 2 }] \
  504. [expr { $indx2 - 1}]]
  505. if { [string compare $conductor $cnd2] != 0 } {
  506. set lne [gets $fp]
  507. continue
  508. }
  509. set strg [string range $strg $indx2 [string length $strg]]
  510. set indx2 [string first "=" $strg]
  511. set strg [string range $strg $indx2 [string length $strg]]
  512. scan $strg "%*c %g" rdc
  513. if {[lsearch -exact [itcl::find objects] $conductor] > -1} {
  514. $conductor addRdc $rdc
  515. }
  516. }
  517. set lne [gets $fp]
  518. }
  519. #
  520. ######## parse for the FXT values #############
  521. #
  522. set fxtCount 0
  523. set lne [gets $fp]
  524. while { [string first "(Backward" $lne] < 1 } {
  525. set indx [string first "::" $lne]
  526. if { $indx > 1 } {
  527. set indx2 [string first ", " $lne]
  528. set conductor [string range $lne [expr { $indx + 2 }] \
  529. [expr { $indx2 - 2}]]
  530. set strg [string range $lne $indx2 [string length $lne]]
  531. set indx [string first "::" $strg]
  532. if { $indx < 1 } {
  533. puts "Trouble"
  534. return
  535. }
  536. set indx2 [string first ")=" $strg]
  537. set cnd2 [string range $strg [expr { $indx + 2 }] \
  538. [expr { $indx2 - 1}]]
  539. global FXT$fxtCount
  540. if { ! $gotFXT } {
  541. lappend _fxtNameList $conductor$cnd2
  542. eval [set FXT$fxtCount ""]
  543. lappend _fxtDataList FXT$fxtCount
  544. }
  545. set strg [string range $strg [expr { $indx2 + 2 }] \
  546. [string length $strg]]
  547. if { [string first "infinite" $strg] > 0 } {
  548. set fxt 0.0
  549. } else {
  550. set indx2 [string first "=" $strg]
  551. set strg [string range $strg $indx2 \
  552. [string length $strg]]
  553. scan $strg "%*c %g" fxt
  554. }
  555. eval { lappend FXT$fxtCount $fxt }
  556. incr fxtCount
  557. }
  558. set lne [gets $fp]
  559. }
  560. lappend _fxtXList $wdth
  561. set gotFXT 1
  562. #
  563. ######## parse for the BXT values #############
  564. #
  565. set bxtCount 0
  566. set lne [gets $fp]
  567. while { [string first "Cross talk" $lne] < 1 } {
  568. set indx [string first "::" $lne]
  569. if { $indx > 1 } {
  570. set indx2 [string first ", " $lne]
  571. set conductor [string range $lne [expr { $indx + 2 }] \
  572. [expr { $indx2 - 2}]]
  573. set strg [string range $lne $indx2 [string length $lne]]
  574. set indx [string first "::" $strg]
  575. if { $indx < 1 } {
  576. puts "Trouble"
  577. return
  578. }
  579. set indx2 [string first ")=" $strg]
  580. set cnd2 [string range $strg [expr { $indx + 2 }] \
  581. [expr { $indx2 - 1}]]
  582. global BXT$bxtCount
  583. if { ! $gotBXT } {
  584. lappend _bxtNameList "$conductor$cnd2"
  585. eval [set BXT$bxtCount ""]
  586. lappend _bxtDataList BXT$bxtCount
  587. }
  588. set strg [string range $strg [expr { $indx2 + 2 }] \
  589. [string length $strg]]
  590. set indx2 [string first "=" $strg]
  591. set strg [string range $strg $indx2 [string length $strg]]
  592. scan $strg "%*c %g" bxt
  593. eval { lappend BXT$bxtCount $bxt }
  594. incr bxtCount
  595. }
  596. set lne [gets $fp]
  597. }
  598. lappend _bxtXList $wdth
  599. set gotBXT 1
  600. }
  601. }
  602. close $fp
  603. _drawTheGraph -1
  604. return
  605. }
  606. ##################################################################
  607. # Delete the existing vectors.
  608. ##################################################################
  609. proc _deleteVectors {} {
  610. global grph1
  611. if { [llength [$grph1 element names]] > 0 } {
  612. set cnt 0
  613. foreach itm [$grph1 element names] {
  614. #-------------------------------------------------
  615. # Destroy the vectors for the elements of the graph.
  616. #-------------------------------------------------
  617. set xv [$grph1 element cget $itm -xdata]
  618. set yv [$grph1 element cget $itm -ydata]
  619. vector destroy $xv
  620. vector destroy $yv
  621. #-------------------------------------------------
  622. # Delete the elements from the graph.
  623. #-------------------------------------------------
  624. $grph1 element delete $itm
  625. }
  626. }
  627. }
  628. proc _getColor { clrIndx } {
  629. global numColors
  630. global colorList
  631. set indx [expr { $clrIndx - (($clrIndx / $numColors) * $numColors) }]
  632. return [lindex $colorList $indx]
  633. }
  634. ##################################################################
  635. # Draw the graph.
  636. ##################################################################
  637. proc _drawTheGraph { flg } {
  638. global grph1
  639. global infofile
  640. global graph_title
  641. global _fxtNameList
  642. global _fxtDataList
  643. global _fxtXList
  644. global _bxtNameList
  645. global _bxtDataList
  646. global _bxtXList
  647. global _xaxis
  648. global _yaxis
  649. global xLst
  650. global _oddImpList
  651. global _evenImpList
  652. if { $flg > -1 } {
  653. _deleteVectors
  654. } else {
  655. set flg 0
  656. }
  657. $grph1 configure -title [file tail $infofile]
  658. $grph1 axis configure x -title $_xaxis
  659. $grph1 axis configure y -title $_yaxis
  660. set cnt 0
  661. set clrCnt 0
  662. set lst [itcl::find objects]
  663. foreach itm $lst {
  664. switch -- $_xaxis {
  665. width/diameter {
  666. set xLst [$itm cget -widthList]
  667. }
  668. height {
  669. set xLst [$itm cget -heightList]
  670. }
  671. conductivity {
  672. set xLst [$itm cget -conductivityList]
  673. }
  674. pitch {
  675. set xLst [$itm cget -pitchList]
  676. }
  677. x-offset {
  678. set xLst [$itm cget -xOffList]
  679. }
  680. y-offset {
  681. set xLst [$itm cget -yOffList]
  682. }
  683. }
  684. ###############################################################
  685. # Draw the FXT data to the 2D graph.
  686. ###############################################################
  687. if { [string compare $_yaxis "FXT"] == 0 } {
  688. foreach obj $_fxtDataList {
  689. global FXT$cnt
  690. vector yvec$cnt
  691. vector xvec$cnt
  692. eval [xvec$cnt set $xLst]
  693. set itmList FXT$cnt
  694. set strg [format "yvec%d set \$FXT%d" $cnt $cnt]
  695. eval $strg
  696. $grph1 element create [lindex $_fxtNameList $cnt] \
  697. -color [_getColor $clrCnt] \
  698. -symbol circle -pixels 5 -linewidth 2 \
  699. -xdata xvec$cnt -ydata yvec$cnt
  700. incr cnt
  701. incr clrCnt
  702. }
  703. return
  704. }
  705. ###############################################################
  706. # Draw the BXT data to the 2D graph.
  707. ###############################################################
  708. if { [string compare $_yaxis "BXT"] == 0 } {
  709. foreach itm $_bxtDataList {
  710. global BXT$cnt
  711. vector yvec$cnt
  712. vector xvec$cnt
  713. eval [xvec$cnt set $xLst]
  714. set itmList BXT$cnt
  715. set strg [format "yvec%d set \$BXT%d" $cnt $cnt]
  716. eval $strg
  717. $grph1 element create [lindex $_bxtNameList $cnt] \
  718. -color [_getColor $clrCnt] \
  719. -symbol circle -pixels 5 -linewidth 2 \
  720. -xdata xvec$cnt -ydata yvec$cnt
  721. incr cnt
  722. incr clrCnt
  723. }
  724. return
  725. }
  726. switch -- $_yaxis {
  727. impedance {
  728. vector yvec$cnt
  729. vector xvec$cnt
  730. eval [xvec$cnt set $xLst]
  731. set yLst [$itm cget -impList]
  732. eval [yvec$cnt set $yLst]
  733. $grph1 axis configure y -title $_yaxis
  734. $grph1 element create $itm -color [_getColor $clrCnt] \
  735. -symbol circle -pixels 5 -linewidth 2 \
  736. -xdata xvec$cnt -ydata yvec$cnt
  737. }
  738. odd-impedance {
  739. vector yvec$cnt
  740. vector xvec$cnt
  741. eval [xvec$cnt set $xLst]
  742. set yLst $_oddImpList
  743. if { [llength $yLst] < 1 } {
  744. tk_messageBox -type ok \
  745. -message "The results file contains no\
  746. odd-impedance values." -icon warning
  747. return
  748. }
  749. eval [yvec$cnt set $yLst]
  750. $grph1 axis configure y -title $_yaxis
  751. $grph1 element create $itm -color [_getColor $clrCnt] \
  752. -symbol circle -pixels 5 -linewidth 2 \
  753. -xdata xvec$cnt -ydata yvec$cnt
  754. }
  755. even-impedance {
  756. vector yvec$cnt
  757. vector xvec$cnt
  758. eval [xvec$cnt set $xLst]
  759. set yLst $_evenImpList
  760. if { [llength $yLst] < 1 } {
  761. tk_messageBox -type ok \
  762. -message "The results file contains no\
  763. even-impedance values." -icon warning
  764. return
  765. }
  766. eval [yvec$cnt set $yLst]
  767. $grph1 axis configure y -title $_yaxis
  768. $grph1 element create $itm -color [_getColor $clrCnt] \
  769. -symbol circle -pixels 5 -linewidth 2 \
  770. -xdata xvec$cnt -ydata yvec$cnt
  771. }
  772. velocity {
  773. vector yvec$cnt
  774. vector xvec$cnt
  775. eval [xvec$cnt set $xLst]
  776. set yLst [$itm cget -velocityList]
  777. eval [yvec$cnt set $yLst]
  778. $grph1 axis configure y -title $_yaxis
  779. $grph1 element create $itm -color [_getColor $clrCnt] \
  780. -symbol circle -pixels 5 -linewidth 2 \
  781. -xdata xvec$cnt -ydata yvec$cnt
  782. }
  783. delay {
  784. vector yvec$cnt
  785. vector xvec$cnt
  786. eval [xvec$cnt set $xLst]
  787. set yLst [$itm cget -delayList]
  788. eval [yvec$cnt set $yLst]
  789. $grph1 axis configure y -title $_yaxis
  790. $grph1 element create $itm -color [_getColor $clrCnt] \
  791. -symbol circle -pixels 5 -linewidth 2 \
  792. -xdata xvec$cnt -ydata yvec$cnt
  793. }
  794. dielectric-constant {
  795. vector yvec$cnt
  796. vector xvec$cnt
  797. eval [xvec$cnt set $xLst]
  798. set dielCLst [$itm cget -dielCList]
  799. eval [yvec$cnt set $dielCLst]
  800. $grph1 axis configure y -title $_yaxis
  801. $grph1 element create $itm -color [_getColor $clrCnt] \
  802. -symbol circle -pixels 5 -linewidth 2 \
  803. -xdata xvec$cnt -ydata yvec$cnt
  804. }
  805. Rdc {
  806. vector yvec$cnt
  807. vector xvec$cnt
  808. eval [xvec$cnt set $xLst]
  809. set rdcLst [$itm cget -rdcList]
  810. eval [yvec$cnt set $rdcLst]
  811. $grph1 axis configure y -title $_yaxis
  812. $grph1 element create $itm -color [_getColor $clrCnt] \
  813. -symbol circle -pixels 5 -linewidth 2 \
  814. -xdata xvec$cnt -ydata yvec$cnt
  815. }
  816. }
  817. incr cnt
  818. incr clrCnt
  819. }
  820. return
  821. }
  822. proc _toggleGrid {} {
  823. global grph1
  824. $grph1 grid toggle
  825. }
  826. ##################################################################
  827. # Create the graph.
  828. ##################################################################
  829. proc _createGraph { parent } {
  830. global grph1
  831. set fgrph [ frame $parent.fgrph -relief raised -borderwidth 2 ]
  832. # create a new graph.
  833. set grph1 [graph $fgrph.g1 -plotbackground white ]
  834. # $grph1 configure -width 900
  835. $grph1 legend configure -font {courier 8}
  836. # get the current display list.
  837. pack $grph1 -side top -expand yes -fill both
  838. pack $fgrph -side top -expand yes -fill both
  839. }
  840. ##########################################################
  841. # Set up a printer.
  842. ##########################################################
  843. proc _setupPrinter {} {
  844. global _printerName
  845. global _colorMode
  846. global _savePrinterName
  847. global _saveColorMode
  848. global _prntFrame
  849. global _ecount
  850. set _ecount 0
  851. set _savePrinterName $_printerName
  852. set _saveColorMode $_colorMode
  853. if {! [winfo exists .prntFrame]} {
  854. set _prntFrame [frame .prntFrame \
  855. -relief sunken -borderwidth 5]
  856. set seglbl [Label $_prntFrame.seglbl \
  857. -justify center -text "Printer Options"]
  858. grid $seglbl -sticky new
  859. set c1 [::gui::guiBuildLabelEntry $_prntFrame _printerName \
  860. "Printer:" ]
  861. grid $c1 -sticky new
  862. set p1 [ComboBox $_prntFrame.sb -labelanchor e \
  863. -textvariable _colorMode \
  864. -values { color grey mono } \
  865. -label "Color Mode:" ]
  866. grid $p1 -sticky new
  867. LabelFrame::align $c1 $p1
  868. set but1 [::gui::guiBuildButton $_prntFrame "OK" \
  869. "_finishPrinter 1" "Print"]
  870. set but2 [::gui::guiBuildButton $_prntFrame "Cancel" \
  871. "_finishPrinter 0" "Cancel the Print"]
  872. grid $but1 $but2 -sticky nw
  873. }
  874. place $_prntFrame -x 75 -y 300
  875. }
  876. ##########################################################
  877. # Finish setting up a printer.
  878. ##########################################################
  879. proc _finishPrinter { opt } {
  880. global _printerName
  881. global _colorMode
  882. global _savePrinterName
  883. global _saveColorMode
  884. global _prntFrame
  885. place forget $_prntFrame
  886. if { $opt } {
  887. puts "Setup Printer: $_printerName $_colorMode"
  888. return
  889. }
  890. set _printerName $_savePrinterName
  891. set _colorMode $_saveColorMode
  892. }
  893. ##################################################################
  894. # main.
  895. ##################################################################
  896. proc main { argc argv } {
  897. global auto_path
  898. global infofile
  899. global colorList
  900. global numColors
  901. global dashesList
  902. set numColors 8
  903. set colorList { navy blue green cyan magenta red orange yellow }
  904. lappend auto_path ..
  905. package require BWidget
  906. option add *font {courier 10 bold}
  907. wm withdraw .
  908. wm title . "Cross-section Generator"
  909. if { $argc == 1 } {
  910. set infofile [lindex $argv 0]
  911. }
  912. createMain
  913. BWidget::place . 0 0 center
  914. DynamicHelp::configure -bg black
  915. DynamicHelp::configure -fg white
  916. wm deiconify .
  917. raise .
  918. focus -force .
  919. }
  920. main $argc $argv
  921. wm geom . [wm geom .]