summaryrefslogtreecommitdiff
path: root/src/DrawResources/Consultation.tcl
blob: 3886dd63e3d83e6b073d2733dd6f29ada850f789 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
#
# wish tools to browse tests and results
#
package require Tk

####################################################
# source batch tcl 
####################################################
#
#  sets the following environment variables
#  
#  WBCONTAINER
#  WBROOT
#  STATION
#
source $env(DRAWHOME)/InitEnvironment.tcl

source $env(DRAWHOME)/Tests.tcl

####################################################
# executable to display images
####################################################

set imageExec $env(WBROOT)/$env(STATION)/bin/TestImage
#set imageExec [ wokinfo -p testexec:TestImage ] 

####################################################
# Colors and title
####################################################

option add *Background grey
option add *Foreground black
wm  title . "Modeling Team Test Browser"
wm geometry . +460+10

####################################################
# Les Boutons
####################################################

frame .top

frame .b

set nextCommand "nextTest"
proc InteractiveNext {} {

    # process the next button
    # remove display of image for rapidity

    global nextCommand withImage
    set oldwith $withImage
    set withImage 0
    $nextCommand
    set withImage $oldwith
    displayImage
    focus .
}

button .b.init  -text "init"          -command init
button .b.clear -text "clear"         -command clearResult
button .b.copy  -text "Copy"          -command copyMaster
button .b.exit  -text "exit"          -command {if $withImage switchImage; exit}
button .b.view  -text "View"          -command viewTest
button .b.run   -text "Run"           -command runTest
button .b.send   -text "Send"         -command sendTest
button .b.next  -text "Next"          -command InteractiveNext
button .b.nul   -text "next UL"       -command nextUL
button .b.nfunc -text "next Function" -command nextFunction

radiobutton .b.withtest -anchor w -relief flat \
	-text "Test " -variable nextCommand -value "nextTest"
radiobutton .b.withres  -anchor w -relief flat \
	-text "With result" -variable nextCommand -value "nextWithResult"
radiobutton .b.witherr  -anchor w -relief flat \
	-text "With error" -variable nextCommand -value "nextWithError"

pack    .b.init .b.clear .b.copy  .b.run .b.send .b.view \
	.b.next .b.withtest .b.withres .b.witherr \
	.b.nul .b.nfunc .b.exit \
	-side top -fill x

pack .b -side right -anchor n -in .top

####################################################
# Les directory test resultat et master
# les entry
####################################################

frame  .root
label  .root.name  -text "Root of tests : " -width 20 -anchor w
entry  .root.val  -relief sunken -textvariable testRoot -width 40
pack .root.name .root.val -side left

frame  .res
label  .res.name    -text "Result directory : " -width 20 -anchor w
entry  .res.val -relief sunken -textvariable resultRoot -width 40
pack .res.name .res.val -side left

frame .master
label .master.name -text "Master directory : " -width 20 -anchor w
entry .master.val  -relief sunken -textvariable masterRoot -width 40
pack .master.name .master.val -side left

frame .exec
label .exec.name -text "Executable : " -width 20 -anchor w
entry .exec.val  -relief sunken -textvariable theExec -width 40
pack .exec.name .exec.val -side left

frame .sendto
label .sendto.name -text "Send to : " -width 20 -anchor w
entry .sendto.val  -relief sunken -textvariable theDraw -width 40
pack .sendto.name .sendto.val -side left

# enforce update when return
bind .root.val <Return> "set theTest $theTest"
bind .res.val <Return> "set theTest $theTest"
bind .master.val <Return> "set theTest $theTest"
bind .exec.val <Return> "set theTest $theTest"

pack .root .res .master .exec .sendto -side top -in .top

####################################################
# Les list box UL Function Test
####################################################

listbox .uls -relief sunken -borderwidth 2 \
	-yscrollcommand ".suls set"
scrollbar .suls -relief sunken  -command ".uls yview"

listbox .funcs -relief sunken -borderwidth 2 \
-yscrollcommand ".sfuncs set"
scrollbar .sfuncs -relief sunken  -command ".funcs yview"

listbox .tests -relief sunken -borderwidth 2 \
-yscrollcommand ".stests set"
scrollbar .stests -relief sunken  -command ".tests yview"

bind .uls <Double-Button-1> {
    set theUL [selection get]
}

bind .funcs <Double-Button-1> {
    set theFunction [selection get]
}

bind .tests <Double-Button-1> {
    set theTest [selection get]
}

