home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 344b.lha / plplot_v2.6 / unix / xterm.c < prev   
Encoding:
C/C++ Source or Header  |  1990-01-27  |  2.7 KB  |  141 lines

  1. #include "plplot.h"
  2. #include <stdio.h>
  3.  
  4. /* This file contains the xterm dependent routines for use with plplot. */
  5.  
  6. #define TEKX   1023
  7. #define TEKY    779
  8.  
  9. /* Define graphics control characters. */
  10. #define FF   12
  11. #define CAN  24
  12. #define ESC  27
  13. #define GS   29
  14. #define US   31
  15. #define ETX  003
  16.  
  17. void xtesetup(xdpi, ydpi, xwid, ywid)
  18. PLINT xwid, ywid;
  19. PLFLT xdpi, ydpi;
  20. {
  21.    /* the user doesn't know what he's talking about. ignore this stuff */
  22. }
  23.  
  24. void xteselect(ori, name)
  25. PLINT ori;
  26. char *name;
  27. {
  28. }
  29.  
  30. void xteinit()
  31. {
  32.       /* tell plplot that this is an interactive device (so pause after */
  33.       /* drawing graph).  use if smod(0) if sending grphx to a file. */
  34.       smod(1);   /* interactive device */
  35.  
  36.       /* set default pen color (this should be the desired pen number) */
  37.       /* plplot will actually tell the device to use this pen by */
  38.       /* making a call to plcolor. */
  39.       scol(1);
  40.  
  41.       swid(1);
  42.       /* set device resolution in dots/mm */
  43.       setpxl(4.771*16,4.653*16);
  44.  
  45.       /* set page size using setphy(xmin,xmax,ymin,ymax) */
  46.       /* plplot assumes that the min coordinates are in the lower left */
  47.       setphy(0,16*TEKX,0,16*TEKY);
  48.  
  49.       printf("%c[?38h",ESC); /* open graphics window */
  50.       printf("%c",GS);       /* set to vector mode */
  51.       printf("%c%c",ESC,FF);
  52. }
  53.  
  54. /* Sets to text mode */
  55. void xtetext()
  56. {
  57.     printf("%c",US);
  58. }
  59.  
  60. /* Sets to graphics mode */
  61. void xtegraph()
  62. {
  63.     /* Nothing has to be done here */
  64. }
  65.  
  66. /* Clears the screen */
  67. void xteclear()
  68. {
  69.      putchar('\007');
  70.      fflush(stdout);
  71.      while(getchar() != '\n')
  72.         ;
  73.      printf("%c%c",ESC,FF);
  74. }
  75.  
  76. static PLINT xold, yold;
  77.  
  78. void xtepage()
  79. {
  80.    xold = -100000;
  81.    yold = -100000;
  82. }
  83.  
  84. /* Change color */
  85. void xtecolor(colour)
  86. PLINT colour;
  87. {
  88. }
  89.  
  90. void xtewidth(width)
  91. PLINT width;
  92. {
  93. }
  94.  
  95. /* Draws a line in the current colour from (x1,y1) to (x2,y2) */
  96. void xteline(x1,y1,x2,y2)
  97. PLINT x1,y1,x2,y2;
  98. {
  99.     PLINT hy,ly,hx,lx;
  100.  
  101.     x1 >>= 4;
  102.     y1 >>= 4;
  103.     x2 >>= 4;
  104.     y2 >>= 4;
  105.     /* If continuation of previous line just send new point */
  106.     if(x1 == xold && y1 == yold) {
  107.        hy = y2/32 + 32;
  108.        ly = y2 - (y2/32)*32 + 96;
  109.        hx = x2/32 + 32;
  110.        lx = x2 - (x2/32)*32 + 64;
  111.        printf("%c%c%c%c",hy,ly,hx,lx);
  112.     }
  113.     else {
  114.        printf("%c",GS);
  115.        hy = y1/32 + 32;
  116.        ly = y1 - (y1/32)*32 + 96;
  117.        hx = x1/32 + 32;
  118.        lx = x1 - (x1/32)*32 + 64;
  119.        printf("%c%c%c%c",hy,ly,hx,lx);
  120.        hy = y2/32 + 32;
  121.        ly = y2 - (y2/32)*32 + 96;
  122.        hx = x2/32 + 32;
  123.        lx = x2 - (x2/32)*32 + 64;
  124.        printf("%c%c%c%c",hy,ly,hx,lx);
  125.     }
  126.     xold = x2;
  127.     yold = y2;
  128. }
  129.  
  130. void xtetidy()
  131. {
  132.    putchar('\007');
  133.    fflush(stdout);
  134.    while(getchar() != '\n')
  135.       ;
  136.    printf("%c%c",US,CAN);
  137.    printf("%c%c",ESC,ETX);
  138.    fflush(stdout);
  139. }
  140.  
  141.