#!/usr/bin/gawk -f # $Id: make_nup_gle 1.11 2000/05/04 15:52:43 pjc Exp $ # $Id: make_nup_gle 1.12 2006/02/07 00:45:43 sxn Exp $ BEGIN { file=0; if (ARGC==1) { if ((test<1)||(test>12)) { printf("No files specified!!\nCreate a Postscript file for upto 12 eps files, using:\n" \ " make_nup_gle *.eps > tmp.gle; gle -device ps tmp.gle ; gv -media a4 tmp.ps\n" \ "For test patterns for n files where n is 5 use:\n make_nup_gle -v test=5\n" \ "Default is Landscape row/column ordering\n" \ "To make order column/row use:\n make_nup_gle -v col=1 *.eps > tmp.gle\n" \ "To make ordering related to portrait files use:\n make_nup_gle -v port=1 *.eps > tmp.gle\n" \ "e.g Portrait column/row ordering test pattern for 12 files use:\n" \ " make_nup_gle -v test=12 -v port=1 -v col=1 > tmp.gle; gle -device ps tmp.gle ; gv -media a4 tmp.ps\n") > "/dev/stderr"; } exit(0); # Jump to END{}, if test set will generate test patterns } # argc=1; } /%%BoundingBox:[ ]*[\-\+0-9]/ { x[file]=$4-$2 y[file]=$5-$3 filename[file]=FILENAME file++ nextfile; } END { if ((ARGC==1)&&((test<1)||(test>12))) { exit(1); } if (ARGC==1) { # Generate test patterns file=test; } printf "size 24 19\n\n" ymax=20; xmax=28; printf "! Auto generated by an awk script, (c) P.Cherriman 1997-2000, S.X.Ng 2001-2006\n" printf "! %d files supplied\n", file width=xmax; height=ymax; rotate=0; if (file==2) { width=ymax; height=xmax/2; rotate=1; printf "! Generating a 2x1 grid\n" } if (file==3||file==4) { width=xmax/2; height=ymax/2; rotate=0; printf "! Generating a 2x2 grid\n" } if (file==5||file==6) { width=ymax/2; height=xmax/3; rotate=1; printf "! Generating a 3x2 grid\n" } if (file==7||file==8) { width=ymax/2; height=xmax/4; rotate=1; printf "! Generating a 4x2 grid\n" } if (file>8&&file<13) { width=xmax/4; height=ymax/3; rotate=0; printf "! Generating a 4x3 grid\n" } if (file>12) { print "Cannot do more than 12 files!!" > "/dev/stderr" exit(1); } cellaspect=width/height printf "! Each cell is %5.3fx%5.3f (AR=%5.3f)", width, height, cellaspect if (rotate==1) printf " and is rotated 90 degrees" if (port==0) { printf "\n! Landscape "; } else { printf "\n! Portrait "; } if (col==0) { printf "Row/Column ordering\n\n"; } else { printf "Column/Row ordering\n\n"; } if (ARGC==1) { # Generate test patterns for(i=0;i "/dev/stderr"; #printf "xoff[%02d]=%5.3f yoff[%02d]=%5.3f\n", i, xoff, i, yoff > "/dev/stderr" # printf "amove %5.3f %5.3f\n", xoff, yoff # sxn 07022006, introduce further x and y offset for gle 4.0.10a printf "amove %5.3f %5.3f\n", xoff-2, yoff-0.6 if (aspect>=1&&rotate==0) { if (aspect>cellaspect) { printf "! Non-Rotate, fileaspect >= 1 and fileaspect > cellaspect\n"; printf "rmove 0 %5.3f ! To adjust for non-perfect fit into cell\n", (height-figheight)/2; place_file_or_testpattern(width, figheight, filename[i], i+1); printf "\n"; } else { printf "! Non-Rotate, fileaspect >= 1 and fileaspect <= cellaspect\n"; printf "rmove %5.3f 0 ! To adjust for non-perfect fit into cell\n", (width-figwidth)/2; place_file_or_testpattern(figwidth, height, filename[i], i+1); printf "\n"; } } if (aspect>=1&&rotate==1) { if (aspect>cellaspect) { printf "! Rotate, fileaspect >= 1 and fileaspect > cellaspect\n"; printf "rmove %5.3f 0 ! To adjust for non-perfect fit into cell\n", (height-figheight)/2; printf "rmove 0 %5.3f ! To compensate for rotate offset\n", width; printf "begin rotate -90\n"; place_file_or_testpattern(width, figheight, filename[i], i+1); printf "end rotate\n\n"; } else { printf "! Rotate, fileaspect >= 1 and fileaspect <= cellaspect\n"; printf "rmove 0 %5.3f ! To adjust for non-perfect fit into cell\n", (width-figwidth)/2; printf "rmove 0 %5.3f ! To compensate for rotate offset\n", figwidth; printf "begin rotate -90\n"; place_file_or_testpattern(figwidth, height, filename[i], i+1); printf "end rotate\n\n"; } } if (aspect<1&&rotate==0) { if (inv_file_aspect>cellaspect) { printf "! Non-Rotate, fileaspect < 1 and 1/fileaspect > cellaspect\n"; printf "rmove 0 %5.3f ! To adjust for non-perfect fit into cell\n", (height-rotate_figheight)/2; printf "rmove 0 %5.3f ! To compensate for rotate offset\n", rotate_figheight; printf "begin rotate -90\n"; place_file_or_testpattern(rotate_figheight, width, filename[i], i+1); printf "end rotate\n\n"; } else { printf "! Non-Rotate, fileaspect < 1 and 1/fileaspect <= cellaspect\n"; printf "rmove %5.3f 0 ! To adjust for non-perfect fit into cell\n", (width-rotate_figwidth)/2; printf "rmove 0 %5.3f ! To compensate for rotate offset\n", height; printf "begin rotate -90\n"; place_file_or_testpattern(height, rotate_figwidth, filename[i], i+1); printf "end rotate\n\n"; } } if (aspect<1&&rotate==1) { if (inv_file_aspect>cellaspect) { printf "! Non-Rotate, fileaspect < 1 and 1/fileaspect > cellaspect\n"; printf "rmove %5.3f 0 ! To adjust for non-perfect fit into cell\n", (height-rotate_figheight)/2; place_file_or_testpattern(rotate_figheight, width, filename[i], i+1); printf "\n"; } else { printf "! Non-Rotate, fileaspect < 1 and 1/fileaspect <= cellaspect\n"; printf "rmove 0 %5.3f ! To adjust for non-perfect fit into cell\n", (width-rotate_figwidth)/2; place_file_or_testpattern(height, rotate_figwidth, filename[i], i+1); printf "\n"; } } } # for each file } function place_file_or_testpattern(x,y,file,pos,ratio,ratio2,ratio3) { ratio=0.8; ratio2=(1-ratio)/2; ratio3=0.5-ratio2; if (ARGC==1) { printf "set color black\nbox %5.3f %5.3f fill white\nrmove %5.3f %5.3f\nbox %5.3f %5.3f fill grey5\n", x, y, ratio2*x, ratio2*y, ratio*x, ratio*y; printf "rmove %5.3f %5.3f\nset color red\nset font psh\nset just cc\nwrite %d\n", ratio3*x, ratio3*y, pos; } else { printf "postscript \"%s\" %5.3f %5.3f\n", file, x, y; } } function corner_mark(x,y) { printf "rline 0 %5.3f\nrmove 0 %5.3f\nrline %5.3f 0\n", y, -y, x; } function mark_corners(x,y,size) { corner_mark(-size,-size); printf "amove 0 %d\n", y; corner_mark(-size,size); printf "amove %d 0\n", x; corner_mark(size,-size); printf "amove %d %d\n", x, y; corner_mark(size,size); } function cross(size) { printf "rline 0 %5.3f\nrmove 0 %5.3f\nrline 0 %5.3f\nrmove 0 %5.3f\n", size, -size, -size, size; printf "rline %5.3f 0\nrmove %5.3f 0\nrline %5.3f 0\nrmove %5.3f 0\n", size, -size, -size, size; } function mark_cell_edges(xmax,ymax,size) { for(i=0;i