~uhh-ssd/+junk/humidity_readout

« back to all changes in this revision

Viewing changes to plplot/plplot-5.9.9/examples/tcl/x23.tcl

  • 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
#   $Id: x23.tcl 11680 2011-03-27 17:57:51Z airwin $
 
2
#
 
3
#   Displays Greek letters and mathematically interesting Unicode ranges
 
4
#   Copyright (C) 2005,2008 Alan Irwin
 
5
#   Copyright (C) 2005,2008 Andrew Ross
 
6
#
 
7
#
 
8
#   This file is part of PLplot.
 
9
#
 
10
#   PLplot is free software; you can redistribute it and/or modify
 
11
#   it under the terms of the GNU Library General Public License as published
 
12
#   by the Free Software Foundation; either version 2 of the License, or
 
13
#   (at your option) any later version.
 
14
#
 
15
#   PLplot is distributed in the hope that it will be useful,
 
16
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
17
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
18
#   GNU Library General Public License for more details.
 
19
#
 
20
#   You should have received a copy of the GNU Library General Public License
 
21
#   along with PLplot; if not, write to the Free Software
 
22
#   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
23
#
 
24
 
 
25
#
 
26
# Displays Greek letters and mathematically interesting Unicode ranges
 
27
#
 
28
 
 
29
proc x23 {{w loopback}} {
 
30
 
 
31
    set Greek0 "#gA"
 
32
    set Greek1 "#gB"
 
33
    set Greek2 "#gG"
 
34
    set Greek3 "#gD"
 
35
    set Greek4 "#gE"
 
36
    set Greek5 "#gZ"
 
37
    set Greek6 "#gY"
 
38
    set Greek7 "#gH"
 
39
    set Greek8 "#gI"
 
40
    set Greek9 "#gK"
 
41
    set Greek10 "#gL"
 
42
    set Greek11 "#gM"
 
43
    set Greek12 "#gN"
 
44
    set Greek13 "#gC"
 
45
    set Greek14 "#gO"
 
46
    set Greek15 "#gP"
 
47
    set Greek16 "#gR"
 
48
    set Greek17 "#gS"
 
49
    set Greek18 "#gT"
 
50
    set Greek19 "#gU"
 
51
    set Greek20 "#gF"
 
52
    set Greek21 "#gX"
 
53
    set Greek22 "#gQ"
 
54
    set Greek23 "#gW"
 
55
    set Greek24 "#ga"
 
56
    set Greek25 "#gb"
 
57
    set Greek26 "#gg"
 
58
    set Greek27 "#gd"
 
59
    set Greek28 "#ge"
 
60
    set Greek29 "#gz"
 
61
    set Greek30 "#gy"
 
62
    set Greek31 "#gh"
 
63
    set Greek32 "#gi"
 
64
    set Greek33 "#gk"
 
65
    set Greek34 "#gl"
 
66
    set Greek35 "#gm"
 
67
    set Greek36 "#gn"
 
68
    set Greek37 "#gc"
 
69
    set Greek38 "#go"
 
70
    set Greek39 "#gp"
 
71
    set Greek40 "#gr"
 
72
    set Greek41 "#gs"
 
73
    set Greek42 "#gt"
 
74
    set Greek43 "#gu"
 
75
    set Greek44 "#gf"
 
76
    set Greek45 "#gx"
 
77
    set Greek46 "#gq"
 
78
    set Greek47 "#gw"
 
79
 
 
80
 
 
81
    matrix Type1 i 166 = {
 
82
        0x0020, 0x0021, 0x0023, 0x0025, 0x0026,
 
83
        0x0028, 0x0029, 0x002b, 0x002c, 0x002e,
 
84
        0x002f, 0x0030, 0x0031, 0x0032, 0x0033,
 
85
        0x0034, 0x0035, 0x0036, 0x0037, 0x0038,
 
86
        0x0039, 0x003a, 0x003b, 0x003c, 0x003d,
 
87
        0x003e, 0x003f, 0x005b, 0x005d, 0x005f,
 
88
        0x007b, 0x007c, 0x007d, 0x00a9, 0x00ac,
 
89
        0x00ae, 0x00b0, 0x00b1, 0x00d7, 0x00f7,
 
90
        0x0192, 0x0391, 0x0392, 0x0393, 0x0394,
 
91
        0x0395, 0x0396, 0x0397, 0x0398, 0x0399,
 
92
        0x039a, 0x039b, 0x039c, 0x039d, 0x039e,
 
93
        0x039f, 0x03a0, 0x03a1, 0x03a3, 0x03a4,
 
94
        0x03a5, 0x03a6, 0x03a7, 0x03a8, 0x03a9,
 
95
        0x03b1, 0x03b2, 0x03b3, 0x03b4, 0x03b5,
 
96
        0x03b6, 0x03b7, 0x03b8, 0x03b9, 0x03ba,
 
97
        0x03bb, 0x03bc, 0x03bd, 0x03be, 0x03bf,
 
98
        0x03c0, 0x03c1, 0x03c2, 0x03c3, 0x03c4,
 
99
        0x03c5, 0x03c6, 0x03c7, 0x03c8, 0x03c9,
 
100
        0x03d1, 0x03d2, 0x03d5, 0x03d6, 0x2022,
 
101
        0x2026, 0x2032, 0x2033, 0x203e, 0x2044,
 
102
        0x2111, 0x2118, 0x211c, 0x2122, 0x2126,
 
103
        0x2135, 0x2190, 0x2191, 0x2192, 0x2193,
 
104
        0x2194, 0x21b5, 0x21d0, 0x21d1, 0x21d2,
 
105
        0x21d3, 0x21d4, 0x2200, 0x2202, 0x2203,
 
106
        0x2205, 0x2206, 0x2207, 0x2208, 0x2209,
 
107
        0x220b, 0x220f, 0x2211, 0x2212, 0x2215,
 
108
        0x2217, 0x221a, 0x221d, 0x221e, 0x2220,
 
109
        0x2227, 0x2228, 0x2229, 0x222a, 0x222b,
 
110
        0x2234, 0x223c, 0x2245, 0x2248, 0x2260,
 
111
        0x2261, 0x2264, 0x2265, 0x2282, 0x2283,
 
112
        0x2284, 0x2286, 0x2287, 0x2295, 0x2297,
 
113
        0x22a5, 0x22c5, 0x2320, 0x2321, 0x2329,
 
114
        0x232a, 0x25ca, 0x2660, 0x2663, 0x2665,
 
115
        0x2666
 
116
    }
 
117
 
 
118
    set title0 "#<0x10>PLplot Example 23 - Greek Letters"
 
119
    set title1 "#<0x10>PLplot Example 23 - Type 1 Symbol Font Glyphs by Unicode (a)"
 
120
    set title2 "#<0x10>PLplot Example 23 - Type 1 Symbol Font Glyphs by Unicode (b)"
 
121
    set title3 "#<0x10>PLplot Example 23 - Type 1 Symbol Font Glyphs by Unicode (c)"
 
122
    set title4 "#<0x10>PLplot Example 23 - Number Forms Unicode Block"
 
123
    set title5 "#<0x10>PLplot Example 23 - Arrows Unicode Block (a)"
 
124
    set title6 "#<0x10>PLplot Example 23 - Arrows Unicode Block (b)"
 
125
    set title7 "#<0x10>PLplot Example 23 - Mathematical Operators Unicode Block (a)"
 
126
    set title8 "#<0x10>PLplot Example 23 - Mathematical Operators Unicode Block (b)"
 
127
    set title9 "#<0x10>PLplot Example 23 - Mathematical Operators Unicode Block (c)"
 
128
    set title10 "#<0x10>PLplot Example 23 - Mathematical Operators Unicode Block (d)"
 
129
 
 
130
 
 
131
    matrix lo i 11 = {
 
132
        0x0,
 
133
        0x0,
 
134
        0x40,
 
135
        0x80,
 
136
        0x2153,
 
137
        0x2190,
 
138
        0x21d0,
 
139
        0x2200,
 
140
        0x2240,
 
141
        0x2280,
 
142
        0x22c0
 
143
    }
 
144
 
 
145
    matrix hi i 11 = {
 
146
        0x30,
 
147
        0x40,
 
148
        0x80,
 
149
        0xA6,
 
150
        0x2184,
 
151
        0x21d0,
 
152
        0x2200,
 
153
        0x2240,
 
154
        0x2280,
 
155
        0x22c0,
 
156
        0x2300
 
157
    }
 
158
 
 
159
    matrix nxcells i 11 = {
 
160
        12,
 
161
        8,
 
162
        8,
 
163
        8,
 
164
        8,
 
165
        8,
 
166
        8,
 
167
        8,
 
168
        8,
 
169
        8,
 
170
        8
 
171
    }
 
172
 
 
173
    matrix nycells i 11 = {
 
174
        8,
 
175
        8,
 
176
        8,
 
177
        8,
 
178
        8,
 
179
        8,
 
180
        8,
 
181
        8,
 
182
        8,
 
183
        8,
 
184
        8
 
185
    }
 
186
 
 
187
    # non-zero values Must be consistent with nxcells and nycells.
 
188
    matrix offset i 11 =  {
 
189
        0,
 
190
        0,
 
191
        64,
 
192
        128,
 
193
        0,
 
194
        0,
 
195
        0,
 
196
        0,
 
197
        0,
 
198
        0,
 
199
        0
 
200
    }
 
201
 
 
202
# 30 possible FCI values.
 
203
    matrix fci i 30 = {
 
204
        0x80000000,
 
205
        0x80000001,
 
206
        0x80000002,
 
207
        0x80000003,
 
208
        0x80000004,
 
209
        0x80000010,
 
210
        0x80000011,
 
211
        0x80000012,
 
212
        0x80000013,
 
213
        0x80000014,
 
214
        0x80000020,
 
215
        0x80000021,
 
216
        0x80000022,
 
217
        0x80000023,
 
218
        0x80000024,
 
219
        0x80000100,
 
220
        0x80000101,
 
221
        0x80000102,
 
222
        0x80000103,
 
223
        0x80000104,
 
224
        0x80000110,
 
225
        0x80000111,
 
226
        0x80000112,
 
227
        0x80000113,
 
228
        0x80000114,
 
229
        0x80000120,
 
230
        0x80000121,
 
231
        0x80000122,
 
232
        0x80000123,
 
233
        0x80000124,
 
234
    }
 
235
 
 
236
    set family(0) "sans-serif"
 
237
    set family(1) "serif"
 
238
    set family(2) "monospace"
 
239
    set family(3) "script"
 
240
    set family(4) "symbol"
 
241
 
 
242
    set style(0) "upright"
 
243
    set style(1) "italic"
 
244
    set style(2) "oblique"
 
245
 
 
246
    set weight(0) "medium"
 
247
    set weight(1) "bold"
 
248
 
 
249
    for {set page 0} {$page<11} {incr page} {
 
250
        
 
251
        $w cmd pladv 0
 
252
 
 
253
        # Set up viewport and window
 
254
 
 
255
        $w cmd plvpor 0.02 0.98 0.02 0.90
 
256
        $w cmd plwind 0.0 1.0 0.0 1.0
 
257
        $w cmd plgspa xmin xmax ymin ymax
 
258
        $w cmd plschr 0.0 0.8
 
259
        set ycharacter_scale [ expr {1.0/($ymax-$ymin)} ]
 
260
 
 
261
        # Factor should be 0.5, but heuristically it turns out to be larger.
 
262
        $w cmd plgchr chardef charht
 
263
        set yoffset [ expr {1.0*$charht*$ycharacter_scale} ]
 
264
 
 
265
        # Draw the grid using plbox
 
266
 
 
267
        $w cmd plcol0 2
 
268
        set deltax [ expr {1.0/[nxcells $page]} ]
 
269
        set deltay [ expr {1.0/[nycells $page]} ]
 
270
        $w cmd plbox "bcg" $deltax 0 "bcg" $deltay 0
 
271
        $w cmd plcol0 15
 
272
        set length [ expr {[hi $page]-[lo $page]} ]
 
273
        set slice 0
 
274
        for {set j [ expr {[nycells $page]-1} ]} {$j>=-1} {incr j -1} {
 
275
            set y [ expr {(0.5+$j)*$deltay} ]
 
276
            for {set i 0} {$i<[nxcells $page]} {incr i} {
 
277
                set x [ expr {(0.5+$i)*$deltax} ]
 
278
                if {$slice < $length} {
 
279
                    if {$page == 0} {
 
280
                        set cmdString [format "#%s" [set Greek$slice]]
 
281
                    } elseif {$page <= 3} {
 
282
                        set cmdString [format "##\[0x%.4x\]" [ Type1 [expr {[offset $page]+$slice}] ] ]
 
283
                    } else {
 
284
                        set cmdString [format "##\[0x%.4x\]" [expr {[lo $page]+$slice}]]
 
285
                    }
 
286
                    $w cmd plptex $x [ expr {$y+$yoffset}] 1. 0. 0.5 [ string range $cmdString 1 end ]
 
287
                    $w cmd plptex $x [ expr {$y-$yoffset}] 1. 0. 0.5 $cmdString
 
288
                }
 
289
                incr slice
 
290
            }
 
291
        }
 
292
 
 
293
        $w cmd plschr 0. 1.0
 
294
        # Page title
 
295
        $w cmd plmtex "t" 1.5 0.5 0.5 [set title$page]
 
296
    }
 
297
 
 
298
    # Demonstrate methods of getting the current fonts
 
299
    $w cmd plgfci fci_old
 
300
    $w cmd plgfont ifamily istyle iweight
 
301
    puts [ format "For example 23 prior to page 12 the FCI is 0x%x" $fci_old ]
 
302
    puts [ format "For example 23 prior to page 12 the font family, style and weight are %s %s %s" \
 
303
               $family($ifamily) $style($istyle) $weight($iweight) ]
 
304
 
 
305
    for {set page 11} {$page<16} {incr page} {
 
306
        set dy 0.030
 
307
        
 
308
        $w cmd pladv 0
 
309
        $w cmd plvpor 0.02 0.98 0.02 0.90
 
310
        $w cmd plwind 0.0 1.0 0.0 1.0
 
311
        $w cmd plsfci 0
 
312
        if {$page == 11} {
 
313
            $w cmd plmtex "t" 1.5 0.5 0.5 "#<0x10>PLplot Example 23 - Set Font with plsfci"
 
314
        } elseif {$page == 12} {
 
315
            $w cmd plmtex "t" 1.5 0.5 0.5 "#<0x10>PLplot Example 23 - Set Font with plsfont"
 
316
        } elseif {$page == 13} {
 
317
            $w cmd plmtex "t" 1.5 0.5 0.5 "#<0x10>PLplot Example 23 - Set Font with ##<0x8nnnnnnn> construct"
 
318
        } elseif {$page == 14} {
 
319
            $w cmd plmtex "t" 1.5 0.5 0.5 "#<0x10>PLplot Example 23 - Set Font with ##<0xmn> constructs"
 
320
        } elseif {$page == 15} {
 
321
            $w cmd plmtex "t" 1.5 0.5 0.5 "#<0x10>PLplot Example 23 - Set Font with ##<FCI COMMAND STRING/> constructs"
 
322
        }
 
323
        $w cmd plschr 0. 0.75
 
324
        for {set i 0} {$i< 30} {incr i} {
 
325
            set family_index [ expr {$i % 5}]
 
326
            set style_index [ expr {($i/5) % 3}]
 
327
            set weight_index [ expr {(($i/5)/3) % 2}]
 
328
            if {$page == 11} {
 
329
                $w cmd plsfci [fci $i]
 
330
                set string [format "Page 12, %s, %s, %s:  The quick brown fox jumps over the lazy dog" \
 
331
                                $family($family_index) \
 
332
                                $style($style_index) \
 
333
                                $weight($weight_index) \
 
334
                           ]
 
335
            } elseif {$page == 12} {
 
336
                $w cmd plsfont $family_index $style_index $weight_index
 
337
                set string [format \
 
338
                                "Page 13, %s, %s, %s:  The quick brown fox jumps over the lazy dog" \
 
339
                                $family($family_index) \
 
340
                                $style($style_index) \
 
341
                                $weight($weight_index) \
 
342
                           ]
 
343
            } elseif {$page == 13} {
 
344
                set string [format \
 
345
                                "Page 14, %s, %s, %s:  #<0x%x>The quick brown fox jumps over the lazy dog" \
 
346
                                $family($family_index) \
 
347
                                $style($style_index) \
 
348
                                $weight($weight_index) \
 
349
                                [fci $i] \
 
350
                               ]
 
351
            } elseif {$page == 14} {
 
352
                set string [format \
 
353
                                "Page 15, %s, %s, %s:  #<0x%1x0>#<0x%1x1>#<0x%1x2>The quick brown fox jumps over the lazy dog" \
 
354
                                $family($family_index) \
 
355
                                $style($style_index) \
 
356
                                $weight($weight_index) \
 
357
                                $family_index \
 
358
                                $style_index \
 
359
                                $weight_index \
 
360
                               ]
 
361
            } elseif {$page == 15} {
 
362
                set string [format \
 
363
                                "Page 16, %s, %s, %s:  #<%s/>#<%s/>#<%s/>The quick brown fox jumps over the lazy dog" \
 
364
                                $family($family_index) \
 
365
                                $style($style_index) \
 
366
                                $weight($weight_index) \
 
367
                                $family($family_index) \
 
368
                                $style($style_index) \
 
369
                                $weight($weight_index) \
 
370
                               ]
 
371
            }
 
372
            $w cmd plptex 0. [ expr {1. - ($i+0.5)*$dy}] 1. 0. 0. $string
 
373
       }
 
374
 
 
375
       $w cmd plschr 0. 1.0
 
376
    }
 
377
 
 
378
    # Restore defaults
 
379
    $w cmd plcol0 1
 
380
}