Project

General

Profile

Statistics
| Branch: | Revision:

root / src / tkenv / menuproc.tcl @ 3e29b8a0

History | View | Annotate | Download (21.3 KB)

1
#=================================================================
2
#  MENUPROC.TCL - part of
3
#
4
#                     OMNeT++/OMNEST
5
#            Discrete System Simulation in C++
6
#
7
#=================================================================
8

    
9
#----------------------------------------------------------------#
10
#  Copyright (C) 1992-2008 Andras Varga
11
#
12
#  This file is distributed WITHOUT ANY WARRANTY. See the file
13
#  `license' for details on this and other legal matters.
14
#----------------------------------------------------------------#
15

    
16
#------
17
# Parts of this file were created using Stewart Allen's Visual Tcl (vtcl)
18
#------
19

    
20
#===================================================================
21
#    HELPER/GUI PROCEDURES
22
#===================================================================
23

    
24
proc network_present {} {
25
    if [opp_isnull [opp_object_systemmodule]] {
26
       messagebox {Error} {No network has been set up yet.} info ok
27
       return 0
28
    }
29
    return 1
30
}
31

    
32
proc network_ready {} {
33
    if {[network_present] == 0} {return 0}
34

    
35
    if {[is_simulation_ok] == 1} {
36
        return 1
37
    } else {
38
        set ans [messagebox {Warning} {Cannot continue this simulation. Rebuild network?} question yesno]
39
        if {$ans == "yes"} {
40
            rebuild
41
            return [is_simulation_ok]
42
        } else {
43
            return 0
44
        }
45
    }
46
}
47

    
48
proc is_simulation_ok {} {
49
    set state [opp_getsimulationstate]
50
    if {$state == "SIM_NEW" || $state == "SIM_RUNNING" || $state == "SIM_READY"} {
51
        return 1
52
    } else {
53
        return 0
54
    }
55
}
56

    
57
proc is_running {} {
58
    set state [opp_getsimulationstate]
59
    if {$state == "SIM_RUNNING" || $state == "SIM_BUSY"} {
60
        return 1
61
    } else {
62
        return 0
63
    }
64
}
65

    
66
proc check_running {} {
67
    if {[opp_getsimulationstate] == "SIM_RUNNING"} {
68
       messagebox {Warning} {Sorry, you cannot do this while the simulation\
69
                             is running. Please stop it first.} info ok
70
       return 1
71
    }
72
    if {[opp_getsimulationstate] == "SIM_BUSY"} {
73
       messagebox {Warning} {The simulation is waiting for external synchronization -- press STOP to interrupt it.} info ok
74
       return 1
75
    }
76
    return 0
77
}
78

    
79
#===================================================================
80
#    MENU PROCEDURES
81
#===================================================================
82

    
83
proc about {} {
84
    # implements Help|About
85
    global OMNETPP_RELEASE OMNETPP_EDITION OMNETPP_BUILDID
86
    aboutDialog "About OMNeT++/OMNEST" "
87
This simulation model is based on:
88

    
89
OMNeT++/OMNEST
90
Discrete Event Simulation Framework
91
" \
92
"(C) 1992-2008 Andras Varga
93
Release: $OMNETPP_RELEASE, build: $OMNETPP_BUILDID, edition: $OMNETPP_EDITION
94

    
95
NO WARRANTY -- see license for details."
96
}
97

    
98
proc exit_omnetpp {} {
99
    global config
100

    
101
    set isrunning [is_running]
102
    set state [opp_getsimulationstate]
103

    
104
    if {$config(confirm-exit)} {
105
        if [opp_isnotnull [opp_object_systemmodule]] {
106
            if {$isrunning} {
107
                set ans [messagebox {Warning} {The simulation is currently running. Do you really want to quit?} warning yesno]
108
                if {$ans == "no"} {
109
                    return
110
                }
111
            } elseif {$state == "SIM_READY"} {
112
                set ans [messagebox {Warning} {Do you want to call finish() before exiting?} warning yesnocancel]
113
                if {$ans == "yes"} {
114
                    # no catch{}: exceptions are handled inside
115
                    opp_finish_simulation
116
                } elseif {$ans == "no"} {
117
                    # nothing to do
118
                } elseif {$ans == "cancel"} {
119
                    return
120
                }
121
            } else {
122
                #set ans [messagebox {Warning} {Do you really want to quit?} warning yesno]
123
            }
124
        }
125
    }
126

    
127
    if {$isrunning} {
128
       opp_stopsimulation
129
    }
130

    
131
    # save settings (fonts etc) globally, and inspector list locally
132
    save_tkenvrc "~/.tkenvrc" 1 0 1
133
    save_tkenvrc ".tkenvrc"   0 1 1 "# Partial Tkenv config file -- see \$HOME/.tkenvrc as well"
134

    
135
    opp_exitomnetpp
136
}
137

    
138
proc create_snapshot {} {
139
    # implements File|Create snapshot
140

    
141
    if {[network_present] == 0} return
142

    
143
    set label ""
144
    set ok [inputbox {Snapshot} {Enter label for current simulation snapshot:} label]
145
    if {$ok == 1} {
146
        if [catch {opp_createsnapshot $label} err] {
147
          messagebox {Error} "Error: $err" error ok
148
          return
149
        }
150
        set snapshotfile [opp_getfilename snapshot]
151
        if {$snapshotfile==""} {
152
            messagebox {Snapshot created} "Current state of simulation has been saved." info ok
153
        } else {
154
            set ans [messagebox {Snapshot created} "Current state of simulation has been \
155
saved into \"$snapshotfile\". Do you want to open it now in a file viewer window?" question yesno]
156
            if {$ans == "yes"} {
157
                view_snapshotfile
158
            }
159
        }
160
    }
161
}
162

    
163
proc load_nedfile {} {
164
   global config
165

    
166
   set fname $config(last-nedfile)
167

    
168
   if {[string compare [file tail $fname] $fname]==0} {
169
       set dir "."
170
   } else {
171
       set dir [file dirname $fname]
172
   }
173

    
174
   set fname [file tail $fname]
175
   set fname [tk_getOpenFile -defaultextension ".ned" \
176
              -initialdir $dir -initialfile $fname \
177
              -filetypes {{{NED files} {*.ned}} {{All files} {*}}}]
178

    
179
   if {$fname!=""} {
180
      set config(last-nedfile) $fname
181
      if [catch {opp_loadnedfile $fname} err] {
182
        opp_updateinspectors
183
        messagebox {Error} "Error: $err" error ok
184
        return
185
      }
186
      opp_updateinspectors
187
   }
188
}
189

    
190
proc new_network {} {
191
    # implements File|New network...
192

    
193
    if [check_running] return
194

    
195
    # get list of network names
196
    set networks [opp_getnetworktypes]
197
    set localpackage [opp_getsimoption localpackage]
198
    set networknames {}
199
    set localnetworknames {}
200
    foreach net $networks {
201
        set networkname [opp_getobjectname $net]
202
        set networkqname [opp_getobjectfullname $net]
203
        if {"$localpackage.$networkname" == "$networkqname"} {
204
            lappend localnetworknames $networkname
205
        } else {
206
            lappend networknames $networkqname
207
        }
208
    }
209
    set localnetworknames [lsort -dictionary $localnetworknames]
210
    set networknames [lsort -dictionary $networknames]
211

    
212
    set networknames [concat $localnetworknames $networknames]
213

    
214
    # pop up dialog, with current network as default
215
    set netname [opp_getnetworktype]
216
    set ok [comboSelectionDialog "Set up network" "Set up a network. NOTE: The network will use parameter values defined in the \n\[General\] section of the ini file." "Select network:" netname $networknames]
217
    if {$ok == 1} {
218
       busy "Setting up network..."
219
       opp_newnetwork $netname
220
       reflect_record_eventlog
221
       busy
222

    
223
       if [opp_isnotnull [opp_object_systemmodule]] {
224
           busy "Opening graphical network inspector..."
225
           opp_inspect [opp_object_systemmodule] (default)
226
           busy
227

    
228
           # tell plugins about it
229
           busy "Notifying Tcl plugins..."
230
           notifyPlugins newNetwork
231
           busy
232
       }
233
    }
234
}
235

    
236
proc new_run {} {
237
    # implements File|New run...
238

    
239
    if [check_running] return
240

    
241
    set configname [opp_getactiveconfigname]
242
    set runnumber  [opp_getactiverunnumber]
243

    
244
    # pop up selection dialog
245
    set ok [runSelectionDialog configname runnumber]
246
    if {$ok == 1} {
247
       # puts "DBG: selected $configname $runnumber"
248
       busy "Setting up network..."
249
       opp_newrun $configname $runnumber
250
       reflect_record_eventlog
251
       busy
252

    
253
       if [opp_isnotnull [opp_object_systemmodule]] {
254
           busy "Opening graphical network inspector..."
255
           opp_inspect [opp_object_systemmodule] (default)
256
           busy
257

    
258
           # tell plugins about it
259
           busy "Notifying Tcl plugins..."
260
           notifyPlugins newNetwork
261
           busy
262
       }
263
    }
264
}
265

    
266
proc edit_copy {{w .main.text}} {
267
   # implements Edit|Copy
268
   tk_textCopy $w
269
}
270

    
271
proc edit_find {{w .main.text}} {
272
   # implements Edit|Find...
273
   findDialog $w
274
}
275

    
276
proc edit_findnext {{w .main.text}} {
277
   # implements Edit|Find next
278
   findNext $w
279
}
280

    
281
proc edit_filterwindowcontents {{w ".main.text"}} {
282
   # implements Edit|Filter window contents...
283
   if {$w==".main.text"} {
284
       mainlogwindow_filterdialog
285
   } else {
286
       set w [winfo toplevel $w]
287
       modulewindow_filterdialog [winfo toplevel $w]
288
   }
289
}
290

    
291
proc toggle_treeview {} {
292
   global config widgets
293

    
294
   if {$config(display-treeview)==1} {
295
       set config(display-treeview) 0
296
       pack forget $widgets(manager)
297
       .toolbar.tree config -relief flat
298
   } else {
299
       set config(display-treeview) 1
300
       pack $widgets(manager) -before .main.text -expand 0 -fill y  -side left
301
       .toolbar.tree config -relief sunken
302
       updateTreeManager
303
   }
304
}
305

    
306
proc toggle_timeline {} {
307
   global config widgets
308

    
309
   if {$config(display-timeline)==1} {
310
       set config(display-timeline) 0
311
       pack forget $widgets(timeline)
312
       .toolbar.tline config -relief flat
313
   } else {
314
       set config(display-timeline) 1
315
       pack $widgets(timeline) -before .main -anchor center -expand 0 -fill x -side top
316
       .toolbar.tline config -relief sunken
317
       redraw_timeline
318
   }
319
}
320

    
321
proc toggle_record_eventlog {} {
322
   if {[opp_getsimoption record_eventlog]==1} {
323
       opp_setsimoption record_eventlog 0
324
   } else {
325
       opp_setsimoption record_eventlog 1
326
   }
327
   reflect_record_eventlog
328
}
329

    
330
proc reflect_record_eventlog {} {
331
   global config widgets
332

    
333
   if {[opp_getsimoption record_eventlog]==1} {
334
       .toolbar.eventlog config -relief sunken
335
   } else {
336
       .toolbar.eventlog config -relief flat
337
   }
338

    
339
   if {[opp_eventlogrecording hasintervals]} {
340
       messagebox {Eventlog Recording} "Switching to manual control of eventlog recording -- the recording intervals specified in the configuration will be ignored." info ok
341
       opp_eventlogrecording clearintervals
342
   }
343
}
344

    
345
proc set_gui_for_runmode {mode {modinspwin ""} {untilmode ""}} {
346
    global opp
347
    set w $modinspwin
348
    if {$w!="" && ![winfo exists $w]} {set w ""}
349

    
350
    set default_iconbutton_relief "flat"
351
    .toolbar.step config -relief $default_iconbutton_relief
352
    .toolbar.run config -relief $default_iconbutton_relief
353
    .toolbar.fastrun config -relief $default_iconbutton_relief
354
    .toolbar.exprrun config -relief $default_iconbutton_relief
355
    catch {$opp(sunken-run-button) config -relief $default_iconbutton_relief}
356
    remove_stopdialog
357

    
358
    if {$w==""} {
359
        if {$mode=="step"} {
360
            .toolbar.step config -relief sunken
361
        } elseif {$mode=="slow"} {
362
            .toolbar.run config -relief sunken
363
        } elseif {$mode=="normal"} {
364
            .toolbar.run config -relief sunken
365
        } elseif {$mode=="fast"} {
366
            .toolbar.fastrun config -relief sunken
367
        } elseif {$mode=="express"} {
368
            .toolbar.exprrun config -relief sunken
369
            display_stopdialog
370
        } elseif {$mode=="notrunning"} {
371
            .toolbar.until config -relief $default_iconbutton_relief
372
        } else {
373
            error "wrong mode parameter $mode"
374
        }
375
    } else {
376
        if {$mode=="normal"} {
377
            $w.toolbar.mrun config -relief sunken
378
            set opp(sunken-run-button) $w.toolbar.mrun
379
        } elseif {$mode=="fast"} {
380
            $w.toolbar.mfast config -relief sunken
381
            set opp(sunken-run-button) $w.toolbar.mfast
382
        } elseif {$mode=="express"} {
383
            display_stopdialog
384
        } elseif {$mode=="notrunning"} {
385
            .toolbar.until config -relief $default_iconbutton_relief
386
        } else {
387
            error "wrong mode parameter $mode with module inspector"
388
        }
389
    }
390

    
391
    if {$untilmode=="until_on"} {
392
        .toolbar.until config -relief sunken
393
    } elseif {$untilmode=="until_off"} {
394
        .toolbar.until config -relief $default_iconbutton_relief
395
    } elseif {$untilmode!=""} {
396
        error "wrong untilmode parameter $mode"
397
    }
398
}
399

    
400
proc one_step {} {
401
    # implements Simulate|One step
402

    
403
    if [is_running] {
404
        set_gui_for_runmode step
405
        opp_stopsimulation
406
    } else {
407
        if {![network_ready]} {return}
408
        set_gui_for_runmode step
409
        opp_onestep
410
        set_gui_for_runmode notrunning
411
    }
412
}
413

    
414
proc runsimulation {mode} {
415
    if [is_running] {
416
        set_gui_for_runmode $mode
417
        opp_set_run_mode $mode
418
        opp_set_run_until_module
419
    } else {
420
        if {![network_ready]} {return}
421
        set_gui_for_runmode $mode
422
        opp_run $mode
423
        set_gui_for_runmode notrunning
424
    }
425
}
426

    
427
proc run_slow {} {
428
    # implements Simulate|Slow execution
429
    runsimulation slow
430
}
431

    
432
proc run_normal {} {
433
    # implements Simulate|Run
434
    runsimulation normal
435
}
436

    
437
proc run_fast {} {
438
    # implements Simulate|Fast Run
439
    runsimulation fast
440
}
441

    
442
proc run_express {} {
443
    # implements Simulate|Express Run
444
    runsimulation express
445
}
446

    
447
proc run_until {} {
448
    # implements Simulate|Run until...
449

    
450
    if {[network_ready] == 0} {
451
       return
452
    }
453

    
454
    set time ""
455
    set event ""
456
    set msg ""
457
    set mode ""    ;# will be set to Normal, Fast or Express
458

    
459
    set ok [rununtil_dialog time event msg mode]
460
    if {$ok==0} return
461

    
462
    if {$mode=="Normal"} {
463
        set mode "normal"
464
    } elseif {$mode=="Fast"} {
465
        set mode "fast"
466
    } elseif {$mode=="Express"} {
467
        set mode "express"
468
    } else {
469
        set mode "normal"
470
    }
471

    
472
    set untilmode "until_on"
473
    if {$time=="" && $event=="" && $msg==""} {set until_on "until_off"}
474

    
475
    if [is_running] {
476
        if [catch {
477
            set_gui_for_runmode $mode "" $untilmode
478
            opp_set_run_mode $mode
479
            opp_set_run_until $time $event $msg
480
        } err] {
481
            messagebox {Error} "Error: $err" error ok
482
        }
483
    } else {
484
        if {![network_ready]} {return}
485
        if [catch {
486
            set_gui_for_runmode $mode "" $untilmode
487
            opp_run $mode $time $event $msg
488
        } err] {
489
            messagebox {Error} "Error: $err" error ok
490
        }
491
        set_gui_for_runmode notrunning
492
    }
493
}
494

    
495
proc run_until_msg {msg mode} {
496
    if {[network_ready] == 0} {
497
       return
498
    }
499
    # mode must be "normal", "fast" or "express"
500
    if [is_running] {
501
        if [catch {
502
            set_gui_for_runmode $mode "" "until_on"
503
            opp_set_run_mode $mode
504
            opp_set_run_until "" "" $msg
505
        } err] {
506
            messagebox {Error} "Error: $err" error ok
507
        }
508
    } else {
509
        if [catch {
510
            set_gui_for_runmode $mode "" "until_on"
511
            opp_run $mode "" "" $msg
512
        } err] {
513
            messagebox {Error} "Error: $err" error ok
514
        }
515
        set_gui_for_runmode notrunning
516
    }
517
}
518

    
519

    
520
proc start_all {} {
521

    
522
    if [check_running] return
523

    
524
    if {[network_present] == 0} return
525
    opp_start_all
526
}
527

    
528
proc call_finish {} {
529

    
530
    # check state is not SIM_RUNNING
531
    if [check_running] return
532

    
533
    # check state is not SIM_NONET
534
    if {[network_present] == 0} return
535

    
536
    # check state is not SIM_FINISHCALLED
537
    if {[opp_getsimulationstate] == "SIM_FINISHCALLED"} {
538
       messagebox {Error} {finish() has been invoked already.} info ok
539
       return
540
    }
541

    
542
    # check state is not SIM_ERROR
543
    if {[opp_getsimulationstate] == "SIM_ERROR"} {
544
       set ans [messagebox {Warning} \
545
                  {Simulation was stopped with error, calling finish() might produce unexpected results. Proceed anyway?} \
546
                  question yesno]
547
       if {$ans == "no"} {
548
           return
549
       }
550
    } else {
551
       set ans [messagebox {Question} \
552
                  {Do you want to conclude this simulation run and invoke finish() on all modules?} \
553
                  question yesno]
554
       if {$ans == "no"} {
555
           return
556
       }
557
    }
558

    
559
    busy "Invoking finish() on all modules..."
560
    opp_finish_simulation
561
    busy
562
}
563

    
564
proc rebuild {} {
565
    # implements Simulate|Rebuild
566

    
567
    if [check_running] return
568

    
569
    if {[network_present] == 0} return
570
    busy "Rebuilding network..."
571
    opp_rebuild
572
    busy
573
}
574

    
575

    
576
proc stop_simulation {} {
577
    # implements Simulate|Stop
578
    if {[opp_getsimulationstate] == "SIM_RUNNING" || [opp_getsimulationstate] == "SIM_BUSY"} {
579
       # "opp_stopsimulation" just *asks* the simulation to stop, causing it to return
580
       # from the "opp_run" command.
581
       # "set_gui_for_runmode notrunning" will be called after "opp_run" has returned.
582
       opp_stopsimulation
583
    }
584

    
585
    # this proc doubles as "stop layouting", when in graphical module inspectors
586
    global stoplayouting
587
    set stoplayouting 1
588
}
589

    
590
proc message_windows {} {
591
    # implements Trace|Message sending...
592
    if {[network_present] == 0} return
593
    create_messagewindow .messagewindow
594
}
595

    
596
proc clear_windows {} {
597
    # implements Trace|Clear windows...
598
    # also called back from C++ code
599
    # TBD: should delete the contents of module windows as well
600
    .main.text delete 1.0 end
601
    catch {.messagewindow.main.text delete 1.0 end}
602
}
603

    
604
proc inspect_filteredobjectlist {{w "."}} {
605
    # implements Find/inspect objects...
606
    set ptr ""
607
    if {$w!="" && $w!="." && ![regexp {\.(ptr.*)-([0-9]+)} $w match ptr type]} {
608
        error "window name $w doesn't look like an inspector window"
609
    }
610
    filteredobjectlist_window $ptr
611
}
612

    
613
proc inspect_bypointer {} {
614
    # implements Inspect|By pointer...
615
    set pointer "ptr"
616
    set ok [inputbox {Inspect by pointer...} {Enter pointer (invalid pointer may cause segmentation fault!):} pointer]
617
    if {$ok == 1} {
618
        opp_inspect $pointer (default)
619
    }
620
}
621

    
622
proc inspect_systemmodule {} {
623
    # implements Inspect|Toplevel modules...
624
    if {[network_present] == 0} return
625
    opp_inspect [opp_object_systemmodule] (default)
626
}
627

    
628
proc inspect_messagequeue {} {
629
    # implements Inspect|Message queue...
630
    opp_inspect [opp_object_messagequeue] (default)
631
}
632

    
633
proc inspect_simulation {} {
634
    # implements Inspect|Simulation...
635
    opp_inspect [opp_object_simulation] (default)
636
}
637

    
638
proc inspect_componenttypes {} {
639
    opp_inspect [opp_object_componenttypes] {(default)}
640
}
641

    
642
proc inspect_classes {} {
643
    opp_inspect [opp_object_classes] {(default)}
644
}
645

    
646
proc inspect_enums {} {
647
    opp_inspect [opp_object_enums] {(default)}
648
}
649

    
650
proc inspect_configentries {} {
651
    opp_inspect [opp_object_configentries] {(default)}
652
}
653

    
654
proc inspect_functions {} {
655
    opp_inspect [opp_object_functions] {(default)}
656
}
657

    
658
proc simulation_options {} {
659
    options_dialog .
660
    opp_updateinspectors
661
}
662

    
663
proc save_tkenv_config {} {
664
    set filename "tkenv.cfg"
665
    set filename [tk_getSaveFile -title {Save Tkenv configuration} \
666
                  -defaultextension "cfg" -initialfile $filename \
667
                  -filetypes {{{Configuration files} {*.cfg}} {{All files} {*}}}]
668

    
669
    if {$filename!=""} {
670
       save_tkenvrc $filename 1 1 0 "# Tkenv config file"
671
    }
672
}
673

    
674
proc load_tkenv_config {} {
675
    set filename "tkenv.cfg"
676
    set filename [tk_getOpenFile -title {Load Tkenv configuration} \
677
                  -defaultextension "cfg" -initialfile $filename \
678
                  -filetypes {{{Configuration files} {*.cfg}} {{All files} {*}}}]
679

    
680
    if {$filename!=""} {
681
       load_tkenvrc $filename
682
    }
683
}
684

    
685
proc edit_textfile {} {
686
    # implements Options|File name...
687
    set types {
688
         {{Text files}             {*.txt}}
689
         {{Ini files}              {*.ini}}
690
         {{NED files}              {*.ned}}
691
         {{C++ files}              {*.cc *.cpp}}
692
         {{C++ headers}            {*.h}}
693
         {{Saved log files}        {*.out}}
694
         {{Output vectors}         {*.vec}}
695
         {{Output scalars}         {*.sca}}
696
         {{Snapshot files}         {*.sna}}
697
         {{Inspector lists}        {*.lst}}
698
         {{All files}              {*}}
699
    }
700
    set filename [tk_getOpenFile -title {View/Edit text file} \
701
                  -defaultextension "out" -initialfile "" \
702
                  -filetypes $types]
703

    
704
    if {$filename!=""} {
705
       create_fileviewer $filename
706
    }
707
}
708

    
709
proc view_inifile {} {
710
    set fname [opp_getfilename ini]
711
    if {$fname == ""} {
712
       messagebox {Info} "The current configuration manager doesn't use file input." info ok
713
       return
714
    }
715

    
716
    view_file $fname
717
}
718

    
719
proc view_outputvectorfile {} {
720
    set fname [opp_getfilename outvector]
721
    if {$fname == ""} {
722
       messagebox {Info} "The current output vector manager doesn't use file output." info ok
723
       return
724
    }
725
    if {![file exists $fname]} {
726
       messagebox {Info} "Output vector file not yet created (no values recorded yet)." info ok
727
       return
728
    }
729
    view_file $fname
730
}
731

    
732
proc view_outputscalarfile {} {
733
    set fname [opp_getfilename outscalar]
734
    if {$fname == ""} {
735
       messagebox {Info} "The current output scalar manager doesn't use file output." info ok
736
       return
737
    }
738
    if {![file exists $fname]} {
739
       messagebox {Info} "Output scalar file not yet created (no output scalars written)." info ok
740
       return
741
    }
742
    view_file $fname
743
}
744

    
745
proc view_snapshotfile {} {
746
    set fname [opp_getfilename snapshot]
747
    if {$fname == ""} {
748
       messagebox {Info} "The current snapshot manager doesn't use file output." info ok
749
       return
750
    }
751
    if {![file exists $fname]} {
752
       messagebox {Info} "Snapshot file not yet created (no snapshots done yet)." info ok
753
       return
754
    }
755
    view_file $fname
756
}
757

    
758
proc view_file {filename} {
759
    if [catch {open $filename r} f] {
760
       messagebox {Error} "Error: $f" info ok
761
       return
762
    } else {
763
       create_fileviewer $filename
764
    }
765
}
766

    
767

    
768
#
769
# Called when simulation speed slider on toolbar changes
770
#
771
proc animSpeedChanged {arr name op} {
772
    if {($op!="w" && $op!="write") || $arr!="priv" || $name!="animspeed"} {error "wrong callback"}
773

    
774
    global priv
775
    opp_setsimoption "animation_speed" $priv(animspeed)
776
}
777