calcRL_exe.tcl 118 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206
  1. #! /bin/sh
  2. #----------------------------------------------*-TCL-*------------
  3. #
  4. # calcRL_exe.tcl
  5. #
  6. # Main program script for calcRL.
  7. #
  8. # Copyright 2002-2004 Mayo Foundation. All Rights Reserved.
  9. # $Id: calcRL_exe.tcl,v 1.4 2004/02/12 22:20:18 techenti Exp $
  10. #
  11. #-----------------------------------------------------------------
  12. # restart using wish \
  13. exec wish "$0" "$@"
  14. global curPosition
  15. global openFile
  16. global fileHead;# the number of each kind of conductor and dielectric
  17. global dieleData recData cirData triData ellData polyData gndData
  18. # global variables for saving all parameters of each kind
  19. global palFlag
  20. global corFlag
  21. global newFlag
  22. global yesMove
  23. global recCounter cirCounter dieleCounter ellCounter triCounter polyCounter \
  24. gndCounter
  25. global recTags cirTags dieleTags ellTags triTags polyTags gndTags
  26. global recId cirId dieleId ellId triId polyId gndId
  27. global maxXcoord maxYcoord
  28. global paletteXsize paletteYsize Xscale Yscale
  29. global pbottomleftX pbottomleftY
  30. global Nh Nit J
  31. global Nwx Nwy Nws
  32. global Np Eps matr
  33. global freq sigma
  34. global pData
  35. global pcal
  36. set fileHead { 0 0 0 0 0 0 0 }; # dieleNum recNum cirNum triNum ellNum polyNum gndNum
  37. set palFlag -1
  38. set corFlag -1; # initially set to new mode
  39. set newFlag -1
  40. set yesMove -1
  41. set curPosition -1
  42. set recCounter 0
  43. set cirCounter 0
  44. set dieleCounter 0
  45. set ellCounter 0
  46. set triCounter 0
  47. set polyCounter 0
  48. set gndCounter 0
  49. set recId ""
  50. set cirId ""
  51. set dieleId ""
  52. set ellId ""
  53. set triId ""
  54. set polyId ""
  55. set gndId ""
  56. set recData ""
  57. set cirData ""
  58. set dieleData ""
  59. set ellData ""
  60. set triData ""
  61. set polyData ""
  62. set gndData ""
  63. set recTags ""
  64. set cirTags ""
  65. set dieleTags ""
  66. set ellTags ""
  67. set triTags ""
  68. set polyTags ""
  69. set gndTags ""
  70. set pData ""
  71. set pcal ""
  72. set maxXcoord 879.00000
  73. set maxYcoord 586.00000
  74. set paletteXsize 0
  75. set paletteYsize 0
  76. set pbottomleftX 0
  77. set pbottomleftY 0
  78. set Xscale 0
  79. set Yscale 0
  80. set Nh 1024
  81. set Nit 40
  82. set J 6
  83. set Nwx 8
  84. set Nwy 10
  85. set Nws 5
  86. set Np 0.0
  87. set Eps 1.0e-5
  88. set matr 1
  89. set freq 1.0e6
  90. set sigma 5.6e7
  91. #########################################################################
  92. # NAME: global_init
  93. # PURPOSE: define the global variables which decide the state of
  94. # display mode
  95. #
  96. #########################################################################
  97. proc global_init { } {
  98. global palettebkcolor
  99. # global board
  100. # catch {unset board}
  101. # array set board {}
  102. createMenu
  103. }
  104. #########################################################################
  105. # NAME: createMenu
  106. # PURPOSE: create the main menu
  107. #
  108. #########################################################################
  109. proc createMenu { } {
  110. frame .mbar -relief raised -bd 2
  111. # frame .draw -relief raised -bd 2
  112. frame .dummy1 -relief raised -width 20c -height 0.05c -background blue
  113. frame .dummy -width 24c -height 0.5c -background black
  114. #############################################################################################
  115. global myAppFileName
  116. canvas .c -width 24c -height 16c -background black \
  117. -xscrollcommand ".shoriz set" \
  118. -yscrollcommand ".svert set"
  119. scrollbar .svert -orient v -command ".c yview"
  120. scrollbar .shoriz -orient h -command ".c xview"
  121. # grid .c -row 0 -column 0 -columnspan 3 -sticky news
  122. # grid .svert -row 0 -column 3 -columnspan 1 -sticky ns
  123. # grid .shoriz -row 1 -column 0 -columnspan 3 -sticky ew
  124. frame .butt
  125. button .butt.rect -text "Rectangle" -command mkRect -background lightblue -foreground black
  126. button .butt.cir -text "Circle" -command mkCir -background lightblue -foreground black
  127. button .butt.poly -text "Trapezoid" -command mkPoly -background lightblue -foreground black
  128. button .butt.gnd -text "Ground Plate" -command mkGnd -background lightblue -foreground black
  129. button .butt.move -text "Move" -command moveUnit -background lightyellow -foreground black
  130. button .butt.delete -text "Delete" -command delUnit -background lightyellow -foreground black
  131. # button .butt1.zoomin -text "Zoom In" -command "zoomFactor .c 1.25"
  132. # button .butt1.zoomout -text "Zoom Out" -command "zoomFactor .c 0.8"
  133. # grid .butt.move .butt.delete ;#.butt1.zoomin .butt1.zoomout
  134. label .dummy.status -text " Status Bar " -background orange
  135. label .dummy.statusCon -text "You are welcome to use this Program!" -background black
  136. ### button .dummy.eplicon -bitmap @epl.bit -background black -foreground white -command eplIntro
  137. button .dummy.eplicon -text epl -background black -foreground white -command eplIntro
  138. ##############################################################################################
  139. pack .mbar .c .butt .dummy1 .dummy -side top -fill x
  140. # pack .draw.svert .draw.c -side right -fill y
  141. # grid .butt.rect .butt.cir .butt.poly .butt.gnd
  142. # pack .butt1.move .butt1.delete -side left
  143. pack .butt.rect .butt.cir .butt.poly .butt.gnd -side left
  144. pack .butt.move .butt.delete -side right
  145. pack .dummy.eplicon .dummy.status .dummy.statusCon -side left
  146. menubutton .mbar.file -text File \
  147. -menu .mbar.file.menu
  148. menubutton .mbar.edit -text Edit \
  149. -menu .mbar.edit.menu
  150. menubutton .mbar.setup -text Setup \
  151. -menu .mbar.setup.menu
  152. menubutton .mbar.handcreate -text HandCreate \
  153. -menu .mbar.handcreate.menu
  154. menubutton .mbar.dropcreate -text DropCreate \
  155. -menu .mbar.dropcreate.menu
  156. menubutton .mbar.calculate -text Calculate \
  157. -menu .mbar.calculate.menu
  158. menubutton .mbar.help -text About \
  159. -menu .mbar.help.menu
  160. pack .mbar.file .mbar.edit .mbar.setup \
  161. .mbar.handcreate .mbar.dropcreate .mbar.calculate -side left
  162. pack .mbar.help -side right
  163. menu .mbar.file.menu
  164. .mbar.file.menu add command -label "New" \
  165. -command myAppFileNew
  166. .mbar.file.menu add command -label "Open" \
  167. -command myAppFileOpen
  168. .mbar.file.menu add command -label "Save" \
  169. -command {myAppFileSave $myAppFileName}
  170. .mbar.file.menu add command -label "Save As" \
  171. -command myAppFileSaveAs
  172. .mbar.file.menu add command -label "Close" \
  173. -command myAppFileClose
  174. .mbar.file.menu add separator
  175. .mbar.file.menu add cascade -label "Print" \
  176. -menu .mbar.file.menu.print
  177. .mbar.file.menu add separator
  178. .mbar.file.menu add command -label "Exit" \
  179. -command myAppExit
  180. menu .mbar.file.menu.print
  181. .mbar.file.menu.print add command -label "Geometrical Parameters" \
  182. -command printPara
  183. .mbar.file.menu.print add command -label "Calculation Parameters" \
  184. -command printcal
  185. .mbar.file.menu.print add command -label "Print Canvas" \
  186. -command printGraph
  187. menu .mbar.edit.menu
  188. .mbar.edit.menu add command -label "Move" \
  189. -command moveUnit
  190. .mbar.edit.menu add command -label "Delete" \
  191. -command delUnit
  192. .mbar.edit.menu add separator
  193. .mbar.edit.menu add command -label "Geometry" \
  194. -command editPara
  195. menu .mbar.setup.menu
  196. .mbar.setup.menu add command -label "Option" \
  197. -command \
  198. { Coption .palettePara { Palette Parameters } 0 }
  199. .mbar.setup.menu add command -label "Parameters" \
  200. -command \
  201. { calpara .calPara { Computational Parameters } }
  202. menu .mbar.handcreate.menu
  203. .mbar.handcreate.menu add command -label "Rectangle" \
  204. -command {
  205. set corFlag -1
  206. ## puts $corFlag
  207. dispRect .rectPara { Rectangular Conductor Parameters } {}
  208. }
  209. .mbar.handcreate.menu add command -label "Circle" \
  210. -command {
  211. set corFlag -1
  212. ## puts $corFlag
  213. dispCir .cirPara { Circular Conductor Parameters } {}
  214. }
  215. .mbar.handcreate.menu add command -label "Trapezoid" \
  216. -command {
  217. set corFlag -1
  218. ## puts $corFlag
  219. getApexnum
  220. }
  221. .mbar.handcreate.menu add command -label "Ground" \
  222. -command {
  223. set corFlag -1
  224. ## puts $corFlag
  225. dispGnd .gndPara { Ground Plane Parameters } {}
  226. }
  227. menu .mbar.dropcreate.menu
  228. .mbar.dropcreate.menu add command -label "Rectangle" \
  229. -command mkRect
  230. .mbar.dropcreate.menu add command -label "Circle" \
  231. -command mkCir
  232. .mbar.dropcreate.menu add command -label "Trapezoid" \
  233. -command mkPoly
  234. .mbar.dropcreate.menu add command -label "Ground" \
  235. -command mkGnd
  236. menu .mbar.calculate.menu
  237. .mbar.calculate.menu add command -label "Check Data" \
  238. -command { startcal1 1 }
  239. .mbar.calculate.menu add command -label "Start Calculation" \
  240. -command { startcal1 2 }
  241. .mbar.calculate.menu add command \
  242. -label "Start Frequency-List Calculation" \
  243. -command { buildFreqList }
  244. .mbar.calculate.menu add command \
  245. -label "Start Calculation - Append Output" \
  246. -command { startcal1 3 }
  247. .mbar.calculate.menu add command -label "Check Results" \
  248. -command { checkResult }
  249. menu .mbar.help.menu
  250. .mbar.help.menu add command -label "About..." \
  251. -command about
  252. tk_menuBar .mbar .mbar.file .mbar.edit .mbar.view .mbar.setup \
  253. .mbar.handcreate .mbar.dropcreate .mbar.calculate .mbar.help
  254. focus .mbar
  255. }
  256. #########################################################################
  257. # NAME: editPara
  258. # PURPOSE: edit the parameters of single objects in the palette
  259. #
  260. #########################################################################
  261. proc editPara { } {
  262. global dieleData recData cirData triData ellData polyData gndData
  263. global recTags cirTags dieleTags ellTags triTags polyTags gndTags
  264. global recId cirId dieleId ellId triId polyId gndId
  265. global palFlag
  266. global newFlag
  267. checkPal
  268. if { $palFlag < 0 } {
  269. return $palFlag
  270. }
  271. if { $newFlag < 0 } {
  272. promptInfo "You must setup a new palette first!"
  273. return $newFlag
  274. }
  275. bind .c <Motion> {
  276. set realX [expr { %x/$Xscale+$pbottomleftX }]
  277. set realY [expr { ($maxYcoord-%y)/$Yscale+$pbottomleftY }]
  278. .dummy.statusCon configure -text "x=$realX, y=$realY"
  279. }
  280. bind .c <Button-1> {
  281. set curPoint [.c find withtag current]
  282. ## puts $curPoint
  283. if { [lsearch -exact $recId $curPoint] != -1 } {
  284. setTag $curPoint $recId $recTags $recData
  285. set corFlag 0
  286. ## puts $corFlag
  287. ## puts "current position: $curPosition"
  288. set title "Correct Rectangle No. "
  289. set title1 [lindex $recData [expr { $curPosition+1 }]]
  290. set title $title$title1
  291. dispRect .rectPara $title $curPosition
  292. } elseif { [lsearch -exact $cirId $curPoint] != -1 } {
  293. setTag $curPoint $cirId $cirTags $cirData
  294. set corFlag 0;# set the correcting mode
  295. ## puts $corFlag
  296. set title "Correct Circle No. "
  297. set title1 [lindex $cirData [expr { $curPosition+1 }]]
  298. set title $title$title1
  299. dispCir .cirPara $title $curPosition
  300. } elseif { [lsearch -exact $dieleId $curPoint] != -1 } {
  301. setTag $curPoint $dieleId $dieleTags $dieleData
  302. set corFlag 0;# set the correcting mode
  303. ## puts $corFlag
  304. set title "Correct Dielectric No. "
  305. set title1 [lindex $dieleData [expr { $curPosition+1 }]]
  306. set title $title$title1
  307. dispDiele .dielePara $title $curPosition
  308. } elseif { [lsearch -exact $triId $curPoint] != -1 } {
  309. setTag $curPoint $triId $triTags $triData
  310. set corFlag 0;# set the correcting mode
  311. ## puts $corFlag
  312. set title "Correct Triangle No. "
  313. set title1 [lindex $triData [expr { $curPosition+1 }]]
  314. set title $title$title1
  315. dispTri .triPara $title $curPosition
  316. } elseif { [lsearch -exact $ellId $curPoint] != -1 } {
  317. setTag $curPoint $ellId $ellTags $ellData
  318. set corFlag 0;# set the correcting mode
  319. ## puts $corFlag
  320. set title "Correct Ellipse No. "
  321. set title1 [lindex $ellData [expr { $curPosition+1 }]]
  322. set title $title$title1
  323. dispEll .ellPara $title $curPosition
  324. } elseif { [lsearch -exact $polyId $curPoint] != -1 } {
  325. setTag $curPoint $polyId $polyTags $polyData
  326. set corFlag 0;# set the correcting mode
  327. ## puts $corFlag
  328. set title "Correct Trapezoid No. "
  329. set title1 [lindex $polyData [expr { $curPosition+1 }]]
  330. set title $title$title1
  331. dispPoly .polyPara $title \
  332. [lindex $polyData [expr { $curPosition+2 }]] $curPosition
  333. } elseif { [lsearch -exact $gndId $curPoint] != -1 } {
  334. setTag $curPoint $gndId $gndTags $gndData
  335. set corFlag 0;# set the correcting mode
  336. ## puts $corFlag
  337. set title "Correct Ground No. "
  338. set title1 [lindex $gndData [expr { $curPosition+1 }]]
  339. set title $title$title1
  340. dispGnd .gndPara $title $curPosition
  341. }
  342. }
  343. }
  344. ################################################################################################
  345. # Here below is to draw different shapes
  346. #
  347. ################################################################################################
  348. proc mkRect { } {
  349. global firstnodex firstnodey
  350. global secondnodex secondnodey
  351. global tempnodex tempnodey
  352. global buttonflag
  353. global maxXcoord maxYcoord
  354. global paletteXsize paletteYsize Xscale Yscale
  355. global pbottomleftX pbottomleftY
  356. global palFlag
  357. global newFlag
  358. global myAppChangedFlag
  359. checkPal
  360. if { $palFlag < 0 } {
  361. return $palFlag
  362. }
  363. if { $newFlag < 0 } {
  364. promptInfo "You must setup a new palette first!"
  365. return $newFlag
  366. }
  367. set buttonflag 0
  368. .c config -cursor { cross red white }
  369. bind .c <Motion> {
  370. ## puts "(%x %y)"
  371. set realX [expr { %x/$Xscale+$pbottomleftX }]
  372. set realY [expr { ($maxYcoord-%y)/$Yscale+$pbottomleftY }]
  373. ## puts "begin1"
  374. ## puts $pbottomleftY
  375. ## puts $Yscale
  376. ## puts $maxYcoord
  377. ## puts $paletteYsize
  378. ## puts $paletteXsize
  379. ## puts "end1"
  380. .dummy.statusCon configure -text "x=$realX, y=$realY"
  381. if { $buttonflag == 1 } {
  382. .c delete interrect
  383. .c create rectangle $tempnodex $tempnodey %x %y -outline blue \
  384. -tags interrect
  385. }
  386. }
  387. bind .c <Button-1> {
  388. if { $buttonflag == 1 } {
  389. .c delete interrect
  390. incr recCounter
  391. set rect [.c create rectangle $tempnodex $tempnodey %x %y \
  392. -outline black -fill yellow -tags recTags$recCounter ]
  393. lappend recId $rect
  394. lappend recTags recTags$recCounter
  395. ## puts $recTags
  396. set firstnodex($rect) $tempnodex
  397. set firstnodey($rect) $tempnodey
  398. set secondnodex($rect) %x
  399. set secondnodey($rect) %y
  400. ## puts $rect
  401. ## puts $firstnodex($rect)
  402. ## puts $firstnodey($rect)
  403. ## puts $secondnodex($rect)
  404. ## puts $secondnodey($rect)
  405. set buttonflag 0
  406. set fileHead [lreplace $fileHead 1 1 [expr { [lindex $fileHead 1]+1 }]]
  407. ## puts $fileHead
  408. lappend recData "REC"
  409. lappend recData $rect
  410. lappend recData recTags$recCounter
  411. lappend recData $recCounter
  412. if { $firstnodex($rect) <= $secondnodex($rect) } {
  413. set bottomleftX [expr { $firstnodex($rect)/$Xscale+$pbottomleftX }]
  414. } else {
  415. set bottomleftX [expr { $secondnodex($rect)/$Xscale+$pbottomleftX }]
  416. }
  417. if { $firstnodey($rect) >= $secondnodey($rect) } {
  418. set bottomleftY [expr { ($maxYcoord-$firstnodey($rect))/$Yscale+$pbottomleftY }]
  419. } else {
  420. set bottomleftY [expr { ($maxYcoord-$secondnodey($rect))/$Yscale+$pbottomleftY }]
  421. }
  422. lappend recData $bottomleftX
  423. lappend recData $bottomleftY
  424. lappend recData [expr { abs($firstnodex($rect)-$secondnodex($rect))/$Xscale }]
  425. lappend recData [expr { abs($firstnodey($rect)-$secondnodey($rect))/$Yscale }]
  426. lappend recData 0
  427. set myAppChangedFlag 1
  428. ## puts $recData
  429. #.c config -cursor { pointer black white }
  430. } else {
  431. set tempnodex %x
  432. set tempnodey %y
  433. set buttonflag 1
  434. }
  435. }
  436. bind .c <Button-3> {
  437. .c delete interrect
  438. set buttonflag 0
  439. #.c config -cursor { pointer black white }
  440. }
  441. return
  442. }
  443. proc mkCir { } {
  444. global firstnodex firstnodey
  445. global secondnodex secondnodey
  446. global tempnodex tempnodey
  447. global buttonflag
  448. global maxXcoord maxYcoord
  449. global paletteXsize paletteYsize Xscale Yscale
  450. global pbottomleftX pbottomleftY
  451. global palFlag newFlag
  452. global myAppChangedFlag
  453. checkPal
  454. if { $palFlag < 0 } {
  455. return $palFlag
  456. }
  457. if { $newFlag < 0 } {
  458. promptInfo "You must setup a new palette first!"
  459. return $newFlag
  460. }
  461. .c config -cursor { cross red white }
  462. set buttonflag 0
  463. bind .c <Motion> {
  464. ## puts "(%x %y)"
  465. set realX [expr { %x/$Xscale+$pbottomleftX }]
  466. set realY [expr { ($maxYcoord-%y)/$Yscale+$pbottomleftY }]
  467. .dummy.statusCon configure -text "x=$realX, y=$realY"
  468. if { $buttonflag == 1 } {
  469. .c delete interrect
  470. set radius [expr { hypot(($tempnodex-%x),($tempnodey-%y)) }]
  471. ## puts $radius
  472. #set radius [expr { hypot([expr { $tempnodex-%x }],[expr { $tempnodey-%y }]) }]
  473. .c create oval [expr { $tempnodex-$radius }] [expr { $tempnodey-$radius }] \
  474. [expr { $tempnodex+$radius }] [expr { $tempnodey+$radius }] -outline blue -tags interrect
  475. }
  476. }
  477. bind .c <Button-1> {
  478. if { $buttonflag == 1 } {
  479. .c delete interrect
  480. set radius [expr { hypot(($tempnodex-%x),($tempnodey-%y)) }]
  481. ## puts $radius
  482. incr cirCounter
  483. set cir [.c create oval [expr { $tempnodex-$radius }] [expr { $tempnodey-$radius }] \
  484. [expr { $tempnodex+$radius }] [expr { $tempnodey+$radius }] \
  485. -outline black -fill red -tags cirTags$cirCounter]
  486. lappend cirId $cir
  487. lappend cirTags cirTags$cirCounter
  488. #lappend allTags cirTags$cirCounter
  489. set firstnodex($cir) $tempnodex
  490. set firstnodey($cir) $tempnodey
  491. set secondnodex($cir) %x
  492. set secondnodey($cir) %y
  493. ## puts $cir
  494. ## puts $firstnodex($cir)
  495. ## puts $firstnodey($cir)
  496. ## puts $secondnodex($cir)
  497. ## puts $secondnodey($cir)
  498. set buttonflag 0
  499. set fileHead [lreplace $fileHead 2 2 [expr { [lindex $fileHead 2]+1 }]]
  500. ## puts $fileHead
  501. lappend cirData "CIR"
  502. lappend cirData $cir
  503. # lappend cirData cirTags$temptag
  504. lappend cirData cirTags$cirCounter
  505. lappend cirData $cirCounter
  506. lappend cirData [expr { $firstnodex($cir)/$Xscale+$pbottomleftX }]
  507. lappend cirData [expr { ($maxYcoord-$firstnodey($cir))/$Yscale+$pbottomleftY }]
  508. lappend cirData [expr { hypot(($firstnodex($cir)-$secondnodex($cir))/$Xscale, \
  509. ($firstnodey($cir)-$secondnodey($cir))/$Yscale) }]
  510. lappend cirData 0
  511. set myAppChangedFlag 1
  512. ## puts $cirData
  513. #.c config -cursor { pointer black white }
  514. } else {
  515. set tempnodex %x
  516. set tempnodey %y
  517. set buttonflag 1
  518. }
  519. }
  520. bind .c <Button-3> {
  521. .c delete interrect
  522. set buttonflag 0
  523. #.c config -cursor { pointer black white }
  524. }
  525. return
  526. }
  527. proc mkDiele { } {
  528. global firstnodex firstnodey
  529. global secondnodex secondnodey
  530. global tempnodex tempnodey
  531. global buttonflag
  532. global maxXcoord maxYcoord
  533. global paletteXsize paletteYsize Xscale Yscale
  534. global pbottomleftX pbottomleftY
  535. global palFlag newFlag
  536. global myAppChangedFlag
  537. checkPal
  538. if { $palFlag < 0 } {
  539. return $palFlag
  540. }
  541. if { $newFlag < 0 } {
  542. promptInfo "You must setup a new palette first!"
  543. return $newFlag
  544. }
  545. .c config -cursor { cross red white }
  546. set buttonflag 0
  547. bind .c <Motion> {
  548. ## puts "(%x %y)"
  549. set realX [expr { %x/$Xscale+$pbottomleftX }]
  550. set realY [expr { ($maxYcoord-%y)/$Yscale+$pbottomleftY }]
  551. .dummy.statusCon configure -text "x=$realX, y=$realY"
  552. if { $buttonflag == 1 } {
  553. .c delete interrect
  554. .c create rectangle $tempnodex $tempnodey %x %y -outline blue \
  555. -tags interrect
  556. }
  557. }
  558. bind .c <Button-1> {
  559. if { $buttonflag == 1 } {
  560. .c delete interrect
  561. incr dieleCounter
  562. set diele [.c create rectangle $tempnodex $tempnodey %x %y \
  563. -outline black -fill black -tags dieleTags$dieleCounter]
  564. lappend dieleId $diele
  565. lappend dieleTags dieleTags$dieleCounter
  566. .c lower $diele
  567. set firstnodex($diele) $tempnodex
  568. set firstnodey($diele) $tempnodey
  569. set secondnodex($diele) %x
  570. set secondnodey($diele) %y
  571. ## puts $diele
  572. ## puts $firstnodex($diele)
  573. ## puts $firstnodey($diele)
  574. ## puts $secondnodex($diele)
  575. ## puts $secondnodey($diele)
  576. set buttonflag 0
  577. set fileHead [lreplace $fileHead 0 0 [expr { [lindex $fileHead 0]+1 }]]
  578. ## puts $fileHead
  579. lappend dieleData "DIELE"
  580. lappend dieleData $diele
  581. lappend dieleData dieleTags$dieleCounter
  582. lappend dieleData $dieleCounter
  583. if { $firstnodex($diele) <= $secondnodex($diele) } {
  584. set bottomleftX [expr { $firstnodex($diele)/$Xscale+$pbottomleftX }]
  585. } else {
  586. set bottomleftX [expr { $secondnodex($diele)/$Xscale+$pbottomleftX }]
  587. }
  588. if { $firstnodey($diele) >= $secondnodey($diele) } {
  589. set bottomleftY [expr { ($maxYcoord-$firstnodey($diele))/$Yscale+$pbottomleftY }]
  590. } else {
  591. set bottomleftY [expr { ($maxYcoord-$secondnodey($diele))/$Yscale+$pbottomleftY }]
  592. }
  593. lappend dieleData $bottomleftX
  594. lappend dieleData $bottomleftY
  595. lappend dieleData [expr { abs($firstnodex($diele)-$secondnodex($diele))/$Xscale }]
  596. lappend dieleData [expr { abs($firstnodey($diele)-$secondnodey($diele))/$Yscale }]
  597. lappend dieleData 0 ;#permit
  598. lappend dieleData 0 ;#permea
  599. set myAppChangedFlag 1
  600. ## puts $dieleData
  601. #.c config -cursor { pointer black white }
  602. } else {
  603. set tempnodex %x
  604. set tempnodey %y
  605. set buttonflag 1
  606. }
  607. }
  608. bind .c <Button-3> {
  609. .c delete interrect
  610. set buttonflag 0
  611. #.c config -cursor { pointer black white }
  612. }
  613. return
  614. }
  615. proc mkGnd { } {
  616. global firstnodex firstnodey
  617. global secondnodex secondnodey
  618. global tempnodex tempnodey
  619. global buttonflag
  620. global maxXcoord maxYcoord
  621. global paletteXsize paletteYsize Xscale Yscale
  622. global pbottomleftX pbottomleftY
  623. global palFlag newFlag
  624. global myAppChangedFlag
  625. checkPal
  626. if { $palFlag < 0 } {
  627. return $palFlag
  628. }
  629. if { $newFlag < 0 } {
  630. promptInfo "You must setup a new palette first!"
  631. return $newFlag
  632. }
  633. .c config -cursor { cross red white }
  634. set buttonflag 0
  635. bind .c <Motion> {
  636. ## puts "(%x %y)"
  637. set realX [expr { %x/$Xscale+$pbottomleftX }]
  638. set realY [expr { ($maxYcoord-%y)/$Yscale+$pbottomleftY }]
  639. .dummy.statusCon configure -text "x=$realX, y=$realY"
  640. if { $buttonflag == 1 } {
  641. .c delete interrect
  642. .c create rectangle $tempnodex $tempnodey %x %y -outline blue \
  643. -tags interrect
  644. }
  645. }
  646. bind .c <Button-1> {
  647. if { $buttonflag == 1 } {
  648. .c delete interrect
  649. incr gndCounter
  650. set gnd [.c create rectangle $tempnodex $tempnodey %x %y \
  651. -outline black -fill green -tags gndTags$gndCounter]
  652. lappend gndId $gnd
  653. lappend gndTags gndTags$gndCounter
  654. set firstnodex($gnd) $tempnodex
  655. set firstnodey($gnd) $tempnodey
  656. set secondnodex($gnd) %x
  657. set secondnodey($gnd) %y
  658. ## puts $gnd
  659. ## puts $firstnodex($gnd)
  660. ## puts $firstnodey($gnd)
  661. ## puts $secondnodex($gnd)
  662. ## puts $secondnodey($gnd)
  663. set buttonflag 0
  664. set fileHead [lreplace $fileHead 6 6 [expr { [lindex $fileHead 6]+1 }]]
  665. ## puts $fileHead
  666. lappend gndData "GND"
  667. lappend gndData $gnd
  668. lappend gndData gndTags$gndCounter
  669. lappend gndData $gndCounter
  670. if { $firstnodex($gnd) <= $secondnodex($gnd) } {
  671. set bottomleftX [expr { $firstnodex($gnd)/$Xscale+$pbottomleftX }]
  672. } else {
  673. set bottomleftX [expr { $secondnodex($gnd)/$Xscale+$pbottomleftX }]
  674. }
  675. if { $firstnodey($gnd) >= $secondnodey($gnd) } {
  676. set bottomleftY [expr { ($maxYcoord-$firstnodey($gnd))/$Yscale+$pbottomleftY }]
  677. } else {
  678. set bottomleftY [expr { ($maxYcoord-$secondnodey($gnd))/$Yscale+$pbottomleftY }]
  679. }
  680. lappend gndData $bottomleftX
  681. lappend gndData $bottomleftY
  682. lappend gndData [expr { abs($firstnodex($gnd)-$secondnodex($gnd))/$Xscale }]
  683. lappend gndData [expr { abs($firstnodey($gnd)-$secondnodey($gnd))/$Yscale }]
  684. lappend gndData 0
  685. set myAppChangedFlag 1
  686. ## puts $gndData
  687. #.c config -cursor { pointer black white }
  688. } else {
  689. set tempnodex %x
  690. set tempnodey %y
  691. set buttonflag 1
  692. }
  693. }
  694. bind .c <Button-3> {
  695. .c delete interrect
  696. set buttonflag 0
  697. #.c config -cursor { pointer black white }
  698. }
  699. return
  700. }
  701. proc mkTri { } {
  702. global firstnodex firstnodey
  703. global secondnodex secondnodey
  704. global thirdnodex thirdnodey
  705. global tempnodex tempnodey
  706. global tempnodex2 tempnodey2
  707. global buttonflag
  708. global maxXcoord maxYcoord
  709. global paletteXsize paletteYsize Xscale Yscale
  710. global pbottomleftX pbottomleftY
  711. global palFlag newFlag
  712. global myAppChangedFlag
  713. checkPal
  714. if { $palFlag < 0 } {
  715. return $palFlag
  716. }
  717. if { $newFlag < 0 } {
  718. promptInfo "You must setup a new palette first!"
  719. return $newFlag
  720. }
  721. .c config -cursor { cross red white }
  722. set buttonflag 0
  723. bind .c <Motion> {
  724. ## puts "(%x %y)"
  725. set realX [expr { %x/$Xscale+$pbottomleftX }]
  726. set realY [expr { ($maxYcoord-%y)/$Yscale+$pbottomleftY }]
  727. .dummy.statusCon configure -text "x=$realX, y=$realY"
  728. if { $buttonflag == 1 } {
  729. .c delete interrect
  730. .c create line $tempnodex $tempnodey %x %y \
  731. -tags interrect
  732. } elseif { $buttonflag == 2 } {
  733. .c delete interrect
  734. .c create polygon $tempnodex $tempnodey $tempnodex2 $tempnodey2 %x %y \
  735. -outline blue -tags interrect
  736. }
  737. }
  738. bind .c <Button-1> {
  739. if { $buttonflag == 2 } {
  740. .c delete interrect
  741. incr triCounter
  742. set tri [.c create polygon $tempnodex $tempnodey \
  743. $tempnodex2 $tempnodey2 %x %y \
  744. -outline black -fill white -tags triTags$triCounter]
  745. lappend triId $tri
  746. lappend triTags triTags$triCounter
  747. set firstnodex($tri) $tempnodex
  748. set firstnodey($tri) $tempnodey
  749. set secondnodex($tri) $tempnodex2
  750. set secondnodey($tri) $tempnodey2
  751. set thirdnodex($tri) %x
  752. set thirdnodey($tri) %y
  753. ## puts $tri
  754. ## puts $firstnodex($tri)
  755. ## puts $firstnodey($tri)
  756. ## puts $secondnodex($tri)
  757. ## puts $secondnodey($tri)
  758. ## puts $thirdnodex($tri)
  759. ## puts $thirdnodey($tri)
  760. set buttonflag 0
  761. set fileHead [lreplace $fileHead 3 3 [expr { [lindex $fileHead 3]+1 }]]
  762. ## puts $fileHead
  763. lappend triData "TRI"
  764. lappend triData $tri
  765. # lappend triData triTags$temptag
  766. lappend triData triTags$triCounter
  767. lappend triData $triCounter
  768. lappend triData [expr { $firstnodex($tri)/$Xscale+$pbottomleftX }]
  769. lappend triData [expr { ($maxYcoord-$firstnodey($tri))/$Yscale+$pbottomleftY }]
  770. lappend triData [expr { $secondnodex($tri)/$Xscale+$pbottomleftX }]
  771. lappend triData [expr { ($maxYcoord-$secondnodey($tri))/$Yscale+$pbottomleftY }]
  772. lappend triData [expr { $thirdnodex($tri)/$Xscale+$pbottomleftX }]
  773. lappend triData [expr { ($maxYcoord-$thirdnodey($tri))/$Yscale+$pbottomleftY }]
  774. lappend triData 0
  775. set myAppChangedFlag 1
  776. ## puts $triData
  777. #.c config -cursor { pointer black white }
  778. } elseif { $buttonflag == 1 } {
  779. .c delete interrect
  780. .c create line $tempnodex $tempnodey %x %y \
  781. -tags interrect
  782. set tempnodex2 %x
  783. set tempnodey2 %y
  784. set buttonflag 2
  785. } else {
  786. set tempnodex %x
  787. set tempnodey %y
  788. set buttonflag 1
  789. }
  790. }
  791. bind .c <Button-3> {
  792. .c delete interrect
  793. set buttonflag 0
  794. #.c config -cursor { pointer black white }
  795. }
  796. return
  797. }
  798. proc mkEll { } {
  799. global firstnodex firstnodey
  800. global secondnodex secondnodey
  801. global tempnodex tempnodey
  802. global buttonflag
  803. global maxXcoord maxYcoord
  804. global paletteXsize paletteYsize Xscale Yscale
  805. global pbottomleftX pbottomleftY
  806. global palFlag newFlag
  807. global myAppChangedFlag
  808. checkPal
  809. if { $palFlag < 0 } {
  810. return $palFlag
  811. }
  812. if { $newFlag < 0 } {
  813. promptInfo "You must setup a new palette first!"
  814. return $newFlag
  815. }
  816. .c config -cursor { cross red white }
  817. set buttonflag 0
  818. bind .c <Motion> {
  819. ## puts "(%x %y)"
  820. set realX [expr { %x/$Xscale+$pbottomleftX }]
  821. set realY [expr { ($maxYcoord-%y)/$Yscale+$pbottomleftY }]
  822. .dummy.statusCon configure -text "x=$realX, y=$realY"
  823. if { $buttonflag == 1 } {
  824. .c delete interrect
  825. set majoraxis [expr { sqrt(2)*($tempnodex-%x) }]
  826. set minoraxis [expr { sqrt(2)*($tempnodey-%y) }]
  827. .c create oval [expr { $tempnodex-$majoraxis }] [expr { $tempnodey-$minoraxis }] \
  828. [expr { $tempnodex+$majoraxis }] [expr { $tempnodey+$minoraxis }] \
  829. -outline blue -tags interrect
  830. }
  831. }
  832. bind .c <Button-1> {
  833. if { $buttonflag == 1 } {
  834. .c delete interrect
  835. set majoraxis [expr { sqrt(2)*($tempnodex-%x) }]
  836. set minoraxis [expr { sqrt(2)*($tempnodey-%y) }]
  837. incr ellCounter
  838. set ell [.c create oval [expr { $tempnodex-$majoraxis }] [expr { $tempnodey-$minoraxis }] \
  839. [expr { $tempnodex+$majoraxis }] [expr { $tempnodey+$minoraxis }] \
  840. -outline black -fill white -tags ellTags$ellCounter]
  841. lappend ellId $ell
  842. # set temptag $ell
  843. # lappend ellTags ellTags$temptag
  844. lappend ellTags ellTags$ellCounter
  845. set firstnodex($ell) $tempnodex
  846. set firstnodey($ell) $tempnodey
  847. set secondnodex($ell) %x
  848. set secondnodey($ell) %y
  849. ## puts $ell
  850. ## puts $firstnodex($ell)
  851. ## puts $firstnodey($ell)
  852. ## puts $secondnodex($ell)
  853. ## puts $secondnodey($ell)
  854. set buttonflag 0
  855. set fileHead [lreplace $fileHead 4 4 [expr { [lindex $fileHead 4]+1 }]]
  856. ## puts $fileHead
  857. lappend ellData "ELL"
  858. lappend ellData $ell
  859. # lappend ellData ellTags$temptag
  860. lappend ellData ellTags$ellCounter
  861. lappend ellData $ellCounter
  862. lappend ellData [expr { $firstnodex($ell)/$Xscale+$pbottomleftX }]
  863. lappend ellData [expr { ($maxYcoord-$firstnodey($ell))/$Yscale+$pbottomleftY }]
  864. lappend ellData [expr { abs($majoraxis)/$Xscale }]
  865. lappend ellData [expr { abs($minoraxis)/$Yscale }]
  866. lappend ellData 0
  867. set myAppChangedFlag 1
  868. ## puts $ellData
  869. #.c config -cursor { pointer black white }
  870. } else {
  871. set tempnodex %x
  872. set tempnodey %y
  873. set buttonflag 1
  874. }
  875. }
  876. bind .c <Button-3> {
  877. .c delete interrect
  878. set buttonflag 0
  879. #.c config -cursor { pointer black white }
  880. }
  881. return
  882. }
  883. proc mkPoly { } {
  884. global apexnum
  885. global xcoord ycoord xycoord
  886. global apexorder
  887. global tempnodex tempnodey
  888. global tempnodex2 tempnodey2
  889. global buttonflag
  890. global maxXcoord maxYcoord
  891. global paletteXsize paletteYsize Xscale Yscale
  892. global pbottomleftX pbottomleftY
  893. global palFlag newFlag
  894. global myAppChangedFlag
  895. checkPal
  896. if { $palFlag < 0 } {
  897. return $palFlag
  898. }
  899. if { $newFlag < 0 } {
  900. promptInfo "You must setup a new palette first!"
  901. return $newFlag
  902. }
  903. getApexnumdrop
  904. set buttonflag 0
  905. set apexorder 0
  906. .c config -cursor { cross red white }
  907. bind .c <Motion> {
  908. ## puts "(%x %y)"
  909. set realX [expr { %x/$Xscale+$pbottomleftX }]
  910. set realY [expr { ($maxYcoord-%y)/$Yscale+$pbottomleftY }]
  911. .dummy.statusCon configure -text "x=$realX, y=$realY"
  912. if { $apexorder > 0 && $apexorder < $apexnum } {
  913. .c delete curside
  914. .c create line [lindex $xcoord [expr { $apexorder-1 }]] \
  915. [lindex $ycoord [expr { $apexorder-1 }]] %x %y -tags curside
  916. }
  917. }
  918. bind .c <Button-1> {
  919. if { $apexorder == 0 } {
  920. set xcoord %x
  921. set ycoord %y
  922. set xycoord %x
  923. lappend xycoord %y
  924. incr apexorder
  925. } elseif { $apexorder > 0 && $apexorder < [expr { $apexnum-1 }] } {
  926. lappend xcoord %x
  927. lappend ycoord %y
  928. lappend xycoord %x
  929. lappend xycoord %y
  930. incr apexorder
  931. .c delete interrect
  932. set counter 0
  933. while { $counter < [expr { $apexorder-1 }] } {
  934. ## puts $counter
  935. ## puts $apexorder
  936. ## puts [lindex $xcoord $counter]
  937. ## puts [lindex $ycoord $counter]
  938. ## puts [lindex $xcoord [expr { $counter+1 }]]
  939. ## puts [lindex $ycoord [expr { $counter+1 }]]
  940. ## puts $xcoord
  941. ## puts $ycoord
  942. ## puts $xycoord
  943. .c create line [lindex $xcoord $counter] [lindex $ycoord $counter] \
  944. [lindex $xcoord [expr { $counter+1 }]] [lindex $ycoord [expr { $counter+1 }]] \
  945. -tags interrect
  946. incr counter
  947. }
  948. } elseif { $apexorder == [expr { $apexnum-1 }] } {
  949. lappend xcoord %x
  950. lappend ycoord %y
  951. lappend xycoord %x
  952. lappend xycoord %y
  953. .c delete interrect
  954. .c delete curside
  955. incr polyCounter
  956. set poly [.c create polygon $xycoord -outline black -fill \
  957. blue -tags polyTags$polyCounter]
  958. lappend polyId $poly
  959. # set temptag $poly
  960. # lappend polyTags polyTags$temptag
  961. lappend polyTags polyTags$polyCounter
  962. set buttonflag 0
  963. set apexorder 0
  964. set fileHead [lreplace $fileHead 5 5 [expr { [lindex $fileHead 5]+1 }]]
  965. ## puts $fileHead
  966. lappend polyData "POLY"
  967. lappend polyData $poly
  968. # lappend polyData polyTags$temptag
  969. lappend polyData polyTags$polyCounter
  970. lappend polyData $polyCounter
  971. lappend polyData [expr { [llength $xycoord]/2 }]
  972. ## puts [llength $xycoord]
  973. for {set i 0} {$i < [expr { [llength $xycoord]/2 }]} {incr i} {
  974. lappend polyData [expr { [lindex $xycoord [expr { 2*$i }]]/$Xscale+$pbottomleftX }]
  975. lappend polyData [expr { ($maxYcoord-[lindex $xycoord [expr { 2*$i+1 }]])/$Yscale \
  976. +$pbottomleftY }]
  977. }
  978. lappend polyData 0
  979. set myAppChangedFlag 1
  980. ## puts $polyData
  981. }
  982. }
  983. bind .c <Button-3> {
  984. .c delete interrect
  985. .c delete curside
  986. set buttonflag 0
  987. set apexorder 0
  988. #.c config -cursor { pointer black white }
  989. }
  990. return
  991. }
  992. #########################################################################################
  993. # Move Unit
  994. #
  995. #########################################################################################
  996. proc moveUnit { } {
  997. global dieleData recData cirData triData ellData polyData gndData
  998. global maxXcoord maxYcoord
  999. global paletteXsize paletteYsize Xscale Yscale
  1000. global pbottomleftX pbottomleftY
  1001. global newFlag
  1002. global myAppChangedFlag
  1003. if { $newFlag < 0 } {
  1004. promptInfo "You must setup a new palette first!"
  1005. return $newFlag
  1006. }
  1007. bind .c <Button-1> {
  1008. if { [lsearch -exact $recId $curPoint] != -1
  1009. || [lsearch -exact $cirId $curPoint] != -1
  1010. || [lsearch -exact $dieleId $curPoint] != -1
  1011. || [lsearch -exact $ellId $curPoint] != -1
  1012. || [lsearch -exact $triId $curPoint] != -1
  1013. || [lsearch -exact $polyId $curPoint] != -1
  1014. || [lsearch -exact $gndId $curPoint] != -1 } {
  1015. set curX %x
  1016. set curY %y
  1017. set oriX %x
  1018. set oriY %y
  1019. } else {}
  1020. }
  1021. bind .c <B1-Motion> {
  1022. set curPoint [.c find withtag current]
  1023. ## puts $curPoint
  1024. if { [lsearch -exact $recId $curPoint] != -1
  1025. || [lsearch -exact $cirId $curPoint] != -1
  1026. || [lsearch -exact $dieleId $curPoint] != -1
  1027. || [lsearch -exact $ellId $curPoint] != -1
  1028. || [lsearch -exact $triId $curPoint] != -1
  1029. || [lsearch -exact $polyId $curPoint] != -1
  1030. || [lsearch -exact $gndId $curPoint] != -1 } {
  1031. ## puts "(%x %y)"
  1032. set realX [expr { %x/$Xscale+$pbottomleftX }]
  1033. set realY [expr { ($maxYcoord-%y)/$Yscale+$pbottomleftY }]
  1034. set deltaX [expr { (%x-$oriX)/$Xscale }]
  1035. set deltaY [expr { ($oriY-%y)/$Yscale }]
  1036. .dummy.statusCon configure -text "x=$realX, y=$realY, dx=$deltaX, dy=$deltaY"
  1037. ## puts $recId
  1038. ## puts [lsearch -exact $recId $curPoint]
  1039. if { [lsearch -exact $recId $curPoint] != -1 } {
  1040. ## puts [lsearch -exact $recId $curPoint]
  1041. ## puts [lindex $recTags [lsearch -exact $recId $curPoint]]
  1042. .c move [lindex $recTags [lsearch -exact $recId $curPoint]] \
  1043. [expr { %x-$curX }] [expr { %y-$curY }]
  1044. .c raise [lindex $recTags [lsearch -exact $recId $curPoint]]; #ensure on top of diele
  1045. # the data of position should be changed and saved after movement
  1046. set curX %x
  1047. set curY %y
  1048. bind .c <ButtonRelease-1> {
  1049. setTag $curPoint $recId $recTags $recData
  1050. set xnew [expr { (%x-$oriX)/$Xscale }]
  1051. set ynew [expr { (%y-$oriY)/$Yscale }]
  1052. set recData [lreplace $recData [expr { $curPosition+2 }] [expr { $curPosition+2 }] \
  1053. [expr { [lindex $recData [expr { $curPosition+2 }]]+$xnew }]]
  1054. set recData [lreplace $recData [expr { $curPosition+3 }] [expr { $curPosition+3 }] \
  1055. [expr { [lindex $recData [expr { $curPosition+3 }]]-$ynew }]]
  1056. set myAppChangedFlag 1
  1057. bind .c <Button-1> { }
  1058. bind .c <B1-Motion> { }
  1059. bind .c <ButtonRelease-1> { }
  1060. }
  1061. } elseif { [lsearch -exact $cirId $curPoint] != -1 } {
  1062. ## puts [lsearch -exact $cirId $curPoint]
  1063. ## puts [lindex $cirTags [lsearch -exact $cirId $curPoint]]
  1064. .c move [lindex $cirTags [lsearch -exact $cirId $curPoint]] \
  1065. [expr { %x-$curX }] [expr { %y-$curY }]
  1066. .c raise [lindex $cirTags [lsearch -exact $cirId $curPoint]]
  1067. set curX %x
  1068. set curY %y
  1069. bind .c <ButtonRelease-1> {
  1070. setTag $curPoint $cirId $cirTags $cirData
  1071. set xnew [expr { (%x-$oriX)/$Xscale }]
  1072. set ynew [expr { (%y-$oriY)/$Yscale }]
  1073. set cirData [lreplace $cirData [expr { $curPosition+2 }] [expr { $curPosition+2 }] \
  1074. [expr { [lindex $cirData [expr { $curPosition+2 }]]+$xnew }]]
  1075. set cirData [lreplace $cirData [expr { $curPosition+3 }] [expr { $curPosition+3 }] \
  1076. [expr { [lindex $cirData [expr { $curPosition+3 }]]-$ynew }]]
  1077. set myAppChangedFlag 1
  1078. bind .c <Button-1> { }
  1079. bind .c <B1-Motion> { }
  1080. bind .c <ButtonRelease-1> { }
  1081. }
  1082. } elseif { [lsearch -exact $dieleId $curPoint] != -1 } {
  1083. ## puts [lsearch -exact $dieleId $curPoint]
  1084. ## puts [lindex $dieleTags [lsearch -exact $dieleId $curPoint]]
  1085. .c move [lindex $dieleTags [lsearch -exact $dieleId $curPoint]] \
  1086. [expr { %x-$curX }] [expr { %y-$curY }]
  1087. .c lower [lindex $dieleTags [lsearch -exact $dieleId $curPoint]]
  1088. set curX %x
  1089. set curY %y
  1090. bind .c <ButtonRelease-1> {
  1091. setTag $curPoint $dieleId $dieleTags $dieleData
  1092. set xnew [expr { (%x-$oriX)/$Xscale }]
  1093. set ynew [expr { (%y-$oriY)/$Yscale }]
  1094. set dieleData [lreplace $dieleData [expr { $curPosition+2 }] [expr { $curPosition+2 }] \
  1095. [expr { [lindex $dieleData [expr { $curPosition+2 }]]+$xnew }]]
  1096. set dieleData [lreplace $dieleData [expr { $curPosition+3 }] [expr { $curPosition+3 }] \
  1097. [expr { [lindex $dieleData [expr { $curPosition+3 }]]-$ynew }]]
  1098. set myAppChangedFlag 1
  1099. bind .c <Button-1> { }
  1100. bind .c <B1-Motion> { }
  1101. bind .c <ButtonRelease-1> { }
  1102. }
  1103. } elseif { [lsearch -exact $ellId $curPoint] != -1 } {
  1104. ## puts [lsearch -exact $ellId $curPoint]
  1105. ## puts [lindex $ellTags [lsearch -exact $ellId $curPoint]]
  1106. .c move [lindex $ellTags [lsearch -exact $ellId $curPoint]] \
  1107. [expr { %x-$curX }] [expr { %y-$curY }]
  1108. .c raise [lindex $ellTags [lsearch -exact $ellId $curPoint]]
  1109. set curX %x
  1110. set curY %y
  1111. bind .c <ButtonRelease-1> {
  1112. setTag $curPoint $ellId $ellTags $ellData
  1113. set xnew [expr { (%x-$oriX)/$Xscale }]
  1114. set ynew [expr { (%y-$oriY)/$Yscale }]
  1115. set ellData [lreplace $ellData [expr { $curPosition+2 }] [expr { $curPosition+2 }] \
  1116. [expr { [lindex $ellData [expr { $curPosition+2 }]]+$xnew }]]
  1117. set ellData [lreplace $ellData [expr { $curPosition+3 }] [expr { $curPosition+3 }] \
  1118. [expr { [lindex $ellData [expr { $curPosition+3 }]]-$ynew }]]
  1119. set myAppChangedFlag 1
  1120. bind .c <Button-1> { }
  1121. bind .c <B1-Motion> { }
  1122. bind .c <ButtonRelease-1> { }
  1123. }
  1124. } elseif { [lsearch -exact $triId $curPoint] != -1 } {
  1125. ## puts [lsearch -exact $triId $curPoint]
  1126. ## puts [lindex $triTags [lsearch -exact $triId $curPoint]]
  1127. .c move [lindex $triTags [lsearch -exact $triId $curPoint]] \
  1128. [expr { %x-$curX }] [expr { %y-$curY }]
  1129. .c raise [lindex $triTags [lsearch -exact $triId $curPoint]]
  1130. set curX %x
  1131. set curY %y
  1132. bind .c <ButtonRelease-1> {
  1133. setTag $curPoint $triId $triTags $triData
  1134. set xnew [expr { (%x-$oriX)/$Xscale }]
  1135. set ynew [expr { (%y-$oriY)/$Yscale }]
  1136. set triData [lreplace $triData [expr { $curPosition+2 }] [expr { $curPosition+2 }] \
  1137. [expr { [lindex $triData [expr { $curPosition+2 }]]+$xnew }]]
  1138. set triData [lreplace $triData [expr { $curPosition+3 }] [expr { $curPosition+3 }] \
  1139. [expr { [lindex $triData [expr { $curPosition+3 }]]-$ynew }]]
  1140. set triData [lreplace $triData [expr { $curPosition+4 }] [expr { $curPosition+4}] \
  1141. [expr { [lindex $triData [expr { $curPosition+4 }]]+$xnew }]]
  1142. set triData [lreplace $triData [expr { $curPosition+5 }] [expr { $curPosition+5 }] \
  1143. [expr { [lindex $triData [expr { $curPosition+5 }]]-$ynew }]]
  1144. set triData [lreplace $triData [expr { $curPosition+6 }] [expr { $curPosition+6 }] \
  1145. [expr { [lindex $triData [expr { $curPosition+6 }]]+$xnew }]]
  1146. set triData [lreplace $triData [expr { $curPosition+7 }] [expr { $curPosition+7 }] \
  1147. [expr { [lindex $triData [expr { $curPosition+7 }]]-$ynew }]]
  1148. set myAppChangedFlag 1
  1149. bind .c <Button-1> { }
  1150. bind .c <B1-Motion> { }
  1151. bind .c <ButtonRelease-1> { }
  1152. }
  1153. } elseif { [lsearch -exact $polyId $curPoint] != -1 } {
  1154. ## puts [lsearch -exact $polyId $curPoint]
  1155. ## puts [lindex $polyTags [lsearch -exact $polyId $curPoint]]
  1156. .c move [lindex $polyTags [lsearch -exact $polyId $curPoint]] \
  1157. [expr { %x-$curX }] [expr { %y-$curY }]
  1158. .c raise [lindex $polyTags [lsearch -exact $polyId $curPoint]]
  1159. set curX %x
  1160. set curY %y
  1161. bind .c <ButtonRelease-1> {
  1162. setTag $curPoint $polyId $polyTags $polyData
  1163. set apex [lindex $polyData [expr { $curPosition+2 }]]
  1164. set xnew [expr { (%x-$oriX)/$Xscale }]
  1165. set ynew [expr { (%y-$oriY)/$Yscale }]
  1166. for {set polycounter 1} {$polycounter<=$apex} {incr polycounter} {
  1167. set tempx [expr { $curPosition+2*$polycounter+1 }]
  1168. set tempy [expr { $curPosition+2*$polycounter+2 }]
  1169. set polyData [lreplace $polyData $tempx $tempx \
  1170. [expr { [lindex $polyData $tempx]+$xnew }]]
  1171. set polyData [lreplace $polyData $tempy $tempy \
  1172. [expr { [lindex $polyData $tempy]-$ynew }]]
  1173. set myAppChangedFlag 1
  1174. bind .c <Button-1> { }
  1175. bind .c <B1-Motion> { }
  1176. bind .c <ButtonRelease-1> { }
  1177. }
  1178. }
  1179. } elseif { [lsearch -exact $gndId $curPoint] != -1 } {
  1180. ## puts [lsearch -exact $gndId $curPoint]
  1181. ## puts [lindex $gndTags [lsearch -exact $gndId $curPoint]]
  1182. .c move [lindex $gndTags [lsearch -exact $gndId $curPoint]] \
  1183. [expr { %x-$curX }] [expr { %y-$curY }]
  1184. .c raise [lindex $gndTags [lsearch -exact $gndId $curPoint]]
  1185. set curX %x
  1186. set curY %y
  1187. bind .c <ButtonRelease-1> {
  1188. setTag $curPoint $gndId $gndTags $gndData
  1189. set xnew [expr { (%x-$oriX)/$Xscale }]
  1190. set ynew [expr { (%y-$oriY)/$Yscale }]
  1191. set gndData [lreplace $gndData [expr { $curPosition+2 }] [expr { $curPosition+2 }] \
  1192. [expr { [lindex $gndData [expr { $curPosition+2 }]]+$xnew }]]
  1193. set gndData [lreplace $gndData [expr { $curPosition+3 }] [expr { $curPosition+3 }] \
  1194. [expr { [lindex $gndData [expr { $curPosition+3 }]]-$ynew }]]
  1195. set myAppChangedFlag 1
  1196. bind .c <Button-1> { }
  1197. bind .c <B1-Motion> { }
  1198. bind .c <ButtonRelease-1> { }
  1199. }
  1200. } else {
  1201. bind .c <Button-1> { }
  1202. bind .c <B1-Motion> { }
  1203. bind .c <ButtonRelease-1> { }
  1204. }
  1205. } else {
  1206. bind .c <B1-Motion> { }
  1207. bind .c <ButtonRelease-1> { }
  1208. }
  1209. }
  1210. }
  1211. #########################################################################################
  1212. # Delete Unit
  1213. # correct fileHead xxxxData xxxxCounter
  1214. #########################################################################################
  1215. proc delUnit { } {
  1216. global myAppChangedFlag
  1217. global newFlag
  1218. if { $newFlag < 0 } {
  1219. promptInfo "You must setup a new palette first!"
  1220. return $newFlag
  1221. }
  1222. bind .c <Button-1> {
  1223. set curPoint [.c find withtag current]
  1224. ## puts $curPoint
  1225. if { [lsearch -exact $recId $curPoint] != -1 } {
  1226. ## puts [lsearch -exact $recId $curPoint]
  1227. ## puts [lindex $recTags [lsearch -exact $recId $curPoint]]
  1228. .c delete [lindex $recTags [lsearch -exact $recId $curPoint]]
  1229. set recData [lreplace $recData [expr { [lsearch -exact $recId $curPoint]*9 }] \
  1230. [expr { [lsearch -exact $recId $curPoint]*9+8 }]]
  1231. set fileHead [lreplace $fileHead 1 1 [expr { [lindex $fileHead 1]-1 }]]
  1232. ## puts $fileHead
  1233. if {[lsearch -exact $recId $curPoint] < [lindex $fileHead 1]} {
  1234. for {set counter [lsearch -exact $recId $curPoint]} \
  1235. {$counter<[lindex $fileHead 1]} {incr counter} {
  1236. set olddata [expr { $counter*9+3 }]
  1237. ## puts $olddata
  1238. set recData [lreplace $recData $olddata $olddata \
  1239. [expr { [lindex $recData $olddata]-1 }]]
  1240. set tempdata [lindex $recData $olddata]
  1241. set recData [lreplace $recData [expr { $olddata-1 }] [expr { $olddata-1 }] \
  1242. recTags$tempdata]
  1243. ## puts $recData
  1244. ## puts recTags[expr { $counter+2 }]
  1245. .c addtag recTags[expr { $counter+1 }] withtag recTags[expr { $counter+2 }]
  1246. .c dtag recTags[expr { $counter+2 }]
  1247. #Must correct tags for create new shapes
  1248. }
  1249. }
  1250. set recCounter [expr { $recCounter-1 }]
  1251. ## puts $recCounter
  1252. # set recTags [lreplace $recTags [lsearch -exact $recId $curPoint] \
  1253. [lsearch -exact $recId $curPoint]]
  1254. set recTags [lreplace $recTags $recCounter $recCounter]
  1255. #delete the last element.
  1256. set recId [lreplace $recId [lsearch -exact $recId $curPoint] \
  1257. [lsearch -exact $recId $curPoint]]
  1258. # set recId [lreplace $recId $recCounter $recCounter]
  1259. ## puts $recTags
  1260. ## puts $recId
  1261. set myAppChangedFlag 1
  1262. #recTags needs to be corrected also
  1263. } elseif { [lsearch -exact $cirId $curPoint] != -1 } {
  1264. ## puts [lsearch -exact $cirId $curPoint]
  1265. ## puts [lindex $cirTags [lsearch -exact $cirId $curPoint]]
  1266. .c delete [lindex $cirTags [lsearch -exact $cirId $curPoint]]
  1267. #
  1268. set cirData [lreplace $cirData [expr { [lsearch -exact $cirId $curPoint]*8 }] \
  1269. [expr { [lsearch -exact $cirId $curPoint]*8+7 }]]
  1270. set fileHead [lreplace $fileHead 2 2 [expr { [lindex $fileHead 2]-1 }]]
  1271. ## puts $fileHead
  1272. if {[lsearch -exact $cirId $curPoint] < [lindex $fileHead 2]} {
  1273. for {set counter [lsearch -exact $cirId $curPoint]} \
  1274. {$counter<[lindex $fileHead 2]} {incr counter} {
  1275. set olddata [expr { $counter*8+3 }]
  1276. ## puts $olddata
  1277. set cirData [lreplace $cirData $olddata $olddata \
  1278. [expr { [lindex $cirData $olddata]-1 }]]
  1279. set tempdata [lindex $cirData $olddata]
  1280. set cirData [lreplace $cirData [expr { $olddata-1 }] [expr { $olddata-1 }] \
  1281. cirTags$tempdata]
  1282. ## puts $cirData
  1283. ## puts cirTags[expr { $counter+2 }]
  1284. .c addtag cirTags[expr { $counter+1 }] withtag cirTags[expr { $counter+2 }]
  1285. .c dtag cirTags[expr { $counter+2 }]
  1286. #Must correct tags for create new shapes
  1287. }
  1288. }
  1289. #.c addtag newTag recTags2
  1290. set cirCounter [expr { $cirCounter-1 }]
  1291. ## puts $cirCounter
  1292. set cirTags [lreplace $cirTags $cirCounter $cirCounter]
  1293. #delete the last element.
  1294. set cirId [lreplace $cirId [lsearch -exact $cirId $curPoint] \
  1295. [lsearch -exact $cirId $curPoint]]
  1296. # set cirId [lreplace $cirId $cirCounter $cirCounter]
  1297. ## puts $cirTags
  1298. ## puts $cirId
  1299. set myAppChangedFlag 1
  1300. } elseif { [lsearch -exact $dieleId $curPoint] != -1 } {
  1301. ## puts [lsearch -exact $dieleId $curPoint]
  1302. ## puts [lindex $dieleTags [lsearch -exact $dieleId $curPoint]]
  1303. .c delete [lindex $dieleTags [lsearch -exact $dieleId $curPoint]]
  1304. set dieleData [lreplace $dieleData [expr { [lsearch -exact $dieleId $curPoint]*10 }] \
  1305. [expr { [lsearch -exact $dieleId $curPoint]*10+9 }]]
  1306. set fileHead [lreplace $fileHead 0 0 [expr { [lindex $fileHead 0]-1 }]]
  1307. ## puts $fileHead
  1308. if {[lsearch -exact $dieleId $curPoint] < [lindex $fileHead 0]} {
  1309. for {set counter [lsearch -exact $dieleId $curPoint]} \
  1310. {$counter<[lindex $fileHead 0]} {incr counter} {
  1311. set olddata [expr { $counter*10+3 }]
  1312. ## puts $olddata
  1313. set dieleData [lreplace $dieleData $olddata $olddata \
  1314. [expr { [lindex $dieleData $olddata]-1 }]]
  1315. set tempdata [lindex $dieleData $olddata]
  1316. set dieleData [lreplace $dieleData [expr { $olddata-1 }] [expr { $olddata-1 }] \
  1317. dieleTags$tempdata]
  1318. ## puts $dieleData
  1319. ## puts dieleTags[expr { $counter+2 }]
  1320. .c addtag dieleTags[expr { $counter+1 }] withtag dieleTags[expr { $counter+2 }]
  1321. .c dtag dieleTags[expr { $counter+2 }]
  1322. #Must correct tags for create new shapes
  1323. }
  1324. }
  1325. #.c addtag newTag recTags2
  1326. set dieleCounter [expr { $dieleCounter-1 }]
  1327. ## puts $dieleCounter
  1328. set dieleTags [lreplace $dieleTags $dieleCounter $dieleCounter]
  1329. #delete the last element.
  1330. set dieleId [lreplace $dieleId [lsearch -exact $dieleId $curPoint] \
  1331. [lsearch -exact $dieleId $curPoint]]
  1332. ## puts $dieleTags
  1333. ## puts $dieleId
  1334. set myAppChangedFlag 1
  1335. } elseif { [lsearch -exact $ellId $curPoint] != -1 } {
  1336. ## puts [lsearch -exact $ellId $curPoint]
  1337. ## puts [lindex $ellTags [lsearch -exact $ellId $curPoint]]
  1338. .c delete [lindex $ellTags [lsearch -exact $ellId $curPoint]]
  1339. set ellData [lreplace $ellData [expr { [lsearch -exact $ellId $curPoint]*9 }] \
  1340. [expr { [lsearch -exact $ellId $curPoint]*9+8 }]]
  1341. set fileHead [lreplace $fileHead 4 4 [expr { [lindex $fileHead 4]-1 }]]
  1342. ## puts $fileHead
  1343. if {[lsearch -exact $ellId $curPoint] < [lindex $fileHead 4]} {
  1344. for {set counter [lsearch -exact $ellId $curPoint]} \
  1345. {$counter<[lindex $fileHead 4]} {incr counter} {
  1346. set olddata [expr { $counter*9+3 }]
  1347. ## puts $olddata
  1348. set ellData [lreplace $ellData $olddata $olddata \
  1349. [expr { [lindex $ellData $olddata]-1 }]]
  1350. set tempdata [lindex $ellData $olddata]
  1351. set ellData [lreplace $ellData [expr { $olddata-1 }] [expr { $olddata-1 }] \
  1352. ellTags$tempdata]
  1353. ## puts $ellData
  1354. ## puts ellTags[expr { $counter+2 }]
  1355. .c addtag ellTags[expr { $counter+1 }] withtag ellTags[expr { $counter+2 }]
  1356. .c dtag ellTags[expr { $counter+2 }]
  1357. #Must correct tags for create new shapes
  1358. }
  1359. }
  1360. #.c addtag newTag recTags2
  1361. set ellCounter [expr { $ellCounter-1 }]
  1362. ## puts $ellCounter
  1363. set ellTags [lreplace $ellTags $ellCounter $ellCounter]
  1364. #delete the last element.
  1365. set ellId [lreplace $ellId [lsearch -exact $ellId $curPoint] \
  1366. [lsearch -exact $ellId $curPoint]]
  1367. ## puts $ellTags
  1368. ## puts $ellId
  1369. set myAppChangedFlag 1
  1370. } elseif { [lsearch -exact $triId $curPoint] != -1 } {
  1371. ## puts [lsearch -exact $triId $curPoint]
  1372. ## puts [lindex $triTags [lsearch -exact $triId $curPoint]]
  1373. .c delete [lindex $triTags [lsearch -exact $triId $curPoint]]
  1374. set triData [lreplace $triData [expr { [lsearch -exact $triId $curPoint]*11 }] \
  1375. [expr { [lsearch -exact $triId $curPoint]*11+10 }]]
  1376. set fileHead [lreplace $fileHead 3 3 [expr { [lindex $fileHead 3]-1 }]]
  1377. ## puts $fileHead
  1378. if {[lsearch -exact $triId $curPoint] < [lindex $fileHead 3]} {
  1379. for {set counter [lsearch -exact $triId $curPoint]} \
  1380. {$counter<[lindex $fileHead 3]} {incr counter} {
  1381. set olddata [expr { $counter*11+3 }]
  1382. ## puts $olddata
  1383. set triData [lreplace $triData $olddata $olddata \
  1384. [expr { [lindex $triData $olddata]-1 }]]
  1385. set tempdata [lindex $triData $olddata]
  1386. set triData [lreplace $triData [expr { $olddata-1 }] [expr { $olddata-1 }] \
  1387. triTags$tempdata]
  1388. ## puts $triData
  1389. ## puts triTags[expr { $counter+2 }]
  1390. .c addtag triTags[expr { $counter+1 }] withtag triTags[expr { $counter+2 }]
  1391. .c dtag triTags[expr { $counter+2 }]
  1392. #Must correct tags for create new shapes
  1393. }
  1394. }
  1395. #.c addtag newTag recTags2
  1396. set triCounter [expr { $triCounter-1 }]
  1397. ## puts $triCounter
  1398. set triTags [lreplace $triTags $triCounter $triCounter]
  1399. #delete the last element.
  1400. set triId [lreplace $triId [lsearch -exact $triId $curPoint] \
  1401. [lsearch -exact $triId $curPoint]]
  1402. ## puts $triTags
  1403. ## puts $triId
  1404. set myAppChangedFlag 1
  1405. } elseif { [lsearch -exact $polyId $curPoint] != -1 } {
  1406. ## puts [lsearch -exact $polyId $curPoint]
  1407. ## puts [lindex $polyTags [lsearch -exact $polyId $curPoint]]
  1408. .c delete [lindex $polyTags [lsearch -exact $polyId $curPoint]]
  1409. setTag $curPoint $polyId $polyTags $polyData
  1410. set idSite $curPosition
  1411. set curPosition1 $curPosition
  1412. ## puts $idSite
  1413. ## puts [expr { $idSite+3+[lindex $polyData [expr { $idSite+2 }]]*2 }]
  1414. set polyData [lreplace $polyData [expr { $idSite-2 }] [expr { $idSite+3+ \
  1415. [lindex $polyData [expr { $idSite+2 }]]*2 }]]
  1416. ## puts $polyData
  1417. set fileHead [lreplace $fileHead 5 5 [expr { [lindex $fileHead 5]-1 }]]
  1418. ## puts $fileHead
  1419. if {[lsearch -exact $polyId $curPoint] < [lindex $fileHead 5]} {
  1420. for {set counter [lsearch -exact $polyId $curPoint]} \
  1421. {$counter<[lindex $fileHead 5]} {incr counter} {
  1422. set olddata [expr { $curPosition1+1 }]
  1423. set polyData [lreplace $polyData $olddata $olddata \
  1424. [expr { [lindex $polyData $olddata]-1 }]]
  1425. set tempdata [lindex $polyData $olddata]
  1426. set polyData [lreplace $polyData [expr { $olddata-1 }] [expr { $olddata-1 }] \
  1427. polyTags$tempdata]
  1428. .c addtag polyTags[expr { $counter+1 }] withtag polyTags[expr { $counter+2 }]
  1429. .c dtag polyTags[expr { $counter+2 }]
  1430. set curPosition1 [expr { $curPosition1+6+[lindex $polyData \
  1431. [expr { $curPosition1+2 }]]*2 }]
  1432. }
  1433. }
  1434. set polyCounter [expr { $polyCounter-1 }]
  1435. ## puts $polyCounter
  1436. set polyTags [lreplace $polyTags $polyCounter $polyCounter]
  1437. #########
  1438. set polyId [lreplace $polyId [lsearch -exact $polyId $curPoint] \
  1439. [lsearch -exact $polyId $curPoint]]
  1440. # set polyId [lreplace $polyId $polyCounter $polyCounter]
  1441. ## puts $polyData
  1442. ## puts $polyTags
  1443. ## puts $polyId
  1444. set myAppChangedFlag 1
  1445. } elseif { [lsearch -exact $gndId $curPoint] != -1 } {
  1446. ## puts [lsearch -exact $gndId $curPoint]
  1447. ## puts [lindex $gndTags [lsearch -exact $gndId $curPoint]]
  1448. .c delete [lindex $gndTags [lsearch -exact $gndId $curPoint]]
  1449. set gndData [lreplace $gndData [expr { [lsearch -exact $gndId $curPoint]*9 }] \
  1450. [expr { [lsearch -exact $gndId $curPoint]*9+8 }]]
  1451. set fileHead [lreplace $fileHead 6 6 [expr { [lindex $fileHead 6]-1 }]]
  1452. ## puts $fileHead
  1453. if {[lsearch -exact $gndId $curPoint] < [lindex $fileHead 6]} {
  1454. for {set counter [lsearch -exact $gndId $curPoint]} \
  1455. {$counter<[lindex $fileHead 6]} {incr counter} {
  1456. set olddata [expr { $counter*9+3 }]
  1457. ## puts $olddata
  1458. set gndData [lreplace $gndData $olddata $olddata \
  1459. [expr { [lindex $gndData $olddata]-1 }]]
  1460. set tempdata [lindex $gndData $olddata]
  1461. set gndData [lreplace $gndData [expr { $olddata-1 }] [expr { $olddata-1 }] \
  1462. gndTags$tempdata]
  1463. ## puts $gndData
  1464. ## puts gndTags[expr { $counter+2 }]
  1465. .c addtag gndTags[expr { $counter+1 }] withtag gndTags[expr { $counter+2 }]
  1466. .c dtag gndTags[expr { $counter+2 }]
  1467. }
  1468. }
  1469. set gndCounter [expr { $gndCounter-1 }]
  1470. ## puts $gndCounter
  1471. set gndTags [lreplace $gndTags $gndCounter $gndCounter]
  1472. set gndId [lreplace $gndId [lsearch -exact $gndId $curPoint] \
  1473. [lsearch -exact $gndId $curPoint]]
  1474. # set gndId [lreplace $gndId $gndCounter $gndCounter]
  1475. ## puts $gndTags
  1476. ## puts $gndId
  1477. set myAppChangedFlag 1
  1478. }
  1479. }
  1480. }
  1481. ################################################################################################
  1482. # hand create graphs
  1483. ################################################################################################
  1484. proc dispRect { w title startpoint } {
  1485. global palFlag corFlag newFlag
  1486. global recData
  1487. global rectx recty rectwidth rectheight rectcond
  1488. global startpoint1
  1489. checkPal
  1490. if { $palFlag < 0 } {
  1491. return $palFlag
  1492. }
  1493. if { $newFlag < 0 } {
  1494. promptInfo "You must setup a new palette first!"
  1495. return $newFlag
  1496. }
  1497. toplevel $w -class Dialog
  1498. wm title $w $title
  1499. wm iconname $w Dialog
  1500. frame $w.top -relief raised -bd 1
  1501. pack $w.top -side top -fill both
  1502. frame $w.bot -relief raised -bd 1
  1503. pack $w.bot -side bottom -fill both
  1504. if { $corFlag == 0 } {
  1505. set rectx [lindex $recData [expr { $startpoint+2 }]]
  1506. set recty [lindex $recData [expr { $startpoint+3 }]]
  1507. set rectwidth [lindex $recData [expr { $startpoint+4 }]]
  1508. set rectheight [lindex $recData [expr { $startpoint+5 }]]
  1509. set rectcond [lindex $recData [expr { $startpoint+6 }]]
  1510. }
  1511. grid [label $w.top.lab1 -text "LowerLeft X Coord"] \
  1512. [entry $w.top.ent1 -textvariable rectx] -sticky e
  1513. grid [label $w.top.lab2 -text "LowerLeft Y Coord"] \
  1514. [entry $w.top.ent2 -textvariable recty] -sticky e
  1515. grid [label $w.top.lab3 -text "Width"] \
  1516. [entry $w.top.ent3 -textvariable rectwidth] -sticky e
  1517. grid [label $w.top.lab4 -text "Height"] \
  1518. [entry $w.top.ent4 -textvariable rectheight] -sticky e
  1519. grid [checkbutton $w.top.but1 -text current -variable rectcond -anchor w] -sticky e
  1520. set startpoint1 $startpoint
  1521. button $w.bot.buttonok -text "OK" -command {
  1522. if { $corFlag == -1 } {
  1523. rectOk $rectx $recty $rectwidth $rectheight $rectcond {}
  1524. destroy .rectPara
  1525. } else {
  1526. rectOk $rectx $recty $rectwidth $rectheight $rectcond $startpoint1
  1527. destroy .rectPara
  1528. }
  1529. }
  1530. button $w.bot.buttoncancel -text "CANCEL" -command { destroy .rectPara }
  1531. pack $w.bot.buttonok $w.bot.buttoncancel -side left -fill both
  1532. }
  1533. proc rectOk { rectx recty rectw recth rectc startpoint } {
  1534. global myAppChangedFlag
  1535. global recCounter recId recTags
  1536. global Xscale Yscale
  1537. global maxYcoord
  1538. global pbottomleftX pbottomleftY
  1539. global fileHead recData
  1540. global corFlag
  1541. ## puts "corFlag"
  1542. ## puts $corFlag
  1543. if { $corFlag ==0 } {
  1544. ## puts [lindex $recData [expr { $startpoint }]]
  1545. .c coords [lindex $recData [expr { $startpoint }]] \
  1546. [expr { ($rectx-$pbottomleftX)*$Xscale }] \
  1547. [expr { $maxYcoord-($recty-$pbottomleftY)*$Yscale }] \
  1548. [expr { ($rectx+$rectw-$pbottomleftX)*$Xscale }] \
  1549. [expr { $maxYcoord-($recty+$recth-$pbottomleftY)*$Yscale }]
  1550. set recData [lreplace $recData [expr { $startpoint+2 }] [expr { $startpoint+2 }] \
  1551. $rectx]
  1552. set recData [lreplace $recData [expr { $startpoint+3 }] [expr { $startpoint+3 }] \
  1553. $recty]
  1554. set recData [lreplace $recData [expr { $startpoint+4 }] [expr { $startpoint+4 }] \
  1555. $rectw]
  1556. set recData [lreplace $recData [expr { $startpoint+5 }] [expr { $startpoint+5 }] \
  1557. $recth]
  1558. set recData [lreplace $recData [expr { $startpoint+6 }] [expr { $startpoint+6 }] \
  1559. $rectc]
  1560. ## puts $recData
  1561. } else {
  1562. incr recCounter
  1563. ## puts [expr { $rectx*$Xscale }]
  1564. ## puts [expr { ($maxYcoord-$recty)*$Yscale }]
  1565. ## puts [expr { ($rectx+$rectw)*$Xscale }]
  1566. ## puts [expr { $maxYcoord-($recty-$recth)*$Yscale }]
  1567. ## puts "ggaga"
  1568. ## puts $rectc
  1569. set rect [.c create rectangle [expr { ($rectx-$pbottomleftX)*$Xscale }] \
  1570. [expr { $maxYcoord-($recty-$pbottomleftY)*$Yscale }] \
  1571. [expr { ($rectx+$rectw-$pbottomleftX)*$Xscale }] \
  1572. [expr { $maxYcoord-($recty+$recth-$pbottomleftY)*$Yscale }] \
  1573. -outline black -fill yellow -tags recTags$recCounter]
  1574. lappend recId $rect
  1575. lappend recTags recTags$recCounter
  1576. ## puts $recCounter
  1577. ## puts $recId
  1578. ## puts $recTags
  1579. set fileHead [lreplace $fileHead 1 1 [expr { [lindex $fileHead 1]+1 }]]
  1580. ## puts $fileHead
  1581. lappend recData "REC"
  1582. lappend recData $rect
  1583. lappend recData recTags$recCounter
  1584. lappend recData $recCounter
  1585. lappend recData $rectx
  1586. lappend recData $recty
  1587. lappend recData $rectw
  1588. lappend recData $recth
  1589. lappend recData $rectc
  1590. ## puts $recData
  1591. set myAppChangedFlag 1
  1592. }
  1593. }
  1594. proc dispCir { w title startpoint } {
  1595. global palFlag corFlag newFlag
  1596. global cirData
  1597. global circenterX circenterY cirRadius cirCond
  1598. global startpoint1
  1599. checkPal
  1600. if { $palFlag < 0 } {
  1601. return $palFlag
  1602. }
  1603. if { $newFlag < 0 } {
  1604. promptInfo "You must setup a new palette first!"
  1605. return $newFlag
  1606. }
  1607. toplevel $w -class Dialog
  1608. wm title $w $title
  1609. wm iconname $w Dialog
  1610. frame $w.top -relief raised -bd 1
  1611. pack $w.top -side top -fill both
  1612. frame $w.bot -relief raised -bd 1
  1613. pack $w.bot -side bottom -fill both
  1614. grid [label $w.top.lab1 -text "Center X Coord"] \
  1615. [entry $w.top.ent1 -textvariable circenterX] -sticky e
  1616. grid [label $w.top.lab2 -text "Center Y Coord"] \
  1617. [entry $w.top.ent2 -textvariable circenterY] -sticky e
  1618. grid [label $w.top.lab3 -text "radius"] \
  1619. [entry $w.top.ent3 -textvariable cirRadius] -sticky e
  1620. grid [checkbutton $w.top.but1 -text current -variable cirCond -anchor w] -sticky e
  1621. if { $corFlag == 0 } {
  1622. set circenterX [lindex $cirData [expr { $startpoint+2 }]]
  1623. set circenterY [lindex $cirData [expr { $startpoint+3 }]]
  1624. set cirRadius [lindex $cirData [expr { $startpoint+4 }]]
  1625. set cirCond [lindex $cirData [expr { $startpoint+5 }]]
  1626. }
  1627. set startpoint1 $startpoint
  1628. button $w.bot.buttonok -text "OK" -command {
  1629. if { $corFlag == -1 } {
  1630. cirOk $circenterX $circenterY $cirRadius $cirCond {}
  1631. destroy .cirPara
  1632. } else {
  1633. cirOk $circenterX $circenterY $cirRadius $cirCond $startpoint1
  1634. destroy .cirPara
  1635. }
  1636. }
  1637. button $w.bot.buttoncancel -text "CANCEL" -command { destroy .cirPara }
  1638. pack $w.bot.buttonok $w.bot.buttoncancel -side left -fill both
  1639. }
  1640. proc cirOk { cirx ciry cirr circ startpoint } {
  1641. global myAppChangedFlag
  1642. global cirCounter cirId cirTags
  1643. global Xscale Yscale
  1644. global maxYcoord
  1645. global pbottomleftX pbottomleftY
  1646. global fileHead cirData
  1647. global corFlag
  1648. if { $corFlag ==0 } {
  1649. ## puts [lindex $cirData [expr { $startpoint }]]
  1650. .c coords [lindex $cirData [expr { $startpoint }]] \
  1651. [expr { ($cirx-$cirr-$pbottomleftX)*$Xscale }] \
  1652. [expr { $maxYcoord-($ciry-$cirr-$pbottomleftY)*$Yscale }] \
  1653. [expr { ($cirx+$cirr-$pbottomleftX)*$Xscale }] \
  1654. [expr { $maxYcoord-($ciry+$cirr-$pbottomleftY)*$Yscale }]
  1655. set cirData [lreplace $cirData [expr { $startpoint+2 }] [expr { $startpoint+2 }] \
  1656. $cirx]
  1657. set cirData [lreplace $cirData [expr { $startpoint+3 }] [expr { $startpoint+3 }] \
  1658. $ciry]
  1659. set cirData [lreplace $cirData [expr { $startpoint+4 }] [expr { $startpoint+4 }] \
  1660. $cirr]
  1661. set cirData [lreplace $cirData [expr { $startpoint+5 }] [expr { $startpoint+5 }] \
  1662. $circ]
  1663. ## puts $cirData
  1664. } else {
  1665. incr cirCounter
  1666. set cir [.c create oval [expr { ($cirx-$cirr-$pbottomleftX)*$Xscale }] [expr { \
  1667. $maxYcoord-($ciry-$cirr-$pbottomleftY)*$Yscale }] \
  1668. [expr { ($cirx+$cirr-$pbottomleftX)*$Xscale }] \
  1669. [expr { $maxYcoord-($ciry+$cirr-$pbottomleftY)*$Yscale }] \
  1670. -outline black -fill red -tags cirTags$cirCounter]
  1671. lappend cirId $cir
  1672. lappend cirTags cirTags$cirCounter
  1673. set fileHead [lreplace $fileHead 2 2 [expr { [lindex $fileHead 2]+1 }]]
  1674. ## puts $fileHead
  1675. lappend cirData "CIR"
  1676. lappend cirData $cir
  1677. lappend cirData cirTags$cirCounter
  1678. lappend cirData $cirCounter
  1679. lappend cirData $cirx
  1680. lappend cirData $ciry
  1681. lappend cirData $cirr
  1682. lappend cirData $circ
  1683. ## puts $cirData
  1684. ## puts $cirCounter
  1685. ## puts $cirId
  1686. ## puts $cirTags
  1687. set myAppChangedFlag 1
  1688. }
  1689. }
  1690. proc dispDiele { w title startpoint } {
  1691. global palFlag corFlag newFlag
  1692. global dieleData
  1693. global dieleX dieleY dieleWidth dieleHeight dielePermit dielePermea
  1694. global startpoint1
  1695. checkPal
  1696. if { $palFlag < 0 } {
  1697. return $palFlag
  1698. }
  1699. if { $newFlag < 0 } {
  1700. promptInfo "You must setup a new palette first!"
  1701. return $newFlag
  1702. }
  1703. toplevel $w -class Dialog
  1704. wm title $w $title
  1705. wm iconname $w Dialog
  1706. frame $w.top -relief raised -bd 1
  1707. pack $w.top -side top -fill both
  1708. frame $w.bot -relief raised -bd 1
  1709. pack $w.bot -side bottom -fill both
  1710. grid [label $w.top.lab1 -text "BottomLeft X Coord"] \
  1711. [entry $w.top.ent1 -textvariable dieleX] -sticky e
  1712. grid [label $w.top.lab2 -text "BottomLeft Y Coord"] \
  1713. [entry $w.top.ent2 -textvariable dieleY] -sticky e
  1714. grid [label $w.top.lab3 -text "Width"] \
  1715. [entry $w.top.ent3 -textvariable dieleWidth] -sticky e
  1716. grid [label $w.top.lab4 -text "Height"] \
  1717. [entry $w.top.ent4 -textvariable dieleHeight] -sticky e
  1718. grid [label $w.top.lab5 -text "Permitivity"] \
  1719. [entry $w.top.ent5 -textvariable dielePermit] -sticky e
  1720. grid [label $w.top.lab6 -text "Permeability"] \
  1721. [entry $w.top.ent6 -textvariable dielePermea] -sticky e
  1722. if { $corFlag == 0 } {
  1723. set dieleX [lindex $dieleData [expr { $startpoint+2 }]]
  1724. set dieleY [lindex $dieleData [expr { $startpoint+3 }]]
  1725. set dieleWidth [lindex $dieleData [expr { $startpoint+4 }]]
  1726. set dieleHeight [lindex $dieleData [expr { $startpoint+5 }]]
  1727. set dielePermit [lindex $dieleData [expr { $startpoint+6 }]]
  1728. set dielePermea [lindex $dieleData [expr { $startpoint+7 }]]
  1729. ## puts $dieleData
  1730. }
  1731. set startpoint1 $startpoint
  1732. button $w.bot.buttonok -text "OK" -command {
  1733. if { $corFlag == -1 } {
  1734. dieleOk $dieleX $dieleY $dieleWidth $dieleHeight $dielePermit $dielePermea {}
  1735. destroy .dielePara
  1736. } else {
  1737. dieleOk $dieleX $dieleY $dieleWidth $dieleHeight $dielePermit \
  1738. $dielePermea $startpoint1
  1739. destroy .dielePara
  1740. }
  1741. }
  1742. button $w.bot.buttoncancel -text "CANCEL" -command { destroy .dielePara }
  1743. pack $w.bot.buttonok $w.bot.buttoncancel -side left -fill both
  1744. }
  1745. proc dieleOk { dielex dieley dielew dieleh dielepermit dielepermea startpoint } {
  1746. global dieleCounter dieleId dieleTags
  1747. global Xscale Yscale
  1748. global maxYcoord
  1749. global dieleData fileHead
  1750. global pbottomleftX pbottomleftY
  1751. global corFlag
  1752. global myAppChangedFlag
  1753. if { $corFlag ==0 } {
  1754. ## puts [lindex $dieleData [expr { $startpoint }]]
  1755. .c coords [lindex $dieleData [expr { $startpoint }]] \
  1756. [expr { ($dielex-$pbottomleftX)*$Xscale }] \
  1757. [expr { $maxYcoord-($dieley-$pbottomleftY)*$Yscale }] \
  1758. [expr { ($dielex+$dielew-$pbottomleftX)*$Xscale }] \
  1759. [expr { $maxYcoord-($dieley+$dieleh-$pbottomleftY)*$Yscale }]
  1760. set dieleData [lreplace $dieleData [expr { $startpoint+2 }] [expr { $startpoint+2 }] \
  1761. $dielex]
  1762. set dieleData [lreplace $dieleData [expr { $startpoint+3 }] [expr { $startpoint+3 }] \
  1763. $dieley]
  1764. set dieleData [lreplace $dieleData [expr { $startpoint+4 }] [expr { $startpoint+4 }] \
  1765. $dielew]
  1766. set dieleData [lreplace $dieleData [expr { $startpoint+5 }] [expr { $startpoint+5 }] \
  1767. $dieleh]
  1768. set dieleData [lreplace $dieleData [expr { $startpoint+6 }] [expr { $startpoint+6 }] \
  1769. $dielepermit]
  1770. set dieleData [lreplace $dieleData [expr { $startpoint+7 }] [expr { $startpoint+7 }] \
  1771. $dielepermea]
  1772. ## puts $dieleData
  1773. } else {
  1774. incr dieleCounter
  1775. set diele [.c create rectangle [expr { ($dielex-$pbottomleftX)*$Xscale }] \
  1776. [expr { $maxYcoord-($dieley-$pbottomleftY)*$Yscale }] \
  1777. [expr { ($dielex+$dielew-$pbottomleftX)*$Xscale }] \
  1778. [expr { $maxYcoord-($dieley+$dieleh-$pbottomleftY)*$Yscale }] \
  1779. -outline black -fill black -tags dieleTags$dieleCounter]
  1780. lappend dieleId $diele
  1781. lappend dieleTags dieleTags$dieleCounter
  1782. set fileHead [lreplace $fileHead 0 0 [expr { [lindex $fileHead 0]+1 }]]
  1783. ## puts $fileHead
  1784. lappend dieleData "DIELE"
  1785. lappend dieleData $diele
  1786. lappend dieleData dieleTags$dieleCounter
  1787. lappend dieleData $dieleCounter
  1788. lappend dieleData $dielex
  1789. lappend dieleData $dieley
  1790. lappend dieleData $dielew
  1791. lappend dieleData $dieleh
  1792. lappend dieleData $dielepermit
  1793. lappend dieleData $dielepermea
  1794. set myAppChangedFlag 1
  1795. ## puts $dieleData
  1796. ## puts $dieleCounter
  1797. ## puts $dieleId
  1798. ## puts $dieleTags
  1799. }
  1800. }
  1801. proc dispEll { w title startpoint } {
  1802. global palFlag corFlag newFlag
  1803. global ellData
  1804. global ellcenterX ellcenterY ellMajor ellMinor ellCond
  1805. global startpoint1
  1806. checkPal
  1807. if { $palFlag < 0 } {
  1808. return $palFlag
  1809. }
  1810. if { $newFlag < 0 } {
  1811. promptInfo "You must setup a new palette first!"
  1812. return $newFlag
  1813. }
  1814. toplevel $w -class Dialog
  1815. wm title $w $title
  1816. wm iconname $w Dialog
  1817. frame $w.top -relief raised -bd 1
  1818. pack $w.top -side top -fill both
  1819. frame $w.bot -relief raised -bd 1
  1820. pack $w.bot -side bottom -fill both
  1821. grid [label $w.top.lab1 -text "Center X Coord"] \
  1822. [entry $w.top.ent1 -textvariable ellcenterX] -sticky e
  1823. grid [label $w.top.lab2 -text "Center Y Coord"] \
  1824. [entry $w.top.ent2 -textvariable ellcenterY] -sticky e
  1825. grid [label $w.top.lab3 -text "X Axis Length"] \
  1826. [entry $w.top.ent3 -textvariable ellMajor] -sticky e
  1827. grid [label $w.top.lab4 -text "Y Axis Length"] \
  1828. [entry $w.top.ent4 -textvariable ellMinor] -sticky e
  1829. grid [label $w.top.lab5 -text "Conductivity"] \
  1830. [entry $w.top.ent5 -textvariable ellCond] -sticky e
  1831. if { $corFlag == 0 } {
  1832. set ellcenterX [lindex $ellData [expr { $startpoint+2 }]]
  1833. set ellcenterY [lindex $ellData [expr { $startpoint+3 }]]
  1834. set ellMajor [lindex $ellData [expr { $startpoint+4 }]]
  1835. set ellMinor [lindex $ellData [expr { $startpoint+5 }]]
  1836. set ellCond [lindex $ellData [expr { $startpoint+6 }]]
  1837. }
  1838. set startpoint1 $startpoint
  1839. button $w.bot.buttonok -text "OK" -command {
  1840. if { $corFlag == -1 } {
  1841. ellOk $ellcenterX $ellcenterY $ellMajor $ellMinor $ellCond {}
  1842. destroy .ellPara
  1843. } else {
  1844. ellOk $ellcenterX $ellcenterY $ellMajor $ellMinor $ellCond $startpoint1
  1845. destroy .ellPara
  1846. }
  1847. }
  1848. button $w.bot.buttoncancel -text "CANCEL" -command { destroy .ellPara }
  1849. pack $w.bot.buttonok $w.bot.buttoncancel -side left -fill both
  1850. }
  1851. proc ellOk { ellx elly ellma ellmi ellc startpoint } {
  1852. global ellCounter ellId ellTags
  1853. global Xscale Yscale
  1854. global maxYcoord
  1855. global fileHead ellData
  1856. global pbottomleftX pbottomleftY
  1857. global corFlag
  1858. global myAppChangedFlag
  1859. if { $corFlag ==0 } {
  1860. ## puts [lindex $ellData [expr { $startpoint }]]
  1861. .c coords [lindex $ellData [expr { $startpoint }]] \
  1862. [expr { ($ellx-$ellma-$pbottomleftX)*$Xscale }] \
  1863. [expr { $maxYcoord-($elly-$ellmi-$pbottomleftY)*$Yscale }] \
  1864. [expr { ($ellx+$ellma-$pbottomleftX)*$Xscale }] \
  1865. [expr { $maxYcoord-($elly+$ellmi-$pbottomleftY)*$Yscale }]
  1866. set ellData [lreplace $ellData [expr { $startpoint+2 }] [expr { $startpoint+2 }] \
  1867. $ellx]
  1868. set ellData [lreplace $ellData [expr { $startpoint+3 }] [expr { $startpoint+3 }] \
  1869. $elly]
  1870. set ellData [lreplace $ellData [expr { $startpoint+4 }] [expr { $startpoint+4 }] \
  1871. $ellma]
  1872. set ellData [lreplace $ellData [expr { $startpoint+5 }] [expr { $startpoint+5 }] \
  1873. $ellmi]
  1874. set ellData [lreplace $ellData [expr { $startpoint+6 }] [expr { $startpoint+6 }] \
  1875. $ellc]
  1876. ## puts $ellData
  1877. } else {
  1878. incr ellCounter
  1879. set ell [.c create oval [expr { ($ellx-$ellma-$pbottomleftX)*$Xscale }] \
  1880. [expr { $maxYcoord-($elly-$ellmi-$pbottomleftY)*$Yscale }] \
  1881. [expr { ($ellx+$ellma-$pbottomleftX)*$Xscale }] \
  1882. [expr { $maxYcoord-($elly+$ellmi-$pbottomleftY)*$Yscale }] \
  1883. -outline black -fill white -tags ellTags$ellCounter]
  1884. lappend ellId $ell
  1885. lappend ellTags ellTags$ellCounter
  1886. set fileHead [lreplace $fileHead 4 4 [expr { [lindex $fileHead 4]+1 }]]
  1887. ## puts $fileHead
  1888. lappend ellData "ELL"
  1889. lappend ellData $ell
  1890. lappend ellData ellTags$ellCounter
  1891. lappend ellData $ellCounter
  1892. lappend ellData $ellx
  1893. lappend ellData $elly
  1894. lappend ellData $ellma
  1895. lappend ellData $ellmi
  1896. lappend ellData $ellc
  1897. set myAppChangedFlag 1
  1898. ## puts $ellData
  1899. ## puts $ellCounter
  1900. ## puts $ellId
  1901. ## puts $ellTags
  1902. }
  1903. }
  1904. proc dispTri { w title startpoint } {
  1905. global palFlag corFlag newFlag
  1906. global triData
  1907. global triapex1X triapex1Y triapex2X triapex2Y triapex3X triapex3Y triCond
  1908. global startpoint1
  1909. checkPal
  1910. if { $palFlag < 0 } {
  1911. return $palFlag
  1912. }
  1913. if { $newFlag < 0 } {
  1914. promptInfo "You must setup a new palette first!"
  1915. return $newFlag
  1916. }
  1917. toplevel $w -class Dialog
  1918. wm title $w $title
  1919. wm iconname $w Dialog
  1920. frame $w.top -relief raised -bd 1
  1921. pack $w.top -side top -fill both
  1922. frame $w.bot -relief raised -bd 1
  1923. pack $w.bot -side bottom -fill both
  1924. grid [label $w.top.lab1 -text "Apex 1 X Coord"] \
  1925. [entry $w.top.ent1 -textvariable triapex1X] -sticky e
  1926. grid [label $w.top.lab2 -text "Apex 1 Y Coord"] \
  1927. [entry $w.top.ent2 -textvariable triapex1Y] -sticky e
  1928. grid [label $w.top.lab3 -text "Apex 2 X Coord"] \
  1929. [entry $w.top.ent3 -textvariable triapex2X] -sticky e
  1930. grid [label $w.top.lab4 -text "Apex 2 Y Coord"] \
  1931. [entry $w.top.ent4 -textvariable triapex2Y] -sticky e
  1932. grid [label $w.top.lab5 -text "Apex 3 X Coord"] \
  1933. [entry $w.top.ent5 -textvariable triapex3X] -sticky e
  1934. grid [label $w.top.lab6 -text "Apex 3 Y Coord"] \
  1935. [entry $w.top.ent6 -textvariable triapex3Y] -sticky e
  1936. grid [label $w.top.lab7 -text "Conductivity"] \
  1937. [entry $w.top.ent7 -textvariable triCond] -sticky e
  1938. if { $corFlag == 0 } {
  1939. set triapex1X [lindex $triData [expr { $startpoint+2 }]]
  1940. set triapex1Y [lindex $triData [expr { $startpoint+3 }]]
  1941. set triapex2X [lindex $triData [expr { $startpoint+4 }]]
  1942. set triapex2Y [lindex $triData [expr { $startpoint+5 }]]
  1943. set triapex3X [lindex $triData [expr { $startpoint+6 }]]
  1944. set triapex3Y [lindex $triData [expr { $startpoint+7 }]]
  1945. set triCond [lindex $triData [expr { $startpoint+8 }]]
  1946. }
  1947. set startpoint1 $startpoint
  1948. button $w.bot.buttonok -text "OK" -command {
  1949. if { $corFlag == -1 } {
  1950. triOk $triapex1X $triapex1Y $triapex2X $triapex2Y $triapex3X $triapex3Y $triCond {}
  1951. destroy .triPara
  1952. } else {
  1953. triOk $triapex1X $triapex1Y $triapex2X $triapex2Y $triapex3X $triapex3Y $triCond \
  1954. $startpoint1
  1955. destroy .triPara
  1956. }
  1957. }
  1958. button $w.bot.buttoncancel -text "CANCEL" -command { destroy .triPara }
  1959. pack $w.bot.buttonok $w.bot.buttoncancel -side left -fill both
  1960. }
  1961. proc triOk { tri1x tri1y tri2x tri2y tri3x tri3y tric startpoint } {
  1962. global triCounter triId triTags
  1963. global Xscale Yscale
  1964. global maxYcoord
  1965. global fileHead triData
  1966. global pbottomleftX pbottomleftY
  1967. global corFlag
  1968. global myAppChangedFlag
  1969. if { $corFlag ==0 } {
  1970. ## puts [lindex $triData [expr { $startpoint }]]
  1971. .c coords [lindex $triData [expr { $startpoint }]] \
  1972. [expr { ($tri1x-$pbottomleftX)*$Xscale }] \
  1973. [expr { $maxYcoord-($tri1y-$pbottomleftY)*$Yscale }] \
  1974. [expr { ($tri2x-$pbottomleftX)*$Xscale }] \
  1975. [expr { $maxYcoord-($tri2y-$pbottomleftY)*$Yscale }] \
  1976. [expr { ($tri3x-$pbottomleftX)*$Xscale }] \
  1977. [expr { $maxYcoord-($tri3y-$pbottomleftY)*$Yscale }]
  1978. set triData [lreplace $triData [expr { $startpoint+2 }] [expr { $startpoint+2 }] \
  1979. $tri1x]
  1980. set triData [lreplace $triData [expr { $startpoint+3 }] [expr { $startpoint+3 }] \
  1981. $tri1y]
  1982. set triData [lreplace $triData [expr { $startpoint+4 }] [expr { $startpoint+4 }] \
  1983. $tri2x]
  1984. set triData [lreplace $triData [expr { $startpoint+5 }] [expr { $startpoint+5 }] \
  1985. $tri2y]
  1986. set triData [lreplace $triData [expr { $startpoint+6 }] [expr { $startpoint+6 }] \
  1987. $tri3x]
  1988. set triData [lreplace $triData [expr { $startpoint+7 }] [expr { $startpoint+7 }] \
  1989. $tri3y]
  1990. set triData [lreplace $triData [expr { $startpoint+8 }] [expr { $startpoint+8 }] \
  1991. $tric]
  1992. ## puts $triData
  1993. } else {
  1994. incr triCounter
  1995. set tri [.c create polygon [expr { ($tri1x-$pbottomleftX)*$Xscale }] \
  1996. [expr { $maxYcoord-($tri1y-$pbottomleftY)*$Yscale }] \
  1997. [expr { ($tri2x-$pbottomleftX)*$Xscale }] \
  1998. [expr { $maxYcoord-($tri2y-$pbottomleftY)*$Yscale }] \
  1999. [expr { ($tri3x-$pbottomleftX)*$Xscale }] \
  2000. [expr { $maxYcoord-($tri3y-$pbottomleftY)*$Yscale }] \
  2001. -outline black -fill white -tags triTags$triCounter]
  2002. lappend triId $tri
  2003. lappend triTags triTags$triCounter
  2004. set fileHead [lreplace $fileHead 3 3 [expr { [lindex $fileHead 3]+1 }]]
  2005. ## puts $fileHead
  2006. lappend triData "TRI"
  2007. lappend triData $tri
  2008. lappend triData triTags$triCounter
  2009. lappend triData $triCounter
  2010. lappend triData $tri1x
  2011. lappend triData $tri1y
  2012. lappend triData $tri2x
  2013. lappend triData $tri2y
  2014. lappend triData $tri3x
  2015. lappend triData $tri3y
  2016. lappend triData $tric
  2017. set myAppChangedFlag 1
  2018. ## puts $triData
  2019. ## puts $triCounter
  2020. ## puts $triId
  2021. ## puts $triTags
  2022. }
  2023. }
  2024. #####################
  2025. # Get the apexnumber of polygons
  2026. #
  2027. #####################
  2028. proc getApexnumdrop { } {
  2029. global apexnum
  2030. set apexnum 4
  2031. return $apexnum
  2032. }
  2033. proc getApexnum { } {
  2034. global apexnum
  2035. set apexnum1 4
  2036. dispPoly .polyPara { Polygon Conductor Parameters } $apexnum1 {}
  2037. return $apexnum1
  2038. }
  2039. proc dispPoly { w title apexnum startpoint } {
  2040. global palFlag corFlag newFlag
  2041. global pbottomleftX pbottomleftY
  2042. global startpoint1
  2043. global polyCounter polyId polyTags
  2044. global Xscale Yscale
  2045. global maxYcoord
  2046. global apexpoly
  2047. global polyData
  2048. global polyapexX1 polyapexY1 polyapexX2 polyapexY2 polyapexX3 polyapexY3
  2049. global polyapexX4 polyapexY4 polyapexX5 polyapexY5 polyapexX6 polyapexY6
  2050. global polyapexX7 polyapexY7 polyapexX8 polyapexY8 polyapexX9 polyapexY9
  2051. global polyapexX10 polyapexY10 polyapexX11 polyapexY11 polyapexX12 polyapexY12
  2052. global polyapexX13 polyapexY13 polyapexX14 polyapexY14 polyapexX15 polyapexY15
  2053. global polyapexX16 polyapexY16 polyapexX17 polyapexY17 polyapexX18 polyapexY18
  2054. global polyapexX19 polyapexY19 polyapexX20 polyapexY20
  2055. global polyCond
  2056. checkPal
  2057. if { $palFlag < 0 } {
  2058. return $palFlag
  2059. }
  2060. if { $newFlag < 0 } {
  2061. promptInfo "You must setup a new palette first!"
  2062. return $newFlag
  2063. }
  2064. set counter 1
  2065. set polyapexlist {}
  2066. set apexpoly $apexnum
  2067. toplevel $w -class Dialog
  2068. wm title $w $title
  2069. wm iconname $w Dialog
  2070. frame $w.top -relief raised -bd 1
  2071. pack $w.top -side top -fill both
  2072. frame $w.bot -relief raised -bd 1
  2073. pack $w.bot -side bottom -fill both
  2074. while { $counter <= $apexnum } {
  2075. global polyapexX polyapexY
  2076. ## puts $counter
  2077. grid [label $w.top.lab[expr { 2*$counter }] -text "Apex$counter X Coord"] \
  2078. [entry $w.top.ent[expr { 2*$counter }] -textvariable polyapexX($counter)] \
  2079. -sticky e
  2080. grid [label $w.top.lab[expr { 2*$counter+1 }] -text "Apex$counter Y Coord"] \
  2081. [entry $w.top.ent[expr { 2*$counter+1 }] -textvariable polyapexY($counter)] -sticky e
  2082. incr counter
  2083. }
  2084. grid [checkbutton $w.top.but1 -text current -variable polyCond -anchor w] -sticky e
  2085. if { $corFlag == 0 } {
  2086. for {set counter 1} {$counter<=$apexnum} {incr counter} {
  2087. set polyapexX($counter) [lindex $polyData [expr { $startpoint+2*$counter+1 }]]
  2088. set polyapexY($counter) [lindex $polyData [expr { $startpoint+2*$counter+2 }]]
  2089. }
  2090. set polyCond [lindex $polyData [expr { $startpoint+2*$counter+1 }]]
  2091. }
  2092. set startpoint1 $startpoint
  2093. button $w.bot.buttonok -text "OK" -command {
  2094. set polyapexlist [expr { ($polyapexX(1)-$pbottomleftX)*$Xscale }]
  2095. lappend polyapexlist [expr { $maxYcoord-($polyapexY(1)-$pbottomleftY)*$Yscale }]
  2096. for {set counter 2} {$counter<=$apexpoly} {incr counter} {
  2097. lappend polyapexlist [expr { ($polyapexX($counter)-$pbottomleftX)*$Xscale }]
  2098. lappend polyapexlist [expr { $maxYcoord-($polyapexY($counter)-$pbottomleftY)*$Yscale }]
  2099. }
  2100. ## puts $polyapexlist
  2101. if { $corFlag == -1 } {
  2102. polyOk $polyapexlist $polyCond {}
  2103. } else {
  2104. polyOk $polyapexlist $polyCond $startpoint1
  2105. }
  2106. destroy .polyPara
  2107. }
  2108. button $w.bot.buttoncancel -text "CANCEL" -command { destroy .polyPara }
  2109. pack $w.bot.buttonok $w.bot.buttoncancel -side left -fill both
  2110. }
  2111. proc polyOk { polyapexlist polyc startpoint } {
  2112. global polyCounter polyId polyTags
  2113. global Xscale Yscale
  2114. global fileHead polyData
  2115. global paletteYsize
  2116. global pbottomleftX pbottomleftY
  2117. global maxYcoord
  2118. global corFlag
  2119. global myAppChangedFlag
  2120. if { $corFlag ==0 } {
  2121. ## puts [lindex $polyData [expr { $startpoint }]]
  2122. .c coords [lindex $polyData [expr { $startpoint }]] $polyapexlist
  2123. for {set i 0} {$i < [expr { [llength $polyapexlist]/2 }]} {incr i} {
  2124. set polyData [lreplace $polyData [expr { $startpoint+3+2*$i }] \
  2125. [expr { $startpoint+3+2*$i }] \
  2126. [expr { [lindex $polyapexlist [expr { 2*$i }]]/$Xscale+$pbottomleftX }]]
  2127. set polyData [lreplace $polyData [expr { $startpoint+4+2*$i }] \
  2128. [expr { $startpoint+4+2*$i }] \
  2129. [expr { ($maxYcoord-[lindex $polyapexlist \
  2130. [expr { 2*$i+1 }]])/$Yscale+$pbottomleftY }]]
  2131. }
  2132. set polyData [lreplace $polyData [expr { $startpoint+3+2*$i }] [expr { $startpoint+4+2*$i }] \
  2133. $polyc]
  2134. ## puts $polyData
  2135. } else {
  2136. incr polyCounter
  2137. set poly [.c create polygon $polyapexlist \
  2138. -outline black -fill blue -tags polyTags$polyCounter]
  2139. lappend polyId $poly
  2140. lappend polyTags polyTags$polyCounter
  2141. set fileHead [lreplace $fileHead 5 5 [expr { [lindex $fileHead 5]+1 }]]
  2142. ## puts $fileHead
  2143. lappend polyData "POLY"
  2144. lappend polyData $poly
  2145. lappend polyData polyTags$polyCounter
  2146. lappend polyData $polyCounter
  2147. lappend polyData [expr { [llength $polyapexlist]/2 }]
  2148. ## puts [llength $polyapexlist]
  2149. for {set i 0} {$i < [expr { [llength $polyapexlist]/2 }]} {incr i} {
  2150. lappend polyData [expr { [lindex $polyapexlist [expr { 2*$i }]]/$Xscale+$pbottomleftX }]
  2151. lappend polyData [expr { ($maxYcoord-[lindex $polyapexlist \
  2152. [expr { 2*$i+1 }]])/$Yscale+$pbottomleftY }]
  2153. }
  2154. lappend polyData $polyc
  2155. set myAppChangedFlag 1
  2156. ## puts $polyData
  2157. ## puts $polyCounter
  2158. ## puts $polyId
  2159. ## puts $polyTags
  2160. }
  2161. }
  2162. proc dispGnd { w title startpoint } {
  2163. global palFlag corFlag newFlag
  2164. global gndX gndY gndWidth gndHeight gndCond
  2165. global gndData
  2166. global startpoint1
  2167. checkPal
  2168. if { $palFlag < 0 } {
  2169. return $palFlag
  2170. }
  2171. if { $newFlag < 0 } {
  2172. promptInfo "You must setup a new palette first!"
  2173. return $newFlag
  2174. }
  2175. toplevel $w -class Dialog
  2176. wm title $w $title
  2177. wm iconname $w Dialog
  2178. frame $w.top -relief raised -bd 1
  2179. pack $w.top -side top -fill both
  2180. frame $w.bot -relief raised -bd 1
  2181. pack $w.bot -side bottom -fill both
  2182. grid [label $w.top.lab1 -text "LowerLeft X Coord"] \
  2183. [entry $w.top.ent1 -textvariable gndX] -sticky e
  2184. grid [label $w.top.lab2 -text "LowerLeft Y Coord"] \
  2185. [entry $w.top.ent2 -textvariable gndY] -sticky e
  2186. grid [label $w.top.lab3 -text "Width"] \
  2187. [entry $w.top.ent3 -textvariable gndWidth] -sticky e
  2188. grid [label $w.top.lab4 -text "Height"] \
  2189. [entry $w.top.ent4 -textvariable gndHeight] -sticky e
  2190. grid [checkbutton $w.top.but1 -text current -variable gndCond -anchor w] -sticky e
  2191. if { $corFlag == 0 } {
  2192. set gndX [lindex $gndData [expr { $startpoint+2 }]]
  2193. set gndY [lindex $gndData [expr { $startpoint+3 }]]
  2194. set gndWidth [lindex $gndData [expr { $startpoint+4 }]]
  2195. set gndHeight [lindex $gndData [expr { $startpoint+5 }]]
  2196. set gndCond [lindex $gndData [expr { $startpoint+6 }]]
  2197. }
  2198. set startpoint1 $startpoint
  2199. button $w.bot.buttonok -text "OK" -command {
  2200. if { $corFlag == -1 } {
  2201. gndOk $gndX $gndY $gndWidth $gndHeight $gndCond {}
  2202. destroy .gndPara
  2203. } else {
  2204. gndOk $gndX $gndY $gndWidth $gndHeight $gndCond $startpoint1
  2205. destroy .gndPara
  2206. }
  2207. }
  2208. button $w.bot.buttoncancel -text "CANCEL" -command { destroy .gndPara }
  2209. pack $w.bot.buttonok $w.bot.buttoncancel -side left -fill both
  2210. }
  2211. proc gndOk { gndx gndy gndw gndh gndc startpoint } {
  2212. global gndCounter gndId gndTags
  2213. global Xscale Yscale
  2214. global maxYcoord
  2215. global fileHead gndData
  2216. global pbottomleftX pbottomleftY
  2217. global corFlag
  2218. global myAppChangedFlag
  2219. if { $corFlag ==0 } {
  2220. ## puts [lindex $gndData [expr { $startpoint }]]
  2221. .c coords [lindex $gndData [expr { $startpoint }]] \
  2222. [expr { ($gndx-$pbottomleftX)*$Xscale }] \
  2223. [expr { $maxYcoord-($gndy-$pbottomleftY)*$Yscale }] \
  2224. [expr { ($gndx+$gndw-$pbottomleftX)*$Xscale }] \
  2225. [expr { $maxYcoord-($gndy+$gndh-$pbottomleftY)*$Yscale }]
  2226. set gndData [lreplace $gndData [expr { $startpoint+2 }] [expr { $startpoint+2 }] \
  2227. $gndx]
  2228. set gndData [lreplace $gndData [expr { $startpoint+3 }] [expr { $startpoint+3 }] \
  2229. $gndy]
  2230. set gndData [lreplace $gndData [expr { $startpoint+4 }] [expr { $startpoint+4 }] \
  2231. $gndw]
  2232. set gndData [lreplace $gndData [expr { $startpoint+5 }] [expr { $startpoint+5 }] \
  2233. $gndh]
  2234. set gndData [lreplace $gndData [expr { $startpoint+6 }] [expr { $startpoint+6 }] \
  2235. $gndc]
  2236. ## puts $gndData
  2237. } else {
  2238. incr gndCounter
  2239. ## puts $Xscale
  2240. ## puts $Yscale
  2241. set gnd [.c create rectangle [expr { ($gndx-$pbottomleftX)*$Xscale }] \
  2242. [expr { $maxYcoord-($gndy-$pbottomleftY)*$Yscale }] \
  2243. [expr { ($gndx+$gndw-$pbottomleftX)*$Xscale }] \
  2244. [expr { $maxYcoord-($gndy+$gndh-$pbottomleftY)*$Yscale }] \
  2245. -outline black -fill green -tags gndTags$gndCounter]
  2246. lappend gndId $gnd
  2247. lappend gndTags gndTags$gndCounter
  2248. set fileHead [lreplace $fileHead 6 6 [expr { [lindex $fileHead 6]+1 }]]
  2249. ## puts $fileHead
  2250. lappend gndData "GND"
  2251. lappend gndData $gnd
  2252. lappend gndData gndTags$gndCounter
  2253. lappend gndData $gndCounter
  2254. lappend gndData $gndx
  2255. lappend gndData $gndy
  2256. lappend gndData $gndw
  2257. lappend gndData $gndh
  2258. lappend gndData $gndc
  2259. set myAppChangedFlag 1
  2260. ## puts $gndData
  2261. ## puts $gndCounter
  2262. ## puts $gndId
  2263. ## puts $gndTags
  2264. }
  2265. }
  2266. ########################################################################################
  2267. # Edit the parameters of the palette
  2268. ########################################################################################
  2269. proc Coption { w title flag } {
  2270. global paletteXsize paletteYsize Xscale Yscale
  2271. global pbottomleftX pbottomleftY
  2272. global tempdata1 tempdata2 tempdata3 tempdata4
  2273. global newFlag
  2274. if { $newFlag < 0 && $flag == 0 } {
  2275. promptInfo "You must setup a new palette first!"
  2276. return $newFlag
  2277. }
  2278. toplevel $w -class Dialog
  2279. wm title $w $title
  2280. wm iconname $w Dialog
  2281. frame $w.top -relief raised -bd 1
  2282. pack $w.top -side top -fill both
  2283. frame $w.bot -relief raised -bd 1
  2284. pack $w.bot -side bottom -fill both
  2285. set tempdata1 $paletteXsize
  2286. set tempdata2 $paletteYsize
  2287. set tempdata3 $pbottomleftX
  2288. set tempdata4 $pbottomleftY
  2289. # grid [label $w.top.lab1 -text "Palette X Size"] \
  2290. \# [entry $w.top.ent1 -textvariable paletteXsize] \
  2291. \# [label $w.top.lab2 -text "m"] -sticky e
  2292. # grid [label $w.top.lab3 -text "Palette Y Size"] \
  2293. \# [entry $w.top.ent2 -textvariable paletteYsize] \
  2294. \# [label $w.top.lab4 -text "m"] -sticky e
  2295. grid [label $w.top.lab3 -text "Palette Size"] \
  2296. [entry $w.top.ent2 -textvariable paletteXsize] \
  2297. [label $w.top.lab4 -text "m"] -sticky e
  2298. grid [label $w.top.lab5 -text "Palette Bottomleft X Coord"] \
  2299. [entry $w.top.ent3 -textvariable pbottomleftX] -sticky e
  2300. grid [label $w.top.lab6 -text "Palette Bottomleft Y Coord"] \
  2301. [entry $w.top.ent4 -textvariable pbottomleftY] -sticky e
  2302. # grid [label $w.top.lab5 -text ""] \
  2303. [entry $w.top.ent5 -textvariable ] -sticky e
  2304. # grid [label $w.top.lab6 -text ""] \
  2305. [entry $w.top.ent6 -textvariable ] -sticky e
  2306. # grid [label $w.top.lab7 -text ""] \
  2307. [entry $w.top.ent7 -textvariable ] -sticky e
  2308. button $w.bot.buttonok -text "OK" -command {
  2309. set paletteYsize [expr { $paletteXsize/$maxXcoord*$maxYcoord }]
  2310. destroy .palettePara
  2311. optionOk
  2312. }
  2313. button $w.bot.buttoncancel -text "CANCEL" -command {
  2314. destroy .palettePara
  2315. set paletteXsize $tempdata1
  2316. set paletteYsize $tempdata2
  2317. set pbottomleftX $tempdata3
  2318. set pbottomleftY $tempdata4
  2319. }
  2320. pack $w.bot.buttonok $w.bot.buttoncancel -side left -fill both
  2321. }
  2322. proc optionOk { } {
  2323. global maxXcoord maxYcoord
  2324. global paletteXsize paletteYsize Xscale Yscale
  2325. global pbottomleftX pbottomleftY
  2326. global palFlag
  2327. global myAppChangedFlag
  2328. if { $paletteXsize > 0 && $paletteYsize > 0 } {
  2329. set Xscale [ expr { $maxXcoord/$paletteXsize }]
  2330. ## puts "begin"
  2331. ## puts $maxXcoord
  2332. ## puts $paletteXsize
  2333. ## puts $Xscale
  2334. ## puts "end"
  2335. set Yscale [ expr { $maxYcoord/$paletteYsize }]
  2336. set palFlag 0
  2337. ## puts "OK"
  2338. }
  2339. }
  2340. proc calpara { w title } {
  2341. global paletteXsize paletteYsize Xscale Yscale
  2342. global pbottomleftX pbottomleftY
  2343. global tempdata1 tempdata2 tempdata3 tempdata4
  2344. global tempdata5 tempdata6 tempdata7 tempdata8
  2345. global tempdata9 tempdata10 tempdata11 tempdata12
  2346. global newFlag
  2347. global Nh Nit J
  2348. global Nwx Nwy Nws
  2349. global Np Eps matr
  2350. global freq sigma
  2351. global myAppChangedFlag
  2352. if { $newFlag < 0 } {
  2353. promptInfo "You must setup a new palette first!"
  2354. return $newFlag
  2355. }
  2356. toplevel $w -class Dialog
  2357. wm title $w $title
  2358. wm iconname $w Dialog
  2359. frame $w.top -relief raised -bd 1
  2360. pack $w.top -side top -fill both
  2361. frame $w.bot -relief raised -bd 1
  2362. pack $w.bot -side bottom -fill both
  2363. set tempdata1 $Nh
  2364. set tempdata2 $Nit
  2365. set tempdata3 $J
  2366. set tempdata4 $Nwx
  2367. set tempdata5 $Nwy
  2368. set tempdata6 $Nws
  2369. set tempdata7 $Np
  2370. set tempdata8 $Eps
  2371. set tempdata9 $matr
  2372. set tempdata10 $freq
  2373. set tempdata11 $sigma
  2374. grid [label $w.top.lab3 -text "Wavelet Point Number"] \
  2375. [entry $w.top.ent2 -textvariable Nh] -sticky e
  2376. grid [label $w.top.lab4 -text "Number of Iteration"] \
  2377. [entry $w.top.ent3 -textvariable Nit] -sticky e
  2378. grid [label $w.top.lab5 -text "Resolution Level"] \
  2379. [entry $w.top.ent4 -textvariable J] -sticky e
  2380. grid [label $w.top.lab6 -text "Gauss Quadrature X"] \
  2381. [entry $w.top.ent5 -textvariable Nwx] -sticky e
  2382. grid [label $w.top.lab7 -text "Gauss Quadrature Y"] \
  2383. [entry $w.top.ent6 -textvariable Nwy] -sticky e
  2384. grid [label $w.top.lab8 -text "Number of Segments/Wavelet"] \
  2385. [entry $w.top.ent7 -textvariable Nws] -sticky e
  2386. grid [label $w.top.lab9 -text "OPQ Seperation"] \
  2387. [entry $w.top.ent8 -textvariable Np] -sticky e
  2388. grid [label $w.top.lab10 -text "STAB Accuracy"] \
  2389. [entry $w.top.ent9 -textvariable Eps] -sticky e
  2390. grid [label $w.top.lab11 -text "Matrix Solution"] \
  2391. [entry $w.top.ent10 -textvariable matr] -sticky e
  2392. grid [label $w.top.lab12 -text "Frequency(Hz)"] \
  2393. [entry $w.top.ent11 -textvariable freq] -sticky e
  2394. grid [label $w.top.lab13 -text "Conductivity(S/m)"] \
  2395. [entry $w.top.ent12 -textvariable sigma] -sticky e
  2396. button $w.bot.buttonok -text "OK" -command {
  2397. set myAppChangedFlag 1
  2398. destroy .calPara
  2399. }
  2400. button $w.bot.buttoncancel -text "CANCEL" -command {
  2401. destroy .calPara
  2402. set Nh $tempdata1
  2403. set Nit $tempdata2
  2404. set J $tempdata3
  2405. set Nwx $tempdata4
  2406. set Nwy $tempdata5
  2407. set Nws $tempdata6
  2408. set Np $tempdata7
  2409. set Eps $tempdata8
  2410. set matr $tempdata9
  2411. set freq $tempdata10
  2412. set sigma $tempdata11
  2413. }
  2414. pack $w.bot.buttonok $w.bot.buttoncancel -side left -fill both
  2415. }
  2416. ########################################################################################
  2417. # Check if the palette parameters have been setup
  2418. ########################################################################################
  2419. proc checkPal { } {
  2420. global maxXcoord maxYcoord
  2421. global paletteXsize paletteYsize Xscale Yscale
  2422. global pbottomleftX pbottomleftY
  2423. global palFlag
  2424. if { $paletteXsize > 0 && $paletteYsize > 0 } {
  2425. set palFlag 0
  2426. } else {
  2427. set palFlag -1
  2428. toplevel .prompted -class Dialog
  2429. wm title .prompted "error"
  2430. wm iconname .prompted Dialog
  2431. frame .prompted.top -relief raised -bd 1
  2432. pack .prompted.top -side top -fill both
  2433. message .prompted.msg -width 8c -justify left -relief flat -bd 2 \
  2434. -text "You must input the palette parameters first."
  2435. button .prompted.okbutton -text "OK" -command { destroy .prompted }
  2436. pack .prompted.msg .prompted.okbutton -side top -padx 2m -pady 2m
  2437. }
  2438. return $palFlag
  2439. }
  2440. proc promptInfo { message } {
  2441. toplevel .prompted -class Dialog
  2442. wm title .prompted "Info"
  2443. wm iconname .prompted Dialog
  2444. frame .prompted.top -relief raised -bd 1
  2445. pack .prompted.top -side top -fill both
  2446. message .prompted.msg -width 8c -justify left -relief flat -bd 2 \
  2447. -text $message
  2448. button .prompted.okbutton -text "OK" -command { destroy .prompted }
  2449. pack .prompted.msg .prompted.okbutton -side top -padx 2m -pady 2m
  2450. }
  2451. ########################################################################################
  2452. # Update data package after deleting and adding new components
  2453. ########################################################################################
  2454. proc updateData { } {
  2455. }
  2456. ########################################################################################
  2457. #--------------------------------------------------
  2458. #
  2459. # File Procedures
  2460. #
  2461. # Note that opening, saving, and closing files
  2462. # are all intertwined. This code assumes that
  2463. # new/open/close/exit may lose some data.
  2464. #
  2465. #--------------------------------------------------
  2466. set myAppFileName ""
  2467. set myAppChangedFlag 0
  2468. set myAppFileTypes {
  2469. {{data files} {.dat} }
  2470. {{tcl files} {.tcl .tk} }
  2471. {{text files} {.txt} }
  2472. {{All Files} * }
  2473. }
  2474. proc myAppFileNew { } {
  2475. global myAppFileName
  2476. global myAppFileTypes
  2477. global myAppChangedFlag
  2478. global newFlag
  2479. global palFlag
  2480. global paletteXsize paletteYsize
  2481. myAppFileClose
  2482. set filename [ tk_getSaveFile -filetypes $myAppFileTypes \
  2483. -initialdir "."]
  2484. puts "file: $filename"
  2485. if {$filename != ""} {
  2486. set indx [string first ".dat" $filename]
  2487. if { $indx > -1 } {
  2488. set myAppFileName [string range $filename 0 [expr { ($indx - 1) }]]
  2489. } else {
  2490. set myAppFileName $filename
  2491. }
  2492. }
  2493. Coption .palettePara { Palette Parameters } 1
  2494. tkwait window .palettePara
  2495. if { $palFlag == 0 } {
  2496. initc 0
  2497. .c configure -background gray
  2498. .dummy.statusCon configure -text "Your have setup a new file named $myAppFileName"
  2499. set newFlag 0
  2500. # set myAppFileName ""
  2501. set myAppChangedFlag 0
  2502. }
  2503. puts "new file: $myAppFileName"
  2504. }
  2505. proc myAppFileOpen { {filename ""} } {
  2506. global myAppFileName
  2507. global myAppChangedFlag
  2508. global myAppFileTypes
  2509. global fileHead
  2510. global dieleData recData cirData triData ellData polyData gndData
  2511. global recCounter cirCounter dieleCounter ellCounter triCounter polyCounter \
  2512. gndCounter
  2513. global recTags cirTags dieleTags ellTags triTags polyTags gndTags
  2514. global recId cirId dieleId ellId triId polyId gndId
  2515. global maxXcoord maxYcoord
  2516. global paletteXsize paletteYsize Xscale Yscale
  2517. global pbottomleftX pbottomleftY
  2518. global newFlag
  2519. global Nh Nit J
  2520. global Nwx Nwy Nws
  2521. global Np Eps matr
  2522. global freq sigma
  2523. myAppFileClose
  2524. if {$filename == ""} {
  2525. set filename [tk_getOpenFile -filetypes $myAppFileTypes]
  2526. }
  2527. if {$filename != ""} {
  2528. puts "Opening $filename"
  2529. if { [catch {open $filename r} fp] } {
  2530. error "Cannot Open File $filename for Reading"
  2531. } else {
  2532. set indx [string first ".dat" $filename]
  2533. if { $indx > -1 } {
  2534. set myAppFileName [string range $filename 0 [expr { ($indx - 1) }]]
  2535. } else {
  2536. set myAppFileName $filename
  2537. }
  2538. #--------------------------------------------------
  2539. # insert code for "open" operation
  2540. #--------------------------------------------------
  2541. ### .t insert end [read $fp [file size $filename]]
  2542. # need to read the data, redraw them on the palette and
  2543. # renew the Id number in xxxID and xxxData, renew counter.
  2544. # So just redraw all of them
  2545. set newFlag 0
  2546. .c configure -background gray
  2547. gets $fp paletteXsize
  2548. gets $fp paletteYsize
  2549. gets $fp Xscale
  2550. gets $fp Yscale
  2551. gets $fp pbottomleftX
  2552. gets $fp pbottomleftY
  2553. gets $fp Nh
  2554. gets $fp Nit
  2555. gets $fp J
  2556. gets $fp Nwx
  2557. gets $fp Nwy
  2558. gets $fp Nws
  2559. gets $fp Np
  2560. gets $fp Eps
  2561. gets $fp matr
  2562. gets $fp freq
  2563. gets $fp sigma
  2564. gets $fp tempfileHead
  2565. gets $fp tempdieleData
  2566. gets $fp temprecData
  2567. gets $fp tempcirData
  2568. gets $fp temptriData
  2569. gets $fp tempellData
  2570. gets $fp temppolyData
  2571. gets $fp tempgndData
  2572. set curNum [lindex $tempfileHead 0]
  2573. for {set counter 0} {$counter < $curNum} {incr counter} {
  2574. set corFlag -1
  2575. set dielex [lindex $tempdieleData [expr { $counter*10+4 }]]
  2576. set dieley [lindex $tempdieleData [expr { $counter*10+5 }]]
  2577. set dielew [lindex $tempdieleData [expr { $counter*10+6 }]]
  2578. set dieleh [lindex $tempdieleData [expr { $counter*10+7 }]]
  2579. set dielepermit [lindex $tempdieleData [expr { $counter*10+8 }]]
  2580. set dielepermea [lindex $tempdieleData [expr { $counter*10+9 }]]
  2581. dieleOk $dielex $dieley $dielew $dieleh $dielepermit $dielepermea {}
  2582. }
  2583. set curNum [lindex $tempfileHead 1]
  2584. for {set counter 0} {$counter < $curNum} {incr counter} {
  2585. set corFlag -1
  2586. set recx [lindex $temprecData [expr { $counter*9+4 }]]
  2587. set recy [lindex $temprecData [expr { $counter*9+5 }]]
  2588. set recw [lindex $temprecData [expr { $counter*9+6 }]]
  2589. set rech [lindex $temprecData [expr { $counter*9+7 }]]
  2590. set recc [lindex $temprecData [expr { $counter*9+8 }]]
  2591. rectOk $recx $recy $recw $rech $recc {}
  2592. }
  2593. set curNum [lindex $tempfileHead 2]
  2594. for {set counter 0} {$counter < $curNum} {incr counter} {
  2595. set corFlag -1
  2596. set cirx [lindex $tempcirData [expr { $counter*8+4 }]]
  2597. set ciry [lindex $tempcirData [expr { $counter*8+5 }]]
  2598. set cirr [lindex $tempcirData [expr { $counter*8+6 }]]
  2599. set circ [lindex $tempcirData [expr { $counter*8+7 }]]
  2600. cirOk $cirx $ciry $cirr $circ {}
  2601. }
  2602. set curNum [lindex $tempfileHead 3]
  2603. for {set counter 0} {$counter < $curNum} {incr counter} {
  2604. set corFlag -1
  2605. set tri1x [lindex $temptriData [expr { $counter*11+4 }]]
  2606. set tri1y [lindex $temptriData [expr { $counter*11+5 }]]
  2607. set tri2x [lindex $temptriData [expr { $counter*11+6 }]]
  2608. set tri2y [lindex $temptriData [expr { $counter*11+7 }]]
  2609. set tri3x [lindex $temptriData [expr { $counter*11+8 }]]
  2610. set tri3y [lindex $temptriData [expr { $counter*11+9 }]]
  2611. set tric [lindex $temptriData [expr { $counter*11+10 }]]
  2612. triOk $tri1x $tri1y $tri2x $tri2y $tri3x $tri3y $tric {}
  2613. }
  2614. set curNum [lindex $tempfileHead 4]
  2615. for {set counter 0} {$counter < $curNum} {incr counter} {
  2616. set corFlag -1
  2617. set ellx [lindex $tempellData [expr { $counter*9+4 }]]
  2618. set elly [lindex $tempellData [expr { $counter*9+5 }]]
  2619. set ellma [lindex $tempellData [expr { $counter*9+6 }]]
  2620. set ellmi [lindex $tempellData [expr { $counter*9+7 }]]
  2621. set ellc [lindex $tempellData [expr { $counter*9+8 }]]
  2622. ellOk $ellx $elly $ellma $ellmi $ellc {}
  2623. }
  2624. set curNum [lindex $tempfileHead 5]
  2625. ## puts $temppolyData
  2626. if {$curNum > 0} {
  2627. for {set counter 0} {$counter < $curNum} {incr counter} {
  2628. set corFlag -1
  2629. if { [lsearch $temppolyData POLY] == 0 } {
  2630. ## puts "hhh"
  2631. set tempapexnum [lindex $temppolyData 4]
  2632. ## puts $tempapexnum
  2633. set tempapex {}
  2634. for { set i 1 } { $i <= $tempapexnum } {incr i} {
  2635. lappend tempapex [expr { ([lindex $temppolyData [expr { 3+2*$i }]] \
  2636. -$pbottomleftX)*$Xscale }]
  2637. lappend tempapex [expr { $maxYcoord-([lindex $temppolyData \
  2638. [expr { 4+2*$i }]]-$pbottomleftY)*$Yscale }]
  2639. }
  2640. set polyc [lindex $temppolyData [expr { 5+2*$tempapexnum }]]
  2641. }
  2642. set temppolyData [lreplace $temppolyData 0 [expr { 5+2*$tempapexnum }]]
  2643. ## puts $tempapex
  2644. ## puts $temppolyData
  2645. polyOk $tempapex $polyc {}
  2646. }
  2647. }
  2648. set curNum [lindex $tempfileHead 6]
  2649. for {set counter 0} {$counter < $curNum} {incr counter} {
  2650. set corFlag -1
  2651. set gndx [lindex $tempgndData [expr { $counter*9+4 }]]
  2652. set gndy [lindex $tempgndData [expr { $counter*9+5 }]]
  2653. set gndw [lindex $tempgndData [expr { $counter*9+6 }]]
  2654. set gndh [lindex $tempgndData [expr { $counter*9+7 }]]
  2655. set gndc [lindex $tempgndData [expr { $counter*9+8 }]]
  2656. gndOk $gndx $gndy $gndw $gndh $gndc {}
  2657. }
  2658. }
  2659. close $fp
  2660. # set myAppFileName $filename
  2661. set myAppChangedFlag 0
  2662. }
  2663. }
  2664. proc myAppFileClose { } {
  2665. global myAppFileName
  2666. global myAppChangedFlag
  2667. if { $myAppChangedFlag } {
  2668. myAppPromptForSave
  2669. }
  2670. delall
  2671. initc 1
  2672. .c configure -background black
  2673. #--------------------------------------------------
  2674. # insert code for "close" operation
  2675. #--------------------------------------------------
  2676. ### .t delete 1.0 end
  2677. set myAppFileName ""
  2678. set myAppChangedFlag 0
  2679. }
  2680. proc myAppFileSave { {filename ""} } {
  2681. global myAppFileName
  2682. global myAppFileTypes
  2683. global myAppChangedFlag
  2684. global fileHead
  2685. global dieleData recData cirData triData ellData polyData gndData
  2686. global recCounter cirCounter dieleCounter ellCounter triCounter polyCounter \
  2687. gndCounter
  2688. global recTags cirTags dieleTags ellTags triTags polyTags gndTags
  2689. global recId cirId dieleId ellId triId polyId gndId
  2690. global maxXcoord maxYcoord
  2691. global paletteXsize paletteYsize Xscale Yscale
  2692. global pbottomleftX pbottomleftY
  2693. global Nh Nit J
  2694. global Nwx Nwy Nws
  2695. global Np Eps matr
  2696. global freq sigma
  2697. puts "file: $filename myAppFileName: $myAppFileName"
  2698. if { $filename == "" && $myAppFileName != "" } {
  2699. set filename $myAppFileName
  2700. } elseif { $filename == "" && $myAppFileName == "" } {
  2701. set filename [tk_getSaveFile -filetypes $myAppFileTypes]
  2702. if { $filename != "" } {
  2703. set myAppFileName $filename
  2704. }
  2705. }
  2706. if { $filename != "" } {
  2707. set fullfilename [format "%s.dat" $filename]
  2708. if { [catch {open $fullfilename w+ } fp] } {
  2709. error "Cannot write to $fullfilename"
  2710. }
  2711. puts "Writing $fullfilename"
  2712. puts $fp $paletteXsize
  2713. puts $fp $paletteYsize
  2714. puts $fp $Xscale
  2715. puts $fp $Yscale
  2716. puts $fp $pbottomleftX
  2717. puts $fp $pbottomleftY
  2718. puts $fp $Nh
  2719. puts $fp $Nit
  2720. puts $fp $J
  2721. puts $fp $Nwx
  2722. puts $fp $Nwy
  2723. puts $fp $Nws
  2724. puts $fp $Np
  2725. puts $fp $Eps
  2726. puts $fp $matr
  2727. puts $fp $freq
  2728. puts $fp $sigma
  2729. puts $fp $fileHead
  2730. puts $fp $dieleData
  2731. puts $fp $recData
  2732. puts $fp $cirData
  2733. puts $fp $triData
  2734. puts $fp $ellData
  2735. puts $fp $polyData
  2736. puts $fp $gndData
  2737. #--------------------------------------------------
  2738. # insert code for "save" operation
  2739. #--------------------------------------------------
  2740. ### puts -nonewline [.t get 1.0 end]
  2741. close $fp
  2742. set myAppFileName $filename
  2743. set myAppChangedFlag 0
  2744. }
  2745. }
  2746. proc myAppFileSaveAs { } {
  2747. global myAppFileTypes
  2748. set filename [tk_getSaveFile -filetypes $myAppFileTypes]
  2749. if { $filename != "" } {
  2750. set myAppFileName $filename
  2751. myAppFileSave $filename
  2752. }
  2753. }
  2754. proc myAppPromptForSave { } {
  2755. set answer [tk_messageBox -title "save?" -type yesno -icon question -message "Do you want to save the changes?"]
  2756. if { $answer == "yes" } {
  2757. myAppFileSaveAs
  2758. }
  2759. }
  2760. proc myAppExit { } {
  2761. myAppFileClose
  2762. exit
  2763. }
  2764. #########################################################################
  2765. # NAME: about
  2766. # PURPOSE: show the about information including name and version
  2767. #
  2768. #########################################################################
  2769. proc about {} {
  2770. # tk_messageBox -message "Muti-conductor Parameters Computation \n Electric Packaging Lab.\n Arizona State University\n 2000.8"
  2771. promptInfo "Calculation of Resistance and\n Inductance of Transmission\n Lines! \n\n Copyright 2000.12 EPL\n Electric Packaging Lab.\nElectrical Engineering Dept. \n Arizona State University\n\n 2000.12"
  2772. }
  2773. proc eplIntro {} {
  2774. promptInfo "This program is developed by\n\n Electric Packaging Lab\n Eletrical Engineering Dept. \n Arizona State University \n\n Tel: (480)965-7048\n http://quantum.eas.asu.edu/"
  2775. }
  2776. proc printPara {} {
  2777. global newFlag
  2778. global pData
  2779. if { $newFlag < 0 } {
  2780. promptInfo "You must setup a new palette first!"
  2781. return $newFlag
  2782. }
  2783. setdata
  2784. ## puts $pData
  2785. exec lpr <<$pData &
  2786. }
  2787. proc printcal {} {
  2788. global newFlag
  2789. global pcal
  2790. if { $newFlag < 0 } {
  2791. promptInfo "You must setup a new palette first!"
  2792. return $newFlag
  2793. }
  2794. caldata
  2795. ## puts $pcal
  2796. exec lpr <<$pcal &
  2797. }
  2798. proc printGraph {} {
  2799. global myAppFileName
  2800. global maxXcoord maxYcoord
  2801. set pssurfix ".ps"
  2802. if { $myAppFileName != "" } {
  2803. set pssurfix $myAppFileName$pssurfix
  2804. } else {
  2805. promptInfo "You must save the palette first!"
  2806. return -1
  2807. }
  2808. .c create rectangle 0 0 [expr { $maxXcoord-1 }] [expr { $maxYcoord-1 }] \
  2809. -outline black -tags printframe
  2810. set psFlag [.c postscript -width 24c -height 16c -colormode gray -file $pssurfix -rotate 1]
  2811. .c delete printframe
  2812. if { $psFlag == "" } {
  2813. exec lpr $pssurfix &
  2814. } else {
  2815. promptInfo "The Postscript file can not be generated!"
  2816. return -1
  2817. }
  2818. }
  2819. proc setTag { id idArray tagArray dataArray } {
  2820. global curPosition
  2821. set tempPosition [lsearch -exact $idArray $id]
  2822. set tempTag [lindex $tagArray $tempPosition]
  2823. set curPosition [lsearch -exact $dataArray $tempTag]
  2824. return $curPosition
  2825. }
  2826. ##############################################
  2827. # Test
  2828. ##############################################
  2829. proc processfreqs { flg } {
  2830. global _freqFrame
  2831. global freq1
  2832. global freq1
  2833. global freq2
  2834. global freq3
  2835. global freq4
  2836. global freq5
  2837. global freq6
  2838. global freq7
  2839. global freq8
  2840. global freq9
  2841. global freq10
  2842. global freq11
  2843. global freq12
  2844. global freq13
  2845. global freq14
  2846. global freq15
  2847. global freq16
  2848. global freq17
  2849. global freq18
  2850. global freq19
  2851. global freq20
  2852. global freq
  2853. ## puts "Destroy the dialog"
  2854. destroy $_freqFrame
  2855. set freqList ""
  2856. for { set ii 1 } { $ii < 21 } { incr ii } {
  2857. set cmnd [format {set frq $freq%s} $ii]
  2858. eval $cmnd
  2859. puts "Frequency $frq"
  2860. if { $frq <= 0.0 } {
  2861. break
  2862. }
  2863. lappend freqList $frq
  2864. set freq $frq
  2865. puts ""
  2866. puts "________________ Freq: $freq __________________"
  2867. startcal1 3
  2868. }
  2869. ## puts "$freqList"
  2870. checkResult
  2871. }
  2872. proc buildFreqList {} {
  2873. global _freqFrame
  2874. global freq1
  2875. global freq1
  2876. global freq2
  2877. global freq3
  2878. global freq4
  2879. global freq5
  2880. global freq6
  2881. global freq7
  2882. global freq8
  2883. global freq9
  2884. global freq10
  2885. global freq11
  2886. global freq12
  2887. global freq13
  2888. global freq14
  2889. global freq15
  2890. global freq16
  2891. global freq17
  2892. global freq18
  2893. global freq19
  2894. global freq20
  2895. set _freqFrame [toplevel .freqs \
  2896. -relief sunken -borderwidth 2]
  2897. set freq1 1e9
  2898. set freq2 2e9
  2899. set freq3 3e9
  2900. set freq4 4e9
  2901. set freq5 5e9
  2902. set freq6 6e9
  2903. set freq7 7e9
  2904. set freq8 8e9
  2905. set freq9 9e9
  2906. set freq10 10e9
  2907. set freq11 20e9
  2908. set freq12 26e9
  2909. set freq13 0
  2910. set freq14 0
  2911. set freq15 0
  2912. set freq16 0
  2913. set freq17 0
  2914. set freq18 0
  2915. set freq19 0
  2916. set freq20 0
  2917. for {set ii 1 } { $ii < 21 } { incr ii } {
  2918. set var "freq$ii"
  2919. set et [ entry $_freqFrame.e$ii -width 20 -textvariable $var ]
  2920. pack $et -side top -expand true -fill x
  2921. }
  2922. set but1 [button $_freqFrame.but1 \
  2923. -text OK -borderwidth 1 \
  2924. -command "processfreqs 1" \
  2925. -relief ridge]
  2926. set but2 [button $_freqFrame.but2 \
  2927. -text Cancel -borderwidth 1 \
  2928. -command "processfreqs 0" \
  2929. -relief ridge]
  2930. pack $but1 $but2 -side bottom -expand true -fill x
  2931. }
  2932. proc startcal1 { flag } {
  2933. global env
  2934. global myAppFileName
  2935. global myAppDirName
  2936. global fileHead
  2937. global dieleData recData cirData triData ellData polyData gndData
  2938. global newFlag
  2939. global pData pcal
  2940. global Nh Nit J
  2941. global Nwx Nwy Nws
  2942. global Np Eps matr
  2943. global freq sigma
  2944. ## puts "newFlag $newFlag"
  2945. ## puts "hhh"
  2946. if { $newFlag < 0 } {
  2947. promptInfo "You must setup a new palette first!"
  2948. return $newFlag
  2949. }
  2950. # set fileId [ open "/users/zhichao/tcltk/cal/data.in" w+ ]
  2951. set fullfilename [format "%s.in" $myAppFileName]
  2952. set fileId [ open $fullfilename w+ ]
  2953. set gndnumber [lindex $fileHead 6]
  2954. set recnumber [lindex $fileHead 1]
  2955. set cirnumber [lindex $fileHead 2]
  2956. set tranumber [lindex $fileHead 5]
  2957. puts $fileId $gndnumber
  2958. puts $fileId $recnumber
  2959. puts $fileId $cirnumber
  2960. puts $fileId $tranumber
  2961. if { $gndnumber > 0 } {
  2962. for { set i 1 } { $i <= $gndnumber } {incr i} {
  2963. puts $fileId [lindex $gndData [expr { ($i-1)*9+4 }]]
  2964. puts $fileId [lindex $gndData [expr { ($i-1)*9+5 }]]
  2965. puts $fileId [lindex $gndData [expr { ($i-1)*9+6 }]]
  2966. puts $fileId [lindex $gndData [expr { ($i-1)*9+7 }]]
  2967. puts $fileId [lindex $gndData [expr { ($i-1)*9+8 }]]
  2968. }
  2969. }
  2970. if { $recnumber > 0 } {
  2971. for { set i 1 } { $i <= $recnumber } {incr i} {
  2972. puts $fileId [lindex $recData [expr { ($i-1)*9+4 }]]
  2973. puts $fileId [lindex $recData [expr { ($i-1)*9+5 }]]
  2974. puts $fileId [lindex $recData [expr { ($i-1)*9+6 }]]
  2975. puts $fileId [lindex $recData [expr { ($i-1)*9+7 }]]
  2976. puts $fileId [lindex $recData [expr { ($i-1)*9+8 }]]
  2977. }
  2978. }
  2979. if { $cirnumber > 0 } {
  2980. for { set i 1 } { $i <= $cirnumber } {incr i} {
  2981. puts $fileId [lindex $cirData [expr { ($i-1)*8+4 }]]
  2982. puts $fileId [lindex $cirData [expr { ($i-1)*8+5 }]]
  2983. puts $fileId [lindex $cirData [expr { ($i-1)*8+6 }]]
  2984. puts $fileId [lindex $cirData [expr { ($i-1)*8+7 }]]
  2985. }
  2986. }
  2987. if { $tranumber > 0 } {
  2988. for { set i 1 } { $i <= $tranumber } {incr i} {
  2989. puts $fileId [lindex $polyData [expr { ($i-1)*14+5 }]]
  2990. puts $fileId [lindex $polyData [expr { ($i-1)*14+6 }]]
  2991. puts $fileId [lindex $polyData [expr { ($i-1)*14+7 }]]
  2992. puts $fileId [lindex $polyData [expr { ($i-1)*14+8 }]]
  2993. puts $fileId [lindex $polyData [expr { ($i-1)*14+9 }]]
  2994. puts $fileId [lindex $polyData [expr { ($i-1)*14+10 }]]
  2995. puts $fileId [lindex $polyData [expr { ($i-1)*14+11 }]]
  2996. puts $fileId [lindex $polyData [expr { ($i-1)*14+12 }]]
  2997. puts $fileId [lindex $polyData [expr { ($i-1)*14+13 }]]
  2998. }
  2999. }
  3000. puts $fileId $Nh
  3001. puts $fileId $Nit
  3002. puts $fileId $J
  3003. puts $fileId $Nwx
  3004. puts $fileId $Nwy
  3005. puts $fileId $Nws
  3006. puts $fileId $Np
  3007. puts $fileId $Eps
  3008. puts $fileId $matr
  3009. puts $fileId $freq
  3010. puts $fileId $sigma
  3011. close $fileId
  3012. ## puts $flag
  3013. if {$flag == 1} {
  3014. setdata
  3015. caldata
  3016. #set fp [ open "/users/zhichao/tcltk/cal/caldata.sys" w+ ]
  3017. set fp [ open "caldata.sys" w+ ]
  3018. puts $fp $pData
  3019. puts $fp $pcal
  3020. close $fp
  3021. #exec emacs "/users/zhichao/tcltk/cal/caldata.sys" &
  3022. exec emacs "$myAppDirName/caldata.sys" &
  3023. } elseif {$flag == 2} {
  3024. set cursr [.c cget -cursor]
  3025. .mbar configure -cursor watch
  3026. .c configure -cursor watch
  3027. update
  3028. set cmnd {$env(CALCRL_LIBRARY)/calcRL $myAppFileName}
  3029. set hd [catch { eval exec $cmnd} result]
  3030. .mbar configure -cursor $cursr
  3031. .c configure -cursor $cursr
  3032. update
  3033. puts $result
  3034. checkResult
  3035. } elseif {$flag == 3} {
  3036. set cursr [.c cget -cursor]
  3037. .mbar configure -cursor watch
  3038. .c configure -cursor watch
  3039. update
  3040. set cmnd {$env(CALCRL_LIBRARY)/calcRL \
  3041. $myAppFileName append}
  3042. set hd [catch { eval exec $cmnd} result]
  3043. .mbar configure -cursor $cursr
  3044. .c configure -cursor $cursr
  3045. update
  3046. puts $result
  3047. }
  3048. }
  3049. proc checkResult { } {
  3050. global myAppFileName
  3051. #exec xemacs /users/zhichao/tcltk/cal/data.out &
  3052. set fullfilename [format "%s.out" $myAppFileName]
  3053. exec emacs $fullfilename &
  3054. }
  3055. proc killpro { hd } {
  3056. global pid
  3057. toplevel .apexwindow -class Dialog
  3058. wm title .apexwindow "Calculation"
  3059. wm iconname .apexwindow Dialog
  3060. frame .apexwindow.textframe -width 10c -height 6c
  3061. frame .apexwindow.buttonframe -width 10c -height 2c
  3062. label .apexwindow.textframe.label -text "In Calculation, Please wait..."
  3063. set pid $hd
  3064. button .apexwindow.buttonframe.bbutton -text Break -command {
  3065. exec kill -9 $pid
  3066. destroy .apexwindow
  3067. }
  3068. pack .apexwindow.textframe .apexwindow.buttonframe -side top -padx 1m -pady 2m
  3069. pack .apexwindow.textframe.label -side left -padx 1m -pady 2m
  3070. pack .apexwindow.buttonframe.bbutton \
  3071. -side left -padx 1m -pady 2m
  3072. }
  3073. proc setdata { } {
  3074. global fileHead
  3075. global dieleData recData cirData triData ellData polyData gndData
  3076. global newFlag
  3077. global pData
  3078. set gndnumber [lindex $fileHead 6]
  3079. set recnumber [lindex $fileHead 1]
  3080. set cirnumber [lindex $fileHead 2]
  3081. set tranumber [lindex $fileHead 5]
  3082. set nl "\n"
  3083. set sp " "
  3084. set sp1 " "
  3085. set sp5 " "
  3086. set sep " -------------------------------------"
  3087. set hh " The Geometrical Parameters"
  3088. set gn " Ground Number:"
  3089. set rn " Rectangle Number:"
  3090. set cn " Circle Number:"
  3091. set tn " Trapezoid Number:"
  3092. set h1 " GROUND PLANE"
  3093. set h2 " RECTANGLE"
  3094. set h3 " CIRCLE"
  3095. set h4 " TRAPEZOID"
  3096. set r1 " lowerleft x:"
  3097. set r2 " lowerleft y:"
  3098. set r3 " width:"
  3099. set r4 " height:"
  3100. set c1 " center x:"
  3101. set c2 " center y:"
  3102. set c3 " radius:"
  3103. set t1 " apex x"
  3104. set t2 " apex y"
  3105. set t3 ":"
  3106. set c " current:"
  3107. set pData $nl$sep$nl$hh$nl$sep$nl$nl
  3108. set pData $pData$gn$sp$gndnumber$nl
  3109. set pData $pData$rn$sp$recnumber$nl
  3110. set pData $pData$cn$sp$cirnumber$nl
  3111. set pData $pData$tn$sp$tranumber$nl$nl$sep$nl
  3112. if { $gndnumber > 0 } {
  3113. for { set i 1 } { $i <= $gndnumber } { incr i } {
  3114. set pData $pData$h1$i$nl$nl
  3115. set pData $pData$r1$sp[lindex $gndData [expr { ($i-1)*9+4 }]]$nl
  3116. set pData $pData$r2$sp[lindex $gndData [expr { ($i-1)*9+5 }]]$nl
  3117. set pData $pData$r3$sp[lindex $gndData [expr { ($i-1)*9+6 }]]$nl
  3118. set pData $pData$r4$sp[lindex $gndData [expr { ($i-1)*9+7 }]]$nl
  3119. #set pData $pData$sp5$c$sp[lindex $gndData [expr { ($i-1)*9+8 }]]$nl
  3120. set pData $pData$nl
  3121. }
  3122. set pData $pData$sep$nl
  3123. }
  3124. if { $recnumber > 0 } {
  3125. for { set i 1 } { $i <= $recnumber } { incr i } {
  3126. set pData $pData$h2$i$nl$nl
  3127. set pData $pData$r1$sp[lindex $recData [expr { ($i-1)*9+4 }]]$nl
  3128. set pData $pData$r2$sp[lindex $recData [expr { ($i-1)*9+5 }]]$nl
  3129. set pData $pData$r3$sp[lindex $recData [expr { ($i-1)*9+6 }]]$nl
  3130. set pData $pData$r4$sp[lindex $recData [expr { ($i-1)*9+7 }]]$nl
  3131. #set pData $pData$sp5$c$sp[lindex $recData [expr { ($i-1)*9+8 }]]$nl
  3132. set pData $pData$nl
  3133. }
  3134. set pData $pData$sep$nl
  3135. }
  3136. if { $cirnumber > 0 } {
  3137. for { set i 1 } { $i <= $cirnumber } { incr i } {
  3138. set pData $pData$h3$i$nl$nl
  3139. set pData $pData$c1$sp[lindex $cirData [expr { ($i-1)*8+4 }]]$nl
  3140. set pData $pData$c2$sp[lindex $cirData [expr { ($i-1)*8+5 }]]$nl
  3141. set pData $pData$c3$sp[lindex $cirData [expr { ($i-1)*8+6 }]]$nl
  3142. #set pData $pData$sp1$c$sp[lindex $cirData [expr { ($i-1)*8+7 }]]$nl
  3143. set pData $pData$nl
  3144. }
  3145. set pData $pData$sep$nl
  3146. }
  3147. if { $tranumber > 0 } {
  3148. for { set i 1 } { $i <= $tranumber } { incr i } {
  3149. set pData $pData$h4$i$nl$nl
  3150. for { set j 1 } { $j <= 4 } { incr j } {
  3151. set pData $pData$t1[expr { $j }]$t3$sp[lindex $polyData [expr { ($i-1)*14+3+$j*2 }]]$nl
  3152. set pData $pData$t2[expr { $j }]$t3$sp[lindex $polyData [expr { ($i-1)*14+4+$j*2 }]]$nl
  3153. }
  3154. #set pData $pData$c$sp[lindex $polyData [expr { ($i-1)*14+13 }]]$nl
  3155. set pData $pData$nl
  3156. }
  3157. }
  3158. }
  3159. proc caldata { } {
  3160. global Nh Nit J
  3161. global Nwx Nwy Nws
  3162. global Np Eps matr
  3163. global freq sigma
  3164. global pcal
  3165. set t1 " Wavelet Point Number:"
  3166. set t2 " Number of Iteration:"
  3167. set t3 " Resolution Level:"
  3168. set t4 " Gauss Quadrature X:"
  3169. set t5 " Gauss Quadrature Y:"
  3170. set t6 " \# of Segments/Wavelet:"
  3171. set t7 " OPQ Seperation:"
  3172. set t8 " STAB Accuracy:"
  3173. set t9 " Matrix Solution:"
  3174. set t10 " Frequency(Hz):"
  3175. set t11 " Conductivity(S/m):"
  3176. set nl "\n"
  3177. set sp " "
  3178. set sep " -------------------------------------"
  3179. set hh " The Calculation Parameters"
  3180. set pcal $nl$sep$nl$hh$nl$sep$nl$nl
  3181. set pcal $pcal$t1$sp$Nh$nl
  3182. set pcal $pcal$t2$sp$Nit$nl
  3183. set pcal $pcal$t3$sp$J$nl
  3184. set pcal $pcal$t4$sp$Nwx$nl
  3185. set pcal $pcal$t5$sp$Nwy$nl
  3186. set pcal $pcal$t6$sp$Nws$nl
  3187. set pcal $pcal$t7$sp$Np$nl
  3188. set pcal $pcal$t8$sp$Eps$nl
  3189. set pcal $pcal$t9$sp$matr$nl
  3190. set pcal $pcal$t10$sp$freq$nl
  3191. set pcal $pcal$t11$sp$sigma$nl
  3192. }
  3193. proc delall { } {
  3194. global fileHead
  3195. global recTags cirTags dieleTags ellTags triTags polyTags gndTags
  3196. set gndnumber [lindex $fileHead 6]
  3197. set recnumber [lindex $fileHead 1]
  3198. set cirnumber [lindex $fileHead 2]
  3199. set tranumber [lindex $fileHead 5]
  3200. if { $gndnumber > 0 } {
  3201. for { set i 0 } { $i < $gndnumber } {incr i} {
  3202. .c delete [lindex $gndTags $i]
  3203. }
  3204. }
  3205. if { $recnumber > 0 } {
  3206. for { set i 0 } { $i < $recnumber } {incr i} {
  3207. .c delete [lindex $recTags $i]
  3208. }
  3209. }
  3210. if { $cirnumber > 0 } {
  3211. for { set i 0 } { $i < $cirnumber } {incr i} {
  3212. .c delete [lindex $cirTags $i]
  3213. }
  3214. }
  3215. if { $tranumber > 0 } {
  3216. for { set i 0 } { $i < $tranumber } {incr i} {
  3217. .c delete [lindex $polyTags $i]
  3218. }
  3219. }
  3220. }
  3221. proc initc { flag } {
  3222. global fileHead;# the number of each kind of conductor and dielectric
  3223. global dieleData recData cirData triData ellData polyData gndData
  3224. # global variables for saving all parameters of each kind
  3225. global palFlag
  3226. global corFlag
  3227. global newFlag
  3228. global recCounter cirCounter dieleCounter ellCounter triCounter polyCounter \
  3229. gndCounter
  3230. global recTags cirTags dieleTags ellTags triTags polyTags gndTags
  3231. global recId cirId dieleId ellId triId polyId gndId
  3232. global maxXcoord maxYcoord
  3233. global paletteXsize paletteYsize Xscale Yscale
  3234. global pbottomleftX pbottomleftY
  3235. global Nh Nit J
  3236. global Nwx Nwy Nws
  3237. global Np Eps matr
  3238. global freq sigma
  3239. global pData pcal
  3240. set fileHead { 0 0 0 0 0 0 0 }; # dieleNum recNum cirNum triNum ellNum polyNum gndNum
  3241. set corFlag -1
  3242. set newFlag -1
  3243. set recCounter 0
  3244. set cirCounter 0
  3245. set dieleCounter 0
  3246. set ellCounter 0
  3247. set triCounter 0
  3248. set polyCounter 0
  3249. set gndCounter 0
  3250. set recId ""
  3251. set cirId ""
  3252. set dieleId ""
  3253. set ellId ""
  3254. set triId ""
  3255. set polyId ""
  3256. set gndId ""
  3257. set recData ""
  3258. set cirData ""
  3259. set dieleData ""
  3260. set ellData ""
  3261. set triData ""
  3262. set polyData ""
  3263. set gndData ""
  3264. set recTags ""
  3265. set cirTags ""
  3266. set dieleTags ""
  3267. set ellTags ""
  3268. set triTags ""
  3269. set polyTags ""
  3270. set gndTags ""
  3271. set pData ""
  3272. set pcal ""
  3273. set maxXcoord 879.00000
  3274. set maxYcoord 586.00000
  3275. if { $flag == 1 } {
  3276. set paletteXsize 0
  3277. set paletteYsize 0
  3278. set pbottomleftX 0
  3279. set pbottomleftY 0
  3280. set palFlag -1
  3281. set Xscale 0
  3282. set Yscale 0
  3283. }
  3284. set Nh 1024
  3285. set Nit 40
  3286. set J 6
  3287. set Nwx 8
  3288. set Nwy 10
  3289. set Nws 5
  3290. set Np 0.0
  3291. set Eps 1.0e-5
  3292. set matr 1
  3293. set freq 1.0e6
  3294. set sigma 5.6e7
  3295. bind .c <Button-1> { }
  3296. bind .c <B1-Motion> { }
  3297. bind .c <ButtonRelease-1> { }
  3298. bind .c <Motion> { }
  3299. }
  3300. proc main { argc argv } {
  3301. global myAppDirName
  3302. global myAppFileName
  3303. global_init
  3304. if { $argc == 1 } {
  3305. set myAppFileName [lindex $argv 0]
  3306. puts "file: $myAppFileName"
  3307. ## puts "file: $myAppFileName"
  3308. myAppFileOpen $myAppFileName
  3309. }
  3310. }
  3311. main $argc $argv