# procedures de trace des variables listes
# mettent a jour la list box correspondante

trace variable listUL w  listULProcW
proc listULProcW {name element op} {
    global listUL
    .uls delete 0 [.uls size]
    foreach f $listUL {.uls insert end $f}
}

trace variable listFunction w  listFunctionProcW
proc listFunctionProcW {name element op} {
    global listFunction
    .funcs delete 0 [.funcs size]
    foreach f $listFunction {.funcs insert end $f}
}

trace variable listTest w  listTestProcW
proc listTestProcW {name element op} {
    global listTest
    .tests delete 0 [.tests size]
    foreach f $listTest {.tests insert end $f}
}

#presentation 

pack .uls .suls .funcs .sfuncs .tests .stests -side left -fill both -in .top

####################################################
# the current UL Function Test, associated buttons
####################################################

frame .current

label .current.ul   -textvariable theUL
label .current.func -textvariable theFunction
label .current.test -textvariable theTest

pack .current.ul .current.func .current.test -side left

####################################################
# le statut
####################################################

frame .status
label .status.h -text "${theStatusHeader} : "
label .status.s -textvariable theStatusLine -anchor w

# menu des fichiers xwd

set withImage 0
set hasImage "No Image"
set nbXWD "0 images  "

label  .status.xwd  -textvariable nbXWD
button .status.vxwd -text "no Display" -command switchImage
bind . <d> switchImage

proc switchImage {} {
    global withImage imageProcess
    if $withImage {
	set withImage 0
	.status.vxwd configure -text "no Display"
	catch {exec kill $imageProcess}
	set imageProcess 0
    } else {
	set withImage 1
	.status.vxwd configure -text "Display"
	displayImage
    }
}

trace variable theXWDFiles w theXWDFilesProcW

proc theXWDFilesProcW {name element op} {
    global nbXWD theXWDFiles
    set nbXWD "[llength $theXWDFiles] images  "
    displayImage
}

set imageProcess 0

