/[ascend]/trunk/ascend4/TK/BrowserProc.tcl
ViewVC logotype

Contents of /trunk/ascend4/TK/BrowserProc.tcl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (show annotations) (download) (as text)
Fri Oct 29 20:54:12 2004 UTC (17 years, 6 months ago) by aw0a
File MIME type: text/x-tcl
File size: 111529 byte(s)
Setting up web subdirectory in repository
1 # BrowserProc.tcl: support Tcl code for the Browser
2 # by Benjamin A. Allan and Kirk A. Abbott
3 # Created: January 1994
4 # Part of ASCEND
5 # Revision: $Revision: 1.99 $
6 # Last modified on: $Date: 1998/07/06 10:28:10 $
7 # Last modified by: $Author: ballan $
8 # Revision control file: $RCSfile: BrowserProc.tcl,v $
9 #
10 # This file is part of the ASCEND Tcl/Tk Interface.
11 #
12 # Copyright (C) 1994-1998 Carnegie Mellon University
13 #
14 # The ASCEND Tcl/Tk Interface is free software; you can redistribute
15 # it and/or modify it under the terms of the GNU General Public
16 # License as published by the Free Software Foundation; either
17 # version 2 of the License, or (at your option) any later version.
18 #
19 # The ASCEND Tcl/Tk Interface is distributed in hope that it will be
20 # useful, but WITHOUT ANY WARRANTY; without even the implied warranty
21 # of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU General Public License for more details.
23 #
24 # You should have received a copy of the GNU General Public License
25 # along with the program; if not, write to the Free Software
26 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139 USA. Check the
27 # file named COPYING. COPYING is found in ../compiler.
28
29 #
30 # proc qassgn {qid val {units ""}}
31 #------------------------------------------------------------------------
32 # holdover patch for old scripts.
33 # do not use this function in new scripts, use qassgn3 instead.
34 #------------------------------------------------------------------------
35 proc qassgn {qid val {units ""}} {
36 return [qassqn3 $qid $val $units]
37 }
38
39 #
40 # proc set_Browser_Defaults {}
41 #------------------------------------------------------------------------
42 # set browser on startup
43 #------------------------------------------------------------------------
44 proc set_Browser_Defaults {} {
45 global ascBrowVect ascGlobalVect xfShowWindow.browser
46
47 if {${xfShowWindow.browser}} {
48 # puts "setting browser buttons"
49 set ascBrowVect(windowname) .browser
50 set ascBrowVect(filename) [pwd]
51 set ascBrowVect(basefiletypes) {
52 {{New values} {.a4v} }
53 {{Old values} {.values} }
54 {{Most} {.*} }
55 {{All} {*} }
56 }
57 set ascBrowVect(filetypes) $ascBrowVect(basefiletypes)
58 set ascBrowVect(currentsim) ""
59 set ascBrowVect(depth) ""
60 set ascBrowVect(qlfdid) $ascBrowVect(currentsim)
61 set ascBrowVect(procedurelist) ""
62
63 if {![info exists ascBrowVect(dimconsistency)]} {
64 set ascBrowVect(dimconsistency) 1
65 }
66 if {![info exists ascBrowVect(lastreadextension)]} {
67 set ascBrowVect(lastreadextension) ".a4v"
68 }
69 if {![info exists ascBrowVect(ShowAtoms)]} {
70 set ascBrowVect(ShowAtoms) "" ;# don't show by default
71 }
72 if {![info exists ascBrowVect(HidePassed)]} {
73 set ascBrowVect(HidePassed) "" ;# don't show by default
74 }
75 if {![info exists ascBrowVect(localkinds)]} {
76 set ascBrowVect(localkinds) REAL_ATOM_INST
77 }
78 set ascBrowVect(locallist) [list \
79 REAL_ATOM_INST \
80 INTEGER_ATOM_INST \
81 BOOLEAN_ATOM_INST \
82 SYMBOL_ATOM_INST \
83 SET_ATOM_INST \
84 REL_INST \
85 LREL_INST \
86 REAL_CONSTANT_INST \
87 INTEGER_CONSTANT_INST \
88 BOOLEAN_CONSTANT_INST \
89 SYMBOL_CONSTANT_INST \
90 ]
91 foreach i $ascBrowVect(locallist) {
92 if {![info exists ascBrowVect(localshow,$i)]} {
93 set ascBrowVect(localshow,$i) 0
94 }
95 }
96 # here we establish the traces which keep the vars in sync
97 # with the lead inst kind of their group, as grouped on the
98 # check buttons in the browser
99 trace variable ascBrowVect(localshow,SET_ATOM_INST) w Brow_LeadCheckBtn
100 trace variable ascBrowVect(localshow,INTEGER_ATOM_INST) w Brow_LeadCheckBtn
101
102 if {![info exists ascBrowVect(localshow,REAL_ATOM_INST)]} {
103 set ascBrowVect(localshow,REAL_ATOM_INST) 1
104 } else {
105 set ascBrowVect(localshow,REAL_ATOM_INST) \
106 $ascBrowVect(localshow,REAL_ATOM_INST) ;# tweak the trace
107 }
108 Brow_UpdateLocalKinds
109 set ascBrowVect(initialized) "FALSE"
110
111 set ascBrowVect(parents) .browser.main_frm.parents_box.listbox1
112 set ascBrowVect(children) .browser.main_frm.child_box.listbox1
113 set ascBrowVect(local) .browser.local_frm.child_box.listbox1
114 set ascBrowVect(locallabel) nothing
115
116 $ascBrowVect(parents) configure \
117 -exportselection {0}
118
119 bind $ascBrowVect(windowname) <F5> Browser_do_ResumeCompile
120
121 bind $ascBrowVect(parents) <1> {
122 set d [%W nearest %y]
123 if {$d != ""} {
124 if {$d == [%W size] - 1} {
125 # no change of focus, just do something else
126 Brow_do_SameParentsBox $d
127 } else {
128 Brow_do_ParentsBox $d
129 }
130 }
131 }
132
133 # bind $ascBrowVect(parents) <3> {# Parentsbox
134 # set d [%W nearest %y]
135 # if {$d != "" } {
136 # Brow_do_ParentsSetValue $d
137 # }
138 # }
139
140 ascRightMouseAddCommand $ascBrowVect(parents) BrowUpdateFindCascade \
141 cascade -label "Find" \
142 -underline -1 -menu $ascBrowVect(parents).childpop.mfind
143
144 ascRightMouseAddCommand $ascBrowVect(parents) BrowUpdateRunCascade \
145 cascade -label "Run" \
146 -underline -1 -menu $ascBrowVect(parents).childpop.mrun
147
148 ascRightMouseAddCommand $ascBrowVect(parents) BrowSetValueState \
149 command -label "Set value" \
150 -underline -1 -command Browser_do_SetValue
151
152 ascRightMouseAddCommand $ascBrowVect(parents) BrowSetAttributeState \
153 command -label "Set attribute values" \
154 -underline -1 -command Brow_do_ParentsSetValue
155
156 ascRightMouseAddCommand $ascBrowVect(parents) BrowShowCodeState \
157 command -label "Show code" \
158 -underline -1 -command {Disp_do_ShowCode [inst type]}
159
160 ascRightMouseAddCommand $ascBrowVect(parents) BrowSolveState \
161 command -label "Solve..." \
162 -underline -1 -command Brow_do_Export2Solver
163
164 ascRightMouseAddCommand $ascBrowVect(parents) normal \
165 command -label "Probe..." \
166 -underline -1 -command Brow_do_Export2Probe
167
168 ascRightMouseAddCommand $ascBrowVect(parents) normal \
169 separator
170
171 ascRightMouseAddCommand $ascBrowVect(parents) normal \
172 command -command {Toggle_Remote ascBrowVect} \
173 -label {Close window} -underline -1
174
175
176 # remove global ListBox bindings from the ChildBox so we
177 # cannot select objects in the ChildBox
178 # default bindtags is $ascBrowVect(children) Listbox .browser all
179 set bind_tags [bindtags $ascBrowVect(children)]
180 if {[set findit [lsearch $bind_tags Listbox]] != -1} {
181 bindtags $ascBrowVect(children) [lreplace $bind_tags $findit $findit]
182 }
183
184 bind $ascBrowVect(children) <1> {
185 # browse down
186 set ndx [%W nearest %y]
187 if {[%W size] != "0"} {
188 Brow_do_ChildBox $ndx
189 }
190 }
191
192 bind $ascBrowVect(children) <Double-2> {
193 set ndx [%W nearest %y]
194 if {[%W size] != "0"} {
195 Brow_do_BooleanToggle $ndx
196 }
197 }
198
199 bind $ascBrowVect(children) <3> {
200 # set value
201 set ndx [%W nearest %y]
202 if {[%W size] != "0"} {
203 Brow_do_ChildSetValue $ndx
204 }
205 }
206
207 bind $ascBrowVect(local) <1> { # export to child box
208 set ndx [%W nearest %y]
209 if {[%W size] != "0"} {
210 Brow_do_LocalBrowse $ndx
211 }
212 }
213
214 bind $ascBrowVect(local) <3> { # set value, if sane
215 set ndx [%W nearest %y]
216 if {[%W size] != 0} {
217 Brow_do_LocalSetValue $ndx
218 }
219 }
220
221 # set up the multiple setvalue box
222 Brow_InitSetvalue
223
224 # Update Enabled/Disabled entries when a menu is posted
225 #
226 .browser.menubar.file configure \
227 -postcommand Brow_Update_File_Buttons
228
229 .browser.menubar.display configure \
230 -postcommand Brow_Update_Display_Buttons
231
232 .browser.menubar.edit configure \
233 -postcommand Brow_Update_Edit_Buttons
234
235 .browser.menubar.export configure \
236 -postcommand Brow_Update_Export_Buttons
237
238 .browser.menubar.find configure \
239 -postcommand Brow_Update_Find_Buttons
240
241 .browser.menubar.view configure \
242 -postcommand Brow_Update_View_Buttons
243
244
245 # Set Initialized flag
246 #
247 set ascBrowVect(initialized) "FALSE"
248
249 # bind "^C"
250 bind .browser <Control-Key-C> "Tool_exit"
251
252 VPane-Bind .browser.main_frm parents_box child_box 10 0.333
253 HPane-Bind .browser main_frm local_frm 10 0.5
254
255 # set pointer
256 .browser config -cursor left_ptr
257
258 # setup trace on dim consistency checking.
259 if {[trace vinfo ascBrowVect(dimconsistency)]==""} {
260 trace variable ascBrowVect(dimconsistency) w Brow_SetDimNoise
261 }
262 } else {
263 puts "browser doesn't exist! buttons not set"
264 }
265 }
266 #update disabling on find popup
267 proc BrowUpdateFindCascade {} {
268 global ascBrowVect ascPopdata
269 set m $ascBrowVect(parents).childpop.mfind
270 if {![winfo exists $m]} {
271 menu $m \
272 -tearoffcommand [string toupper $m] \
273 -tearoff 0
274 $m add command \
275 -command {Brow_do_FindFixed TRUE} \
276 -label {Fixed variables} \
277 -underline -1
278 $m add command \
279 -command {Brow_do_FindOpers} \
280 -label {Operands} \
281 -underline -1
282 $m add command \
283 -command {Brow_do_FindFixed FALSE} \
284 -label {Free variables} \
285 -underline -1
286 $m add command \
287 -command {Brow_do_FindEligible} \
288 -label {Eligible variables} \
289 -underline -1
290 $m add command \
291 -command {Brow_do_FindActive} \
292 -label {Active variables} \
293 -underline -1
294 $m add command \
295 -command {Brow_do_FindUndefined} \
296 -label {Undefined values} \
297 -underline -1
298 # bindings don't stick if you leave out this update.
299 update
300 bind $m <Any-Leave> "+
301 set ascPopdata($ascBrowVect(parents).childpop.in) 0
302 set ascPopdata($ascBrowVect(parents).childpop.id) \
303 \[after \$ascPopdata(delay) \{if \{!\$ascPopdata($ascBrowVect(parents).childpop.in)\} \
304 \{ tkMenuUnpost $ascBrowVect(parents).childpop \} \}\]
305 "
306 bind $m <Any-Enter> "+
307 set ascPopdata($ascBrowVect(parents).childpop.in) 1
308 catch \{after cancel \$ascPopdata($ascBrowVect(parents).childpop.id)\}
309 "
310 }
311 menu_disable_all $m
312 if {[$ascBrowVect(parents) size] != 0} {
313 $m entryconfigure 0 -state normal
314 $m entryconfigure 5 -state normal
315 }
316 switch [inst kind] {
317 WHEN_INST -
318 REL_INST -
319 LREL_INST {
320 $m entryconfigure 1 -state normal
321 }
322 MODEL_INST -
323 ARRAY_INT_INST -
324 ARRAY_ENUM_INST {
325 $m entryconfigure 2 -state normal
326 $m entryconfigure 3 -state normal
327 }
328 default { }
329 }
330
331 return normal
332 }
333 #update methods menu
334 proc BrowUpdateRunCascade {} {
335 global ascBrowVect ascPopdata
336 set m $ascBrowVect(parents).childpop.mrun
337 if {[winfo exists $m]} {
338 catch {destroy $m}
339 }
340 set mlist ""
341 if {[string compare [inst kind] "MODEL_INST"] == 0} {
342 set itype [inst type]
343 if {![llength [libr_query -methods -type $itype]] && \
344 ![llength [libr_query -basemethods]]} {
345 return disabled
346 }
347 set mlist [libr_query -methods -type $itype]
348 set blist [libr_query -basemethods]
349 foreach i $blist {
350 if {[lsearch -exact $mlist $i] == -1} {
351 lappend mlist $i
352 }
353 }
354 set nlist [lsort $mlist]
355 set mlist $nlist
356 } else {
357 return disabled
358 }
359 set root [Brow_get_subname]
360 menu $m \
361 -tearoffcommand [string toupper $m] \
362 -tearoff 0
363 foreach i $mlist {
364 $m add command \
365 -command "RUN $root.$i" \
366 -label $i \
367 -underline -1
368 }
369 update
370 bind $m <Any-Leave> "+
371 set ascPopdata($ascBrowVect(parents).childpop.in) 0
372 set ascPopdata($ascBrowVect(parents).childpop.id) \
373 \[after \$ascPopdata(delay) \{if \{!\$ascPopdata($ascBrowVect(parents).childpop.in)\} \
374 \{ tkMenuUnpost $ascBrowVect(parents).childpop \} \}\]
375 "
376 bind $m <Any-Enter> "+
377 set ascPopdata($ascBrowVect(parents).childpop.in) 1
378 catch \{after cancel \$ascPopdata($ascBrowVect(parents).childpop.id)\}
379 "
380 return normal
381 }
382 #
383 # proc Brow_trans_option {opt}
384 #-----------------------------------------------------------------------
385 # Brow_trans_option: translate Xname into vector name for the options
386 # and return subscript, vector id in a list
387 # If option unrecognized, return same name and Brow
388 # Note: a useless function unless the browser resources are standardized
389 # like everyone elses
390 #-----------------------------------------------------------------------
391 proc Brow_trans_option {opt} {
392 switch $opt {
393 {displayAtomValue} {return {TypeorValue Brow}}
394 {queryFile} {return {queryfile Brow}}
395 default {return "$opt Brow"}
396 }
397 }
398
399 #
400 # proc Brow_do_Font {args}
401 #---------------------------------------------------------------------
402 # font select button for browser window
403 #---------------------------------------------------------------------
404 proc Brow_do_Font {args} {
405 global ascBrowVect
406 set font ""
407 if {$args !=""} {
408 set font $args
409 } else {
410 set font [ascFontGet]
411 }
412 if {"$font" == ""} {
413 return
414 }
415 $ascBrowVect(children) configure -font $font
416 $ascBrowVect(parents) configure -font $font
417 $ascBrowVect(local) configure -font $font
418 set ascBrowVect(font) [$ascBrowVect(children) cget -font]
419 }
420
421
422 #
423 # proc Brow_InitBrowser {}
424 #-------------------------------------------------------------------------
425 # empty browserboxes and set currentsim/child/parent null
426 #-------------------------------------------------------------------------
427 proc Brow_InitBrowser {} {
428 global ascBrowVect
429
430 rootinit;
431 ascclearlist $ascBrowVect(parents);
432 ascclearlist $ascBrowVect(children);
433 ascclearlist $ascBrowVect(local);
434 }
435
436 #
437 # proc BrowMakeName
438 #-------------------------------------------------------------------------
439 # return qlfdid of child
440 #-------------------------------------------------------------------------
441 proc BrowMakeName {} {
442 global ascBrowVect
443
444 set name [Brow_get_subname]
445 set ascBrowVect(qlfdid) $name
446 set ascBrowVect(instkind) [inst kind]
447 # puts "-->$ascBrowVect(qlfdid) -- [inst kind] -- [inst nchild]<--"
448 return $ascBrowVect(qlfdid)
449 }
450
451 #
452 # proc Brow_do_ChildBox {ndx}
453 #-------------------------------------------------------------------------
454 # Gets the child selected in the child box at index ndx. Strips the \{ and
455 # \} and sets the 0th element as the potential new parent.
456 # Calls the registerd command "root $newparent". The "root" command will
457 # for the instance name and adjust the depth if found. If all is ok the
458 # newparent is inserted in the parent listbox.
459 # Brow_do_UpdateChild is then used to update the child box. Set the new
460 # selection to the newparent.
461 #-------------------------------------------------------------------------
462 proc Brow_do_ChildBox {ndx} {
463 global ascBrowVect
464
465 set a [$ascBrowVect(children) get $ndx]
466 set newparent [stripbraces $a]
467 switch [inst kind] {
468 ERROR_INST -
469 REAL_ATOM_INST -
470 INTEGER_ATOM_INST -
471 BOOLEAN_ATOM_INST -
472 SYMBOL_ATOM_INST -
473 SET_ATOM_INST -
474 REL_INST -
475 LREL_INST {return; #disable descent into ATOM children}
476 }
477 set aftername [string last " IS_A " $newparent]
478 if {$aftername == -1} {
479 set aftername [string last " = " $newparent]
480 }
481 if {$aftername >= 0 } {
482 set prettyP [string range $newparent 0 $aftername]
483 set prettyP [string trim $prettyP]
484 set candidate [string trim $prettyP "\[\'\]"]
485 set nok [catch {root $candidate} errmsg]
486 if {$nok} {
487 if {$errmsg == "At leaves of the Instance Tree"} {
488 puts stderr "--> $errmsg"
489 }
490 $ascBrowVect(children) delete 0 end
491 return
492 } else {
493 $ascBrowVect(parents) insert end $prettyP
494 Brow_do_UpdateChild \
495 $ascBrowVect(TypeorValue) \
496 $ascBrowVect(ShowAtoms) \
497 $ascBrowVect(HidePassed)
498 }
499 Brow_Setup_Selection $ascBrowVect(parents)
500 return;
501 }
502 }
503
504 #
505 # Brow_get_partname {listindex}
506 #-------------------------------------------------------------------------
507 # returns the name up to element ndx (which counts from 0) from
508 # the browser parent box, less any trailing non-MODEL names.
509 # if listindex is end, returns complete less any trailing array/ATOM names.
510 #-------------------------------------------------------------------------
511 proc Brow_get_partname {{ndx -1}} {
512 global ascBrowVect
513 if {$ndx < 0 || "$ndx" == "end"} {
514 set ndx [$ascBrowVect(parents) size]
515 }
516 set name "[$ascBrowVect(parents) get 0 0]"
517 set lastpart $name
518 if {[$ascBrowVect(parents) size] > 1} {
519 foreach i [$ascBrowVect(parents) get 1 $ndx] {
520 if { [string index $i 0] != "\["} {
521 append name .$i
522 } else {
523 append name $i
524 }
525 qlfdid $name
526 if {![string compare [inst kind search] "MODEL_INST"]} {
527 set lastpart $name
528 }
529 }
530 }
531 return $lastpart
532 }
533
534 #
535 # Brow_get_subname {listindex}
536 #-------------------------------------------------------------------------
537 # returns the name up to element ndx (which counts from 0) from
538 # the browser parent box.
539 # if listindex is end, returns complete name.
540 #-------------------------------------------------------------------------
541 proc Brow_get_subname {{ndx -1}} {
542 global ascBrowVect
543 if {$ndx < 0 || "$ndx" == "end"} {
544 set ndx [$ascBrowVect(parents) size]
545 }
546 set name "[$ascBrowVect(parents) get 0 0]"
547 if {[$ascBrowVect(parents) size] > 1} {
548 foreach i [$ascBrowVect(parents) get 1 $ndx] {
549 if { [string index $i 0] != "\["} {
550 append name .$i
551 } else {
552 append name $i
553 }
554 }
555 }
556 return $name
557 }
558
559 #
560 # proc Brow_do_SameParentsBox {ndx}
561 #-------------------------------------------------------------------------
562 # Does things that we want when not changing the focus.
563 # Creates a popup menu for:
564 # running methods, what else?
565 #-------------------------------------------------------------------------
566 proc Brow_do_SameParentsBox {ndx} {
567 # puts we should put a menu here.
568 }
569 #
570 # proc Brow_do_ParentsBox {ndx}
571 #-------------------------------------------------------------------------
572 # The main binding for ascending the Browser Parents Box.
573 # Sets the current working
574 # instance based on the listbox index. Updates the child box. Sets the
575 # current selection. A valid listbox index must be sent to this function.
576 # i.e. A valid instance must exist and must have been selected.
577 #-------------------------------------------------------------------------
578 proc Brow_do_ParentsBox {ndx} {
579 global ascBrowVect ascScripVect
580 set depth $ndx
581 incr depth
582 set muffle $ascScripVect(executing)
583 if {!$muffle} {
584 set ascScripVect(executing) 1
585 }
586 if {[$ascBrowVect(parents) size] > 1} {
587 set name [Brow_get_subname $ndx]
588 Brow_Export_Any_2Browser $name
589 }
590 if {!$muffle} {
591 set ascScripVect(executing) 0
592 }
593 }
594
595 # left side browser
596 proc Brow_do_ParentsSetValue {{ndx 0}} {
597 global ascBrowVect
598 set name [Brow_get_subname]
599 puts $name
600 if {[catch {qlfdid $name} errmsg]} {return}
601 Browser_SetvalueBox $ascBrowVect(windowname) $name
602 }
603
604 # right side browser
605 proc Brow_do_ChildSetValue {ndx} {
606 global ascBrowVect
607 set i [lindex [$ascBrowVect(children) get $ndx] 0]
608 set name [Brow_childname [Brow_get_subname] $i]
609 if {[catch {qlfdid $name} errmsg]} {return}
610 Browser_do_SetValue $ascBrowVect(windowname) $name
611 }
612
613 # bottom browser
614 proc Brow_do_LocalSetValue {ndx} {
615 global ascBrowVect
616 set i [lindex [$ascBrowVect(local) get $ndx] 0]
617 set name [Brow_childname [Brow_get_subname] $i]
618 if {[catch {qlfdid $name} errmsg]} {return}
619 Browser_do_SetValue $ascBrowVect(local) $name
620 }
621
622 proc Brow_do_LocalBrowse {ndx} {
623 global ascBrowVect
624 set i [lindex [$ascBrowVect(local) get $ndx] 0]
625 Script_ClearInterrupt
626 BROWSE [Brow_childname [Brow_get_subname] $i]
627 }
628
629 proc Brow_UpdateLocalLabel {leadkind} {
630 global ascBrowVect
631 switch $leadkind {
632 REAL_ATOM_INST {set ascBrowVect(locallabel) {Real variables}}
633 INTEGER_ATOM_INST {set ascBrowVect(locallabel) {Discrete variables}}
634 REL_INST {set ascBrowVect(locallabel) {Real relations}}
635 LREL_INST {set ascBrowVect(locallabel) {Logical relations}}
636 REAL_CONSTANT_INST {set ascBrowVect(locallabel) {Real constants}}
637 SET_ATOM_INST {set ascBrowVect(locallabel) {Discrete constants}}
638 }
639 }
640
641 #
642 # proc Brow_do_UpdateCore {basename listbox instkindlist}
643 #-------------------------------------------------------------------------
644 # # Prototype implementation. Not to be optimized until we prove it needs
645 # # optimizing.
646 # This cannot be called until after Brow_do_ParentsBox.
647 # This should not be called until after Brow_do_UpdateChild
648 # Updates the local box based on the available information in the instance
649 # and ascBrowVect(localkinds).
650 # This implementation could be extremely speeded up by reconsidering
651 # whether we should have multiple local_frm.childbox of which only
652 # one is shown (a la probe) and whether we should revisit C code
653 # to return additional info to reduce the tcl work load.
654 # Additionally, the ui needs more buttons: this is a slight overload of
655 # the View button.
656 #
657 # dumb assumptions:
658 # all things in localbox are atoms (in the sense of having a value)
659 # user wants to see ATOM attributes/units
660 # [brow_child_list search all $ascBrowVect(TypeorValue)]
661 #-------------------------------------------------------------------------
662 proc Brow_do_UpdateCore {base box kindlist} {
663 ascclearlist $box
664 set connector .
665 set rootkind {}
666 if {[catch {set rootkind [inst kind current]} err]} {
667 return
668 }
669 set childlist [inst child]
670 if {$rootkind=="ARRAY_ENUM_INST" || $rootkind=="ARRAY_INT_INST"} {
671 set connector ""
672 }
673 foreach c $childlist {
674 set name $base$connector$c
675 if {[catch {qlfdid $name} errmsg]} {continue}
676 set instkind [inst kind search]
677 if {[lsearch -exact $kindlist $instkind] != -1 &&
678 [libr_type_is_shown [inst type search]] != 0} {
679 set line ""
680 set esym " = "
681 set val [inst atomvalue search]
682 switch $instkind {
683 REL_INST -
684 LREL_INST {
685 set esym " : "
686 }
687 }
688 catch {set val [lindex [u_browgetval search] 0]} errmsg
689 append line $c $esym $val
690 $box insert end $line
691 }
692 }
693 }
694
695 #
696 # proc Brow_do_UpdateLocalBox {}
697 #-------------------------------------------------------------------------
698 # # Prototype implementation. Not to be optimized until we prove it needs
699 # # optimizing.
700 # This cannot be called until after Brow_do_ParentsBox.
701 # This should not be called until after Brow_do_UpdateChild
702 # Updates the local box based on the available information in the instance
703 # and ascBrowVect(localkinds).
704 # This implementation could be extremely speeded up by reconsidering
705 # whether we should have multiple local_frm.childbox of which only
706 # one is shown (a la probe) and whether we should revisit C code
707 # to return additional info to reduce the tcl work load.
708 # Additionally, the ui needs more buttons: this is a slight overload of
709 # the View button.
710 #
711 # dumb assumptions:
712 # all things in localbox are atoms (in the sense of having a value)
713 # user wants to see ATOM attributes/units
714 # [brow_child_list search all $ascBrowVect(TypeorValue)]
715 #
716 # args should be empty or the lead type of a group of types corresponding
717 # to a checkbutton on the browser.
718 # It tells the user which button they toggled last, to help explain
719 # the 2 letter button labels.
720 #-------------------------------------------------------------------------
721 proc Brow_do_UpdateLocalBox {args} {
722 global ascBrowVect
723 Brow_UpdateLocalLabel $args
724 set base [Brow_get_subname]
725 # here we need to assemble localkinds from the current set of booleans
726 Brow_UpdateLocalKinds
727 Brow_do_UpdateCore [Brow_get_subname] \
728 $ascBrowVect(local) \
729 $ascBrowVect(localkinds)
730 }
731
732 #
733 # proc Brow_LeadCheckBtn {name1 name2 op}
734 #-------------------------------------------------------------------------
735 # updates the groups of variables based on the name of the lead
736 # instance type toggled by the check buttons.
737 #-------------------------------------------------------------------------
738 proc Brow_LeadCheckBtn {name1 name2 op} {
739 global ascBrowVect
740 if {$name1 != "ascBrowVect" || $op != "w"} {
741 return
742 }
743 switch $name2 {
744 localshow,REL_INST -
745 localshow,LREL_INST -
746 localshow,REAL_CONSTANT_INST -
747 localshow,REAL_ATOM_INST {
748 # do nothing for these, as they are singletons
749 return
750 }
751 localshow,INTEGER_ATOM_INST {
752 set ascBrowVect(localshow,BOOLEAN_ATOM_INST) \
753 $ascBrowVect(localshow,INTEGER_ATOM_INST)
754 set ascBrowVect(localshow,SYMBOL_ATOM_INST) \
755 $ascBrowVect(localshow,INTEGER_ATOM_INST)
756 }
757 localshow,BOOLEAN_ATOM_INST -
758 localshow,SYMBOL_ATOM_INST {
759 # do nothing for these, as they are followers of INTEGER_ATOM_INST
760 return
761 }
762 localshow,SET_ATOM_INST {
763 set ascBrowVect(localshow,INTEGER_CONSTANT_INST) \
764 $ascBrowVect(localshow,SET_ATOM_INST)
765 set ascBrowVect(localshow,BOOLEAN_CONSTANT_INST) \
766 $ascBrowVect(localshow,SET_ATOM_INST)
767 set ascBrowVect(localshow,SYMBOL_CONSTANT_INST) \
768 $ascBrowVect(localshow,SET_ATOM_INST)
769 }
770 localshow,INTEGER_CONSTANT_INST -
771 localshow,BOOLEAN_CONSTANT_INST -
772 localshow,SYMBOL_CONSTANT_INST {
773 # do nothing for these, as they are followers of SET_ATOM_INST
774 return
775 }
776 default {return}
777 }
778 }
779 #
780 # proc Brow_UpdateLocalKinds {}
781 #-------------------------------------------------------------------------
782 # fills in the value of ascBrowVect(localkinds)
783 # given the current values of the localshow booleans
784 #-------------------------------------------------------------------------
785 proc Brow_UpdateLocalKinds {} {
786 global ascBrowVect
787 set ascBrowVect(localkinds) ""
788 foreach i $ascBrowVect(locallist) {
789 if {$ascBrowVect(localshow,$i)} {
790 lappend ascBrowVect(localkinds) $i
791 }
792 }
793 }
794
795 #
796 # proc Brow_do_UpdateChild { {TypeorVal TYPE} {atoms ATOMS} {passed PASSED}}
797 #-------------------------------------------------------------------------
798 # Updates the child box based on the current instance. Will use as
799 # default arguments the ascBrowVect(TypeorVal) variable.
800 # Calls the brow_child_list routines with
801 # these arguments to display the child (aka subitem) info. Sets the
802 # current selection back to the Brow parents Box. The C-call WILL NOT
803 # return an error if the current instance is NULL. This simplifies the
804 # code a lot!!!
805 #-------------------------------------------------------------------------
806 proc Brow_do_UpdateChild { {TypeorVal TYPE} {atoms ATOMS} {passed PASSED}} {
807 global ascBrowVect
808
809 set nok [catch {
810 brow_child_list current all $TypeorVal $atoms $passed
811 } childlist_or_err]
812 if {$nok} {
813 if {$childlist_or_err == "At leaves of the Instance Tree"} {
814 $ascBrowVect(children) delete 0 end
815 return
816 }
817 if {$childlist_or_err == "Child not found - check your root"} {
818 $ascBrowVect(children) delete 1 end
819 return
820 }
821 }
822 set childlist $childlist_or_err
823 $ascBrowVect(children) delete 0 end
824 foreach child $childlist {
825 $ascBrowVect(children) insert end $child
826 }
827 Brow_do_UpdateLocalBox
828 }
829
830 #
831 # proc Brow_SetDimNoise {n1 n2 mode}
832 #-------------------------------------------------------------------------
833 # toggle the C setting of dim noise whenever the user does.
834 #-------------------------------------------------------------------------
835 proc Brow_SetDimNoise {n1 n2 mode} {
836 global ascBrowVect
837 u_dim_setverify $ascBrowVect(dimconsistency)
838 }
839 #
840 # Brow_do_TypeorValue
841 #-------------------------------------------------------------------------
842 # This is the command that is bound to the checkbutton for setting the
843 # view in the browser to variable types or values.
844 #-------------------------------------------------------------------------
845 proc Brow_do_TypeorValue {} {
846 global ascBrowVect
847 Brow_do_UpdateChild \
848 $ascBrowVect(TypeorValue) \
849 $ascBrowVect(ShowAtoms) \
850 $ascBrowVect(HidePassed)
851 }
852
853
854 #
855 # proc Brow_Update_Edit_Buttons {}
856 #-------------------------------------------------------------------------
857 # This procedure is bound to the Edit Menu Button.
858 # Used for enabling the Edit_Menu items depending on the type of the
859 # selected instance
860 #-------------------------------------------------------------------------
861 # by default everybody is disabled until proven useful
862 proc Brow_Update_Edit_Buttons {} {
863 global ascBrowVect
864 set mb .browser.menubar.edit
865
866 menu_disable_all $mb
867 if {[$ascBrowVect(parents) size] == 0 || [catch {inst kind} ]} {
868 return
869 }
870
871 # Run method -- menu_item 0
872 #
873 if {[string compare [inst kind] "MODEL_INST"] == 0} {
874 set itype [inst type]
875 if {[llength [libr_query -methods -type $itype]] || \
876 [llength [libr_query -basemethods]]} {
877 $mb entryconfigure 0 -state normal
878 }
879 }
880 # Clear Vars -- menu_item 1
881 #
882 if {![inst atomchild]} {
883 $mb entryconfigure 1 -state normal
884 }
885 # Set Value -- menu item 3
886 #
887 $mb entryconfigure 3 -state [BrowRealSetValueState]
888
889 # read/write values always work
890 # refine button 4
891 # disable if the instance has no potential refinements or if
892 # the instance is the child of an atom.
893 if {[is_type_refined] != 0 && ![inst atomchild]} {
894 $mb entryconfigure 4 -state normal
895 }
896 # merge button 5 and resume button 7
897 if {![inst atomchild]} {
898 $mb entryconfigure 5 -state normal
899 $mb entryconfigure 7 -state normal
900 }
901 }
902
903 proc BrowSolveState {} {
904 if {![string compare [inst kind] "MODEL_INST"]} {
905 return normal
906 }
907 return disabled
908 }
909 proc BrowShowCodeState {} {
910 global ascPopInfo
911 if {[inst type]==""} {
912 return disabled
913 }
914 set lbl "Show code of [inst type]..."
915 $ascPopInfo(menu) entryconfigure $ascPopInfo(index) -label $lbl
916 return normal
917 }
918
919 proc BrowRealSetValueState {} {
920 if {[inst isassignable]} {
921 return normal
922 }
923 return disabled
924 }
925
926 proc BrowSetValueState {} {
927 global ascPopInfo
928 set lbl "Set value of [Brow_get_subname]"
929 $ascPopInfo(menu) entryconfigure $ascPopInfo(index) -label $lbl
930 return [BrowRealSetValueState]
931 }
932
933 proc BrowSetAttributeState {} {
934 global ascPopInfo
935 set lbl "Set attributes of [Brow_get_subname]"
936 $ascPopInfo(menu) entryconfigure $ascPopInfo(index) -label $lbl
937 return normal
938 }
939 #
940 # proc Brow_Update_View_Buttons {}
941 #-------------------------------------------------------------------------
942 # Disable or enable the view menu items.
943 #-------------------------------------------------------------------------
944 proc Brow_Update_View_Buttons {} {
945 # save option and hide/unhide names items
946 global ascBrowVect ascGlobalVect
947 set mb .browser.menubar.view
948
949 if {$ascGlobalVect(saveoptions) == 0} {
950 $mb entryconfigure 9 -state disabled
951 } else {
952 $mb entryconfigure 9 -state normal
953 }
954
955 if {[$ascBrowVect(parents) size] == 0 || [catch {inst kind} ]} {
956 return
957 }
958 set kind [inst kind]
959 if {$kind != "ARRAY_ENUM_INST" && $kind != "ARRAY_INT_INST"} {
960 $mb entryconfigure 4 -state normal
961 $mb entryconfigure 5 -state normal
962 } else {
963 $mb entryconfigure 4 -state disabled
964 $mb entryconfigure 5 -state disabled
965 }
966 }
967
968 #
969 # proc Brow_Update_File_Buttons {}
970 #-------------------------------------------------------------------------
971 # Disable or enable the file menu items.
972 #-------------------------------------------------------------------------
973 proc Brow_Update_File_Buttons {} {
974 # all buttons always valid currently.
975 }
976 #
977 # proc Brow_Update_Display_Buttons {}
978 #-------------------------------------------------------------------------
979 # Disable or enable the display menu items.
980 #-------------------------------------------------------------------------
981 proc Brow_Update_Display_Buttons {} {
982 global ascBrowVect
983 set mb .browser.menubar.display
984
985 menu_disable_all $mb
986 if {[$ascBrowVect(parents) size] == 0 || [catch {inst kind} ]} {
987 return
988 }
989 set kind [inst kind]
990 # Atrributes -- menu_item 0
991 # implemented for real variables
992 #$mb entryconfigure 1 -state normal
993
994
995 # Attributes item 0
996 if {$kind == "REAL_ATOM_INST"} {
997 $mb entryconfigure 0 -state normal
998 }
999
1000 # Relations -- menu_item 1
1001 # Enable if is a model instance, is a relation, or is
1002 # an array of relation. The command __brow_isrelation handles the
1003 # 2nd and 3rd Case. Also enable if the instance is a
1004 # REAL_ATOM_INST -- a little overloading here. What we
1005 # do is display the relations that the atom is incident in.
1006 if {$kind == "MODEL_INST" || $kind == "REAL_ATOM_INST"} {
1007 $mb entryconfigure 1 -state normal
1008 } else {
1009 if {[__brow_isrelation current] == 1} {
1010 $mb entryconfigure 1 -state normal
1011 } {
1012 $mb entryconfigure 1 -state disabled
1013 }
1014 }
1015
1016 # Conditional Relations -- menu_item 2
1017 # Enable if is a model instance
1018
1019 if {$kind =="MODEL_INST" } {
1020 $mb entryconfigure 2 -state normal
1021 } else {
1022 $mb entryconfigure 2 -state disabled
1023 }
1024
1025 # Logical Relations -- menu_item 3
1026 # Enable if is a model instance, is a logical relation, or is
1027 # an array of logical relation. The command __brow_islogrel handles the
1028 # 2nd and 3rd Case. Also enable if the instance is a
1029 # BOOLEAN_ATOM_INST. What we do is display the logical relations
1030 # that the atom is incident in.
1031 #
1032
1033 if {$kind == "MODEL_INST" || $kind == "BOOLEAN_ATOM_INST"} {
1034 $mb entryconfigure 3 -state normal
1035 } else {
1036 if {[__brow_islogrel current] == 1} {
1037 $mb entryconfigure 3 -state normal
1038 } else {
1039 $mb entryconfigure 3 -state disabled
1040 }
1041 }
1042
1043 # Conditional Logical Relations -- menu_item 4
1044 # Enable if is a model instance
1045
1046 if {$kind =="MODEL_INST" } {
1047 $mb entryconfigure 4 -state normal
1048 } else {
1049 $mb entryconfigure 4 -state disabled
1050 }
1051
1052
1053 # When Statement -- menu_item 5
1054 # Enable if is a model instance, is a when, or is
1055 # an array of when. The command __brow_iswhen handles the
1056 # 2nd and 3rd Case.
1057 #
1058
1059 if {$kind == "MODEL_INST"} {
1060 $mb entryconfigure 5 -state normal
1061 } else {
1062 if {[__brow_iswhen current] == 1} {
1063 $mb entryconfigure 5 -state normal
1064 } else {
1065 if {[__brow_isinstanceinwhen current] == 1 } {
1066 $mb entryconfigure 5 -state normal
1067 } else {
1068 $mb entryconfigure 5 -state disabled
1069 }
1070 }
1071 }
1072
1073 # Plot -- menu item 7
1074 #
1075 if {[b_isplottable current]} {
1076 $mb entryconfigure 7 -state normal
1077 } else {
1078 $mb entryconfigure 7 -state disabled
1079 }
1080 # Statistics -- menu item 8
1081 #
1082 $mb entryconfigure 8 -state normal
1083 }
1084 #
1085 # proc Brow_Update_Find_Buttons {}
1086 #-------------------------------------------------------------------------
1087 # Disable or enable the find menu items.
1088 #-------------------------------------------------------------------------
1089 proc Brow_Update_Find_Buttons {} {
1090 global ascBrowVect
1091 set mb .browser.menubar.find
1092
1093 menu_disable_all $mb
1094 if {[$ascBrowVect(parents) size] == 0 || [catch {inst kind} ]} {
1095 return
1096 }
1097 # Enable all that are currently implemented, some for certain types only
1098 set disabled_list [list 7 8]
1099 set enabled_list [list 0 1 2 3 4 5 6 9]
1100
1101 foreach item $enabled_list {
1102 $mb entryconfigure $item -state normal
1103 }
1104 # type
1105 if {[$ascBrowVect(parents) size] != 0} {
1106 $mb entryconfigure 1 -state normal
1107 } else {
1108 $mb entryconfigure 1 -state disabled
1109 }
1110 # eligible
1111 if {[inst kind] == "MODEL_INST"} {
1112 $mb entryconfigure 5 -state normal
1113 } else {
1114 $mb entryconfigure 5 -state disabled
1115 }
1116 # active
1117 if {[inst kind] == "MODEL_INST"} {
1118 $mb entryconfigure 6 -state normal
1119 } else {
1120 $mb entryconfigure 6 -state disabled
1121 }
1122 # operands
1123 switch [inst kind] {
1124 WHEN_INST -
1125 LREL_INST -
1126 REL_INST {
1127 $mb entryconfigure 7 -state normal
1128 }
1129 default {
1130 $mb entryconfigure 7 -state disabled
1131 }
1132 }
1133 }
1134 #
1135 # proc Brow_Update_Export_Buttons {}
1136 #-------------------------------------------------------------------------
1137 # Disable or enable the export menu items.
1138 #-------------------------------------------------------------------------
1139 proc Brow_Update_Export_Buttons {} {
1140 global ascBrowVect
1141 set mb .browser.menubar.export
1142
1143 menu_disable_all $mb
1144 if {[$ascBrowVect(parents) size] == 0 || [catch {inst kind} ]} {
1145 return
1146 }
1147 # Enable export to solver
1148 # Will later be enabled for models and arrays of models.
1149 #
1150 if {[inst kind]=="MODEL_INST"} {
1151 $mb entryconfigure 0 -state normal
1152 }
1153 # probe legal always once not null
1154 if {![inst atomchild]} {
1155 $mb entryconfigure 1 -state normal
1156 }
1157 $mb entryconfigure 2 -state normal
1158 }
1159
1160
1161 #
1162 # proc Brow_do_BooleanToggle {ndx}
1163 #-------------------------------------------------------------------------
1164 # flip the truth of child ndx in the childbox
1165 #-------------------------------------------------------------------------
1166 proc Brow_do_BooleanToggle {ndx} {
1167 global ascBrowVect
1168 set int_ndx [expr $ndx + 1]
1169 set element [brow_child_list current $int_ndx VALUE]
1170 if {$element == ""} {
1171 return
1172 }
1173 set childname [lindex [lindex $element 0] 0]
1174 #
1175 # PUT SOME SAFETY CHECKS HERE !!!!
1176 # (put some safety checks in your c code, nincompoop)
1177 #
1178 if {[catch {root $childname} ]} {return}
1179 set kind [inst kind]
1180 if {$kind == "BOOLEAN_INST" || $kind == "BOOLEAN_ATOM_INST"} {
1181 set childvalue [lindex [stripbraces $element] 2]
1182 set childname [lindex [stripbraces $element] 0]
1183 if {$childvalue == "TRUE"} {
1184 set childvalue "FALSE"
1185 } else {
1186 set childvalue "TRUE"
1187 }
1188 brow_assign $childvalue
1189 set name [Brow_get_subname].$childname
1190 oldinst;
1191 Brow_do_UpdateChild \
1192 $ascBrowVect(TypeorValue) \
1193 $ascBrowVect(ShowAtoms) \
1194 $ascBrowVect(HidePassed)
1195 HUB_Message_to_HUB BOOLEANUPDATED [sims getc]
1196 HUB_Message_to_HUB VARIABLEUPDATED [sims getc]
1197 HUB_Message_to_HUB VALUESET $name $childvalue
1198 } else {
1199 oldinst;
1200 }
1201 }
1202
1203 #
1204 # proc Brow_do_UpdateParent {qlfdid}
1205 #-------------------------------------------------------------------------
1206 # fill browser parent box with qlfdid.
1207 # This function assumes that the name list is a preformatted
1208 # name list, such as that returned from a call to qlfdid.
1209 # example : a.b['q.z.w'][12].lower_bound would be in a list as:
1210 # a b ['q.z.w'] [12] lower_bound.
1211 # The Qlfdid_SplitPretty function served well for a long time,
1212 # but choked on q['a.b.c'] (being fooled by the dots in the
1213 # symbol.
1214 #-------------------------------------------------------------------------
1215 proc Brow_do_UpdateParent {name_list} {
1216 global ascBrowVect
1217
1218 set w $ascBrowVect(parents)
1219 set len [llength $name_list]
1220 if {$len == "0"} {
1221 return
1222 }
1223 $w delete 0 end
1224 for {set c 0} {$c < $len} {incr c} {
1225 $w insert end [lindex $name_list $c]
1226 }
1227 }
1228
1229 #
1230 # proc Brow_do_Export2Probe {}
1231 #------------------------------------------------------------------------
1232 # browser export 2 probe button
1233 #------------------------------------------------------------------------
1234 proc Brow_do_Export2Probe {} {# Attached to the Browser Export Menu
1235 global ascBrowVect
1236 Probe_Import_Filtered $ascBrowVect(windowname) [Brow_get_subname]
1237 }
1238
1239 #
1240 # proc Brow_do_ExportOne2Probe {}
1241 #-------------------------------------------------------------------------
1242 # Exports a single item to the current probe.
1243 # kind of a dull thing to do.
1244 #-------------------------------------------------------------------------
1245 proc Brow_do_ExportOne2Probe {} {
1246 Probe_Import current [Brow_get_subname]
1247 }
1248
1249 #
1250 # proc Brow_Export_Any_2Browser {qlfdid}
1251 #-------------------------------------------------------------------------
1252 # focus browser on qlfdid. The call to btransfer is to set
1253 # up the instance pointers. This call actually goes through
1254 # the qlfdid search *again*. This can be made more efficient.!!
1255 # One approach would be save the search list as a UserData Node
1256 # and retrieve on the next call.
1257 #-------------------------------------------------------------------------
1258 proc Brow_Export_Any_2Browser {{name ""}} {
1259 global ascBrowVect
1260 if {$name == ""} {
1261 return
1262 }
1263 set nok [catch "qlfdid \{$name\}" errmsg]
1264 if {$nok} {
1265 set msg "Unable to locate simulation $name. "
1266 append msg $errmsg
1267 Brow_Raise_Alert $msg "Export Error"
1268 return
1269 }
1270 set name_list "$errmsg"
1271 set nok [catch "btransfer \{$name\}" errmsg]
1272 if {$nok} {
1273 Brow_Raise_Alert $errmsg
1274 return
1275 }
1276 Brow_do_UpdateParent "$name_list"
1277 Brow_do_UpdateChild \
1278 $ascBrowVect(TypeorValue) \
1279 $ascBrowVect(ShowAtoms) \
1280 $ascBrowVect(HidePassed)
1281 set ascBrowVect(currentsim) [lindex $name_list 0]
1282 Brow_Setup_Selection $ascBrowVect(parents)
1283 HUB_Message_to_HUB INSTBROWSED $name
1284 if {$ascBrowVect(visibility)} {
1285 newraise .browser
1286 }
1287
1288 }
1289
1290 # proc Brow_HandleSimsDelete
1291 #------------------------------------------------------------------------
1292 # This procedure will be registered with the HUB.
1293 # If the current sim is the sim that is to be deleted then the g_instlist
1294 # for the browser will be initialized, the currentsim (all this in C-land)
1295 # will be set to NULL. The BrowserParents and ChildBox will be returned
1296 # to a clean state. This will prepare the system for the deletion of a
1297 # simulation
1298 #------------------------------------------------------------------------
1299 proc Brow_HandleSimsDelete {sims} {
1300 global ascBrowVect
1301 if {[sims getcurrent] != $sims} {
1302 return 0;
1303 }
1304 Brow_InitBrowser;
1305 return 0;
1306 }
1307
1308 #
1309 # proc Brow_HandleInstRefined
1310 #------------------------------------------------------------------------
1311 # This procedure will be called from the HUB.
1312 # If an instance HAS been refined, this procedure will check to see
1313 # if the instance was present in the browser by checking the name
1314 # of its simulation. If it was the instance will be re-exported to the
1315 # browser. Otherwise nothing will happen.
1316 #------------------------------------------------------------------------
1317 proc Brow_HandleInstRefined {args} {
1318 if {$args == ""} {return}
1319 set inst_name [lindex $args 0]
1320 set sim_name [lindex [split $inst_name .] 0]
1321 set cur_sim [sims getcurrent]
1322 if {$cur_sim == $sim_name} {
1323 Brow_Export_Any_2Browser $inst_name
1324 return 0;
1325 }
1326 }
1327
1328 #
1329 # proc Brow_HandleInstMerged
1330 #------------------------------------------------------------------------
1331 # This procedure will be called from the HUB.
1332 # If an instance HAS been merged, this should hanlde the re-exporting to
1333 # the browser. The same process as Brow_HandleInstRefined is used...
1334 # For the time being this seems sufficient.
1335 #------------------------------------------------------------------------
1336 proc Brow_HandleInstMerged {args} {
1337 Brow_HandleInstRefined {args}
1338 }
1339
1340 #
1341 # proc Brow_HandleVariableUpdated
1342 #-------------------------------------------------------------------------
1343 # This function will be called for the browser whenever a variables
1344 # values has changed. This call will be dispatched from the HUB.
1345 #-------------------------------------------------------------------------
1346 proc Brow_HandleVariableUpdated {{list ""}} {
1347 global ascBrowVect
1348 if {"[__brow_iname]" == "NULL_INSTANCE"} {
1349 return 0;
1350 }
1351 Brow_do_UpdateChild \
1352 $ascBrowVect(TypeorValue) \
1353 $ascBrowVect(ShowAtoms) \
1354 $ascBrowVect(HidePassed)
1355 return 0;
1356 }
1357
1358 #
1359 # proc Brow_HandleTypeHidden
1360 #-------------------------------------------------------------------------
1361 # This function will be called for the browser whenever a the TYPESHOW
1362 # bit of a type description has changed. This call will be dispatched
1363 # from the HUB.
1364 #-------------------------------------------------------------------------
1365 proc Brow_HandleTypeHidden {{list ""}} {
1366 global ascBrowVect
1367 if {"[__brow_iname]" == "NULL_INSTANCE"} {
1368 return 0;
1369 }
1370 Brow_do_UpdateChild \
1371 $ascBrowVect(TypeorValue) \
1372 $ascBrowVect(ShowAtoms) \
1373 $ascBrowVect(HidePassed)
1374 return 0;
1375 }
1376
1377 #
1378 # Do a series of finds to find undefined sets, integer const,
1379 # symbol const, boolean const, real const, integer const
1380 # vars,
1381 # var flags
1382 proc Brow_do_FindUndefined {{inst current}} {
1383 }
1384
1385 #
1386 # proc Brow_do_FindbyName {}
1387 #-------------------------------------------------------------------------
1388 # Find.byname buttton in the browser
1389 #-------------------------------------------------------------------------
1390 proc Brow_do_FindbyName {} {
1391 global ascMonoEntry1 ascBrowVect
1392 set pos [setpos .browser 150 70]
1393 set current_name [Brow_get_subname]
1394 set AscMonoEntry1(font) $ascBrowVect(font)
1395 set data [VShowWindow.ascMonoEntry1 "Enter Name" $pos \
1396 "$current_name" "Find by Name"]
1397 set btn [lindex $data 0]
1398 if {$btn != 1} {
1399 return
1400 }
1401 set name [lindex $data 1]
1402 if {$name == ""} {
1403 return
1404 }
1405 Brow_Export_Any_2Browser $name
1406 }
1407
1408 # proc Brow_Setup_FindBox
1409 #-------------------------------------------------------------------------
1410 # Sets up the box of found instances so that an export to the probe
1411 # may be done. There is a much more efficient way of doing these finds
1412 # which would maintain a list in C-land, rather than get instance names
1413 # and then reconvert them when exporting. For the time being this is how
1414 # it is being done. The same applies for cliques and aliases.
1415 #-------------------------------------------------------------------------
1416 proc Brow_Setup_FindBox {list {currentname ""}} {
1417 global ascListSelectB1Box ascBrowVect
1418
1419 if {![string length $currentname]} {
1420 set currentname [Brow_get_subname]
1421 }
1422 set ascListSelectB1Box(grab) 0
1423 set ascListSelectB1Box(btn2name) TagAll
1424 set ascListSelectB1Box(btn3name) Browse
1425 set ascListSelectB1Box(btn4name) Probe
1426 set ascListSelectB1Box(btn5name) ""
1427 set ascListSelectB1Box(btn2destroy) 0
1428 set ascListSelectB1Box(btn3destroy) 0
1429 set ascListSelectB1Box(btn4destroy) 0
1430 set ascListSelectB1Box(btn2command) Browser_FindSelectAll
1431 set ascListSelectB1Box(btn3command) Browser_BrowseListSelect
1432 set ascListSelectB1Box(btn4command) Browser_ProbeListSelect
1433 set ascListSelectB1Box(title) "Instances Found in [Brow_get_subname]"
1434 set ascListSelectB1Box(toplevelname) ".browfindbytype"
1435 set ascListSelectB1Box(font) $ascBrowVect(font)
1436 set ascListSelectB1Box(selectmode) extended
1437 set ascListSelectB1Box(headline) "Instances matched:"
1438
1439
1440 if {$list==""} {puts stderr "no matches found" ; return}
1441 set newlist {}
1442 set sep .
1443 switch [inst kind] {
1444 ARRAY_INT_INST -
1445 ARRAY_ENUM_INST {
1446 set sep {}
1447 }
1448 }
1449 foreach i $list {
1450 lappend newlist $currentname$sep$i
1451 }
1452 set button [AscListSelectB1Box $newlist \
1453 250x240[setpos .browser 150 20]]
1454 }
1455
1456 #proc Brow_Convert_TRUE_FALSE
1457 #-------------------------------------------------------------------------
1458 # Normalise TRUE or FALSE to their respective numeric representations.
1459 # It is cleaner to do it here rather than in C-land. The function
1460 # __brow_find_type expects 1 or 0 for boolean type values.
1461 #-------------------------------------------------------------------------
1462 proc Brow_Convert_TRUE_FALSE {value} {
1463 if {$value == "TRUE" || $value == "true"} {
1464 return 1
1465 } elseif {$value == "FALSE" || $value == "false"} {
1466 return 0
1467 } else {
1468 return $value
1469 }
1470 }
1471
1472 #
1473 # proc Brow_FindbyType {}
1474 #-------------------------------------------------------------------------
1475 # Sets up the data to make the C-call to do the
1476 # real find_by_type.
1477 #-------------------------------------------------------------------------
1478 proc Brow_FindbyType {query_list} {
1479
1480 set type [string trim [lindex $query_list 0]]
1481 set attr [string trim [lindex $query_list 1]]
1482 set lowvalue [Brow_Convert_TRUE_FALSE [string trim [lindex $query_list 2]]]
1483 set hivalue [Brow_Convert_TRUE_FALSE [string trim [lindex $query_list 3]]]
1484 if {$type == ""} {
1485 Brow_Raise_Alert "No type given,\nto find" "Find Error"
1486 return 1
1487 }
1488 if {$attr == ""} {
1489 set nok [catch {__brow_find_type cur $type} err_or_data]
1490 } elseif {$lowvalue == ""} {
1491 set nok [catch {__brow_find_type cur $type $attr} err_or_data]
1492 } elseif {$hivalue == ""} {
1493 set nok [catch {__brow_find_type cur $type $attr $lowvalue} err_or_data]
1494 } else {
1495 set nok [catch {__brow_find_type cur $type $attr $lowvalue $hivalue} \
1496 err_or_data]
1497 }
1498 if {$nok} {
1499 Brow_Raise_Alert $err_or_data
1500 return 1
1501 }
1502 if {"$err_or_data"==""} {
1503 Brow_Raise_Alert "No matches found."
1504 return 1
1505 }
1506 Brow_Setup_FindBox $err_or_data
1507 }
1508
1509 #
1510 # proc Brow_do_FindbyType {}
1511 #-------------------------------------------------------------------------
1512 # Find.bytype button in the browser
1513 #-------------------------------------------------------------------------
1514 proc Brow_do_FindbyType {} {
1515 global AscMonoEntry4 ascBrowVect
1516
1517 # The following code assumes that AscMonoEntry4.t was explicitly
1518 # sourced rather than auto-loaded. As such the AscMonoEntry4 array
1519 # exists, and can be written to. We want to stuff the box with the
1520 # last query made.
1521
1522 set pos [setpos .browser 150 70]
1523 if {$AscMonoEntry4(count) == 0} {
1524 set AscMonoEntry4(resultNW) solver_var
1525 set AscMonoEntry4(resultNE) fixed
1526 set AscMonoEntry4(resultSW) TRUE
1527 set AscMonoEntry4(resultSE) ""
1528 }
1529 incr AscMonoEntry4(count)
1530 set AscMonoEntry4(font) $ascBrowVect(font)
1531 set data [VShowWindow.ascMonoEntry4 "Find by Type" $pos \
1532 "Type" "Attribute" "Low Value" "High Value" \
1533 $AscMonoEntry4(resultNW) $AscMonoEntry4(resultNE) \
1534 $AscMonoEntry4(resultSW) $AscMonoEntry4(resultSE)]
1535 set btn [lindex $data 0]
1536 if {$btn == "1"} {
1537 set query_list [lrange $data 1 4]
1538 set res [Brow_FindbyType $query_list]
1539 }
1540 if {$btn =="3"} {Help_button browser find.bytype}
1541 }
1542
1543 #
1544 # proc Brow_RelationType{}
1545 #-------------------------------------------------------------------------
1546 # Find.bytype button in the browser
1547 #-------------------------------------------------------------------------
1548 proc Brow_RelationType {relinst} {
1549
1550 qlfdid $inst
1551 set nok [catch {qlfdid $name} err_msg]
1552 if {$nok} {
1553 puts "$err_msg"
1554 return -2
1555 }
1556 set nok [catch {__brow_reln_relopsearch} err_msg]
1557 return $err_msg
1558 }
1559
1560
1561 #
1562 # proc Brow_RelationSatisfied {}
1563 #-------------------------------------------------------------------------
1564 #-------------------------------------------------------------------------
1565 proc Brow_do_RelationSatisfied {} {
1566 error "Brow_do_RelationSatisfied not implemented"
1567 }
1568
1569
1570 #
1571 # proc Browser_FindSelectAll {{tl ""}}
1572 #-------------------------------------------------------------------------
1573 # select all in the asclistselectb1box associate with tl, or
1574 # select all in the last asclistselectb1box created if tl == ""
1575 #-------------------------------------------------------------------------
1576 proc Browser_FindSelectAll {{tl ""}} {
1577 AscListSelectB1SelectAll "$tl"
1578 }
1579
1580 #
1581 # proc Browser_BrowseListSelect {}
1582 #-------------------------------------------------------------------------
1583 # send first of any aliases selected/clique to the browser
1584 #-------------------------------------------------------------------------
1585 proc Browser_BrowseListSelect {} {
1586 global ascListSelectB1Box
1587 set list $ascListSelectB1Box(itemselected)
1588 if {$list != ""} {
1589 set item [lindex $list 0]
1590 Brow_Export_Any_2Browser $item
1591 }
1592 }
1593 #
1594 # proc Browser_ProbeListSelect {}
1595 #-------------------------------------------------------------------------
1596 # send any aliases/clique selected to the probe as single items
1597 #-------------------------------------------------------------------------
1598 proc Browser_ProbeListSelect {} {
1599 global ascListSelectB1Box
1600 set list $ascListSelectB1Box(itemselected)
1601 Probe_Import_List current $list
1602 }
1603
1604 #
1605 # proc Brow_do_FindAliases {}
1606 #-------------------------------------------------------------------------
1607 # Find.aliases button in the browser
1608 #-------------------------------------------------------------------------
1609 proc Brow_do_FindAliases {} {
1610 global ascListSelectB1Box ascBrowVect
1611 set list ""
1612 catch {set list [aliases current]}
1613
1614 set ascListSelectB1Box(grab) 0
1615 set ascListSelectB1Box(btn2name) Browse
1616 set ascListSelectB1Box(btn3name) Probe
1617 set ascListSelectB1Box(btn4name) ""
1618 set ascListSelectB1Box(btn5name) ""
1619 set ascListSelectB1Box(btn2destroy) 0
1620 set ascListSelectB1Box(btn3destroy) 0
1621 set ascListSelectB1Box(btn4destroy) 0
1622 set ascListSelectB1Box(btn5destroy) 0
1623 set ascListSelectB1Box(btn2command) Browser_BrowseListSelect
1624 set ascListSelectB1Box(btn3command) Browser_ProbeListSelect
1625 set ascListSelectB1Box(title) "Aliases for [Brow_get_subname]"
1626 set ascListSelectB1Box(toplevelname) ".browaliases"
1627 set ascListSelectB1Box(font) $ascBrowVect(font)
1628 set ascListSelectB1Box(selectmode) extended
1629 set ascListSelectB1Box(headline) "ARE_THE_SAME instances:"
1630
1631
1632 if {$list==""} {puts stderr "no aliases" ; return}
1633 set button [AscListSelectB1Box $list \
1634 250x240[setpos .browser 150 20]]
1635 }
1636
1637 #
1638 # proc Brow_do_FindISAs {}
1639 #-------------------------------------------------------------------------
1640 # Where.created button in the browser
1641 #-------------------------------------------------------------------------
1642 proc Brow_do_FindISAs {} {
1643 global ascListSelectB1Box ascBrowVect
1644 set list ""
1645 catch {set list [isas current]}
1646
1647 set ascListSelectB1Box(grab) 0
1648 set ascListSelectB1Box(btn2name) Browse
1649 set ascListSelectB1Box(btn3name) Probe
1650 set ascListSelectB1Box(btn4name) ""
1651 set ascListSelectB1Box(btn5name) ""
1652 set ascListSelectB1Box(btn2destroy) 0
1653 set ascListSelectB1Box(btn3destroy) 0
1654 set ascListSelectB1Box(btn4destroy) 0
1655 set ascListSelectB1Box(btn5destroy) 0
1656 set ascListSelectB1Box(btn2command) Browser_BrowseListSelect
1657 set ascListSelectB1Box(btn3command) Browser_ProbeListSelect
1658 set ascListSelectB1Box(title) "[Brow_get_subname] created as"
1659 set ascListSelectB1Box(toplevelname) ".browisas"
1660 set ascListSelectB1Box(font) $ascBrowVect(font)
1661 set ascListSelectB1Box(selectmode) extended
1662 set ascListSelectB1Box(headline) "Constructed instances:"
1663
1664
1665 if {$list==""} {puts stderr "no isas, which is very odd!" ; return}
1666 set button [AscListSelectB1Box $list \
1667 250x240[setpos .browser 150 20]]
1668 }
1669 #
1670 # proc Brow_do_FindClique {}
1671 #-------------------------------------------------------------------------
1672 # Find.clique button in the browser
1673 #-------------------------------------------------------------------------
1674 proc Brow_do_FindClique {} {
1675 global ascListSelectB1Box ascBrowVect
1676 set list ""
1677 catch {set list [cliques]}
1678
1679 set ascListSelectB1Box(grab) 0
1680 set ascListSelectB1Box(btn2name) TagAll
1681 set ascListSelectB1Box(btn3name) Browse
1682 set ascListSelectB1Box(btn4name) Probe
1683 set ascListSelectB1Box(btn5name) ""
1684 set ascListSelectB1Box(btn2destroy) 0
1685 set ascListSelectB1Box(btn3destroy) 0
1686 set ascListSelectB1Box(btn4destroy) 0
1687 set ascListSelectB1Box(btn2command) Browser_FindSelectAll
1688 set ascListSelectB1Box(btn3command) Browser_BrowseListSelect
1689 set ascListSelectB1Box(btn4command) Browser_ProbeListSelect
1690 set ascListSelectB1Box(title) "Clique of [Brow_get_subname]"
1691 set ascListSelectB1Box(toplevelname) ".browclique"
1692 set ascListSelectB1Box(font) $ascBrowVect(font)
1693 set ascListSelectB1Box(selectmode) extended
1694 set ascListSelectB1Box(headline) "ARE_ALIKE instances:"
1695
1696
1697 if {$list==""} {puts stderr "no clique!" ; return}
1698 set button [AscListSelectB1Box $list \
1699 250x240[setpos .browser 150 20]]
1700 }
1701 #
1702 # proc Brow_do_FindFixed {fixed}
1703 #-------------------------------------------------------------------------
1704 # Find free/fixed variables button in the browser popup
1705 #-------------------------------------------------------------------------
1706 proc Brow_do_FindFixed {fixed} {
1707 global ascListSelectBox ascSolvVect ascBrowVect
1708
1709 switch $fixed {
1710 TRUE {
1711 Brow_FindbyType {real fixed 1}
1712 }
1713 FALSE -
1714 default {
1715 Brow_FindbyType {real fixed 0}
1716 }
1717 }
1718 }
1719 #
1720 # proc Brow_do_FindEligible {}
1721 #-------------------------------------------------------------------------
1722 # Find.eligible variables button in the browser
1723 #-------------------------------------------------------------------------
1724 proc Brow_do_FindEligible {} {
1725 global ascListSelectBox ascSolvVect ascBrowVect
1726
1727 set list {}
1728 set prefix "[Brow_get_subname]"
1729 if {[slv_checksys] && 0 == \
1730 [string compare [sims getc] [lindex [split [slv_get_pathname] .] 0]]} {
1731 set list [__brow_find_type cur solver_var message eligible]
1732 set ascListSelectBox(title) "Eligible in Solver"
1733 } else {
1734 set list ""
1735 set refresh 0
1736 catch {set list [lindex [brow_find_eligible 2] 0]}
1737 set ascListSelectBox(title) "Eligible in [Brow_get_subname]"
1738 }
1739
1740 set ascListSelectBox(grab) 1
1741 set ascListSelectBox(btn3name) ""
1742 set ascListSelectBox(btn4name) ""
1743 set ascListSelectBox(btn5name) ""
1744 set ascListSelectBox(toplevelname) ".broweligible"
1745 set ascListSelectBox(font) $ascBrowVect(font)
1746 set ascListSelectBox(selectmode) browse
1747 set ascListSelectBox(headline) "Select to fix one of:"
1748 set newlist ""
1749
1750 foreach i $list {
1751 lappend newlist $prefix.$i
1752 }
1753 if {$newlist==""} {
1754 puts stderr "No variables eligible to be fixed."
1755 Brow_Raise_Alert "No variables eligible\n to be fixed." "DOF analysis"
1756 return
1757 }
1758 set alist [lsort $newlist]
1759 set button [AscListSelectBox $newlist \
1760 250x240[setpos .browser 50 20]]
1761 if {$button==2} {return}
1762 Solve_EligListSelect 0 ;# what is this doing here?
1763 }
1764
1765 #
1766 # proc Brow_do_FindActiveRels {}
1767 #-------------------------------------------------------------------------
1768 # Find.active rels button in the browser
1769 #-------------------------------------------------------------------------
1770 proc Brow_do_FindActiveRels {} {
1771 entertrace
1772 global ascListSelectB1Box ascSolvVect ascBrowVect
1773
1774 set list {}
1775 set prefix "[Brow_get_subname]"
1776 if {[slv_checksys] && 0 == \
1777 [string compare [sims getc] [lindex [split [slv_get_pathname] .] 0]]} {
1778 set list [__brow_find_type cur relation message active]
1779 set ascListSelectB1Box(title) "Active Relations in Solver"
1780 } else {
1781 set list ""
1782 set refresh 0
1783 catch {set list [lindex [brow_find_activerels 2] 0]}
1784 set ascListSelectB!Box(title) "Active Relations in [Brow_get_subname]"
1785 }
1786
1787 set ascListSelectB1Box(grab) 0
1788 set ascListSelectB1Box(btn2name) TagAll
1789 set ascListSelectB1Box(btn3name) Browse
1790 set ascListSelectB1Box(btn4name) Probe
1791 set ascListSelectB1Box(btn5name) ""
1792 set ascListSelectB1Box(btn2destroy) 0
1793 set ascListSelectB1Box(btn3destroy) 0
1794 set ascListSelectB1Box(btn4destroy) 0
1795 set ascListSelectB1Box(btn2command) Browser_FindSelectAll
1796 set ascListSelectB1Box(btn3command) Browser_BrowseListSelect
1797 set ascListSelectB1Box(btn4command) Browser_ProbeListSelect
1798 set ascListSelectB1Box(title) "Active Relations of [Brow_get_subname]"
1799 set ascListSelectB1Box(toplevelname) ".browactive"
1800 set ascListSelectB1Box(font) $ascBrowVect(font)
1801 set ascListSelectB1Box(selectmode) extended
1802 set ascListSelectB1Box(headline) "Active Relations:"
1803
1804 foreach i $list {
1805 lappend newlist $prefix.$i
1806 }
1807 if {$newlist==""} {
1808 puts stderr "No active relations."
1809 Brow_Raise_Alert "No Active Relation\n" "Solver Configuration"
1810 return
1811 }
1812 set alist [lsort $newlist]
1813 set button [AscListSelectB1Box $newlist \
1814 250x240[setpos .browser 150 20]]
1815 return
1816 leavetrace
1817 }
1818
1819 #
1820 # proc Brow_do_FindRels {}
1821 #-------------------------------------------------------------------------
1822 # Find.relations button in the browser
1823 #-------------------------------------------------------------------------
1824 proc Brow_do_FindRels {} {
1825 puts stdout "Finding relations not implemented"
1826 }
1827 #
1828 # proc Brow_do_FindOpers {}
1829 #-------------------------------------------------------------------------
1830 # Find.operands button in the browser
1831 #-------------------------------------------------------------------------
1832 proc Brow_do_FindOpers {} {
1833 set list [inst operands -current]
1834 set root "[Brow_get_partname]"
1835 if {[llength $list]} {
1836 Brow_Setup_FindBox $list $root
1837 } else {
1838 Brow_Raise_Alert "No operands found in [Brow_get_subname]" \
1839 "Operands message"
1840 }
1841 }
1842 #
1843 # proc Brow_do_FindParents {}
1844 #-------------------------------------------------------------------------
1845 # Find.parents button in the browser
1846 #-------------------------------------------------------------------------
1847 proc Brow_do_FindParents {} {
1848 puts stdout "Finding parents not implemented"
1849 }
1850 #
1851 # proc Brow_do_FindPendings {}
1852 #-------------------------------------------------------------------------
1853 # Find.pendings button in the browser
1854 #-------------------------------------------------------------------------
1855 proc Brow_do_FindPendings {} {
1856 if {[bnumpendings instance current] > 0} {
1857 puts "\n--------------------------------------------------------------\n\
1858 Pendings statements for the instance\n"
1859 bwritependings [sims getcurrentsim]
1860 puts "\n--------------------------------------------------------------"
1861 return;
1862 } else {
1863 puts "\n--------------------------------------------------------------\n"
1864 puts "No pendings statements for the browser instance\n"
1865 }
1866 }
1867
1868 #
1869 # proc Qlfdid_SplitPretty {qlfdid}
1870 #-------------------------------------------------------------------------
1871 # parse qlfdid: .->spc [ -> spc[
1872 #-------------------------------------------------------------------------
1873 proc Qlfdid_SplitPretty {name} {
1874 set b $name
1875 regsub -all {\.} $b " " b;
1876 regsub -all {\[} $b " \[" b;
1877 regsub -all {\]} $b "\]" b;
1878 return $b;
1879 }
1880
1881 #
1882 # Brow_Setup_Selection {listbox {startpos "end"} {endpos "end"}}
1883 #-------------------------------------------------------------------------
1884 # clear present list selection and select from startpos to endpos
1885 #-------------------------------------------------------------------------
1886 proc Brow_Setup_Selection {listbox {startpos "end"} {endpos "end"}} {
1887
1888 $listbox selection clear 0 end
1889 $listbox selection set $startpos $endpos
1890 }
1891
1892 #
1893 # proc Browser_ProcShowCode
1894 #-------------------------------------------------------------------------
1895 # show procedure code for each procedure in $ascListSelectBox(itemselected)
1896 # assuming each item is an proc of the current instance.
1897 #-------------------------------------------------------------------------
1898 proc Browser_ProcShowCode {currentname} {
1899 global ascListSelectBox ascUtilVect ascDispVect
1900 if {$ascListSelectBox(itemselected)==""} {return}
1901
1902 DispClear;
1903 qlfdid $currentname
1904 foreach i $ascListSelectBox(itemselected) {
1905 set outputfile [FileUniqueName "$ascUtilVect(asctmp)/ascdisproc"]
1906 bgetproc $i $outputfile search
1907 set f [open $outputfile]
1908 # read chunks of 10k
1909 while {![eof $f]} {
1910 $ascDispVect(textBox) insert end [read $f 10000]
1911 }
1912 close $f
1913 file delete $outputfile
1914 }
1915 DispSetEntry "Method code from $currentname"
1916 newraise .display
1917 }
1918
1919 #
1920 # proc Browser_do_Methods {}
1921 #-------------------------------------------------------------------------
1922 # browser Edit.RunMethods button
1923 #-------------------------------------------------------------------------
1924 proc Browser_do_Methods {} {
1925 global ascBrowVect
1926 global ascListSelectBox
1927 global ascLibrVect
1928
1929 set currentname [Brow_get_subname]
1930 set ascListSelectBox(grab) 0
1931 set ascListSelectBox(btn3name) Show
1932 set ascListSelectBox(btn4name) ""
1933 set ascListSelectBox(btn5name) ""
1934 set ascListSelectBox(btn3destroy) 0
1935 set ascListSelectBox(btn3command) "Browser_ProcShowCode $currentname"
1936 set ascListSelectBox(headline) "Methods ($currentname):"
1937 set ascListSelectBox(toplevelname) ".browprocedures"
1938 set ascListSelectBox(font) $ascBrowVect(font)
1939 set ascListSelectBox(selectmode) extended
1940 set ascListSelectBox(title) "Select Method"
1941
1942 set typename [inst type]
1943 set proc_list {}
1944 if {[catch {set proc_list [libr_query -methods -type $typename]} err]} {
1945 return;
1946 }
1947 if {$proc_list=="1" && [llength [libr_query -basemethods]] == 0} {
1948 return
1949 }
1950 foreach i [libr_query -basemethods] {
1951 if {[lsearch -exact $proc_list $i] == -1} {
1952 lappend proc_list $i
1953 }
1954 }
1955 set button [AscListSelectBox [lsort -dictionary $proc_list] \
1956 250x240[setpos .browser 50 50]]
1957 if {$button==2} {return}
1958 set Proc_list $ascListSelectBox(itemselected)
1959 if {$Proc_list != "" } {
1960 foreach Proc $Proc_list {
1961 if {[string length $Proc]==0} {
1962 continue
1963 }
1964 set nok [catch {
1965 brow_runmethod -method $Proc \
1966 -qlfdid $currentname \
1967 -backtrace $ascLibrVect(btuifstop) \
1968 -stopOnErr $ascLibrVect(ignorestop)
1969 } err]
1970 puts -nonewline "Running method $Proc in "
1971 puts $currentname
1972 if {$nok} {
1973 Brow_Raise_Alert $err" "Method Error"
1974 return 1
1975 }
1976 HUB_Message_to_HUB PROCRUN $currentname.$Proc
1977 }
1978 Brow_do_UpdateChild \
1979 $ascBrowVect(TypeorValue) \
1980 $ascBrowVect(ShowAtoms) \
1981 $ascBrowVect(HidePassed)
1982 HUB_Message_to_HUB VARIABLEUPDATED [sims getc]
1983 HUB_Message_to_HUB WHENVARUPDATED [sims getc]
1984 #
1985 # This is not required anymore. Its consequences are now a part
1986 # of the consequences of WHENVARUPDATED.
1987 # (wish this were TRUE: baa 6/11/97
1988 HUB_Message_to_HUB BOOLEANUPDATED [sims getc]
1989 #
1990 return 0;
1991 }
1992 Brow_Raise_Alert "No method was selected" "Intialization Error"
1993 return 1;
1994 }
1995
1996 #
1997 # proc Browser_do_ClearVars {}
1998 #-------------------------------------------------------------------------
1999 # browser Edit.ClearVars button
2000 #-------------------------------------------------------------------------
2001 proc Browser_do_ClearVars {} {
2002 Solve_do_Flush do_not_record
2003 free_all_vars
2004 HUB_Message_to_HUB CLEARVARS [Brow_get_subname]
2005 }
2006
2007 #
2008 # proc Browser_do_SetValue {{toplevel self} {instname ""}}
2009 #-------------------------------------------------------------------------
2010 # browser Edit.setvalue button
2011 # if a name is supplied, sets that value instead of current instance
2012 #-------------------------------------------------------------------------
2013 proc Browser_do_SetValue {{toplevel self} {instname ""}} {
2014 global ascBrowVect
2015 global AscEntryBox2
2016
2017 if {[string compare $toplevel "self"]==0} {
2018 set toplevel $ascBrowVect(windowname)
2019 }
2020 if {$instname == ""} {
2021 set instname [Brow_get_subname]
2022 }
2023 if {[catch {qlfdid $instname} errmsg]} {
2024 append msg "Browser_do_SetValue unable to find" $instname
2025 error $msg "This isn't a bug-- it's a user mistake"
2026 }
2027 if {![inst isassignable search]} {
2028 return
2029 }
2030
2031 if {[catch {set cur_value [u_browgetval search]} err]} {
2032 set cur_value [inst atomvalue search]
2033 set cur_units "\*"
2034 } else {
2035 set cur_value [stripbraces $cur_value]
2036 set cur_units [lindex [split $cur_value] 1]
2037 set cur_value [lindex $cur_value 0]
2038 }
2039 set pos [setpos $toplevel 65 65]
2040 set title {}
2041 append title $instname
2042 switch [inst kind search] {
2043 SYMBOL_INST -
2044 SYMBOL_ATOM_INST -
2045 SYMBOL_CONSTANT_INST {
2046 append title "\nValue / Units\n (do not include ' around value)"
2047 }
2048 default {
2049 append title "\nValue / Units"
2050 }
2051 }
2052 set data [VShowWindow.ascMonoEntry2 $title $pos $cur_value $cur_units]
2053 set btn [lindex $data 0]
2054 if {$btn == 1 && ( \
2055 [string compare $cur_value [lindex $data 1]] !=0 || \
2056 [string compare $cur_units [lindex $data 2]] !=0) } {
2057 set value [lindex $data 1]
2058 set units [lindex $data 2]
2059 brow_assign -search $value $units
2060 HUB_Message_to_HUB VALUESET $instname $value $units
2061 Brow_do_UpdateChild \
2062 $ascBrowVect(TypeorValue) \
2063 $ascBrowVect(ShowAtoms) \
2064 $ascBrowVect(HidePassed)
2065 # Brow_do_UpdateChild (in local Core update) moves qlfdid.
2066 qlfdid $instname
2067 if {[inst iswhenvar search]} {
2068 HUB_Message_to_HUB WHENVARUPDATED $instname
2069 #
2070 # solver needs to know about potential changes of configuration
2071 #
2072 } else {
2073 if {[inst kind search]=="BOOLEAN_INST" || \
2074 [inst kind search]=="BOOLEAN_ATOM_INST"} {
2075 HUB_Message_to_HUB BOOLEANUPDATED $instname
2076 #
2077 # solver needs to know about potential dof changes
2078 #
2079 } else {
2080 HUB_Message_to_HUB VARIABLEUPDATED $instname
2081 }
2082 }
2083 }
2084 }
2085 #
2086 proc Brow_InitSetvalue {} {
2087 global ascSetvalueVect ascBrowVect
2088 set ascSetvalueVect(basenamelist) [list rootname]
2089 set ascSetvalueVect(namelist) [list rootname]
2090 set ascSetvalueVect(rootname) ""
2091 set ascSetvalueVect(rootname.label) "Assigning in:"
2092 set ascSetvalueVect(rootname.type) string
2093
2094 set ascSetvalueVect(grab) 1
2095 set ascSetvalueVect(cancellable) 1
2096 set ascSetvalueVect(npages) 1
2097 set ascSetvalueVect(toplevel) .setvalue
2098 set ascSetvalueVect(titlebase) "Set instance values: "
2099 set ascSetvalueVect(helpcommand) {Help_button browser.set.values}
2100 set ascSetvalueVect(whenokcommand) Brow_CheckSetvaluesInput
2101
2102 set ascParPageVect(btn_font) $ascBrowVect(font)
2103 set ascParPageVect(lbl_font) $ascBrowVect(font)
2104 }
2105
2106 #
2107 # proc Brow_CheckSetvaluesInput {}
2108 #------------------------------------------------------------------------
2109 # Checks the string entries in a for not containing ' characters.
2110 # checks ${c}__uni_ string entries in a for being legal units.
2111 #------------------------------------------------------------------------
2112 proc Brow_CheckSetvaluesInput {} {
2113 # this shouldn't be necessary, ASSIGN should be robust to bad input
2114 # and we should catch around ASSIGN.
2115 }
2116
2117 #
2118 # proc Brow_SetvalueConfigure {name}
2119 #------------------------------------------------------------------------
2120 # Sets up the namelist in ascSetvalueVect based on name.
2121 # Do not call this with a bad instance name.
2122 # On return, ascSetvalueVect(vallist) is the list of leaf names of
2123 # parts in instance $name which were offered to the user for assignment.
2124 # Does not unroll arrays.
2125 # If a part named foo in vallist is of type 'real' then there will also be
2126 # an element foo__uni_ of type 'string'
2127 # there may be other elements in ascSetvalueVect, but they are irrelevant
2128 # if not in vallist.
2129 #------------------------------------------------------------------------
2130 proc Brow_SetvalueConfigure {name} {
2131 global ascSetvalueVect
2132
2133 set ascSetvalueVect(namelist) $ascSetvalueVect(basenamelist)
2134 set ascSetvalueVect(entrywidth) 20
2135 set ascSetvalueVect(rootname) $name
2136 set ascSetvalueVect(rootname.choices) $ascSetvalueVect(rootname)
2137 set ascSetvalueVect(title) $ascSetvalueVect(titlebase)
2138 append ascSetvalueVect(title) $ascSetvalueVect(rootname)
2139 # if name is assignable (atomic & !relation), create rootvalue
2140 # entry based on type.
2141 # get childlist of name, find assignables and their types,
2142 # build name list, including a units entry for reals
2143 qlfdid $name ;# set g_search_inst in C land
2144 set clist [inst child search] ;# want the full list, not just viewables
2145 set ascSetvalueVect(vallist) ""
2146 set counter 0
2147 set page 1
2148 foreach c $clist {
2149 incr counter
2150 if {$page * 10 < $counter} { incr page }
2151 set cname [Brow_childname $name $c]
2152 if {[catch {qlfdid $cname} errmsg] || ![inst isassignable search]} {
2153 continue ;# skip NULL children and unassignables
2154 }
2155 lappend ascSetvalueVect(namelist) $c
2156 lappend ascSetvalueVect(vallist) $c
2157 set ascSetvalueVect($c.label) $c
2158 set ascSetvalueVect($c.page) $page
2159 set tmplen 0
2160 catch {set tmplen [string length [inst atomvalue search]]}
2161 if {$tmplen && $tmplen < 40 && $tmplen > $ascSetvalueVect(entrywidth)} {
2162 set ascSetvalueVect(entrywidth) $tmplen
2163 }
2164 switch [inst kind search] {
2165 REAL_INST -
2166 REAL_ATOM_INST -
2167 REAL_CONSTANT_INST {
2168 set cur_value ""
2169 set cur_units ""
2170 if {[catch {set cur_value [u_browgetval search]} \
2171 err]} {
2172 set cur_value [inst atomvalue search]
2173 set cur_units "\*"
2174 } else {
2175 set cur_value [lindex $cur_value 0]
2176 set cur_units [lindex [split $cur_value] 1]
2177 set cur_value [lindex $cur_value 0]
2178 }
2179 set ascSetvalueVect($c) $cur_value
2180 set ascSetvalueVect($c.type) real
2181 set ascSetvalueVect($c.old) $cur_value
2182 lappend ascSetvalueVect(namelist) ${c}__uni_
2183 set tmplen 0
2184 catch {set tmplen [string length $cur_units]}
2185 if {$tmplen < 40 && \
2186 $tmplen > $ascSetvalueVect(entrywidth)} {
2187 set ascSetvalueVect(entrywidth) $tmplen
2188 }
2189 set ascSetvalueVect(${c}__uni_) $cur_units
2190 set ascSetvalueVect(${c}__uni_.type) string
2191 set ascSetvalueVect(${c}__uni_.page) $page
2192 set ascSetvalueVect(${c}__uni_.old) $cur_units
2193 set ascSetvalueVect(${c}__uni_.label) "Units for "
2194 append ascSetvalueVect(${c}__uni_.label) $c
2195 }
2196 INTEGER_INST -
2197 INTEGER_ATOM_INST -
2198 INTEGER_CONSTANT_INST {
2199 set ascSetvalueVect($c) [inst atomvalue search]
2200 set ascSetvalueVect($c.old) $ascSetvalueVect($c)
2201 set ascSetvalueVect($c.type) int
2202 }
2203 BOOLEAN_INST -
2204 BOOLEAN_ATOM_INST -
2205 BOOLEAN_CONSTANT_INST {
2206 set ascSetvalueVect($c) [inst atomvalue search]
2207 switch $ascSetvalueVect($c) {
2208 FALSE {
2209 set ascSetvalueVect($c) 0
2210 set ascSetvalueVect($c.old) 0
2211 set ascSetvalueVect($c.type) bool
2212 }
2213 TRUE {
2214 set ascSetvalueVect($c) 1
2215 set ascSetvalueVect($c.old) 1
2216 set ascSetvalueVect($c.type) bool
2217 }
2218 UNDEFINED {
2219 set ascSetvalueVect($c) UNDEFINED
2220 set ascSetvalueVect($c.old) UNDEFINED
2221 set ascSetvalueVect($c.type) bool
2222 }
2223 default {
2224 error \
2225 "Brow_SetvalueConfigure bool confused"
2226 }
2227 }; # END inner switch
2228 }
2229 SYMBOL_INST -
2230 SYMBOL_ATOM_INST -
2231 SYMBOL_CONSTANT_INST {
2232 set ascSetvalueVect($c) [inst atomvalue search]
2233 set ascSetvalueVect($c.old) $ascSetvalueVect($c)
2234 set ascSetvalueVect($c.type) string
2235 }
2236 SET_ATOM_INST -
2237 SET_INST {
2238 # do nothing with sets yet; # too complicated
2239 }
2240 default {
2241 # above should be a complete listing of our assignable kinds.
2242 error \
2243 "Brow_SetvalueConfigure can't cope with [inst kind search]"
2244 }
2245 }
2246 }
2247 set ascSetvalueVect(npages) $page
2248 }
2249
2250 #
2251 # proc Brow_childname {root leaf}
2252 #------------------------------------------------------------------------
2253 # Figures out how to add leaf to root and returns the combination.
2254 # Basically, this centralizes the checks for gluing array elements
2255 # to root names in qualified id production.
2256 #------------------------------------------------------------------------
2257 proc Brow_childname {root leaf} {
2258 if {$leaf == ""} {return $root}
2259 if { [string index $leaf 0] != "\["} {
2260 append root .$leaf
2261 } else {
2262 append root $leaf
2263 }
2264 return $root
2265 }
2266
2267 #
2268 # proc Browser_SetvalueBox {caller name}
2269 #------------------------------------------------------------------------
2270 # Caller is the name of the toplevel window calling this function.
2271 # Set values dialog for assignable children of name.
2272 # $name may point to any sort of instance that has assignable children.
2273 # If nothing to do, returns silently.
2274 # name is a full qualified identifier.
2275 # Uses the ASSIGN operator because we can't cope with the
2276 # hub event generation here without creating an impenetrable mess.
2277 #------------------------------------------------------------------------
2278 proc Browser_SetvalueBox {caller name} {
2279 global ascProbVect
2280 global ascSetvalueVect
2281
2282 Brow_SetvalueConfigure $name
2283 if {$ascSetvalueVect(vallist) == ""} {
2284 return; # don't call parpage as it may barf on empty.
2285 }
2286 ascParPage ascSetvalueVect [setpos $caller 0 0] 1 0
2287 if {$ascSetvalueVect(__,cancelled)} {return}
2288 foreach i $ascSetvalueVect(vallist) {
2289 switch $ascSetvalueVect($i.type) {
2290 real {
2291 if {$ascSetvalueVect($i) == "UNDEFINED"} {continue}
2292 if {$ascSetvalueVect($i.old) != $ascSetvalueVect($i) || \
2293 $ascSetvalueVect(${i}__uni_.old) != \
2294 $ascSetvalueVect(${i}__uni_)} {
2295 puts $i
2296 if {$i != "__atom_value__"} {
2297 if {[catch {ASSIGN [Brow_childname $name $i] \
2298 $ascSetvalueVect($i) $ascSetvalueVect(${i}__uni_)
2299 } errmsg]} {
2300 append errmsg ": " $i " " $ascSetvalueVect($i) " "
2301 append errmsg $ascSetvalueVect(${i}__uni_)
2302 puts $errmsg
2303 }
2304 } else {
2305 if {[catch {ASSIGN $name $ascSetvalueVect($i) \
2306 $ascSetvalueVect(${i}__uni_)
2307 } errmsg]} {
2308 append errmsg ": " $name " " $ascSetvalueVect($i) " "
2309 append errmsg $ascSetvalueVect(${i}__uni_)
2310 puts $errmsg
2311 }
2312 }
2313 }
2314 }
2315 int -
2316 bool -
2317 string {
2318 if {$ascSetvalueVect($i) == "UNDEFINED"} {continue}
2319 if {$ascSetvalueVect($i.old) != $ascSetvalueVect($i)} {
2320 if {$i != "__atom_value__"} {
2321 if {[catch {ASSIGN [Brow_childname $name $i] \
2322 $ascSetvalueVect($i)} errmsg]} {
2323 append errmsg ": " $i " " $ascSetvalueVect($i) " "
2324 append errmsg $ascSetvalueVect(${i}__uni_)
2325 puts $errmsg
2326 }
2327 } else {
2328 if {[catch {ASSIGN $name $ascSetvalueVect($i)} errmsg]} {
2329 append errmsg ": " $name " " $ascSetvalueVect($i) " "
2330 append errmsg $ascSetvalueVect(${i}__uni_)
2331 puts $errmsg
2332 }
2333 }
2334 }
2335 }
2336 default {
2337 error "binary data type in Brow_SetvalueBox???"
2338 }
2339 }
2340 }
2341 }
2342
2343 #===========================================
2344 #
2345 # proc Brow_do_Read {}
2346 #-------------------------------------------------------------------------
2347 # Read values back into an instance.
2348 # instance should have at least the namespace of the instance which was used
2349 # when writing the read file.
2350 # Instance doesn't have to be in the browser.
2351 #-------------------------------------------------------------------------
2352 proc Brow_do_Read {} {
2353 global ascBrowVect
2354 set defaultname [file dirname $ascBrowVect(filename)]
2355 set filename [tk_getOpenFile \
2356 -defaultextension "" \
2357 -filetypes $ascBrowVect(filetypes) \
2358 -initialdir $defaultname \
2359 -parent .browser \
2360 -title {Read saved values file}]
2361
2362 if {$filename == "" || [file isdirectory $filename]} {
2363 return 1;
2364 } else {
2365 puts "Reading values from $filename"
2366 if {[catch {Brow_parse_values $filename 0} err]} {
2367 puts "Problem reading values file:"
2368 puts "error>>>$err<<<"
2369 }
2370 set ascBrowVect(filename) $filename
2371 set newext "[file extension $filename]"
2372 if {$newext != ""} {
2373 set ascBrowVect(lastreadextension) $newext
2374 ascresort_filetypes ascBrowVect lastreadextension
2375 }
2376
2377 update idletasks
2378 }
2379 # here we should be grabbing the first line of filename, taking its
2380 #second to last item, and issuing the updated calls with that sim name.
2381 HUB_Message_to_HUB VARIABLEUPDATED
2382 HUB_Message_to_HUB BOOLEANUPDATED
2383 HUB_Message_to_HUB DATAREAD $filename
2384 }
2385
2386 proc Brow_do_SaveOptions {} {
2387 View_Save_Window_Options browser
2388 }
2389 #
2390 # proc Brow_do_Write {}
2391 #-------------------------------------------------------------------------
2392 # write real and boolean values from current instance downward to file.
2393 # not particularly picky about what ARE_THE_SAMEd parts get called.
2394 # The prefix that is used at the moment is : "qassgn3 \{".
2395 # "qassgn3" is the fastest version of the reading code.
2396 # The dummy_name is a requirement of teh bwritevalues command.
2397 #-------------------------------------------------------------------------
2398 proc Brow_do_Write {} {
2399 global ascBrowVect
2400
2401 set defaultname $ascBrowVect(filename)
2402 set filename [tk_getSaveFile \
2403 -defaultextension "" \
2404 -filetypes $ascBrowVect(filetypes) \
2405 -initialfile $defaultname \
2406 -parent .browser \
2407 -title {Save variable values}]
2408
2409 if {$filename == ""} {
2410 return 1;
2411 } {
2412 set ascBrowVect(filename) $filename
2413 bwritevalues $filename "qassgn3 \{" current "dummy_name" #fast
2414 puts "Wrote values file $filename."
2415 }
2416 HUB_Message_to_HUB DATAWRITE [Brow_get_subname] $filename
2417 }
2418
2419 #
2420 # proc Browser_RefineShowCode {}
2421 #-------------------------------------------------------------------------
2422 # display code of type (found in ascListSelectBox) in the display window
2423 #-------------------------------------------------------------------------
2424 proc Browser_RefineShowCode {} {
2425 global ascListSelectBox ascUtilVect ascDispVect
2426
2427 if {$ascListSelectBox(itemselected)==""} {return}
2428 set type [lindex $ascListSelectBox(itemselected) 0]
2429 set inputfile [file_by_type $type]
2430 set outputfile [FileUniqueName "$ascUtilVect(asctmp)/ascdiscode"]
2431 set result [Disp_ShowCode $type $inputfile $outputfile]
2432 if {$result == "0"} {
2433 FastFileInText $ascDispVect(textBox) $outputfile
2434 }
2435 file delete $outputfile
2436 DispSetEntry "Refinement code of $type"
2437 newraise .display
2438 }
2439
2440 #
2441 # proc Browser_Refine {}
2442 #-------------------------------------------------------------------------
2443 # browser Edit.refine button
2444 # target_type is the target_type to refine to. This procedure does the
2445 # actual work of refining the types by calling the C-code. inst_context
2446 # specifies whether the current or search instance.
2447 # NOTE: The current sim will be re-exported to the browser. This is a fast
2448 # operation and ensures that none of the browser instances are all update
2449 # after the refine has been done, and that they are not looking at *moved*
2450 # instances.
2451 #-------------------------------------------------------------------------
2452 proc Browser_Refine {target_type {inst_context "current"}} {
2453 if {$target_type == ""} {return 1}
2454 set nok [catch "brefine $target_type $inst_context" err_msg]
2455 if {$nok} {
2456 Brow_Raise_Alert "$err_msg" "Refine Error";
2457 return 1;
2458 } {
2459 return 0;
2460 }
2461 }
2462 #
2463 # proc Browser_do_Refine {}
2464 #-------------------------------------------------------------------------
2465 # browser Edit.refine button
2466 # target_type is the target_type to refine to.
2467 #-------------------------------------------------------------------------
2468 proc Browser_do_Refine {} {
2469 global ascBrowVect
2470
2471 global ascListSelectBox
2472 set ascListSelectBox(grab) 1
2473 set ascListSelectBox(btn4name) ""
2474 set ascListSelectBox(btn3name) Show
2475 set ascListSelectBox(btn5name) ""
2476 set ascListSelectBox(btn3destroy) 0
2477 set ascListSelectBox(btn3command) Browser_RefineShowCode
2478 set ascListSelectBox(headline) "Eligible types for refinement:"
2479 set ascListSelectBox(toplevelname) ".browrefine"
2480 set ascListSelectBox(selectmode) browse
2481 set ascListSelectBox(font) $ascBrowVect(font)
2482 set ascListSelectBox(title) "Refining [inst type] [Brow_get_subname]:"
2483
2484 set type [inst type]
2485 set button [AscListSelectBox [drefines_meall $type] \
2486 250x240[setpos .browser 50 50]]
2487 if {$button==2} {return 1}
2488 if {$button==1} {
2489 set target_type $ascListSelectBox(itemselected)
2490 }
2491 if {$target_type ==""} {
2492 Brow_Raise_Alert "You must specify\na type." "Refine Error";
2493 return 1;
2494 }
2495 #
2496 # Save the old names so that we can set back up
2497 # the browser when finished. Inform all interested parties
2498 # that the move is about to take place. THEN do the refine.
2499 #
2500 set old_name [Brow_get_subname]
2501 set old_sim [sims getcurrent]
2502 HUB_Message_to_HUB INSTANCEMOVED $old_sim
2503 set nok [Browser_Refine $target_type current]
2504 if {$nok} { return 1 }
2505
2506 # The following should handle the re-exporting of the given
2507 # instance to the Browser. We don't do it here directly as a
2508 # we need to send the message to the HUB that something WAS refined
2509 # in any Case but don't want to set up a potential infinite loop, or
2510 # end up calling the re-export code twice.
2511
2512 HUB_Message_to_HUB INSTREFINED $old_name $target_type
2513 }
2514
2515 # proc Browser_Merge {}
2516 #-------------------------------------------------------------------------
2517 # This command ASSUMES that g_search_inst is looking at the instance to
2518 # be merged with. Will attempt to merge the current and the search inst.
2519 # Hence it takes no args. This routine could be made more general, by
2520 # setting up more instance pointers. The code for BrowMergeCmd in
2521 # interface/BrowserProc.c should then be modified accordingly.
2522 #-------------------------------------------------------------------------
2523 proc Browser_Merge {} {
2524 set nok [catch "bmerge" err_msg]
2525 if {$nok} {
2526 Brow_Raise_Alert "$err_msg" "Merge Error"
2527 return 1
2528 }
2529 return 0
2530 }
2531
2532 #
2533 # proc Browser_do_Merge {}
2534 #-------------------------------------------------------------------------
2535 # This command is bound to the merge menu item on the browser. It will
2536 # prompt for a dialog box for the name of the instance to be merged
2537 # with. Will call 'qlfdid' to search for the instance and if found
2538 # leave g_search_isnt looking at the instance. Brow_Merge will be then
2539 # called to do the true merge.
2540 # target_inst is the fully qualified name of the instance that is going
2541 # to be merged with the current instance. Will work only on the current
2542 # instance.
2543 #-------------------------------------------------------------------------
2544 proc Browser_do_Merge {} {
2545 global AscMonoEntry1 ascBrowVect
2546
2547 set sim [sims getc]
2548 set name [Brow_get_subname]
2549 set AscMonoEntry1(font) $ascBrowVect(font)
2550 set target_inst [lindex [VShowWindow.ascMonoEntry1 \
2551 "Instance Name :" "420x100[setpos .browser 50 50]" \
2552 "" "Enter fully qualified instance name to merge with."] 1]
2553 if {$AscMonoEntry1(button)==2} {return 1}
2554 if {$AscMonoEntry1(button)==3} {puts "No help yet"; return 1}
2555 if {$target_inst ==""} {
2556 Brow_Raise_Alert "You must specify\nan instance name." "Merge Error";
2557 return 1;
2558 }
2559 set nok [catch "qlfdid {$target_inst}" err_msg]
2560 if {$nok} {
2561 Brow_Raise_Alert "Error in finding instance\n$err_msg" "Merge Error"
2562 return 1;
2563 }
2564
2565 # Inform all interested parties that an instance is about
2566 # to be moved in memory. This includes the Browser itself.
2567 # THEN do the merge.
2568
2569 HUB_Message_to_HUB INSTANCEMOVED $sim
2570 set nok [Browser_Merge]
2571 if {$nok} { return 1 }
2572
2573 # The re-exporting of the instance to the browser is handled by
2574 # the below code. See the note in Browser_do_Refine for more details.
2575 #
2576 HUB_Message_to_HUB INSTMERGED $name $target_inst
2577 }
2578
2579 #
2580 # proc Browser_do_ResumeCompile {}
2581 #-------------------------------------------------------------------------
2582 # browser Edit.compile.resumecompilation button
2583 #-------------------------------------------------------------------------
2584 proc Browser_do_ResumeCompile {} {
2585 global ascBrowVect
2586 set old_name [Brow_get_subname]
2587 set old_sim [sims getcurrent]
2588 HUB_Message_to_HUB INSTANCEMOVED $old_sim
2589 sim_reinstantiate $old_name
2590 global ascScripVect
2591 set muffle $ascScripVect(executing)
2592 if {!$muffle} {set ascScripVect(executing) 1}
2593 Brow_Export_Any_2Browser $old_name
2594 if {!$muffle} {set ascScripVect(executing) 0}
2595 #if {$nok} { return 1 }
2596 HUB_Message_to_HUB INSTANCERESUMED $old_sim
2597 }
2598
2599 #
2600 # proc Brow_Raise_Alert {errmsg {label "Error"} {geom "200x70+480+200"}}
2601 #-------------------------------------------------------------------------
2602 # browser alertbox
2603 #-------------------------------------------------------------------------
2604 proc Brow_Raise_Alert {errmsg {label "Error"} {geom "200x70+480+200"}} {
2605 Script_Raise_Alert $errmsg $label
2606 }
2607 #
2608 # proc Brow_CreatePart_ErrorCheck {partname parttype}
2609 #-------------------------------------------------------------------------
2610 # inverse boolean sanity check on create part button
2611 # Needed for Create Part only.
2612 #-------------------------------------------------------------------------
2613 proc Brow_CreatePart_ErrorCheck {partname parttype} {
2614 if {$partname == ""} {
2615 set errmsg "No name was given\n for the part"
2616 Brow_Raise_Alert $errmsg "Create Part Error"
2617 return 1;
2618 }
2619 if {$parttype == ""} {
2620 set errmsg "No type was given"
2621 Brow_Raise_Alert $errmsg "Create Part Error"
2622 return 1;
2623 }
2624 puts "Check childexist"
2625 set list [inst child]
2626 if {[lsearch $list $partname] == -1} {
2627 set errmsg "The name given\nalready exists"
2628 Brow_Raise_Alert $errmsg "Create Part Error"
2629 return 1;
2630 }
2631 puts "Check typeexist"
2632 if {![libr_query -exists -type $parttype]} {
2633 set errmsg "The specified type\ndoes not exist"
2634 Brow_Raise_Alert $errmsg "Create Part Error"
2635 return 1;
2636 }
2637 return 0;
2638 }
2639 #
2640 # proc Browser_do_CreatePart {}
2641 #-------------------------------------------------------------------------
2642 # browser Edit.compile.createpart button
2643 #-------------------------------------------------------------------------
2644 proc Browser_do_CreatePart {} {
2645 global ascBrowVect AscMonoEntry2
2646
2647 # disabled until problem with typeexist (library.h:FindType) fixed.
2648 Brow_Raise_Alert "Create Part not\nyet implemented"
2649 return 1;
2650
2651 set pos [setpos .browser 65 65]
2652 set AscMonoEntry2(font) $ascBrowVect(font)
2653 set data \
2654 [VShowWindow.ascMonoEntry2 "Part name Type name" \
2655 "$pos" "newpart" "\*"]
2656 if {$data == "" || [lindex $data 0] == 2} {
2657 return;
2658 }
2659 set partname [lindex $data 1]
2660 set parttype [lindex $data 2]
2661 set nok [Brow_CreatePart_ErrorCheck $partname $parttype]
2662 if {$nok} {
2663 return 1;
2664 }
2665 set nok [catch "createpart $partname $parttype" err]
2666 if {$nok} {
2667 return 1;
2668 } {
2669 puts "Part $partname OF $parttype Created"
2670 return 0;
2671 }
2672 }
2673 #-------------------------------------------------------------------------
2674 #-------------------------------------------------------------------------
2675 #DISPLAY CODE
2676
2677 #
2678 # proc Brow_InvokePlotProgram
2679 #-------------------------------------------------------------------------
2680 # Accepts the name of a plot file and will invoke a plotting program on it.
2681 #-------------------------------------------------------------------------
2682 proc Brow_InvokePlotProgram {filename {plotcommand ""}} {
2683 global ascUtilVect
2684 if {$plotcommand != ""} {
2685 set plot_cmd $plotcommand
2686 } {
2687 set plot_cmd $ascUtilVect(plot_command)
2688 if {$plot_cmd == ""} {return}
2689 }
2690 #exec $plot_cmd $filename
2691 if {[catch {eval "exec" $plot_cmd $filename &} msg]} {
2692 puts "Error invoking $plot_cmd $filename"
2693 }
2694 }
2695
2696 #
2697 # proc Brow_PrepPlotFile
2698 #-------------------------------------------------------------------------
2699 # Prepares and writes the plotfile based on the type of plot, which is
2700 # currently one of plain, xgraph, gnu_plot. Valid instances are
2701 # 'current' or 'search'.
2702 #-------------------------------------------------------------------------
2703 proc Brow_PrepPlotFile {plot_type {whichinst "current"}} {
2704 global ascUtilVect
2705 set username [ascwhoami]
2706 set file_prefix $ascUtilVect(asctmp)/asc$username
2707 set filename [FileUniqueName "$file_prefix.$plot_type"]
2708
2709 # call the C-code to write the plotfile for the current inst.
2710 set res [b_prepplotfile $whichinst $filename $plot_type]
2711 puts "Generating plot file \"$filename\""
2712 return $filename;
2713 }
2714
2715 #
2716 # proc Brow_do_Plot
2717 #-------------------------------------------------------------------------
2718 # This is the function bound the menu item plot under mb display in the
2719 # browser. A unique filename is created from the code FileUniqueName
2720 # function in DisplayProc.tcl.
2721 #-------------------------------------------------------------------------
2722 proc Brow_do_Plot {} {
2723 global ascUtilVect
2724
2725 # Next C-call returns 1 if we can plot.
2726 set can_plot [b_isplottable current];
2727 if {$can_plot == 0} {return}
2728 set plot_type $ascUtilVect(plot_type)
2729
2730 # This will create a filename of the form /tmp/ascka0p.xgraph6459.113525
2731 set filename [Brow_PrepPlotFile $plot_type]
2732 if {$filename == ""} {return}
2733 if {$ascUtilVect(plot_command) != ""} {
2734 Brow_InvokePlotProgram $filename $ascUtilVect(plot_command)
2735 HUB_Message_to_HUB PLOTMADE [Brow_get_subname] $filename
2736 } {error "Plot command not set in utilities window!"}
2737 }
2738 #
2739 # proc Brow_do_Statistics {}
2740 #-------------------------------------------------------------------------
2741 # Display.Statistics button in the browser
2742 #-------------------------------------------------------------------------
2743 proc Brow_do_Statistics {} {
2744 puts stdout "Instance Statistics for [Brow_get_subname]:"
2745 bstatistics
2746 puts stdout "====================================================="
2747 }
2748
2749
2750 #
2751 # proc Brow_do_DispAttr {}
2752 #-------------------------------------------------------------------------
2753 # This is command will display the attributes associated with
2754 # the currently focused instance if it is a variable. needs to be
2755 # expanded.
2756 #-------------------------------------------------------------------------
2757 proc Brow_do_DispAttr {} {
2758 global ascDispVect
2759 set list "none"
2760 catch {set list [dbg_write_qlfattr [Brow_get_subname]]}
2761 DispClear;
2762 DispSetEntry "Attributes of [Brow_get_subname]"
2763 DispInsert $list
2764 if {$ascDispVect(visibility)} {newraise .display}
2765 }
2766
2767 #
2768 # proc Brow_do_HideNames
2769 #-------------------------------------------------------------------------
2770 # pops up a list of visible children of type (see ChildVisible, child.h,
2771 # or maybe just "inst child") and strip off the leading goo of each)
2772 # and makes invisible those selected.
2773 # Children hidden are hidden in all contexts similar to the current one,
2774 # because the hide bit is part of the typedescriptions child list.
2775 # maybe we should have hide child and hide child in all refinements.
2776 #-------------------------------------------------------------------------
2777 proc Brow_do_HideNames {} {
2778 global ascListSelectB1Box ascBrowVect
2779 set list ""
2780 set type "[inst type]"
2781 set plist ""
2782 catch {set list [brow_child_list current all TYPE ATOMS PASSED]}
2783 foreach i $list {
2784 lappend plist "[lindex $i 0]"
2785 }
2786
2787 if {$plist == ""} {
2788 Brow_Raise_Alert "Hide names called without children to hide" \
2789 "Unhide error"
2790 return
2791 }
2792 set ascListSelectB1Box(grab) 0
2793 set ascListSelectB1Box(btn2name) TagAll
2794 set ascListSelectB1Box(btn3name) Hide
2795 set ascListSelectB1Box(btn4name) ""
2796 set ascListSelectB1Box(btn5name) ""
2797 set ascListSelectB1Box(btn2destroy) 0
2798 set ascListSelectB1Box(btn3destroy) 0
2799 set ascListSelectB1Box(btn4destroy) 0
2800 set ascListSelectB1Box(btn2command) Browser_FindSelectAll
2801 set ascListSelectB1Box(btn3command) Brow_HideListSelect
2802 set ascListSelectB1Box(title) "Hide names in $type"
2803 set ascListSelectB1Box(toplevelname) ".browhidename"
2804 set ascListSelectB1Box(selectmode) extended
2805 set ascListSelectB1Box(headline) "Hideable $type Parts"
2806 set ascBrowVect(hideparts_type) $type
2807
2808 set button [AscListSelectB1Box $plist \
2809 250x240[setpos .browser 150 20]]
2810 }
2811
2812 proc Brow_HideListSelect {} {
2813 global ascListSelectB1Box ascBrowVect
2814 set list $ascListSelectB1Box(itemselected)
2815 set type $ascBrowVect(hideparts_type)
2816 foreach i $list {
2817 libr_hide_type $type $i
2818 Libr_recordhide add $type $i
2819 }
2820 HUB_Message_to_HUB TYPEHIDDEN
2821 }
2822 #
2823 # proc Brow_do_UnHideNames {}
2824 #-------------------------------------------------------------------------
2825 # pops up a list of invisible children of type (see ChildVisible, child.h)
2826 # and makes visible those selected.
2827 #-------------------------------------------------------------------------
2828 proc Brow_do_UnHideNames {} {
2829 global ascListSelectB1Box ascBrowVect
2830 set list ""
2831 set alllist ""
2832 set hiddenlist ""
2833 set type "[inst type]"
2834 set plist ""
2835 catch {set list [brow_child_list current all TYPE ATOMS PASSED]}
2836 foreach i $list {
2837 lappend plist "[lindex $i 0]"
2838 }
2839 catch {set alllist [inst child]}
2840 if {$alllist == "0"} {
2841 Brow_Raise_Alert "UnHide names called\non childless instance" \
2842 "Unhide error"
2843 return
2844 }
2845 foreach i $alllist {
2846 if {[lsearch -exact $plist $i] == -1} {
2847 lappend hiddenlist $i
2848 }
2849 }
2850 if {$hiddenlist == ""} {
2851 Brow_Raise_Alert "UnHide names found no hidden children" \
2852 "Unhide message"
2853 return
2854 }
2855
2856 set ascListSelectB1Box(grab) 0
2857 set ascListSelectB1Box(btn2name) TagAll
2858 set ascListSelectB1Box(btn3name) UnHide
2859 set ascListSelectB1Box(btn4name) ""
2860 set ascListSelectB1Box(btn5name) ""
2861 set ascListSelectB1Box(btn2destroy) 0
2862 set ascListSelectB1Box(btn3destroy) 0
2863 set ascListSelectB1Box(btn4destroy) 0
2864 set ascListSelectB1Box(btn2command) Browser_FindSelectAll
2865 set ascListSelectB1Box(btn3command) Brow_UnHideListSelect
2866 set ascListSelectB1Box(title) "UnHide names in $type"
2867 set ascListSelectB1Box(toplevelname) ".browshowname"
2868 set ascListSelectB1Box(selectmode) extended
2869 set ascListSelectB1Box(headline) "$type hidden Parts"
2870 set ascBrowVect(hideparts_type) $type
2871
2872 set button [AscListSelectB1Box $hiddenlist \
2873 250x240[setpos .browser 150 20]]
2874 }
2875
2876 proc Brow_UnHideListSelect {} {
2877 global ascListSelectB1Box ascBrowVect
2878 set list $ascListSelectB1Box(itemselected)
2879 set type $ascBrowVect(hideparts_type)
2880 foreach i $list {
2881 libr_unhide_type $type $i
2882 Libr_recordhide delete $type $i
2883 }
2884 HUB_Message_to_HUB TYPEHIDDEN
2885 }
2886
2887 # proc Brow_DispRelsForAtom
2888 #-------------------------------------------------------------------------
2889 # This actually does the work of fetching the relations associated
2890 # with a REAL_ATOM_INST and soon to come BOOLEAN_ATOM_INSTs and stuffing
2891 # them in the Display window.
2892 #-------------------------------------------------------------------------
2893 proc Brow_DispRelsForAtom {{context "current"}} {
2894 global ascDispVect
2895
2896 set rel_list [__brow_relsforatom $context];
2897 if {$rel_list == ""} {
2898 newraise .display;
2899 DispClear;
2900 return
2901 }
2902 # clear the display box.
2903 DispClear;
2904 DispSetEntry "Relations for atom [Brow_get_subname]"
2905 DispInsert2 $rel_list;
2906 newraise .display
2907 }
2908
2909
2910 # proc Brow_DispRelations
2911 #-------------------------------------------------------------------------
2912 # This actually does the work of fetching the relations and stuffing them
2913 # in the display box. Valid options are INFIX or POSFIX.
2914 #-------------------------------------------------------------------------
2915 proc Brow_DispRelations {{infix_or_postfix "INFIX"}} {
2916 global ascDispVect
2917 if {$infix_or_postfix == "INFIX"} {
2918 set rel_list [bgetrels current];
2919 } {
2920 set rel_list [bgetrelspf current];
2921 }
2922 if {$rel_list == ""} {
2923 newraise .display;
2924 DispClear;
2925 return
2926 }
2927 # clear the display box.
2928 DispClear;
2929 DispSetEntry "Relations in [Brow_get_subname]"
2930 DispInsert2 $rel_list;
2931 newraise .display
2932 }
2933
2934
2935 #
2936 # proc Brow_do_DispRelations {}
2937 #-------------------------------------------------------------------------
2938 # This command will display the relations associated with
2939 # the currently focused instance. The relations will be displayed in the
2940 # Display window. A postfix representation of the display is coded but
2941 # not bound to the button.
2942 #-------------------------------------------------------------------------
2943 proc Brow_do_DispRelations {} {
2944 global ascBrowVect
2945
2946 set inst_kind [inst kind]
2947 # if not model type then check for arrays of relations
2948
2949 switch $inst_kind {
2950 {MODEL_INST} {
2951 Brow_DispRelations INFIX;
2952 }
2953 {REAL_ATOM_INST} {
2954 Brow_DispRelsForAtom current;
2955 }
2956 default {
2957 set is_rel_type [__brow_isrelation current]
2958 if {$is_rel_type} {
2959 Brow_DispRelations INFIX;
2960 }
2961 }
2962 }
2963 }
2964
2965
2966 # proc Brow_DispCondRels
2967 #-------------------------------------------------------------------------
2968 # This actually does the work of fetching the conditional relations and
2969 # stuffing them in the display box. Only INFIX representation.
2970 #-------------------------------------------------------------------------
2971 proc Brow_DispCondRels {} {
2972 global ascDispVect
2973
2974 set rel_list [bgetcondrels current];
2975
2976 if {$rel_list == ""} {
2977 newraise .display;
2978 DispClear;
2979 return
2980 }
2981 # clear the display box.
2982 DispClear;
2983 DispSetEntry "Conditional Relations in [Brow_get_subname]"
2984 DispInsert2 $rel_list;
2985 newraise .display
2986 }
2987
2988
2989 #
2990 # proc Brow_do_DispCondRels {}
2991 #-------------------------------------------------------------------------
2992 # This command will display the relations associated with
2993 # the currently focused instance. The relations will be displayed in the
2994 # Display window.
2995 #-------------------------------------------------------------------------
2996 proc Brow_do_DispCondRels {} {
2997 global ascBrowVect
2998
2999 set inst_kind [inst kind]
3000 # if not model type then check for arrays of relations
3001
3002 switch $inst_kind {
3003 {MODEL_INST} {
3004 Brow_DispCondRels;
3005 }
3006 default {
3007 set is_rel_type [__brow_isrelation current]
3008 if {$is_rel_type} {
3009 Brow_DispCondRels;
3010 }
3011 }
3012 }
3013 }
3014
3015
3016
3017 # proc Brow_DispLogRelsForAtom
3018 #-------------------------------------------------------------------------
3019 # This actually does the work of fetching the logical relations associated
3020 # with a BOOLEAN_ATOM_INST and stuffing
3021 # them in the Display window.
3022 #-------------------------------------------------------------------------
3023 proc Brow_DispLogRelsForAtom {{context "current"}} {
3024 global ascDispVect
3025
3026 set lrel_list [__brow_logrelsforatom $context];
3027 if {$lrel_list == ""} {
3028 newraise .display;
3029 DispClear;
3030 return
3031 }
3032 # clear the display box.
3033 DispClear;
3034 DispSetEntry "Logical Relations for atom [Brow_get_subname]"
3035 DispInsert2 $lrel_list;
3036 newraise .display
3037 }
3038
3039
3040 # proc Brow_DispLogRels
3041 #-------------------------------------------------------------------------
3042 # This actually does the work of fetching the logical relations
3043 # and stuffing them in the display box.
3044 # Valid options are INFIX or POSFIX.
3045 #-------------------------------------------------------------------------
3046 proc Brow_DispLogRels {{infix_or_postfix "INFIX"}} {
3047 global ascDispVect
3048 if {$infix_or_postfix == "INFIX"} {
3049 set lrel_list [bgetlogrels current];
3050 } {
3051 set lrel_list [bgetlogrelspf current];
3052 }
3053 if {$lrel_list == ""} {
3054 newraise .display;
3055 DispClear;
3056 return
3057 }
3058 # clear the display box.
3059 DispClear;
3060 DispSetEntry "Logical Relations in [Brow_get_subname]"
3061 DispInsert2 $lrel_list;
3062 newraise .display
3063 }
3064
3065
3066 #
3067 # proc Brow_do_DispLogRels {}
3068 #-------------------------------------------------------------------------
3069 # This command will display the logical relations associated with
3070 # the currently focused instance. The logical relations will be displayed
3071 # in the Display window. A postfix representation of the display is coded
3072 # but not bound to the button.
3073 #-------------------------------------------------------------------------
3074 proc Brow_do_DispLogRels {} {
3075 global ascBrowVect
3076
3077 set inst_kind [inst kind]
3078 # if not model type then check for arrays of logical relations
3079
3080 switch $inst_kind {
3081 {MODEL_INST} {
3082 Brow_DispLogRels INFIX;
3083 }
3084 {BOOLEAN_ATOM_INST} {
3085 Brow_DispLogRelsForAtom current;
3086 }
3087 default {
3088 set is_logrel_type [__brow_islogrel current]
3089 if {$is_logrel_type} {
3090 Brow_DispLogRels INFIX;
3091 }
3092 }
3093 }
3094 }
3095
3096
3097
3098 # proc Brow_DispCondLogRels
3099 #-------------------------------------------------------------------------
3100 # This actually does the work of fetching the conditional logical
3101 # relations and stuffing them in the display box.
3102 # Only INFIX representation.
3103 #-------------------------------------------------------------------------
3104 proc Brow_DispCondLogRels {} {
3105 global ascDispVect
3106
3107 set logrel_list [bgetcondlogrels current];
3108
3109 if {$logrel_list == ""} {
3110 newraise .display;
3111 DispClear;
3112 return
3113 }
3114 # clear the display box.
3115 DispClear;
3116 DispSetEntry "Conditional Logical Relations in [Brow_get_subname]"
3117 DispInsert2 $logrel_list;
3118 newraise .display
3119 }
3120
3121
3122 #
3123 # proc Brow_do_DispCondLogRels {}
3124 #-------------------------------------------------------------------------
3125 # This command will display the logical relations associated with
3126 # the currently focused instance. The log relations will be displayed
3127 # in the Display window.
3128 #-------------------------------------------------------------------------
3129 proc Brow_do_DispCondLogRels {} {
3130 global ascBrowVect
3131
3132 set inst_kind [inst kind]
3133 # if not model type then check for arrays of relations
3134
3135 switch $inst_kind {
3136 {MODEL_INST} {
3137 Brow_DispCondLogRels;
3138 }
3139 default {
3140 set is_logrel_type [__brow_islogrel current]
3141 if {$is_logrel_type} {
3142 Brow_DispCondLogRels;
3143 }
3144 }
3145 }
3146 }
3147
3148
3149
3150
3151
3152
3153
3154
3155 # proc Brow_DispWhensForInstance
3156 #-------------------------------------------------------------------------
3157 # This actually do the work of fetching the whens associated
3158 # with an instance and stuffing them in the Display window.
3159 # Instance can be boolean, integer, symbol, relation. It will
3160 # collect the WHENs which include such an instance in either
3161 # the list of variables or in some of the CASEs.
3162 #-------------------------------------------------------------------------
3163 proc Brow_DispWhensForInstance {{context "current"}} {
3164 global ascDispVect
3165
3166 set when_list [__brow_whensforinstance $context];
3167 if {$when_list == ""} {
3168 newraise .display;
3169 DispClear;
3170 return
3171 }
3172 # clear the display box.
3173 DispClear;
3174 DispSetEntry "Whens for instance [Brow_get_subname]"
3175 DispInsert2 $when_list;
3176 newraise .display
3177 }
3178
3179
3180 # proc Brow_DispWhens
3181 #-------------------------------------------------------------------------
3182 # This actually does the work of fetching the whens
3183 # and stuffing them in the display box. It works for models, a WHEN or
3184 # array of WHENs
3185 #-------------------------------------------------------------------------
3186 proc Brow_DispWhens {} {
3187 global ascDispVect
3188 #
3189 set when_list [bgetwhens current];
3190 if {$when_list == ""} {
3191 newraise .display;
3192 DispClear;
3193 return
3194 }
3195 # clear the display box.
3196 DispClear;
3197 DispSetEntry "Whens in [Brow_get_subname]"
3198 DispInsert2 $when_list;
3199 newraise .display
3200 }
3201
3202
3203 #
3204 # proc Brow_do_DispWhens {}
3205 #-------------------------------------------------------------------------
3206 # This command will display the WHENs associated with
3207 # the currently focused instance. The whens will be displayed
3208 # in the Display window.
3209 #-------------------------------------------------------------------------
3210 proc Brow_do_DispWhens {} {
3211 global ascBrowVect
3212
3213 # To check for model
3214 set inst_kind [inst kind]
3215
3216 if { $inst_kind =="MODEL_INST" } {
3217 Brow_DispWhens;
3218 return
3219 }
3220
3221 # To check for when or array of when
3222 set is_when_type [__brow_iswhen current]
3223
3224 if {$is_when_type} {
3225 Brow_DispWhens;
3226 return
3227 }
3228
3229 # if not model type or when then check for instance in when
3230 set is_instance_in_when [__brow_isinstanceinwhen current]
3231
3232 if {$is_instance_in_when} {
3233 Brow_DispWhensForInstance;
3234 return
3235 }
3236 }
3237
3238 #-------------------------------------------------------------------------
3239 #-------------------------------------------------------------------------
3240
3241
3242 # proc Brow_do_Help {}
3243 # proc Brow_do_BindHelp {}
3244 #-------------------------------------------------------------------------
3245 # browser help onbrowsing, onbrowser, respectively
3246 #-------------------------------------------------------------------------
3247 proc Brow_do_Help {} {
3248 Help_button browser
3249 }
3250 proc Brow_do_BindHelp {} {
3251 Help_button browser.help onbrowser
3252 }
3253
3254 #
3255 # misc random header, unmatched by any function
3256 #-------------------------------------------------------------------------
3257 # proc Brow_export_to_probe
3258 #
3259 # defined in ProbeProc.tcl
3260 #
3261 # This code will be for return values from the brow_child_list or inst type
3262 # routines of the form 'name IS_A type' or 'name = value'. It is perhaps
3263 # easiest to retunr this compound information as a long list and to use
3264 # the following function to strip apart. For example the ascBrowVect(children)
3265 # needs the compound information but the ascParentsBox needs only the name.
3266 #-------------------------------------------------------------------------
3267
3268 #
3269 # proc strip {tvlist} {
3270 #-------------------------------------------------------------------------
3271 # remove ' [ ] from a string tvlist
3272 #-------------------------------------------------------------------------
3273 proc strip {tvlist} {
3274
3275 regsub -all {\'} $tvlist "" b;
3276 regsub -all {\[} $b "" b; regsub -all {\]} $b "" b;
3277 return $b;
3278 }
3279
3280 #
3281 # proc stripbraces {listelement}
3282 #-------------------------------------------------------------------------
3283 # remove any outer { } from a string
3284 #-------------------------------------------------------------------------
3285 proc stripbraces {listelement} {
3286 set listelement [string trimleft $listelement " \{"];
3287 set list [string trimright $listelement " \}"];
3288 return $list
3289 }
3290
3291 #
3292 # proc Brow_parse_values {filename force}
3293 #-------------------------------------------------------------------------
3294 # function to parse a values file. unexecutable tcl lines will be reported
3295 # as will the total line count parsed.
3296 #-------------------------------------------------------------------------
3297 proc Brow_parse_values {filename force} {
3298 global ascBrowVect
3299 set ok 1
3300 set lc 0
3301 set line ""
3302 set errors ""
3303 set ec 0
3304 # open file
3305 set fileid [open $filename r]
3306 set cc [gets $fileid line]
3307 # get first line for preprocessing
3308 if {$cc<0} {
3309 close $fileid
3310 puts stdout "Read $lc lines from $filename."
3311 return
3312 }
3313 # check header for new style relative addressing
3314 if {[string first qlfdid $line] == 0} {
3315 set root [lindex $line 1]
3316 set label ""
3317 set title ""
3318 if {[catch {eval $line} err]} {
3319 set title "Read values into what object? ($root not found)"
3320 set label "Name:"
3321 set force 0
3322 } else {
3323 set title "Values to be read into:"
3324 set label "Object:"
3325 }
3326 global AscMonoEntry1
3327 set AscMonoEntry2(font) $ascBrowVect(font)
3328 if {$force == 0} { # confirm read-to location
3329 set tinst [lindex [VShowWindow.ascMonoEntry1 \
3330 $label "500x100[setpos .library 50 50]" \
3331 $root $title ""] 1]
3332 if {$AscMonoEntry1(button)==2} {
3333 close $fileid
3334 return
3335 }
3336 if {$AscMonoEntry1(button)==3} {
3337 set expl {Enter a simulation or qualified name.}
3338 Script_Raise_Alert $expl "$label help:"
3339 close $fileid
3340 return
3341 }
3342 if {[catch {qlfdid $tinst} msg]} {
3343 Script_Raise_Alert "$tinst not found!" "Undefined instance"
3344 close $fileid
3345 return
3346 }
3347 }
3348 # else the qlfdid passed above in catch eval line
3349 } else {
3350 incr lc
3351 if {[catch $line ] && $line != ""} {
3352 incr ec
3353 lappend errors "$lc:"
3354 lappend errors $line
3355 }
3356 }
3357 while {$ok} {
3358 set cc [gets $fileid line]
3359 if {$cc<0} {break}
3360 incr lc
3361 if {[catch $line ] && $line != ""} {
3362 # puts stderr "Unable to parse value file line: $lc\n $line"
3363 if {[string first qlfdid $line] == 0} {
3364 puts stderr "exiting read values due to qlfdid failure\n"
3365 close $fileid
3366 }
3367 incr ec
3368 lappend errors "$lc:"
3369 lappend errors $line
3370 }
3371 }
3372 close $fileid
3373 puts stdout "Read $lc lines from $filename."
3374 if {$ec} {
3375 puts stderr "Errors on $ec lines."
3376 puts stderr " Type \"Brow_parse_errors\" to see the lines."
3377 }
3378 set ascBrowVect(parseerrors) $errors
3379 }
3380
3381 proc Brow_parse_errors {} {
3382 global ascBrowVect
3383 puts stderr "Parse errors: -------------------------------------"
3384 foreach i $ascBrowVect(parseerrors) {
3385 puts stderr $i
3386 }
3387 puts stderr "End of parse errors -------------------------------------"
3388 }
3389
3390 #
3391 # eof
3392 #

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22