1#!/usr/bin/perl
2#
3#   Copyright (c) International Business Machines  Corp., 2002
4#
5#   This program is free software;  you can redistribute it and/or modify
6#   it under the terms of the GNU General Public License as published by
7#   the Free Software Foundation; either version 2 of the License, or (at
8#   your option) any later version.
9#
10#   This program is distributed in the hope that it will be useful, but
11#   WITHOUT ANY WARRANTY;  without even the implied warranty of
12#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13#   General Public License for more details.
14#
15#   You should have received a copy of the GNU General Public License
16#   along with this program;  if not, write to the Free Software
17#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18#
19#
20# posterize.pl
21#
22#   This script generates a postscript file from output generated from the
23#   fcgp http://sourceforge.net/projects/fcgp/ for plotting
24#
25#
26# History:
27#   2003-09-04 wrote - James M Kenefick Jr. <jkenefic@us.ibm.com>
28#
29
30
31
32# a good deal of this could be turned in to cli
33# arguments.
34
35# Constants
36my $Title = "Linux Kernel Coverage";
37my $KernelVersion = "2.5.73";
38my $TestDescription = "A Sample Print";
39my $Image = "../lgp/image.ps";
40
41# Variables
42my $Bounds = "";
43# Paper sizes in inches
44my $PAPER_WIDTH = 34;
45my $PAPER_HEIGHT = 42;
46
47# points per inch
48my $ppi = 72;
49
50# Margins
51my $TopMargin = 1;
52my $BottomMargin = 1.5;
53my $LeftMargin = 1;
54my $RightMargin = 1;
55
56
57$RightMargin = $PAPER_WIDTH - $RightMargin;
58$TopMargin = $PAPER_HEIGHT - $TopMargin;
59
60my $filename = "poster.ps";
61
62# Sizes in ppi
63my $PPI_WIDTH = ($PAPER_WIDTH * $ppi);
64my $PPI_HEIGHT = ($PAPER_HEIGHT * $ppi);
65
66# Date we create poster
67my $date = `date`;
68
69print STDERR "Creating Poster\n";
70
71open POSTER, ">$filename";
72
73
74
75print(POSTER <<END_OF_USAGE);
76%!PS-Adobe-1.0
77%%DocumentFonts: Helvetica Helvetica-Bold
78%%Title: Linux 2.4.0 Kernel Poster
79%%Creator: Rusty's scripts and postersize (GPL)
80%%CreationDate: $date
81%%Pages: 1
82%%BoundingBox: 0 0 $PPI_WIDTH $PPI_HEIGHT
83%%EndComments
84%!
85/PRorig_showpage_x178313 /showpage load def /showpage{
86                                              errordict /handleerror {} put
87                                             }def
88/initgraphics{}def/setpagedevice{pop}def
89statusdict begin /a4tray{}def /lettertray{}def end
90/a4{}def/a3{}def/a0{}def/letter{}def/legal{}def
91/a4small{}def /lettersmall{}def /a4tray{}def /lettertray{}def
92/setscreen{pop pop pop}def
93/ColorManagement {pop} def
94
95
96/A {gsave newpath 0 360 arc stroke grestore} bind def
97/M {moveto} bind def
98/L {lineto} bind def
99/D {[] 0 setdash} bind def
100/D5 {[5] 0 setdash} bind def
101/C0 {0 0 0 setrgbcolor} bind def
102/C1 {.8 .4 .4 setrgbcolor} bind def
103/C2 {.5 1 .5 setrgbcolor} bind def
104/C3 {0 .7 0 setrgbcolor} bind def
105/C4 {1 0 0 setrgbcolor} bind def
106/C5 {0 0 1 setrgbcolor} bind def
107/R {grestore} bind def
108/S {0 0 M stroke} bind def
109/T {gsave translate} bind def
110/U {C0 newpath 4 copy 4 2 roll 8 7 roll M L L L closepath stroke
111C1 findfont exch scalefont setfont M show} bind def
112
113% Added James M Kenefick Jr.
114/Hi_Color {0 0 1} def
115/Med_Color {0 .60 1}  def
116/Lo_Color {0 1 1} def
117/None_Color {.75 .75 .75} def
118/Hi {newpath 4 copy 4 2 roll 8 7 roll M L L L Hi_Color setrgbcolor fill closepath} bind def
119/Med {newpath 4 copy 4 2 roll 8 7 roll M L L L Med_Color setrgbcolor fill closepath} bind def
120/Lo {newpath 4 copy 4 2 roll 8 7 roll M L L L Lo_Color setrgbcolor fill closepath} bind def
121/None {newpath 4 copy 4 2 roll 8 7 roll M L L L None_Color setrgbcolor fill closepath} bind def
122
123/inch
124{
125	72 mul
126}
127def
128
129/LeftMargin $LeftMargin inch def
130/RightMargin $RightMargin inch def
131/TopMargin $TopMargin inch def
132/BottomMargin $BottomMargin inch def
133/FontScale 25 def
134/AuthorFontScale 70 def
135
136/centerText
137{
138	dup
139	stringwidth pop
140	2 div
141	RightMargin LeftMargin sub 2 div
142	exch sub
143	LeftMargin add
144	NextLine moveto
145	show
146}
147def
148
149/upLine
150{
151	/NextLine
152	NextLine LineSpace2 add
153	def
154}
155def
156
157/advanceLine
158{
159	/NextLine
160	NextLine LineSpace sub
161	def
162}
163def
164
165/fontScale
166{
167	TopMargin BottomMargin sub FontScale div
168}
169def
170
171/authorfontScale
172{
173	TopMargin BottomMargin sub AuthorFontScale div
174}
175def
176
177/rightJustify
178{
179	dup
180	stringwidth pop
181	RightMargin 1 inch sub
182	exch sub
183	NextLine moveto
184	show
185}
186def
187
188/usableY
189{
190	TopMargin LineSpace 3 mul sub BottomMargin sub
191}
192def
193
194/usableX
195{
196	RightMargin LeftMargin sub
197}
198def
199gsave
200/Times-Roman findfont fontScale scalefont setfont
201/LineSpace fontScale def
202/NextLine (B) stringwidth pop TopMargin exch sub def
203
204%%EndProlog
205%%Page 1
206% title
207
208($Title) centerText advanceLine
209(Kernel: $KernelVersion) centerText advanceLine
210($TestDescription) centerText
211
212% Author Block
213LeftMargin BottomMargin translate
214/Times-Roman findfont authorfontScale scalefont setfont
215/LineSpace2 authorfontScale def
216/NextLine 0 def
217(Based on work by Rusty Russell, Christian Reiniger) rightJustify
218upLine
219(By James M. Kenefick Jr.) rightJustify
220
221grestore
222LeftMargin BottomMargin translate
223
224% Key Block
22515 15 scale
226% This is the key for the graph.
227
228/box { newpath moveto 0 1 rlineto 2 0 rlineto 0 -1 rlineto closepath } def
229/key { setrgbcolor 2 copy box gsave fill grestore 0 0 0 setrgbcolor strokepath fill moveto 2.4 0.25 rmoveto show } def
230
231/Helvetica-Oblique findfont
2321 scalefont setfont
2330.1 setlinewidth
234
235(static functions) 1 5 0.5 1 0.5 key % Light green.
236(indirectly called functions) 1 7 0 0.7 0 key % green
237(exported functions) 1 9 1 0 0 key % red
238(other functions) 1 11 0 0 1 key % blue
239
240(Low Coverage) 1 15 Lo_Color key % blue
241(Medium Coverage) 1 17 Med_Color key % blue
242(Hi Coverage) 1 19 Hi_Color key % blue
243(No Coverage) 1 21 None_Color key % blue
2441 3.25 moveto
2450.8 0.4 0.4 setrgbcolor
246/Helvetica findfont
2471 scalefont setfont
248(xxx) show
2491 3 moveto
2502.4 0.25 rmoveto
2510 0 0 setrgbcolor
252/Helvetica-Oblique findfont
2531 scalefont setfont
254(function name) show
255
2561 1.25 moveto
2570.8 0.4 0.4 setrgbcolor
258/Helvetica-Bold findfont
2591 scalefont setfont
260(xxx) show
2611 1 moveto
2622.4 0.25 rmoveto
2630 0 0 setrgbcolor
264/Helvetica-Oblique findfont
2651 scalefont setfont
266(source filename) show
267
2686 24 moveto
269/Helvetica-Bold findfont
2702 scalefont setfont
271(Key) show
272
273% Box around it
274newpath
2750.2 0.2 moveto
2760.2 27 lineto
27717 27 lineto
27817 0.2 lineto
279closepath
280strokepath fill
281
282
2831 15 div 1 15 div scale
284
285% find and move to center
286END_OF_USAGE
287
288# Find the bounds for the image
289
290$Bounds = `tail -1 $Image`;
291($Junk, $Junk, $minX, $minY, $maxX, $maxY) = split / /, $Bounds;
292
293my $xRange = $maxX - $minX;
294my $yRange = $maxY - $minY;
295
296if ($xRange < $yRange){
297	$Range = $xRange;
298} else {
299	$Range = $yRange;
300}
301print POSTER " 0 usableY usableX sub 2 div translate\n";
302print POSTER "usableX $Range div usableX $Range div scale\n";
303print POSTER "$Range 2 div $Range 2 div translate\n";
304print POSTER "gsave\n";
305# Paste in actual image.
306print POSTER `cat /home/lgp/image.ps`;
307print POSTER "%%Trailer\n";
308print POSTER "grestore\n";
309print POSTER "showpage\n";
310print POSTER "PRorig_showpage_x178313\n";
311print POSTER "/showpage /PRorig_showpage_x178313 load def\n";
312
313