home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume24 / gnuplot3 / part17 < prev    next >
Text File  |  1991-10-27  |  49KB  |  1,741 lines

  1. Newsgroups: comp.sources.misc
  2. From: gershon%gr@cs.utah.edu (Elber Gershon)
  3. Subject:  v24i039:  gnuplot3 - interactive function plotting utility, Part17/26
  4. Message-ID: <1991Oct28.002324.12536@sparky.imd.sterling.com>
  5. X-Md4-Signature: 2e7b599a6d9e532057d6defc66706ba1
  6. Date: Mon, 28 Oct 1991 00:23:24 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: gershon%gr@cs.utah.edu (Elber Gershon)
  10. Posting-number: Volume 24, Issue 39
  11. Archive-name: gnuplot3/part17
  12. Environment: UNIX, MS-DOS, VMS
  13. Supersedes: gnuplot2: Volume 11, Issue 65-79
  14.  
  15. #!/bin/sh
  16. # this is Part.17 (part 17 of a multipart archive)
  17. # do not concatenate these parts, unpack them in order with /bin/sh
  18. # file gnuplot/term/iris4d.trm continued
  19. #
  20. if test ! -r _shar_seq_.tmp; then
  21.     echo 'Please unpack part 1 first!'
  22.     exit 1
  23. fi
  24. (read Scheck
  25.  if test "$Scheck" != 17; then
  26.     echo Please unpack part "$Scheck" next!
  27.     exit 1
  28.  else
  29.     exit 0
  30.  fi
  31. ) < _shar_seq_.tmp || exit 1
  32. if test ! -f _shar_wnt_.tmp; then
  33.     echo 'x - still skipping gnuplot/term/iris4d.trm'
  34. else
  35. echo 'x - continuing file gnuplot/term/iris4d.trm'
  36. sed 's/^X//' << 'SHAR_EOF' >> 'gnuplot/term/iris4d.trm' &&
  37. X  
  38. X  return;
  39. }
  40. X
  41. IRIS4D_text()
  42. {
  43. X  return; /* enter text from another window!!! */
  44. }
  45. X
  46. IRIS4D_linetype(linetype)
  47. int linetype;
  48. {
  49. X  static int pen_color_24[11] =
  50. X    {
  51. X      IRIS4D_BLACK,        /* reserved for border and numbers */
  52. X      IRIS4D_MAGENTA,        /* reserved for axis traces */
  53. X      IRIS4D_LIGHTCYAN,
  54. X      IRIS4D_RED,
  55. X      IRIS4D_GREEN,
  56. X      IRIS4D_LIGHTMAGENTA,
  57. X      IRIS4D_YELLOW,
  58. X      IRIS4D_LIGHTRED,
  59. X      IRIS4D_LIGHTGREEN,
  60. X      IRIS4D_CYAN,
  61. X      IRIS4D_BROWN,
  62. X    };
  63. X  static int pen_color[8] = {0 ,1, 4, 5, 6, 1, 2, 4};
  64. X
  65. X  if (iris24bits)
  66. X  {
  67. X    int pencolor = pen_color_24[linetype < 0 ? linetype + 2 : linetype % 9 + 2];
  68. X
  69. X    RGBcolor(colors24bits[pencolor][0],
  70. X         colors24bits[pencolor][1],
  71. X         colors24bits[pencolor][2]);
  72. X    /* Make all lines solid (linestyle 0) upto to the ninth. If more than
  73. X     * 9 colors are needed, start to use the different line styles (1 to 8).
  74. X     */
  75. X    setlinestyle(linetype < 9 ? 0 : (linetype + 2) % 8 + 1);
  76. X  }
  77. X  else
  78. X  {
  79. X    linetype = linetype % 8;
  80. X    color((Colorindex) pen_color[linetype]);
  81. X    setlinestyle(linetype);
  82. X  }
  83. X  return;
  84. }
  85. X
  86. IRIS4D_move(x, y)
  87. unsigned int x, y;
  88. {
  89. X  move2i(x, y);
  90. X  return;
  91. }
  92. X
  93. IRIS4D_cmove(x, y)
  94. unsigned int x, y;
  95. {
  96. X  cmov2i(x, y);
  97. X  return;
  98. }
  99. X
  100. IRIS4D_vector(x, y)
  101. unsigned x, y;
  102. {
  103. X  draw2i(x, y);
  104. X  return;
  105. }
  106. X
  107. X
  108. IRIS4D_put_text(x,y,str)
  109. int x, y;
  110. char *str;
  111. {
  112. X  IRIS4D_cmove(x,y - IRIS4D_VCHAR/2);
  113. X  charstr(str);
  114. X  return;
  115. }
  116. X
  117. X
  118. IRIS4D_reset()
  119. {
  120. X  return;
  121. }
  122. X
  123. SHAR_EOF
  124. echo 'File gnuplot/term/iris4d.trm is complete' &&
  125. chmod 0644 gnuplot/term/iris4d.trm ||
  126. echo 'restore of gnuplot/term/iris4d.trm failed'
  127. Wc_c="`wc -c < 'gnuplot/term/iris4d.trm'`"
  128. test 5305 -eq "$Wc_c" ||
  129.     echo 'gnuplot/term/iris4d.trm: original size 5305, current size' "$Wc_c"
  130. rm -f _shar_wnt_.tmp
  131. fi
  132. # ============= gnuplot/term/kyo.trm ==============
  133. if test -f 'gnuplot/term/kyo.trm' -a X"$1" != X"-c"; then
  134.     echo 'x - skipping gnuplot/term/kyo.trm (File already exists)'
  135.     rm -f _shar_wnt_.tmp
  136. else
  137. > _shar_wnt_.tmp
  138. echo 'x - extracting gnuplot/term/kyo.trm (Text)'
  139. sed 's/^X//' << 'SHAR_EOF' > 'gnuplot/term/kyo.trm' &&
  140. /* Prescribe (KYOCERA) driver - Michael Waldor */
  141. /* Modified for gnuplot 2.0 sk@sun4 24-Apr-1990 13:23 */
  142. #ifdef PRESCRIBE
  143. X
  144. #define PRE_XMAX 2567
  145. #define PRE_YMAX 1815    /* X:Y = sqrt(2) */
  146. X
  147. #define PRE_XLAST (PRE_XMAX - 1)
  148. #define PRE_YLAST (PRE_YMAX - 1)
  149. X
  150. #define PRE_VCHAR (PRE_YMAX/30)
  151. #define PRE_HCHAR 33    /* about 9 chars per inch */
  152. #define PRE_HTIC (PRE_XMAX/80)
  153. #define PRE_VTIC PRE_HTIC
  154. X
  155. /* for Courier font: */
  156. #define KYO_VCHAR (14*(300/72))    /* 12 pt + 2 pt baselineskip */
  157. #define KYO_HCHAR (300/10)    /*  10 chars per inch */
  158. X
  159. enum JUSTIFY pre_justify=LEFT;    /* text is flush left */
  160. X
  161. PRE_init()
  162. {
  163. X  (void) fprintf(outfile,"!R! RES;\n") ;
  164. X  /* UNIT: units are dots, 300 dots = 1 in = 72 pt */
  165. X  /* SPO: landscape format */
  166. X  /* STM, SLM set top, left margin*/
  167. X  /* Font: bold Helvetica (proportional font) */
  168. X  (void) fprintf(outfile,"PAGE; UNIT D; SPO L; STM 280; SLM 440;\n") ;
  169. X  (void) fprintf(outfile,"FTMD 15; FONT 29; SCPI 9;\n") ;
  170. }
  171. X
  172. KYO_init()
  173. {
  174. X  (void) fprintf(outfile,"!R! RES;\n") ;
  175. X  /* UNIT: units are dots, 300 dots = 1 in = 72 pt */
  176. X  /* SPO: landscape format */
  177. X  /* STM, SLM set top, left margin */
  178. X  /* Font: Courier (fixed width font) */
  179. X  (void) fprintf(outfile,"PAGE; UNIT D; SPO L; STM 280; SLM 440;\n") ;
  180. X  (void) fprintf(outfile,"FTMD 15; FONT 17; SCPI 10;\n") ;
  181. }
  182. X
  183. PRE_graphics()
  184. {
  185. }
  186. X
  187. PRE_text()            /* eject page after each plot */
  188. {
  189. X  (void) fprintf(outfile,"PAGE;\n") ; 
  190. }
  191. X
  192. PRE_linetype(linetype)
  193. int linetype ;
  194. {
  195. X  /* actually choose pendiameter */
  196. X  if (linetype < 0) linetype = -linetype;
  197. X  else linetype = 3;
  198. X  (void) fprintf(outfile,"SPD %d;\n", linetype) ;
  199. }
  200. PRE_move(x,y)
  201. unsigned int x,y ;
  202. {
  203. X  (void) fprintf(outfile,"MAP %1d,%1d;\n",x,PRE_YMAX-y) ;
  204. }
  205. PRE_vector(x,y)
  206. unsigned int x,y ;
  207. {
  208. X  (void) fprintf(outfile,"DAP %1d, %1d;\n",x,PRE_YMAX-y) ;
  209. }
  210. PRE_put_text(x, y, str)
  211. unsigned int x,y ;
  212. char *str;
  213. {
  214. X  PRE_move(x,y);
  215. X  switch(pre_justify){
  216. X  case RIGHT:
  217. X    (void) fprintf(outfile,"RTXT \"%s\", B;\n",str) ;
  218. X    break;
  219. X  default:
  220. X    (void) fprintf(outfile,"TEXT \"%s\", B;\n",str) ;
  221. X  }
  222. }
  223. int PRE_justify_text(mode)
  224. enum JUSTIFY mode;
  225. {
  226. X  pre_justify=mode;
  227. X  switch(pre_justify){
  228. X  case LEFT:
  229. X  case RIGHT:
  230. X    return(TRUE);
  231. X  default:
  232. X    return(FALSE);
  233. X  }
  234. X  
  235. }
  236. X
  237. PRE_reset()
  238. {
  239. X  (void) fprintf(outfile,"PAGE; RES; EXIT;\n");
  240. }
  241. X
  242. #endif /* PRESCRIBE */
  243. SHAR_EOF
  244. chmod 0666 gnuplot/term/kyo.trm ||
  245. echo 'restore of gnuplot/term/kyo.trm failed'
  246. Wc_c="`wc -c < 'gnuplot/term/kyo.trm'`"
  247. test 2313 -eq "$Wc_c" ||
  248.     echo 'gnuplot/term/kyo.trm: original size 2313, current size' "$Wc_c"
  249. rm -f _shar_wnt_.tmp
  250. fi
  251. # ============= gnuplot/term/latex.trm ==============
  252. if test -f 'gnuplot/term/latex.trm' -a X"$1" != X"-c"; then
  253.     echo 'x - skipping gnuplot/term/latex.trm (File already exists)'
  254.     rm -f _shar_wnt_.tmp
  255. else
  256. > _shar_wnt_.tmp
  257. echo 'x - extracting gnuplot/term/latex.trm (Text)'
  258. sed 's/^X//' << 'SHAR_EOF' > 'gnuplot/term/latex.trm' &&
  259. /* GNUPLOT - latex.trm */
  260. /*
  261. X * Copyright (C) 1990   
  262. X *
  263. X * Permission to use, copy, and distribute this software and its
  264. X * documentation for any purpose with or without fee is hereby granted, 
  265. X * provided that the above copyright notice appear in all copies and 
  266. X * that both that copyright notice and this permission notice appear 
  267. X * in supporting documentation.
  268. X *
  269. X * Permission to modify the software is granted, but not the right to
  270. X * distribute the modified code.  Modifications are to be distributed 
  271. X * as patches to released version.
  272. X *  
  273. X * This software  is provided "as is" without express or implied warranty.
  274. X * 
  275. X * This file is included by ../term.c.
  276. X *
  277. X * This terminal driver supports:
  278. X *   LaTeX pictures (latex).
  279. X *   LaTeX pictures with emTeX specials (emtex). 
  280. X *
  281. X * AUTHORS
  282. X *   David Kotz, Russell Lang
  283. X *
  284. X * send your comments or suggestions to (pixar!info-gnuplot@sun.com).
  285. X * 
  286. X */
  287. X
  288. /* modified to optimize use of \rule for long lines */
  289. X
  290. /* the following LATEX driver has been modified by 
  291. X   Russell Lang, eln272v@monu1.cc.monash.oz from the
  292. X   GnuTeX 1.3 driver by David Kotz, David.Kotz@Dartmouth.edu.
  293. X   Since then it has been further extended by David Kotz.
  294. X   EmTeX driver by Russell Lang. */
  295. X
  296. X
  297. #define LATEX_PTS_PER_INCH (72.27)
  298. #define DOTS_PER_INCH (300)    /* resolution of printer we expect to use */
  299. #define LATEX_UNIT (LATEX_PTS_PER_INCH/DOTS_PER_INCH) /* dot size in pt */
  300. X
  301. /* 5 inches wide by 3 inches high (default) */
  302. #define LATEX_XMAX (5*DOTS_PER_INCH)  /* (LATEX_PTS_PER_INCH/LATEX_UNIT*5.0) */
  303. #define LATEX_YMAX (3*DOTS_PER_INCH)  /* (LATEX_PTS_PER_INCH/LATEX_UNIT*3.0) */
  304. X
  305. #define LATEX_HTIC (5*DOTS_PER_INCH/72)        /* (5./LATEX_UNIT) */
  306. #define LATEX_VTIC (5*DOTS_PER_INCH/72)        /* (5./LATEX_UNIT) */
  307. #define LATEX_HCHAR (DOTS_PER_INCH*53/10/72)    /* (5.3/LATEX_UNIT) */
  308. #define LATEX_VCHAR (DOTS_PER_INCH*11/72)    /* (11./LATEX_UNIT) */
  309. X
  310. static int LATEX_posx;
  311. static int LATEX_posy;
  312. static enum JUSTIFY latex_justify=LEFT;
  313. static int latex_angle=0;
  314. X
  315. /* Default line-drawing character */
  316. /* the definition of plotpoint varies with linetype */
  317. #define LATEX_DOT "\\usebox{\\plotpoint}"
  318. #define LATEX_TINY_DOT "\\rule{.1pt}{.1pt}" /* for dots plot style */
  319. X
  320. /* POINTS */
  321. #define LATEX_POINT_TYPES 12    /* we supply more point types */
  322. static char *LATEX_points[] = {
  323. X    "\\raisebox{-1.2pt}{\\makebox(0,0){$\\Diamond$}}",
  324. X    "\\makebox(0,0){$+$}",
  325. X    "\\raisebox{-1.2pt}{\\makebox(0,0){$\\Box$}}",
  326. X    "\\makebox(0,0){$\\times$}",
  327. X    "\\makebox(0,0){$\\triangle$}",
  328. X    "\\makebox(0,0){$\\star$}",
  329. X    "\\circle{12}", "\\circle{18}", "\\circle{24}",
  330. X    "\\circle*{12}", "\\circle*{18}", "\\circle*{24}"
  331. };
  332. X
  333. /* LINES */
  334. static float LATEX_size = 0;    /* current thick of line in points */
  335. static float LATEX_dotspace = 0; /* current dotspace of line in points */
  336. #define LATEX_LINE_TYPES 6    /* number of line types below */
  337. #define LATEX_THIN_LINE 0    /* the thinnest solid line type */
  338. static struct {
  339. X    float size;            /* size of dot, or thick of line in points */
  340. X    float dotspace;            /* inter-dot space in points; 0 for lines */
  341. } LATEX_lines[] = {
  342. X    {.35, 0.0},                /* thin solid line */
  343. X    {.7, 0.0},                /* thick solid line */
  344. X    {1.0, 0.0},                /* Thick solid line */
  345. X    {.5, 5.0},                /* dotted line */
  346. X    {.5, 9.0},                /* widely dotted line */
  347. X    {.5, 13.0}                /* really widely dotted line */
  348. };
  349. /* for drawing dotted and solid lines */
  350. static void LATEX_dot_line();
  351. static void LATEX_solid_line();
  352. static void LATEX_rule();
  353. static void LATEX_flushdot();
  354. #define LATEX_flushrule() LATEX_rule(2, 0.,0.,0.,0.) /* flush old rule */
  355. static BOOLEAN LATEX_moved = TRUE;    /* pen is up after move */
  356. static float LATEX_dotsize;    /* size of LATEX_DOT in units */
  357. static BOOLEAN LATEX_needsdot = FALSE;/* does dotted line need termination? */
  358. X
  359. #ifdef EMTEX
  360. BOOLEAN emtex=FALSE; /* not currently using emtex */
  361. static void EMTEX_solid_line();
  362. #endif
  363. X
  364. /* ARROWS */
  365. /* the set of non-vertical/non-horizontal LaTeX vector slopes */
  366. /* except negatives - they are handled specially */
  367. static struct vslope {
  368. X    int dx, dy;
  369. } LATEX_slopes[] = {
  370. X    {1,1}, {1,2}, {1,3}, {1,4},
  371. X    {2,1}, {2,3},
  372. X    {3,1}, {3,2}, {3,4},
  373. X    {4,1}, {4,3},
  374. X    {0,0}                    /* terminator */
  375. };
  376. static void best_latex_arrow(); /* figure out the best arrow */
  377. X
  378. LATEX_init()
  379. {
  380. #ifdef EMTEX
  381. X    emtex = FALSE;
  382. #endif
  383. X    LATEX_posx = LATEX_posy = 0;
  384. X    fprintf(outfile, "%% GNUPLOT: LaTeX picture\n");
  385. X    fprintf(outfile, "\\setlength{\\unitlength}{%fpt}\n", LATEX_UNIT);
  386. X    fprintf(outfile, 
  387. X          "\\ifx\\plotpoint\\undefined\\newsavebox{\\plotpoint}\\fi\n");
  388. X    LATEX_linetype(-1);
  389. }
  390. X
  391. X
  392. LATEX_scale(xs, ys)
  393. X    double xs, ys;            /* scaling factors */
  394. {
  395. X    register struct termentry *t = &term_tbl[term];
  396. X
  397. X    /* we change the table for use in graphics.c and LATEX_graphics */
  398. X    t->xmax = (unsigned int)(LATEX_XMAX * xs);
  399. X    t->ymax = (unsigned int)(LATEX_YMAX * ys);
  400. X
  401. X    return(TRUE);
  402. }
  403. X
  404. LATEX_graphics()
  405. {
  406. X    register struct termentry *t = &term_tbl[term];
  407. X
  408. X    fprintf(outfile, "\\begin{picture}(%d,%d)(0,0)\n", t->xmax, t->ymax);
  409. X    fprintf(outfile, "\\tenrm\n");
  410. }
  411. X
  412. X
  413. LATEX_text()
  414. {
  415. X    LATEX_flushrule();
  416. X    LATEX_flushdot();
  417. X    fprintf(outfile, "\\end{picture}\n");
  418. X    LATEX_posx = LATEX_posy = 0; /* current position */
  419. X    LATEX_moved = TRUE;    /* pen is up after move */
  420. }
  421. X
  422. LATEX_linetype(linetype)
  423. X    int linetype;
  424. {
  425. X    float size;
  426. X
  427. X    if (linetype >= LATEX_LINE_TYPES)
  428. X     linetype %= LATEX_LINE_TYPES;
  429. X
  430. #ifdef EMTEX
  431. X    if (!emtex)
  432. #endif
  433. X    LATEX_flushrule();
  434. X    LATEX_flushdot();
  435. X
  436. X    /* Find the new desired line thickness. */
  437. X    /* negative linetypes (for axes) use a thin line */
  438. X    /* only relevant for drawing axes/border in 3d */
  439. X    size = (linetype >= 0 ? LATEX_lines[linetype].size 
  440. X          : LATEX_lines[LATEX_THIN_LINE].size);
  441. X
  442. X    /* If different from current size, redefine \plotpoint */
  443. X    if (size != LATEX_size) {
  444. X       fprintf(outfile, 
  445. X             "\\sbox{\\plotpoint}{\\rule[%.3fpt]{%.3fpt}{%.3fpt}}%%\n",
  446. X             -size/2, size, size);
  447. #ifdef EMTEX
  448. X        if (emtex)         /* change line width */
  449. X        fprintf(outfile, "\\special{em:linewidth %.1fpt}%%\n", size);
  450. #endif
  451. X    }
  452. X    
  453. X    LATEX_size = size;
  454. X    LATEX_dotsize = size / LATEX_UNIT;
  455. X    LATEX_dotspace = (linetype >= 0) ? LATEX_lines[linetype].dotspace : 0;
  456. X    LATEX_moved = TRUE;            /* reset */
  457. }
  458. X
  459. LATEX_move(x,y)
  460. X    unsigned int x,y;
  461. {
  462. X    LATEX_flushdot();
  463. X
  464. X    LATEX_posx = x;
  465. X    LATEX_posy = y;
  466. X    LATEX_moved = TRUE;            /* reset */
  467. }
  468. X
  469. X
  470. LATEX_point(x,y, number)        /* version of line_and_point */
  471. X    unsigned int x,y;
  472. X    int number;                /* type of point */
  473. {
  474. X    LATEX_move(x,y);
  475. X    
  476. X    /* Print the character defined by 'number'; number < 0 means 
  477. X      to use a dot, otherwise one of the defined points. */
  478. X    fprintf(outfile, "\\put(%d,%d){%s}\n", x, y, 
  479. X          (number < 0 ? LATEX_TINY_DOT
  480. X           : LATEX_points[number % LATEX_POINT_TYPES]));
  481. }
  482. X
  483. X
  484. LATEX_vector(ux,uy)
  485. X    unsigned int ux,uy;
  486. {
  487. X    if (LATEX_dotspace == 0.0) {
  488. X       /* solid line */
  489. #ifdef EMTEX
  490. X       if (emtex)
  491. X        EMTEX_solid_line(LATEX_posx, (int)ux, LATEX_posy, (int)uy);
  492. X       else
  493. #endif
  494. X        LATEX_solid_line(LATEX_posx, (int)ux, LATEX_posy, (int)uy);
  495. X    } else
  496. X     /* dotted line */
  497. X     LATEX_dot_line(LATEX_posx, (int)ux, LATEX_posy, (int)uy);
  498. X
  499. X    LATEX_posx = ux;
  500. X    LATEX_posy = uy;
  501. }
  502. X
  503. static void
  504. LATEX_solid_line(x1,x2, y1,y2)
  505. X    int x1,x2, y1,y2;
  506. {
  507. X    float slope;
  508. X    int inc;
  509. X    float next;
  510. X    float x,y;
  511. X    int code;                /* possibly combine with previous rule */
  512. X
  513. X    /* we draw a solid line using the current line thickness (size) */
  514. X    /* we do it with lots of \\rules */
  515. X
  516. X    if (x1 == x2 && y1 == y2) { /* zero-length line - just a dot */
  517. X       if (LATEX_moved) {
  518. X          LATEX_flushrule();
  519. X          /* plot a dot */
  520. X          fprintf(outfile, "\\put(%u,%u){%s}\n", x1, y1, LATEX_DOT);
  521. X       }
  522. X    } else {
  523. X       code = (LATEX_moved ? 0 : 1); /* no combine after move */
  524. X       if (x1 == x2)        /* vertical line - special case */
  525. X        LATEX_rule(code, (double)x1, (double)y1,
  526. X               LATEX_dotsize, (double)y2-y1);
  527. X       else if (y1 == y2)    /* horizontal line - special case */
  528. X        LATEX_rule(code, (double)x1, (double)y1, (double)x2-x1,
  529. X               LATEX_dotsize);
  530. X       else {
  531. X          slope = ((float)y2-y1)/((float)x2-x1);
  532. X          if (abs(slope) <= 1.0) {
  533. X             /* longer than high */
  534. X             inc = sign(y2-y1);
  535. X             for (x = x1, y = y1; (y2-y)*inc >= 0; y += inc) {
  536. X                next = inc/slope + x;
  537. X                if ((x2>x1 && next > x2) || (x2<x1 && next < x2)) {
  538. X                    LATEX_rule(code, x,y, x2-x, LATEX_dotsize);
  539. X                    break;
  540. X                } else {
  541. X                    LATEX_rule(code, x,y, next-x, LATEX_dotsize);
  542. X                    x = next;
  543. X                }
  544. X                code = 0;
  545. X             }
  546. X          } else {
  547. X             /* higher than long */
  548. X             inc = sign(x2-x1);
  549. X             for (x = x1, y = y1; (x2-x)*inc >= 0; x += inc) {
  550. X                next = inc*slope + y;
  551. X                if ((y2>y1 && next > y2) || (y2<y1 && next < y2)) {
  552. X                    LATEX_rule(code, x,y, LATEX_dotsize, y2-y);
  553. X                    break;
  554. X                } else {
  555. X                    LATEX_rule(code, x,y, LATEX_dotsize, next-y);
  556. X                    y = next;
  557. X                }
  558. X                code = 0;
  559. X             }
  560. X          }
  561. X       }
  562. X    }
  563. X    LATEX_moved = FALSE;
  564. }
  565. X
  566. /* Draw a \rule. Width or height may be negative; we can correct.
  567. X * The rule is never output immediately. The previous rule is output
  568. X * as-is if code is 0, and the previous rule is
  569. X * combined with the current rule (if possible) if code is 1.
  570. X * The previous rule is output, and the new one ignored, if code is 2.
  571. X */
  572. static void
  573. LATEX_rule(code, x,y, width, height)
  574. X    int code;                /* how do we treat this rule? */
  575. X    double x, y;
  576. X    double width;
  577. X    double height;
  578. {  
  579. X    static float lastx, lasty;
  580. X    static float lastw, lasth;
  581. X    static BOOLEAN valid = FALSE; /* is 'last' data valid? */
  582. X    BOOLEAN combine = (code == 1);
  583. X    BOOLEAN flush = (code == 2);
  584. X
  585. X    if (!flush)
  586. X     if (width == 0 || height == 0)
  587. X       return;            /* ignore this rule */
  588. X
  589. X    if (valid && combine) {
  590. X       /* try to combine new rule with old rule */
  591. X       if ((int)lastx == (int)x && lastw == width) { /* vertical rule */
  592. X          if (lasth * height >= 0) { /* same sign */
  593. X             lasth += height;
  594. X             return;
  595. X          }
  596. X       } else if ((int)lasty == (int)y && lasth == height){ /* horiz rule */
  597. X          if (lastw * width >= 0) { /* same sign */
  598. X             lastw += width;
  599. X             return;
  600. X          }
  601. X       }
  602. X       /* oh well, output last and remember the new one */
  603. X    }
  604. X
  605. X    if (valid) {
  606. X       /* output the rule */
  607. X       if (lastw < 0) {
  608. X          lastx += lastw;
  609. X          lastw = -lastw;
  610. X       }
  611. X       if (lasth < 0) {
  612. X          lasty += lasth;
  613. X          lasth = -lasth;
  614. X       }
  615. X
  616. X       /* if very small use canned dot */
  617. X       if (lastw < LATEX_dotsize || lasth < LATEX_dotsize)
  618. X        fprintf(outfile, "\\put(%d,%d){%s}\n",       
  619. X               (int)lastx, (int)lasty, LATEX_DOT);
  620. X       else
  621. X        fprintf(outfile, "\\put(%d,%d){\\rule[%.3fpt]{%.3fpt}{%.3fpt}}\n",
  622. X               (int)lastx, (int)lasty, -LATEX_dotsize*LATEX_UNIT/2,
  623. X               lastw*LATEX_UNIT, lasth*LATEX_UNIT);
  624. X    }
  625. X    
  626. X    if (flush) {
  627. X       valid = FALSE;
  628. X    } else {
  629. X       lastx = x; lasty = y;
  630. X       lastw = width; lasth = height;
  631. X       valid = TRUE;
  632. X    }
  633. }
  634. X
  635. static void
  636. LATEX_dot_line(x1,x2, y1,y2)
  637. X    int x1,x2, y1,y2;
  638. {
  639. X    static float LATEX_left;    /* fraction of space left after last dot */
  640. #ifndef AMIGA_AC_5
  641. X    extern double sqrt();
  642. #endif
  643. X    /* we draw a dotted line using the current dot spacing */
  644. X
  645. X    if (LATEX_moved)
  646. X     LATEX_left = 1.0;        /* reset after a move */
  647. X
  648. X    /* zero-length line? */
  649. X    if (x1 == x2 && y1 == y2) {
  650. X       if (LATEX_moved)
  651. X        /* plot a dot */
  652. X        fprintf(outfile, "\\put(%u,%u){%s}\n", x1, y1, LATEX_DOT);
  653. X    } else {
  654. X       float dotspace = LATEX_dotspace / LATEX_UNIT;
  655. X       float x,y;            /* current position */
  656. X       float xinc, yinc;    /* increments */
  657. X       float slope;        /* slope of line */
  658. X       float lastx = -1;    /* last x point plotted */
  659. X       float lasty = -1;    /* last y point plotted */
  660. X
  661. X       /* first, figure out increments for x and y */
  662. X       if (x2 == x1) {
  663. X          xinc = 0.0;
  664. X          yinc = dotspace;
  665. X       } else {
  666. X          slope = ((float)y2-y1)/((float)x2-x1);
  667. X          xinc = dotspace / sqrt(1 + slope*slope) * sign(x2-x1);
  668. X          yinc = slope * xinc;
  669. X       }
  670. X       
  671. X       /* now draw the dotted line */
  672. X       /* we take into account where we last placed a dot */
  673. X       for (x=x1 + xinc*(1-LATEX_left), y=y1 + yinc*(1-LATEX_left);
  674. X           (x2-x)*xinc >= 0 && (y2-y)*yinc >= 0; /* same sign or zero */
  675. X           lastx = x, x += xinc, 
  676. X           lasty = y, y += yinc)
  677. X        fprintf(outfile, "\\put(%d,%d){%s}\n", (int)x, (int)y, LATEX_DOT);
  678. X
  679. X       /* how much is left over, as a fraction of dotspace? */
  680. X       if (xinc != 0.0)            /* xinc must be nonzero */
  681. X        if (lastx >= 0)
  682. X          LATEX_left = abs(x2 - lastx) / abs(xinc);
  683. X        else
  684. X          LATEX_left += abs(x2-x1) / abs(xinc);
  685. X       else
  686. X        if (lasty >= 0)
  687. X          LATEX_left = abs(y2 - lasty) / abs(yinc);
  688. X        else
  689. X          LATEX_left += abs(y2-y1) / abs(yinc);
  690. X    }
  691. X
  692. X    LATEX_needsdot = (LATEX_left > 0);
  693. X
  694. X    LATEX_moved = FALSE;
  695. }
  696. X
  697. static void
  698. LATEX_flushdot()
  699. {
  700. X    if (LATEX_needsdot) 
  701. X     fprintf(outfile, "\\put(%d,%d){%s}\n", 
  702. X            LATEX_posx, LATEX_posy, LATEX_DOT);
  703. X    LATEX_needsdot = FALSE;
  704. }
  705. X
  706. LATEX_arrow(sx,sy, ex,ey, head)
  707. X    int sx,sy, ex,ey;
  708. X    BOOLEAN head;
  709. {
  710. X    best_latex_arrow(sx,sy, ex,ey, 1, head);
  711. X
  712. X    LATEX_posx = ex;
  713. X    LATEX_posy = ey;
  714. }
  715. X
  716. static void best_latex_arrow(sx,sy, ex,ey, who, head)
  717. X    int sx,sy, ex,ey;        /* start and end points */
  718. X    int who;                /* 1=LATEX, 2=EEPIC */
  719. X    BOOLEAN head;
  720. {
  721. X    int dx = ex - sx;
  722. X    int dy = ey - sy;
  723. X    int x, y;                /* points near sx,sy */
  724. X    float m;                /* slope of line */
  725. X    float arrowslope;        /* slope of arrow */
  726. X    float minerror = 0;        /* best-case error */
  727. X    struct vslope *slope;    /* one of the slopes */
  728. X    struct vslope *bestslope;    /* the slope with min error */
  729. X    BOOLEAN horiz;            /* was it the horiz line that was best? */
  730. X
  731. X    /* We try to draw a real arrow (ie, \vector). If we can't get
  732. X    * a slope that is close, we draw a bent arrow.
  733. X    */
  734. X
  735. X    if (dx == 0) {
  736. X       /* vertical arrow */
  737. X       fprintf(outfile, "\\put(%d,%d){\\%s(0,%d){%d}}\n",
  738. X             sx, sy, head ? "vector":"line", 
  739. X             sign(ey-sy), abs(ey-sy));
  740. X    } else if (dy == 0) {
  741. X       /* horizontal arrow */
  742. X       fprintf(outfile, "\\put(%d,%d){\\%s(%d,0){%d}}\n",
  743. X             sx, sy, head ? "vector":"line",
  744. X             sign(ex-sx), abs(ex-sx));
  745. X    } else {
  746. X       /* Slanted arrow. We'll give it a try.
  747. X        * we try to find the closest-slope arrowhead.
  748. X        */
  749. X       bestslope = NULL;
  750. X       minerror = 0; /* to shut up turbo C */
  751. X       m = abs((float)dy/dx); /* the slope we want */
  752. X       for (slope = LATEX_slopes; slope->dx != 0.0; slope++) {
  753. X          /* find the slope of the arrow */
  754. X          arrowslope = (float) slope->dy / slope->dx;
  755. X          if (bestslope == NULL || abs(m-arrowslope) < minerror) {
  756. X             minerror = abs(m-arrowslope);
  757. X             bestslope = slope;
  758. X          }
  759. X       }
  760. X
  761. X       /* now we have the best slope arrow */
  762. X       /* maybe it's exactly the right slope! */
  763. X       if (minerror == 0.0)    /* unlikely but possible */
  764. X        fprintf(outfile, "\\put(%d,%d){\\%s(%d,%d){%d}}\n",
  765. X               sx, sy, head ? "vector" : "line",
  766. X               bestslope->dx*sign(ex-sx), bestslope->dy*sign(ey-sy),
  767. X               abs(ex-sx));
  768. X       else {
  769. X          /* we draw the line the usual way, with thin lines */
  770. #ifdef EMTEX
  771. X          if (emtex) {
  772. X             LATEX_linetype(LATEX_THIN_LINE);
  773. X             EMTEX_solid_line(sx,ex,sy,ey);
  774. X          } else 
  775. #endif
  776. X            if (who == 1) {
  777. X               LATEX_linetype(LATEX_THIN_LINE);
  778. X               LATEX_solid_line(sx,ex,sy,ey);
  779. X            }
  780. #ifdef EEPIC
  781. X            else {
  782. X               EEPIC_move(sx,sy);
  783. X               EEPIC_vector(ex,ey);
  784. X            }
  785. #endif /* EEPIC */
  786. X          /* and then draw an arrowhead (a short vector) there */
  787. X            if (head)
  788. X                  fprintf(outfile, "\\put(%d,%d){\\vector(%d,%d){0}}\n",
  789. X                ex, ey, 
  790. X                bestslope->dx*sign(ex-sx), bestslope->dy*sign(ey-sy));
  791. X       }
  792. X    }
  793. }
  794. X
  795. X
  796. LATEX_put_text(x, y, str)
  797. X    int x,y;                /* reference point of string */
  798. X    char str[];            /* the text */
  799. {
  800. X    /* ignore empty strings */
  801. X    if (str[0] == '\0')
  802. X     return;
  803. X
  804. X    fprintf(outfile, "\\put(%d,%d)",x,y);
  805. X    switch(latex_angle) {  
  806. X        case 0: {
  807. X          switch(latex_justify) {
  808. X             case LEFT: {
  809. X                fprintf(outfile,
  810. X                       "{\\makebox(0,0)[l]{%s}}\n", str);
  811. X                break;
  812. X             }
  813. X             case CENTRE: {
  814. X                fprintf(outfile,
  815. X                       "{\\makebox(0,0){%s}}\n", str);
  816. X                break;
  817. X             }
  818. X             case RIGHT: {
  819. X                fprintf(outfile,
  820. X                       "{\\makebox(0,0)[r]{%s}}\n", str);
  821. X                break;
  822. X             }
  823. X          }
  824. X          break;
  825. X       }
  826. X       case 1: {            /* put text in a short stack */
  827. X          switch(latex_justify) {
  828. X             case LEFT: {
  829. X                fprintf(outfile,
  830. X                       "{\\makebox(0,0)[lb]{\\shortstack{%s}}}\n", str);
  831. X                break;
  832. X             }
  833. X             case CENTRE: {
  834. X                fprintf(outfile,
  835. X                       "{\\makebox(0,0)[l]{\\shortstack{%s}}}\n", str);
  836. X                break;
  837. X             }
  838. X             case RIGHT: {
  839. X                fprintf(outfile,
  840. X                       "{\\makebox(0,0)[lt]{\\shortstack{%s}}}\n", str);
  841. X                break;
  842. X             }
  843. X          }
  844. X          break;
  845. X       }    
  846. X    }
  847. }
  848. X
  849. X
  850. X
  851. int LATEX_justify_text(mode)
  852. X    enum JUSTIFY mode;
  853. {
  854. X    latex_justify = mode;
  855. X    return (TRUE);
  856. }
  857. X
  858. int LATEX_text_angle(angle)
  859. X    int angle;
  860. {
  861. X    /* we can't really write text vertically, but this will 
  862. X      put the ylabel centred at the left of the plot, and
  863. X      then we'll make a \shortstack */
  864. X    latex_angle = angle;
  865. X    return (TRUE);
  866. }
  867. X
  868. LATEX_reset()
  869. {
  870. X    LATEX_posx = LATEX_posy = 0; /* current position */
  871. X    LATEX_moved = TRUE;    /* pen is up after move */
  872. }
  873. X
  874. X
  875. #ifdef EMTEX
  876. X
  877. EMTEX_init()
  878. {
  879. X    emtex=TRUE;
  880. X    LATEX_posx = LATEX_posy = 0;
  881. X    fprintf(outfile, "%% GNUPLOT: LaTeX picture with emtex specials\n");
  882. X    fprintf(outfile, "\\setlength{\\unitlength}{%fpt}\n", LATEX_UNIT);
  883. X    fprintf(outfile, 
  884. X          "\\ifx\\plotpoint\\undefined\\newsavebox{\\plotpoint}\\fi\n");
  885. X    LATEX_linetype(-1);
  886. }
  887. X
  888. X
  889. EMTEX_reset()
  890. {
  891. X    emtex=FALSE;
  892. X    LATEX_posx = LATEX_posy = 0;
  893. }
  894. X
  895. X
  896. EMTEX_text()
  897. {
  898. X    fprintf(outfile, "\\end{picture}\n");
  899. }
  900. X
  901. X
  902. static void
  903. EMTEX_solid_line(x1,x2, y1,y2)
  904. X    int x1,x2, y1,y2;
  905. {
  906. X    /* emtex special solid line */
  907. X    if (LATEX_moved)
  908. X        fprintf(outfile, "\\put(%d,%d){\\special{em:moveto}}\n", x1, y1);
  909. X    if ( (x1!=x2) || (y1!=y2) )
  910. X        fprintf(outfile, "\\put(%d,%d){\\special{em:lineto}}\n", x2, y2);
  911. X    LATEX_posx = x2;
  912. X    LATEX_posy = y2;
  913. X    LATEX_moved = FALSE;
  914. }
  915. X
  916. X
  917. #endif /* EMTEX */
  918. SHAR_EOF
  919. chmod 0644 gnuplot/term/latex.trm ||
  920. echo 'restore of gnuplot/term/latex.trm failed'
  921. Wc_c="`wc -c < 'gnuplot/term/latex.trm'`"
  922. test 17764 -eq "$Wc_c" ||
  923.     echo 'gnuplot/term/latex.trm: original size 17764, current size' "$Wc_c"
  924. rm -f _shar_wnt_.tmp
  925. fi
  926. # ============= gnuplot/term/object.h ==============
  927. if test -f 'gnuplot/term/object.h' -a X"$1" != X"-c"; then
  928.     echo 'x - skipping gnuplot/term/object.h (File already exists)'
  929.     rm -f _shar_wnt_.tmp
  930. else
  931. > _shar_wnt_.tmp
  932. echo 'x - extracting gnuplot/term/object.h (Text)'
  933. sed 's/^X//' << 'SHAR_EOF' > 'gnuplot/term/object.h' &&
  934. /* 
  935. X *    FIG : Facility for Interactive Generation of figures
  936. X *
  937. X *    (c) copy right 1985 by Supoj Sutanthavibul (supoj@sally.utexas.edu)
  938. X *      January 1985.
  939. X *    1st revision : Aug 1985.
  940. X *    2nd revision : Feb 1988.
  941. X *
  942. X *    %W%    %G%
  943. */
  944. #define                    DEFAULT            -1
  945. X
  946. typedef        struct f_pattern {
  947. X            int            w, h;
  948. X            int            *p;
  949. X            }
  950. X        F_pattern;
  951. X
  952. typedef        struct f_pen {
  953. X            int            x, y;
  954. X            int            *p;
  955. X            }
  956. X        F_pen;
  957. X
  958. typedef        struct f_point {
  959. X            int            x, y;
  960. X            struct f_point        *next;
  961. X            }
  962. X        F_point;
  963. X
  964. typedef        struct f_pos {
  965. X            int            x, y;
  966. X            }
  967. X        F_pos;
  968. X
  969. typedef        struct f_arrow {
  970. X            int            type;
  971. X            int            style;
  972. X            float            thickness;
  973. X            float            wid;
  974. X            float            ht;
  975. X            }
  976. X        F_arrow;
  977. X
  978. typedef        struct f_ellipse {
  979. X            int            type;
  980. #define                    T_ELLIPSE_BY_RAD    1
  981. #define                    T_ELLIPSE_BY_DIA    2
  982. #define                    T_CIRCLE_BY_RAD        3
  983. #define                    T_CIRCLE_BY_DIA        4
  984. X            int            style;
  985. X            int            thickness;
  986. X            int            color;
  987. #define                    BLACK            0
  988. X            int            depth;
  989. X            int            direction;
  990. X            float            style_val;
  991. X            float            angle;
  992. X            struct f_pen        *pen;
  993. X            struct f_pattern    *area_fill;
  994. #define                           UNFILLED    (F_pattern *)0
  995. #define                           BLACK_FILL    (F_pattern *)1
  996. #define                           DARK_GRAY_FILL    (F_pattern *)2
  997. #define                           MED_GRAY_FILL    (F_pattern *)3
  998. #define                           LIGHT_GRAY_FILL    (F_pattern *)4
  999. #define                           WHITE_FILL    (F_pattern *)4
  1000. X            struct f_pos        center;
  1001. X            struct f_pos        radiuses;
  1002. X            struct f_pos        start;
  1003. X            struct f_pos        end;
  1004. X            struct f_ellipse    *next;
  1005. X            }
  1006. X        F_ellipse;
  1007. X
  1008. typedef        struct f_arc {
  1009. X            int            type;
  1010. #define                    T_3_POINTS_ARC        1
  1011. X            int            style;
  1012. X            int            thickness;
  1013. X            int            color;
  1014. X            int            depth;
  1015. X            struct f_pen        *pen;
  1016. X            struct f_pattern    *area_fill;
  1017. X            float            style_val;
  1018. X            int            direction;
  1019. X            struct f_arrow        *for_arrow;
  1020. X            struct f_arrow        *back_arrow;
  1021. X            struct {float x, y;}    center;
  1022. X            struct f_pos        point[3];
  1023. X            struct f_arc        *next;
  1024. X            }
  1025. X        F_arc;
  1026. X
  1027. typedef        struct f_line {
  1028. X            int            type;
  1029. #define                    T_POLYLINE    1
  1030. #define                    T_BOX        2
  1031. #define                    T_POLYGON    3
  1032. X            int            style;
  1033. X            int            thickness;
  1034. X            int            color;
  1035. X            int            depth;
  1036. X            float            style_val;
  1037. X            struct f_pen        *pen;
  1038. X            struct f_pattern    *area_fill;
  1039. X            struct f_arrow        *for_arrow;
  1040. X            struct f_arrow        *back_arrow;
  1041. X            struct f_point        *points;
  1042. X            struct f_line        *next;
  1043. X            }
  1044. X        F_line;
  1045. X
  1046. typedef        struct f_text {
  1047. X            int            type;
  1048. #define                    T_LEFT_JUSTIFIED    0
  1049. #define                    T_CENTER_JUSTIFIED    1
  1050. #define                    T_RIGHT_JUSTIFIED    2
  1051. X            int            font;
  1052. #define                    DEFAULT_FONT        0
  1053. #define                    ROMAN_FONT        1
  1054. #define                    BOLD_FONT        2
  1055. #define                    ITALIC_FONT        3
  1056. #define                    MODERN_FONT        4
  1057. #define                    TYPEWRITER_FONT        5
  1058. X            int            size;    /* point size */
  1059. X            int            color;
  1060. X            int            depth;
  1061. X            float            angle;    /* in radian */
  1062. X            int            style;
  1063. #define                    PLAIN        1
  1064. #define                    ITALIC        2
  1065. #define                    BOLD        4
  1066. #define                    OUTLINE        8
  1067. #define                    SHADOW        16
  1068. X            int            height;    /* pixels */
  1069. X            int            length;    /* pixels */
  1070. X            int            base_x;
  1071. X            int            base_y;
  1072. X            struct f_pen        *pen;
  1073. X            char            *cstring;
  1074. X            struct f_text        *next;
  1075. X            }
  1076. X        F_text;
  1077. X
  1078. typedef        struct f_control {
  1079. X            float            lx, ly, rx, ry;
  1080. X            struct f_control    *next;
  1081. X            }
  1082. X        F_control;
  1083. X
  1084. #define        int_spline(s)        (s->type & 0x2)
  1085. #define        normal_spline(s)    (!(s->type & 0x2))
  1086. #define        closed_spline(s)    (s->type & 0x1)
  1087. #define        open_spline(s)        (!(s->type & 0x1))
  1088. X
  1089. typedef        struct f_spline {
  1090. X            int            type;
  1091. #define                    T_OPEN_NORMAL        0
  1092. #define                    T_CLOSED_NORMAL        1
  1093. #define                    T_OPEN_INTERPOLATED    2
  1094. #define                    T_CLOSED_INTERPOLATED    3
  1095. X            int            style;
  1096. X            int            thickness;
  1097. X            int            color;
  1098. X            int            depth;
  1099. X            float            style_val;
  1100. X            struct f_pen        *pen;
  1101. X            struct f_pattern    *area_fill;
  1102. X            struct f_arrow        *for_arrow;
  1103. X            struct f_arrow        *back_arrow;
  1104. X            /*
  1105. X            For T_OPEN_NORMAL and T_CLOSED_NORMAL points
  1106. X            are control points while they are knots for
  1107. X            T_OPEN_INTERPOLATED and T_CLOSED_INTERPOLTED
  1108. X            whose control points are stored in controls.
  1109. X            */
  1110. X            struct f_point        *points;
  1111. X            struct f_control    *controls;
  1112. X            struct f_spline        *next;
  1113. X            }
  1114. X        F_spline;
  1115. X
  1116. typedef        struct f_compound {
  1117. X            struct f_pos        nwcorner;
  1118. X            struct f_pos        secorner;
  1119. X            struct f_line        *lines;
  1120. X            struct f_ellipse    *ellipses;
  1121. X            struct f_spline        *splines;
  1122. X            struct f_text        *texts;
  1123. X            struct f_arc        *arcs;
  1124. X            struct f_compound    *compounds;
  1125. X            struct f_compound    *next;
  1126. X            }
  1127. X        F_compound;
  1128. X
  1129. #define        ARROW_SIZE        sizeof(struct f_arrow)
  1130. #define        POINT_SIZE        sizeof(struct f_point)
  1131. #define        CONTROL_SIZE        sizeof(struct f_control)
  1132. #define        ELLOBJ_SIZE        sizeof(struct f_ellipse)
  1133. #define        ARCOBJ_SIZE        sizeof(struct f_arc)
  1134. #define        LINOBJ_SIZE        sizeof(struct f_line)
  1135. #define        TEXOBJ_SIZE        sizeof(struct f_text)
  1136. #define        SPLOBJ_SIZE        sizeof(struct f_spline)
  1137. #define        COMOBJ_SIZE        sizeof(struct f_compound)
  1138. X
  1139. /**********************  object codes  **********************/
  1140. X
  1141. #define        O_ELLIPSE        1
  1142. #define        O_POLYLINE        2
  1143. #define        O_SPLINE        3
  1144. #define        O_TEXT            4
  1145. #define        O_ARC            5
  1146. #define        O_COMPOUND        6
  1147. #define        O_END_COMPOUND        -O_COMPOUND
  1148. #define        O_ALL_OBJECT        99
  1149. X
  1150. /************  object styles (except for f_text)  ************/
  1151. X
  1152. #define        SOLID_LINE        0
  1153. #define        DASH_LINE        1
  1154. #define        DOTTED_LINE        2
  1155. X
  1156. #define        CLOSED_PATH        0
  1157. #define        OPEN_PATH        1
  1158. SHAR_EOF
  1159. chmod 0666 gnuplot/term/object.h ||
  1160. echo 'restore of gnuplot/term/object.h failed'
  1161. Wc_c="`wc -c < 'gnuplot/term/object.h'`"
  1162. test 5063 -eq "$Wc_c" ||
  1163.     echo 'gnuplot/term/object.h: original size 5063, current size' "$Wc_c"
  1164. rm -f _shar_wnt_.tmp
  1165. fi
  1166. # ============= gnuplot/term/post.trm ==============
  1167. if test -f 'gnuplot/term/post.trm' -a X"$1" != X"-c"; then
  1168.     echo 'x - skipping gnuplot/term/post.trm (File already exists)'
  1169.     rm -f _shar_wnt_.tmp
  1170. else
  1171. > _shar_wnt_.tmp
  1172. echo 'x - extracting gnuplot/term/post.trm (Text)'
  1173. sed 's/^X//' << 'SHAR_EOF' > 'gnuplot/term/post.trm' &&
  1174. /* GNUPLOT - post.trm */
  1175. /*
  1176. X * Copyright (C) 1990   
  1177. X *
  1178. X * Permission to use, copy, and distribute this software and its
  1179. X * documentation for any purpose with or without fee is hereby granted, 
  1180. X * provided that the above copyright notice appear in all copies and 
  1181. X * that both that copyright notice and this permission notice appear 
  1182. X * in supporting documentation.
  1183. X *
  1184. X * Permission to modify the software is granted, but not the right to
  1185. X * distribute the modified code.  Modifications are to be distributed 
  1186. X * as patches to released version.
  1187. X *  
  1188. X * This software  is provided "as is" without express or implied warranty.
  1189. X * 
  1190. X * This file is included by ../term.c.
  1191. X *
  1192. X * This terminal driver supports:
  1193. X *     postscript
  1194. X *
  1195. X * AUTHORS
  1196. X *  Russell Lang
  1197. X * 
  1198. X * send your comments or suggestions to (pixar!info-gnuplot@sun.com).
  1199. X *
  1200. X * The 'postscript' driver produces landscape output 10" wide and 7" high.  
  1201. X * To get a smaller epsf output use 'set size 0.5,0.5', 
  1202. X * 'set term postscript portrait', make only one plot per file
  1203. X * and change the first line of the postscript file from
  1204. X * '%!PS-Adobe-2.0' to '%!PS-Adobe-2.0 EPSF-2.0'
  1205. X * To change font to Times-Roman and font size to 20pts use 
  1206. X * 'set term postscript "Times-Roman" 20'.
  1207. X */
  1208. X
  1209. X
  1210. /* PostScript driver by Russell Lang, rjl@monu1.cc.monash.edu.au */
  1211. X
  1212. char ps_font[MAX_ID_LEN+1] = "Courier" ; /* name of font */
  1213. int ps_fontsize = 14;                     /* size of font in pts */
  1214. BOOLEAN ps_portrait = FALSE;                 /* vertical page */
  1215. BOOLEAN ps_color = FALSE;
  1216. int ps_page=0;            /* page count */
  1217. int ps_path_count=0;     /* count of lines in path */
  1218. int ps_ang=0;            /* text angle */
  1219. enum JUSTIFY ps_justify=LEFT;    /* text is flush left */
  1220. X
  1221. char *PS_header[] = {
  1222. "/vpt2 vpt 2 mul def\n",
  1223. "/hpt2 hpt 2 mul def\n",
  1224. /* flush left show */
  1225. "/Lshow { currentpoint stroke moveto\n",
  1226. "  0 vshift rmoveto show } def\n", 
  1227. /* flush right show */
  1228. "/Rshow { currentpoint stroke moveto\n",
  1229. "  dup stringwidth pop neg vshift rmoveto show } def\n", 
  1230. /* centred show */
  1231. "/Cshow { currentpoint stroke moveto\n",
  1232. "  dup stringwidth pop -2 div vshift rmoveto show } def\n", 
  1233. /* Dash or Color Line */
  1234. "/DL { Color {setrgbcolor [] 0 setdash pop}\n",
  1235. " {pop pop pop 0 setdash} ifelse } def\n",
  1236. /* Border Lines */
  1237. "/BL { stroke gnulinewidth 2 mul setlinewidth } def\n",
  1238. /* Axes Lines */
  1239. "/AL { stroke gnulinewidth 2 div setlinewidth } def\n",
  1240. /* Plot Lines */
  1241. "/PL { stroke gnulinewidth setlinewidth } def\n",
  1242. /* Line Types */
  1243. "/LTb { BL [] 0 0 0 DL } def\n", /* border */
  1244. "/LTa { AL [1 dl 2 dl] 0 setdash 0 0 0 setrgbcolor } def\n", /* axes */
  1245. "/LT0 { PL [] 0 1 0 DL } def\n",
  1246. "/LT1 { PL [4 dl 2 dl] 0 0 1 DL } def\n",
  1247. "/LT2 { PL [2 dl 3 dl] 1 0 0 DL } def\n",
  1248. "/LT3 { PL [1 dl 1.5 dl] 1 0 1 DL } def\n",
  1249. "/LT4 { PL [5 dl 2 dl 1 dl 2 dl] 0 1 1 DL } def\n",
  1250. "/LT5 { PL [4 dl 3 dl 1 dl 3 dl] 1 1 0 DL } def\n",
  1251. "/LT6 { PL [2 dl 2 dl 2 dl 4 dl] 0 0 0 DL } def\n",
  1252. "/LT7 { PL [2 dl 2 dl 2 dl 2 dl 2 dl 4 dl] 1 0.3 0 DL } def\n",
  1253. "/LT8 { PL [2 dl 2 dl 2 dl 2 dl 2 dl 2 dl 2 dl 4 dl] 0.5 0.5 0.5 DL } def\n",
  1254. "/M {moveto} def\n",
  1255. "/L {lineto} def\n",
  1256. "/P { stroke [] 0 setdash\n", /* Point */
  1257. "  currentlinewidth 2 div sub moveto\n",
  1258. "  0 currentlinewidth rlineto  stroke } def\n",
  1259. "/D { stroke [] 0 setdash  2 copy  vpt add moveto\n", /* Diamond */
  1260. "  hpt neg vpt neg rlineto  hpt vpt neg rlineto\n",
  1261. "  hpt vpt rlineto  hpt neg vpt rlineto  closepath  stroke\n",
  1262. "  P  } def\n",
  1263. "/A { stroke [] 0 setdash  vpt sub moveto  0 vpt2 rlineto\n", /* Plus (Add) */
  1264. "  currentpoint stroke moveto\n",
  1265. "  hpt neg vpt neg rmoveto  hpt2 0 rlineto stroke\n",
  1266. "  } def\n",
  1267. "/B { stroke [] 0 setdash  2 copy  exch hpt sub exch vpt add moveto\n", /* Box */
  1268. "  0 vpt2 neg rlineto  hpt2 0 rlineto  0 vpt2 rlineto\n",
  1269. "  hpt2 neg 0 rlineto  closepath  stroke\n",
  1270. "  P  } def\n",
  1271. "/C { stroke [] 0 setdash  exch hpt sub exch vpt add moveto\n", /* Cross */
  1272. "  hpt2 vpt2 neg rlineto  currentpoint  stroke  moveto\n",
  1273. "  hpt2 neg 0 rmoveto  hpt2 vpt2 rlineto stroke  } def\n",
  1274. "/T { stroke [] 0 setdash  2 copy  vpt 1.12 mul add moveto\n", /* Triangle */
  1275. "  hpt neg vpt -1.62 mul rlineto\n",
  1276. "  hpt 2 mul 0 rlineto\n",
  1277. "  hpt neg vpt 1.62 mul rlineto  closepath  stroke\n",
  1278. "  P  } def\n",
  1279. "/S { 2 copy A C} def\n", /* Star */
  1280. NULL
  1281. };
  1282. X
  1283. #define PS_XOFF    50    /* page offset in pts */
  1284. #define PS_YOFF    50
  1285. X
  1286. #define PS_XMAX 7200
  1287. #define PS_YMAX 5040
  1288. X
  1289. #define PS_XLAST (PS_XMAX - 1)
  1290. #define PS_YLAST (PS_YMAX - 1)
  1291. X
  1292. #define PS_VTIC (PS_YMAX/80)
  1293. #define PS_HTIC (PS_YMAX/80)
  1294. X
  1295. #define PS_SC (10)                /* scale is 1pt = 10 units */
  1296. #define    PS_LW (0.5*PS_SC)        /* linewidth = 0.5 pts */
  1297. X
  1298. #define PS_VCHAR (14*PS_SC)        /* default is 14 point characters */
  1299. #define PS_HCHAR (14*PS_SC*6/10)
  1300. X
  1301. X
  1302. PS_options()
  1303. {
  1304. X    extern struct value *const_express();
  1305. X    extern double real();
  1306. X
  1307. X    if (!END_OF_COMMAND) {
  1308. X        if (almost_equals(c_token,"p$ortrait")) {
  1309. X            ps_portrait=TRUE;
  1310. X            c_token++;
  1311. X        }
  1312. X        else if (almost_equals(c_token,"l$andscape")) {
  1313. X            ps_portrait=FALSE;
  1314. X            c_token++;
  1315. X        }
  1316. X        else if (almost_equals(c_token,"d$efault")) {
  1317. X            ps_portrait=FALSE;
  1318. X            ps_color=FALSE;
  1319. X            strcpy(ps_font,"Courier");
  1320. X            ps_fontsize = 14;
  1321. X            c_token++;
  1322. X        }
  1323. X    }
  1324. X
  1325. X    if (!END_OF_COMMAND) {
  1326. X        if (almost_equals(c_token,"m$onochrome")) {
  1327. X            ps_color=FALSE;
  1328. X            c_token++;
  1329. X        }
  1330. X        else if (almost_equals(c_token,"c$olor")) {
  1331. X            ps_color=TRUE;
  1332. X            c_token++;
  1333. X        }
  1334. X    }
  1335. X
  1336. X    if (!END_OF_COMMAND && isstring(c_token)) {
  1337. X        quote_str(ps_font,c_token);
  1338. X        c_token++;
  1339. X    }
  1340. X
  1341. X    if (!END_OF_COMMAND) {
  1342. X        /* We have font size specified */
  1343. X        struct value a;
  1344. X        ps_fontsize = (int)real(const_express(&a));
  1345. X        c_token++;
  1346. X        term_tbl[term].v_char = (unsigned int)(ps_fontsize*PS_SC);
  1347. X        term_tbl[term].h_char = (unsigned int)(ps_fontsize*PS_SC*6/10);
  1348. X    }
  1349. X
  1350. X    sprintf(term_options,"%s %s \"%s\" %d",
  1351. X        ps_portrait ? "portrait" : "landscape",
  1352. X        ps_color ? "color" : "monochrome",ps_font,ps_fontsize);
  1353. }
  1354. X
  1355. X
  1356. PS_init()
  1357. {
  1358. struct termentry *t = &term_tbl[term];
  1359. int i;
  1360. X    ps_page = 0;
  1361. X    fprintf(outfile,"%%!PS-Adobe-2.0\n");
  1362. X    fprintf(outfile,"%%%%Creator: gnuplot\n");
  1363. X    fprintf(outfile,"%%%%DocumentFonts: %s\n", ps_font);
  1364. X    fprintf(outfile,"%%%%BoundingBox: %d %d ", PS_XOFF,PS_YOFF);
  1365. X    if (ps_portrait)
  1366. X        fprintf(outfile,"%d %d\n", 
  1367. X            (int)(xsize*(PS_XMAX)/PS_SC+0.5+PS_XOFF), 
  1368. X            (int)(ysize*(PS_YMAX)/PS_SC+0.5+PS_YOFF) );
  1369. X    else 
  1370. X        fprintf(outfile,"%d %d\n", 
  1371. X            (int)(ysize*(PS_YMAX)/PS_SC+0.5+PS_XOFF), 
  1372. X            (int)(xsize*(PS_XMAX)/PS_SC+0.5+PS_YOFF) );
  1373. X    fprintf(outfile,"%%%%Pages: (atend)\n");
  1374. X    fprintf(outfile,"%%%%EndComments\n");
  1375. X    fprintf(outfile,"/gnudict 40 dict def\ngnudict begin\n");
  1376. X    fprintf(outfile,"/Color %s def\n",ps_color ? "true" : "false");
  1377. X    fprintf(outfile,"/gnulinewidth %.3f def\n",PS_LW);
  1378. X    fprintf(outfile,"/vshift %d def\n", (int)(t->v_char)/(-3));
  1379. X    fprintf(outfile,"/dl {%d mul} def\n",PS_SC); /* dash length */
  1380. X    fprintf(outfile,"/hpt %.1f def\n",PS_HTIC/2.0);
  1381. X    fprintf(outfile,"/vpt %.1f def\n",PS_VTIC/2.0);
  1382. X    for ( i=0; PS_header[i] != NULL; i++)
  1383. X        fprintf(outfile,"%s",PS_header[i]);
  1384. X    fprintf(outfile,"end\n");
  1385. X    fprintf(outfile,"%%%%EndProlog\n");
  1386. }
  1387. X
  1388. X
  1389. PS_graphics()
  1390. {
  1391. struct termentry *t = &term_tbl[term];
  1392. X    ps_page++;
  1393. X    fprintf(outfile,"%%%%Page: %d %d\n",ps_page,ps_page);
  1394. X    fprintf(outfile,"gnudict begin\n");
  1395. X    fprintf(outfile,"gsave\n");
  1396. X    fprintf(outfile,"%d %d translate\n",PS_XOFF,PS_YOFF);
  1397. X    if (ps_portrait) {
  1398. X        fprintf(outfile,"%.3f %.3f scale\n", xsize/PS_SC, ysize/PS_SC);
  1399. X    }
  1400. X    else {
  1401. X        fprintf(outfile,"%.3f %.3f scale\n", ysize/PS_SC, xsize/PS_SC);
  1402. X        fprintf(outfile,"90 rotate\n0 %d translate\n", -PS_YMAX);
  1403. X    }
  1404. X    fprintf(outfile,"0 setgray\n");
  1405. X    fprintf(outfile,"/%s findfont %d ", ps_font, (t->v_char) );
  1406. X    fprintf(outfile,"scalefont setfont\n");
  1407. X    fprintf(outfile,"newpath\n");
  1408. X    ps_path_count = 0;
  1409. }
  1410. X
  1411. X
  1412. PS_text()
  1413. {
  1414. X    ps_path_count = 0;
  1415. X    fprintf(outfile,"stroke\ngrestore\nend\nshowpage\n");
  1416. }
  1417. X
  1418. X
  1419. PS_reset()
  1420. {
  1421. X    fprintf(outfile,"%%%%Trailer\n");
  1422. X    fprintf(outfile,"%%%%Pages: %d\n",ps_page);
  1423. }
  1424. X
  1425. X
  1426. PS_linetype(linetype)
  1427. int linetype;
  1428. {
  1429. char *line = "ba012345678"; 
  1430. X    fprintf(outfile,"LT%c\n", line[(linetype%9)+2]);
  1431. X    ps_path_count = 0;
  1432. }
  1433. X
  1434. X
  1435. PS_move(x,y)
  1436. unsigned int x,y;
  1437. {
  1438. X    fprintf(outfile,"%d %d M\n", x, y);
  1439. X    ps_path_count += 1;
  1440. }
  1441. X
  1442. X
  1443. PS_vector(x,y)
  1444. unsigned int x,y;
  1445. {
  1446. X    fprintf(outfile,"%d %d L\n", x, y);
  1447. X    ps_path_count += 1;
  1448. X    if (ps_path_count >= 400) {
  1449. X        fprintf(outfile,"currentpoint stroke moveto\n");
  1450. X        ps_path_count = 0;
  1451. X    }
  1452. }
  1453. X
  1454. X
  1455. PS_put_text(x,y,str)
  1456. unsigned int x, y;
  1457. char *str;
  1458. {
  1459. char ch;
  1460. X    PS_move(x,y);
  1461. X    if (ps_ang != 0)
  1462. X        fprintf(outfile,"currentpoint gsave translate %d rotate 0 0 moveto\n"
  1463. X            ,ps_ang*90);
  1464. X    putc('(',outfile);
  1465. X    ch = *str++;
  1466. X    while(ch!='\0') {
  1467. X        if ( (ch=='(') || (ch==')') || (ch=='\\') )
  1468. X            putc('\\',outfile);
  1469. X        putc(ch,outfile);
  1470. X        ch = *str++;
  1471. X    }
  1472. X    switch(ps_justify) {
  1473. X        case LEFT : fprintf(outfile,") Lshow\n");
  1474. X            break;
  1475. X        case CENTRE : fprintf(outfile,") Cshow\n");
  1476. X            break;
  1477. X        case RIGHT : fprintf(outfile,") Rshow\n");
  1478. X            break;
  1479. X    }
  1480. X    if (ps_ang != 0)
  1481. X        fprintf(outfile,"grestore\n");
  1482. X    ps_path_count = 0;
  1483. }
  1484. X
  1485. int PS_text_angle(ang)
  1486. int ang;
  1487. {
  1488. X    ps_ang=ang;
  1489. X    return TRUE;
  1490. }
  1491. X
  1492. int PS_justify_text(mode)
  1493. enum JUSTIFY mode;
  1494. {
  1495. X    ps_justify=mode;
  1496. X    return TRUE;
  1497. }
  1498. X
  1499. /* postscript point routines */
  1500. PS_point(x,y,number)
  1501. int x,y;
  1502. int number;
  1503. {
  1504. char *point = "PDABCTS";
  1505. X    number %= POINT_TYPES;
  1506. X     if (number < -1)
  1507. X        number = -1;        /* negative types are all 'dot' */
  1508. X    fprintf(outfile,"%d %d %c\n", x, y, point[number+1]);
  1509. X    ps_path_count = 0;
  1510. }
  1511. X
  1512. SHAR_EOF
  1513. chmod 0644 gnuplot/term/post.trm ||
  1514. echo 'restore of gnuplot/term/post.trm failed'
  1515. Wc_c="`wc -c < 'gnuplot/term/post.trm'`"
  1516. test 9281 -eq "$Wc_c" ||
  1517.     echo 'gnuplot/term/post.trm: original size 9281, current size' "$Wc_c"
  1518. rm -f _shar_wnt_.tmp
  1519. fi
  1520. # ============= gnuplot/term/dxf.trm ==============
  1521. if test -f 'gnuplot/term/dxf.trm' -a X"$1" != X"-c"; then
  1522.     echo 'x - skipping gnuplot/term/dxf.trm (File already exists)'
  1523.     rm -f _shar_wnt_.tmp
  1524. else
  1525. > _shar_wnt_.tmp
  1526. echo 'x - extracting gnuplot/term/dxf.trm (Text)'
  1527. sed 's/^X//' << 'SHAR_EOF' > 'gnuplot/term/dxf.trm' &&
  1528. /* GNUPLOT - dxf.trm */
  1529. /*
  1530. X * Copyright (C) 1991
  1531. X *
  1532. X * Permission to use, copy, and distribute this software and its
  1533. X * documentation for any purpose with or without fee is hereby granted,
  1534. X * provided that the above copyright notice appear in all copies and
  1535. X * that both that copyright notice and this permission notice appear
  1536. X * in supporting documentation.
  1537. X *
  1538. X * Permission to modify the software is granted, but not the right to
  1539. X * distribute the modified code.  Modifications are to be distributed
  1540. X * as patches to released version.
  1541. X *
  1542. X * This software  is provided "as is" without express or implied warranty.
  1543. X *
  1544. X * This file is included by ../term.c.
  1545. X *
  1546. X * This terminal driver supports:
  1547. X *   AutoCad (Release 10.x) dxf file format (import with AutoCad dxfin command)
  1548. X *
  1549. X *
  1550. X * AUTHOR
  1551. X *   Florian Hiss  (fhis1231@w204zrz.zrz.tu-berlin.de)
  1552. X *
  1553. X * send your comments or suggestions to (pixar!info-gnuplot@sun.com).
  1554. */
  1555. X
  1556. #define DXF_UNIT 60.0
  1557. #define LINEWIDTH 0.0351  /* default line width is 1 pt */
  1558. X
  1559. /* 120 (autocad units) wide by 80 (autocad units) high (default)
  1560. X   use the GNUPLOT 'set size' command to change the defaults */
  1561. #define DXF_XMAX (120.0 * DXF_UNIT)
  1562. #define DXF_YMAX (80.0 * DXF_UNIT)
  1563. #define DXF_HTIC (0.01 * DXF_XMAX)  /* 1.0 percent */
  1564. #define DXF_VTIC (0.01 * DXF_YMAX)  /* 1.0 percent */
  1565. #define DXF_HCHAR (0.014 * DXF_XMAX) /* 1.4 percent */
  1566. #define DXF_VCHAR (0.026 * DXF_YMAX) /* 2.6 percent */
  1567. #define DXF_TEXTHEIGHT (0.7 * DXF_VCHAR) /* actual text height */
  1568. #define DXF_TEXTWIDTH (0.7 * DXF_HCHAR) /* actual text width,
  1569. X only a guess, we don't know the width of a character of given height
  1570. X of the AutoCad STANDARD text font, so change it if you like */
  1571. #define DXF_LINE_TYPES 7 /* number of line types we support. see below  */
  1572. #define MAX_LAYER 7  /* number of layers used for the drawing. see below */
  1573. #define LT_SCALE 1  /* line type scaling */
  1574. X
  1575. static unsigned int DXF_posx;
  1576. static unsigned int DXF_posy;
  1577. static unsigned int dxf_linetype; /* linetype is mapped to a layer. see below. */
  1578. enum JUSTIFY dxf_justify = LEFT;
  1579. static float dxf_angle = 0.0; /* either 0 (horizontal) or 90.0 (vertical) */
  1580. X
  1581. /* text style used in the entire drawing */
  1582. static char *text_style = "STANDARD";
  1583. /* text always resides on layer 0 */
  1584. #define TEXT_LAYER 0
  1585. /* each linetype resides on its own layer. each layer has its own color.
  1586. X   this avoids difficulties that AutoCad has with proper scaling of
  1587. X   the linetypes.
  1588. X   change the colors according to your needs */
  1589. static char *layer_name[] = {"0","1","2","3","4","5","6"};
  1590. /* the colours are white, red, yellow, green, cyan, blue, magenta.
  1591. X   change them according to your needs.
  1592. X   when using a black and white plotting device the colours map to different
  1593. X   line thicknesses. see description of AutoCad print / plot command */
  1594. static char *layer_colour[] = {"7","1","2","3","4","5","6"};
  1595. /* support line types AutoCad has to offer by default. */
  1596. static char *layer_lines[] = {"CONTINUOUS","DASHED","HIDDEN","CENTER","PHANTOM",
  1597. X                "DOT","DASHDOT"};
  1598. X
  1599. static BOOLEAN vector_was_last = FALSE;
  1600. X
  1601. DXF_init()
  1602. {
  1603. X    DXF_posx = DXF_posy = 0;
  1604. X    dxf_linetype = 0;
  1605. X    dxf_angle = 0.0;
  1606. X    vector_was_last = FALSE;
  1607. }
  1608. X
  1609. DXF_graphics()
  1610. {
  1611. X    register struct termentry *t = &term_tbl[term];
  1612. X    int i;
  1613. X
  1614. X    fprintf(outfile,"999\n");
  1615. X    fprintf(outfile,"%% GNUPLOT: dxf file for AutoCad\n");
  1616. X    fprintf(outfile,"  0\nSECTION\n  2\nHEADER\n");
  1617. X    fprintf(outfile,"  9\n$EXTMIN\n");
  1618. X    fprintf(outfile," 10\n0.000\n 20\n0.000\n");
  1619. X    fprintf(outfile,"  9\n$EXTMAX\n");
  1620. X    fprintf(outfile," 10\n%-6.3f\n 20\n%-6.3f\n",t->xmax/DXF_UNIT,t->ymax/DXF_UNIT);
  1621. X    fprintf(outfile,"  9\n$LIMMIN\n");
  1622. X    fprintf(outfile," 10\n0.000\n 20\n0.000\n");
  1623. X    fprintf(outfile,"  9\n$LIMMAX\n");
  1624. X    fprintf(outfile," 10\n%-6.3f\n 20\n%-6.3f\n",t->xmax/DXF_UNIT,t->ymax/DXF_UNIT);
  1625. X    fprintf(outfile,"  9\n$TEXTSTYLE\n  7\n%s\n",text_style);
  1626. X    fprintf(outfile,"  9\n$TEXTSIZE\n 40\n%-6.3f\n",DXF_TEXTHEIGHT/DXF_UNIT);
  1627. X    fprintf(outfile,"  9\n$PLINEWID\n 40\n%-6.4f\n",LINEWIDTH);
  1628. X    fprintf(outfile,"  9\n$LTSCALE\n  40\n%-6.3f\n",LT_SCALE);
  1629. X    fprintf(outfile,"  9\n$COORDS\n 70\n  1\n");
  1630. X    fprintf(outfile,"  9\n$CELTYPE\n 6\nBYLAYER\n"); /* entity line type name */
  1631. X    fprintf(outfile,"  9\n$CLAYER\n  8\n0\n"); /* current layer */
  1632. X    fprintf(outfile,"  9\n$CECOLOR\n 62\n   %s\n",layer_colour[0]);
  1633. X    fprintf(outfile,"  9\n$MENU\n  1\nacad\n");
  1634. X    fprintf(outfile,"  0\nENDSEC\n");
  1635. X    fprintf(outfile,"  0\nSECTION\n  2\nTABLES\n");
  1636. X    /* the linetype table */
  1637. X    fprintf(outfile,"0\nTABLE\n  2\nLTYPE\n 70\n    %d\n",DXF_LINE_TYPES);
  1638. X    fprintf(outfile,"0\nLTYPE\n  2\nCONTINUOUS\n 70\n    64\n");
  1639. X    fprintf(outfile,"  3\nSolid line\n 72\n    65\n 73\n      0\n 40\n0.0\n");
  1640. X    fprintf(outfile,"  0\nLTYPE\n  2\nDASHED\n 70\n    64\n");
  1641. X    fprintf(outfile,"  3\n__ __ __ __ __ __ __ __ __ __ __ __ __ __ __\n");
  1642. X    fprintf(outfile," 72\n    65\n 73\n     2\n 40\n0.75\n 49\n0.5\n 49\n-0.25\n");
  1643. X    fprintf(outfile,"  0\nLTYPE\n  2\nHIDDEN\n 70\n    64\n");
  1644. X    fprintf(outfile,"  3\n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\n");
  1645. X    fprintf(outfile," 72\n    65\n 73\n     2\n 40\n0.375\n 49\n0.25\n 49\n-0.125\n");
  1646. X    fprintf(outfile,"  0\nLTYPE\n  2\nCENTER\n 70\n    64\n");
  1647. X    fprintf(outfile,"  3\n____ _ ____ _ ____ _ ____ _ ____ _ ____ _ ____\n");
  1648. X    fprintf(outfile," 72\n    65\n 73\n     4\n 40\n2.0\n 49\n1.25\n 49\n-0.25\n");
  1649. X    fprintf(outfile," 49\n0.25\n 49\n-0.25\n");
  1650. X    fprintf(outfile,"  0\nLTYPE\n  2\nPHANTOM\n 70\n    64\n");
  1651. X    fprintf(outfile,"  3\n_____ _ _ _____ _ _ _____ _ _ _____ _ _ ____\n");
  1652. X    fprintf(outfile," 72\n    65\n 73\n     6\n 40\n2.5\n 49\n1.25\n");
  1653. X    fprintf(outfile," 49\n-0.25\n 49\n0.25\n 49\n-0.25\n 49\n0.25\n 49\n-0.25\n");
  1654. X    fprintf(outfile,"  0\nLTYPE\n  2\nDOT\n 70\n    64\n");
  1655. X    fprintf(outfile,"  3\n...............................................\n");
  1656. X    fprintf(outfile," 72\n    65\n 73\n     2\n 40\n0.25\n 49\n0.0\n 49\n-0.25\n");
  1657. X    fprintf(outfile,"  0\nLTYPE\n  2\nDASHDOT\n 70\n    64\n");
  1658. X    fprintf(outfile,"  3\n__ . __ . __ . __ . __ . __ . __ . __ . __ . __\n");
  1659. X    fprintf(outfile," 72\n    65\n 73\n     4\n 40\n1.0\n 49\n0.5\n 49\n-0.25\n");
  1660. X    fprintf(outfile," 49\n0.0\n 49\n-0.25\n");
  1661. X    fprintf(outfile,"  0\nENDTAB\n");
  1662. X    /* the layer table */
  1663. X    fprintf(outfile,"  0\nTABLE\n  2\nLAYER\n 70\n   %-d\n",MAX_LAYER);
  1664. X    for (i = 1; i <= MAX_LAYER; i++)
  1665. X        fprintf(outfile,"  0\nLAYER\n  2\n%s\n 70\n   64\n62\n   %s\n  6\n%s\n",
  1666. X            layer_name[i-1],layer_colour[i-1],layer_lines[i-1]);
  1667. X    fprintf(outfile,"  0\nENDTAB\n0\nENDSEC\n");
  1668. X    /* no blocks for insertion */
  1669. X    fprintf(outfile,"  0\nSECTION\n  2\nBLOCKS\n  0\nENDSEC\n");
  1670. X    /* start the entity section */
  1671. X    fprintf(outfile,"  0\nSECTION\n");
  1672. X    fprintf(outfile,"  2\nENTITIES\n");
  1673. }
  1674. X
  1675. DXF_text()
  1676. {
  1677. X    if (vector_was_last) fprintf(outfile,"  0\nSEQEND\n");
  1678. X    fprintf(outfile,"  0\nENDSEC\n  0\nEOF\n");
  1679. }
  1680. X
  1681. DXF_linetype(linetype)
  1682. X    int linetype;
  1683. {
  1684. X    linetype = abs(linetype);
  1685. X    linetype = linetype%DXF_LINE_TYPES;
  1686. X    dxf_linetype = linetype;
  1687. }
  1688. X
  1689. DXF_move(x, y)
  1690. X    unsigned int x, y;
  1691. {
  1692. X    DXF_posx = x;
  1693. X    DXF_posy = y;
  1694. X    if (vector_was_last) fprintf(outfile,"  0\nSEQEND\n");
  1695. X    vector_was_last = FALSE;
  1696. X    fprintf(outfile,"  0\nPOLYLINE\n  8\n%s\n 66\n   1\n",layer_name[dxf_linetype]);
  1697. X    fprintf(outfile,"  6\n%s\n",layer_lines[dxf_linetype]);
  1698. X    fprintf(outfile,"  0\nVERTEX\n  8\n%s\n",layer_name[dxf_linetype]);
  1699. X    fprintf(outfile,"  6\n%s\n",layer_lines[dxf_linetype]);
  1700. X    fprintf(outfile," 10\n%-6.3f\n 20\n%-6.3f\n 30\n0.000\n",DXF_posx/DXF_UNIT,DXF_posy/DXF_UNIT);
  1701. }
  1702. X
  1703. DXF_vector(ux, uy)
  1704. X    unsigned int ux, uy;
  1705. {
  1706. X    DXF_posx = ux;
  1707. X    DXF_posy = uy;
  1708. X    vector_was_last = TRUE;
  1709. X    fprintf(outfile,"  0\nVERTEX\n  8\n%s\n",layer_name[dxf_linetype]);
  1710. X    fprintf(outfile,"  6\n%s\n",layer_lines[dxf_linetype]);
  1711. X    fprintf(outfile,"  10\n%-6.3f\n  20\n%-6.3f\n  30\n0.000\n",
  1712. X                    DXF_posx/DXF_UNIT,DXF_posy/DXF_UNIT);
  1713. }
  1714. X
  1715. DXF_put_text(x, y, str)
  1716. X    int x, y;
  1717. X    char str[];
  1718. {
  1719. X    int stl;
  1720. X    float xleftpos, yleftpos, xrightpos,yrightpos;
  1721. X    /* ignore empty strings */
  1722. X    if (str[0] == '\0') return;
  1723. SHAR_EOF
  1724. true || echo 'restore of gnuplot/term/dxf.trm failed'
  1725. fi
  1726. echo 'End of  part 17'
  1727. echo 'File gnuplot/term/dxf.trm is continued in part 18'
  1728. echo 18 > _shar_seq_.tmp
  1729. exit 0
  1730.  
  1731. exit 0 # Just in case...
  1732. -- 
  1733. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  1734. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  1735. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  1736. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  1737.