1 | # This program is under CECILL_B licence. See footer for details. |
---|
2 | |
---|
3 | ################################################# |
---|
4 | # need description |
---|
5 | ################################################# |
---|
6 | proc debug {txt } { |
---|
7 | global debug |
---|
8 | if {$debug} { |
---|
9 | log "$txt" "debug" |
---|
10 | } |
---|
11 | } |
---|
12 | |
---|
13 | ################################################ |
---|
14 | # need description |
---|
15 | ################################################# |
---|
16 | proc success {txt } { |
---|
17 | global debug |
---|
18 | if {$debug} { |
---|
19 | log "$txt \n" "ok" |
---|
20 | } |
---|
21 | } |
---|
22 | |
---|
23 | ################################################# |
---|
24 | # need description |
---|
25 | ################################################# |
---|
26 | proc warning {txt } { |
---|
27 | log "$txt" "warning" |
---|
28 | } |
---|
29 | |
---|
30 | proc pause args { |
---|
31 | set txt "Info : [join $args]" |
---|
32 | tk_messageBox -type ok -title stop -message $txt |
---|
33 | # -parent . |
---|
34 | } |
---|
35 | |
---|
36 | proc font_create {} { |
---|
37 | set graph_font [font create graph_font -family courrier -size 10 ] |
---|
38 | set graph_fonttitle [font create graph_fonttitle -family courrier -size 12 -weight bold -underline true ] |
---|
39 | set log_font [font create log_font -family courier -size 10 ] |
---|
40 | } |
---|
41 | |
---|
42 | proc log_create {} { |
---|
43 | global engine_version waypoint workingDir log_channel |
---|
44 | |
---|
45 | |
---|
46 | |
---|
47 | |
---|
48 | |
---|
49 | |
---|
50 | |
---|
51 | set waypoint 0 |
---|
52 | |
---|
53 | |
---|
54 | # fenetre log |
---|
55 | ttk::frame .log -relief groove |
---|
56 | pack .log -side bottom -fill x |
---|
57 | set log_lines 7 |
---|
58 | |
---|
59 | |
---|
60 | set coltxt [ThemeColor 1.05] |
---|
61 | text .log.text_log -height $log_lines -yscrollcommand {.log.ybar_log set} -wrap word -font log_font -background $coltxt -highlightcolor $coltxt -highlightbackground $coltxt -selectbackground skyblue1 |
---|
62 | |
---|
63 | bind .log.text_log <Enter> [subst { set tabscroll 0 }] |
---|
64 | bind .log.text_log <Leave> [subst { set tabscroll 1 }] |
---|
65 | |
---|
66 | |
---|
67 | |
---|
68 | |
---|
69 | ttk::scrollbar .log.ybar_log -orient vertical -command {.log.text_log yview} |
---|
70 | |
---|
71 | ttk::button .log.copy -image icon_clipboard -command { |
---|
72 | clipboard clear |
---|
73 | clipboard append [.log.text_log get -- 1.0 end] |
---|
74 | puts [.log.text_log get -- 1.0 end] |
---|
75 | } |
---|
76 | ttk::button .log.palm -image icon_palm -command [subst { |
---|
77 | .log.text_log configure -state normal |
---|
78 | for {set i 0} {\$i< 5} {incr i} { |
---|
79 | .log.text_log insert end "\n" |
---|
80 | } |
---|
81 | .log.text_log insert end "Waypoint \$waypoint" debug |
---|
82 | incr waypoint |
---|
83 | .log.text_log yview moveto 1.0 |
---|
84 | .log.text_log configure -state disabled |
---|
85 | }] |
---|
86 | ttk::button .log.zoom -image icon_magnifierplus -command { |
---|
87 | set curh [.log.text_log cget -height] |
---|
88 | if {$curh == 7} { |
---|
89 | .log.text_log configure -height 30 |
---|
90 | .log.zoom configure -image icon_magnifierminus |
---|
91 | } else { |
---|
92 | .log.text_log configure -height 7 |
---|
93 | .log.zoom configure -image icon_magnifierplus |
---|
94 | } |
---|
95 | } |
---|
96 | |
---|
97 | balloon .log.palm "Add some space and a numbered waypoint" |
---|
98 | balloon .log.zoom "Increase/Decrease the size of the log" |
---|
99 | balloon .log.copy "Copy log content to clipboard" |
---|
100 | |
---|
101 | # cartouche Identite |
---|
102 | ttk::frame .log.id |
---|
103 | set username [getConfig "config id user name"] |
---|
104 | set company [getConfig "config id user company"] |
---|
105 | set logo "icon_$company" |
---|
106 | if {$logo in [image names]} { |
---|
107 | ttk::label .log.id.logo -image "icon_$company" |
---|
108 | } else { |
---|
109 | puts "Warning , image $logo does not exists" |
---|
110 | ttk::label .log.id.logo |
---|
111 | } |
---|
112 | ttk::label .log.id.user -text $username |
---|
113 | ttk::label .log.id.power -style "Multiple.TLabel" -text "by Cerfacs" -image icon_gui_tiny -compound left -justify center |
---|
114 | |
---|
115 | pack .log.id.logo -side top -anchor center -padx 2 |
---|
116 | pack .log.id.user -side top -anchor center -padx 5 |
---|
117 | pack .log.id.power -side bottom -anchor center -padx 5 |
---|
118 | pack .log.id -side right -pady 2 -padx 2 -fill both |
---|
119 | |
---|
120 | |
---|
121 | pack .log.text_log -fill both -side left -expand true -pady 2 -padx {2 0} |
---|
122 | pack .log.ybar_log -side left -fill y -pady 2 -padx {0 2} |
---|
123 | pack .log.copy -side bottom -pady 2 |
---|
124 | pack .log.palm -side bottom -pady 2 |
---|
125 | pack .log.zoom -side bottom -pady 2 |
---|
126 | |
---|
127 | |
---|
128 | |
---|
129 | |
---|
130 | |
---|
131 | |
---|
132 | |
---|
133 | |
---|
134 | log {.____ ____ ___ _ _ _____ ___ _ |
---|
135 | / __ \ ) _)\ ) __( ) \/ ( )__ __() __( )_\ |
---|
136 | ))__(( | '__/ | _) | \ | | | | _) /( )\ |
---|
137 | \____/ )_( )___( )_()_( )_( )___( )_/ \_(} |
---|
138 | log "Version : $engine_version" |
---|
139 | |
---|
140 | |
---|
141 | .log.text_log tag configure none -foreground black |
---|
142 | .log.text_log tag configure debug -foreground blue |
---|
143 | .log.text_log tag configure ok -foreground green4 |
---|
144 | .log.text_log tag configure warning -foreground red |
---|
145 | .log.text_log tag configure xdrerror -foreground red4 |
---|
146 | .log.text_log tag configure xdrexecute -foreground grey50 |
---|
147 | .log.text_log tag configure plugin -foreground violet |
---|
148 | |
---|
149 | |
---|
150 | } |
---|
151 | |
---|
152 | proc log {txt {tagid none}} { |
---|
153 | global log_channel |
---|
154 | |
---|
155 | .log.text_log configure -state normal |
---|
156 | .log.text_log insert end "\n$txt" $tagid |
---|
157 | # limit the length of text |
---|
158 | .log.text_log delete 1.0 end-4000lines |
---|
159 | .log.text_log yview moveto 1.0 |
---|
160 | .log.text_log configure -state disabled |
---|
161 | |
---|
162 | puts $log_channel "$txt" |
---|
163 | |
---|
164 | } |
---|
165 | |
---|
166 | ################################################# |
---|
167 | # need description |
---|
168 | ################################################# |
---|
169 | |
---|
170 | proc arginfo {level} { |
---|
171 | set proc [lindex [info level [expr -1-$level]] 0] |
---|
172 | set which [uplevel [list namespace which -command $proc]] |
---|
173 | puts "proc \[$which\]" |
---|
174 | set i -1 |
---|
175 | foreach arg [info args $which] { |
---|
176 | incr i |
---|
177 | set value [uplevel [expr 1+$level] [list set $arg] ] |
---|
178 | if { [info default $which $arg def] } { |
---|
179 | puts " arg\[$i\] \[$arg\] = \[$value\] default = \[$def\]" |
---|
180 | } else { |
---|
181 | puts " arg\[$i\] \[$arg\] = \[$value\]" |
---|
182 | } |
---|
183 | } |
---|
184 | } |
---|
185 | |
---|
186 | ################################################# |
---|
187 | # need description |
---|
188 | ################################################# |
---|
189 | |
---|
190 | proc stackInfo {} { |
---|
191 | puts "" |
---|
192 | puts "=====================================" |
---|
193 | set levels [expr [info level]-1] |
---|
194 | for {set i 0} {$i <= $levels} {incr i} { |
---|
195 | arginfo $i |
---|
196 | } |
---|
197 | puts "=====================================" |
---|
198 | puts "" |
---|
199 | } |
---|
200 | |
---|
201 | |
---|
202 | |
---|
203 | proc exec_script {cmd} { |
---|
204 | |
---|
205 | set erreur [ catch {exec -ignorestderr {*}$cmd } err] |
---|
206 | if {$erreur} { |
---|
207 | warning "Error file attempting to do : $cmd" |
---|
208 | warning $err |
---|
209 | return 0 |
---|
210 | } |
---|
211 | return 1 |
---|
212 | } |
---|
213 | |
---|
214 | |
---|
215 | ################################################# |
---|
216 | # retrieve the current folder whatever the OS is |
---|
217 | ################################################## |
---|
218 | |
---|
219 | proc osPwd {} { |
---|
220 | # First try : UNIX |
---|
221 | if {[catch {set result [exec {pwd}]}]} { |
---|
222 | # Then : Windows |
---|
223 | if {[catch {set result [exec {echo %cd%}]}]} { |
---|
224 | # Unknown |
---|
225 | error "System unknown" |
---|
226 | } |
---|
227 | } |
---|
228 | return $result |
---|
229 | } |
---|
230 | |
---|
231 | proc copyFileInWkdir {path} { |
---|
232 | global workingDir |
---|
233 | set copiedfile [file tail $path] |
---|
234 | |
---|
235 | if {$copiedfile == $path} { |
---|
236 | } else { |
---|
237 | file copy -force $path [file join $workingDir $copiedfile] |
---|
238 | } |
---|
239 | return $copiedfile |
---|
240 | } |
---|
241 | |
---|
242 | proc lremove {listVariable value} { |
---|
243 | upvar 1 $listVariable var |
---|
244 | set idx [lsearch -exact $var $value] |
---|
245 | if {$idx != -1} { |
---|
246 | set var [lreplace $var $idx $idx] |
---|
247 | } |
---|
248 | } |
---|
249 | |
---|
250 | # get the max and min of a list |
---|
251 | proc list_bounds {input {min 1e+40} {max -1e+40} } { |
---|
252 | foreach item $input { |
---|
253 | if {$item > $max} {set max $item} |
---|
254 | if {$item < $min} {set min $item} |
---|
255 | |
---|
256 | } |
---|
257 | return "$min $max" |
---|
258 | } |
---|
259 | |
---|
260 | |
---|
261 | |
---|
262 | |
---|
263 | ############################################################## |
---|
264 | # Handle unexpected errors in the tcl/tk code with a message # |
---|
265 | # Replace the default tk procedure that display a code error # |
---|
266 | ############################################################## |
---|
267 | proc bgerror {error} { |
---|
268 | global errorInfo conf engine_version |
---|
269 | # Save the stack error message and save it in an error file with the time and configuration information |
---|
270 | set bugReport $errorInfo |
---|
271 | |
---|
272 | set current_dir [pwd] |
---|
273 | set bugFilePath [file join $current_dir "bug_Report.txt"] |
---|
274 | set bugFile [open $bugFilePath w] |
---|
275 | puts $bugFile "Error generated the [clock format [clock seconds] -format {%b. %d, %Y %I:%M:%S %p}]" |
---|
276 | puts $bugFile "Stack report:" |
---|
277 | puts $bugFile "$bugReport" |
---|
278 | puts $bugFile "-----------------------------------------------" |
---|
279 | puts $bugFile "User configuration:" |
---|
280 | foreach var [array names conf] { |
---|
281 | puts $bugFile "$var : $conf($var)" |
---|
282 | } |
---|
283 | close $bugFile |
---|
284 | |
---|
285 | # Display a pop up for the user |
---|
286 | set win ".error" |
---|
287 | set ierror 0 |
---|
288 | |
---|
289 | |
---|
290 | if {[winfo exists $win]} { |
---|
291 | destroy $win |
---|
292 | } |
---|
293 | |
---|
294 | toplevel $win |
---|
295 | wm title $win "Internal error" |
---|
296 | |
---|
297 | |
---|
298 | ttk::frame $win.f |
---|
299 | pack $win.f |
---|
300 | |
---|
301 | ttk::label $win.f.mess -text "Internal error: \n $error" -image icon_garfield -compound left |
---|
302 | |
---|
303 | |
---|
304 | ttk::frame $win.f.report |
---|
305 | text $win.f.report.txt -yscrollcommand [list $win.f.report.sby set] -width 70 -height 10 -wrap word |
---|
306 | ttk::scrollbar $win.f.report.sby -orient vertical -command [list $win.f.report.txt yview] |
---|
307 | $win.f.report.txt insert end "engine : $engine_version \n \n $bugReport" |
---|
308 | grid $win.f.report.txt -row 0 -column 0 -sticky news |
---|
309 | grid $win.f.report.sby -row 0 -column 1 -sticky news |
---|
310 | |
---|
311 | |
---|
312 | ttk::separator $win.f.sep |
---|
313 | ttk::label $win.f.panel -text "This error is not handled . Contact the person in charge on your site\n On his/her behalf, post a full description on how it happened plus the file:\n $bugFilePath \n " -justify center |
---|
314 | pack $win.f.mess -pady 20 |
---|
315 | pack $win.f.report -pady 10 |
---|
316 | pack $win.f.sep -fill x |
---|
317 | pack $win.f.panel -pady 20 |
---|
318 | |
---|
319 | raise $win . |
---|
320 | |
---|
321 | } |
---|
322 | |
---|
323 | |
---|
324 | |
---|
325 | |
---|
326 | proc balloon {w help} { |
---|
327 | bind $w <Any-Enter> "after 500 [list balloon:show %W [list $help]]" |
---|
328 | bind $w <Any-Leave> "destroy %W.balloon" |
---|
329 | } |
---|
330 | |
---|
331 | proc balloon:show {w arg} { |
---|
332 | if {[eval winfo containing [winfo pointerxy .]]!=$w} {return} |
---|
333 | set top $w.balloon |
---|
334 | catch {destroy $top} |
---|
335 | toplevel $top -bd 1 -bg black |
---|
336 | wm overrideredirect $top 1 |
---|
337 | |
---|
338 | if {[string equal [tk windowingsystem] aqua]} { |
---|
339 | ::tk::unsupported::MacWindowStyle style $top help none |
---|
340 | } |
---|
341 | pack [message $top.txt -aspect 10000 -bg lightyellow \ |
---|
342 | -font fixed -text $arg] |
---|
343 | set wmx [winfo rootx $w] |
---|
344 | set wmy [expr [winfo rooty $w]+[winfo height $w]] |
---|
345 | wm geometry $top \ |
---|
346 | [winfo reqwidth $top.txt]x[winfo reqheight $top.txt]+$wmx+$wmy |
---|
347 | raise $top |
---|
348 | } |
---|
349 | |
---|
350 | proc split_list {L} { |
---|
351 | |
---|
352 | set len [expr {int(0.5*[llength $L])}] |
---|
353 | set A "" |
---|
354 | set B "" |
---|
355 | for {set i 0} {$i< $len} {incr i} { |
---|
356 | lappend A [lindex $L [expr {$i*2}]] |
---|
357 | lappend B [lindex $L [expr {$i*2+1}]] |
---|
358 | } |
---|
359 | return "{$A} {$B}" |
---|
360 | } |
---|
361 | |
---|
362 | proc get_keys_listcsv {L} { |
---|
363 | |
---|
364 | set L [split $L ";"] |
---|
365 | set len [expr {int(0.5*[llength $L])}] |
---|
366 | set A "" |
---|
367 | for {set i 0} {$i< $len} {incr i} { |
---|
368 | lappend A [lindex $L [expr {$i*2}]] |
---|
369 | } |
---|
370 | return $A |
---|
371 | } |
---|
372 | |
---|
373 | proc get_values_listcsv {L} { |
---|
374 | set L [split $L ";"] |
---|
375 | set len [expr {int(0.5*[llength $L])}] |
---|
376 | set A "" |
---|
377 | for {set i 0} {$i< $len} {incr i} { |
---|
378 | lappend A [lindex $L [expr {$i*2+1}]] |
---|
379 | } |
---|
380 | return $A |
---|
381 | } |
---|
382 | |
---|
383 | proc keyvalue_listcsv {L} { |
---|
384 | set L [split $L ";"] |
---|
385 | set len [expr {int(0.5*[llength $L])}] |
---|
386 | set A "" |
---|
387 | |
---|
388 | for {set i 0} {$i< $len} {incr i} { |
---|
389 | lappend A "[lindex $L [expr {$i*2}]] [lindex $L [expr {$i*2+1}]]" |
---|
390 | } |
---|
391 | return $A |
---|
392 | } |
---|
393 | |
---|
394 | # to limit huge chunks of text |
---|
395 | proc limit_string {str max} { |
---|
396 | set str2 $str |
---|
397 | set bit [expr {int(0.5*$max)}] |
---|
398 | if {[string length $str] >$max} { |
---|
399 | set str2 "[string range $str 0 $bit](...) [string range $str end-$bit end] " |
---|
400 | } |
---|
401 | return $str2 |
---|
402 | } |
---|
403 | |
---|
404 | #to get the parent of a dot separated string |
---|
405 | proc crop_address {adr levels} { |
---|
406 | set ladr [split $adr "."] |
---|
407 | set end_adr [expr {[llength $ladr] - $levels -1 }] |
---|
408 | |
---|
409 | if {$end_adr <0 } { |
---|
410 | error "crop_address cannot crop $levels levels from $adr" |
---|
411 | return |
---|
412 | } |
---|
413 | set new_adr [join [lrange $ladr 0 $end_adr] "."] |
---|
414 | return $new_adr |
---|
415 | } |
---|
416 | |
---|
417 | |
---|
418 | proc canvas_text_vector {w x y txt pos size rotate color tags} { |
---|
419 | |
---|
420 | set hsize [expr {0.7 *$size}] |
---|
421 | set csize [expr {0.7 *$hsize}] |
---|
422 | |
---|
423 | set slant 0.0 |
---|
424 | set rotate [expr {$rotate*1./180*3.1415}] |
---|
425 | |
---|
426 | set txtl [split $txt ""] |
---|
427 | |
---|
428 | set ltxt [llength $txtl] |
---|
429 | set wtxt [expr {$ltxt*$hsize}] |
---|
430 | |
---|
431 | set x0 $x |
---|
432 | set y0 $y |
---|
433 | |
---|
434 | |
---|
435 | |
---|
436 | |
---|
437 | |
---|
438 | switch $pos { |
---|
439 | "center" { |
---|
440 | set xstart [expr {-$wtxt*0.5}] |
---|
441 | set ystart [expr {-$size*0.5}] |
---|
442 | } |
---|
443 | "ne" { |
---|
444 | set xstart [expr {+$wtxt*0.1}] |
---|
445 | set ystart [expr {+$size*0.1}] |
---|
446 | } |
---|
447 | "e" { |
---|
448 | set xstart [expr {+$wtxt*0.1}] |
---|
449 | set ystart [expr {-$size*0.5}] |
---|
450 | } |
---|
451 | "se" { |
---|
452 | set xstart [expr {+$wtxt*0.1}] |
---|
453 | set ystart [expr {-$size*1.1}] |
---|
454 | } |
---|
455 | "nw" { |
---|
456 | set xstart [expr {-$wtxt*1 -$size*0.1}] |
---|
457 | set ystart [expr {+$size*0.1}] |
---|
458 | } |
---|
459 | "w" { |
---|
460 | set xstart [expr {-$wtxt*1 -$size*0.1}] |
---|
461 | set ystart [expr {-$size*0.5}] |
---|
462 | } |
---|
463 | "sw" { |
---|
464 | set xstart [expr {-$wtxt*1 -$size*0.1}] |
---|
465 | set ystart [expr {-$size*1.1}] |
---|
466 | } |
---|
467 | } |
---|
468 | |
---|
469 | foreach char $txtl { |
---|
470 | switch $char { |
---|
471 | |
---|
472 | "0" {set draw {{0.7 0} {1 0.3} {1 0.7} {0.7 1} {0.7 1} {0.3 1} {0 0.7} {0 0.3} {0.3 0} {0.7 0} {0.3 1}}} |
---|
473 | "1" {set draw {{0.1 0} {0.9 0} {0.5 0} {0.5 1} {0.2 0.7}}} |
---|
474 | "2" {set draw {{1 0} {0 0} {1 0.7} {0.7 1} {0.7 1} {0.3 1} {0 0.7}}} |
---|
475 | "3" {set draw {{0 0} {0.7 0} {1 0.3} {0.8 0.6} {0.5 0.6} {0.8 0.6} {1 0.7} {1 0.8} {0.8 1} {0.7 1} {0 1} }} |
---|
476 | "4" {set draw {{0.7 0} {0.7 1} {0 0.3} {1 0.3} }} |
---|
477 | "5" {set draw {{1 1} {0 1} {0 0.55} {1 0.55} {1 0.2} {0.8 0} {0 0}}} |
---|
478 | "6" {set draw {{0.9 1} {0.3 1} {0 0.7} {0 0.2} {0.2 0} {0.8 0} {1 0.2} {1 0.4} {0.8 0.5} {0 0.5}}} |
---|
479 | "7" {set draw {{0 0} {0 0.2} {1 1} {0 1} {0 0.9}}} |
---|
480 | "8" {set draw {{0.7 0} {1 0.3} {1 0.4} {0.1 0.7} {0.1 0.8} {0.3 1} {0.7 1} {0.9 0.8} {0.9 0.7} {0 0.4} {0 0.3} {0.3 0} {0.7 0}}} |
---|
481 | "9" {set draw {{0 0} {0.80 0} {1 0.2} {1 0.8} {0.8 1} {0.2 1} {0 0.8} {0 0.6} {0.1 0.5} {1 0.5} }} |
---|
482 | "A" {set draw {{0 0} {0.5 1} {0.75 0.5} {0.25 0.5} {0.75 0.5} {1 0} }} |
---|
483 | "a" {set draw {{1 0} {1 0.7} {0.2 0.7} {0 0.5} {0 0.1} {0.1 0} {0.9 0} {1 0.1} }} |
---|
484 | "B" {set draw {{0 0.5} {0.8 0.5} {1 0.7} {1 0.8} {0.8 1} {0 1} {0 0} {0.8 0} {1 0.2} {1 0.3} {0.8 0.5} }} |
---|
485 | "b" {set draw {{0 1} {0 0} {0.8 0} {1 0.1} {1 0.5} {0.5 0.7} {0 0.5}}} |
---|
486 | "C" {set draw {{1 1} {0.2 1} {0 0.8} {0 0.2} {0.2 0} {1 0}}} |
---|
487 | "c" {set draw {{1 0.7} {0.2 0.7} {0 0.5} {0 0.2} {0.2 0} {1 0}}} |
---|
488 | "D" {set draw {{0 1} {0 0} {0.8 0} {1 0.2} {1 0.8} {0.8 1} {0 1}}} |
---|
489 | "d" {set draw {{1 1} {1 0} {1 0.1} {0.9 0} {0.2 0} {0 0.2} {0 0.4} {0.5 0.7} {1 0.7}}} |
---|
490 | "E" {set draw {{1 0} {0 0} {0 0.5} {0.4 0.5} {0 0.5} {0 1} {1 1} }} |
---|
491 | "e" {set draw {{0 0.35} {1 0.35} {1 0.5} {0.8 0.7} {0.2 0.7} {0 0.5} {0 0.2} {0.2 0} {1 0}}} |
---|
492 | "F" {set draw {{0 0} {0 0.5} {0.4 0.5} {0 0.5} {0 1} {1 1} }} |
---|
493 | "f" {set draw {{0.5 0} {0.5 0.7} {0 0.7} {1 0.7} {0.5 0.7} {0.5 0.8} {0.8 1} {1 1} }} |
---|
494 | "G" {set draw {{1 1} {0.2 1} {0 0.8 } {0 0.2} {0.2 0} {1 0} {1 0.5} {0.8 0.5} }} |
---|
495 | "g" {set draw { {0 -0.1} {0.2 -0.3} {0.8 -0.3} {1 -0.1} {1 0.7} {0.3 0.7} {0 0.3} {0 0.3} {0.3 0} {0.8 0} {1 0.2} }} |
---|
496 | "H" {set draw {{0 0} {0 1} {0 0.5} {1 0.5} {1 1} {1 0}}} |
---|
497 | "h" {set draw {{0 1} {0 0} {0 0.5} {0.5 0.7} {0.8 0.7} {1 0.5} {1 0}}} |
---|
498 | "I" {set draw {{0.3 0} {0.7 0} {0.5 0} {0.5 1} {0.7 1} {0.3 1}}} |
---|
499 | "i" {set draw {{0.3 0.7} {0.5 0.7} {0.5 0} {0.8 0}}} |
---|
500 | "J" {set draw {{0 0} {0.5 0} {0.7 0.2} {0.7 1} {0.5 1} }} |
---|
501 | "j" {set draw {{0.1 0.7} {0.7 0.7} {0.7 -0.1} {0.5 -0.3} {0 -0.3}}} |
---|
502 | "K" {set draw {{0 0} {0 1} {0 0.6} {1 0} {0 0.6} {1 1} }} |
---|
503 | "k" {set draw {{0 0} {0 1} {0 0.4} {1 0} {0 0.4} {1 0.7}}} |
---|
504 | "L" {set draw {{0 1} {0 0} {1 0}}} |
---|
505 | "l" {set draw {{0.3 1} {0.5 1} {0.5 0} {0.8 0}}} |
---|
506 | "M" {set draw {{0 0} {0 1} {0.5 0.3} {1 1} {1 0}}} |
---|
507 | "m" {set draw {{0 0} {0 0.7} {0 0.5} {0.5 0.7} {0.5 0} {0.5 0.5} {0.8 0.7} {1 0.5} {1 0}}} |
---|
508 | "N" {set draw {{0 0} {0 1} {1 0} {1 1} }} |
---|
509 | "n" {set draw {{0 0} {0 0.7} {0 0.5} {0.8 0.7} {1 0.5} {1 0} }} |
---|
510 | "O" {set draw {{0.7 0} {1 0.3} {1 0.7} {0.7 1} {0.7 1} {0.3 1} {0 0.7} {0 0.3} {0.3 0} {0.7 0}}} |
---|
511 | "o" {set draw {{0.7 0} {1 0.3} {1 0.5} {0.7 0.7} {0.7 0.7} {0.3 0.7} {0 0.5} {0 0.3} {0.3 0} {0.7 0}}} |
---|
512 | "P" {set draw {{0 0} {0 1} {0.8 1} {1 0.8} {1 0.7} {0.8 0.5} {0 0.5}}} |
---|
513 | "p" {set draw {{0 0.7} {0 -0.3} {0 0} {0.8 0} {1 0.2} {1 0.5} {0.5 0.7} {0 0.5}}} |
---|
514 | "Q" {set draw {{0.7 0} {1 0.3} {1 0.7} {0.7 1} {0.7 1} {0.3 1} {0 0.7} {0 0.3} {0.3 0} {0.7 0} {0.9 -0.2}}} |
---|
515 | "q" {set draw {{1 -0.3} {1 0.7} {0.2 0.7} {0 0.5} {0 0.1} {0.1 0} {0.9 0} {1 0.1} }} |
---|
516 | "R" {set draw {{0 0} {0 1} {0.8 1} {1 0.8} {1 0.7} {0.8 0.5} {0 0.5} {1 0} }} |
---|
517 | "r" {set draw {{0 0.7} {0 0} {0 0.5} {0.5 0.7} {1 0.7} {1 0.5}}} |
---|
518 | "S" {set draw {{0 0} {0.8 0} {1 0.2} {1 0.3} {0 0.7} {0 0.8} {0.2 1} {1 1}}} |
---|
519 | "s" {set draw {{0 0} {0.8 0} {1 0.2} {1 0.3} {0 0.5} {0 0.6} {0.2 0.7} {1 0.7}}} |
---|
520 | "T" {set draw {{0.5 0} {0.5 1} {1 1} {0 1}}} |
---|
521 | "t" {set draw {{0 0.7} {0.8 0.7} {0.4 0.7} {0.4 1} {0.4 0.2} {0.6 0} {1 0}}} |
---|
522 | "U" {set draw {{0 1} {0 0.2} {0.2 0} {0.8 0} {1 0.2} {1 1}}} |
---|
523 | "u" {set draw {{0 0.7} {0 0.2} {0.2 0} {0.8 0} {1 0.2} {1 0.7} {1 0}}} |
---|
524 | "V" {set draw {{0 1} {0.5 0} {1 1} }} |
---|
525 | "v" {set draw {{0 0.7} {0.5 0} {1 0.7} }} |
---|
526 | "W" {set draw {{0 1} {0.3 0} {0.5 1} {0.7 0} {1 1}}} |
---|
527 | "w" {set draw {{0 0.7} {0.3 0} {0.5 0.7} {0.7 0} {1 0.7}}} |
---|
528 | "X" {set draw {{0 0} {1 1} {0.5 0.5} {1 0} {0 1}}} |
---|
529 | "x" {set draw {{0 0} {1 0.7} {0.5 0.35} {1 0} {0 0.7}}} |
---|
530 | "Y" {set draw {{0.5 0} {0.5 0.6} {0 1} {0.5 0.6} {1 1}}} |
---|
531 | "y" {set draw {{0 0.7} {0.5 0} {1 0.7} {0.4 -0.1} {0 -0.3}}} |
---|
532 | "Z" {set draw {{1 0} {0 0} {1 1} {0 1}}} |
---|
533 | "z" {set draw {{1 0} {0 0} {1 0.7} {0 0.7}}} |
---|
534 | "," {set draw {{0.7 0.20} {0.7 0} {0.9 -0.3} }} |
---|
535 | "." {set draw {{0.7 0.20} {0.7 0} }} |
---|
536 | "+" {set draw {{0.1 0.5} {0.9 0.5} {0.5 0.5} {0.5 0.2} {0.5 0.8} }} |
---|
537 | "-" {set draw {{0.1 0.5} {0.9 0.5}}} |
---|
538 | "(" {set draw { {0.7 1} {0.3 1} {0 0.7} {0 0.3} {0.3 0} {0.7 0} }} |
---|
539 | ")" {set draw { {0.3 1} {0.7 1} {1 0.7} {1 0.3} {0.7 0} {0.3 0} }} |
---|
540 | "[" {set draw { {0.7 1} {0 1} {0 0} {0.7 0} }} |
---|
541 | "]" {set draw { {0.3 1} {1 1} {1 0} {0.3 0} }} |
---|
542 | |
---|
543 | default {set draw ""} |
---|
544 | } |
---|
545 | set line "" |
---|
546 | foreach point $draw { |
---|
547 | set xx [expr { [lindex $point 0] * $csize } ] |
---|
548 | set yy [expr { ( 1. - [lindex $point 1] ) * $size } ] |
---|
549 | |
---|
550 | set x1 [expr { $xstart + $xx - $slant*$yy }] |
---|
551 | set y1 [expr { $ystart + $yy }] |
---|
552 | |
---|
553 | set x2 [expr {$x0+cos($rotate)*$x1 + sin($rotate)*$y1} ] |
---|
554 | set y2 [expr {$y0-sin($rotate)*$x1 + cos($rotate)*$y1} ] |
---|
555 | |
---|
556 | |
---|
557 | lappend line $x2 |
---|
558 | lappend line $y2 |
---|
559 | } |
---|
560 | if {$draw != ""} { |
---|
561 | $w create line $line -fill $color -width 1 -tags $tags |
---|
562 | } |
---|
563 | set xstart [expr { $xstart + $hsize }] |
---|
564 | |
---|
565 | #set ystart [expr { $ystart - sin($rotate)*$hsize + cos($rotate)*$size}] |
---|
566 | } |
---|
567 | |
---|
568 | } |
---|
569 | |
---|
570 | proc canvas_makegif2 {win filename} { |
---|
571 | global widgetInfo |
---|
572 | |
---|
573 | $win delete pointer |
---|
574 | set bbox [ $win bbox all] |
---|
575 | if {$bbox == ""} {return} |
---|
576 | set x0 [lindex $bbox 0] |
---|
577 | set y0 [lindex $bbox 1] |
---|
578 | set x1 [lindex $bbox 2] |
---|
579 | set y1 [lindex $bbox 3] |
---|
580 | |
---|
581 | set nx [expr {int ($x1 -$x0)}] |
---|
582 | set ny [expr {int ($y1 -$y0)}] |
---|
583 | |
---|
584 | image create photo fooble -width $nx -height $ny |
---|
585 | fooble blank |
---|
586 | foreach item [$win find all] { |
---|
587 | set rawcol [$win itemcget $item -fill] |
---|
588 | if {$rawcol == ""} { |
---|
589 | set rawcol [$win itemcget $item -outline] |
---|
590 | } |
---|
591 | if {$rawcol != ""} { |
---|
592 | set color [eval format "#%04x%04x%04x" [winfo rgb . $rawcol]] |
---|
593 | set type [$win type $item ] |
---|
594 | |
---|
595 | switch $type { |
---|
596 | "line" { |
---|
597 | set coords [$win coords $item] |
---|
598 | set xi0 [expr {([lindex $coords 0])}] |
---|
599 | set yi0 [expr {([lindex $coords 1])}] |
---|
600 | foreach {xi1 yi1} $coords { |
---|
601 | set dx [expr {$xi1-$xi0}] |
---|
602 | set dy [expr {$yi1-$yi0}] |
---|
603 | set adx [expr {abs($dx)}] |
---|
604 | set ady [expr {abs($dy)}] |
---|
605 | if {$dx>0} { |
---|
606 | set stepx 1 |
---|
607 | } else { |
---|
608 | set stepx -1 |
---|
609 | } |
---|
610 | if {$dy>0} { |
---|
611 | set stepy 1 |
---|
612 | } else { |
---|
613 | set stepy -1 |
---|
614 | } |
---|
615 | |
---|
616 | if { $adx > $ady} { |
---|
617 | if {$adx > 1} { |
---|
618 | if {$stepx == 1} { |
---|
619 | for {set x [expr {int($xi0)}]} {$x <$xi1} {incr x 1} { |
---|
620 | set y [expr {int($yi0 + ($x - $xi0)/($xi1-$xi0) * ($yi1-$yi0))}] |
---|
621 | fooble put $color -to [expr {($x-$x0)}] [expr {($y-$y0)}] |
---|
622 | } |
---|
623 | } else { |
---|
624 | for {set x [expr {int($xi1)}]} {$x <$xi0} {incr x 1} { |
---|
625 | set y [expr {int($yi0 + ($x - $xi0)/($xi1-$xi0) * ($yi1-$yi0))}] |
---|
626 | fooble put $color -to [expr {($x-$x0)}] [expr {($y-$y0)}] |
---|
627 | } |
---|
628 | } |
---|
629 | } |
---|
630 | } |
---|
631 | if {$ady > $adx } { |
---|
632 | if {$ady > 1} { |
---|
633 | if {$stepy == 1} { |
---|
634 | for {set y [expr {int($yi0)}]} {$y <$yi1} {incr y 1} { |
---|
635 | set x [expr {int($xi0 + ($y - $yi0)/($yi1-$yi0) * ($xi1-$xi0))}] |
---|
636 | fooble put $color -to [expr {($x-$x0)}] [expr {($y-$y0)}] |
---|
637 | } |
---|
638 | } else { |
---|
639 | for {set y [expr {int($yi1)}]} {$y <$yi0} {incr y 1} { |
---|
640 | set x [expr {int($xi0 + ($y - $yi0)/($yi1-$yi0) * ($xi1-$xi0))}] |
---|
641 | fooble put $color -to [expr {($x-$x0)}] [expr {($y-$y0)}] |
---|
642 | } |
---|
643 | |
---|
644 | } |
---|
645 | } |
---|
646 | } |
---|
647 | |
---|
648 | set xi0 $xi1 |
---|
649 | set yi0 $yi1 |
---|
650 | } |
---|
651 | } |
---|
652 | "oval" { |
---|
653 | set coords [$win coords $item] |
---|
654 | set xmin [lindex $coords 0] |
---|
655 | set ymin [lindex $coords 1] |
---|
656 | set xmax [lindex $coords 2] |
---|
657 | set ymax [lindex $coords 3] |
---|
658 | set xmid [expr {(0.5*($xmax+$xmin))}] |
---|
659 | set ymid [expr {(0.5*($ymax+$ymin))}] |
---|
660 | set dx [expr {($xmax-$xmin)}] |
---|
661 | set rad [expr {(0.5*$dx)}] |
---|
662 | set hrad [expr {(0.36*$dx)}] |
---|
663 | fooble put $color -to [expr {int($xmid-$hrad-$x0)}] [expr {int($ymid-$hrad-$y0)}] [expr {int($xmid+$hrad-$x0)}] [expr {int($ymid+$hrad-$y0)}] |
---|
664 | |
---|
665 | #for {set x [expr {int(-$hrad)}] } {$x <=$hrad} {incr x} { |
---|
666 | # for {set y [expr {int($hrad)}] } {$y <= $rad} {incr y} { |
---|
667 | # #puts "here $x $y" |
---|
668 | # set radius [expr {$x*$x+$y*$y}] |
---|
669 | # if {$radius < [expr {$rad*$rad}]} { |
---|
670 | # fooble put $color -to [expr {int($xmid+$x-$x0)}] [expr {int($ymid+$y-$y0)}] |
---|
671 | # fooble put $color -to [expr {int($xmid+$x-$x0)}] [expr {int($ymid-$y-$y0)}] |
---|
672 | # fooble put $color -to [expr {int($xmid+$y-$x0)}] [expr {int($ymid+$x-$y0)}] |
---|
673 | # fooble put $color -to [expr {int($xmid-$y-$x0)}] [expr {int($ymid+$x-$y0)}] |
---|
674 | # } |
---|
675 | # } |
---|
676 | #} |
---|
677 | } |
---|
678 | "default" { |
---|
679 | set bbox [$win bbox $item] |
---|
680 | set xi0 [lindex $bbox 0] |
---|
681 | set yi0 [lindex $bbox 1] |
---|
682 | set xi1 [lindex $bbox 2] |
---|
683 | set yi1 [lindex $bbox 3] |
---|
684 | canvas_makegif_scan $win $xi0 $xi1 $yi0 $yi1 $x0 $y0 |
---|
685 | } |
---|
686 | } |
---|
687 | #switch $type { |
---|
688 | # "oval" { |
---|
689 | # |
---|
690 | # set coords [$win coords $item] |
---|
691 | # set xmin [lindex $coords 0] |
---|
692 | # set ymin [lindex $coords 1] |
---|
693 | # set xmax [lindex $coords 2] |
---|
694 | # set ymax [lindex $coords 3] |
---|
695 | # fooble put $color -to [expr {int($xmin-$x0)}] [expr {int($ymin-$y0)}] [expr {int($xmax-$x0)}] [expr {int($ymax-$y0)}] |
---|
696 | # } |
---|
697 | # "line" { |
---|
698 | # set coords [$win coords $item] |
---|
699 | # |
---|
700 | # fooble put blue -to [expr {int($xmin-$x0)}] [expr {int($ymin-$y0)}] [expr {int($xmax-$x0)}] [expr {int($ymax-$y0)}] |
---|
701 | # } |
---|
702 | #} |
---|
703 | } |
---|
704 | } |
---|
705 | fooble write $filename -format gif |
---|
706 | puts "Done..." |
---|
707 | } |
---|
708 | |
---|
709 | |
---|
710 | |
---|
711 | proc canvas_makegif {win filename} { |
---|
712 | global widgetInfo |
---|
713 | |
---|
714 | $win delete pointer |
---|
715 | set bbox [ $win bbox all] |
---|
716 | if {$bbox == ""} {return} |
---|
717 | set x0 [lindex $bbox 0] |
---|
718 | set y0 [lindex $bbox 1] |
---|
719 | set x1 [lindex $bbox 2] |
---|
720 | set y1 [lindex $bbox 3] |
---|
721 | |
---|
722 | set nx [expr {int ($x1 -$x0)}] |
---|
723 | set ny [expr {int ($y1 -$y0)}] |
---|
724 | |
---|
725 | image create photo fooble -width $nx -height $ny |
---|
726 | fooble blank |
---|
727 | canvas_makegif_iterate $win $x0 $x1 $y0 $y1 $x0 $y0 |
---|
728 | fooble write $filename -format gif |
---|
729 | image delete fooble |
---|
730 | #puts "Done..." |
---|
731 | } |
---|
732 | |
---|
733 | proc canvas_makegif_scan {win xmin xmax ymin ymax x0 y0 } { |
---|
734 | set item [$win find overlapping $xmin $ymin $xmax $ymax] |
---|
735 | if {$item == ""} { |
---|
736 | # #debug "Skipping square $square" |
---|
737 | return |
---|
738 | } |
---|
739 | |
---|
740 | set multipleitem 1 |
---|
741 | |
---|
742 | if {[llength $item] == 1} { |
---|
743 | set rawcol [$win itemcget $item -fill] |
---|
744 | if {$rawcol == ""} { |
---|
745 | set rawcol [$win itemcget $item -outline] |
---|
746 | } |
---|
747 | if {$rawcol != ""} { |
---|
748 | set color [eval format "#%04x%04x%04x" [winfo rgb . $rawcol]] |
---|
749 | set multipleitem 0 |
---|
750 | #fooble put $color -to [expr {$xmin-$x0}] [expr {$ymin-$y0}] [expr {$xmax-$x0}] [expr {$ymax-$y0}] |
---|
751 | } else { |
---|
752 | #set color "" |
---|
753 | #nocolor for single item, skip |
---|
754 | return |
---|
755 | } |
---|
756 | } |
---|
757 | |
---|
758 | for {set x $xmin} {$x<=$xmax} {incr x} { |
---|
759 | for {set y $ymin} {$y<=$ymax} {incr y} { |
---|
760 | set item [$win find overlapping $x $y $x $y] |
---|
761 | if {$item != ""} { |
---|
762 | |
---|
763 | if {$multipleitem} { |
---|
764 | set item [lindex $item end] |
---|
765 | set rawcol [$win itemcget $item -fill] |
---|
766 | if {$rawcol == ""} { |
---|
767 | set rawcol [$win itemcget $item -outline] |
---|
768 | } |
---|
769 | if {$rawcol != ""} { |
---|
770 | set color [eval format "#%04x%04x%04x" [winfo rgb . $rawcol]] |
---|
771 | } else { |
---|
772 | set color "" |
---|
773 | } |
---|
774 | } |
---|
775 | if {$color != ""} { |
---|
776 | fooble put $color -to [expr {$x-$x0}] [expr {$y-$y0}] |
---|
777 | } |
---|
778 | } |
---|
779 | } |
---|
780 | } |
---|
781 | } |
---|
782 | |
---|
783 | proc canvas_makegif_iterate {win xmin xmax ymin ymax x0 y0 } { |
---|
784 | set item [$win find overlapping $xmin $ymin $xmax $ymax] |
---|
785 | |
---|
786 | if {$item== ""} { |
---|
787 | #debug "Skipping square $square" |
---|
788 | return |
---|
789 | } |
---|
790 | |
---|
791 | set xmid [expr {int (0.5*($xmax+$xmin))}] |
---|
792 | set ymid [expr {int (0.5*($ymax+$ymin))}] |
---|
793 | |
---|
794 | set xmidp1 [expr {$xmid+1}] |
---|
795 | set ymidp1 [expr {$ymid+1}] |
---|
796 | |
---|
797 | if { [expr ($ymid-$ymin)]> 2} { |
---|
798 | canvas_makegif_iterate $win $xmin $xmid $ymin $ymid $x0 $y0 |
---|
799 | canvas_makegif_iterate $win $xmin $xmid $ymidp1 $ymax $x0 $y0 |
---|
800 | canvas_makegif_iterate $win $xmidp1 $xmax $ymin $ymid $x0 $y0 |
---|
801 | canvas_makegif_iterate $win $xmidp1 $xmax $ymidp1 $ymax $x0 $y0 |
---|
802 | } else { |
---|
803 | canvas_makegif_scan $win $xmin $xmax $ymin $ymax $x0 $y0 |
---|
804 | } |
---|
805 | return |
---|
806 | } |
---|
807 | |
---|
808 | |
---|
809 | # function to create a text on a canvas with surrounding white |
---|
810 | proc canvas_text_highlighted {wincan x y txt tags} { |
---|
811 | set bbox [$wincan bbox all] |
---|
812 | set midx [expr {0.5*([lindex $bbox 0]+[lindex $bbox 2])}] |
---|
813 | set midy [expr {0.5*([lindex $bbox 1]+[lindex $bbox 3])}] |
---|
814 | |
---|
815 | if {$x>$midx} { |
---|
816 | set dx -5 |
---|
817 | set posx e |
---|
818 | } else { |
---|
819 | set dx 5 |
---|
820 | set posx w |
---|
821 | } |
---|
822 | if {$y>$midy} { |
---|
823 | set dy -5 |
---|
824 | set posy s |
---|
825 | } else { |
---|
826 | set dy 5 |
---|
827 | set posy n |
---|
828 | } |
---|
829 | |
---|
830 | set anchor "$posy$posx" |
---|
831 | |
---|
832 | $wincan create text [expr {$dx+$x-1}] [expr {$dy+$y-1}] -text $txt -tags $tags -anchor $anchor -fill white |
---|
833 | $wincan create text [expr {$dx+$x+1}] [expr {$dy+$y-1}] -text $txt -tags $tags -anchor $anchor -fill white |
---|
834 | $wincan create text [expr {$dx+$x-1}] [expr {$dy+$y+1}] -text $txt -tags $tags -anchor $anchor -fill white |
---|
835 | $wincan create text [expr {$dx+$x+1}] [expr {$dy+$y+1}] -text $txt -tags $tags -anchor $anchor -fill white |
---|
836 | $wincan create text [expr {$dx+$x}] [expr {$dy+$y}] -text $txt -tags $tags -anchor $anchor -fill black |
---|
837 | } |
---|
838 | |
---|
839 | |
---|
840 | proc commify {num {sep ,}} { |
---|
841 | while {[regsub {^([-+]?\d+)(\d\d\d)} $num "\\1$sep\\2" num]} {} |
---|
842 | return $num |
---|
843 | } |
---|
844 | |
---|
845 | |
---|
846 | proc printtime { start stop } { |
---|
847 | return [format "%0.3f" [expr { ($stop - $start)*0.001 }]] |
---|
848 | } |
---|
849 | |
---|
850 | proc stringclean { str } { |
---|
851 | set str_c [string map {"à " "a" "ç" "c" "é" "e" "Ú" "e" "ù" "u" "ú" "u" "â" "a" "\t" " " ">" ".gt." "<" ".lt."} $str ] |
---|
852 | return $str_c |
---|
853 | } |
---|
854 | |
---|
855 | proc stringcleanBalise { str } { |
---|
856 | set str_c [stringclean $str] |
---|
857 | # no spaces or operands |
---|
858 | set str_c [string map {" " "_" "*" "times" "+" "plus" "/" "divide" "\}" "\)" "\{" "\(" "%" "" "!" "" "?" ""} $str_c ] |
---|
859 | return $str_c |
---|
860 | } |
---|
861 | |
---|
862 | |
---|
863 | |
---|
864 | proc string2latex { str } { |
---|
865 | set str_c [string map {"à " "\\`{a}" "ç" "\\c{c}" "é" "\\'{e}" "Ú" "\\`{e}" "ù" "\\`{u}" "ú" "\\'{u}" } $str ] |
---|
866 | return $str_c |
---|
867 | } |
---|
868 | |
---|
869 | # return a random integer between min and max |
---|
870 | proc myRand { min max } { |
---|
871 | set value [ expr {int(rand() * ($max - $min)) + $min}] |
---|
872 | return $value |
---|
873 | } |
---|
874 | |
---|
875 | # EASTER EGG |
---|
876 | proc random_msg {} { |
---|
877 | set messages "" |
---|
878 | |
---|
879 | # envoie un message une fois sur dix seulement |
---|
880 | if {[myRand 1 100] > 10 } { return ""} |
---|
881 | |
---|
882 | lappend messages "Get outta here and go back to your boring programs." |
---|
883 | lappend messages "Just leave. When you come back, i'll be waiting with a bat." |
---|
884 | lappend messages "You're lucky i don't smack you for thinking about leaving." |
---|
885 | # TP spirit |
---|
886 | lappend messages "Vous avez verifie les bilans du calcul ? (T.P.)" |
---|
887 | lappend messages "Sur 100 calculs faux, 90 n'ont pas le bon point de fonctionnement, et 9 n'ont pas la bonne geometrie. (T.P.)" |
---|
888 | lappend messages "Si on a le bon signe et la bonne dimension, alors c'est un bon modele. (T.P.)" |
---|
889 | lappend messages "On ne change qu'un parametre a la fois. Un seul. Pas d'exceptions. (T.P.)" |
---|
890 | lappend messages "Il vaut mieux un qui sait que dix qui cherchent (T.P.)" |
---|
891 | |
---|
892 | lappend messages "Est ce que vous avez verifié Shannon? Tout est dans Shannon. (V.M.)" |
---|
893 | |
---|
894 | lappend messages "B****l de b**e (H.D.)" |
---|
895 | |
---|
896 | lappend messages "The answer is 42." |
---|
897 | lappend messages "He's dead, Jim!" |
---|
898 | lappend messages "Si vous pouvez lire ceci, c'est que vous n'avez probablement pas assez de travail." |
---|
899 | lappend messages "Dans simuler, y a -muler" |
---|
900 | #lappend messages "Je ne peux pas donner la seule chose que j'ai a vendre (Mestre Grrincha)" |
---|
901 | lappend messages "Tout calcul a le droit dâêtre présumé juste tant quâil nâest pas déclaré faux, conformément à la loi, par un tribunal indépendant et impartial à lâissue dâun procÚs public et équitable. " |
---|
902 | lappend messages "La ou s'abat le désespoir, s'eleve la victoire des perséverants (Thomas Sankara)" |
---|
903 | |
---|
904 | |
---|
905 | |
---|
906 | set max_index [expr {[llength $messages]-1}] |
---|
907 | set msg [lindex $messages [myRand 0 $max_index] ] |
---|
908 | return $msg |
---|
909 | } |
---|
910 | |
---|
911 | |
---|
912 | |
---|
913 | # Copyright CERFACS 2014 |
---|
914 | # |
---|
915 | # antoine.dauptain@cerfacs.fr |
---|
916 | # |
---|
917 | # This software is a computer program whose purpose is to ensure technology |
---|
918 | # transfer between academia and industry. |
---|
919 | # |
---|
920 | # This software is governed by the CeCILL-B license under French law and |
---|
921 | # abiding by the rules of distribution of free software. You can use, |
---|
922 | # modify and/ or redistribute the software under the terms of the CeCILL-B |
---|
923 | # license as circulated by CEA, CNRS and INRIA at the following URL |
---|
924 | # "http://www.cecill.info". |
---|
925 | # |
---|
926 | # As a counterpart to the access to the source code and rights to copy, |
---|
927 | # modify and redistribute granted by the license, users are provided only |
---|
928 | # with a limited warranty and the software's author, the holder of the |
---|
929 | # economic rights, and the successive licensors have only limited |
---|
930 | # liability. |
---|
931 | # |
---|
932 | # In this respect, the user's attention is drawn to the risks associated |
---|
933 | # with loading, using, modifying and/or developing or reproducing the |
---|
934 | # software by the user in light of its specific status of free software, |
---|
935 | # that may mean that it is complicated to manipulate, and that also |
---|
936 | # therefore means that it is reserved for developers and experienced |
---|
937 | # professionals having in-depth computer knowledge. Users are therefore |
---|
938 | # encouraged to load and test the software's suitability as regards their |
---|
939 | # requirements in conditions enabling the security of their systems and/or |
---|
940 | # data to be ensured and, more generally, to use and operate it in the |
---|
941 | # same conditions as regards security. |
---|
942 | # |
---|
943 | # The fact that you are presently reading this means that you have had |
---|
944 | # knowledge of the CeCILL-B license and that you accept its terms. |
---|