/************************************************************************* hpout.c Copyright 1986 by Stephen Vermeulen Licence for non-comercial use is granted so long as this program is not sold or packaged with anything that is sold. Use by any government (of any ideology) or agency or agent thereof is strictly prohibited! This program acts as a filter converting a file containing Vdraw audit commands into HPGL plotter commands so that Vdraw can be used to prepare high quality graphics on XY plotters. Note: some audit commands are not implemented at all, these include area filling and the various bit map manipulations like magnify, cut, paste and move, conceivably a very ambitious user might attempt to implement these as well. Good luck! Syntax is: hpout plot.guide vdraw.audit hpgl.out where: plot.guide is a small file containing some parameters of interest to the program about the plotter and how large the drawing should be made. magfactor (magnifing factor, typically 10) fmag (font magnifing factor) p1x p1y (location of 0, 0 on the plotter) plotter (model number of plotter) vdraw.audit is the file containg the audit commands output by Vdraw. hpgl.out is the file containing the hpgl approximation of the Vdraw drawing. **************************************************************************/ #include "stdio.h" #include "math.h" #define AREAN1 30 #define AREAN2 30 #define AREAM 8 #define AREAPOWER 3 #define AUDITVERSION 1 #define LINEN 16 #define CIRCLE 0x1 #define ARC 0x2 #define PIE_PIECE 0x4 #define FINISHED 0x10 #define AUDIT_UNDERLINE 1 #define AUDIT_BOLD 2 #define AUDIT_ITALIC 4 #define AUDIT_EXTENDED 8 #define AUDIT_J1 0 #define AUDIT_J2 1 #define AUDIT_COMPLEMENT 2 #define TRUE 1 #define FALSE 0 #define ARROW_HOLLOW 0 #define ARROW_SOLID 1 #define ARROW_START 2 #define ARROW_END 4 char buf[80]; char command[20]; char *audit_commands[] = { "aspect", "bitmap", "move", "draw", "select", "pen", "box", "circle", "arc", "fill", "text", "erase", "font", "version","line","pixel","cut","paste","invert","copy", "arrow","erasebox" }; #define NCOMMANDS 22 FILE *hp_out; main(argc, argv) int argc; char *argv[]; { FILE *audit_in, *guide_in; int i, j, x, y, x1, y1, x2, y2; int version, mode, mode1, mode2, found; int pen_no, line_type, ubie, j12c; int invflag, colour, arrowflag, fontheight; int p1x, p1y, plotterno, arrowlength, arrowwidth; int bm_width, bm_height, bm_depth; double aspect, r, a1, a2, mag; double deg_to_rad, fmag, theta, da, a; double ts, tc, t1, t2, t3, t4; double p2x, p2y, p3x, p3y; static char fontname[80]; fontheight = 10; /* this will be overridden later */ deg_to_rad = atan(1.0)/45.0; if (argc != 4) { fprintf(stderr, "Syntax: %s plot.guide vdraw.audit hpgl.out\n", argv[0]); exit(0); } guide_in = fopen(argv[1], "r"); if (guide_in == NULL) { fprintf(stderr, "Cannot open %s for read\n", argv[1]); exit(1); } audit_in = fopen(argv[2], "r"); if (audit_in == NULL) { fprintf(stderr, "Cannot open %s for read\n", argv[2]); exit(2); } hp_out = fopen(argv[3], "w"); if (hp_out == NULL) { fprintf(stderr, "Cannot open %s for write\n", argv[3]); exit(3); } fscanf(guide_in, "%lf", &mag); fscanf(guide_in, "%lf", &fmag); fscanf(guide_in, "%d %d", &p1x, &p1y); fscanf(guide_in, "%d", &plotterno); arrowlength = 12.0; arrowwidth = 4.0; /***************************************************************** Plotter initialization and initial setup routines follow ******************************************************************/ fprintf(hp_out, "IN;SP2;\n"); /* pick default pen up */ /***************************************************************** Now loop through the Vdraw audit file and convert to HPGL *********************************************************************/ version = 1; while( fgets(buf, 80, audit_in) ) { sscanf(buf, "%s", command); found = 0; for(i = 0; i