OSDN Git Service

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