home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume24 / chemtab / part02 / graphlib.c < prev    next >
C/C++ Source or Header  |  1991-03-12  |  2KB  |  131 lines

  1. #ifdef    ReGIS
  2.  
  3. #include <stdio.h>
  4. #include <curses.h>
  5. #include <strings.h>
  6. #include "variables.h"
  7. #include "element.h"
  8. #include "graph.h"
  9. #include "undefs.h"
  10. #include "tune.h"
  11.  
  12. /*
  13.  * ReGIS graphics interface package (NOTE: Not curses oriented)
  14.  */
  15.  
  16. chcolor(col)
  17. int    col;
  18. {
  19.     if (!strncmp(getenv("TERM"), "vt2", 3)) {
  20.         switch(col) {
  21.             case '7':
  22.             case '2':
  23.             case '4':
  24.                 col = RED_2;
  25.                 break;
  26.             case '1':
  27.             case '5':
  28.                 col = BLU_2;
  29.                 break;
  30.             case '0': col = BLK_2; break;
  31.             default:
  32.                 col = GRN_2;
  33.                 break;
  34.         }
  35.     }
  36.     printf("W(I%d)", col);
  37. }
  38.  
  39. initregis()
  40. {
  41.     printf("\033Pp");
  42. #ifdef    LASERPRT
  43.     if (laser)
  44.         fprintf(lsr, "\033Pp");
  45. #endif    LASERPRT
  46.     chcolor(6);
  47. }
  48.  
  49. endregis()
  50. {
  51. #ifdef    LASERPRT
  52.     if (laser)
  53.         fprintf(lsr, "\033\\");
  54. #endif    LASERPRT
  55.     printf("\033\\"); 
  56. }
  57.  
  58. regisgoto(x, y)
  59. int    x, y;
  60. {
  61. #ifdef    LASERPRT
  62.     if (laser)
  63.         fprintf(lsr, "P[%d,%d]", x, y);
  64. #endif    LASERPRT
  65.     printf("P[%d,%d]", x, y);
  66. }
  67.  
  68. line(x1, y1, x2, y2)
  69. int    x1, y1, x2, y2;    /* From x1,y1 to x2,y2 */
  70. {
  71.     regisgoto(x1, y1);
  72.     printf("V[%d,%d]", x2, y2);
  73. #ifdef    LASERPRT
  74.     if (laser)
  75.         fprintf(lsr, "V[%d,%d]", x2, y2);
  76. #endif    LASERPRT
  77.     }
  78.  
  79. mybox(width, x1, y1, x2, y2)
  80. int    width, x1, y1, x2, y2;
  81. {
  82.     int    i;
  83.     for (i = 0; i <= width; i++) {
  84.         line(x1+i, y1+i, x2-i, y1+i);
  85.         line(x2-i, y1+i, x2-i, y2-i);
  86.         line(x2-i, y2-i, x1+i, y2-i);
  87.         line(x1+i, y2-i, x1+i, y1+i);
  88.     }
  89. }
  90.  
  91. hash(x1, y1, which)
  92. int    x1, y1, which;        /* Make small hashmark with cross at x1,y1 */
  93. {
  94.     if (which) {
  95.         regisgoto(x1, y1);  /* decided to make it a circle... */
  96.         printf("W(S1)C[+2]W(S0)");
  97.         fflush(stdout);
  98. #ifdef    LASERPRT
  99.         if (laser)
  100.             fprintf(lsr, "W(S1)C[+2]W(S0)");
  101. #endif    LASERPRT
  102.     } else {
  103.         line(x1, y1-2, x1, y1+2);
  104.         line(x1-2, y1, x1+2, y1);
  105.     }
  106. }
  107.  
  108. text(size, dir, angle, string)
  109. int    size,        /* 0 through 16 * multiplier of # pixels in char */
  110.     dir,        /* Angle of text in 45 degree increments */
  111.     angle;        /* italics angle -45 to 45 degrees */
  112. char    *string;    /* text to output */
  113. {
  114.     printf("T(D%d)(S%d)(D%d)(I%d)'%s'", dir, size, dir, angle, string);
  115. #ifdef    LASERPRT
  116.     if (laser)
  117.         fprintf(lsr, "T(D%d)(S%d)(D%d)(I%d)'%s'", dir, size, dir, angle, string);
  118. #endif    LASERPRT
  119. }
  120.  
  121. regispc()
  122. {
  123.     noecho(); crmode();
  124.     regisgoto(10, 455);
  125.     text(1, 0, -5, "Press SPACE to continue...");
  126.     fflush(stdout);
  127.     getchar();
  128.     echo(); nocrmode();
  129. }
  130. #endif    ReGIS
  131.