void plD_init_plm(PLStream *pls) { PLmDev *dev; U_CHAR c = (U_CHAR) INITIALIZE; dbug_enter("plD_init_plm"); pls->color = 1; /* Is a color device */ pls->dev_fill0 = 1; /* Handle solid fills */ pls->dev_fill1 = 1; /* Handle pattern fills */ /* Initialize family file info */ plFamInit(pls); /* Prompt for a file name if not already set */ plOpenFile(pls); pls->pdfs = pdf_finit(pls->OutFile); /* Allocate and initialize device-specific data */ pls->dev = calloc(1, (size_t) sizeof(PLmDev)); if (pls->dev == NULL) plexit("plD_init_plm: Out of memory."); dev = (PLmDev *) pls->dev; dev->xold = PL_UNDEFINED; dev->yold = PL_UNDEFINED; dev->xmin = 0; dev->xmax = PIXELS_X - 1; dev->ymin = 0; dev->ymax = PIXELS_Y - 1; dev->pxlx = (double) PIXELS_X / (double) LPAGE_X; dev->pxly = (double) PIXELS_Y / (double) LPAGE_Y; plP_setpxl(dev->pxlx, dev->pxly); plP_setphy(dev->xmin, dev->xmax, dev->ymin, dev->ymax); /* Write Metafile header. */ WriteFileHeader(pls); /* Write color map state info */ plD_state_plm(pls, PLSTATE_CMAP0); plD_state_plm(pls, PLSTATE_CMAP1); /* Write initialization command. */ DEBUG_PRINT_LOCATION("before init"); plm_wr( pdf_wr_1byte(pls->pdfs, c) ); }
/*-------------------------------------------------------------------------- * void plD_init_wxpng( PLStream *pls ) * * Initialize wxpng device. *--------------------------------------------------------------------------*/ void plD_init_wxpng( PLStream *pls ) { // Log_Verbose( "plD_init_wxwidgets()" ); wxPLDevBase* dev; dev = common_init( pls ); /* Initialize family file info */ plFamInit( pls ); /* Prompt for a file name if not already set. */ plOpenFile( pls ); pls->plbuf_write = 1; /* use the plot buffer! */ pls->termin = 0; /* file oriented device */ pls->graphx = GRAPHICS_MODE; /* No text mode for this driver (at least for now, might add a console window if I ever figure it out and have the inclination) */ pls->page = 0; dev->showGUI = false; dev->bitmapType = wxBITMAP_TYPE_PNG; }
void plD_init_imp(PLStream *pls) { PLDev *dev; /* Initialize family file info */ plFamInit(pls); /* Prompt for a file name if not already set */ plOpenFile(pls); /* Allocate and initialize device-specific data */ dev = plAllocDev(pls); dev->xold = PL_UNDEFINED; dev->yold = PL_UNDEFINED; dev->xmin = 0; dev->ymin = 0; dev->xmax = IMPX; dev->ymax = IMPY; dev->xlen = dev->xmax - dev->xmin; dev->ylen = dev->ymax - dev->ymin; plP_setpxl((PLFLT) 11.81, (PLFLT) 11.81); plP_setphy(dev->xmin, dev->xmax, dev->ymin, dev->ymax); LineBuff = (short *) malloc(BUFFLENG * sizeof(short)); if (LineBuff == NULL) { plexit("Error in memory alloc in plD_init_imp()."); } fprintf(pls->OutFile, "@Document(Language ImPress, jobheader off)"); fprintf(pls->OutFile, "%c%c", SET_HV_SYSTEM, OPBYTE1); fprintf(pls->OutFile, "%c%c%c", SET_ABS_H, OPWORDH1, OPWORDH2); fprintf(pls->OutFile, "%c%c%c", SET_ABS_V, OPWORDV1, OPWORDV2); fprintf(pls->OutFile, "%c%c", SET_HV_SYSTEM, OPBYTE2); }
void plD_init_xfig(PLStream *pls) { PLDev *dev; plParseDrvOpts(xfig_options); if (text) pls->dev_text = 1; /* want to draw text */ /* Initialize family file info */ plFamInit(pls); /* Prompt for a file name if not already set */ plOpenFile(pls); /* Allocate and initialize device-specific data */ dev = plAllocDev(pls); dev->xold = PL_UNDEFINED; dev->yold = PL_UNDEFINED; dev->xmin = 0; dev->xmax = FIGX; dev->ymin = 0; dev->ymax = FIGY; dev->xscale_dev = DPI/25.4; dev->yscale_dev = DPI/25.4; offset_inc = dev->ymax * (PLINT)dev->yscale_dev; offset = - offset_inc; pls->dev_fill0 = 1; /* Handle solid fills */ if (!pls->colorset) pls->color = 1; /* Is a color device */ plP_setpxl(dev->xscale_dev, dev->xscale_dev); /* dpmm -- dots per mm */ plP_setphy(0, FIGX * dev->xscale_dev, 0, FIGY * dev->yscale_dev); /* physical dimension in mm */ /* Write out header */ fprintf(pls->OutFile, "#FIG 3.2\n"); fprintf(pls->OutFile, "Landscape\n"); fprintf(pls->OutFile, "Center\n"); fprintf(pls->OutFile, "Metric\n"); fprintf(pls->OutFile, "A4\n"); fprintf(pls->OutFile, "100.0\n"); fprintf(pls->OutFile, "Single\n"); fprintf(pls->OutFile, "-2\n"); fprintf(pls->OutFile, "%d 2\n", DPI); /* user defined colors, for colormap0 */ cmap0_ncol = 2 * pls->ncol0; /* allow for a maximum of 2x the default cmap0 entries */ cmap0_pos = ftell(pls->OutFile); stcmap0(pls); /* user defined colors, for colormap1 */ cmap1_ncol = 2 * pls->ncol1; /* allow for a maximum of 2x the default cmap1 entries */ cmap1_pos = ftell(pls->OutFile); stcmap1(pls); bufflen = 2 * BSIZE; buffptr = (short *) malloc(sizeof(short) * bufflen); if (buffptr == NULL) plexit("Out of memory!"); }
void plD_init_ljii(PLStream *pls) { PLDev *dev; /* Initialize family file info */ plFamInit(pls); /* Prompt for a file name if not already set */ plOpenFile(pls); /* Allocate and initialize device-specific data */ dev = plAllocDev(pls); dev->xold = PL_UNDEFINED; dev->yold = PL_UNDEFINED; dev->xmin = 0; dev->ymin = 0; plP_setpxl((PLFLT) 5.905, (PLFLT) 5.905); /* Rotate by 90 degrees since portrait mode addressing is used */ dev->xmin = 0; dev->ymin = 0; dev->xmax = JETY; dev->ymax = JETX; dev->xlen = dev->xmax - dev->xmin; dev->ylen = dev->ymax - dev->ymin; plP_setphy(dev->xmin, dev->xmax, dev->ymin, dev->ymax); /* If portrait mode is specified, then set up an additional rotation * transformation with aspect ratio allowed to adjust via freeaspect. * Default orientation is landscape (ORIENTATION == 3 or 90 deg rotation * counter-clockwise from portrait). (Legacy PLplot used seascape * which was equivalent to ORIENTATION == 1 or 90 deg clockwise rotation * from portrait.) */ if (pls->portrait) { plsdiori((PLFLT)(4 - ORIENTATION)); pls->freeaspect = 1; } /* Allocate storage for bit map matrix */ #ifdef MSDOS if ((bitmap = (char _HUGE *) halloc((long) NBYTES, sizeof(char))) == NULL) plexit("Out of memory in call to calloc"); #else if ((bitmap = (void *) calloc(NBYTES, sizeof(char))) == NULL) plexit("Out of memory in call to calloc"); #endif /* Reset Printer */ fprintf(OF, "%cE", ESC); }
static void ps_init(PLStream *pls) { PSDev *dev; PLFLT pxlx = YPSSIZE/LPAGE_X; PLFLT pxly = XPSSIZE/LPAGE_Y; if (text) { pls->dev_text = 1; /* want to draw text */ pls->dev_unicode = 1; /* want unicode */ if(hrshsym) pls->dev_hrshsym = 1; /* want Hershey symbols */ } pls->dev_fill0 = 1; /* Can do solid fills */ /* Initialize family file info */ plFamInit(pls); /* Prompt for a file name if not already set */ plOpenFile(pls); /* Allocate and initialize device-specific data */ if (pls->dev != NULL) free((void *) pls->dev); pls->dev = calloc(1, (size_t) sizeof(PSDev)); if (pls->dev == NULL) plexit("ps_init: Out of memory."); dev = (PSDev *) pls->dev; dev->xold = PL_UNDEFINED; dev->yold = PL_UNDEFINED; plP_setpxl(pxlx, pxly); dev->llx = XPSSIZE; dev->lly = YPSSIZE; dev->urx = 0; dev->ury = 0; dev->ptcnt = 0; /* Rotate by 90 degrees since portrait mode addressing is used */ dev->xmin = 0; dev->ymin = 0; dev->xmax = PSY; dev->ymax = PSX; dev->xlen = dev->xmax - dev->xmin; dev->ylen = dev->ymax - dev->ymin; plP_setphy(dev->xmin, dev->xmax, dev->ymin, dev->ymax); /* If portrait mode is specified, then set up an additional rotation * transformation with aspect ratio allowed to adjust via freeaspect. * Default orientation is landscape (ORIENTATION == 3 or 90 deg rotation * counter-clockwise from portrait). (Legacy PLplot used seascape * which was equivalent to ORIENTATION == 1 or 90 deg clockwise rotation * from portrait.) */ if (pls->portrait) { plsdiori((PLFLT)(4 - ORIENTATION)); pls->freeaspect = 1; } /* Header comments into PostScript file */ fprintf(OF, "%%!PS-Adobe-2.0 EPSF-2.0\n"); fprintf(OF, "%%%%BoundingBox: \n"); fprintf(OF, "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n"); fprintf(OF, "%%%%Title: PLplot Graph\n"); fprintf(OF, "%%%%Creator: PLplot Version %s\n", VERSION); fprintf(OF, "%%%%CreationDate: %s\n", ps_getdate()); fprintf(OF, "%%%%Pages: (atend)\n"); fprintf(OF, "%%%%EndComments\n\n"); /* Definitions */ /* Save VM state */ fprintf(OF, "/PSSave save def\n"); /* Define a dictionary and start using it */ fprintf(OF, "/PSDict 200 dict def\n"); fprintf(OF, "PSDict begin\n"); fprintf(OF, "/@restore /restore load def\n"); fprintf(OF, "/restore\n"); fprintf(OF, " {vmstatus pop\n"); fprintf(OF, " dup @VMused lt {pop @VMused} if\n"); fprintf(OF, " exch pop exch @restore /@VMused exch def\n"); fprintf(OF, " } def\n"); fprintf(OF, "/@pri\n"); fprintf(OF, " {\n"); fprintf(OF, " ( ) print\n"); fprintf(OF, " ( ) cvs print\n"); fprintf(OF, " } def\n"); /* n @copies - */ fprintf(OF, "/@copies\n"); fprintf(OF, " {\n"); fprintf(OF, " /#copies exch def\n"); fprintf(OF, " } def\n"); /* - @start - -- start everything */ fprintf(OF, "/@start\n"); fprintf(OF, " {\n"); fprintf(OF, " vmstatus pop /@VMused exch def pop\n"); fprintf(OF, " } def\n"); /* - @end - -- finished */ fprintf(OF, "/@end\n"); fprintf(OF, " {flush\n"); fprintf(OF, " end\n"); fprintf(OF, " PSSave restore\n"); fprintf(OF, " } def\n"); /* bop - -- begin a new page */ /* Only fill background if we are using color and if the bg isn't white */ fprintf(OF, "/bop\n"); fprintf(OF, " {\n"); fprintf(OF, " /SaveImage save def\n"); fprintf(OF, " } def\n"); /* - eop - -- end a page */ fprintf(OF, "/eop\n"); fprintf(OF, " {\n"); fprintf(OF, " showpage\n"); fprintf(OF, " SaveImage restore\n"); fprintf(OF, " } def\n"); /* Set line parameters */ fprintf(OF, "/@line\n"); fprintf(OF, " {0 setlinecap\n"); fprintf(OF, " 0 setlinejoin\n"); fprintf(OF, " 1 setmiterlimit\n"); fprintf(OF, " } def\n"); /* d @hsize - horizontal clipping dimension */ fprintf(OF, "/@hsize {/hs exch def} def\n"); fprintf(OF, "/@vsize {/vs exch def} def\n"); /* d @hoffset - shift for the plots */ fprintf(OF, "/@hoffset {/ho exch def} def\n"); fprintf(OF, "/@voffset {/vo exch def} def\n"); /* Set line width */ fprintf(OF, "/lw %d def\n", (int) ( (pls->width < MIN_WIDTH) ? DEF_WIDTH : (pls->width > MAX_WIDTH) ? MAX_WIDTH : pls->width)); /* Setup user specified offsets, scales, sizes for clipping */ fprintf(OF, "/@SetPlot\n"); fprintf(OF, " {\n"); fprintf(OF, " ho vo translate\n"); fprintf(OF, " XScale YScale scale\n"); fprintf(OF, " lw setlinewidth\n"); fprintf(OF, " } def\n"); /* Setup x & y scales */ fprintf(OF, "/XScale\n"); fprintf(OF, " {hs %d div} def\n", YPSSIZE); fprintf(OF, "/YScale\n"); fprintf(OF, " {vs %d div} def\n", XPSSIZE); /* Macro definitions of common instructions, to keep output small */ fprintf(OF, "/M {moveto} def\n"); fprintf(OF, "/D {lineto} def\n"); fprintf(OF, "/A {0.5 0 360 arc} def\n"); fprintf(OF, "/S {stroke} def\n"); fprintf(OF, "/Z {stroke newpath} def\n"); fprintf(OF, "/F {fill} def\n"); fprintf(OF, "/C {setrgbcolor} def\n"); fprintf(OF, "/G {setgray} def\n"); fprintf(OF, "/W {setlinewidth} def\n"); fprintf(OF, "/SF {selectfont} def\n"); fprintf(OF, "/R {rotate} def\n"); fprintf(OF, "/SW {stringwidth 2 index mul exch 2 index mul exch rmoveto pop} bind def\n"); fprintf(OF, "/B {Z %d %d M %d %d D %d %d D %d %d D %d %d closepath} def\n", XMIN, YMIN, XMIN, YMAX, XMAX, YMAX, XMAX, YMIN, XMIN, YMIN); fprintf(OF, "/CL {newpath M D D D closepath clip} def\n"); /* End of dictionary definition */ fprintf(OF, "end\n\n"); /* Set up the plots */ fprintf(OF, "PSDict begin\n"); fprintf(OF, "@start\n"); fprintf(OF, "%d @copies\n", COPIES); fprintf(OF, "@line\n"); fprintf(OF, "%d @hsize\n", YSIZE); fprintf(OF, "%d @vsize\n", XSIZE); fprintf(OF, "%d @hoffset\n", YOFFSET); fprintf(OF, "%d @voffset\n", XOFFSET); fprintf(OF, "@SetPlot\n\n"); }
void plD_init_gif(PLStream *pls) { png_Dev *dev=NULL; pls->termin = 0; /* Not an interactive device */ pls->icol0 = 1; pls->bytecnt = 0; pls->page = 0; pls->dev_fill0 = 1; /* Can do solid fills */ pls->family = 1; /* pmr: allow multiple pages. */ if (!pls->colorset) pls->color = 1; /* Is a color device */ /* Initialize family file info */ plFamInit(pls); /* Prompt for a file name if not already set */ plOpenFile(pls); /* Allocate and initialize device-specific data */ plD_init_gif_Dev(pls); dev=(png_Dev *)pls->dev; if (pls->xlength <= 0 || pls->ylength <=0) { /* use default width, height of 800x600 if not specifed by -geometry option * or plspage */ plspage(0., 0., 800, 600, 0, 0); } pls->graphx = GRAPHICS_MODE; dev->pngx = pls->xlength - 1; /* should I use -1 or not??? */ dev->pngy = pls->ylength - 1; #ifdef use_experimental_hidden_line_hack if (dev->pngx>dev->pngy) /* Work out the scaling factor for the */ { /* "virtual" (oversized) page */ dev->scale=PIXELS_X/dev->pngx; } else { dev->scale=PIXELS_Y/dev->pngy; } #else dev->scale=1; #endif if (pls->xdpi<=0) { /* This corresponds to a typical monitor resolution of 4 pixels/mm. */ plspage(4.*25.4, 4.*25.4, 0, 0, 0, 0); } else { pls->ydpi=pls->xdpi; /* Set X and Y dpi's to the same value */ } /* Convert DPI to pixels/mm */ plP_setpxl(dev->scale*pls->xdpi/25.4,dev->scale*pls->ydpi/25.4); plP_setphy(0, dev->scale*dev->pngx, 0, dev->scale*dev->pngy); #ifdef HAVE_FREETYPE if (pls->dev_text) { init_freetype_lv2(pls); } #endif }
static void tek_init(PLStream *pls) { TekDev *dev; int xmin = 0; int xmax = TEKX; int ymin = 0; int ymax = TEKY; PLFLT pxlx = 4.771; PLFLT pxly = 4.653; pls->graphx = TEXT_MODE; /* Allocate and initialize device-specific data */ pls->dev = calloc(1, (size_t) sizeof(TekDev)); if (pls->dev == NULL) plexit("tek_init: Out of memory."); dev = (TekDev *) pls->dev; dev->curcolor = 1; dev->xold = PL_UNDEFINED; dev->yold = PL_UNDEFINED; plP_setpxl(pxlx, pxly); plP_setphy(xmin, xmax, ymin, ymax); /* Terminal/file initialization */ if (pls->termin) { pls->OutFile = stdout; tty_setup(); } else { plFamInit(pls); plOpenFile(pls); } switch (pls->dev_minor) { #ifdef PLD_tek4107 case tek4107: pls->graphx = GRAPHICS_MODE; fprintf(pls->OutFile, "\033%%!0"); /* set tek mode */ fprintf(pls->OutFile, "\033KN1"); /* clear the view */ fprintf(pls->OutFile, "\033LZ"); /* clear dialog buffer */ fprintf(pls->OutFile, "\033ML1"); /* set default color */ break; #endif /* PLD_tek4107 */ /* A sneaky hack: VLT sometimes has leftover panel information, causing * garbage at the beginning of a sequence of color fills. Since * there is no clear panel command, instead I set the fill color to the * same as background and issue an end panel command. */ #ifdef PLD_vlt case vlt:{ char fillcol[4]; tek_graph(pls); encode_int(fillcol, 0); fprintf(pls->OutFile, "\033MP%s\033LE", fillcol); break; } #endif /* PLD_vlt */ default: tek_graph(pls); } /* Initialize palette */ if ( pls->color & 0x01 ) { printf("\033TM111"); /* Switch to RGB colors */ setcmap(pls); } /* Finish initialization */ fprintf(pls->OutFile, VECTOR_MODE); /* Enter vector mode */ if (pls->termin) fprintf(pls->OutFile, CLEAR_VIEW);/* erase and home */ fflush(pls->OutFile); }