gui_elements.tcl 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485
  1. #----------------------------------------------------------------
  2. #
  3. # gui_elements.tcl
  4. #
  5. # Callback functions for TNT GUI operation.
  6. # ::gui::_selectNode
  7. # ::gui::_fillGlobalValues
  8. # ::gui::_highlightSelected
  9. # ::gui::_drpendComp
  10. # ::gui::_nameChangedWarning
  11. # ::gui::_modify
  12. # ::gui::_delete
  13. # ::gui::_deleteAll
  14. # ::gui::_addGroundPlane
  15. # ::gui::_chckElementGrnd
  16. # ::gui::_chckElementDiel
  17. # ::gui::_chckElementCond
  18. # ::gui::_buildTree
  19. # ::gui::_addRectDielectric
  20. # ::gui::_addDielectric
  21. # ::gui::_insertInTree
  22. # ::gui::_addConductor
  23. # ::gui::_configureColor
  24. # ::gui::_readMaterialList
  25. # ::gui::guiSetupPrinter
  26. # ::gui::_finishPrinter
  27. # ::gui::_putDielectricLayerToFile
  28. # ::gui::_putRectangleDielectricToFile
  29. # ::gui::_putRectangleConductorsToFile
  30. # ::gui::_putCircleConductorsToFile
  31. # ::gui::_putTrapezoidConductorsToFile
  32. # ::gui::_putGroundPlaneToFile
  33. # ::gui::guiReadNewPermittivityList
  34. # ::gui::guiReadNewLossTangentList
  35. # ::gui::guiReadNewConductivityList
  36. # ::gui::_logDesignAttributes
  37. # ::gui::_setDefaultUnits
  38. # ::gui::_getWidthHeight
  39. #
  40. #
  41. # Sharon Zahn
  42. # October 9, 2002
  43. #
  44. # Copyright 2002-2004 Mayo Foundation. All Rights Reserved
  45. # $Id: gui_elements.tcl,v 1.16 2004/07/20 14:51:55 techenti Exp $
  46. #
  47. #----------------------------------------------------------------
  48. package require Itcl
  49. package provide gui 2.0
  50. #------------------------------------------------------
  51. # New/Update/Rename Structure Procedures
  52. #
  53. # When creating a new cross section structure,
  54. # set all dialog fields to defaults, open the
  55. # dialog, check the results, create the new element.
  56. #------------------------------------------------------
  57. proc ::gui::newStructure {type} {
  58. #------------------------------------------------------
  59. # Create new object, in global namespace
  60. # A simple "::#auto" would do the trick, but we'll create
  61. # an abbreviated name, based on the class type, but
  62. # with maximum of four letters per word
  63. # (e.g. RectangleConductors -> RectCond)
  64. #------------------------------------------------------
  65. foreach word [regexp -inline -all {[A-Z][^A-Z]*} $type] {
  66. append name [string range $word 0 3]
  67. }
  68. set i 1
  69. while {[info command ::$name$i] != ""} {incr i}
  70. set objname $name$i
  71. set obj [$type ::$objname]
  72. #------------------------------------------------------
  73. # Create dialog, if necessary
  74. #------------------------------------------------------
  75. set dlg $::gui::dialog($type,dialog)
  76. if { ! [winfo exists $dlg] } {
  77. set dlg [::gui::_createStructureDialog $type]
  78. }
  79. #------------------------------------------------------
  80. # Set dialog field values from object public variables
  81. #------------------------------------------------------
  82. set ::gui::dialog($type,name) $objname
  83. foreach var [$obj info variable] {
  84. if { [$obj info variable $var -protection] == "public" } {
  85. lappend attributes [namespace tail $var]
  86. }
  87. }
  88. foreach var $attributes {
  89. set ::gui::dialog($type,$var) [$obj cget -$var]
  90. }
  91. #------------------------------------------------------
  92. # Configure the dialog for "new", draw it, and
  93. # interpret the result
  94. #------------------------------------------------------
  95. $dlg itemconfigure 0 -state normal ;# add
  96. $dlg itemconfigure 1 -state disabled ;# modify
  97. $dlg itemconfigure 2 -state disabled ;# delete
  98. $dlg configure -default 0
  99. set result [$dlg draw]
  100. switch -- $result {
  101. -1 -
  102. 3 {
  103. #---------------------------
  104. # Cancel
  105. #---------------------------
  106. itcl::delete object $obj
  107. return
  108. }
  109. 0 {
  110. #---------------------------
  111. # Add new structure
  112. #---------------------------
  113. # Insert the structure name into the GUI tree
  114. # (We don't have to add to the canvas, as the object
  115. # automatically inserts itself into ::Stackup.)
  116. $::gui::_tree insert 0 root $objname -text $objname
  117. # Copy dialog values to object
  118. foreach var $attributes {
  119. $objname configure -$var $::gui::dialog($type,$var)
  120. }
  121. # Check the name, in case they tried
  122. # to rename the object.
  123. set newname $::gui::dialog($type,name)
  124. if { $newname != $objname } {
  125. ::gui::renameStructure $objname $newname
  126. }
  127. }
  128. }
  129. #---------------------------------------
  130. # Redraw/rezoom the canvas
  131. #---------------------------------------
  132. ::gui::_canvas_redraw
  133. ::gui::_canvas_zoom_fit $::gui::_canvas
  134. }
  135. #----------------------------------------------------------------
  136. #
  137. # ::gui::updateStructure
  138. #
  139. # Open the structure dialog to allow the user to
  140. # change parameters of the specified cross section object.
  141. #
  142. # This function is usually called by a double-click on
  143. # the GUI.
  144. #
  145. # Arguments:
  146. # objname Name of cross section object
  147. #
  148. # Results:
  149. # This procedure will create (if necessary) a structure
  150. # entry dialog and set the entry values from the object.
  151. # It will draw the dialog and wait for the user to close
  152. # it. The object will be updated, or it may be deleted.
  153. # Then the canvas is redrawn.
  154. #
  155. #----------------------------------------------------------------
  156. proc ::gui::updateStructure {objname} {
  157. #------------------------------------------------------
  158. # fine object and type
  159. #------------------------------------------------------
  160. set obj [namespace which -command $objname]
  161. if { $obj eq "" } {
  162. return
  163. }
  164. set type [namespace tail [$obj info class]]
  165. #------------------------------------------------------
  166. # Make sure the dialog exists
  167. #------------------------------------------------------
  168. set dlg $::gui::dialog($type,dialog)
  169. if { ! [winfo exists $dlg] } {
  170. set dlg [::gui::_createStructureDialog $type]
  171. }
  172. #------------------------------------------------------
  173. # Set dialog field values from object public variables
  174. #------------------------------------------------------
  175. set ::gui::dialog($type,name) $objname
  176. foreach var [$obj info variable] {
  177. if { [$obj info variable $var -protection] == "public" } {
  178. lappend attributes [namespace tail $var]
  179. }
  180. }
  181. foreach var $attributes {
  182. set ::gui::dialog($type,$var) [$obj cget -$var]
  183. }
  184. #------------------------------------------------------
  185. # Configure the dialog for "update", draw it, and
  186. # interpret the result
  187. #------------------------------------------------------
  188. $dlg itemconfigure 0 -state disabled ;# add
  189. $dlg itemconfigure 1 -state normal ;# modify
  190. $dlg itemconfigure 2 -state normal ;# delete
  191. $dlg configure -default 1
  192. set result [$dlg draw]
  193. switch -- $result {
  194. -1 -
  195. 3 {
  196. #---------------------------
  197. # Cancel
  198. #---------------------------
  199. return
  200. }
  201. 1 {
  202. #---------------------------
  203. # Modify structure object
  204. #---------------------------
  205. # Copy dialog values to object
  206. foreach var $attributes {
  207. $obj configure -$var $::gui::dialog($type,$var)
  208. }
  209. # Check the name, in case they tried
  210. # to rename the object.
  211. set newname $::gui::dialog($type,name)
  212. if { $newname != $objname } {
  213. ::gui::renameStructure $objname $newname
  214. }
  215. }
  216. 2 {
  217. #---------------------------
  218. # Delete from stackup
  219. #---------------------------
  220. # Remove from the GUI tree
  221. $::gui::_tree delete $objname
  222. # delete object
  223. itcl::delete object $obj
  224. }
  225. }
  226. #---------------------------------------
  227. # Redraw the canvas
  228. #---------------------------------------
  229. ::gui::_canvas_redraw
  230. }
  231. proc ::gui::renameStructure {oldname newname} {
  232. #------------------------------------------------------
  233. # Don't overwrite an existing command name.
  234. #
  235. # It would be nice if we could restrict only
  236. # to renaming over existing object names,
  237. # but we have to impose stricter limits.
  238. # If we allow the user to rename a structure
  239. # to something like "if", then most of this
  240. # program won't run. :-(
  241. #
  242. # Some adventurous day, we may put all the
  243. # model objects in a separate namespace, so
  244. # there will be less restrictions.
  245. #------------------------------------------------------
  246. if { [info command ::$newname] != "" } {
  247. tk_messageBox -title "Cannot rename" -icon warning -type ok \
  248. -message "Cannot rename '$oldname' to '$newname' because it
  249. conflicts with an existing object or Tcl command."
  250. return
  251. }
  252. # otherwise, its OK. Rename the object.
  253. set oldobj [namespace which -command $oldname]
  254. set newobj [namespace qualifiers $oldobj]::$newname
  255. rename $oldobj $newobj
  256. # Update the layer stackup
  257. set i [lsearch $::Stackup::structureList $oldobj]
  258. set ::Stackup::structureList \
  259. [lreplace $::Stackup::structureList $i $i $newobj]
  260. # Update the GUI
  261. set i [$::gui::_tree index $oldname]
  262. $::gui::_tree delete $oldname
  263. $::gui::_tree insert $i root $newname -text $newname
  264. }
  265. #------------------------------------------------------
  266. #
  267. # ::gui::highlightItem
  268. #
  269. # Apply highlighting to the specified cross section
  270. # object in both the canvas and the tree.
  271. #
  272. #------------------------------------------------------
  273. proc ::gui::highlightItem { objname } {
  274. # Select the object on the canvas
  275. ::gui::_canvasDraw_visitor setTagToSelect $objname
  276. ::gui::_canvas_redraw
  277. # Set or clear the tree selection
  278. if { $objname eq "" } {
  279. $::gui::_tree selection clear
  280. } else {
  281. # Set tree selection
  282. $::gui::_tree selection set $objname
  283. }
  284. }
  285. ##################################################################
  286. # Select a component from the tree structure.
  287. ##################################################################
  288. proc ::gui::_selectNode { node } {
  289. $::gui::_tree selection clear
  290. $::gui::_tree selection set $node
  291. update
  292. set ::gui::_currentNode $node
  293. set objnme [$::gui::_tree itemcget $node -text]
  294. # Select item in the canvas
  295. ::gui::_canvasDraw_visitor setTagToSelect $objnme
  296. ::gui::_canvas_redraw
  297. }
  298. ##################################################################
  299. # Fill the appropriate global values from selected component.
  300. ##################################################################
  301. proc ::gui::_fillGlobalValues {objnme} {
  302. #----------------------------------
  303. # Is this object a groundplane?
  304. #----------------------------------
  305. if { [$objnme isa GroundPlane] } {
  306. set ::gui::_gname $objnme
  307. # set ::gui::_gthickness [$objnme cget -thickness]
  308. return
  309. }
  310. #----------------------------------
  311. # Is this object a dielectric?
  312. #----------------------------------
  313. if { [$objnme isa DielectricLayer] } {
  314. set ::gui::_dname $objnme
  315. set ::gui::_thickness [$objnme cget -thickness]
  316. set ::gui::_permittivity [$objnme cget -permittivity]
  317. set ::gui::_permeability [$objnme cget -permeability]
  318. set ::gui::_lossTangent [$objnme cget -lossTangent]
  319. return
  320. }
  321. #----------------------------------
  322. # Is this object a rectangle-dielectric?
  323. #----------------------------------
  324. if { [$objnme isa RectangleDielectric] } {
  325. set ::gui::_dRname $objnme
  326. set ::gui::_dheight [$objnme cget -height]
  327. set ::gui::_dwidth [$objnme cget -width]
  328. set ::gui::_dpermittivity [$objnme cget -permittivity]
  329. set ::gui::_dpermeability [$objnme cget -permeability]
  330. set ::gui::_dlossTangent [$objnme cget -lossTangent]
  331. set ::gui::_dnumber [$objnme cget -number]
  332. set ::gui::_dpitch [$objnme cget -pitch]
  333. set ::gui::_dxoffset [$objnme cget -xOffset]
  334. set ::gui::_dyoffset [$objnme cget -yOffset]
  335. return
  336. }
  337. #----------------------------------
  338. # Is this object a rectangle-conductor?
  339. #----------------------------------
  340. if { [$objnme isa RectangleConductors] } {
  341. set ::gui::_rname $objnme
  342. set ::gui::_rheight [$objnme cget -height]
  343. set ::gui::_rwidth [$objnme cget -width]
  344. set ::gui::_rconductivity [$objnme cget -conductivity]
  345. set ::gui::_rnumber [$objnme cget -number]
  346. set ::gui::_rpitch [$objnme cget -pitch]
  347. set ::gui::_rxoffset [$objnme cget -xOffset]
  348. set ::gui::_ryoffset [$objnme cget -yOffset]
  349. return
  350. }
  351. #----------------------------------
  352. # Is this object a circle-conductor?
  353. #----------------------------------
  354. if { [$objnme isa CircleConductors] } {
  355. set ::gui::_cname $objnme
  356. set ::gui::_cdiameter [$objnme cget -diameter]
  357. set ::gui::_cconductivity [$objnme cget -conductivity]
  358. set ::gui::_cnumber [$objnme cget -number]
  359. set ::gui::_cpitch [$objnme cget -pitch]
  360. set ::gui::_cxoffset [$objnme cget -xOffset]
  361. set ::gui::_cyoffset [$objnme cget -yOffset]
  362. return
  363. }
  364. #----------------------------------
  365. # Is this object a trapezoid-conductor?
  366. #----------------------------------
  367. if { [$objnme isa TrapezoidConductors] } {
  368. set ::gui::_tname $objnme
  369. set ::gui::_theight [$objnme cget -height]
  370. set ::gui::_ttopwidth [$objnme cget -topWidth]
  371. set ::gui::_tbotwidth [$objnme cget -bottomWidth]
  372. set ::gui::_tconductivity [$objnme cget -conductivity]
  373. set ::gui::_tnumber [$objnme cget -number]
  374. set ::gui::_tpitch [$objnme cget -pitch]
  375. set ::gui::_txoffset [$objnme cget -xOffset]
  376. set ::gui::_tyoffset [$objnme cget -yOffset]
  377. return
  378. }
  379. }
  380. ##################################################################
  381. # Highlight the selected item in the graphic window.
  382. ##################################################################
  383. proc ::gui::_highlightSelected { node objnme } {
  384. $::gui::_tree selection set $node
  385. update
  386. set ::gui::_currentNode $node
  387. # set objnme [$tree itemcget $node -text]
  388. set objnme [format {::%s} $objnme]
  389. #------------------------------------------------
  390. # Highlight the appropriate entry form for this item.
  391. #------------------------------------------------
  392. set ::gui::selectedObject $objnme
  393. #------------------------------------------------
  394. # Put the currently defined values into the
  395. # appropriate form.
  396. #------------------------------------------------
  397. #----------------------------------
  398. # Get rid of the leading ::
  399. #----------------------------------
  400. set lgt [string length $objnme]
  401. set nme1 [string range $objnme 2 $lgt]
  402. ::gui::_fillGlobalValues $nme1
  403. }
  404. ##################################################################
  405. # Finish moving the selected component in the tree.
  406. ##################################################################
  407. proc ::gui::_drpendComp { plistbox psource listdrp \
  408. opertr type datav } {
  409. set itemToMovePos [$::gui::_tree index $datav]
  410. set pos [lindex $listdrp 2]
  411. if { $pos > $itemToMovePos } {
  412. set mvto [expr {$pos - 1}]
  413. } else {
  414. set mvto $pos
  415. }
  416. if { $mvto < 1 } {
  417. set mvto 0
  418. }
  419. $::gui::_tree move root $datav $mvto
  420. set lst $::Stackup::structureList
  421. set lgt [expr {[llength $lst] - 1}]
  422. set indx1 [expr {$lgt - $itemToMovePos}]
  423. set it1 [lindex $lst $indx1]
  424. set indx2 [expr {$lgt - $pos}]
  425. set cnt 0
  426. set newlist ""
  427. if { $indx2 < 0 } {
  428. lappend newlist $it1
  429. }
  430. foreach snme $::Stackup::structureList {
  431. if { $cnt == $indx2 } {
  432. if { [string compare $snme $it1] != 0 } {
  433. lappend newlist $snme
  434. }
  435. if { $cnt > -1 } {
  436. lappend newlist $it1
  437. }
  438. } else {
  439. if { [string compare $snme $it1] != 0 } {
  440. lappend newlist $snme
  441. }
  442. }
  443. incr cnt
  444. }
  445. set ::Stackup::structureList $newlist
  446. #---------------------------------------
  447. # Redraw the canvas.
  448. #---------------------------------------
  449. ::gui::_canvas_redraw
  450. }
  451. ##########################################################
  452. # Warn the user that this cannot be done.
  453. ##########################################################
  454. proc ::gui::_nameChangedWarning { name newname } {
  455. set strg "Name: $name cannot be changed! $newname is ignored."
  456. ::gui::guiPopupWarning $strg
  457. }
  458. ##################################################################
  459. # Set the selected component values to the global values.
  460. ##################################################################
  461. proc ::gui::_modify {} {
  462. if { [string length [$::gui::_tree selection get]] < 2 } {
  463. ::gui::guiPopupWarning "Select the object you wish to modify."
  464. return
  465. }
  466. set elmnt [$::gui::_tree itemcget $::gui::_currentNode -text]
  467. if { [$elmnt isa GroundPlane] } {
  468. if { [string compare $elmnt $::gui::_gname] != 0 } {
  469. ::gui::_nameChangedWarning $elmnt $::gui::_gname
  470. }
  471. # $elmnt configure -thickness $::gui::_gthickness
  472. #---------------------------------------
  473. # Redraw the canvas.
  474. #---------------------------------------
  475. ::gui::_canvas_redraw
  476. }
  477. if { [$elmnt isa DielectricLayer] } {
  478. if { [string compare $elmnt $::gui::_dname] != 0 } {
  479. ::gui::_nameChangedWarning $elmnt $::gui::_dname
  480. }
  481. $elmnt configure -thickness $::gui::_thickness
  482. $elmnt configure -permittivity $::gui::_permittivity
  483. $elmnt configure -permeability $::gui::_permeability
  484. $elmnt configure -lossTangent $::gui::_lossTangent
  485. #---------------------------------------
  486. # Redraw the canvas.
  487. #---------------------------------------
  488. ::gui::_canvas_redraw
  489. return
  490. }
  491. if { [$elmnt isa RectangleDielectric] } {
  492. if { [string compare $elmnt $::gui::_dname] != 0 } {
  493. ::gui::_nameChangedWarning $elmnt $::gui::_dRname
  494. }
  495. $elmnt configure -permittivity $::gui::_dpermittivity
  496. $elmnt configure -permeability $::gui::_dpermeability
  497. $elmnt configure -lossTangent $::gui::_dlossTangent
  498. $elmnt configure -height $::gui::_dheight
  499. $elmnt configure -width $::gui::_dwidth
  500. $elmnt configure -number $::gui::_rnumber
  501. $elmnt configure -pitch $::gui::_dpitch
  502. $elmnt configure -xOffset $::gui::_dxoffset
  503. $elmnt configure -yOffset $::gui::_dyoffset
  504. #---------------------------------------
  505. # Redraw the canvas.
  506. #---------------------------------------
  507. ::gui::_canvas_redraw
  508. return
  509. }
  510. if { [$elmnt isa RectangleConductors] } {
  511. if { [string compare $elmnt $::gui::_rname] != 0 } {
  512. ::gui::_nameChangedWarning $elmnt $::gui::_rname
  513. }
  514. $elmnt configure -height $::gui::_rheight
  515. $elmnt configure -width $::gui::_rwidth
  516. $elmnt configure -conductivity $::gui::_rconductivity
  517. $elmnt configure -number $::gui::_rnumber
  518. $elmnt configure -pitch $::gui::_rpitch
  519. $elmnt configure -xOffset $::gui::_rxoffset
  520. $elmnt configure -yOffset $::gui::_ryoffset
  521. #---------------------------------------
  522. # Redraw the canvas.
  523. #---------------------------------------
  524. ::gui::_canvas_redraw
  525. return
  526. }
  527. if { [$elmnt isa CircleConductors] } {
  528. if { [string compare $elmnt $::gui::_cname] != 0 } {
  529. ::gui::_nameChangedWarning $elmnt $::gui::_cname
  530. }
  531. $elmnt configure -diameter $::gui::_cdiameter
  532. $elmnt configure -conductivity $::gui::_cconductivity
  533. $elmnt configure -number $::gui::_cnumber
  534. $elmnt configure -pitch $::gui::_cpitch
  535. $elmnt configure -xOffset $::gui::_cxoffset
  536. $elmnt configure -yOffset $::gui::_cyoffset
  537. #---------------------------------------
  538. # Redraw the canvas.
  539. #---------------------------------------
  540. ::gui::_canvas_redraw
  541. return
  542. }
  543. if { [$elmnt isa TrapezoidConductors] } {
  544. if { [string compare $elmnt $::gui::_tname] != 0 } {
  545. ::gui::_nameChangedWarning $elmnt $::gui::_tname
  546. }
  547. $elmnt configure -height $::gui::_theight
  548. $elmnt configure -topWidth $::gui::_ttopwidth
  549. $elmnt configure -bottomWidth $::gui::_tbotwidth
  550. $elmnt configure -conductivity $::gui::_tconductivity
  551. $elmnt configure -number $::gui::_tnumber
  552. $elmnt configure -pitch $::gui::_tpitch
  553. $elmnt configure -xOffset $::gui::_txoffset
  554. $elmnt configure -yOffset $::gui::_tyoffset
  555. #---------------------------------------
  556. # Redraw the canvas.
  557. #---------------------------------------
  558. ::gui::_canvas_redraw
  559. return
  560. }
  561. }
  562. ##########################################################
  563. # Delete all the cross section structures
  564. ##########################################################
  565. proc ::gui::_deleteAll {} {
  566. #---------------------------------------
  567. # Delete everything from the layer stackup,
  568. # the tree, and canvas.
  569. #---------------------------------------
  570. foreach obj $::Stackup::structureList {
  571. catch {itcl::delete object $obj}
  572. }
  573. set ::Stackup::structureList [list]
  574. $::gui::_tree delete [$::gui::_tree nodes root]
  575. $::gui::_canvas delete all
  576. #---------------------------------------
  577. # set global variables to a sane state
  578. #---------------------------------------
  579. set ::gui::_currentNode ""
  580. set ::gui::_tagSelected ""
  581. set ::gui::_title ""
  582. set ::gui::_num_c_segs 10
  583. set ::gui::_num_p_segs 10
  584. }
  585. ##########################################################
  586. # Add a groundplane.
  587. ##########################################################
  588. proc ::gui::_addGroundPlane {} {
  589. if { [string length $::gui::_gname] < 1 } {
  590. incr ::gui::_grndCount
  591. set nme [format {::G%s} G$::gui::_grndCount]
  592. } else {
  593. set nme [format {::%s} $::gui::_gname]
  594. }
  595. set result [lsearch -exact \
  596. [itcl::find objects -class GroundPlane] $nme]
  597. if { $result > -1 } {
  598. set msgdlg [MessageDlg .msg \
  599. -message "$nme exists. Use a different name." \
  600. -title Warning -type ok]
  601. return
  602. }
  603. #---------------------------------------
  604. # Insert the ground-plane item into the tree.
  605. #---------------------------------------
  606. ::gui::_insertInTree $nme $nme
  607. #---------------------------------------
  608. # Create the ground-plane object.
  609. #---------------------------------------
  610. GroundPlane $nme
  611. #---------------------------------------
  612. # Increment the ground-plane count (to
  613. # create unique names).
  614. #---------------------------------------
  615. incr ::gui::_grndCount
  616. #---------------------------------------
  617. # Redraw the canvas.
  618. #---------------------------------------
  619. ::gui::_canvas_redraw
  620. }
  621. ##########################################################
  622. # Check the ground, increment the ground count, and
  623. # insert into the tree.
  624. ##########################################################
  625. proc ::gui::_chckElementGrnd { obj lstg } {
  626. foreach item $lstg {
  627. if { [string compare $obj $item] == 0 } {
  628. # Increment the dielectric element count.
  629. incr ::gui::_grndCount
  630. #---------------------------------------
  631. # Insert the dielectric item into the tree.
  632. #---------------------------------------
  633. ::gui::_insertInTree $item
  634. break
  635. }
  636. }
  637. }
  638. ##########################################################
  639. # Check the dielectric, increment the dielectric count, and
  640. # insert into the tree.
  641. ##########################################################
  642. proc ::gui::_chckElementDiel { obj lstd } {
  643. foreach item $lstd {
  644. if { [string compare $obj $item] == 0 } {
  645. # Increment the dielectric element count.
  646. incr ::gui::_dielCount
  647. #---------------------------------------
  648. # Insert the dielectric item into the tree.
  649. #---------------------------------------
  650. ::gui::_insertInTree $item $item
  651. break
  652. }
  653. }
  654. }
  655. ##########################################################
  656. # Check what kind of conductor this is, count according to
  657. # the type (circle, rectangle, or trapezoid), and insert
  658. # into the tree.
  659. ##########################################################
  660. proc ::gui::_chckElementCond { obj lstr lstc lstt } {
  661. foreach item $lstr {
  662. if { [string compare $obj $item] == 0 } {
  663. # Increment the dielectric element count.
  664. incr ::gui::_condCount
  665. #---------------------------------------
  666. # Insert the dielectric item into the tree.
  667. #---------------------------------------
  668. ::gui::_insertInTree $item $item
  669. break
  670. }
  671. }
  672. foreach item $lstc {
  673. if { [string compare $obj $item] == 0 } {
  674. # Increment the dielectric element count.
  675. incr ::gui::_condCount
  676. #---------------------------------------
  677. # Insert the dielectric item into the tree.
  678. #---------------------------------------
  679. ::gui::_insertInTree $item $item
  680. break
  681. }
  682. }
  683. foreach item $lstt {
  684. if { [string compare $obj $item] == 0 } {
  685. # Increment the dielectric element count.
  686. incr ::gui::_condCount
  687. #---------------------------------------
  688. # Insert the dielectric item into the tree.
  689. #---------------------------------------
  690. ::gui::_insertInTree $item $item
  691. break
  692. }
  693. }
  694. }
  695. ##########################################################
  696. # Add a dielectric.
  697. ##########################################################
  698. proc ::gui::_addRectDielectric {} {
  699. if { [string length $::gui::_dRname] < 1 } {
  700. incr ::gui::_dielCount
  701. set nme [format {::Diel%d} $::gui::_dielCount]
  702. } else {
  703. set nme [format {::%s} $::gui::_dRname]
  704. }
  705. # Increment the dielectric element count.
  706. #incr ::gui::_dielCount
  707. #---------------------------------------
  708. # Insert the dielectric item into the tree.
  709. #---------------------------------------
  710. ::gui::_insertInTree $nme $nme
  711. set result [lsearch -exact \
  712. [itcl::find objects -class RectangleDielectric] $nme]
  713. if { $result > -1 } {
  714. set msgdlg [MessageDlg .msg \
  715. -message "$nme exists. Use a different name." \
  716. -title Warning -type ok]
  717. return
  718. }
  719. set shape [RectangleDielectric $nme \
  720. -width $::gui::_dwidth \
  721. -height $::gui::_dheight \
  722. -permittivity $::gui::_dpermittivity \
  723. -permeability $::gui::_dpermeability \
  724. -lossTangent $::gui::_dlossTangent \
  725. -number $::gui::_dnumber \
  726. -pitch $::gui::_dpitch \
  727. -xOffset $::gui::_dxoffset \
  728. -yOffset $::gui::_dyoffset]
  729. #---------------------------------------
  730. # Redraw the canvas.
  731. #---------------------------------------
  732. ::gui::_canvas_redraw
  733. }
  734. ##########################################################
  735. # Add a dielectric.
  736. ##########################################################
  737. proc ::gui::_addDielectric {} {
  738. if { [string length $::gui::_dname] < 1 } {
  739. incr ::gui::_dielCount
  740. set nme [format {::D%d} $::gui::_dielCount]
  741. } else {
  742. set nme [format {::%s} $::gui::_dname]
  743. }
  744. set result [lsearch -exact \
  745. [itcl::find objects -class DielectricLayer] $nme]
  746. if { $result > -1 } {
  747. set msgdlg [MessageDlg .msg \
  748. -message "$nme exists. Use a different name." \
  749. -title Warning -type ok]
  750. return
  751. }
  752. # Increment the dielectric element count.
  753. #incr ::gui::_dielCount
  754. #---------------------------------------
  755. # Insert the dielectric item into the tree.
  756. #---------------------------------------
  757. ::gui::_insertInTree $nme $nme
  758. #--------------------------------------
  759. # Create the dielectric object.
  760. #---------------------------------------
  761. DielectricLayer $nme -permittivity $::gui::_permittivity \
  762. -permeability $::gui::_permeability \
  763. -lossTangent $::gui::_lossTangent \
  764. -thickness $::gui::_thickness
  765. #---------------------------------------
  766. # Redraw the canvas.
  767. #---------------------------------------
  768. ::gui::_canvas_redraw
  769. }
  770. ##########################################################
  771. # Insert the new item (a groundplane, dielectric, or a
  772. # conductor) into the design tree.
  773. ##########################################################
  774. proc ::gui::_insertInTree { objname } {
  775. $::gui::_tree insert 0 root $objname -text $objname
  776. }
  777. ##########################################################
  778. # Add a conductor.
  779. #
  780. # val: rectangle, circle or trapezoid
  781. ##########################################################
  782. proc ::gui::_addConductor {val} {
  783. if { [string compare $val "rectangle"] == 0} {
  784. if { [string length $::gui::_rname] < 1 } {
  785. incr ::gui::_condCount
  786. set nme [format {::Rect%d} $::gui::_condCount]
  787. } else {
  788. set nme [format {::%s} $::gui::_rname]
  789. }
  790. set result [lsearch -exact \
  791. [itcl::find objects -class RectangleConductors] $nme]
  792. if { $result > -1 } {
  793. set msgdlg [MessageDlg .msg \
  794. -message "$nme exists. Use a different name." \
  795. -title Warning -type ok]
  796. return
  797. }
  798. set shape [RectangleConductors $nme -width $::gui::_rwidth\
  799. -height $::gui::_rheight -conductivity $::gui::_rconductivity \
  800. -number $::gui::_rnumber -pitch $::gui::_rpitch -xOffset $::gui::_rxoffset \
  801. -yOffset $::gui::_ryoffset]
  802. }
  803. if { [string compare $val "circle"] == 0} {
  804. if { [string length $::gui::_cname] < 1 } {
  805. incr ::gui::_condCount
  806. set nme [format {::Circ%d} $::gui::_condCount]
  807. } else {
  808. set nme [format {::%s} $::gui::_cname]
  809. }
  810. set result [lsearch -exact \
  811. [itcl::find objects -class CircleConductors] $nme]
  812. if { $result > -1 } {
  813. set msgdlg [MessageDlg .msg \
  814. -message "$nme exists. Use a different name." \
  815. -title Warning -type ok]
  816. return
  817. }
  818. set shape [CircleConductors $nme \
  819. -diameter $::gui::_cdiameter \
  820. -conductivity $::gui::_cconductivity \
  821. -number $::gui::_cnumber -pitch $::gui::_cpitch \
  822. -xOffset $::gui::_cxoffset -yOffset $::gui::_cyoffset]
  823. }
  824. if { [string compare $val "trapezoid"] == 0} {
  825. if { [string length $::gui::_tname] < 1 } {
  826. incr ::gui::_condCount
  827. set nme [format {::Trap%d} $::gui::_condCount]
  828. } else {
  829. set nme [format {::%s} $::gui::_tname]
  830. }
  831. set result [lsearch -exact \
  832. [itcl::find objects -class TrapezoidConductors] $nme]
  833. if { $result > -1 } {
  834. set msgdlg [MessageDlg .msg \
  835. -message "$nme exists. Use a different name." \
  836. -title Warning -type ok]
  837. return
  838. }
  839. set shape [TrapezoidConductors $nme \
  840. -topWidth $::gui::_ttopwidth \
  841. -bottomWidth $::gui::_tbotwidth -height $::gui::_theight \
  842. -conductivity $::gui::_tconductivity \
  843. -number $::gui::_tnumber -pitch $::gui::_tpitch \
  844. -xOffset $::gui::_txoffset -yOffset $::gui::_tyoffset]
  845. }
  846. #---------------------------------------
  847. # Insert the conductor item into the tree.
  848. #---------------------------------------
  849. ::gui::_insertInTree $shape $shape
  850. incr ::gui::_condCount
  851. #---------------------------------------
  852. # Redraw the canvas.
  853. #---------------------------------------
  854. ::gui::_canvas_redraw
  855. }
  856. ##########################################################
  857. # Read in the new material attribute list.
  858. #
  859. # title : title for the pop-up window
  860. # arrList : list of name/value attributes from the file.
  861. # flg : true - file name being passed in
  862. # false - no file name so pop-up a file-selector
  863. # defaultFile: name of the file to open
  864. ##########################################################
  865. proc ::gui::_readMaterialList { title arrList flg defaultFile } {
  866. if { ! $flg } {
  867. set name $defaultFile
  868. } else {
  869. set typelist {
  870. {{mmtl files} {.list} }
  871. {{All Files} * }
  872. }
  873. set name [ tk_getOpenFile -filetypes $typelist \
  874. -title $title ]
  875. # Evade Windows double-click bug
  876. if { $::tcl_platform(platform) eq "windows" } {
  877. ::gui::drainEventQueue
  878. }
  879. if { [string length $name] < 1 } {
  880. return
  881. }
  882. }
  883. if { [array exists $arrList] } {
  884. unset $arrList
  885. }
  886. puts "Reading $name"
  887. set fp [open $name r]
  888. while { [gets $fp lne] > -1 } {
  889. set cname [lindex $lne 0]
  890. set cvalue [lindex $lne 1]
  891. set cmd [format "set %s(%s) %s" $arrList $cname $cvalue]
  892. eval $cmd
  893. }
  894. close $fp
  895. }
  896. ##########################################################
  897. # Set up a printer.
  898. ##########################################################
  899. proc ::gui::guiSetupPrinter {} {
  900. set ::gui::_savePrinterName $::gui::_printerName
  901. set ::gui::_saveColorMode $::gui::_colorMode
  902. if {! [winfo exists .prntFrame]} {
  903. set ::gui::_prntFrame [frame .prntFrame \
  904. -relief sunken -borderwidth 5]
  905. set seglbl [Label $::gui::_prntFrame.seglbl \
  906. -justify center -text "Printer Options"]
  907. grid $seglbl -columnspan 2 -sticky news -padx 4 -pady 4
  908. guiBuildLabelEntry $::gui::_prntFrame ::gui::_printerName "Printer:"
  909. set lb [Label $::gui::_prntFrame.lb -label "Color Mode:"]
  910. set sb [SpinBox $::gui::_prntFrame.sb \
  911. -textvariable ::gui::_colorMode \
  912. -values { color grey mono } ]
  913. grid $lb $sb -sticky news -padx 4 -pady 4
  914. set but1 [::gui::guiBuildButton $::gui::_prntFrame "OK" \
  915. "::gui::_finishPrinter 1" "Print"]
  916. set but2 [::gui::guiBuildButton $::gui::_prntFrame "Cancel" \
  917. "::gui::_finishPrinter 0" "Cancel the Print"]
  918. grid $but1 $but2 -sticky nw
  919. }
  920. place $::gui::_prntFrame -x 75 -y 300
  921. }
  922. ##########################################################
  923. # Finish setting up a printer.
  924. ##########################################################
  925. proc ::gui::_finishPrinter { opt } {
  926. place forget $::gui::_prntFrame
  927. if { $opt } {
  928. puts "*Setup Printer: $::gui::_printerName $::gui::_colorMode*"
  929. return
  930. }
  931. set ::gui::_printerName $::gui::_savePrinterName
  932. set ::gui::_colorMode $::gui::_saveColorMode
  933. }
  934. ##########################################################
  935. # Output the dielectric attributes.
  936. ##########################################################
  937. proc ::gui::_putDielectricLayerToFile { nme fp } {
  938. set thickness [$nme cget -thickness]
  939. set permittivity [$nme cget -permittivity]
  940. set permeability [$nme cget -permeability]
  941. set lossTangent [$nme cget -lossTangent]
  942. puts $fp "$nme: DielectricLayer"
  943. puts $fp " thikkckness : $thickness"
  944. puts $fp " permittivity: $permittivity"
  945. puts $fp " permeability: $permeability"
  946. puts $fp " lossTangent : $lossTangent"
  947. }
  948. ##########################################################
  949. # Output the dielectric attributes.
  950. ##########################################################
  951. proc ::gui::_putRectangleDielectricToFile { nme fp } {
  952. set thickness [$nme cget -thickness]
  953. set permittivity [$nme cget -permittivity]
  954. set permeability [$nme cget -permeability]
  955. set lossTangent [$nme cget -lossTangent]
  956. set dheight [$nme cget -height]
  957. set dwidth [$nme cget -width]
  958. set dnumber [$nme cget -number]
  959. set dpitch [$nme cget -pitch]
  960. set dxoffset [$nme cget -xOffset]
  961. set dyoffset [$nme cget -yOffset]
  962. puts $fp "$nme: DielectricLayer"
  963. puts $fp " thickness : $thickness"
  964. puts $fp " permittivity: $permittivity"
  965. puts $fp " permeability: $permeability"
  966. puts $fp " lossTangent : $lossTangent"
  967. puts $fp " height : $dheight"
  968. puts $fp " width : $drwidth"
  969. puts $fp " number : $dnumber"
  970. puts $fp " pitch : $dpitch"
  971. puts $fp " x-offset : $dxoffset"
  972. puts $fp " y-offset : $dyoffset"
  973. }
  974. ##########################################################
  975. # Output the rectangle conductor attributes.
  976. ##########################################################
  977. proc ::gui::_putRectangleConductorsToFile { nme fp } {
  978. set rheight [$nme cget -height]
  979. set rwidth [$nme cget -width]
  980. set rconductivity [$nme cget -conductivity]
  981. set rnumber [$nme cget -number]
  982. set rpitch [$nme cget -pitch]
  983. set rxoffset [$nme cget -xOffset]
  984. set ryoffset [$nme cget -yOffset]
  985. puts $fp "$nme: RectangleConductors"
  986. puts $fp " height : $rheight"
  987. puts $fp " width : $rwidth"
  988. puts $fp " conductivity: $rconductivity"
  989. puts $fp " number : $rnumber"
  990. puts $fp " pitch : $rpitch"
  991. puts $fp " x-offset : $rxoffset"
  992. puts $fp " y-offset : $ryoffset"
  993. }
  994. ##########################################################
  995. # Output the circle conductor attributes.
  996. ##########################################################
  997. proc ::gui::_putCircleConductorsToFile { nme fp } {
  998. set cdiameter [$nme cget -diameter]
  999. set cconductivity [$nme cget -conductivity]
  1000. set cnumber [$nme cget -number]
  1001. set cpitch [$nme cget -pitch]
  1002. set cxoffset [$nme cget -xOffset]
  1003. set cyoffset [$nme cget -yOffset]
  1004. puts $fp "$nme: CircleConductors"
  1005. puts $fp " diameter : $cdiameter"
  1006. puts $fp " conductivity: $cconductivity"
  1007. puts $fp " number : $cnumber"
  1008. puts $fp " pitch : $cpitch"
  1009. puts $fp " x-offset : $cxoffset"
  1010. puts $fp " y-offset : $cyoffset"
  1011. }
  1012. ##########################################################
  1013. # Output the trapezoid conductor attributes.
  1014. ##########################################################
  1015. proc ::gui::_putTrapezoidConductorsToFile { nme fp } {
  1016. set theight [$nme cget -height]
  1017. set ttopwidth [$nme cget -topWidth]
  1018. set tbotwidth [$nme cget -bottomWidth]
  1019. set tconductivity [$nme cget -conductivity]
  1020. set tnumber [$nme cget -number]
  1021. set tpitch [$nme cget -pitch]
  1022. set txoffset [$nme cget -xOffset]
  1023. set tyoffset [$nme cget -yOffset]
  1024. puts $fp "$nme: TrapezoidConductors"
  1025. puts $fp " height : $theight"
  1026. puts $fp " topWidth : $ttopwidth"
  1027. puts $fp " botWidth : $tbotwidth"
  1028. puts $fp " conductivity: $tconductivity"
  1029. puts $fp " number : $tnumber"
  1030. puts $fp " pitch : $tpitch"
  1031. puts $fp " x-offset : $txoffset"
  1032. puts $fp " y-offset : $tyoffset"
  1033. }
  1034. ##########################################################
  1035. # Output the ground plane attributes.
  1036. ##########################################################
  1037. proc ::gui::_putGroundPlaneToFile { nme fp } {
  1038. set gname $nme
  1039. # set gthickness [$nme cget -thickness]
  1040. puts $fp "$nme: GroundPlane"
  1041. #thickness : "$thickness"
  1042. }
  1043. ##########################################################
  1044. # Read in a new permittivity-list.
  1045. ##########################################################
  1046. proc ::gui::guiReadNewPermittivityList {} {
  1047. _readMaterialList "Read Permittivity List" ::gui::_pValList 1 \
  1048. [file join $::gui::scriptDir permittivity.list]
  1049. # _pValList is actually an array. Lets copy the values
  1050. # into a proper list.
  1051. set ::gui::_permittivityList [list]
  1052. foreach { name value } [ array get ::gui::_pValList ] {
  1053. lappend ::gui::_permittivityList "$name $value"
  1054. }
  1055. }
  1056. ##########################################################
  1057. # Read in a new loss-tangent list.
  1058. ##########################################################
  1059. proc ::gui::guiReadNewLossTangentList {} {
  1060. _readMaterialList "Read lossTangent List" ::gui::_ltValList 1 \
  1061. [file join $::gui::scriptDir loss_tangent.list]
  1062. # _ltValList is actually an array. Lets copy the values
  1063. # into a proper list.
  1064. set ::gui::_losstangentList [list]
  1065. foreach { name value } [ array get ::gui::_ltValList ] {
  1066. lappend ::gui::_losstangentList "$name $value"
  1067. }
  1068. }
  1069. ##########################################################
  1070. # Read in a new conductivity-list.
  1071. ##########################################################
  1072. proc ::gui::guiReadNewConductivityList {} {
  1073. _readMaterialList "Read Conductivity List" ::gui::_cValList 1 \
  1074. [file join $::gui::scriptDir conductivity.list]
  1075. # _cValList is actually an array. Lets copy the values
  1076. # into a proper list.
  1077. set ::gui::_conductivityList [list]
  1078. foreach { name value } [ array get ::gui::_cValList ] {
  1079. lappend ::gui::_conductivityList "$name $value"
  1080. }
  1081. }
  1082. ##########################################################
  1083. # Log the attributes of the design.
  1084. ##########################################################
  1085. proc ::gui::_logDesignAttributes { fp } {
  1086. #
  1087. # General attributes.
  1088. #
  1089. puts $fp "UNITS\t\t\t$::Stackup::defaultLengthUnits"
  1090. puts $fp "COUPLING_LENGTH\t\t$::Stackup::couplingLength"
  1091. puts $fp "RISE_TIME\t\t$::Stackup::riseTime"
  1092. puts $fp "CSEG\t\t\t$::gui::_num_c_segs"
  1093. puts $fp "DSEG\t\t\t$::gui::_num_p_segs"
  1094. set lst [itcl::find objects -class DielectricLayer]
  1095. set lstrd [itcl::find objects -class RectangleDielectric]
  1096. set numDiel [expr { [llength $lst] + [llength $lstrd] }]
  1097. puts $fp "NUM_DIEL\t\t$numDiel"
  1098. #
  1099. # Dielectric attributes.
  1100. #
  1101. foreach itm $lst {
  1102. if { [string length $itm] == 0 } {
  1103. break
  1104. }
  1105. set nme [string range $itm 2 [string length $itm]]
  1106. set strg [format {%s_THICKNESS} $nme]
  1107. puts $fp "$strg\t\t[$itm cget -thickness]"
  1108. set strg [format {%s_PERMITTIVITY} $nme]
  1109. puts $fp "$strg\t\t[$itm cget -permittivity]"
  1110. set strg [format {%s_LOSSTANGENT} $nme]
  1111. puts $fp "$strg\t\t[$itm cget -lossTangent]"
  1112. }
  1113. foreach itm $lstrd {
  1114. if { [string length $itm] == 0 } {
  1115. break
  1116. }
  1117. set nme [string range $itm 2 [string length $itm]]
  1118. set strg [format {%s_PERMITTIVITY} $nme]
  1119. puts $fp "$strg\t\t[$itm cget -permittivity]"
  1120. set strg [format {%s_LOSSTANGENT} $nme]
  1121. puts $fp "$strg\t\t[$itm cget -lossTangent]"
  1122. set num [$itm cget -number]
  1123. puts $fp "$strg\t\t$num"
  1124. if { $num > 1 } {
  1125. set pitch [$itm cget -pitch]
  1126. } else {
  1127. set pitch 0.0
  1128. }
  1129. set strg [format {%s_PITCH} $nme]
  1130. puts $fp "$strg\t\t$pitch"
  1131. set strg [format {%s_DISTANCE} $nme]
  1132. puts $fp "$strg\t\t[$itm cget -xOffset]"
  1133. set wdt [$itm cget -width]
  1134. set strg [format {%s_WIDTH} $nme]
  1135. puts $fp "$strg\t\t\t$wdt"
  1136. set strg [format {%s_HEIGHT} $nme]
  1137. set hgt [$itm cget -height]
  1138. puts $fp "$strg\t\t\t$hgt"
  1139. }
  1140. set st [itcl::find objects -class RectangleConductors]
  1141. set lst ""
  1142. foreach itm $st {
  1143. lappend lst $itm
  1144. }
  1145. set st [itcl::find objects -class CircleConductors]
  1146. foreach itm $st {
  1147. lappend lst $itm
  1148. }
  1149. set st [itcl::find objects -class TrapezoidConductors]
  1150. foreach itm $st {
  1151. lappend lst $itm
  1152. }
  1153. set numConds [llength $lst]
  1154. puts $fp "NUM_COND_SETS\t\t$numConds"
  1155. set shapes { RECTANGLE CIRCLE TRAPEZOID }
  1156. #
  1157. # Conductor attributes.
  1158. #
  1159. foreach itm $lst {
  1160. if { [string length $itm] == 0 } {
  1161. break
  1162. }
  1163. set nme [string range $itm 2 [string length $itm]]
  1164. set num [$itm cget -number]
  1165. set strg [format {%s_NUM_COND} $nme]
  1166. puts $fp "$strg\t\t$num"
  1167. if { $num > 1 } {
  1168. set pitch [$itm cget -pitch]
  1169. } else {
  1170. set pitch 0.0
  1171. }
  1172. set strg [format {%s_PITCH} $nme]
  1173. puts $fp "$strg\t\t$pitch"
  1174. set strg [format {%s_COND} $nme]
  1175. puts $fp "$strg\t\t[$itm cget -conductivity]"
  1176. set strg [format {%s_DISTANCE} $nme]
  1177. puts $fp "$strg\t\t[$itm cget -xOffset]"
  1178. set strg [format {%s_SHAPE} $nme]
  1179. if { [$itm isa RectangleConductors] } {
  1180. set opt 0
  1181. }
  1182. if { [$itm isa CircleConductors] } {
  1183. set opt 1
  1184. }
  1185. if { [$itm isa TrapezoidConductors] } {
  1186. set opt 2
  1187. }
  1188. puts $fp "$strg\t\t[lindex $shapes $opt]"
  1189. set strg [format {%s_UW} $nme]
  1190. switch -- $opt {
  1191. 0 {
  1192. set wdt [$itm cget -width]
  1193. }
  1194. 1 {
  1195. set wdt [expr {[$itm cget -diameter] * 0.5} ]
  1196. }
  1197. 2 {
  1198. set wdt [$itm cget -topWidth]
  1199. }
  1200. }
  1201. puts $fp "$strg\t\t\t$wdt"
  1202. set strg [format {%s_LW} $nme]
  1203. if { $opt == 2 } {
  1204. set wdt [$itm cget -bottomWidth]
  1205. } else {
  1206. set wdt 0.0
  1207. }
  1208. puts $fp "$strg\t\t\t$wdt"
  1209. set strg [format {%s_H} $nme]
  1210. if { $opt == 1 } {
  1211. set hgt [expr {[$itm cget -diameter] * 0.5} ]
  1212. } else {
  1213. set hgt [$itm cget -height]
  1214. }
  1215. puts $fp "$strg\t\t\t$hgt"
  1216. }
  1217. }
  1218. ##########################################################
  1219. # Set the default length units.
  1220. ##########################################################
  1221. proc ::gui::_setDefaultUnits {} {
  1222. set ::units::default(Length) $::Stackup::defaultLengthUnits
  1223. puts "Default units: $::Stackup::defaultLengthUnits"
  1224. }
  1225. proc ::gui::_getWidthHeight {} {
  1226. set structureList $Stackup::structureList
  1227. set condWidth 0.0
  1228. set condHeight 0.0
  1229. foreach struct $structureList {
  1230. #--------------------------------------------------------------
  1231. # Add the heights of the ground-planes and dielectrics.
  1232. #--------------------------------------------------------------
  1233. if {[$struct isa GroundPlane] || [$struct isa DielectricLayer]} {
  1234. continue
  1235. }
  1236. #--------------------------------------------------------------
  1237. # Get the largest conductor width and the shortest conductor
  1238. # height.
  1239. #--------------------------------------------------------------
  1240. set width [$struct width]
  1241. if { $width > $condWidth } {
  1242. set condWidth $width
  1243. set conductivity [$struct cget -conductivity]
  1244. set condHeight [$struct height]
  1245. }
  1246. }
  1247. return "$condWidth $condHeight $conductivity"
  1248. }