-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTK_BasicGraph.tcl
More file actions
95 lines (75 loc) · 3.12 KB
/
Copy pathTK_BasicGraph.tcl
File metadata and controls
95 lines (75 loc) · 3.12 KB
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
#!/bin/sh
# the next line restarts using tclsh \
exec $SPI_PATH/wish "$0" "$@"
#============================================================================
# Environnement Canada
# Centre Meteorologique Canadien
# 2100 Trans-Canadienne
# Dorval, Quebec
#
# Projet : Exemple de scripts.
# Fichier : TK_BasicGraph.tcl
# Creation : Juillet 2010 - J.P. Gauthier - CMC/CMOE
# Description: Demonstration du graph
#
# Parametres :
#
# Retour:
#============================================================================
puts \n[file tail [info script]]
package require TkglCanvas
package require TkGeoEER
font create FONT1 -family arial -weight bold -size 12 -slant italic
font create FONT2 -family courier -size 20 -slant italic
#----- Create graph
glcanvas .glcanvas -width 1000 -height 600 -bg grey -relief sunken -bd 1 -highlightthickness 0
pack .glcanvas -side top -fill both -expand True
.glcanvas create graph -x 5 -y 5 -width 990 -height 590 -anchor nw -xlegend 5 -ylegend 5 -command graphtest \
-fg black -bg gray -fill white -tags "GRAPH" -font FONT2 -title "Graph Test\nDoes it look ok ?"
#----- Get the item clicked with button 1
bind .glcanvas <Button-1> { Pick %x %y }
#----- Create axis
graphaxis create AXISX
graphaxis create AXISY
#----- Create date
vector create DATA
vector dim DATA { X Y }
#----- Create graphitem
graphitem create ITEM
graphitem configure ITEM -xaxis AXISX -yaxis AXISY -xdata DATA.X -ydata DATA.Y -orient X -desc "O3" \
-outline black -fill gray90 -iconfill red -iconoutline black -transparency 75 -width 1 -size 3 -value False -font FONT1 \
-type LINE -font FONT1 -icon CIRCLE -bitmap "" -stipple "" -image ""
#----- Load observation data into graph
set file /home/afsr/005/public_html/SPI/Script/DataIn/O3.20050302.obs
set obss [observation load $file]
#for { set n 0 } { $n<[observation define [lindex $obss 0] -NB] } { incr n }
for { set n 0 } { $n<50 } { incr n } {
set id [observation define [lindex $obss 0] -ID $n]
if { [expr $n%5]==0 } {
continue
}
foreach obs $obss {
set sec [expr [observation define $obs -DATE]+$n*60]
set val [observation define $obs -DATA $n]
if { $val=="-" } { set val 0 }
vector append DATA [list $sec [expr $val+10]]
break
}
}
#----- Configure graph axis
graphaxis configure AXISX -font FONT1 -type LINEAR -color blue -gridcolor lightblue -dash "." -position LL -width 1 \
-min [vector stats DATA.X -min] -max [expr [vector stats DATA.X -max]+300] -intervals [lsort -increasing [vector get DATA.X]] \
-unit "Temps" -format "TIME" -angle 30
graphaxis configure AXISY -font FONT1 -type LINEAR -color yellow -gridcolor gold -gridwidth 1 -dash "." -position LL -width 1 \
-min 0 -max [vector stats DATA.Y -max] -unit Pbb -increment 10 -angle 30
#----- Redraw graph
.glcanvas itemconf GRAPH -item ITEM
#----- This proc retreives the item clicked on
proc Pick { X Y } {
puts "Picked $X $Y: [graphtest -pick $X $Y]"
}
update idletasks
.glcanvas postscript -file $env(CI_DATA_OUT)/TK_BasicGraph.ps
image create photo TMPIMG
.glcanvas buffer TMPIMG 1 1 1000 600
TMPIMG write "$env(CI_DATA_OUT)/TK_BasicGraph.png" -format png