~uhh-ssd/+junk/humidity_readout

« back to all changes in this revision

Viewing changes to plplot/plplot-5.9.9/examples/tk/tk04.in

  • Committer: Joachim Erfle
  • Date: 2013-07-24 13:53:41 UTC
  • Revision ID: joachim.erfle@desy.de-20130724135341-1qojpp701zsn009p
initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!@xtk04_LOCATION@ -f
 
2
#                     -*-tcl-*-
 
3
# $Id: tk04.in 11657 2011-03-19 21:57:18Z airwin $
 
4
# Maurice LeBrun
 
5
# 30 Jun 1994
 
6
#
 
7
# @> A script illustrating use of 2-d tcl api (plframe).
 
8
###############################################################################
 
9
 
 
10
package require Itk
 
11
 
 
12
wm title . "tk04"
 
13
plstdwin .
 
14
 
 
15
###############################################################################
 
16
# Set up the menubar and message widgets.
 
17
 
 
18
frame .menu -relief raised -borderwidth 3
 
19
 
 
20
button .menu.comp -text "Compute Function" -command "compute"
 
21
button .menu.contour -text "Line Contour" -command "contour"
 
22
button .menu.shade -text "Color Fill Contour" -command "shade"
 
23
pack .menu.comp .menu.contour .menu.shade -side left
 
24
 
 
25
button .menu.exit -text "Exit" -command "destroy ." 
 
26
pack .menu.exit -side right
 
27
 
 
28
message .msg \
 
29
        -font -Adobe-helvetica-medium-r-normal--*-240* -aspect 200 \
 
30
         -width 500 -borderwidth 1 \
 
31
        -text "TK04: 2-d Tcl API"
 
32
 
 
33
pack .menu .msg -fill x
 
34
 
 
35
tk_menuBar .menu .menu.comp .menu.contour .menu.shade .menu.exit
 
36
 
 
37
PLXWin .plw
 
38
pack .plw -side bottom -expand 1 -fill both
 
39
 
 
40
matrix x f 64 64
 
41
 
 
42
# This is the front end to the data computation.  Initially we just
 
43
# create the matrix to hold the data, and then vector down to the C
 
44
# side to set the data.  However, one could easily embellish this to
 
45
# accept specifications from the user (via Tk entries), and act on
 
46
# them.  For instance, choosing the size of the matrix, passing
 
47
# paramaters to the compiled side, etc.
 
48
 
 
49
proc compute {} {
 
50
 
 
51
    global x
 
52
 
 
53
    get_data x
 
54
}
 
55
 
 
56
# Draw a contour of the data.
 
57
 
 
58
proc contour {} {
 
59
 
 
60
    global x
 
61
 
 
62
    .plw pladv
 
63
    .plw plvpor 0.1 0.9 0.1 0.9
 
64
    .plw plwind 1. 64. 1. 64.
 
65
 
 
66
    .plw plcol0 6
 
67
    .plw pllab "(x)" "(y)" "#frPLplot Example Tk04"
 
68
 
 
69
    # plot the data points
 
70
 
 
71
    .plw plcol0 9
 
72
 
 
73
    matrix clev f 10
 
74
 
 
75
    set max [x max]
 
76
    set min [x min]
 
77
 
 
78
    for {set i 0} {$i < 10} {incr i} {
 
79
        clev $i = [expr $min + ($max-$min)*($i+.5)/10 ]
 
80
    }
 
81
 
 
82
    .plw plcont x clev
 
83
 
 
84
    .plw plcol0 1
 
85
    .plw plbox "bcnst" 0.0 0 "bcnstv" 0.0 0
 
86
}
 
87
 
 
88
proc shade {} {
 
89
    
 
90
    global x
 
91
 
 
92
    .plw pladv
 
93
    .plw plvpor 0.1 0.9 0.1 0.9
 
94
    .plw plwind 0. 1. 0. 1.
 
95
 
 
96
    .plw plcol0 6
 
97
    .plw pllab "(x)" "(y)" "Cool shade plot example from Tcl"
 
98
 
 
99
    set max [x max]
 
100
    set min [x min]
 
101
 
 
102
    set xmin 0
 
103
    set xmax 1
 
104
    set ymin 0
 
105
    set ymax 1
 
106
 
 
107
    for {set i 0} {$i < 20} {incr i} {
 
108
        set sh_min [expr $min + ($max-$min)*$i/20.]
 
109
        set sh_max [expr $min + ($max-$min)*($i+1)/20.]
 
110
        set sh_col [expr $i/20.]
 
111
 
 
112
        .plw plshade x $xmin $xmax $ymin $ymax $sh_min $sh_max 1 $sh_col 0 \
 
113
            1 0 0 0 \
 
114
            1 "NULL"
 
115
            
 
116
    }
 
117
 
 
118
    .plw plcol0 1
 
119
    .plw plbox "bcnst" 0.0 0 "bcnstv" 0.0 0
 
120
}
 
121
 
 
122
###############################################################################