1#!/usr/bin/env wish
2
3# le titre
4wm  title . mdump2
5
6# le cadre
7frame .top -borderwidth 10 -background white
8pack .top -side top -fill x
9
10# les boutons de commande
11set but [button .top.dump -text "Dump" -command Dump -background red]
12button .top.quit -text "Quitter" -command exit -background red
13pack .top.quit .top.dump -side left
14
15# le label d'entree du fichier a dumper
16label .top.l -text " Fichier MED : " -padx 0 -background white
17entry .top.file -width 20 -relief sunken \
18	-textvariable file
19pack .top.l -side left
20pack .top.file -side left -fill x -expand true
21
22# le mode de stockage des donnees en memoire
23frame .option1 -background white
24label .option1.o -text " Mode de stockage des donn�es en m�moire : " -padx 1 \
25 -background white
26set choix_stockage NO_INTERLACE
27set f [frame .option1.ms -borderwidth 5  -background white ]
28radiobutton $f.1 -variable choix_stockage -text " NON ENTRELACE " \
29 -value NO_INTERLACE
30radiobutton $f.2 -variable choix_stockage -text " ENTRELACE " \
31 -value FULL_INTERLACE
32pack $f.1 -side left
33pack $f.2 -side right
34pack .option1.o -side left
35pack $f -side left
36pack .option1 -side top -fill x
37
38# Le mode de connectivite
39frame .option2 -background white
40label .option2.o -text " Mode de connectivit� : " -padx 0 -background white
41set choix_connectivite NODALE
42set mc [frame .option2.mc -borderwidth 5  -background white]
43radiobutton $mc.1 -variable choix_connectivite -text " CONNECTIVITE NODALE " \
44 -value NODALE
45radiobutton $mc.2 -variable choix_connectivite \
46 -text " CONNECTIVITE DESCENDANTE " -value DESCENDANTE
47pack $mc.1 -side left
48pack $mc.2 -side right
49pack .option2.o -side left
50pack $mc -side left
51pack .option2 -side top -fill x
52
53# Lecture complete ou non ?
54frame .option4 -background white
55label .option4.o -text " Mode de lecture : " -padx 0 -background white
56set choix_lecture LECTURE_COMPLETE
57set mc [frame .option4.mc -borderwidth 5  -background white]
58radiobutton $mc.1 -variable choix_lecture -text " LECTURE COMPLETE " \
59 -value LECTURE_COMPLETE
60radiobutton $mc.2 -variable choix_lecture \
61 -text " LECTURE DES EN-TETES SEULEMENT " -value LECTURE_EN_TETE_SEULEMENT
62pack $mc.1 -side left
63pack $mc.2 -side right
64pack .option4.o -side left
65pack $mc -side left
66pack .option4 -side top -fill x
67
68# Affichage complet ou structure seulement ?
69frame .option0 -background white
70label .option0.o -text " Affichage : " -padx 0 -background white
71set choix_structure ""
72set af [frame .option0.mc -borderwidth 5  -background white]
73radiobutton $af.1 -variable choix_structure -text " AFFICHAGE COMPLET                  " \
74 -value ""
75radiobutton $af.2 -variable choix_structure \
76 -text " STRUCTURE SEULEMENT           " -value "--structure"
77pack $af.1 -side left
78pack $af.2 -side right
79pack .option0.o -side left
80pack $af -side left
81pack .option0 -side top -fill x
82
83# le numero de maillage
84frame .option3 -background white
85label .option3.o -text " Numero de maillage : " -padx 0 -background white
86set numero 1
87entry .option3.numero -width 10 -relief sunken \
88	-textvariable numero
89pack .option3.o -side left
90pack .option3.numero -side left -fill x -expand true
91pack .option3 -side top -fill both
92
93# la fenetre d'affichage
94frame .t -background white
95set log [text .t.log -width 80 -height 20 \
96	-borderwidth 2 -relief raised -setgrid true \
97	-yscrollcommand {.t.scroll set} -background cyan]
98scrollbar .t.scroll -command {.t.log yview}
99pack .t.scroll -side right -fill y
100pack .t.log -side left -fill both -expand true
101pack .t -side top -fill both -expand true
102
103# les touches du clavier
104bind .top.file <Return> Dump
105focus .top.file
106
107# la commande dump
108proc Dump { } {
109   global exec_path choix_structure file input log but choix_structure choix_connectivite choix_stockage numero choix_lecture
110
111# on suppose que bindir c'est $prefix/bin ce qui malheureusement peut ne pas etre le cas si l'utilisateur utilise l'option de configure !!!
112# il faudrait peut-etre comparer /usr/local/bin et ${exec_prefix}/bin pour etre sur !
113   set cmd "@prefix@/bin/mdump2"
114
115   if { $choix_lecture == "LECTURE_EN_TETE_SEULEMENT" } {
116     if [catch {open "|$cmd $choix_structure $file $numero $choix_connectivite $choix_lecture |& cat"} input] {
117       $log insert end $input\n
118     } else {
119       $but config -text Stop -command Stop
120       $log insert end $file\n
121       fileevent $input readable Log
122     }
123   } else {
124     if [catch {open "|$cmd $choix_structure $file $numero $choix_connectivite $choix_stockage |& cat"} input] {
125       $log insert end $input\n
126     } else {
127       $but config -text Stop -command Stop
128       $log insert end $file\n
129       fileevent $input readable Log
130     }
131   }
132}
133
134proc Log { } {
135   global input log
136   if [eof $input] {
137      Stop
138   } else {
139      gets $input line
140      $log insert end $line\n
141      $log see end
142  }
143}
144
145proc Stop { } {
146   global input but
147   catch {close $input}
148   $but config -text "Dump" -command Dump
149}
150
151