proc displayImage {} {
    global withImage
    if {! $withImage} return
    global imageExec imageProcess
    global theXWDFiles resultRoot masterRoot theUL theFunction 
    if $imageProcess {catch {exec kill $imageProcess}}

    foreach f [glob -nocomplain /tmp/*.xwd] {catch {exec rm -f $f}}
    set r {}
    foreach h $theXWDFiles {
	set g [file rootname [file tail $h]]
	set f $resultRoot/$theUL/$theFunction/$g.Z
	if [file readable $f] {
	    catch {exec cp $f /tmp/r$g.Z}
	    catch {exec uncompress /tmp/r$g.Z}
	    lappend r /tmp/r$g
	} else {lappend r "XXXX"}
	set f $masterRoot/$theUL/$theFunction/$g.Z
	if [file readable $f] {
	    catch {exec cp $f /tmp/m$g.Z}
	    catch {exec uncompress /tmp/m$g.Z}
	    lappend r /tmp/m$g
	} else {lappend r "XXXX"}
    }
    set imageProcess [eval exec $imageExec $r & ]
}

pack .status.h .status.s -side left
pack .status.vxwd .status.xwd -side right

####################################################
# Les resultats et les master
####################################################

frame .log
text .log.result -relief raised -bd 2 -width 38 -yscrollcommand ".log.sresult set"
scrollbar .log.sresult -relief sunken -command ".log.result yview"
text .log.master -relief raised -bd 2 -width 38 -yscrollcommand ".log.smaster set"
scrollbar .log.smaster -relief sunken -command ".log.master yview"

# trace the files names
proc loadFile {file text} {
    $text delete 1.0 end
    if {$file == ""} return
    if [file isdirectory $file] return
    if [file readable $file] {
	set f [open $file]
	while {![eof $f]} {
	    $text insert end [read $f 1000]
	}
	close $f
    }
}

trace variable theLog w theLogProc
proc theLogProc {name element op} {
    global theLog 
    loadFile $theLog .log.result
}

trace variable theErrorLines w theErrorLinesProc
proc theErrorLinesProc {name element op} {
    global theErrorLines
    # tag the errors if there are
    .log.result tag delete error
    foreach l $theErrorLines {
	.log.result tag add error $l.0 $l.end
	.log.result tag configure error -background orange
    }
}

trace variable theDiffs w theDiffsProc
proc theDiffsProc {name element op} {
    global theDiffs
    # tag the differences if there are
    .log.result tag delete diffs
    .log.master tag delete diffs
    if [llength $theDiffs] {
	foreach l $theDiffs {
	    .log.result tag add diffs ${l}.0 ${l}.end
	    .log.master tag add diffs ${l}.0 ${l}.end
	}
	.log.result tag configure diffs -background lightblue
	.log.master tag configure diffs -background lightblue
    }
}

trace variable theMasterLog w theMasterLogProc
proc theMasterLogProc {name element op} {
    global theMasterLog
    loadFile $theMasterLog .log.master
}

pack .log.result .log.sresult .log.master .log.smaster -side left -fill y

####################################################
# panel to display the test
####################################################

set hasTestPanel 0
set withBeginEnd 0
set beginFunction ""
set endFunction   ""
set beginUL       ""
set endUL         ""

proc viewTest {} {
    global hasTestPanel 
    if {! $hasTestPanel} {
	set hasTestPanel 1
	toplevel .panel
	wm geometry .panel +10+610

	frame .panel.b
	button .panel.b.quit -text Quit \
		-command {destroy .panel; set hasTestPanel 0}
	bind .panel <q> {destroy .panel; set hasTestPanel 0}

	button .panel.b.bfunc -textvariable beginFunction \
		-command {loadFile $testRoot/$theUL/$theFunction/begin .panel.t.text}
	button .panel.b.efunc -textvariable endFunction \
		-command {loadFile $testRoot/$theUL/$theFunction/end .panel.t.text}
	button .panel.b.bul -textvariable beginUL \
		-command {loadFile $testRoot/$theUL/begin .panel.t.text}
	button .panel.b.eul -textvariable endUL \
		-command {loadFile $testRoot/$theUL/end .panel.t.text}
	button .panel.b.test -textvariable theTest \
		-command {loadFile $testRoot/$theUL/$theFunction/$theTest .panel.t.text}
	button .panel.b.next -text Next -command {$nextCommand; focus .panel}
	bind .panel <n> {$nextCommand}

	button .panel.b.concat -text "Concat " -command {
	    if { $withBeginEnd} { 
		set withBeginEnd 0
	    } else { 
		set withBeginEnd 1
	    } 
	    displayTest
	}
	button .panel.b.send   -text "Send"         -command sendTest

	pack .panel.b.quit .panel.b.next .panel.b.concat .panel.b.send \
		-side top -fill x 
	pack .panel.b.eul .panel.b.efunc .panel.b.test .panel.b.bfunc \
		.panel.b.bul \
		-side bottom -fill x 

	frame .panel.t
	text .panel.t.text -relief raised -width 65 -bd 2 \
		-yscrollcommand ".panel.t.scroll set"
	scrollbar .panel.t.scroll -relief sunken -command ".panel.t.text yview"
	pack .panel.t.text .panel.t.scroll -side left -fill both

	pack .panel.t .panel.b -side left -fill both

    } else {
	destroy .panel
	set hasTestPanel 0	
    }
    displayTest
}

proc displayTest {} {
    global hasTestPanel
    global withBeginEnd
    if {! $hasTestPanel} return
    global testRoot theUL theFunction theTest
    global beginFunction endFunction beginUL endUL
    if { ! $withBeginEnd} {
	loadFile $testRoot/$theUL/$theFunction/$theTest .panel.t.text
    } else {
	global testRoot resultRoot theExec theLog theDraw
	global theUL theFunction theTest
	set f /tmp/theTest[pid]
	set ff [open $f w]
	puts $ff "set testroot $testRoot"
	puts $ff "set testinfos(resultRoot)  $resultRoot"
	puts $ff "set testinfos(theUL)       $theUL"
	puts $ff "set testinfos(theFunction) $theFunction"
	puts $ff "set testinfos(theTest)     $theTest"
	close $ff
	catch {exec cat -s \
		$testRoot/$theUL/begin \
		$testRoot/$theUL/$theFunction/begin \
		$testRoot/$theUL/$theFunction/$theTest \
		$testRoot/$theUL/$theFunction/end \
		$testRoot/$theUL/end  >> $f}
	loadFile $f .panel.t.text
    }
    set beginFunction "$theFunction begin"
    set endFunction   "$theFunction end"
    set beginUL "$theUL begin"
    set endUL   "$theUL end"
    wm title .panel "$theUL $theFunction $theTest"
}

trace variable theTest w theTestProcW
proc theTestProcW {name element op} {
    displayTest
}

####################################################
# presentation generale
####################################################

pack .top .current .status .log -side top -fill x

init