home *** CD-ROM | disk | FTP | other *** search
/ Encyclopedia of Graphics File Formats Companion / GFF_CD.ISO / software / unix / saoimage / sao1_07.tar / rtcmd.c < prev    next >
C/C++ Source or Header  |  1990-05-11  |  3KB  |  161 lines

  1.  
  2. #include <stdio.h>
  3.  
  4. #include <X11/Xlib.h>        /* X window stuff */
  5. #include <X11/Xutil.h>        /* X window manager stuff */
  6. #include "hfiles/constant.h"    /* define codes */
  7. #include "hfiles/define.h"    /* YES, NO, MIN, MAX and more */
  8. #include "hfiles/struct.h"    /* define the works */
  9. #include "hfiles/extern.h"    /* extern main parameter structures */
  10. #include "hfiles/rtcmd.h"    /* command protocol and ID's */
  11.  
  12.  
  13. #define SOP_Count    56
  14.  
  15.  
  16. int si_command(cmd)
  17.             cmdrec *cmd;
  18. {
  19.  
  20.     switch ( cmd->command ) {
  21.  
  22.     case NOPER:    break;
  23.  
  24.  
  25.     case PIXEL:
  26.         if ( cmd->count == 1 ) 
  27.             si_pixel(cmd->count, cmd->mode, &cmd->x);
  28.         else;
  29.             /* read in a list of pixels  */
  30.             /* saqhack_dispix(cmd.count, */
  31.         break;
  32.  
  33.     case FILER:
  34.         si_filer(cmd);
  35.         break;
  36.  
  37.     case FRAME:
  38.     default:
  39.         fprintf(stderr, "si_command: bad command.\n");
  40.     }
  41.  
  42.     return 1;
  43.  
  44. }
  45.  
  46. int    ITypeMap[] = { SOP_Count };
  47.  
  48.  
  49.  
  50. si_filer(cmd)
  51.             cmdrec *cmd;
  52. {
  53.     switch ( cmd->mode ) {
  54.     case INITI:
  55.         si_init(cmd);
  56.         break;
  57.  
  58.     default:
  59.         fprintf(stderr, "si_filer: bad mode.\n");
  60.     };
  61. }
  62.  
  63. si_init(cmd)
  64.             cmdrec *cmd;
  65. {
  66.     img.file_type = ITypeMap[cmd->x];
  67.     if ( !img.file_type ) img.filename = "Counts read from InterNet"; 
  68.     img.fd = 0;
  69.  
  70.     img.filerows = cmd->dx;
  71.     img.filecols = cmd->dy;
  72.  
  73.     new_display();
  74.     make_scalemap(0, 10);
  75.     buffer.scale_min = 0;
  76.     buffer.scale_max = 10;
  77. }    
  78.  
  79.  
  80.  
  81. si_pixel(count, mode, list)
  82.             int count;
  83.             int mode;
  84.             position *list;
  85. {
  86.     while ( count-- ) {
  87.         switch ( mode ) {
  88.  
  89.         case SET:
  90.             fprintf(stderr, "Set a pixel at %d, %d to %d\n"
  91.                 , list->x, list->y, list->z);
  92.  
  93.             break;
  94.         case ADD:
  95.             disp_pixel(list->x, list->y,
  96.                 buffer.shortbuf
  97.                   [list->x + coord.buf.width * list->y]
  98.                  += list->z);
  99.  
  100.             break;
  101.         case XOR:
  102.  
  103.         default:
  104.             fprintf(stderr, "mode %d at %d, %d to %d"
  105.                 , mode, list->x, list->y, list->z);
  106.             fprintf(stderr, "si_pixel: bad mode\n");
  107.         };
  108.     };
  109. }
  110.  
  111.  
  112.  
  113. disp_pixel(x, y, value)
  114.             int x, y, value;
  115. {
  116.         float xr, yr;
  117.  
  118.           unsigned long original;
  119.           GC gc, set_gc();
  120.  
  121. /*    i_transform(&coord.buftodisp, x, y, &xr, &yr);
  122.  
  123.     x = xr;  y = yr;
  124. */
  125.  
  126.     if (        ( x < 0 ) 
  127.         || ( y < 0 ) 
  128.         || ( x > coord.disp.X2i ) 
  129.         || ( y > coord.disp.Y2i ) ) return; 
  130.  
  131.     dispbox.image.data[x + y * coord.disp.width] = value 
  132.         = buffer.scalemap[value];
  133.  
  134.       original = color.gcset.disp.foreground;            /* From MvH */
  135.  
  136.       color.gcset.disp.foreground = (unsigned long)value;
  137.       gc = set_gc(&color.gcset.disp);
  138.       XDrawPoint(dispbox.display, dispbox.ID, gc, x, y);
  139.  
  140.       color.gcset.disp.foreground = original;
  141.  
  142. /*    check n pix/ sec
  143.  
  144.     check tot pix
  145.  
  146.     ? write
  147.  
  148.     check pixels / kbytes
  149.  
  150.     ? partition
  151.  
  152.     write
  153. */
  154. }
  155.  
  156.  
  157.  
  158.     
  159.  
  160.  
  161.