-
Notifications
You must be signed in to change notification settings - Fork 4
/
tnt.tcl
executable file
·328 lines (284 loc) · 10.7 KB
/
tnt.tcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
#! /bin/sh
# restart using wish \
exec wish "$0" "$@"
#----------------------------------------------------------------
#
# tnt.tcl
#
# Main entry point for the TNT interface program
# for Mayo SPPDG MMTL and other transmission line
# simulators.
#
# This module creates the BWidget mainframe framework
# for the main window, and defines procedures for
# accessing numerous other integrated simulation programs
# and utilities.
#
# The actual GUI is constructed by [createElements]
#
#
# Copyright 2002-2004 Mayo Foundation. All Rights Reserved.
# $Id: tnt.tcl,v 1.27 2004/09/10 20:04:53 techenti Exp $
#
#----------------------------------------------------------------
set TNT_VERSION 1.2.2
#----------------------------------------------------------------
# From whence is this script run?
# For there shall we find the rest.
#----------------------------------------------------------------
set ::scriptDir [file dirname [info script]]
#----------------------------------------------------------------
# TNT's application-specific libraries are usually found
# in the ../lib directory, relative to this script's location.
#----------------------------------------------------------------
set ::auto_path [linsert $auto_path 0 [file join $scriptDir .. lib]]
#----------------------------------------------------------------
# TNT executes binaries out of the same bin directory
# as this script. Add this directory to the head of our
# path, so [auto_execok] can easily find executables.
#----------------------------------------------------------------
if { $::tcl_platform(platform) eq "windows" } {
set sep ";"
} else {
set sep ":"
}
set ::env(PATH) $::scriptDir$sep$::env(PATH)
#----------------------------------------------------------------
# TNT's documentation is usually found in ../doc,
# relative to this script's location.
#----------------------------------------------------------------
set ::docDirPath [file join $scriptDir .. doc]
#----------------------------------------------------------------
# But for 'developer mode,' things are a little messy.
# Application libraries are subdirectories under $scriptDir.
# Executables (e.g., bem) are found in their respecitve
# subdirectories, and docs are found under $scriptDir/doc.
#----------------------------------------------------------------
if { [file exists [file join $scriptDir bem]] } {
lappend ::auto_path $scriptDir [file join $scriptDir bem]
set ::env(PATH) [file join $::scriptDir bem]$sep$::env(PATH)
}
if { [file exists [file join $scriptDir calcRL]] } {
lappend ::auto_path $scriptDir [file join $scriptDir calcRL]
set ::env(PATH) [file join $::scriptDir calcRL]$sep$::env(PATH)
}
if { [file exists [file join $scriptDir calcCAP]] } {
lappend ::auto_path $scriptDir [file join $scriptDir calcCAP]
set ::env(PATH) [file join $::scriptDir calcCAP]$sep$::env(PATH)
}
if { [file exists [file join $scriptDir doc]] } {
set ::docDirPath [file join $scriptDir doc]
}
#----------------------------------------------------------------
# Splash Screen
#
# Before anything else, find the GUI components, and throw
# up a nice splash screen while we're doing the rest of the
# initialization.
#
# The splash screen is part of the GUI package, but we don't
# want to do a package require. That's too slow. So we
# create the "gui" namespace, locate the source directory,
# and directly source the splash screen code.
#----------------------------------------------------------------
package require Tk
wm withdraw .
toplevel .splash
namespace eval gui {
set LIBRARY [file join $::scriptDir .. lib]
set flist [glob -nocomplain [file join $LIBRARY gui* splash.tcl]]
if { [llength $flist] == 0 } {
set flist [glob -nocomplain [file join $::scriptDir gui* splash.tcl]]
}
set splash [lindex $flist 0]
set LIBRARY [file normalize [file dirname $splash]]
}
source $::gui::splash
::gui::splash .splash
#----------------------------------------------------------------
# Load Required Packages
#----------------------------------------------------------------
package require Itcl
package require BWidget
#----------------------------------------------------------------
# Load application-specific packages
#----------------------------------------------------------------
package require gui
package require csdl
package require units
package require bem
# Optional packages
set femPkg [catch { package require fem }]
set calcRLpkg [catch { package require calcRL}]
set calcCAPpkg [catch { package require calcCAP}]
#----------------------------------------------------------------
# Create the main window.
#----------------------------------------------------------------
proc createMain { mmtlInitialize } {
#----------------------------------------------------------------
# BWidget Menu description
# Each menubar entry is
# menuname tags menuid tearoff menuentries
# where menuentries are one of
# separator
# command menuname ?tags? ?desc? ?accel? ?option value?...
# checkbutton menuname ?tags? ?desc? ?accel? ?option value?...
# radiobutton menuname ?tags? ?desc? ?accel? ?option value?...
# radiobutton menuname ?tags? ?desc? ?accel? ?option value?...
# cascade menuname tags menuID tearoff menuentries
#----------------------------------------------------------------
set descmenu {
"&File" all file 0 {
{command "Ne&w" {} "Create a new file" {Ctrl n} \
-command ::gui::guiNew}
{command "&Open..." {} "Open existing file" {Ctrl o} \
-command ::gui::guiOpenExisting}
{command "&Save" {} "Save cross section" \
{Ctrl s} -command ::gui::guiSave}
{command "Sa&ve As..." {} \
"Save cross section to new file" {Ctrl v} \
-command ::gui::guiSaveAs}
{command "&Print..." {} "Print the cross section" {Ctrl p} \
-command ::gui::_canvas_print}
{command "E&xit" {} "Exit" {Ctrl x} -command _exit}
}
"View" all view 0 {
{checkbutton "Console" {} "Show/hide command console" {} \
-variable ::gui::_showConsole}
{checkbutton "Annotation" {} \
"Show/hide dimensions and descriptions" {} \
-variable ::gui::_annotateFlag \
-command gui::_canvas_toggleAnnotation}
{command "Redraw" {} "Redraw cross section" \
{} -command gui::_canvas_redraw}
}
"&Setup" all setup 0 {
{command "Re-read conductivity list" {} \
"Read in a new conductivity list" {} \
-command ::gui::guiReadNewConductivityList}
{command "Re-read lossTangent list" {} \
"Read in a new lossTangent list" {} \
-command ::gui::guiReadNewLossTangentList}
{command "Re-read permittivity list" {} \
"Read in a new permittivity list" {} \
-command ::gui::guiReadNewPermittivityList}
}
"&BEM" all bem 0 {
{command "Run BEM MMTL S&imulation" {} \
"Save cross section file and run MMTL" \
{Ctrl i} -command ::gui::saveAndRunBem}
{command "View BEM MMTL Result" {} \
"Vie&w BEM MMTL results" {Ctrl w} \
-command {::gui::guiPopupResultsFile "result"}}
{command "Generate &HSPICE W" {} \
"Generate HSPICE W-element from MMTL results" \
{Ctrl h} -command ::gui::writeHspiceW}
}
"&Sweep" all sweep 0 {
{command "S&weep Simulation" {} \
"Run current node in sweep mode" {} \
-command ::gui::guiRunSweepMMTL }
{command "View \"swept_result\" file" {} \
"Display swept_result file" {} \
-command {::gui::guiPopupResultsFile "swept_result"} }
{command "Write csv file" {} \
"Write swept results into csv file" {} \
-command "::gui::writeSweptCsvFile swept_result" }
}
"&Iterate" all iterate 0 {
{command "I&terate Conductor Width" {} \
"Sweep conductor width or diameter to achieve impendance" {} \
-command ::gui::guiRunIterateMMTL }
{command "View \"iterate_result\" file" {} \
"Display iterate_result file" {} \
-command {::gui::guiPopupResultsFile "iterate_result"}}
{command "Write csv file" {} \
"Write iterate results into csv file" {} \
-command "::gui::writeSweptCsvFile iterate_result" }
}
}
#----------------------------------------------------------------
# Optional experimental wavelet simulators
#----------------------------------------------------------------
if { ($::calcRLpkg==0) || ($::calcCAPpkg==0) } {
append descmenu "\"Wavelet Simulators\" all calcrl 0 \{"
}
if { $::calcRLpkg == 0 } {
append descmenu {
{command "Run RL Calculator" \
{} "Run full-wave wavelet-based RL calculator" {} \
-command ::gui::runCalcRL}
{command "View RL result file" {} \
"Display RL Calculator result file" {} \
-command {::gui::guiPopupResultsFile ri.out} }
}
}
if { $::calcCAPpkg == 0 } {
append descmenu {
{command "Run Capacitance Calculator" \
{} "Run full-wave wavelet-based Capacitance calculator" {} \
-command ::gui::runCalcCap}
{command "View Capacitance result file" {} \
"Display Capacitance Calculator result file" {} \
-command {::gui::guiPopupResultsFile cap.out} }
}
}
if { ($::calcRLpkg==0) || ($::calcCAPpkg==0) } {
append descmenu "\}"
}
append descmenu {
"&Help" all help 0 {
{command "User Guide" {} "" {} \
-command {::gui::tnt_help userguide}}
{command "About TNT" {} "" {} \
-command {wm deiconify .splash}}
}
}
set ::gui::mainframe [MainFrame .mainframe \
-menu $descmenu]
set ::gui::f1 [$::gui::mainframe getframe]
set ::gui::f2 [::gui::guiCreateElements $::gui::f1 $mmtlInitialize]
pack $::gui::f2 -expand true -fill both
pack $::gui::f1 -expand true -fill both
pack $::gui::mainframe -expand true -fill both
wm protocol . WM_DELETE_WINDOW {_exit}
}
#----------------------------------------------------------------
#
# _exit
#
# Application exit point.
# This would be a good place to catch model changes and
# prompt for save before exiting.
#
#----------------------------------------------------------------
proc _exit {} {
exit
}
#----------------------------------------------------------------
#
# main
#
# Controls splash screen, creates main window, and opens
# a file, if specified on the command line.
#
#----------------------------------------------------------------
proc main { argv } {
set mmtlInitialize 1
wm withdraw .
# Create main window
createMain $mmtlInitialize
BWidget::place . 0 0 center
# Swap out splash screen with main window.
wm withdraw .splash
wm title . "TNT Cross Section Generator"
wm deiconify .
update
# If there was a filename supplied on the command line,
# then open that file
if { [llength $argv] > 0 } {
set filename [lindex $argv 0]
::gui::guiOpenExisting $filename
}
}
main $argv