[BACK]Return to epslatex.trm CVS log [TXT][DIR] Up to [local] / OpenXM_contrib / gnuplot / term

Annotation of OpenXM_contrib/gnuplot/term/epslatex.trm, Revision 1.1

1.1     ! ohara       1: /*
        !             2:  * $Id: epslatex.trm,v 1.1.2.4 2002/01/26 19:05:34 lhecking Exp $
        !             3:  */
        !             4:
        !             5: /* GNUPLOT - epslatex.trm */
        !             6:
        !             7: /*[
        !             8:  * Copyright 2000
        !             9:  *
        !            10:  * Permission to use, copy, and distribute this software and its
        !            11:  * documentation for any purpose with or without fee is hereby granted,
        !            12:  * provided that the above copyright notice appear in all copies and
        !            13:  * that both that copyright notice and this permission notice appear
        !            14:  * in supporting documentation.
        !            15:  *
        !            16:  * Permission to modify the software is granted, but not the right to
        !            17:  * distribute the complete modified source code.  Modifications are to
        !            18:  * be distributed as patches to the released version.  Permission to
        !            19:  * distribute binaries produced by compiling modified sources is granted,
        !            20:  * provided you
        !            21:  *   1. distribute the corresponding source modifications from the
        !            22:  *    released version in the form of a patch file along with the binaries,
        !            23:  *   2. add special version identification to distinguish your version
        !            24:  *    in addition to the base release version number,
        !            25:  *   3. provide your name and address as the primary contact for the
        !            26:  *    support of your modified version, and
        !            27:  *   4. retain our contact information in regard to use of the base
        !            28:  *    software.
        !            29:  * Permission to distribute the released version of the source code along
        !            30:  * with corresponding source modifications in the form of a patch file is
        !            31:  * granted with same provisions 2 through 4 for binary distributions.
        !            32:  *
        !            33:  * This software is provided "as is" without express or implied warranty
        !            34:  * to the extent permitted by applicable law.
        !            35: ]*/
        !            36:
        !            37: /*
        !            38:  * This terminal driver supports:
        !            39:  *     epslatex
        !            40:  */
        !            41:
        !            42: /* Written by Gregor Thalhammer
        !            43:  * you'll find a lot of similarities with the pslatex, postscript and pstricks terminal drivers
        !            44:  */
        !            45:
        !            46: #include "driver.h"
        !            47:
        !            48: #ifdef TERM_REGISTER
        !            49: register_term(epslatex)
        !            50: #endif
        !            51:
        !            52: #ifdef TERM_PROTO
        !            53: TERM_PUBLIC void EPSL_options __PROTO((void));
        !            54: TERM_PUBLIC void EPSL_init __PROTO((void));
        !            55: TERM_PUBLIC void EPSL_graphics __PROTO((void));
        !            56: TERM_PUBLIC void EPSL_text __PROTO((void));
        !            57: TERM_PUBLIC void EPSL_reset __PROTO((void));
        !            58: TERM_PUBLIC void EPSL_linetype __PROTO((int linetype));
        !            59: TERM_PUBLIC void EPSL_move __PROTO((unsigned int x, unsigned int y));
        !            60: TERM_PUBLIC void EPSL_vector __PROTO((unsigned int x, unsigned int y));
        !            61: TERM_PUBLIC void EPSL_arrow __PROTO((unsigned int xstart, unsigned int ystart, unsigned int xend, unsigned int yend, TBOOLEAN head));
        !            62: TERM_PUBLIC void EPSL_put_text __PROTO((unsigned int x, unsigned int y, char *str));
        !            63: TERM_PUBLIC int EPSL_text_angle __PROTO((int ang));
        !            64: TERM_PUBLIC int EPSL_justify_text __PROTO((enum JUSTIFY mode));
        !            65: TERM_PUBLIC void EPSL_point __PROTO((unsigned int x, unsigned int y, int number));
        !            66: TERM_PUBLIC int EPSL_set_font __PROTO((char *font));
        !            67: TERM_PUBLIC void EPSL_fillbox __PROTO((int style, unsigned int x1, unsigned int y1, unsigned int width, unsigned int height));
        !            68: TERM_PUBLIC void EPSL_linewidth __PROTO((double linewidth));
        !            69: TERM_PUBLIC void EPSL_pointsize __PROTO((double ptsize));
        !            70:
        !            71: #ifdef PM3D
        !            72: /* Not needed --- PS terminal version reused:
        !            73: TERM_PUBLIC int EPSL_make_palette __PROTO((t_sm_palette *));
        !            74: TERM_PUBLIC void EPSL_previous_palette __PROTO((void));
        !            75: TERM_PUBLIC void EPSL_set_color __PROTO((double));
        !            76: */
        !            77: TERM_PUBLIC void EPSL_filled_polygon __PROTO((int, gpiPoint *));
        !            78: #endif
        !            79:
        !            80: #define EPSL_SC (50)           /* scale is 1pt = 10 units */
        !            81: /* changed to 50, but gs now renders terribly slowly to display (x11alpha) !! */
        !            82: #define EPSL_POINT_TYPES 8     /* never used! */
        !            83: #define EPSL_XOFF      72      /* page offset in pts */
        !            84: #define EPSL_YOFF      72
        !            85: #define EPSL_XMAX       (5*72*EPSL_SC) /* default plot size 5*3 inch */
        !            86: #define EPSL_YMAX       (3*72*EPSL_SC)
        !            87: #define EPSL_XLAST      (EPSL_XMAX - 1)
        !            88: #define EPSL_YLAST      (EPSL_YMAX - 1)
        !            89: #define EPSL_VTIC       (6.0*EPSL_SC)
        !            90: #define EPSL_HTIC       (6.0*EPSL_SC)
        !            91: #define EPSL_POINTSIZE  (2.0*EPSL_SC)
        !            92: #define        EPSL_LW         (0.4*EPSL_SC)   /* linewidth = 0.4 pts */
        !            93: #define EPSL_VCHAR      (11*EPSL_SC)   /* default is 11 point characters */
        !            94: #define EPSL_HCHAR      (11*EPSL_SC*5/10)
        !            95:
        !            96: #endif /* TERM_PROTO */
        !            97:
        !            98: #ifndef TERM_PROTO_ONLY
        !            99:
        !           100: #ifdef TERM_BODY
        !           101:
        !           102: #define EPSL_FLUSH_PATH \
        !           103:     if (EPSL_path_count) {fputs("Gpstroke\n",gpoutfile); EPSL_path_count = 0; EPSL_relative_ok = FALSE;}
        !           104:
        !           105: /* From version.c */
        !           106: extern char gnuplot_version[];
        !           107: extern char gnuplot_patchlevel[];
        !           108:
        !           109: static char EPSL_font[MAX_ID_LEN + 1] = "default";     /* name of font */
        !           110: static int EPSL_fontsize = 11; /* size of font in pts */
        !           111:
        !           112: static TBOOLEAN EPSL_color = FALSE;    /* don't use colors */
        !           113: static TBOOLEAN EPSL_solid = FALSE;    /*  use solid lines */
        !           114:
        !           115: static int EPSL_path_count = 0;        /* count of lines in path */
        !           116: static int EPSL_ang = 0;       /* text angle */
        !           117:
        !           118: static enum JUSTIFY EPSL_justify = LEFT;       /* text is flush left */
        !           119: /* static int x = 0; */
        !           120:
        !           121: /* for testing */
        !           122: /*
        !           123: char GPFAR * GPFAR EPSL_header[] = {"(prolog.ps) run\n", NULL};
        !           124:  */
        !           125:
        !           126: char GPFAR *GPFAR EPSL_header[] = {
        !           127: " /hpt hpt_ def  \n",
        !           128: " /vpt vpt_ def  \n",
        !           129: " /Gppointsize_ 1 def \n",
        !           130: " /Gplinewidth_ 1 def \n",
        !           131: "  \n",
        !           132: " /ArrowDict 25 dict def  \n",
        !           133: "  \n",
        !           134: " /M /moveto load def  \n",
        !           135: " /L /lineto load def  \n",
        !           136: " /R /rmoveto load def  \n",
        !           137: " /V /rlineto load def  \n",
        !           138: " /ED { exch def} bind def  \n",
        !           139: "  \n",
        !           140: " /Atan {/atan load stopped {pop pop 0} if } def  \n",
        !           141: " /Div {dup 0 eq { pop } { div } ifelse } def  \n",
        !           142: " /Pyth {dup mul exch dup mul add sqrt} def  \n",
        !           143: "  \n",
        !           144: " %Sizes  \n",
        !           145: " /Gpsetlinewidth  \n",
        !           146: " { \n",
        !           147: "   dup \n",
        !           148: " %  /Gplinewidth_ ED %save \n",
        !           149: "   Gplinewidth mul setlinewidth \n",
        !           150: " } def  \n",
        !           151: "  \n",
        !           152: " /Gpsetpointsize   \n",
        !           153: " {  \n",
        !           154: "   dup  \n",
        !           155: "   /Gppointsize_ ED %save \n",
        !           156: "   dup  \n",
        !           157: "   vpt_ mul /vpt ED \n",
        !           158: "   hpt_ mul /hpt ED  \n",
        !           159: " } def  \n",
        !           160: "      \n",
        !           161: " %Color  \n",
        !           162: " /SetHsbColor { Color {sethsbcolor} {pop pop pop} ifelse } def  \n",
        !           163: " /SetCmykColor { Color {setcmykcolor} {pop pop pop pop} ifelse } def  \n",
        !           164: " /SimpleSetColor {6 div 1 1 SetHsbColor} def  \n",
        !           165: " /Black {0 0 0 0 SetCmykColor} def  \n",
        !           166: " /Red {0 SimpleSetColor} def  \n",
        !           167: " /Blue {1 1 0 0 SetCmykColor} def  \n",
        !           168: " /Cyan {1 0 0 0 SetCmykColor} def  \n",
        !           169: " /Magenta {0 1 0 0 SetCmykColor} def \n",
        !           170: "  \n",
        !           171: " %Stroking  \n",
        !           172: " /PathLength@ % z = z + sqrt{(x-xlast)^2 + (y-ylast)^2}  \n",
        !           173: "  {  \n",
        !           174: "    /z   \n",
        !           175: "    z  \n",
        !           176: "    y ylast sub  \n",
        !           177: "    x xlast sub  \n",
        !           178: "    Pyth  \n",
        !           179: "    add  \n",
        !           180: "    def   \n",
        !           181: "    /ylast y def  \n",
        !           182: "    /xlast x def  \n",
        !           183: "  } def  \n",
        !           184: "      \n",
        !           185: "  /PathLength  \n",
        !           186: "  {  \n",
        !           187: "    flattenpath  \n",
        !           188: "    /z 0 def  \n",
        !           189: "    { %move  \n",
        !           190: "      /ystart ED  \n",
        !           191: "      /xstart ED  \n",
        !           192: "      /xlast xstart def  \n",
        !           193: "      /ylast ystart def  \n",
        !           194: "    }  \n",
        !           195: "    { %line  \n",
        !           196: "      /y ED  \n",
        !           197: "      /x ED  \n",
        !           198: "      PathLength@  \n",
        !           199: "    }  \n",
        !           200: "    { %curve  \n",
        !           201: "    }  \n",
        !           202: "    { %close  \n",
        !           203: "      /x xstart def  \n",
        !           204: "      /y ystart def  \n",
        !           205: "      PathLength@   \n",
        !           206: "    }  \n",
        !           207: "    /pathforall load  \n",
        !           208: "    stopped {pop pop pop pop} if  \n",
        !           209: "    z  \n",
        !           210: "  } def  \n",
        !           211: "    \n",
        !           212: " %dotsep DotLine  \n",
        !           213: " /DotLine   \n",
        !           214: " {  \n",
        !           215: "   PathLength /b ED   \n",
        !           216: "   /z ED   \n",
        !           217: "   /y currentlinewidth def   \n",
        !           218: "   /z y z add def   \n",
        !           219: "   [ 0 b b z Div round Div dup 0 le { pop 1 } if] 0 setdash   \n",
        !           220: "   1 setlinecap  \n",
        !           221: " } def  \n",
        !           222: "  \n",
        !           223: " /DashLine   \n",
        !           224: "  {  \n",
        !           225: "    PathLength /b ED   \n",
        !           226: "    /x ED   \n",
        !           227: "    /y ED   \n",
        !           228: "    /z y x add def   \n",
        !           229: "    b y sub z Div round z mul y add b exch Div \n",
        !           230: "    dup  \n",
        !           231: "    y mul /y ED   \n",
        !           232: "    x mul /x ED   \n",
        !           233: "    x 0 gt y 0 gt and   \n",
        !           234: "    { [ y x ] 0 }  \n",
        !           235: "    { [ 1 0 ] 0 }  \n",
        !           236: "    ifelse  \n",
        !           237: "    setdash  \n",
        !           238: "  } def  \n",
        !           239: "  \n",
        !           240: " /DashLineTwo \n",
        !           241: "  {  \n",
        !           242: "    PathLength /b ED   \n",
        !           243: "    /u ED \n",
        !           244: "    /v ED \n",
        !           245: "    /x ED   \n",
        !           246: "    /y ED \n",
        !           247: "    /z y x add u add v add def   \n",
        !           248: "    b y sub z Div round z mul y add b exch Div \n",
        !           249: "    dup  \n",
        !           250: "    y mul /y ED   \n",
        !           251: "    x mul /x ED   \n",
        !           252: "    x 0 gt y 0 gt and   \n",
        !           253: "    { [ y x v u] 0 }  \n",
        !           254: "    { [ 1 0 ] 0 }  \n",
        !           255: "    ifelse  \n",
        !           256: "    setdash  \n",
        !           257: "  } def  \n",
        !           258: "      \n",
        !           259: "  \n",
        !           260: " /DotLineStroke   \n",
        !           261: " {  \n",
        !           262: "   gsave  \n",
        !           263: "     Dashed {currentlinewidth 2 mul DotLine} if  \n",
        !           264: "     stroke  \n",
        !           265: "   grestore  \n",
        !           266: " } def  \n",
        !           267: "    \n",
        !           268: " /SolidLineStroke  \n",
        !           269: " {  \n",
        !           270: "   gsave  \n",
        !           271: "     [] 0 setdash  \n",
        !           272: "     stroke  \n",
        !           273: "   grestore  \n",
        !           274: " } def  \n",
        !           275: "    \n",
        !           276: " /DashLineStroke  \n",
        !           277: " {  \n",
        !           278: "   gsave   \n",
        !           279: "     Dashed {Gplinewidth 8 mul Gplinewidth 5 mul DashLine} if  \n",
        !           280: "     stroke  \n",
        !           281: "   grestore  \n",
        !           282: " } def  \n",
        !           283: "   \n",
        !           284: " /DashDotLineStroke  \n",
        !           285: " {  \n",
        !           286: "   gsave   \n",
        !           287: "     Dashed {Gplinewidth 8 mul Gplinewidth 5 mul 0 Gplinewidth 5 mul DashLineTwo} if  \n",
        !           288: "     stroke  \n",
        !           289: "   grestore  \n",
        !           290: " } def  \n",
        !           291: "    \n",
        !           292: " /DashShortLineStroke  \n",
        !           293: " {  \n",
        !           294: "   gsave   \n",
        !           295: "     Dashed {Gplinewidth 4 mul dup DashLine} if  \n",
        !           296: "     stroke  \n",
        !           297: "   grestore  \n",
        !           298: " } def  \n",
        !           299: "    \n",
        !           300: " /ArrowHead  \n",
        !           301: " {   \n",
        !           302: "   currentlinewidth mul add dup 2 div /w ED  \n",
        !           303: "   mul dup /h ED  \n",
        !           304: "   mul /a ED   \n",
        !           305: "   w neg h moveto   \n",
        !           306: "   0 0 L   \n",
        !           307: "   w h L   \n",
        !           308: "   w neg a neg rlineto   \n",
        !           309: "   gsave fill grestore   \n",
        !           310: " } def  \n",
        !           311: "    \n",
        !           312: "  %/DrawArrowHead {1 dup scale 0.2 1.4 50 3 ArrowHead} def  \n",
        !           313: "  %%%%%  \n",
        !           314: "  %inset length dim num  \n",
        !           315: "  %arrowwidth = dim + num*linewidth  \n",
        !           316: "  %arrowlength = length*arrowwidth  \n",
        !           317: "  %arrowinset = width * inset  \n",
        !           318: "    \n",
        !           319: "  /DrawArrowHead {0.2 1.4 Gplinewidth 3 mul 4 ArrowHead} def  \n",
        !           320: "    \n",
        !           321: "  /Arrow  \n",
        !           322: "  {  \n",
        !           323: "    currentpoint  \n",
        !           324: "    4 2 roll  \n",
        !           325: "    ArrowDict  \n",
        !           326: "    begin  \n",
        !           327: "      /@mtrx matrix currentmatrix def  \n",
        !           328: "      gsave  \n",
        !           329: "        2 copy translate  \n",
        !           330: "        2 index sub neg exch  \n",
        !           331: "        3 index sub exch Atan  \n",
        !           332: "        rotate  \n",
        !           333: "        newpath  \n",
        !           334: "        DrawArrowHead  \n",
        !           335: "        @mtrx setmatrix  \n",
        !           336: "        currentpoint  \n",
        !           337: "      grestore  \n",
        !           338: "    end %ArrowDicht  \n",
        !           339: "    lineto  \n",
        !           340: "    Gpstroke  \n",
        !           341: "  } def  \n",
        !           342: "    \n",
        !           343: "  %axis  \n",
        !           344: "  /LTa   \n",
        !           345: "  {  \n",
        !           346: "    Gpstroke      \n",
        !           347: "    newpath  \n",
        !           348: "    0 setgray  \n",
        !           349: "    /Gpstroke {DotLineStroke newpath} def  \n",
        !           350: "  } def  \n",
        !           351: "    \n",
        !           352: "  %border  \n",
        !           353: "  /LTb  \n",
        !           354: "  {  \n",
        !           355: "    Gpstroke      \n",
        !           356: "    newpath  \n",
        !           357: "    0 setgray  \n",
        !           358: "    /Gpstroke {SolidLineStroke newpath} def  \n",
        !           359: "  } def  \n",
        !           360: "    \n",
        !           361: "  /LT0  \n",
        !           362: "  {  \n",
        !           363: "    Gpstroke      \n",
        !           364: "    newpath  \n",
        !           365: "    Red  \n",
        !           366: "    /Gpstroke {SolidLineStroke newpath} def  \n",
        !           367: "  } def  \n",
        !           368: "    \n",
        !           369: "  /LT1  \n",
        !           370: "  {  \n",
        !           371: "    Gpstroke      \n",
        !           372: "    newpath  \n",
        !           373: "    Blue  \n",
        !           374: "    /Gpstroke {DashLineStroke newpath} def  \n",
        !           375: "  } def  \n",
        !           376: "    \n",
        !           377: "  /LT2   \n",
        !           378: "  {  \n",
        !           379: "    Gpstroke  \n",
        !           380: "    newpath  \n",
        !           381: "    Cyan  \n",
        !           382: "    /Gpstroke {DashShortLineStroke newpath} def  \n",
        !           383: "  } def  \n",
        !           384: "  \n",
        !           385: "  /LT3   \n",
        !           386: "  {  \n",
        !           387: "    Gpstroke  \n",
        !           388: "    newpath  \n",
        !           389: "    Magenta  \n",
        !           390: "    /Gpstroke {DashDotLineStroke newpath} def  \n",
        !           391: "  } def  \n",
        !           392: "    \n",
        !           393: "  /Pnt  \n",
        !           394: "  {  \n",
        !           395: "    gsave   \n",
        !           396: "      [] 0 setdash  \n",
        !           397: "      1 setlinecap   \n",
        !           398: "      Gplinewidth Gppointsize_ mul setlinewidth \n",
        !           399: "      M  \n",
        !           400: "      0 0 V  \n",
        !           401: "      stroke  \n",
        !           402: "    grestore  \n",
        !           403: "  } def  \n",
        !           404: "    \n",
        !           405: "  /DiaPath  \n",
        !           406: "  {  \n",
        !           407: "      [] 0 setdash  \n",
        !           408: "      Gplinewidth setlinewidth  \n",
        !           409: "      2 copy   \n",
        !           410: "      newpath  \n",
        !           411: "      vpt add moveto  \n",
        !           412: "      hpt neg vpt neg rlineto   \n",
        !           413: "      hpt vpt neg rlineto  \n",
        !           414: "      hpt vpt rlineto   \n",
        !           415: "      hpt neg vpt rlineto  \n",
        !           416: "      closepath  \n",
        !           417: "  } def  \n",
        !           418: "    \n",
        !           419: "  /Dia   \n",
        !           420: "  {   \n",
        !           421: "    gsave  \n",
        !           422: "      DiaPath  \n",
        !           423: "      stroke  \n",
        !           424: "    grestore  \n",
        !           425: "  } def  \n",
        !           426: "    \n",
        !           427: "  /DaF  \n",
        !           428: "  {  \n",
        !           429: "    gsave  \n",
        !           430: "      DiaPath  \n",
        !           431: "      fill  \n",
        !           432: "    grestore  \n",
        !           433: "  } def  \n",
        !           434: "    \n",
        !           435: "  /Crc  \n",
        !           436: "  {  \n",
        !           437: "    gsave  \n",
        !           438: "      [] 0 setdash  \n",
        !           439: "      Gplinewidth setlinewidth  \n",
        !           440: "      newpath  \n",
        !           441: "      vpt 0.85 mul 0 360 arc  \n",
        !           442: "      closepath  \n",
        !           443: "      stroke  \n",
        !           444: "    grestore  \n",
        !           445: "  } def  \n",
        !           446: "        \n",
        !           447: "    \n",
        !           448: "  /Crs  \n",
        !           449: "  {  \n",
        !           450: "    gsave  \n",
        !           451: "      [] 0 setdash  \n",
        !           452: "      Gplinewidth setlinewidth  \n",
        !           453: "      0 setlinecap  \n",
        !           454: "      newpath  \n",
        !           455: "      vpt sub  \n",
        !           456: "      moveto  \n",
        !           457: "      0 vpt 2 mul rlineto  \n",
        !           458: "      hpt vpt neg rmoveto  \n",
        !           459: "      hpt 2 mul neg 0 rlineto  \n",
        !           460: "      stroke  \n",
        !           461: "    grestore  \n",
        !           462: "  } def  \n",
        !           463: "    \n",
        !           464: "  /CrX  \n",
        !           465: "  {  \n",
        !           466: "  gsave  \n",
        !           467: "   translate  \n",
        !           468: "   45 rotate  \n",
        !           469: "   0 0 Crs  \n",
        !           470: "  grestore  \n",
        !           471: "  } def  \n",
        !           472: "    \n",
        !           473: "  /CcF  \n",
        !           474: "  {  \n",
        !           475: "    gsave  \n",
        !           476: "      [] 0 setdash  \n",
        !           477: "      Gplinewidth setlinewidth  \n",
        !           478: "      newpath  \n",
        !           479: "      vpt 0.85 mul 0 360 arc  \n",
        !           480: "      closepath  \n",
        !           481: "      fill  \n",
        !           482: "    grestore  \n",
        !           483: "  } def  \n",
        !           484: "    \n",
        !           485: "  /Box  \n",
        !           486: "  {  \n",
        !           487: "     gsave  \n",
        !           488: "       translate  \n",
        !           489: "       45 rotate  \n",
        !           490: "       0 0 DiaPath  \n",
        !           491: "       stroke  \n",
        !           492: "     grestore  \n",
        !           493: "  } def  \n",
        !           494: "    \n",
        !           495: "  /BxF  \n",
        !           496: "  {  \n",
        !           497: "     gsave  \n",
        !           498: "       translate  \n",
        !           499: "       45 rotate  \n",
        !           500: "       0 0 DiaPath  \n",
        !           501: "       fill  \n",
        !           502: "     grestore  \n",
        !           503: "  } def  \n",
        !           504: "    \n",
        !           505: "  /Gpstroke {stroke} def  \n",
        !           506: "  1 setlinecap  \n",
        !           507: "  1 setlinejoin \n",
        !           508:     NULL
        !           509: };
        !           510:
        !           511: static int EPSL_pen_x, EPSL_pen_y;
        !           512: static int EPSL_taken;
        !           513: static int EPSL_linetype_last;
        !           514: static TBOOLEAN EPSL_relative_ok;
        !           515: static char *EPSL_texfilename = NULL;
        !           516: static FILE *EPSL_texfile;
        !           517:
        !           518: TERM_PUBLIC void
        !           519: EPSL_options()
        !           520: {
        !           521:     if (!END_OF_COMMAND) {     /* set all options to their default values */
        !           522:        if (almost_equals(c_token, "d$efault")) {
        !           523:            EPSL_color = FALSE;
        !           524:            EPSL_solid = FALSE;
        !           525:            strcpy(EPSL_font, "default");
        !           526:            EPSL_fontsize = 11;
        !           527:            term->v_char = (unsigned int) (EPSL_fontsize * EPSL_SC);
        !           528:            term->h_char = (unsigned int) (EPSL_fontsize * EPSL_SC * 5 / 10);
        !           529:            c_token++;
        !           530:        }
        !           531:     }
        !           532:
        !           533:     if (!END_OF_COMMAND) {
        !           534:        if (almost_equals(c_token, "m$onochrome")) {
        !           535:            EPSL_color = FALSE;
        !           536:            c_token++;
        !           537:        } else if (almost_equals(c_token, "c$olor")
        !           538:                   || almost_equals(c_token, "c$olour")) {
        !           539:            EPSL_color = TRUE;
        !           540:            c_token++;
        !           541:        }
        !           542:     }
        !           543:
        !           544:     if (!END_OF_COMMAND) {
        !           545:        if (almost_equals(c_token, "so$lid")) {
        !           546:            EPSL_solid = TRUE;
        !           547:            c_token++;
        !           548:        } else if (almost_equals(c_token, "da$shed")) {
        !           549:            EPSL_solid = FALSE;
        !           550:            c_token++;
        !           551:        }
        !           552:     }
        !           553:
        !           554:     if (!END_OF_COMMAND && isstring(c_token)) {
        !           555:        quote_str(EPSL_font, c_token, MAX_ID_LEN);
        !           556:        c_token++;
        !           557:     }
        !           558:
        !           559:     if (!END_OF_COMMAND) {
        !           560:        /* We have font size specified */
        !           561:        struct value a;
        !           562:        EPSL_fontsize = (int) real(const_express(&a));
        !           563:        term->v_char = (unsigned int) (EPSL_fontsize * EPSL_SC);
        !           564:        term->h_char = (unsigned int) (EPSL_fontsize * EPSL_SC * 5 / 10);
        !           565:     }
        !           566:
        !           567:     sprintf(default_font, "%s,%d", EPSL_font, EPSL_fontsize);  /* 'default_font' declared in set.c */
        !           568:
        !           569:     sprintf(term_options, "%s %s \"%s\" %d",
        !           570:            EPSL_color ? "color" : "monochrome",
        !           571:            EPSL_solid ? "solid" : "dashed",
        !           572:            EPSL_font, EPSL_fontsize);
        !           573: }
        !           574:
        !           575:
        !           576: /* the init fn for the epslatex driver */
        !           577: TERM_PUBLIC void
        !           578: EPSL_init()
        !           579: {
        !           580:     char *dotIndex=NULL;
        !           581:     char *name;
        !           582:
        !           583:     /* Why is EPSL_header global, and psi1, psi2 not? */
        !           584:
        !           585:     static char GPFAR psi1[] = "%%%%Creator: gnuplot %s patchlevel %s\n\
        !           586: %%%%CreationDate: %s";
        !           587:     static char GPFAR psi2[] = "%%%%EndComments\n\
        !           588: /Gpdict 100 dict def\n\
        !           589: Gpdict begin\n\
        !           590: /Color %s def\n\
        !           591: /Dashed %s def\n\
        !           592: /Gplinewidth %.3f def\n\
        !           593: /hpt_ %.3f def\n\
        !           594: /vpt_ %.3f def\n";
        !           595:
        !           596:     time_t now;
        !           597:
        !           598:     unsigned int xmin_t, ymin_t, xmax_t, ymax_t;
        !           599:     int i;
        !           600:     term->xmax = EPSL_XMAX;
        !           601:     term->ymax = EPSL_YMAX;
        !           602:     xmin_t = EPSL_XMAX * xoffset / (EPSL_SC);
        !           603:     xmax_t = EPSL_XMAX * (xsize + xoffset) / (EPSL_SC);
        !           604:     ymin_t = EPSL_YMAX * yoffset / (EPSL_SC);
        !           605:     ymax_t = EPSL_YMAX * (yoffset + ysize) / (EPSL_SC);
        !           606:
        !           607:     fputs("%%!PS-Adobe-3.0 EPSF-3.0\n", gpoutfile);
        !           608:     if (outstr)
        !           609:        fprintf(gpoutfile, "%%%%Title: (%s)\n", outstr);
        !           610:     time(&now);
        !           611:     fprintf(gpoutfile, psi1, gnuplot_version, gnuplot_patchlevel, asctime(localtime(&now)));
        !           612:
        !           613:     fprintf(gpoutfile, "%%%%BoundingBox: %d %d %d %d\n",
        !           614:            EPSL_XOFF + xmin_t, EPSL_XOFF + ymin_t,
        !           615:            EPSL_XOFF + xmax_t, EPSL_YOFF + ymax_t);
        !           616:
        !           617:     fprintf(gpoutfile, psi2,
        !           618:            EPSL_color ? "true" : "false",
        !           619:            EPSL_solid ? "false" : "true",
        !           620:            (double) EPSL_LW, (double) EPSL_POINTSIZE, (double) EPSL_POINTSIZE);
        !           621:
        !           622:     for (i = 0; EPSL_header[i] != NULL; i++)
        !           623:        fprintf(gpoutfile, "%s", EPSL_header[i]);
        !           624:
        !           625:     fputs("end\n%%%%EndProlog\n", gpoutfile);
        !           626:
        !           627:     EPSL_texfile = NULL;
        !           628:
        !           629:     if (outstr && (dotIndex = strrchr(outstr, '.'))) {
        !           630:        /* assume file name is ending in ".eps" */
        !           631:        if (EPSL_texfilename)
        !           632:            free(EPSL_texfilename);
        !           633:        EPSL_texfilename = gp_alloc(dotIndex - outstr + 5, "epslatex texfilename");
        !           634:        if (EPSL_texfilename) {
        !           635:            /* including . */
        !           636:            safe_strncpy(EPSL_texfilename, outstr, dotIndex - outstr + 2);
        !           637:            strcpy(EPSL_texfilename + (dotIndex - outstr) + 1, "tex");
        !           638:            if ((EPSL_texfile = fopen(EPSL_texfilename, "w")) == (FILE *) NULL) {
        !           639:                fprintf(stderr, "Cannot open tex file %s for output\n", EPSL_texfilename);
        !           640:            }
        !           641:        } else {
        !           642:            fprintf(stderr, "Cannot make LaTeX file name from %s\nTurning off LaTeX output\n", outstr);
        !           643:        }
        !           644:     }
        !           645:     if (EPSL_texfile) {
        !           646:        name = gp_alloc(dotIndex - outstr + 1, "epslatex temp filename");
        !           647:        safe_strncpy(name, outstr, dotIndex - outstr + 1);
        !           648:        name[dotIndex - outstr] = 0;
        !           649:        fprintf(EPSL_texfile, "%%GNUPLOT: LaTeX picture with Postscript\n\
        !           650: \\begin{picture}(0,0)%%\n\
        !           651: \\includegraphics{%s}%%\n\
        !           652: \\end{picture}%%\n\
        !           653: \\setlength{\\unitlength}{%.4fbp}%%\n", name, 1.0 / EPSL_SC);
        !           654:     }
        !           655: #ifdef PM3D
        !           656:     /* to optimize output for postscript terminals family */
        !           657:     postscript_gpoutfile = gpoutfile;
        !           658: #endif
        !           659: }
        !           660:
        !           661:
        !           662: TERM_PUBLIC void
        !           663: EPSL_graphics()
        !           664: {
        !           665:     static char GPFAR psg1[] = "0 setgray\nnewpath\n";
        !           666:     struct termentry *t = term;
        !           667:
        !           668:     fprintf(gpoutfile, "\
        !           669: Gpdict begin\ngsave\n\
        !           670: %d %d translate\n\
        !           671: %.4f %.4f scale\n\
        !           672: %s",
        !           673:            EPSL_XOFF, EPSL_YOFF,
        !           674:            1.0 / EPSL_SC, 1.0 / EPSL_SC,
        !           675:            psg1);
        !           676:     EPSL_pointsize(pointsize);
        !           677:     EPSL_linewidth(1.0);
        !           678:     EPSL_path_count = 0;
        !           679:     EPSL_relative_ok = FALSE;
        !           680:     EPSL_pen_x = EPSL_pen_y = -4000;
        !           681:     EPSL_taken = 0;
        !           682:     EPSL_linetype_last = -1;
        !           683:
        !           684:     if (EPSL_texfile)
        !           685:        fprintf(EPSL_texfile, "\\begin{picture}(%d,%d)(0,0)%%\n",
        !           686:                (int) (xsize * t->xmax), (int) (ysize * t->ymax));
        !           687: }
        !           688:
        !           689:
        !           690: TERM_PUBLIC void
        !           691: EPSL_text()
        !           692: {
        !           693:     EPSL_FLUSH_PATH;
        !           694:     fputs("grestore\nend\nshowpage\n%%%%EOF\n", gpoutfile);
        !           695:     if (EPSL_texfile) {
        !           696:        fputs("\\end{picture}%\n\\endinput\n", EPSL_texfile);
        !           697:     }
        !           698: }
        !           699:
        !           700: TERM_PUBLIC void
        !           701: EPSL_reset()
        !           702: {
        !           703:     if (EPSL_texfile) {
        !           704:        fclose(EPSL_texfile);
        !           705:        EPSL_texfile = NULL;
        !           706:     }
        !           707: }
        !           708:
        !           709:
        !           710: TERM_PUBLIC void
        !           711: EPSL_linetype(linetype)
        !           712: int linetype;
        !           713: {
        !           714:     EPSL_FLUSH_PATH;
        !           715:     linetype = (linetype % 4) + 2;
        !           716:     if (linetype < 0)
        !           717:        linetype = 0;
        !           718:     EPSL_relative_ok = FALSE;
        !           719: #if 0
        !           720:     if (EPSL_linetype_last == linetype)
        !           721:        return;
        !           722: #endif
        !           723:     EPSL_linetype_last = linetype;
        !           724:     fprintf(gpoutfile, "LT%c\n", "ba0123"[linetype]);
        !           725:     EPSL_path_count = 0;
        !           726: }
        !           727:
        !           728:
        !           729: TERM_PUBLIC void
        !           730: EPSL_linewidth(linewidth)
        !           731: double linewidth;
        !           732: {
        !           733:     EPSL_FLUSH_PATH;
        !           734:     fprintf(gpoutfile, "%.3f Gpsetlinewidth\n", linewidth);
        !           735: }
        !           736:
        !           737: TERM_PUBLIC void
        !           738: EPSL_pointsize(ptsize)
        !           739: double ptsize;
        !           740: {
        !           741:     fprintf(gpoutfile, "%.3f Gpsetpointsize\n", ptsize);
        !           742: }
        !           743:
        !           744: TERM_PUBLIC void
        !           745: EPSL_move(x, y)
        !           746: unsigned int x, y;
        !           747: {
        !           748:     int dx, dy;
        !           749:     /* Make this semi-dynamic and independent of architecture */
        !           750:     char abso[5 + 2 * INT_STR_LEN], rel[5 + 2 * INT_STR_LEN];
        !           751:
        !           752:     /*if (EPSL_path_count) {EPSL_FLUSH_PATH}; */
        !           753:     EPSL_FLUSH_PATH;
        !           754:     dx = x - EPSL_pen_x;
        !           755:     dy = y - EPSL_pen_y;
        !           756:     /* can't cancel all null moves--need a move after stroke'ing */
        !           757:     if (dx == 0 && dy == 0 && EPSL_relative_ok)
        !           758:        return;
        !           759:     sprintf(abso, "%d %d M\n", x, y);
        !           760:     sprintf(rel, "%d %d R\n", dx, dy);
        !           761:     if (strlen(rel) < strlen(abso) && EPSL_relative_ok) {
        !           762:        fputs(rel, gpoutfile);
        !           763:        EPSL_taken++;
        !           764:     } else
        !           765:        fputs(abso, gpoutfile);
        !           766:     EPSL_relative_ok = TRUE;
        !           767:     EPSL_path_count += 1;
        !           768:
        !           769:     EPSL_pen_x = x;
        !           770:     EPSL_pen_y = y;
        !           771: }
        !           772:
        !           773: TERM_PUBLIC void
        !           774: EPSL_vector(x, y)
        !           775: unsigned int x, y;
        !           776: {
        !           777:     int dx, dy;
        !           778:     char abso[5 + 2 * INT_STR_LEN], rel[5 + 2 * INT_STR_LEN];
        !           779:
        !           780:     dx = x - EPSL_pen_x;
        !           781:     dy = y - EPSL_pen_y;
        !           782:     if (dx == 0 && dy == 0)
        !           783:        return;
        !           784:     sprintf(abso, "%d %d L\n", x, y);
        !           785:     sprintf(rel, "%d %d V\n", dx, dy);
        !           786:     if (strlen(rel) < strlen(abso) && EPSL_relative_ok) {
        !           787:        fputs(rel, gpoutfile);
        !           788:        EPSL_taken++;
        !           789:     } else
        !           790:        fputs(abso, gpoutfile);
        !           791:     EPSL_relative_ok = TRUE;
        !           792:     EPSL_path_count += 1;
        !           793:     EPSL_pen_x = x;
        !           794:     EPSL_pen_y = y;
        !           795:     /* if (ps_path_count >= 400) {
        !           796:        fprintf(gpoutfile,"currentpoint stroke M\n");
        !           797:        ps_path_count = 0;
        !           798:        }
        !           799:      */
        !           800: }
        !           801:
        !           802: TERM_PUBLIC void
        !           803: EPSL_arrow(xstart, ystart, xend, yend, head)
        !           804: unsigned int xstart, ystart, xend, yend;
        !           805: TBOOLEAN head;
        !           806: {
        !           807:     fprintf(gpoutfile, "%d %d M\n%d %d %s\n", xstart, ystart, xend, yend, head ? "Arrow" : "L Gpstroke");
        !           808: }
        !           809:
        !           810: TERM_PUBLIC void
        !           811: EPSL_put_text(x, y, str)
        !           812:     unsigned int x, y;
        !           813:     char *str;
        !           814: {
        !           815:     if (EPSL_texfile) {
        !           816:        fprintf(EPSL_texfile, "\\put(%d,%d){", x, y);
        !           817:        if (EPSL_ang) {
        !           818:            fputs("\\rotatebox{90}{", EPSL_texfile);
        !           819:        }
        !           820:        if (((str[0] == '{') || (str[0] == '['))) {
        !           821:            fprintf(EPSL_texfile, "\\makebox(0,0)%s", str);
        !           822:        } else
        !           823:            switch (EPSL_justify) {
        !           824:            case LEFT:
        !           825:                fprintf(EPSL_texfile, "\\makebox(0,0)[l]{\\strut{}%s}", str);
        !           826:                break;
        !           827:            case CENTRE:
        !           828:                fprintf(EPSL_texfile, "\\makebox(0,0){\\strut{}%s}", str);
        !           829:                break;
        !           830:            case RIGHT:
        !           831:                fprintf(EPSL_texfile, "\\makebox(0,0)[r]{\\strut{}%s}", str);
        !           832:                break;
        !           833:            }
        !           834:        if (EPSL_ang) {
        !           835:            fputs("}", EPSL_texfile);
        !           836:        }
        !           837:        fputs("}%\n", EPSL_texfile);
        !           838:     }
        !           839: }
        !           840:
        !           841:
        !           842: TERM_PUBLIC int
        !           843: EPSL_text_angle(ang)
        !           844: int ang;
        !           845: {
        !           846:     EPSL_ang = ang;
        !           847:     return TRUE;
        !           848: }
        !           849:
        !           850:
        !           851: TERM_PUBLIC int
        !           852: EPSL_justify_text(mode)
        !           853: enum JUSTIFY mode;
        !           854: {
        !           855:     EPSL_justify = mode;
        !           856:     return TRUE;
        !           857: }
        !           858:
        !           859:
        !           860: TERM_PUBLIC int
        !           861: EPSL_set_font(font)            /* Entry font added by DJL */
        !           862: char *font;
        !           863: {
        !           864:     char name[32];
        !           865:     int size, sep;
        !           866:
        !           867:     sep = strcspn(font, ",");
        !           868:     strncpy(name, font, sep);
        !           869:     name[sep] = 0;
        !           870:     size = EPSL_fontsize;
        !           871:     sscanf(&(font[sep + 1]), "%d", &size);
        !           872:     return TRUE;
        !           873: }
        !           874:
        !           875: TERM_PUBLIC void
        !           876: EPSL_point(x, y, number)
        !           877: unsigned int x, y;
        !           878: int number;
        !           879: {
        !           880:     static char GPFAR *GPFAR pointFNS[] = { "Pnt", "Dia", "Crc", "Crs", "CrX", "Box", "DaF", "CcF", "BxF" };
        !           881:
        !           882:     EPSL_FLUSH_PATH;
        !           883:     if (number < 0)
        !           884:        number = -1;            /* negative types are all 'dot' */
        !           885:     else
        !           886:        number %= sizeof(pointFNS) / sizeof(pointFNS[0]) - 1;
        !           887:     fprintf(gpoutfile, "%d %d %s\n", x, y, pointFNS[number + 1]);
        !           888:
        !           889:     EPSL_relative_ok = 0;
        !           890:     EPSL_path_count = 0;
        !           891:     EPSL_linetype_last = -1;   /* force next linetype change */
        !           892: }
        !           893:
        !           894: TERM_PUBLIC void
        !           895: EPSL_fillbox(style, x1, y1, x2, y2)
        !           896: int style;
        !           897: unsigned int x1, y1, x2, y2;
        !           898: {
        !           899:     /* ULIG: the style parameter is now used for the fillboxes style
        !           900:     * (not implemented here), see the documentation */
        !           901:     EPSL_FLUSH_PATH fprintf(gpoutfile, "%d %d %d %d BoxFill\n", x1, y1, x2, y2);
        !           902:
        !           903:     EPSL_relative_ok = 0;
        !           904:     EPSL_linetype_last = -1;
        !           905: }
        !           906:
        !           907: #ifdef PM3D
        !           908:
        !           909: TERM_PUBLIC void
        !           910: EPSL_filled_polygon(points, corners)
        !           911:     int points;
        !           912:     gpiPoint *corners;
        !           913: {
        !           914:     PS_filled_polygon(points, corners);
        !           915:     EPSL_relative_ok = FALSE;
        !           916: }
        !           917:
        !           918: #endif /* PM3D */
        !           919:
        !           920: #endif /* TERM_BODY */
        !           921:
        !           922: #ifdef TERM_TABLE
        !           923:
        !           924: TERM_TABLE_START(epslatex_driver)
        !           925: "epslatex",
        !           926: "LaTeX (Text) and encapsulated PostScript",
        !           927: EPSL_XMAX, EPSL_YMAX, EPSL_VCHAR, EPSL_HCHAR,
        !           928: EPSL_VTIC, EPSL_HTIC, EPSL_options, EPSL_init, EPSL_reset,
        !           929: EPSL_text, null_scale, EPSL_graphics, EPSL_move, EPSL_vector,
        !           930: EPSL_linetype, EPSL_put_text, EPSL_text_angle,
        !           931: EPSL_justify_text, EPSL_point, EPSL_arrow, EPSL_set_font, EPSL_pointsize,
        !           932: 0 /*flags */ , 0 /*suspend */ , 0 /*resume */ , EPSL_fillbox, EPSL_linewidth
        !           933: #ifdef PM3D
        !           934: #ifdef USE_MOUSE
        !           935: , 0, 0, 0, 0, 0 /* no mouse support for epslatex */
        !           936: #endif
        !           937: , PS_make_palette,
        !           938: PS_previous_palette,
        !           939: PS_set_color,
        !           940: EPSL_filled_polygon
        !           941: #endif
        !           942: TERM_TABLE_END(epslatex_driver)
        !           943:
        !           944: #undef LAST_TERM
        !           945: #define LAST_TERM epslatex_driver
        !           946: #endif /* TERM_TABLE */
        !           947: #endif /* TERM_PROTO_ONLY */
        !           948:
        !           949: #ifdef TERM_HELP
        !           950: START_HELP(post)
        !           951: "1 epslatex",
        !           952: "?commands set terminal epslatex",
        !           953: "?set terminal epslatex",
        !           954: "?set term epslatex",
        !           955: "?terminal epslatex",
        !           956: "?term epslatex",
        !           957: "?epslatex",
        !           958: " Two options may be set in the `epslatex` driver.",
        !           959: "",
        !           960: " Syntax:",
        !           961: "       set terminal epslatex {default}",
        !           962: "                               {color | monochrome} {solid | dashed}",
        !           963: "                               {\"<fontname>\"} {<fontsize>}",
        !           964: "",
        !           965: " `default` mode sets all options to their defaults: `monochrome`, `dashed`,",
        !           966: " \"default\" and 11pt.",
        !           967: "  Default size of a plot is 5 inches wide and 3 inches high.",
        !           968: "",
        !           969: " `solid` draws all plots with solid lines, overriding any dashed patterns;",
        !           970: " `\"<fontname>\"` is the name of font; and `<fontsize>` is",
        !           971: " the size of the font in PostScript points. Font selection isn't supported yet.",
        !           972: " Font size selection is supported only for the calculation of proper spacing.",
        !           973: " The actual LaTeX font at the point of inclusion is taken, so use LaTeX commands",
        !           974: " for changing fonts. If you use e.g. 12pt as font size for your LaTeX documents, ",
        !           975: " use '\"default\" 12' as options.",
        !           976: "",
        !           977: " All drivers for LaTeX offer a special way of controlling text positioning:",
        !           978: " If any text string begins with '{', you also need to include a '}' at the",
        !           979: " end of the text, and the whole text will be centered both horizontally",
        !           980: " and vertically by LaTeX. --- If the text string begins with '[', you need",
        !           981: " to continue it with: a position specification (up to two out of t,b,l,r),",
        !           982: " ']{', the text itself, and finally, '}'. The text itself may be anything",
        !           983: " LaTeX can typeset as an LR-box. \\rule{}{}'s may help for best positioning.",
        !           984: " See also the documenation of the pslatex terminal driver.",
        !           985: " To create multiline labels, use \\shortstack, example",
        !           986: "    set ylabel '[r]{\\shortstack{first line \\\\ second line}}' ",
        !           987: "",
        !           988: " The driver produces two different files, one for the LaTeX part and one for",
        !           989: " the eps part of the figure. ",
        !           990: " The name of the LaTeX file is derived from the name of",
        !           991: " the eps file given on the `set output` command; it is determined by replacing",
        !           992: " the trailing `.eps` (actually just the final extent in the file name---and",
        !           993: " the option will be turned off if there is no extent) with `.tex` in the output",
        !           994: " file name.  Remember to close the file before leaving `gnuplot`.",
        !           995: " There is no LaTeX output if no output file is given!",
        !           996: " In your LaTeX documents use '\\input{filename}' for inclusion of the figure.",
        !           997: " Include \\usepackage{graphics} in the preambel!",
        !           998: " Via 'epstopdf' (contained e.g. in the teTeX package, requires ghostscript)",
        !           999: " pdf files can made out of the eps files. If the graphics package is properly",
        !          1000: " configured, the LaTeX files can also be processed by pdflatex without",
        !          1001: " changes, and the pdf files are included instead of the eps files"
        !          1002: END_HELP(post)
        !          1003: #endif

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>