gui_initialize.tcl 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927
  1. #----------------------------------------------------------------
  2. #
  3. # mmtl_initialize.tcl
  4. #
  5. # Main entry point for the interface program
  6. # for Mayo SPPDG MMTL and other transmission line
  7. # simulators.
  8. #
  9. # This module creates the BWidget ::gui::mainframe framework
  10. # for the main window, and defines procedures for
  11. # accessing numerous other integrated simulation programs
  12. # and utilities.
  13. #
  14. # The actual GUI is constructed by [createElements]
  15. #
  16. # Copyright 2002-2004 Mayo Foundation. All Rights Reserved
  17. # $Id: gui_initialize.tcl,v 1.29 2004/09/10 19:51:10 techenti Exp $
  18. #
  19. #----------------------------------------------------------------
  20. package provide gui 2.0
  21. # From whence is this script run?
  22. # For there shall we find the rest. (of the GUI stuff)
  23. set ::gui::scriptDir [file dirname [info script]]
  24. #----------------------------------------------------------------
  25. #
  26. # ::gui::guiNew
  27. #
  28. # "New File" operation, called from the menu File->New.
  29. # This function just deletes all the design information.
  30. #
  31. #----------------------------------------------------------------
  32. proc ::gui::guiNew {} {
  33. #------------------------------------------------------
  34. # Delete all the design information,
  35. # and reset GUI defaults.
  36. #------------------------------------------------------
  37. ::gui::_deleteAll
  38. set ::gui::_nodename ""
  39. set ::gui::_nodedirectory ""
  40. ::gui::_setNodeName
  41. }
  42. #----------------------------------------------------------------
  43. #
  44. # ::gui::guiOpenExisting
  45. #
  46. # "Open File" operation, called from the menu File->Open.
  47. #
  48. # Prompt for file name (if not given). Set node name
  49. # and directory, and read the cross section.
  50. #
  51. # Arguments:
  52. # filename (optional) -- path name with
  53. # (optional) .xsctn type
  54. #
  55. # Results:
  56. # Sets global variables for node name and node directory.
  57. # Reads new cross section data.
  58. #
  59. #----------------------------------------------------------------
  60. proc ::gui::guiOpenExisting { {filename ""} } {
  61. set ::gui::_title ""
  62. set typelist {
  63. {{mmtl files} {.xsctn} }
  64. {{All Files} * }
  65. }
  66. #------------------------------------------------------
  67. # If we didn't get a filename from the argument,
  68. # then prompt for a file name
  69. #------------------------------------------------------
  70. if { $filename == "" } {
  71. set filename [ tk_getOpenFile -filetypes $typelist \
  72. -initialdir $::gui::_nodedirectory]
  73. # Evade Windows double-click bug
  74. if { $::tcl_platform(platform) eq "windows" } {
  75. ::gui::drainEventQueue
  76. }
  77. # Check that the user didn't cancel from this option.
  78. if { [string length $filename] < 1 } {
  79. return {}
  80. }
  81. } else {
  82. #------------------------------------------------------
  83. # We _did_ get a file name.
  84. # Allow file type ".xsctn" to be optional
  85. #------------------------------------------------------
  86. if { [file extension $filename] ne ".xsctn" } {
  87. append $filename ".xsctn"
  88. }
  89. }
  90. #------------------------------------------------------
  91. # Define node name and directory
  92. #------------------------------------------------------
  93. set ::gui::_nodedirectory [file dirname $filename]
  94. set ::gui::_nodename [file rootname $filename]
  95. #------------------------------------------------------
  96. # Open and read the file, update the GUI
  97. #------------------------------------------------------
  98. ::gui::_read_cross_section_file $filename
  99. }
  100. #----------------------------------------------------------------
  101. #
  102. # ::gui::_read_cross_section_file
  103. #
  104. # Read cross section file and update the GUI
  105. #
  106. # This function does _not_ update the global node
  107. # name and directory, and is suitable for reading
  108. # in temporary cross sections, as might be done
  109. # during iterations or sweeping.
  110. #
  111. # Arguments:
  112. # filename
  113. #
  114. # Results:
  115. # Old cross section results are deleted
  116. # New cross section file is read.
  117. # GUI is updated.
  118. #
  119. #----------------------------------------------------------------
  120. proc ::gui::_read_cross_section_file { filename } {
  121. #---------------------------------------------------------
  122. # Delete old data and set defaults
  123. #---------------------------------------------------------
  124. ::gui::_deleteAll
  125. set ::CSEG 10
  126. set ::DSEG 10
  127. #---------------------------------------------------
  128. # Read new cross section and set GUI parameters
  129. #---------------------------------------------------
  130. ::csdl::csdlReadTCL $filename
  131. set ::gui::_num_c_segs $::CSEG
  132. set ::gui::_num_p_segs $::DSEG
  133. set ::gui::_title $::_title
  134. #---------------------------------------------------
  135. # Tell the units conversion routines what our new
  136. # defeault units should be
  137. #---------------------------------------------------
  138. set ::units::default(Length) $::Stackup::defaultLengthUnits
  139. set ::units::default(Time) ps
  140. #---------------------------------------------------
  141. # Update the GUI
  142. #---------------------------------------------------
  143. ::gui::_setNodeName
  144. ::gui::_canvas_redraw
  145. ::gui::_canvas_zoom_fit $::gui::_canvas
  146. foreach obj $::Stackup::structureList {
  147. set objname [namespace tail $obj]
  148. $::gui::_tree insert 0 root $objname -text $objname
  149. }
  150. }
  151. #----------------------------------------------------------------
  152. #
  153. # ::gui::guiSave
  154. #
  155. # Save the cross section file to the previously
  156. # defined file name. If the file name doesn't exist
  157. # (because this is a new cross section), then call guiSaveAs.
  158. #
  159. #----------------------------------------------------------------
  160. proc ::gui::guiSave {} {
  161. #-------------------------------------
  162. # If we don't have a file name, then
  163. # call guiSaveAs, which chooses a
  164. # file name, then calls us again.
  165. #-------------------------------------
  166. if { $::gui::_nodename eq "" } {
  167. ::gui::guiSaveAs
  168. return
  169. }
  170. set filename ${::gui::_nodename}.xsctn
  171. #-------------------------------------
  172. # Some attributes need to be changed
  173. # from GUI-specific formatting to
  174. # regular CSDL.
  175. #-------------------------------------
  176. ::gui::_replaceNamedValues
  177. ::csdl::csdlWriteTCL $filename $::gui::_title \
  178. $::gui::_num_c_segs $::gui::_num_p_segs
  179. return
  180. }
  181. #----------------------------------------------------------------
  182. #
  183. # ::gui::guiSaveAs
  184. #
  185. # Prompt for a file name and save the cross section.
  186. #
  187. # Its almost an infinte loop ... but we can call guiSave
  188. # to do the actual file save. (As long as we make sure
  189. # that the filename is defined.)
  190. #
  191. #----------------------------------------------------------------
  192. proc ::gui::guiSaveAs {} {
  193. #------------------------------------------------------
  194. # Prompt for file name
  195. #------------------------------------------------------
  196. set typelist {
  197. {{cross-section files} {.xsctn} }
  198. {{All Files} * }
  199. }
  200. set filename [ tk_getSaveFile -filetypes $typelist \
  201. -initialdir $::gui::_nodedirectory ]
  202. # Evade Windows double-click bug
  203. if { $::tcl_platform(platform) eq "windows" } {
  204. ::gui::drainEventQueue
  205. }
  206. #------------------------------------------------------
  207. # Check that the user didn't cancel from this option.
  208. #------------------------------------------------------
  209. if { [string length $filename] < 1 } {
  210. return {}
  211. }
  212. #------------------------------------------------------
  213. # Allow file type ".xsctn" to be optional
  214. #------------------------------------------------------
  215. if { [file extension $filename] ne "*.xsctn" } {
  216. append $filename ".xsctn"
  217. }
  218. #------------------------------------------------------
  219. # Save directory and file names, and
  220. # display the new filename
  221. #------------------------------------------------------
  222. set ::gui::_nodedirectory [file dirname $filename]
  223. set ::gui::_nodename [file rootname $filename]
  224. ::gui::_setNodeName
  225. #---------------------------------------------------
  226. # Save the file
  227. #---------------------------------------------------
  228. ::gui::guiSave
  229. }
  230. #----------------------------------------------------------------
  231. #
  232. # ::gui::writeHspiceW
  233. #
  234. # Write HSPICE W-element model.
  235. #
  236. #----------------------------------------------------------------
  237. proc ::gui::writeHspiceW {} {
  238. #--------------------------------------------------------------
  239. # Create the Welement object, and ask it for the
  240. # W-element string
  241. #--------------------------------------------------------------
  242. set w [Welement #auto]
  243. set wmodel [$w welementString ${::gui::_nodename}.result]
  244. itcl::delete object $w
  245. #--------------------------------------------------------------
  246. # Write the W-element file and display it to the user
  247. #--------------------------------------------------------------
  248. set fp [open ${::gui::_nodename}.hspice-w.rlgc w]
  249. puts $fp $wmodel
  250. close $fp
  251. ::gui::guiPopupResultsFile "hspice-w.rlgc"
  252. }
  253. ##################################################################
  254. ##################################################################
  255. proc ::gui::guiViewPlotP {} {
  256. global env
  257. ::bem::bemViewPlotPotential $::gui::_nodename
  258. }
  259. ##################################################################
  260. ##################################################################
  261. proc ::gui::guiViewTheGraph { type } {
  262. ::bem::bemViewGraph ${::gui::_nodename}.$type
  263. }
  264. proc ::gui::_setDisplayData {} {
  265. #-------------------------------------------------------------
  266. # The user has the choice of setting the display data to the
  267. # data from the last save, data prior to the simulations, or
  268. # leaving set to the values at the end of the last simulation.
  269. #-------------------------------------------------------------
  270. set retrn [tk_dialog .tkd "Question" \
  271. "Set the display data to?" \
  272. question {} \
  273. "Data from previous save" "Data prior to simulations" \
  274. "Data after simulations"]
  275. switch -- $retrn {
  276. 0 {
  277. puts "Set the display values to the data from the last save."
  278. _read_cross_section_file ${::gui::_nodename}.xsctn
  279. }
  280. 1 {
  281. puts "Set the display values to the data prior to\
  282. the simulations."
  283. _read_cross_section_file ${::gui::_nodename}.xsctn.temp
  284. }
  285. 2 {
  286. if { ! [catch { puts "Update the values for\
  287. $selectedObject" }] } {
  288. #------------------------------------------------
  289. # Put the currently defined values into the
  290. # appropriate form.
  291. #------------------------------------------------
  292. _fillGlobalValues $selectedObject
  293. }
  294. }
  295. }
  296. ::gui::_canvas_redraw
  297. }
  298. #----------------------------------------------------------------
  299. #
  300. # ::gui::saveAndRunBem
  301. #
  302. # Save the cross section file.
  303. # Open a control dialog with a log window
  304. # Run 'bem' simulator, directing output
  305. # to the log window.
  306. # Display BEM results in another dialog.
  307. #
  308. #----------------------------------------------------------------
  309. proc ::gui::saveAndRunBem {} {
  310. # Make sure that the dialogs exist
  311. if { ! [winfo exists $::gui::dialog(bemRun,dialog)] } {
  312. ::gui::_createBemRunDialog
  313. }
  314. if { ! [winfo exists $::gui::dialog(bemLog,dialog)] } {
  315. ::gui::_createBemLogDialog
  316. }
  317. # Open a "run" window, let them change settings,
  318. # and check to see if they hit the "run" button.
  319. set result [$::gui::dialog(bemRun,dialog) draw]
  320. if { $result == 0 } {
  321. # Save the cross section
  322. # (might have new coupling length or rise time)
  323. ::gui::guiSave
  324. # Run mmtl as a subprocess.
  325. set cmd [auto_execok bem]
  326. set filename $::gui::_nodename
  327. set cseg $::gui::_num_c_segs
  328. set dseg $::gui::_num_p_segs
  329. set pipe [open "|$cmd \"$filename\" $cseg $dseg" w+]
  330. # Connect stdout and stderror to the text widget
  331. fconfigure $pipe -buffering none -blocking 0
  332. set txt $::gui::dialog(bemLog,text)
  333. fileevent $pipe readable [list ::gui::_copyDataToText $txt $pipe]
  334. # Set busy cursor, clear the text widget, and draw dialog
  335. $txt configure -cursor watch
  336. $txt delete 1.0 end
  337. set result [$::gui::dialog(bemLog,dialog) draw]
  338. # Just in case the simulator is still running
  339. # when we get back from the dialog...
  340. catch {close $pipe}
  341. set defcursor [lindex [$txt configure -cursor] 3]
  342. $txt configure -cursor $defcursor
  343. # Did they click "View Results?"
  344. if { $result == 0 } {
  345. ::gui::guiPopupResultsFile "result"
  346. }
  347. }
  348. }
  349. #----------------------------------------------------------------
  350. #
  351. # ::gui::_copyDataToText
  352. #
  353. # Copy data from a file channel into a text widget.
  354. # Called on a 'readable' fileevent, this will copy
  355. # whatever data is available on a file channel
  356. # to the end of the text widget.
  357. #
  358. # If we detect EOF, then we set the text widget cursor
  359. # to the default, on the assumption that somebody might
  360. # have changed it to a watch.
  361. #
  362. #----------------------------------------------------------------
  363. proc ::gui::_copyDataToText {textwidget fp} {
  364. # Read the channel
  365. set status [catch {set line [read $fp]} result]
  366. if { $status != 0 } {
  367. # error on the channel
  368. error "Error reading $fp: $result"
  369. } else {
  370. # append data to text widget
  371. $textwidget insert end $line
  372. # $textwidget insert end \n
  373. $textwidget see end
  374. }
  375. # check for end of run
  376. if { [eof $fp] } {
  377. close $fp
  378. set defcursor [lindex [$textwidget configure -cursor] 3]
  379. $textwidget configure -cursor $defcursor
  380. }
  381. }
  382. #----------------------------------------------------------------
  383. #
  384. # ::gui::writeSweptCsvFile
  385. #
  386. # Writes a csv (character separated values) file from
  387. # the swept (or iterated) results file.
  388. #
  389. #----------------------------------------------------------------
  390. proc ::gui::writeSweptCsvFile { filetype } {
  391. # Write csv file
  392. # (sorry, no choices...)
  393. set filename [::bem::bemWriteSweptParameterFile $filetype]
  394. # Display file for user
  395. if { $filename ne "" } {
  396. ::gui::guiPopupFile $filename
  397. }
  398. }
  399. #
  400. #----------------------------------------------------------------
  401. #
  402. # ::gui::runCalcRL
  403. #
  404. # Run the experimental wavelet-based RL calculator.
  405. #
  406. #----------------------------------------------------------------
  407. proc ::gui::runCalcRL {} {
  408. # Make sure that the dialogs exist
  409. if { ! [winfo exists $::gui::dialog(calcRLRun,dialog)] } {
  410. ::gui::_createCalcRLRunDialog
  411. }
  412. if { ! [winfo exists $::gui::dialog(calcRLLog,dialog)] } {
  413. ::gui::_createCalcRLLogDialog
  414. }
  415. # Open a "run" window, let them change settings,
  416. # and check to see if they hit the "run" button.
  417. set result [$::gui::dialog(calcRLRun,dialog) draw]
  418. if { $result == 0 } {
  419. #------------------------------------------------
  420. # Save the cross section and generate the
  421. # calcRL input file
  422. #------------------------------------------------
  423. ::gui::guiSave
  424. ::calcRL::genInputFile $::gui::_nodename $::Stackup::frequency
  425. # Figure out command and filename
  426. set cmd [auto_execok calcRL]
  427. set filename ${::gui::_nodename}.ri
  428. # Translate frequencies to Hz
  429. foreach freq $::gui::calcRLfrequencies {
  430. lappend frequencies [::units::convert $freq "Hz"]
  431. }
  432. #------------------------------------------------
  433. # We need to run calcRL multiple times for
  434. # multiple frequencies. We want to have
  435. # asynchronous execution, but we can only tie
  436. # one process pipeline to the log text widget.
  437. # (Multiple [open "|calcRL..."] calls would
  438. # interleave their output.)
  439. #
  440. # Since /bin/sh might not be available, we will
  441. # write a tcl script with the proper number of
  442. # exec commands.
  443. #
  444. # Unfortunately, we have to modify the input
  445. # file each time we execute the calcRL program.
  446. # But all the info for creating a new data
  447. # file is in this interpreter. So our script
  448. # becomes a bunch of inline data and exec commands.
  449. #------------------------------------------------
  450. # Start building script
  451. set script {
  452. # /bin/tclsh
  453. # Dynamically Created Script for running calcRL
  454. #
  455. # We need to repeately re-write the input
  456. # file with new frequency values.
  457. proc writeInputFile {filename data} {
  458. set fp [open $filename "w"]
  459. puts $fp $data
  460. close $fp
  461. }
  462. }
  463. # No "append" for the first frequency, so
  464. # we get a clean set of output files
  465. set freq [lindex $frequencies 0]
  466. ::calcRL::genInputFile $::gui::_nodename $freq
  467. set fp [open ${filename}.in "r"]
  468. set data [read $fp]
  469. close $fp
  470. append script "writeInputFile \"$filename.in\" \{$data\}\n"
  471. append script "catch {exec $cmd \"$filename\" \"\"} result\n"
  472. append script "puts \$result\n"
  473. # Add data and commands for following frequencies
  474. foreach freq [lrange $frequencies 1 end] {
  475. ::calcRL::genInputFile $::gui::_nodename $freq
  476. set fp [open ${filename}.in "r"]
  477. set data [read $fp]
  478. close $fp
  479. append script "writeInputFile \"$filename.in\" \{$data\}\n"
  480. append script "catch {exec $cmd \"$filename\" append} result\n"
  481. append script "puts \$result\n"
  482. }
  483. append script "exit\n"
  484. # Write the script to a file
  485. # (oooh, if only tclsh took command line scripts...)
  486. set scriptfilename ${filename}.script
  487. set fp [open $scriptfilename "w"]
  488. puts $fp $script
  489. close $fp
  490. # ... finally ... we can execute the script
  491. set tclsh [auto_execok tclsh]
  492. if { $tclsh eq "" } {
  493. set tclsh [list [info nameofexecutable]]
  494. }
  495. set pipe [open "|$tclsh \"$scriptfilename\"" "r+"]
  496. # Connect stdout and stderror to the text widget
  497. fconfigure $pipe -buffering none -blocking 0
  498. set txt $::gui::dialog(calcRLLog,text)
  499. fileevent $pipe readable [list ::gui::_copyDataToText $txt $pipe]
  500. # Set busy cursor, clear the text widget, and draw dialog
  501. $txt configure -cursor watch
  502. $txt delete 1.0 end
  503. set result [$::gui::dialog(calcRLLog,dialog) draw]
  504. # Just in case the simulator is still running
  505. # when we get back from the dialog...
  506. catch {close $pipe}
  507. set defcursor [lindex [$txt configure -cursor] 3]
  508. $txt configure -cursor $defcursor
  509. # Did they click "View Results?"
  510. if { $result == 0 } {
  511. ::gui::guiPopupResultsFile "ri.out"
  512. }
  513. }
  514. }
  515. #----------------------------------------------------------------
  516. #
  517. # ::gui::runCalcCap
  518. #
  519. # Run the experimental wavelet-based RL calculator.
  520. #
  521. #----------------------------------------------------------------
  522. proc ::gui::runCalcCap {} {
  523. # Make sure that the dialogs exist
  524. if { ! [winfo exists $::gui::dialog(calcCapLog,dialog)] } {
  525. ::gui::_createCalcCapLogDialog
  526. }
  527. #------------------------------------------------
  528. # Save the cross section and generate the
  529. # calcCap input file
  530. #------------------------------------------------
  531. ::gui::guiSave
  532. ::calcCAP::genInputFile $::gui::_nodename
  533. # Figure out command and filename, and run it
  534. set cmd [auto_execok calcCAP]
  535. set filename ${::gui::_nodename}.cap
  536. set pipe [open "|$cmd \"$filename\"" "r+"]
  537. # Connect stdout and stderror to the text widget
  538. fconfigure $pipe -buffering none -blocking 0
  539. set txt $::gui::dialog(calcCapLog,text)
  540. fileevent $pipe readable [list ::gui::_copyDataToText $txt $pipe]
  541. # Set busy cursor, clear the text widget, and draw dialog
  542. $txt configure -cursor watch
  543. $txt delete 1.0 end
  544. set result [$::gui::dialog(calcCapLog,dialog) draw]
  545. # Just in case the simulator is still running
  546. # when we get back from the dialog...
  547. catch {close $pipe}
  548. set defcursor [lindex [$txt configure -cursor] 3]
  549. $txt configure -cursor $defcursor
  550. # Did they click "View Results?"
  551. if { $result == 0 } {
  552. ::gui::guiPopupResultsFile "cap.out"
  553. }
  554. }
  555. #----------------------------------------------------------------
  556. #
  557. # ::gui::guiPopupResultsFile
  558. #
  559. # Pop up a dialog with one of the simulation results
  560. # files. This is really a convenience function for
  561. # many of the GUI operations, which operate on
  562. # files with the same base name as the cross section.
  563. #
  564. # Appends the file type to the open file root
  565. # name ($::gui::_nodename), and call ::gui::guiPopupFile.
  566. #
  567. #----------------------------------------------------------------
  568. proc ::gui::guiPopupResultsFile { type } {
  569. ::gui::guiPopupFile ${::gui::_nodename}.$type
  570. }
  571. proc ::gui::_replaceNamedValues {} {
  572. #---------------------------------------------------------
  573. # Set the default units to match the gui-defined units for
  574. # length.
  575. #---------------------------------------------------------
  576. set ::units::default(Length) $::Stackup::defaultLengthUnits
  577. set ::units::default(Time) ps
  578. foreach item $::Stackup::structureList {
  579. set nme [string range $item 2 \
  580. [expr {[string length $item] - 1} ]]
  581. #-------------------------------------------------
  582. # Find out the component-type of $nme.
  583. #-------------------------------------------------
  584. if { [$nme isa GroundPlane] } {
  585. continue
  586. }
  587. if { [$nme isa DielectricLayer] || \
  588. [$nme isa RectangleDielectric] } {
  589. set type 1
  590. }
  591. if { [$nme isa RectangleConductors] || \
  592. [$nme isa CircleConductors] || \
  593. [$nme isa TrapezoidConductors] } {
  594. set type 2
  595. }
  596. #-------------------------------------------------
  597. # Loop through the attributes of this item.
  598. #-------------------------------------------------
  599. foreach def [$item configure] {
  600. set flg [lindex $def 0]
  601. set vle [lindex $def 2]
  602. #---------------------------------------------
  603. # Skip the attribute is the value is set to the default.
  604. #---------------------------------------------
  605. if { [string compare $vle [lindex $def 1]] == 0 } {
  606. continue
  607. }
  608. #---------------------------------------------
  609. # If attribute is conductivity, check if the value
  610. # is the name of a material. If it is, replace the
  611. # name with the numerical value.
  612. #---------------------------------------------
  613. if { ($type == 2) && \
  614. (! [string compare $flg "-conductivity"]) } {
  615. set nme [lindex $vle 0]
  616. if { ! [ catch { set val $::gui::_cValList($nme) } \
  617. result ] } {
  618. set val [lindex $vle 1]
  619. if { [string length $val] < 1 } {
  620. set val $::gui::_cValList($nme)
  621. }
  622. $item configure -conductivity $val
  623. }
  624. }
  625. #---------------------------------------------
  626. # If attribute is permittivity, check if the value
  627. # is the name of a material. If it is, replace the
  628. # name with the numerical value.
  629. #---------------------------------------------
  630. if { ($type == 1) && \
  631. (! [string compare $flg "-permittivity"]) } {
  632. set nme [lindex $vle 0]
  633. if { ![ catch { set val $::gui::_pValList($nme) } \
  634. result ] } {
  635. set val [lindex $vle 1]
  636. if { [string length $val] < 1 } {
  637. set val $::gui::_pValList($nme)
  638. }
  639. $item configure -permittivity $val
  640. }
  641. }
  642. #---------------------------------------------
  643. # If attribute is loss tangent, check if the value
  644. # is the name of a material. If it is, replace the
  645. # name with the numerical value.
  646. #---------------------------------------------
  647. if { ($type == 1) && \
  648. (! [string compare $flg "-lossTangent"]) } {
  649. set nme [lindex $vle 0]
  650. if { ! [ catch { set val $::gui::_ltValList($nme) } \
  651. result ] } {
  652. set val [lindex $vle 1]
  653. if { [string length $val] < 1 } {
  654. set val $::gui::_ltValList($nme)
  655. }
  656. $item configure -lossTangent $val
  657. }
  658. }
  659. }
  660. }
  661. }
  662. ##################################################################
  663. #
  664. #
  665. ##################################################################
  666. proc ::gui::guiRunIterateMMTL {} {
  667. if { [string length $::gui::_nodename] < 1 } {
  668. guiOpenExisting
  669. }
  670. ::bem::bemRunIterateMMTL $::gui::_nodename $::gui::_num_c_segs \
  671. $::gui::_num_p_segs 1 $::gui::f1 $::gui::f1
  672. }
  673. ##################################################################
  674. ##################################################################
  675. proc ::gui::guiRunSweepMMTL {} {
  676. if { [string length $::gui::_nodename] < 1 } {
  677. guiOpenExisting
  678. }
  679. ::bem::bemRunSweepMMTL $::gui::_nodename $::gui::_num_c_segs \
  680. $::gui::_num_p_segs 1 $::gui::f1 $::gui::f1
  681. }
  682. ##################################################################
  683. ##################################################################
  684. proc ::gui::guiRunFee2dDisplay {} {
  685. ::fem::femRunFee2dDisplay [file join $::scriptDir \
  686. ${::gui::_nodename}.fee2d]
  687. }
  688. ##################################################################
  689. ##################################################################
  690. proc ::gui::guiSaveFee2d {} {
  691. #---------------------------------------------------------
  692. # Set the default units to match the gui-defined units for
  693. # length.
  694. #---------------------------------------------------------
  695. set ::units::default(Length) $::Stackup::defaultLengthUnits
  696. set ::units::default(Time) ps
  697. _replaceNamedValues
  698. if { [string length $::gui::_nodename] < 1 } {
  699. ::gui::guiSaveAs
  700. }
  701. ::fem::femSave [file join $::scriptDir $::gui::_nodename]
  702. }
  703. ##################################################################
  704. ##################################################################
  705. proc ::gui::guiRunFee2dRun {} {
  706. ::fem::femRunFee2d ${::gui::_nodename}.fee2d
  707. }
  708. ##################################################################
  709. ##################################################################
  710. proc ::gui::guiRunFee2dPlotTranParameters {} {
  711. ::fem::femPlotTranParameters [file join $::scriptDir \
  712. ${::gui::_nodename}.fee2d]
  713. }
  714. ##################################################################
  715. ##################################################################
  716. proc ::gui::guiRunFee2dPlotEigenParameters {} {
  717. ::fem::femPlotEigenParameters [file join $::scriptDir \
  718. ${::gui::_nodename}.fee2d]
  719. }
  720. ##########################################################
  721. # Write the input file for the program the calculates
  722. # resistance/inductance.
  723. ##########################################################
  724. proc ::gui::guiGenRLinputFiles {} {
  725. ::calcRL::calcRL_GenInputFiles $::gui::_nodename
  726. }
  727. proc ::gui::guiRunRLbatch { flg } {
  728. ::calcRL::calcRL_RunBatch $::gui::_nodename $flg
  729. ::gui::guiPopupResultsFile "ri.out"
  730. }
  731. proc ::gui::guiRunRLgraphical {} {
  732. ::calcRL::calcRL_RunGraphical $::gui::_nodename
  733. }
  734. ##########################################################
  735. # Write the input file for the program the calculates
  736. # capacitance.
  737. ##########################################################
  738. proc ::gui::guiGenCAPinputFiles {} {
  739. ::calcCAP::calcCAP_GenInputFiles $::gui::_nodename
  740. }
  741. proc ::gui::guiRunCAPbatch {} {
  742. ::calcCAP::calcCAP_RunBatch $::gui::_nodename
  743. ::gui::guiPopupResultsFile "cap.out"
  744. }
  745. proc ::gui::guiRunCAPgraphic {} {
  746. ::calcCAP::calcCAP_RunGraphical $::gui::_nodename
  747. }