[175] | 1 | %%BeginProlog
|
---|
| 2 | %
|
---|
| 3 | % PostScript prolog file of the BLT graph widget.
|
---|
| 4 | %
|
---|
| 5 | % Copyright 1989-1992 Regents of the University of California.
|
---|
| 6 | % Permission to use, copy, modify, and distribute this
|
---|
| 7 | % software and its documentation for any purpose and without
|
---|
| 8 | % fee is hereby granted, provided that the above copyright
|
---|
| 9 | % notice appear in all copies. The University of California
|
---|
| 10 | % makes no representations about the suitability of this
|
---|
| 11 | % software for any purpose. It is provided "as is" without
|
---|
| 12 | % express or implied warranty.
|
---|
| 13 | %
|
---|
| 14 | % Copyright 1991-1997 Bell Labs Innovations for Lucent Technologies.
|
---|
| 15 | %
|
---|
| 16 | % Permission to use, copy, modify, and distribute this software and its
|
---|
| 17 | % documentation for any purpose and without fee is hereby granted, provided
|
---|
| 18 | % that the above copyright notice appear in all copies and that both that the
|
---|
| 19 | % copyright notice and warranty disclaimer appear in supporting documentation,
|
---|
| 20 | % and that the names of Lucent Technologies any of their entities not be used
|
---|
| 21 | % in advertising or publicity pertaining to distribution of the software
|
---|
| 22 | % without specific, written prior permission.
|
---|
| 23 | %
|
---|
| 24 | % Lucent Technologies disclaims all warranties with regard to this software,
|
---|
| 25 | % including all implied warranties of merchantability and fitness. In no event
|
---|
| 26 | % shall Lucent Technologies be liable for any special, indirect or
|
---|
| 27 | % consequential damages or any damages whatsoever resulting from loss of use,
|
---|
| 28 | % data or profits, whether in an action of contract, negligence or other
|
---|
| 29 | % tortuous action, arising out of or in connection with the use or performance
|
---|
| 30 | % of this software.
|
---|
| 31 | %
|
---|
| 32 |
|
---|
| 33 | 200 dict begin
|
---|
| 34 |
|
---|
| 35 | /BaseRatio 1.3467736870885982 def % Ratio triangle base / symbol size
|
---|
| 36 | /BgColorProc 0 def % Background color routine (symbols)
|
---|
| 37 | /DrawSymbolProc 0 def % Routine to draw symbol outline/fill
|
---|
| 38 | /StippleProc 0 def % Stipple routine (bar segments)
|
---|
| 39 | /DashesProc 0 def % Dashes routine (line segments)
|
---|
| 40 |
|
---|
| 41 | % Define the array ISOLatin1Encoding (which specifies how characters are
|
---|
| 42 | % encoded for ISO-8859-1 fonts), if it isn't already present (Postscript
|
---|
| 43 | % level 2 is supposed to define it, but level 1 doesn't).
|
---|
| 44 |
|
---|
| 45 | systemdict /ISOLatin1Encoding known not {
|
---|
| 46 | /ISOLatin1Encoding [
|
---|
| 47 | /space /space /space /space /space /space /space /space
|
---|
| 48 | /space /space /space /space /space /space /space /space
|
---|
| 49 | /space /space /space /space /space /space /space /space
|
---|
| 50 | /space /space /space /space /space /space /space /space
|
---|
| 51 | /space /exclam /quotedbl /numbersign /dollar /percent /ampersand
|
---|
| 52 | /quoteright
|
---|
| 53 | /parenleft /parenright /asterisk /plus /comma /minus /period /slash
|
---|
| 54 | /zero /one /two /three /four /five /six /seven
|
---|
| 55 | /eight /nine /colon /semicolon /less /equal /greater /question
|
---|
| 56 | /at /A /B /C /D /E /F /G
|
---|
| 57 | /H /I /J /K /L /M /N /O
|
---|
| 58 | /P /Q /R /S /T /U /V /W
|
---|
| 59 | /X /Y /Z /bracketleft /backslash /bracketright /asciicircum /underscore
|
---|
| 60 | /quoteleft /a /b /c /d /e /f /g
|
---|
| 61 | /h /i /j /k /l /m /n /o
|
---|
| 62 | /p /q /r /s /t /u /v /w
|
---|
| 63 | /x /y /z /braceleft /bar /braceright /asciitilde /space
|
---|
| 64 | /space /space /space /space /space /space /space /space
|
---|
| 65 | /space /space /space /space /space /space /space /space
|
---|
| 66 | /dotlessi /grave /acute /circumflex /tilde /macron /breve /dotaccent
|
---|
| 67 | /dieresis /space /ring /cedilla /space /hungarumlaut /ogonek /caron
|
---|
| 68 | /space /exclamdown /cent /sterling /currency /yen /brokenbar /section
|
---|
| 69 | /dieresis /copyright /ordfeminine /guillemotleft /logicalnot /hyphen
|
---|
| 70 | /registered /macron
|
---|
| 71 | /degree /plusminus /twosuperior /threesuperior /acute /mu /paragraph
|
---|
| 72 | /periodcentered
|
---|
| 73 | /cedillar /onesuperior /ordmasculine /guillemotright /onequarter
|
---|
| 74 | /onehalf /threequarters /questiondown
|
---|
| 75 | /Agrave /Aacute /Acircumflex /Atilde /Adieresis /Aring /AE /Ccedilla
|
---|
| 76 | /Egrave /Eacute /Ecircumflex /Edieresis /Igrave /Iacute /Icircumflex
|
---|
| 77 | /Idieresis
|
---|
| 78 | /Eth /Ntilde /Ograve /Oacute /Ocircumflex /Otilde /Odieresis /multiply
|
---|
| 79 | /Oslash /Ugrave /Uacute /Ucircumflex /Udieresis /Yacute /Thorn
|
---|
| 80 | /germandbls
|
---|
| 81 | /agrave /aacute /acircumflex /atilde /adieresis /aring /ae /ccedilla
|
---|
| 82 | /egrave /eacute /ecircumflex /edieresis /igrave /iacute /icircumflex
|
---|
| 83 | /idieresis
|
---|
| 84 | /eth /ntilde /ograve /oacute /ocircumflex /otilde /odieresis /divide
|
---|
| 85 | /oslash /ugrave /uacute /ucircumflex /udieresis /yacute /thorn
|
---|
| 86 | /ydieresis
|
---|
| 87 | ] def
|
---|
| 88 | } if
|
---|
| 89 |
|
---|
| 90 | % font ISOEncode font
|
---|
| 91 | % This procedure changes the encoding of a font from the default
|
---|
| 92 | % Postscript encoding to ISOLatin1. It is typically invoked just
|
---|
| 93 | % before invoking "setfont". The body of this procedure comes from
|
---|
| 94 | % Section 5.6.1 of the Postscript book.
|
---|
| 95 |
|
---|
| 96 | /ISOEncode {
|
---|
| 97 | dup length dict
|
---|
| 98 | begin
|
---|
| 99 | {1 index /FID ne {def} {pop pop} ifelse} forall
|
---|
| 100 | /Encoding ISOLatin1Encoding def
|
---|
| 101 | currentdict
|
---|
| 102 | end
|
---|
| 103 |
|
---|
| 104 | % I'm not sure why it's necessary to use "definefont" on this new
|
---|
| 105 | % font, but it seems to be important; just use the name "Temporary"
|
---|
| 106 | % for the font.
|
---|
| 107 |
|
---|
| 108 | /Temporary exch definefont
|
---|
| 109 | } bind def
|
---|
| 110 |
|
---|
| 111 | /Stroke {
|
---|
| 112 | gsave
|
---|
| 113 | stroke
|
---|
| 114 | grestore
|
---|
| 115 | } def
|
---|
| 116 |
|
---|
| 117 | /Fill {
|
---|
| 118 | gsave
|
---|
| 119 | fill
|
---|
| 120 | grestore
|
---|
| 121 | } def
|
---|
| 122 |
|
---|
| 123 | /SetFont {
|
---|
| 124 | % Stack: pointSize fontName
|
---|
| 125 | findfont exch scalefont ISOEncode setfont
|
---|
| 126 | } def
|
---|
| 127 |
|
---|
| 128 | /Box {
|
---|
| 129 | % Stack: x y width height
|
---|
| 130 | newpath
|
---|
| 131 | exch 4 2 roll moveto
|
---|
| 132 | dup 0 rlineto
|
---|
| 133 | exch 0 exch rlineto
|
---|
| 134 | neg 0 rlineto
|
---|
| 135 | closepath
|
---|
| 136 | } def
|
---|
| 137 |
|
---|
| 138 | /SetFgColor {
|
---|
| 139 | % Stack: red green blue
|
---|
| 140 | CL 0 eq {
|
---|
| 141 | pop pop pop 0 0 0
|
---|
| 142 | } if
|
---|
| 143 | setrgbcolor
|
---|
| 144 | CL 1 eq {
|
---|
| 145 | currentgray setgray
|
---|
| 146 | } if
|
---|
| 147 | } def
|
---|
| 148 |
|
---|
| 149 | /SetBgColor {
|
---|
| 150 | % Stack: red green blue
|
---|
| 151 | CL 0 eq {
|
---|
| 152 | pop pop pop 1 1 1
|
---|
| 153 | } if
|
---|
| 154 | setrgbcolor
|
---|
| 155 | CL 1 eq {
|
---|
| 156 | currentgray setgray
|
---|
| 157 | } if
|
---|
| 158 | } def
|
---|
| 159 |
|
---|
| 160 | % The next two definitions are taken from "$tk_library/prolog.ps"
|
---|
| 161 |
|
---|
| 162 | % desiredSize EvenPixels closestSize
|
---|
| 163 | %
|
---|
| 164 | % The procedure below is used for stippling. Given the optimal size
|
---|
| 165 | % of a dot in a stipple pattern in the current user coordinate system,
|
---|
| 166 | % compute the closest size that is an exact multiple of the device's
|
---|
| 167 | % pixel size. This allows stipple patterns to be displayed without
|
---|
| 168 | % aliasing effects.
|
---|
| 169 |
|
---|
| 170 | /EvenPixels {
|
---|
| 171 | % Compute exact number of device pixels per stipple dot.
|
---|
| 172 | dup 0 matrix currentmatrix dtransform
|
---|
| 173 | dup mul exch dup mul add sqrt
|
---|
| 174 |
|
---|
| 175 | % Round to an integer, make sure the number is at least 1, and compute
|
---|
| 176 | % user coord distance corresponding to this.
|
---|
| 177 | dup round dup 1 lt {pop 1} if
|
---|
| 178 | exch div mul
|
---|
| 179 | } bind def
|
---|
| 180 |
|
---|
| 181 | % width height string filled StippleFill --
|
---|
| 182 | %
|
---|
| 183 | % Given a path and other graphics information already set up, this
|
---|
| 184 | % procedure will fill the current path in a stippled fashion. "String"
|
---|
| 185 | % contains a proper image description of the stipple pattern and
|
---|
| 186 | % "width" and "height" give its dimensions. If "filled" is true then
|
---|
| 187 | % it means that the area to be stippled is gotten by filling the
|
---|
| 188 | % current path (e.g. the interior of a polygon); if it's false, the
|
---|
| 189 | % area is gotten by stroking the current path (e.g. a wide line).
|
---|
| 190 | % Each stipple dot is assumed to be about one unit across in the
|
---|
| 191 | % current user coordinate system.
|
---|
| 192 |
|
---|
| 193 | % width height string StippleFill --
|
---|
| 194 | %
|
---|
| 195 | % Given a path already set up and a clipping region generated from
|
---|
| 196 | % it, this procedure will fill the clipping region with a stipple
|
---|
| 197 | % pattern. "String" contains a proper image description of the
|
---|
| 198 | % stipple pattern and "width" and "height" give its dimensions. Each
|
---|
| 199 | % stipple dot is assumed to be about one unit across in the current
|
---|
| 200 | % user coordinate system. This procedure trashes the graphics state.
|
---|
| 201 |
|
---|
| 202 | /StippleFill {
|
---|
| 203 | % The following code is needed to work around a NeWSprint bug.
|
---|
| 204 |
|
---|
| 205 | /tmpstip 1 index def
|
---|
| 206 |
|
---|
| 207 | % Change the scaling so that one user unit in user coordinates
|
---|
| 208 | % corresponds to the size of one stipple dot.
|
---|
| 209 | 1 EvenPixels dup scale
|
---|
| 210 |
|
---|
| 211 | % Compute the bounding box occupied by the path (which is now
|
---|
| 212 | % the clipping region), and round the lower coordinates down
|
---|
| 213 | % to the nearest starting point for the stipple pattern. Be
|
---|
| 214 | % careful about negative numbers, since the rounding works
|
---|
| 215 | % differently on them.
|
---|
| 216 |
|
---|
| 217 | pathbbox
|
---|
| 218 | 4 2 roll
|
---|
| 219 | 5 index div dup 0 lt {1 sub} if cvi 5 index mul 4 1 roll
|
---|
| 220 | 6 index div dup 0 lt {1 sub} if cvi 6 index mul 3 2 roll
|
---|
| 221 |
|
---|
| 222 | % Stack now: width height string y1 y2 x1 x2
|
---|
| 223 | % Below is a doubly-nested for loop to iterate across this area
|
---|
| 224 | % in units of the stipple pattern size, going up columns then
|
---|
| 225 | % across rows, blasting out a stipple-pattern-sized rectangle at
|
---|
| 226 | % each position
|
---|
| 227 |
|
---|
| 228 | 6 index exch {
|
---|
| 229 | 2 index 5 index 3 index {
|
---|
| 230 | % Stack now: width height string y1 y2 x y
|
---|
| 231 |
|
---|
| 232 | gsave
|
---|
| 233 | 1 index exch translate
|
---|
| 234 | 5 index 5 index true matrix tmpstip imagemask
|
---|
| 235 | grestore
|
---|
| 236 | } for
|
---|
| 237 | pop
|
---|
| 238 | } for
|
---|
| 239 | pop pop pop pop pop
|
---|
| 240 | } bind def
|
---|
| 241 |
|
---|
| 242 |
|
---|
| 243 | /LS { % Stack: x1 y1 x2 y2
|
---|
| 244 | newpath 4 2 roll moveto lineto stroke
|
---|
| 245 | } def
|
---|
| 246 |
|
---|
| 247 | /EndText {
|
---|
| 248 | %Stack :
|
---|
| 249 | grestore
|
---|
| 250 | } def
|
---|
| 251 |
|
---|
| 252 | /BeginText {
|
---|
| 253 | %Stack : w h theta centerX centerY
|
---|
| 254 | gsave
|
---|
| 255 | % Translate the origin to the center of bounding box and rotate
|
---|
| 256 | translate neg rotate
|
---|
| 257 | % Translate back to the origin of the text region
|
---|
| 258 | -0.5 mul exch -0.5 mul exch translate
|
---|
| 259 | } def
|
---|
| 260 |
|
---|
| 261 | /DrawAdjText {
|
---|
| 262 | %Stack : str strWidth x y
|
---|
| 263 | moveto % Go to the text position
|
---|
| 264 | exch dup dup 4 2 roll
|
---|
| 265 |
|
---|
| 266 | % Adjust character widths to get desired overall string width
|
---|
| 267 | % adjust X = (desired width - real width)/#chars
|
---|
| 268 |
|
---|
| 269 | stringwidth pop sub exch
|
---|
| 270 | length div
|
---|
| 271 | 0 3 -1 roll
|
---|
| 272 |
|
---|
| 273 | % Flip back the scale so that the string is not drawn in reverse
|
---|
| 274 |
|
---|
| 275 | gsave
|
---|
| 276 | 1 -1 scale
|
---|
| 277 | ashow
|
---|
| 278 | grestore
|
---|
| 279 | } def
|
---|
| 280 |
|
---|
| 281 | /DrawBitmap {
|
---|
| 282 | % Stack: ?bgColorProc? boolean centerX centerY width height theta imageStr
|
---|
| 283 | gsave
|
---|
| 284 | 6 -2 roll translate % Translate to center of bounding box
|
---|
| 285 | 4 1 roll neg rotate % Rotate by theta
|
---|
| 286 |
|
---|
| 287 | % Find upperleft corner of bounding box
|
---|
| 288 |
|
---|
| 289 | 2 copy -.5 mul exch -.5 mul exch translate
|
---|
| 290 | 2 copy scale % Make pixel unit scale
|
---|
| 291 | newpath
|
---|
| 292 | 0 0 moveto 0 1 lineto 1 1 lineto 1 0 lineto
|
---|
| 293 | closepath
|
---|
| 294 |
|
---|
| 295 | % Fill rectangle with background color
|
---|
| 296 |
|
---|
| 297 | 4 -1 roll {
|
---|
| 298 | gsave
|
---|
| 299 | 4 -1 roll exec fill
|
---|
| 300 | grestore
|
---|
| 301 | } if
|
---|
| 302 |
|
---|
| 303 | % Paint the image string into the unit rectangle
|
---|
| 304 |
|
---|
| 305 | 2 copy true 3 -1 roll 0 0 5 -1 roll 0 0 6 array astore 5 -1 roll
|
---|
| 306 | imagemask
|
---|
| 307 | grestore
|
---|
| 308 | } def
|
---|
| 309 |
|
---|
| 310 | % Symbols:
|
---|
| 311 |
|
---|
| 312 | % Skinny-cross
|
---|
| 313 | /Sc {
|
---|
| 314 | % Stack: x y symbolSize
|
---|
| 315 | gsave
|
---|
| 316 | 3 -2 roll translate 45 rotate
|
---|
| 317 | 0 0 3 -1 roll Sp
|
---|
| 318 | grestore
|
---|
| 319 | } def
|
---|
| 320 |
|
---|
| 321 | % Skinny-plus
|
---|
| 322 | /Sp {
|
---|
| 323 | % Stack: x y symbolSize
|
---|
| 324 | gsave
|
---|
| 325 | 3 -2 roll translate
|
---|
| 326 | 2 idiv
|
---|
| 327 | dup 2 copy
|
---|
| 328 | newpath neg 0 moveto 0 lineto
|
---|
| 329 | DrawSymbolProc
|
---|
| 330 | newpath neg 0 exch moveto 0 exch lineto
|
---|
| 331 | DrawSymbolProc
|
---|
| 332 | grestore
|
---|
| 333 | } def
|
---|
| 334 |
|
---|
| 335 | % Cross
|
---|
| 336 | /Cr {
|
---|
| 337 | % Stack: x y symbolSize
|
---|
| 338 | gsave
|
---|
| 339 | 3 -2 roll translate 45 rotate
|
---|
| 340 | 0 0 3 -1 roll Pl
|
---|
| 341 | grestore
|
---|
| 342 | } def
|
---|
| 343 |
|
---|
| 344 | % Plus
|
---|
| 345 | /Pl {
|
---|
| 346 | % Stack: x y symbolSize
|
---|
| 347 | gsave
|
---|
| 348 | 3 -2 roll translate
|
---|
| 349 | dup 2 idiv
|
---|
| 350 | exch 6 idiv
|
---|
| 351 |
|
---|
| 352 | %
|
---|
| 353 | % 2 3 The plus/cross symbol is a
|
---|
| 354 | % closed polygon of 12 points.
|
---|
| 355 | % 0 1 4 5 The diagram to the left
|
---|
| 356 | % x,y represents the positions of
|
---|
| 357 | % 11 10 7 6 the points which are computed
|
---|
| 358 | % below.
|
---|
| 359 | % 9 8
|
---|
| 360 | %
|
---|
| 361 |
|
---|
| 362 | newpath
|
---|
| 363 | 2 copy exch neg exch neg moveto dup neg dup lineto
|
---|
| 364 | 2 copy neg exch neg lineto 2 copy exch neg lineto
|
---|
| 365 | dup dup neg lineto 2 copy neg lineto 2 copy lineto
|
---|
| 366 | dup dup lineto 2 copy exch lineto 2 copy neg exch lineto
|
---|
| 367 | dup dup neg exch lineto exch neg exch lineto
|
---|
| 368 | closepath
|
---|
| 369 | DrawSymbolProc
|
---|
| 370 | grestore
|
---|
| 371 | } def
|
---|
| 372 |
|
---|
| 373 | % Circle
|
---|
| 374 | /Ci {
|
---|
| 375 | % Stack: x y symbolSize
|
---|
| 376 | gsave
|
---|
| 377 | 3 copy pop
|
---|
| 378 | moveto newpath
|
---|
| 379 | 2 div 0 360 arc
|
---|
| 380 | closepath DrawSymbolProc
|
---|
| 381 | grestore
|
---|
| 382 | } def
|
---|
| 383 |
|
---|
| 384 | % Square
|
---|
| 385 | /Sq {
|
---|
| 386 | % Stack: x y symbolSize
|
---|
| 387 | gsave
|
---|
| 388 | dup dup 2 div dup
|
---|
| 389 | 6 -1 roll exch sub exch
|
---|
| 390 | 5 -1 roll exch sub 4 -2 roll Box
|
---|
| 391 | DrawSymbolProc
|
---|
| 392 | grestore
|
---|
| 393 | } def
|
---|
| 394 |
|
---|
| 395 | % Line
|
---|
| 396 | /Li {
|
---|
| 397 | % Stack: x y symbolSize
|
---|
| 398 | gsave
|
---|
| 399 | 3 1 roll exch 3 -1 roll 2 div 3 copy
|
---|
| 400 | newpath
|
---|
| 401 | sub exch moveto add exch lineto
|
---|
| 402 | stroke
|
---|
| 403 | grestore
|
---|
| 404 | } def
|
---|
| 405 |
|
---|
| 406 | % Diamond
|
---|
| 407 | /Di {
|
---|
| 408 | % Stack: x y symbolSize
|
---|
| 409 | gsave
|
---|
| 410 | 3 1 roll translate 45 rotate 0 0 3 -1 roll Sq
|
---|
| 411 | grestore
|
---|
| 412 | } def
|
---|
| 413 |
|
---|
| 414 | % Triangle
|
---|
| 415 | /Tr {
|
---|
| 416 | % Stack: x y symbolSize
|
---|
| 417 | gsave
|
---|
| 418 | 3 -2 roll translate
|
---|
| 419 | BaseRatio mul 0.5 mul % Calculate 1/2 base
|
---|
| 420 | dup 0 exch 30 cos mul % h1 = height above center point
|
---|
| 421 | neg % b2 0 -h1
|
---|
| 422 | newpath moveto % point 1; b2
|
---|
| 423 | dup 30 sin 30 cos div mul % h2 = height below center point
|
---|
| 424 | 2 copy lineto % point 2; b2 h2
|
---|
| 425 | exch neg exch lineto %
|
---|
| 426 | closepath
|
---|
| 427 | DrawSymbolProc
|
---|
| 428 | grestore
|
---|
| 429 | } def
|
---|
| 430 |
|
---|
| 431 | % Arrow
|
---|
| 432 | /Ar {
|
---|
| 433 | % Stack: x y symbolSize
|
---|
| 434 | gsave
|
---|
| 435 | 3 -2 roll translate
|
---|
| 436 | BaseRatio mul 0.5 mul % Calculate 1/2 base
|
---|
| 437 | dup 0 exch 30 cos mul % h1 = height above center point
|
---|
| 438 | % b2 0 h1
|
---|
| 439 | newpath moveto % point 1; b2
|
---|
| 440 | dup 30 sin 30 cos div mul % h2 = height below center point
|
---|
| 441 | neg % -h2 b2
|
---|
| 442 | 2 copy lineto % point 2; b2 h2
|
---|
| 443 | exch neg exch lineto %
|
---|
| 444 | closepath
|
---|
| 445 | DrawSymbolProc
|
---|
| 446 | grestore
|
---|
| 447 | } def
|
---|
| 448 |
|
---|
| 449 | % Bitmap
|
---|
| 450 | /Bm {
|
---|
| 451 | % Stack: x y symbolSize
|
---|
| 452 | gsave
|
---|
| 453 | 3 1 roll translate pop DrawSymbolProc
|
---|
| 454 | grestore
|
---|
| 455 | } def
|
---|
| 456 |
|
---|
| 457 | %%EndProlog
|
---|
| 458 |
|
---|
| 459 | %%BeginSetup
|
---|
| 460 | gsave % Save the graphics state
|
---|
| 461 |
|
---|
| 462 | % Default line/text style parameters
|
---|
| 463 |
|
---|
| 464 | 1 setlinewidth % width
|
---|
| 465 | 1 setlinejoin % join
|
---|
| 466 | 0 setlinecap % cap
|
---|
| 467 | [] 0 setdash % dashes
|
---|
| 468 |
|
---|
| 469 | /CL 0 def % Set color level mode
|
---|
| 470 | 0 0 0 setrgbcolor % color
|
---|
| 471 |
|
---|