multipage_hp2ps
authorRavi Nanavati <ravi@bluespec.com>
Fri, 29 Sep 2006 22:47:39 +0000 (22:47 +0000)
committerRavi Nanavati <ravi@bluespec.com>
Fri, 29 Sep 2006 22:47:39 +0000 (22:47 +0000)
Add support for splitting the key index over multiple pages in hp2ps
Multipage support can be requested with the -M command-line flag
or inferred if the number of bands requested is greater than 20
(the limit on the number of bands displayed has been removed)

Please include this change in the 6.6 branch as well as HEAD

utils/hp2ps/Defines.h
utils/hp2ps/Dimensions.c
utils/hp2ps/Error.c
utils/hp2ps/Key.c
utils/hp2ps/Main.c
utils/hp2ps/Main.h
utils/hp2ps/PsFile.c
utils/hp2ps/PsFile.h

index 8d38546..ae620f4 100644 (file)
@@ -10,7 +10,7 @@
 extern floatish _thresh_;
 
 #define TWENTY                   _twenty_ /* show top 20 bands, grouping excess     */
-#define DEFAULT_TWENTY         20 /* this is default and absolute maximum   */
+#define DEFAULT_TWENTY         20 /* this is default and maximum per page   */
 extern int _twenty_;
 
 #define LARGE_FONT             12  /* Helvetica 12pt                        */
index e732402..4b4aadb 100644 (file)
@@ -51,7 +51,8 @@ Dimensions()
        titleheight = TITLE_HEIGHT;
     } 
 
-    graphwidth  = titlewidth - graphx0 - (TWENTY ? KeyWidth() : 0);
+    boolish keyOnGraph = !multipageflag && TWENTY != 0;
+    graphwidth  = titlewidth - graphx0 - (keyOnGraph ? KeyWidth() : 0);
     graphheight = borderheight - titleheight - (2 * borderspace) - graphy0;
 }
 
index 809c24e..68f88d8 100644 (file)
@@ -47,6 +47,7 @@ Usage(str)
    printf("      -ef[in|mm|pt] produce Encapsulated PostScript f units wide (f > 2 inches)\n");
    printf("      -g  produce output suitable for GHOSTSCRIPT previever\n");
    printf("      -i[+|-] sort by identifier string (-i+ gives greatest on top) \n"); 
+   printf("      -M  multi-page output (key separate from graph)\n");
    printf("      -mn print maximum of n bands (default & max 20)\n");
    printf("          -m0 removes the band limit altogether\n");
    printf("      -p  use previous scaling, shading and ordering\n");
index 8c63721..314a682 100644 (file)
@@ -5,6 +5,7 @@
 #include "Dimensions.h"
 #include "HpFile.h"
 #include "Shade.h"
+#include "PsFile.h"
 
 /* own stuff */
 #include "Key.h"
@@ -20,12 +21,18 @@ void Key()
     for (i = 0; i < nidents; i++)    /* count identifiers */ 
        ;
 
-    c  = graphy0;
-    dc = graphheight / (floatish) (i + 1);
+    c  = multipageflag ? 0 : graphy0;
+    dc = graphheight / (floatish) ((i <= 20) ? (i + 1) : 20);
 
     for (i = 0; i < nidents; i++) {
        c += dc;
        KeyEntry(c, identtable[i]->name, ShadeOf(identtable[i]->name));
+        // if we have spit out 20 entries and we're going to output more
+        // advance the page
+       if (i % DEFAULT_TWENTY == (DEFAULT_TWENTY - 1) && i != nidents - 1) {
+         c = 0;
+         NextPage();
+       }
     }
 }
 
@@ -42,7 +49,7 @@ KeyEntry(centreline, name, colour)
     namebase = centreline - (floatish) (NORMAL_FONT / 2);
     keyboxbase = centreline - ((floatish) KEY_BOX_WIDTH / 2.0);
 
-    kstart = graphx0 + graphwidth;
+    kstart = graphx0 + (multipageflag ? 0 : graphwidth);
 
     fprintf(psfp, "%f %f moveto\n", kstart + borderspace, keyboxbase);
     fprintf(psfp, "0 %d rlineto\n", KEY_BOX_WIDTH);
