gui_build.tcl 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884
  1. #----------------------------------------------------------------
  2. #
  3. # mmtl_build.tcl
  4. #
  5. # Build the TNT GUI main window
  6. #
  7. #
  8. # Copyright 2002-2004 Mayo Foundation. All Rights Reserved
  9. # $Id: gui_build.tcl,v 1.25 2004/07/20 14:51:55 techenti Exp $
  10. #
  11. #----------------------------------------------------------------
  12. package require Tk
  13. package require BWidget
  14. package provide gui 2.0
  15. ##################################################################
  16. #
  17. # createElements
  18. #
  19. # The TNT gui can be created for a standalone application,
  20. # or as an integrated part of Xmission. For standalone
  21. # mode, the main panels are arranged vertically, and
  22. # the integrated version arranges them horizontally with
  23. # some extra control buttons.
  24. #
  25. ##################################################################
  26. proc ::gui::guiCreateElements { nb {mmtlInterface 1} } {
  27. #------------------------------------------------------
  28. # Create and populate the three main frames
  29. # of the user interface: title, control, and canvas.
  30. #------------------------------------------------------
  31. set f [frame $nb.tnt]
  32. set titleframe [_createTitleframeElements $f]
  33. set controlframe [_createControlframeElements $f]
  34. set canvasframe [_createCanvasframeElements $f]
  35. #------------------------------------------------------
  36. # Check if this is the TNT gui interface.
  37. #------------------------------------------------------
  38. if { $mmtlInterface } {
  39. #------------------------------------------------------
  40. # Manage the three main frames, from top to bottom
  41. #------------------------------------------------------
  42. grid $titleframe -padx 4 -pady 4 -sticky news
  43. grid $controlframe -padx 4 -pady 4 -sticky news
  44. grid $canvasframe -padx 4 -pady 4 -sticky news
  45. grid columnconfigure $f 0 -weight 1
  46. grid rowconfigure $f 2 -weight 1
  47. #------------------------------------------------------
  48. # Create the console, using sppdgTcllib's
  49. # wrapper around TkCon.
  50. #------------------------------------------------------
  51. package require console
  52. console::create -title "TNT Console" \
  53. -variable ::gui::_showConsole
  54. } else {
  55. #------------------------------------------------------
  56. # This isn't TNT, so we manage the frames
  57. # differently and add control buttons for BEM
  58. # MMTL simulation
  59. #------------------------------------------------------
  60. set bb [ButtonBox $f.controlButtons -default -1 -homogeneous 1]
  61. $bb add -text "New" -command mmtlOpenNew -helptext "Create a new file"
  62. $bb add -text "New" -command mmtlOpenNew \
  63. -helptext "Create a new file"
  64. $bb add -text "Open" -command mmtlOpenExisting \
  65. -helptext "Open an existing file"
  66. $bb add -text "Save" -command mmtlSave \
  67. -helptext "Save the file"
  68. $bb add -text "SaveAs" -command mmtlSaveAs \
  69. -helptext "Save the file under a different name"
  70. $bb add -text "Run" -command saveAndRunBem \
  71. -helptext "Save graphic file, run BEM sim, retrieve results."
  72. $bb add -text "View" -command mmtlView \
  73. -helptext "Send MMTL results to log window."
  74. grid $titleframe $canvasframe -padx 4 -pady 4 -sticky news
  75. grid $controlframe ^ -padx 4 -pady 4 -sticky news
  76. grid $bb - -padx 4 -pady 4 -sticky news
  77. grid columnconfigure $f 2 -weight 1
  78. grid rowconfigure $f 1 -weight 1
  79. }
  80. #----------------------------------------------------
  81. # Read in the material - value lists for conductivity,
  82. # loss-tangent and permittivity.
  83. #----------------------------------------------------
  84. ::gui::_readMaterialList "Read Conductivity List" ::gui::_cValList 0 \
  85. [file join $::gui::scriptDir conductivity.list]
  86. ::gui::_readMaterialList "Read lossTangent List" ::gui::_ltValList 0 \
  87. [file join $::gui::scriptDir loss_tangent.list]
  88. ::gui::_readMaterialList "Read Permittivity List" ::gui::_pValList 0 \
  89. [file join $::gui::scriptDir permittivity.list]
  90. # _pValList is actually an array. Lets copy the values
  91. # into a proper list.
  92. set ::gui::_permittivityList [list]
  93. foreach { name value } [ array get ::gui::_pValList ] {
  94. lappend ::gui::_permittivityList "$name $value"
  95. }
  96. # _ltValList is actually an array. Lets copy the values
  97. # into a proper list.
  98. set ::gui::_losstangentList [list]
  99. foreach { name value } [ array get ::gui::_ltValList ] {
  100. lappend ::gui::_losstangentList "$name $value"
  101. }
  102. # _cValList is actually an array. Lets copy the values
  103. # into a proper list.
  104. set ::gui::_conductivityList [list]
  105. foreach { name value } [ array get ::gui::_cValList ] {
  106. lappend ::gui::_conductivityList "$name $value"
  107. }
  108. return $f
  109. }
  110. proc ::gui::_protectFromWindowsDoubleClickBug {} {
  111. puts protecting
  112. set newEvent [event info <<KeyOrButton>>]
  113. if { ($::tcl_platform(platform) eq "windows") && ($newEvent eq "")} {
  114. event add <<KeyOrButton>> <Button> <Key>
  115. bind Nascent <<KeyOrButton>> {break}
  116. bind all <Expose> {+ ::gui::_ignoreKeyOrButtonEvents %W}
  117. }
  118. }
  119. proc ::gui::_ignoreKeyOrButtonEvents { w } {
  120. bindtags $w [linsert [bindtags $w] 0 Nascent]
  121. after 300 [list ::gui::_restoreKeyOrButtonEvents $w]
  122. }
  123. proc ::gui::_restoreKeyOrButtonEvents { w } {
  124. if {[winfo exists $w]} {
  125. bindtags $w [lreplace [bindtags $w] 0 0]
  126. }
  127. }
  128. #-----------------------------------------------------------------
  129. # _createCanvas
  130. #
  131. # Creates the cross section drawing canvas and supporting
  132. # widgets, which include zoom buttons and scrollbars.
  133. #
  134. #-----------------------------------------------------------------
  135. proc ::gui::_createCanvasframeElements {parent} {
  136. set f [frame $parent.canvasframe]
  137. #----------------------------------------------------
  138. # Create the canvas, and save the widget name
  139. # in a global - as it is used by drawing objects.
  140. #----------------------------------------------------
  141. set ::gui::_canvas [canvas $f.canvas -width 500 \
  142. -relief groove -borderwidth 3 \
  143. -xscrollcommand [list $f.hscroll set] \
  144. -yscrollcommand [list $f.vscroll set] ]
  145. #----------------------------------------------------
  146. # Scrollbars are nice
  147. #----------------------------------------------------
  148. scrollbar $f.hscroll -command [list $f.canvas xview] \
  149. -orient horizontal
  150. scrollbar $f.vscroll -command [list $f.canvas yview]
  151. #----------------------------------------------------
  152. # Create zoom buttons
  153. #----------------------------------------------------
  154. button $f.zoom_in \
  155. -command [list ::gui::_canvas_zoom $f.canvas 1.25] \
  156. -image [image create photo viewmag+-22 -data {
  157. R0lGODlhFgAWAIYAAPwCBHSe1GyWzFyOxFSGvER6rDxyrHym3MTm/Nzy/Oz6
  158. /OTy/Ex+rBxelMzq/Oz2/Pz+/PT+/PT6/OT2/NTu/ARKhLzi/Mzm/Lze/NTq
  159. /Nzq/Mzi/GyezMTi/LTa/Nzu/LTW/Lza/LzW/LTS/KzO/KzS/KTK/KzK/KTG
  160. /KzG/Dx6rLTe/JzC/KS+/Jy6/JS69CRmnJSy/JSu/Iyq/AROhKTC/JS2/Iyi
  161. /Hye9LSuBISe/HyS9HSK9Pz+BKRiDPyWHMSOLKxmDKRaBMySXFwyBMSOVISq
  162. 3Fw2BER6tHyq3MySLAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  163. AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  164. AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  165. AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAA
  166. LAAAAAAWABYAAAf/gACCggECAwQFBoOLjIIHAggICQoLCQwNjYwHCA4PEBAR
  167. EhITFBWZjhYLn54PrQsXGKaZAhkSnxAKrQkaG7GZHBS2oq67HR4YHrKLAh/C
  168. rQ8LGhcgISAiyoMECQ8Sz9IiIyMkJSTYggQbHR8Z3+IkJicoKeYAKhgrGCEi
  169. JSUnKSwtXLh4QQ8AjGogSohIgUJgDBkzaJxqEI5EvBo2Ysy4gQNHhRynKpw4
  170. UaOFDRk4dOzgUQFCDx8hK7h4iGNlhQo/ekAAEuQUgJsVaAQFIOTHECA7e/ps
  171. RERIEaRAYA4yosjnER9Hkw46gGQpgKZPd/owkiSEAbJLifh4qsSHCgMqFIQW
  172. XKS2iFpBRuYyJaIUwAG9SwMBACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJv
  173. IHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0
  174. cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
  175. }]
  176. button $f.zoom_out \
  177. -command [list ::gui::_canvas_zoom $f.canvas 0.80] \
  178. -image [image create photo viewmag--22 -data {
  179. R0lGODlhFgAWAIYAAPwCBHSe1GyWzFyOxFSGvER6rDxyrHym3MTm/Nzy/Oz6
  180. /OTy/Ex+rBxelMzq/Oz2/Pz+/PT+/PT6/OT2/NTu/ARKhLzi/Mzm/Lze/NTq
  181. /Nzq/Mzi/GyezMTi/LTa/Nzu/LTW/Lza/LzW/LTS/KzO/KzS/KTK/KzK/KTG
  182. /KzG/Dx6rLTe/JzC/KS+/Jy6/JS69CRmnJSy/JSu/Iyq/AROhKTC/JS2/Iyi
  183. /Hye9LSuBISe/HyS9HSK9Pz+BKRiDPyWHMSOLKxmDKRaBMySXFwyBMSOVFw2
  184. BISq3Hyq3ISq5MySLAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  185. AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  186. AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  187. AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAA
  188. LAAAAAAWABYAAAf/gACCggECAwQFBoOLjIIHAggICQoLCQwNjYwHCA4PEBAR
  189. EhITFBWZjhYLn54PrQsXGKaZAhkSnxAKrQkaG7GZHBS2oq67HR4YHrKLAh/C
  190. rQ8LGhcgISAiyoMECQ8Sz9IiIyMkJSTYggQbHR8Z3+IkJicoKeYAKhgrGCEi
  191. JSUnKSwtXLh4QQ8AjGogSohIgUJgDBkzaJxqEI5EvBo2Ysy4gQNHhRynKpw4
  192. UaOFDRk4dOzgUQFCDx8hK7h4iGNlhQo/ekAAEuQUgJsVaAQFIOTHECA7e/ps
  193. RERIEaRAYC5lZMTH0aRTGTV9utPHESRJjnxdSsTHUyU+VBhQAXRq2SJlCrMy
  194. JaJU7ikMgQAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAy
  195. LjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVk
  196. Lg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
  197. }]
  198. button $f.zoom_fit \
  199. -command [list ::gui::_canvas_zoom_fit $f.canvas] \
  200. -image [image create photo window_fullscreen-22 -data {
  201. R0lGODlhFgAWAIUAAISq5ISq3Hyq3AR2xAT+BLTW/KTO/JTG/Hy6/Gyy/Eyi
  202. /DSa/CSO/AyG/AR+/ARyvKzS/IS+/GSy/ASC/Hym3Nzm/NTi/NTm/Mzi/Mze
  203. /MTe/MTa9Pz+/PQeLOweJPQeJPT6/Oz6/Oz2/OTy/OT2/Lza/Nzy/NTy/Mzu
  204. /NTu/Mzq/LTa/KzW9LTW9AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  205. AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAQALAAAAAAWABYAAAb/
  206. QEAgIBASjcVhckBoBgqGAyKhWDAajqw2+2gSAAXIISKpMiaTrbbbpFQsF7jF
  207. gsFkMJqMRrPRsL8cHR4eHxwgICEhIiEfgx4bTE4chB6IICIgIyAkJJQlfwEc
  208. jYOHISSmnY6QXgEglY6bIpyDHxWPfwCHh5UkmSImIh4VJCarbbqYnCS/JiYj
  209. JicoBbjIycTEzSnaBZEEFJeXIiPYIyMVJ9oqK9SYIh8k480nJx8mKtLd3x6p
  210. Hs0mKSYcofAwzQuAYI7g+auQgtCHDyz+UEhVy1kFEyhQVLjgqGATAPw+jACo
  211. LePDQSzybVjJssSKEgVWFGjBgiaEPwMe5NypsyfPEAc6vQgdSrSo0aNIkxI1
  212. EAQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkg
  213. RGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0
  214. cDovL3d3dy5kZXZlbGNvci5jb20AOw==
  215. }]
  216. button $f.zoom_reg \
  217. -command [list ::gui::_canvas_zooming_mode $f.canvas] \
  218. -image [image create photo viewmag-22 -data {
  219. R0lGODlhFgAWAIYAAPwCBHSe1GyWzFyOxFSGvER6rDxyrHym3MTm/Nzy/Oz6
  220. /OTy/Ex+rBxelMzq/Oz2/Pz+/PT+/PT6/OT2/NTu/ARKhLzi/Mzm/Lze/NTq
  221. /Nzq/Mzi/GyezMTi/LTa/Nzu/LTW/Lza/LzW/LTS/KzO/KzS/KTK/KzK/KTG
  222. /KzG/Dx6rLTe/JzC/KS+/Jy6/JS69CRmnJSy/JSu/Iyq/AROhKTC/JS2/Iyi
  223. /Hye9LSuBISe/HyS9HSK9Pz+BKRiDPyWHMSOLKxmDKRaBMySXFwyBMSOVFw2
  224. BMySLAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  225. AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  226. AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  227. AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAA
  228. LAAAAAAWABYAAAf/gACCggECAwQFBoOLjIIHAggICQoLCQwNjYwHCA4PEBAR
  229. EhITFBWZjhYLn54PrQsXGKaZAhkSnxAKrQkaG7GZHBS2oq67HR4YHrKLAh/C
  230. rQ8LGhcgISAiyoMECQ8Sz9IiIyMkJSTYggQbHR8Z3+IkJicoKeYAKhgrGCEi
  231. JSUnKSwtXLh4QQ8AjGogSohIgUJgDBkzaJxqEI5EvBo2Ysy4gQNHhRynKpw4
  232. UaOFDRk4dOzgUQFCDx8hK7h4iGNlhQo/ekAAEuQUgJsVaAQFIOTHECA7e/ps
  233. RERIEaRAYC5lZMTH0aRTGTV9ulNqVkFEfDw94vUrgLBFwppdRISI0rWNA+wE
  234. AgAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBE
  235. ZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRw
  236. Oi8vd3d3LmRldmVsY29yLmNvbQA7
  237. }]
  238. #----------------------------------------------------
  239. # Grid buttons at the top, then the canvas and
  240. # scrollbars. Make the canvas and scrollbars
  241. # resizable.
  242. #----------------------------------------------------
  243. grid $f.zoom_in $f.zoom_out $f.zoom_fit $f.zoom_reg
  244. grid $f.canvas -columnspan 5 -sticky news
  245. grid $f.hscroll -columnspan 5 -sticky ew
  246. grid $f.vscroll -row 1 -column 5 -sticky ns
  247. grid rowconfigure $f 1 -weight 1
  248. grid columnconfigure $f 4 -weight 1
  249. #----------------------------------------------------
  250. # Bindings
  251. # If the canvas resizes, do a redraw.
  252. # Select on click
  253. # Modify on double-click
  254. #----------------------------------------------------
  255. bind $::gui::_canvas <Configure> { ::gui::_canvas_redraw }
  256. bind $::gui::_canvas <ButtonRelease-1> {::gui::_canvas_select %W %x %y}
  257. bind $::gui::_canvas <Double-ButtonRelease-1> {
  258. ::gui::updateStructure [$::gui::_tree selection get]
  259. }
  260. #----------------------------------------------------
  261. # Create drawing visitor, which traverses the
  262. # layer stackup, creating canvas elements.
  263. #----------------------------------------------------
  264. canvasDraw ::gui::_canvasDraw_visitor
  265. #----------------------------------------------------
  266. # Set the initial scale factor
  267. #----------------------------------------------------
  268. set ::gui::canvasScaleFactor 1.0
  269. return $f
  270. }
  271. ##################################################################
  272. # Build the main user window.
  273. ##################################################################
  274. proc ::gui::_createTitleframeElements { parent } {
  275. set f [frame $parent.titleframe]
  276. #--------------------------------------------------------------
  277. # Create a project title (description) which spans the
  278. # window.
  279. #--------------------------------------------------------------
  280. set ltitle [label $f.ltitle -text "Title"]
  281. set etitle [entry $f.etitle -textvariable ::gui::_title]
  282. set lunits [label $f.lunits -text "Default Units"]
  283. set cbunits [ComboBox $f.cbunits -width 10 \
  284. -values {mils microns inches meters} \
  285. -textvariable ::Stackup::defaultLengthUnits \
  286. -modifycmd ::gui::_setDefaultUnits ]
  287. grid $ltitle $etitle $lunits $cbunits -sticky ew -padx 4 -pady 4
  288. grid columnconfigure $f 1 -weight 1
  289. #--------------------------------------------------------------
  290. # Default parameters for this model
  291. #--------------------------------------------------------------
  292. set ::Stackup::defaultLengthUnits "meters"
  293. # set ::Stackup::frequency 1e9
  294. # guiBuildLabelEntry $parent ::Stackup::couplingLength "Coupling Length:"
  295. # guiBuildLabelEntry $parent ::Stackup::riseTime "Risetime (ps):"
  296. # guiBuildLabelEntry $parent ::Stackup::frequency "Frequency :"
  297. # guiBuildLabelEntry $parent ::gui::_num_c_segs "ConductorSegments:"
  298. # guiBuildLabelEntry $parent ::gui::_num_p_segs "DielectricSegments:"
  299. return $f
  300. }
  301. #------------------------------------------------------
  302. # On global variables and GUI Dialogs
  303. #
  304. # We want to create and modify CSDL objects from
  305. # the GUI, and be able to set the object's
  306. # attributes (public variables) from the GUI dialogs.
  307. #
  308. # We define a namespace array (::gui::dialog())
  309. # which contains entries for all various
  310. # dialog attributes. This array holds the
  311. # -textvariables for the data entry dialog entries,
  312. # comboboxes, spinboxes.
  313. #
  314. # For creating and modifying CSDL structures,
  315. # we index the array by CSDL structure type
  316. # (e.g., RectangleConductors) and attribute name
  317. # (e.g., width). So the textvariable for the
  318. # entry would be of the forms
  319. # $::gui::dialog(RectangleConductors,width)
  320. # $::gui::dialog($type,$attribute)
  321. #
  322. # Each dialog also has special attributes for 'name',
  323. # which is the name of the corresponding CSDL object
  324. # (without the :: specifiers), and 'dialog', which is
  325. # the name of the dialog widget for this type.
  326. #
  327. #------------------------------------------------------
  328. #------------------------------------------------------
  329. #
  330. # Create Structure Dialogs
  331. #
  332. # Data entry dialogs for the various cross section
  333. # structures are very similar. We construct them as
  334. # a grid of labels and entries on a dialog. Since
  335. # they are so similar, we can create them with a
  336. # common procedure, using switches to determine
  337. # which widgets to create and how to grid them.
  338. #
  339. #------------------------------------------------------
  340. proc ::gui::_createStructureDialog { type } {
  341. #------------------------------------------------------
  342. # Rectangle Dielectrics Form
  343. #------------------------------------------------------
  344. # Create dialog, with title based on $type
  345. set ::gui::dialog($type,dialog) .dialog$type
  346. regsub -all {[A-Z]} $type { \0} dialogTitle
  347. set dlg [Dialog $::gui::dialog($type,dialog) -title $dialogTitle \
  348. -side bottom -anchor e -default 0 -cancel 3]
  349. $dlg add -text "Add"
  350. $dlg add -text "Modify"
  351. $dlg add -text "Delete"
  352. $dlg add -text "Cancel"
  353. #------------------------------------------------------
  354. # Different widgets for each type of form.
  355. # Simple attributes are just a label and an entry.
  356. # Complex attributes have special widgets, such as
  357. # comboboxes or spinboxes.
  358. #------------------------------------------------------
  359. switch -exact $type {
  360. GroundPlane {
  361. set simpleAttributes [list name thickness]
  362. }
  363. DielectricLayer {
  364. set simpleAttributes [list name permeability thickness]
  365. set complexAttributes(permittivity) 1
  366. set complexAttributes(lossTangent) 1
  367. }
  368. RectangleDielectric {
  369. set simpleAttributes \
  370. [list name permeability width height "x Offset" "y Offset"]
  371. set complexAttributes(permittivity) 1
  372. set complexAttributes(lossTangent) 1
  373. }
  374. RectangleConductors {
  375. set simpleAttributes \
  376. [list name width height pitch "x Offset" "y Offset"]
  377. set complexAttributes(conductivity) 1
  378. set complexAttributes(number) 1
  379. }
  380. TrapezoidConductors {
  381. set simpleAttributes [list name topWidth bottomWidth height \
  382. pitch "x Offset" "y Offset"]
  383. set complexAttributes(conductivity) 1
  384. set complexAttributes(number) 1
  385. }
  386. CircleConductors {
  387. set simpleAttributes \
  388. [list name diameter pitch "x Offset" "y Offset"]
  389. set complexAttributes(conductivity) 1
  390. set complexAttributes(number) 1
  391. }
  392. }
  393. #------------------------------------------------------
  394. # Create widgets
  395. #------------------------------------------------------
  396. set w [$dlg getframe]
  397. foreach item $simpleAttributes {
  398. set varname [string map {" " ""} $item]
  399. set l$varname [label $w.l$varname -text [string totitle $item]]
  400. set e$varname [entry $w.e$varname -width 10 \
  401. -textvariable ::gui::dialog($type,$varname)]
  402. }
  403. if { [info exists complexAttributes(permittivity)] } {
  404. set lpermitt [label $w.lpermitt -text "Permittivity"]
  405. set cbpermitt [ComboBox $w.cbpermitt -width 10 \
  406. -values $::gui::_permittivityList \
  407. -textvariable ::gui::dialog($type,permittivity)]
  408. }
  409. if { [info exists complexAttributes(lossTangent)] } {
  410. set llosstan [label $w.llosstan -text "Loss Tangent"]
  411. set cblosstan [ComboBox $w.cblosstan -width 10 \
  412. -values $::gui::_losstangentList \
  413. -textvariable ::gui::dialog($type,lossTangent)]
  414. }
  415. if { [info exists complexAttributes(conductivity)] } {
  416. set lconduct [label $w.lconduct -text "Conductivity"]
  417. set cbconduct [ComboBox $w.cbconduct -width 10 \
  418. -values $::gui::_conductivityList \
  419. -textvariable ::gui::dialog($type,conductivity)]
  420. }
  421. if { [info exists complexAttributes(number)] } {
  422. set lnumber [label $w.lnumber -text "Number"]
  423. set snumber [spinbox $w.snumber -width 5 -from 1 -to 100\
  424. -textvariable ::gui::dialog($type,number)]
  425. }
  426. #------------------------------------------------------
  427. # Manage widgets in a grid and set the stacking
  428. # order for tab-traversal.
  429. # (Different arrangement for each dialog)
  430. #------------------------------------------------------
  431. switch -exact $type {
  432. GroundPlane {
  433. grid $lname $ename -sticky ew -padx 4 -pady 4
  434. grid $lthickness $ethickness -sticky ew -padx 4 -pady 4
  435. grid $lname $lthickness -sticky e
  436. foreach e [list $ename $ethickness] {
  437. raise $e
  438. }
  439. }
  440. DielectricLayer {
  441. grid $lname $ename - - -sticky ew -padx 4 -pady 4
  442. grid $lpermitt $cbpermitt $lpermeability $epermeability \
  443. -sticky ew -padx 4 -pady 4
  444. grid $llosstan $cblosstan -sticky ew -padx 4 -pady 4
  445. grid $lthickness $ethickness -sticky ew -padx 4 -pady 4
  446. grid $lname $lpermitt $lpermeability \
  447. $llosstan $lthickness -sticky e
  448. foreach e [list $ename $cbpermitt $epermeability \
  449. $cblosstan $ethickness ] {
  450. raise $e
  451. }
  452. }
  453. RectangleDielectric {
  454. grid $lname $ename - - -sticky ew -padx 4 -pady 4
  455. grid $lpermitt $cbpermitt $lpermeability $epermeability \
  456. -sticky ew -padx 4 -pady 4
  457. grid $llosstan $cblosstan -sticky ew -padx 4 -pady 4
  458. grid $lwidth $ewidth -sticky ew -padx 4 -pady 4
  459. grid $lheight $eheight -sticky ew -padx 4 -pady 4
  460. grid $lxOffset $exOffset $lyOffset $eyOffset \
  461. -sticky ew -padx 4 -pady 4
  462. grid $lname $lpermitt $lpermeability $llosstan \
  463. $lwidth $lheight $lxOffset $lyOffset \
  464. -sticky e
  465. foreach e [list $ename $cbpermitt $epermeability \
  466. $cblosstan $ewidth $eheight $exOffset $eyOffset] {
  467. raise $e
  468. }
  469. }
  470. RectangleConductors {
  471. grid $lname $ename - - -sticky ew -padx 4 -pady 4
  472. grid $lconduct $cbconduct - - -sticky ew -padx 4 -pady 4
  473. grid $lwidth $ewidth $lnumber $snumber \
  474. -sticky ew -padx 4 -pady 4
  475. grid $lheight $eheight $lpitch $epitch \
  476. -sticky ew -padx 4 -pady 4
  477. grid $lxOffset $exOffset $lyOffset $eyOffset \
  478. -sticky ew -padx 4 -pady 4
  479. grid $lname $lconduct $lwidth $lheight $lnumber $lpitch \
  480. $lxOffset $lyOffset -sticky e
  481. foreach e [list $ename $cbconduct $ewidth $snumber \
  482. $eheight $epitch $exOffset $eyOffset] {
  483. raise $e
  484. }
  485. }
  486. TrapezoidConductors {
  487. grid $lname $ename - - -sticky ew -padx 4 -pady 4
  488. grid $lconduct $cbconduct - - -sticky ew -padx 4 -pady 4
  489. grid $ltopWidth $etopWidth -sticky ew -padx 4 -pady 4
  490. grid $lbottomWidth $ebottomWidth $lnumber $snumber \
  491. -sticky ew -padx 4 -pady 4
  492. grid $lheight $eheight $lpitch $epitch \
  493. -sticky ew -padx 4 -pady 4
  494. grid $lxOffset $exOffset $lyOffset $eyOffset \
  495. -sticky ew -padx 4 -pady 4
  496. grid $lname $lconduct $ltopWidth $lbottomWidth $lheight \
  497. $lnumber $lpitch $lxOffset $lyOffset -sticky e
  498. foreach e [list $ename $cbconduct $etopWidth $ebottomWidth \
  499. $snumber $eheight $epitch $exOffset $eyOffset] {
  500. raise $e
  501. }
  502. }
  503. CircleConductors {
  504. grid $lname $ename - - -sticky ew -padx 4 -pady 4
  505. grid $lconduct $cbconduct - - -sticky ew -padx 4 -pady 4
  506. grid $ldiameter $ediameter $lnumber $snumber \
  507. -sticky ew -padx 4 -pady 4
  508. grid x x $lpitch $epitch \
  509. -sticky ew -padx 4 -pady 4
  510. grid $lxOffset $exOffset $lyOffset $eyOffset \
  511. -sticky ew -padx 4 -pady 4
  512. grid $lname $lconduct $ldiameter $lnumber $lpitch \
  513. $lxOffset $lyOffset -sticky e
  514. foreach e [list $ename $cbconduct $ediameter $snumber \
  515. $epitch $exOffset $eyOffset] {
  516. raise $e
  517. }
  518. }
  519. }
  520. # Enable resizing (of columns 1 and 3)
  521. grid columnconfigure $w {1 3} -weight 1
  522. pack $w -expand yes -fill both
  523. return $dlg
  524. }
  525. #------------------------------------------------------
  526. #
  527. # ::gui::_createBemRunDialog
  528. #
  529. # Simulation controls and "run" button
  530. #
  531. #------------------------------------------------------
  532. proc ::gui::_createBemRunDialog { } {
  533. set dlg [Dialog .bemRun \
  534. -title "Run Boundary Element Method (BEM) MMTL" \
  535. -homogeneous 1 -side bottom -anchor e -default 0 -cancel 1]
  536. $dlg add -text Run
  537. $dlg add -text Cancel
  538. set dlgf [$dlg getframe]
  539. # Control the simulation with these values
  540. set cframe [TitleFrame $dlgf.controls -text "Simulation Controls"]
  541. set f [$cframe getframe]
  542. set lclen [label $f.lclen -text "Coupling Length"]
  543. set eclen [entry $f.eclen -width 10 \
  544. -textvariable ::Stackup::couplingLength]
  545. set lrise [label $f.lrise -text "Risetime (ps)"]
  546. set erise [entry $f.erise -width 10 -textvariable ::Stackup::riseTime]
  547. set lcseg [label $f.lcseg -text "Conductor Segments"]
  548. set ecseg [entry $f.ecseg -width 10 -textvariable ::gui::_num_c_segs]
  549. set ldseg [label $f.ldseg -text "Dielectric Segments"]
  550. set edseg [entry $f.edseg -width 10 -textvariable ::gui::_num_p_segs]
  551. grid $lclen $eclen $lcseg $ecseg -sticky news -padx 4 -pady 4
  552. grid $lrise $erise $ldseg $edseg -sticky news -padx 4 -pady 4
  553. pack $cframe -side top -padx 4 -pady 4
  554. # save for later
  555. set ::gui::dialog(bemRun,dialog) $dlg
  556. }
  557. #------------------------------------------------------
  558. #
  559. # ::gui::_createBemLogDialog
  560. #
  561. # Simple log window and close button
  562. #
  563. #------------------------------------------------------
  564. proc ::gui::_createBemLogDialog {} {
  565. set dlg [Dialog .bemLog \
  566. -title "Boundary Element Method (BEM) MMTL Run Log" \
  567. -homogeneous 1 -side bottom -anchor e -default 0 -cancel 1]
  568. $dlg add -text "Show Results"
  569. $dlg add -text "Close"
  570. set sw [ScrolledWindow [$dlg getframe].sw]
  571. set txt [text $sw.text]
  572. $sw setwidget $txt
  573. pack $sw -padx 4 -pady 4 -expand true -fill both
  574. # save for later
  575. set ::gui::dialog(bemLog,dialog) $dlg
  576. set ::gui::dialog(bemLog,text) $txt
  577. }
  578. #------------------------------------------------------
  579. #
  580. # ::gui::_createCalcRLRunDialog
  581. #
  582. # Simulation controls and "run" button
  583. #
  584. #------------------------------------------------------
  585. proc ::gui::_createCalcRLRunDialog { } {
  586. set dlg [Dialog .calcRLRun \
  587. -title "Run Wavelet-based RL Calculator" \
  588. -homogeneous 1 -side bottom -anchor e -default 0 -cancel 1]
  589. $dlg add -text Run
  590. $dlg add -text Cancel
  591. set dlgf [$dlg getframe]
  592. # Control the simulation with these values
  593. set cframe [TitleFrame $dlgf.controls -text "Simulation Controls"]
  594. set f [$cframe getframe]
  595. set lfreq [label $f.lfreq -text "Frequencies"]
  596. set efreq [entry $f.efreq -width 30 \
  597. -textvariable ::gui::calcRLfrequencies]
  598. grid $lfreq $efreq -sticky news -padx 4 -pady 4
  599. pack $cframe -side top -padx 4 -pady 4
  600. # save for later
  601. set ::gui::dialog(calcRLRun,dialog) $dlg
  602. }
  603. #------------------------------------------------------
  604. #
  605. # ::gui::_createCalcRLLogDialog
  606. #
  607. # Simple log window and close button
  608. #
  609. #------------------------------------------------------
  610. proc ::gui::_createCalcRLLogDialog {} {
  611. set dlg [Dialog .calcRLLog \
  612. -title "Wavelet-based RL Calculator Run Log" \
  613. -homogeneous 1 -side bottom -anchor e -default 0 -cancel 1]
  614. $dlg add -text "Show Results"
  615. $dlg add -text "Close"
  616. set sw [ScrolledWindow [$dlg getframe].sw]
  617. set txt [text $sw.text]
  618. $sw setwidget $txt
  619. pack $sw -padx 4 -pady 4 -expand true -fill both
  620. # save for later
  621. set ::gui::dialog(calcRLLog,dialog) $dlg
  622. set ::gui::dialog(calcRLLog,text) $txt
  623. }
  624. #------------------------------------------------------
  625. #
  626. # ::gui::_createCalcCapLogDialog
  627. #
  628. # Simple log window and close button
  629. #
  630. #------------------------------------------------------
  631. proc ::gui::_createCalcCapLogDialog {} {
  632. set dlg [Dialog .calcCapLog \
  633. -title "Wavelet-based Capacitance Calculator Run Log" \
  634. -homogeneous 1 -side bottom -anchor e -default 0 -cancel 1]
  635. $dlg add -text "Show Results"
  636. $dlg add -text "Close"
  637. set sw [ScrolledWindow [$dlg getframe].sw]
  638. set txt [text $sw.text]
  639. $sw setwidget $txt
  640. pack $sw -padx 4 -pady 4 -expand true -fill both
  641. # save for later
  642. set ::gui::dialog(calcCapLog,dialog) $dlg
  643. set ::gui::dialog(calcCapLog,text) $txt
  644. }
  645. ##################################################################
  646. # Popup the various data entry forms
  647. ##################################################################
  648. proc ::gui::_activateClearForm {pane varName} {
  649. $::gui::_pageManager raise $pane
  650. set $varName ""
  651. }
  652. ##################################################################
  653. # Display file name on main window title bar
  654. ##################################################################
  655. proc ::gui::_setNodeName {} {
  656. wm title . "TNT: $::gui::_nodename"
  657. }
  658. #----------------------------------------------------------------
  659. #
  660. # _controlframeElements
  661. #
  662. # Build the control frame elements, including the "new"
  663. # structure buttons and the tree view of the stackup.
  664. #----------------------------------------------------------------
  665. proc ::gui::_createControlframeElements { parent } {
  666. set f [frame $parent.controlframe]
  667. #--------------------------------------------------------------
  668. # Create "New Structure" buttons
  669. #
  670. # Each button opens a different dialog and creates a new
  671. # structure object for the layer stackup.
  672. #--------------------------------------------------------------
  673. set newbuttons [TitleFrame $f.newbuttons -text "Create New Structure"]
  674. set bb [ButtonBox [$newbuttons getframe].buttons -orient vertical]
  675. $bb add -text "New Ground Plane" \
  676. -command [list ::gui::newStructure GroundPlane]
  677. $bb add -text "New Dielectric Layer" \
  678. -command [list ::gui::newStructure DielectricLayer]
  679. $bb add -text "New Dielectric Block" \
  680. -command [list ::gui::newStructure RectangleDielectric]
  681. $bb add -text "New Rectangle Conductors" \
  682. -command [list ::gui::newStructure RectangleConductors]
  683. $bb add -text "New Trapezoid Conductors" \
  684. -command [list ::gui::newStructure TrapezoidConductors]
  685. $bb add -text "New Circular Conductors" \
  686. -command [list ::gui::newStructure CircleConductors]
  687. #--------------------------------------------------------------
  688. # We'll create the corresponding dialogs later, on demand,
  689. # because if we try to create them while the main window is
  690. # withdrawn, some window managers (from Microsoft) won't
  691. # correctly handle transient dialogs. But we must set
  692. # the dialog name variable here, so that 'winfo exists' works.
  693. #--------------------------------------------------------------
  694. set ::gui::dialog(GroundPlane,dialog) ""
  695. set ::gui::dialog(DielectricLayer,dialog) ""
  696. set ::gui::dialog(RectangleDielectric,dialog) ""
  697. set ::gui::dialog(RectangleConductors,dialog) ""
  698. set ::gui::dialog(TrapezoidConductors,dialog) ""
  699. set ::gui::dialog(CircleConductors,dialog) ""
  700. set ::gui::dialog(canvasPrint,dialog) ""
  701. set ::gui::dialog(bemRun,dialog) ""
  702. set ::gui::dialog(bemLog,dialog) ""
  703. set ::gui::dialog(calcRLRun,dialog) ""
  704. set ::gui::dialog(calcRLLog,dialog) ""
  705. set ::gui::dialog(calcCapLog,dialog) ""
  706. set ::gui::dialog(result,dialog) ""
  707. #------------------------------------------------------
  708. # Create tree view of stackup
  709. #------------------------------------------------------
  710. set treeFrame [TitleFrame $f.treeframe -text "Layer Stackup"]
  711. set sw [ScrolledWindow [$treeFrame getframe].sw \
  712. -relief sunken -borderwidth 3]
  713. set ::gui::_tree [Tree $sw.tree -relief flat \
  714. -borderwidth 0 -width 15 \
  715. -highlightthickness 0 -redraw 1 \
  716. -dropenabled 1 -dragenabled 1 \
  717. -selectbackground red \
  718. -showlines false \
  719. -dragevent 1 -droptypes {
  720. TREE_NODE {copy {} move {} link {}}
  721. LISTBOX_ITEM {copy {} move {} link {}}
  722. } \
  723. -dropcmd "::gui::_drpendComp" \
  724. -dropovermode p ]
  725. $sw setwidget $::gui::_tree
  726. # We have to pack widgets into the TitleFrame frame
  727. pack $bb -expand true -fill both
  728. pack $sw -expand true -fill both
  729. # But we grid the TitleFrames for nice resizing
  730. grid $newbuttons $treeFrame -sticky news -padx 4 -pady 4
  731. grid columnconfigure $f 1 -weight 1
  732. #-------------------------------------------
  733. # Bind MB1 click on a tree node to be a select of
  734. # that item. Double-click opens a modify dialog.
  735. #-------------------------------------------
  736. $::gui::_tree bindText <ButtonPress-1> ::gui::highlightItem
  737. $::gui::_tree bindText <Double-ButtonPress-1> ::gui::updateStructure
  738. return $f
  739. }
  740. ##################################################################
  741. # Popup the form for the selected component.
  742. ##################################################################
  743. proc ::gui::_popupForm { objnme } {
  744. set class [$objnme info class]
  745. # Raise the proper page, based on class name
  746. set pageName [string trim $class ":"]
  747. $::gui::_pageManager raise $pageName
  748. }