index 3b5efed..eb50e00 100644 (file)
@@ -17,7 +17,7 @@
 #include "Utilities.h"
 
 boolish pflag = 0;     /* read auxiliary file                  */
-boolish eflag = 0;     /* scaled EPSF                          */ 
+boolish eflag = 0;     /* scaled EPSF                          */
 boolish dflag = 0;     /* sort by standard deviation           */
 int     iflag = 0;     /* sort by identifier (3-way flag)      */
 boolish gflag = 0;     /* output suitable for previewer        */
@@ -29,6 +29,7 @@ boolish tflag = 0;    /* ignored threshold specified          */
 boolish cflag = 0;      /* colour output                        */
 
 boolish filter;                /* true when running as a filter        */
+boolish multipageflag = 0;  /* true when the output should be 2 pages - key and profile */ 
 
 static floatish WidthInPoints PROTO((char *));           /* forward */
 static FILE *Fp PROTO((char *, char **, char *, char *)); /* forward */
@@ -107,9 +108,13 @@ char* argv[];
            case 'm':
                mflag++;
                TWENTY = atoi(*argv + 1);
-               if (TWENTY > DEFAULT_TWENTY)
-                   Usage(*argv-1);
+               // only 20 keys fit on a page
+               if (TWENTY > DEFAULT_TWENTY) 
+                  multipageflag++;
                goto nextarg;
+           case 'M':
+               multipageflag++;
+                goto nextarg;
            case 't':
                tflag++;
                THRESHOLD_PERCENT = (floatish) atof(*argv + 1);
@@ -161,7 +166,8 @@ nextarg: ;
 
     if (pflag) Reorder();    /* ReOrders on aux file */
 
-    if (TWENTY) TopTwenty(); /* Selects top twenty (mflag) */
+    /* Selects top bands (mflag) - can be more than 20 now */
+    if (TWENTY != 0) TopTwenty(); 
 
     Dimensions();
 
index 30e7a7e..81c62dc 100644 (file)
@@ -64,6 +64,8 @@ extern int     mflag;
 extern boolish tflag;
 extern boolish cflag;
 
+extern boolish multipageflag;
+
 extern char *programname;
 
 extern char *hpfile;
index 357f826..1324da6 100644 (file)
@@ -21,11 +21,8 @@ static void TitleOutlineBox PROTO((void)); /* forward */
 static void BigTitleText PROTO((void)); /* forward */
 static void TitleText PROTO((void)); /* forward */
 
-void
-PutPsFile()
+static void DoTitleAndBox()
 {
-    Prologue();
-    Variables();
     BorderOutlineBox();
 
     if (bflag) {
@@ -35,12 +32,35 @@ PutPsFile()
        TitleOutlineBox();
        TitleText();
     }
+}
+
+static void Landscape PROTO((void));                   /* forward */
+static void Portrait  PROTO((void));                   /* forward */
+
+void NextPage() {
+    fprintf(psfp, "showpage\n");
+    if (gflag) Portrait(); else Landscape();
+    DoTitleAndBox();
+}
+
+void
+PutPsFile()
+{
+    Prologue();
+    Variables();
 
     CurvesInit();
 
+    DoTitleAndBox();
+
+    if (multipageflag) {
+      Key(); // print multi-page key even if there are more than 20 bands 
+      NextPage();
+    }
+
     Axes();
 
-    if (TWENTY) Key();
+    if (!multipageflag && (TWENTY != 0)) Key();
 
     Curves();
 
@@ -52,8 +72,6 @@ PutPsFile()
 
 static void StandardSpecialComments PROTO((void));     /* forward */
 static void EPSFSpecialComments PROTO((floatish));     /* forward */
-static void Landscape PROTO((void));                   /* forward */
-static void Portrait  PROTO((void));                   /* forward */
 static void Scaling   PROTO((floatish));               /* forward */
 
 static void
index acec070..07d3ed2 100644 (file)
@@ -2,5 +2,6 @@
 #define PS_FILE_H
 
 void PutPsFile PROTO((void));
+void NextPage PROTO((void)); // for Key.c
 
 #endif /* PS_FILE_H */