IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 22, 2007, 12:23:09 PM (19 years ago)
Author:
eugene
Message:

upgrading to kapa 2.0 API, upgrades to dvo user interface

Location:
trunk/Ohana/src/kapa2
Files:
5 added
57 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/kapa2/Makefile

    r13333 r13479  
    1 default: kapa2
     1default: kapa
    22help:
    33        @echo "make options: kapa (default)"
     
    2020INDEPS  = $(DESTINC)/kapa.h $(DESTINC)/dvo.h $(DESTINC)/gfitsio.h $(DESTINC)/ohana.h
    2121
    22 kapa2: $(BIN)/kapa2.$(ARCH)
    23 install: $(DESTBIN)/kapa2
     22kapa2: $(BIN)/kapa.$(ARCH)
     23install: $(DESTBIN)/kapa
    2424
    2525KAPA = \
     
    4949$(SRC)/Graphs.$(ARCH).o                   $(SRC)/SetGraphSize.$(ARCH).o       \
    5050$(SRC)/Resize.$(ARCH).o                   $(SRC)/ErasePlots.$(ARCH).o         \
     51$(SRC)/EraseImage.$(ARCH).o               $(SRC)/SetToolbox.$(ARCH).o         \
    5152$(SRC)/EraseCurrentPlot.$(ARCH).o         $(SRC)/EraseSections.$(ARCH).o      \
    5253$(SRC)/SetSection.$(ARCH).o               $(SRC)/DefineSection.$(ARCH).o      \
     
    6465$(SRC)/CreatePicture.$(ARCH).o            $(SRC)/CreateColorbar.$(ARCH).o     \
    6566$(SRC)/MakeColormap.$(ARCH).o             $(SRC)/SetColormap.$(ARCH).o        \
    66 $(SRC)/PaintOverlay.$(ARCH).o             $(SRC)/PaintTickmarks.$(ARCH).o     \
     67$(SRC)/PaintOverlay.$(ARCH).o             $(SRC)/SetGraphData.$(ARCH).o       \
    6768$(SRC)/LoadOverlay.$(ARCH).o              $(SRC)/EraseOverlay.$(ARCH).o       \
    68 $(SRC)/LoadTickmarks.$(ARCH).o            $(SRC)/SaveOverlay.$(ARCH).o        \
     69$(SRC)/SaveOverlay.$(ARCH).o              $(SRC)/SetImageData.$(ARCH).o       \
    6970$(SRC)/CSaveOverlay.$(ARCH).o             $(SRC)/EraseOverlay.$(ARCH).o       \
    7071$(SRC)/CheckVisual.$(ARCH).o              $(SRC)/CursorOps.$(ARCH).o          \
     
    8889$(OBJ): $(INDEPS) $(LDDEPS)
    8990
    90 $(BIN)/kapa2.$(ARCH): $(OBJ)
     91$(BIN)/kapa.$(ARCH): $(OBJ)
  • trunk/Ohana/src/kapa2/include/constants.h

    r13320 r13479  
    1010 | PointerMotionMask)
    1111
    12 # define PAD1  5
    13 # define PAD2  3
     12# define PAD1  3
     13# define PAD2  5
    1414# define TEXTPAD 25
    1515# define COLORPAD 10
    1616# define TEXT_Y 15
    17 # define ZOOM_X 170
    18 # define ZOOM_Y 170
     17# define ZOOM_X 152
     18# define ZOOM_Y 152
    1919# define NOVERLAYS 4
    2020# define BUTTON_WIDTH 28
  • trunk/Ohana/src/kapa2/include/globals.h

    r13333 r13479  
    1515
    1616/* file descriptor for socket connection to mana */
    17 int sock;
     17// int sock;
    1818
    1919/* each layout / section defines one of the active portions of the graphics window
  • trunk/Ohana/src/kapa2/include/prototypes.h

    r13333 r13479  
    3939
    4040/* EventLoop */
    41 int           PScommand           PROTO(());
     41int           PScommand           PROTO((int sock));
    4242int           CheckPipe           PROTO(());
    4343int           Reconfig            PROTO((XEvent *event));
     
    4545
    4646/* CheckPipe */
    47 int           PNGit               PROTO(());
    48 int           PPMit               PROTO(());
    49 int           LoadFrame           PROTO(());
    50 int           LoadObject          PROTO(());
    51 int           LoadLabels          PROTO(());
    52 int           LoadTextlines       PROTO(());
    53 int           LoadVectorData      PROTO(());
    54 int           Resize              PROTO(());
    55 int           GetLimits           PROTO(());
    56 int           SetLimits           PROTO(());
    57 int           SetSection          PROTO(());
    58 int           ListSection         PROTO(());
    59 int           DefineSection       PROTO(());
    60 int           SetFont             PROTO(());
    61 int           EraseCurrentPlot    PROTO(());
    62 int           ErasePlots          PROTO(());
    63 int           EraseSections       PROTO(());
     47int           PNGit               PROTO((int sock));
     48int           PPMit               PROTO((int sock));
     49int           LoadFrame           PROTO((int sock));
     50int           LoadObject          PROTO((int sock));
     51int           LoadLabels          PROTO((int sock));
     52int           LoadTextlines       PROTO((int sock));
     53int           Resize              PROTO((int sock));
     54int           GetLimits           PROTO((int sock));
     55int           SetLimits           PROTO((int sock));
     56int           SetSection          PROTO((int sock));
     57int           ListSection         PROTO((int sock));
     58int           MoveSection         PROTO((int sock));
     59int           DefineSection       PROTO((int sock));
     60int           SetFont             PROTO((int sock));
     61int           EraseCurrentPlot    PROTO((void));
     62int           ErasePlots          PROTO((void));
     63int           EraseSections       PROTO((void));
     64int           EraseImage          PROTO((void));
     65int           SetGraphData        PROTO((int sock));
     66int           GetGraphData        PROTO((int sock));
     67int           SetImageData        PROTO((int sock));
     68int           GetImageData        PROTO((int sock));
     69
     70int           LoadVectorData      PROTO((int sock, KapaGraphWidget *graph, int N, char *type));
    6471
    6572/* Section Utilities */
     
    7481Section      *GetActiveSection    PROTO(());
    7582int           SetActiveSectionByNumber PROTO((int N));
    76 int           ListSection         PROTO(());
     83int           ListSection         PROTO((int sock));
    7784
    7885KapaGraphWidget *InitGraph        PROTO(());
    7986void          DrawGraph           PROTO((KapaGraphWidget *graph));
    8087void          SetGraphSize        PROTO((Section *section));
     88void          FreeGraph           PROTO((KapaGraphWidget *graph));
    8189
    8290void          InitLayout          PROTO((int argc, char **argv));
     
    124132void          QuitX               PROTO((Display *display, char *message));
    125133Graphic      *GetGraphic          PROTO(());
     134int           GetPixelCount       PROTO((int sock));
    126135
    127136int           Center              PROTO(());
     
    131140void          Remap24             PROTO((Graphic *graphic, KapaImageWidget *image, Matrix *matrix));
    132141void          Remap32             PROTO((Graphic *graphic, KapaImageWidget *image, Matrix *matrix));
    133 int           LoadPicture         PROTO(());
     142int           LoadPicture         PROTO((int sock));
     143
    134144KapaImageWidget *InitImage        PROTO(());
     145void          FreeImage           PROTO((KapaImageWidget *image));
    135146void          SetImageSize        PROTO((Section *section));
    136 int           GetPixelCount       PROTO(());
     147
    137148void          InitButtonSize      PROTO((Button *button, int width, int height, char *bitmap));
    138149void          InitButtonFunc      PROTO((Button *button, int (*function)()));
  • trunk/Ohana/src/kapa2/include/structures.h

    r13320 r13479  
    9595  int Nobjects;
    9696  unsigned long color;
    97   Object *objects;
     97  KiiOverlay *objects;
    9898} Overlay;
    9999 
     
    116116  Axis      axis[4];    /* coordinate axes */
    117117  Label     label[8];   /* fixed axis labels */
     118  Graphdata data;       /* current graph data */
    118119
    119120  Gobjects *objects;    /* graphic objects */   
     
    138139  Button   grey_button;
    139140  Button   rainbow_button;
    140   Button   puns_button;
     141  Button    puns_button;
    141142  Button   overlay_button[NOVERLAYS];
    142143
    143144  // location of the status box
    144145  int      text_x, text_y;
     146  int      text_dx, text_dy;
    145147  int      location;          // position of the zoom/status widgets (0 = none, 1-4 = bottom,left,top,right)
    146148  int      MovePointer;
     
    159161  Coords   coords;
    160162  char     file[1024];     /* name of file */
    161   char     buffer_name[1024];  /* name of buffer */
     163  char     name[1024];  /* name of buffer */
    162164} KapaImageWidget;
    163165
  • trunk/Ohana/src/kapa2/src/CSaveOverlay.c

    r13320 r13479  
    11# include "Ximage.h"
    22
    3 int CSaveOverlay () {
     3int CSaveOverlay (int sock) {
    44
    5   char filename[256];
     5  char filename[256], *type;
    66  int i, N;
    77  double ra, dec, ra1, dec1, x1, y1, dra, ddec;
     
    1010  KapaImageWidget *image;
    1111
     12  KiiScanMessage (sock, "%*s %d %s", &N, filename);
     13 
    1214  section = GetActiveSection();
    1315  image   = section->image;
     16  if (image == NULL) return (TRUE);
    1417
    15   KiiScanMessage (sock, "%*s %d %s", &N, filename);
    16  
    1718  f = fopen (filename, "w");
    1819  if (f == NULL) {
     
    2223
    2324  for (i = 0; i < image[0].overlay[N].Nobjects; i++) {
    24     if (!strcmp (image[0].overlay[N].objects[i].type, "LINE")) {
     25    if (image[0].overlay[N].objects[i].type == KII_OVERLAY_LINE) {
    2526      XY_to_RD (&ra, &dec, image[0].overlay[N].objects[i].x, image[0].overlay[N].objects[i].y, &image[0].coords);
    2627      x1 = image[0].overlay[N].objects[i].x + image[0].overlay[N].objects[i].dx;
     
    4041      dra = cos (dec*RAD_DEG) * fabs (ra1 - ra);
    4142    }
    42     fprintf (f, "%s %lf %lf %lf %lf\n", image[0].overlay[N].objects[i].type, ra, dec, dra, ddec);
     43    type = KiiOverlayTypeByNumber (image[0].overlay[N].objects[i].type);
     44    if (type == NULL) continue;
     45    fprintf (f, "%s %lf %lf %lf %lf\n", type, ra, dec, dra, ddec);
    4346   }
    4447  fclose (f);
  • trunk/Ohana/src/kapa2/src/Center.c

    r13320 r13479  
    11# include "Ximage.h"
    22
    3 int Center () {
     3int Center (int sock) {
    44
    55  int zoom;
     
    99  KapaImageWidget *image;
    1010
     11  KiiScanMessage (sock, "%lf %lf %d", &X,  &Y, &zoom);
     12
    1113  graphic = GetGraphic();
    1214  section = GetActiveSection();
    1315  image = section->image;
    14 
    15   KiiScanMessage (sock, "%lf %lf %d", &X,  &Y, &zoom);
     16  if (image == NULL) return (TRUE);
    1617
    1718  image[0].X = 0.5*image[0].matrix.Naxis[0] - X;
  • trunk/Ohana/src/kapa2/src/CheckPipe.c

    r13333 r13479  
    22# define STRCONST(A) ((int)(0x1000000*A[0] + 0x10000*A[1] + 0x100*A[2] + 0x1*A[3]))
    33
     4static KapaSockAddress Address;
     5static int InitSocket = -1;
     6static int sock = -1;
     7
     8// we can supply a port here, with only small changes
     9void InitPipe () {
     10  InitSocket = KapaServerInit (&Address);
     11  return;
     12}
     13
     14int GetActiveSocket () {
     15  return (sock);
     16}
     17
     18// after we have processed the command, we unblock the socket
     19# define FINISHED(A) { fcntl (sock, F_SETFL, O_NONBLOCK); return (A); }
     20
    421int CheckPipe () {
    522
    623  int status;
    7   char buffer[32];
     24  char word[5];
     25
     26  // check if we have a valid connection. if not, see if we can get one
     27  if (sock == -1) {
     28    sock = KapaServerWait (InitSocket, &Address);
     29    if (sock == -1) return (TRUE);
     30    close (InitSocket); /* stop listening for new connections */
     31    fcntl (sock, F_SETFL, O_NONBLOCK); 
     32  }
    833
    934  /***** read (4 byte) message word from socket ****/
    10   status = read (sock, buffer, 4);
    11   buffer[4] = 0;
     35  status = read (sock, word, 4);
     36  word[4] = 0;
    1237  switch (status) {
    1338  case -1:                          /* no input from pipe: continue */
     
    2954  }
    3055 
     56  /* once we get a command, we block to ensure we get complete messages */
     57  fcntl (sock, F_SETFL, !O_NONBLOCK); 
     58
    3159  /***** handle different messages ****/
    3260  if (ACTIVE_CURSOR) {
    33     if (strcmp (buffer, "NCUR")) {
    34       fprintf (stderr, "wrong end message %s\n", buffer);
    35       return (TRUE);
     61    if (strcmp (word, "NCUR")) {
     62      fprintf (stderr, "wrong end message %s\n", word);
     63      KiiSendCommand (sock, 4, "DONE");
     64      FINISHED (TRUE);
    3665    }
    3766    ACTIVE_CURSOR = FALSE;
    38     return (TRUE);
     67    KiiSendCommand (sock, 4, "DONE");
     68    FINISHED (TRUE);
    3969  }
    4070
    41   if (!strcmp (buffer, "QUIT")) return (FALSE);
    42  
    43   if (!strcmp (buffer, "CURS")) {
     71  if (!strcmp (word, "QUIT")) FINISHED (FALSE);
     72 
     73  if (!strcmp (word, "CURS")) {
    4474    ACTIVE_CURSOR = TRUE;
    45     return (TRUE);
    46   }
    47  
    48   if (!strcmp (buffer, "PSIT")) {
    49     status = PScommand ();
    50     write (sock, "DONE", 4);
    51     return (status);
    52   }
    53  
    54   if (!strcmp (buffer, "PNGF")) {
    55     status = PNGit ();
    56     write (sock, "DONE", 4);
    57     return (status);
    58   }
    59  
    60   if (!strcmp (buffer, "PPMF")) {
    61     status = PPMit ();
    62     write (sock, "DONE", 4);
    63     return (status);
    64   }
    65  
    66   if (!strcmp (buffer, "DBOX")) {
    67     status = LoadFrame ();
    68     return (status);
    69   }
    70  
    71   if (!strcmp (buffer, "PLOT")) {
    72     status = LoadObject ();
    73     return (status);
    74   }
    75  
    76   if (!strcmp (buffer, "LABL")) {
    77     status = LoadLabels ();
    78     return (TRUE);
    79   }
    80  
    81   if (!strcmp (buffer, "PTXT")) {
    82     status = LoadTextlines ();
    83     return (TRUE);
    84   }
    85  
    86   if (!strcmp (buffer, "RSIZ")) {
    87     status = Resize ();
    88     return (status);
    89   }
    90 
    91   if (!strcmp (buffer, "LIMS")) {
    92     GetLimits ();
    93     return (TRUE);
    94   }
    95  
    96   if (!strcmp (buffer, "SLIM")) {
    97     status = SetLimits ();
    98     return (TRUE);
    99   }
    100  
    101   if (!strcmp (buffer, "SSEC")) {
    102     status = SetSection ();
    103     return (TRUE);
    104   }
    105  
    106   if (!strcmp (buffer, "LSEC")) {
    107     status = ListSection ();
    108     return (TRUE);
    109   }
    110  
    111   if (!strcmp (buffer, "DSEC")) {
    112     status = DefineSection ();
    113     return (TRUE);
    114   }
    115  
    116   if (!strcmp (buffer, "FONT")) {
    117     status = SetFont ();
    118     return (TRUE);
     75    KiiSendCommand (sock, 4, "DONE");
     76    FINISHED (TRUE);
     77  }
     78 
     79  if (!strcmp (word, "PSIT")) {
     80    status = PScommand (sock);
     81    KiiSendCommand (sock, 4, "DONE");
     82    FINISHED (status);
     83  }
     84 
     85  if (!strcmp (word, "PNGF")) {
     86    status = PNGit (sock);
     87    KiiSendCommand (sock, 4, "DONE");
     88    FINISHED (status);
     89  }
     90 
     91  if (!strcmp (word, "PPMF")) {
     92    status = PPMit (sock);
     93    KiiSendCommand (sock, 4, "DONE");
     94    FINISHED (status);
     95  }
     96 
     97  if (!strcmp (word, "DBOX")) {
     98    status = LoadFrame (sock);
     99    KiiSendCommand (sock, 4, "DONE");
     100    FINISHED (status);
     101  }
     102 
     103  if (!strcmp (word, "PLOT")) {
     104    status = LoadObject (sock);
     105    // LoadObject sends its own handshake
     106    // KiiSendCommand (sock, 4, "DONE");
     107    FINISHED (status);
     108  }
     109 
     110  if (!strcmp (word, "LABL")) {
     111    status = LoadLabels (sock);
     112    KiiSendCommand (sock, 4, "DONE");
     113    FINISHED (TRUE);
     114  }
     115 
     116  if (!strcmp (word, "PTXT")) {
     117    status = LoadTextlines (sock);
     118    KiiSendCommand (sock, 4, "DONE");
     119    FINISHED (TRUE);
     120  }
     121 
     122  if (!strcmp (word, "RSIZ")) {
     123    status = Resize (sock);
     124    KiiSendCommand (sock, 4, "DONE");
     125    FINISHED (status);
     126  }
     127
     128  if (!strcmp (word, "GLIM")) {
     129    GetLimits (sock);
     130    KiiSendCommand (sock, 4, "DONE");
     131    FINISHED (TRUE);
     132  }
     133 
     134  if (!strcmp (word, "SLIM")) {
     135    status = SetLimits (sock);
     136    KiiSendCommand (sock, 4, "DONE");
     137    FINISHED (TRUE);
     138  }
     139 
     140  if (!strcmp (word, "GSTY")) {
     141    GetGraphData (sock);
     142    KiiSendCommand (sock, 4, "DONE");
     143    FINISHED (TRUE);
     144  }
     145 
     146  if (!strcmp (word, "SSTY")) {
     147    status = SetGraphData (sock);
     148    KiiSendCommand (sock, 4, "DONE");
     149    FINISHED (TRUE);
     150  }
     151 
     152  if (!strcmp (word, "GIMD")) {
     153    GetImageData (sock);
     154    KiiSendCommand (sock, 4, "DONE");
     155    FINISHED (TRUE);
     156  }
     157 
     158  if (!strcmp (word, "SIMD")) {
     159    status = SetImageData (sock);
     160    KiiSendCommand (sock, 4, "DONE");
     161    FINISHED (TRUE);
     162  }
     163 
     164  if (!strcmp (word, "TOOL")) {
     165    status = SetToolbox (sock);
     166    KiiSendCommand (sock, 4, "DONE");
     167    FINISHED (TRUE);
     168  }
     169 
     170  if (!strcmp (word, "SSEC")) {
     171    status = SetSection (sock);
     172    KiiSendCommand (sock, 4, "DONE");
     173    FINISHED (TRUE);
     174  }
     175 
     176  if (!strcmp (word, "LSEC")) {
     177    status = ListSection (sock);
     178    KiiSendCommand (sock, 4, "DONE");
     179    FINISHED (TRUE);
     180  }
     181 
     182  if (!strcmp (word, "DSEC")) {
     183    status = DefineSection (sock);
     184    KiiSendCommand (sock, 4, "DONE");
     185    FINISHED (TRUE);
     186  }
     187 
     188  if (!strcmp (word, "MSEC")) {
     189    status = MoveSection (sock);
     190    KiiSendCommand (sock, 4, "DONE");
     191    FINISHED (TRUE);
     192  }
     193 
     194  if (!strcmp (word, "FONT")) {
     195    status = SetFont (sock);
     196    KiiSendCommand (sock, 4, "DONE");
     197    FINISHED (TRUE);
    119198  }
    120199 
    121200  /* Erase Section */
    122   if (!strcmp (buffer, "ERSC")) {
    123     status = EraseCurrentPlot (TRUE);
    124     return (status);
    125   }
    126  
    127   /* Erase Section */
    128   if (!strcmp (buffer, "ERAS")) {
    129     status = ErasePlots (TRUE);
    130     return (status);
    131   }
    132  
    133   /* Don't Erase Section */
    134   if (!strcmp (buffer, "ERSS")) {
    135     status = EraseSections (FALSE);
    136     return (status);
    137   }
    138  
    139 
    140   if (!strcmp (buffer, "READ")) {
    141     status = LoadPicture ();
    142     return (status);
    143   }
    144 
    145   // XXX duplicate Command word
    146   if (!strcmp (buffer, "ERAS")) {
    147     status = EraseOverlay ();
    148     return (status);
    149   }
    150 
    151   if (!strcmp (buffer, "LOAD")) {
    152     status = LoadOverlay ();
    153     return (status);
    154   }
    155 
    156   if (!strcmp (buffer, "TICK")) {
    157     status = LoadTickmarks ();
    158     return (status);
    159   }
    160 
    161   if (!strcmp (buffer, "SAVE")) {
    162     status = SaveOverlay ();
    163     return (status);
    164   }
    165 
    166   if (!strcmp (buffer, "CSVE")) {
    167     status = CSaveOverlay ();
    168     return (status);
    169   }
    170 
    171   if (!strcmp (buffer, "JPEG")) {
    172     status = JPEGit24 ();
    173     write (sock, "DONE", 4);
    174     return (status);
    175   }
    176 
    177   if (!strcmp (buffer, "CENT")) {
    178     status = Center ();
    179     return (status);
    180   }
    181 
    182   if (!strcmp (buffer, "NPIX")) {
    183     GetPixelCount ();
    184     return (TRUE);
    185   }
    186 
    187   fprintf (stderr, "unknown signal %s\n", buffer);
    188 
    189   return (TRUE);
    190 
     201  if (!strcmp (word, "ERSC")) {
     202    status = EraseCurrentPlot ();
     203    KiiSendCommand (sock, 4, "DONE");
     204    FINISHED (status);
     205  }
     206 
     207  /* Erase Plots */
     208  if (!strcmp (word, "ERSP")) {
     209    status = ErasePlots ();
     210    KiiSendCommand (sock, 4, "DONE");
     211    FINISHED (status);
     212  }
     213 
     214  /* Erase Sections */
     215  if (!strcmp (word, "ERSS")) {
     216    status = EraseSections ();
     217    KiiSendCommand (sock, 4, "DONE");
     218    FINISHED (status);
     219  }
     220
     221  /* Erase Image */
     222  if (!strcmp (word, "ERSI")) {
     223    status = EraseImage ();
     224    KiiSendCommand (sock, 4, "DONE");
     225    FINISHED (status);
     226  }
     227
     228  /* Erase Overlay for this section */
     229  if (!strcmp (word, "ERSO")) {
     230    status = EraseOverlay (sock);
     231    KiiSendCommand (sock, 4, "DONE");
     232    FINISHED (status);
     233  }
     234
     235  if (!strcmp (word, "READ")) {
     236    status = LoadPicture (sock);
     237    KiiSendCommand (sock, 4, "DONE");
     238    FINISHED (status);
     239  }
     240
     241  if (!strcmp (word, "LOAD")) {
     242    status = LoadOverlay (sock);
     243    KiiSendCommand (sock, 4, "DONE");
     244    FINISHED (status);
     245  }
     246
     247  if (!strcmp (word, "SAVE")) {
     248    status = SaveOverlay (sock);
     249    KiiSendCommand (sock, 4, "DONE");
     250    FINISHED (status);
     251  }
     252
     253  if (!strcmp (word, "CSVE")) {
     254    status = CSaveOverlay (sock);
     255    KiiSendCommand (sock, 4, "DONE");
     256    FINISHED (status);
     257  }
     258
     259  if (!strcmp (word, "JPEG")) {
     260    status = JPEGit24 (sock);
     261    KiiSendCommand (sock, 4, "DONE");
     262    FINISHED (status);
     263  }
     264
     265  if (!strcmp (word, "CENT")) {
     266    status = Center (sock);
     267    KiiSendCommand (sock, 4, "DONE");
     268    FINISHED (status);
     269  }
     270
     271  if (!strcmp (word, "NPIX")) {
     272    GetPixelCount (sock);
     273    KiiSendCommand (sock, 4, "DONE");
     274    FINISHED (TRUE);
     275  }
     276
     277  fprintf (stderr, "unknown signal %s\n", word);
     278  KiiSendCommand (sock, 4, "DONE");
     279  FINISHED (TRUE);
    191280}
  • trunk/Ohana/src/kapa2/src/CheckVisual.c

    r13320 r13479  
    158158    /* make private colormap  */
    159159    if (graphic[0].Npixels < 16) {
    160       fprintf (stderr, "can't allocate enough cells, using private colormap\n");
     160      // fprintf (stderr, "can't allocate enough cells, using private colormap\n");
    161161      graphic[0].colormap = XCreateColormap (graphic[0].display, RootWindow (graphic[0].display, graphic[0].screen), graphic[0].visual, AllocNone);
    162162      for (graphic[0].Npixels = NPIXELS;
     
    178178  if (!dyn) {
    179179    graphic[0].Npixels = 256;
    180     fprintf (stderr, "can't use dynamic colors, color scrollbar inactive\n");
    181     fprintf (stderr, " this can be avoided by using a dynamic visual class\n");
    182     fprintf (stderr, " (see Kii help page for details)\n");
     180    // fprintf (stderr, "can't use dynamic colors, color scrollbar inactive\n");
     181    // fprintf (stderr, " this can be avoided by using a dynamic visual class\n");
     182    // fprintf (stderr, " (see Kii help page for details)\n");
    183183  }
    184184
  • trunk/Ohana/src/kapa2/src/CreatePicture.c

    r13320 r13479  
    5656  case 32:
    5757    REALLOCATE (image[0].picture.data, char, (4*image[0].picture.dx*image[0].picture.dy + 32));
    58     fprintf (stderr, "allocating %d for picture data\n", (4*image[0].picture.dx*image[0].picture.dy + 32));
    5958    memset (image[0].picture.data, 0xbd, 4*image[0].picture.dx*image[0].picture.dy + 30);
    6059    l = (unsigned int *) image[0].picture.data;
  • trunk/Ohana/src/kapa2/src/CreateZoom16.c

    r13320 r13479  
    11# include "Ximage.h"
    2 # define XPIX(x,Rx,S) (x*S + Rx)
    3 # define ZPIX(value,Rz1,Rz2) (value*Rz1 - Rz2)
    42# define FRAC(a) ((a) - (int)(a))
     3
     4static float slope = 1.0;
     5static float start = 0.0;
     6static int MaxValue = 255;
     7
     8// XXX inline this if needed
     9static int PixelLookup(float value) {
     10  int out;
     11  out = MIN (MAX (slope * value - start, 0), MaxValue);
     12  return (out);
     13}
    514
    615void CreateZoom16 (KapaImageWidget *image, Graphic *graphic, double x, double y) {
     
    918  int i_start, i_end, j_start, j_end;
    1019  int dropback;  /* this is a bit of a kludge... */
    11   int dx, dy, DX, DY;
     20  int dx, dy, DX, DY, pixelN;
    1221  double expand, zoomscale, Rx, Ry;
    1322  int expand_in, expand_out;
    1423  unsigned char *out_pix, *out_pix2, *data;
    15   unsigned char *in_pix,  *in_pix2;
     24  float *imdata, *in_pix,  *in_pix2;
    1625  unsigned char pixel1[256], pixel2[256];
    1726  unsigned char pixvalue1, pixvalue2;
     
    3746  back1 = 0x0000ff & back;
    3847  back2 = 0x0000ff & (back >> 8);
     48  // define the color transform parameters
     49  MaxValue = graphic[0].Npixels - 1;
     50  if (image[0].range != 0.0) {
     51    slope = graphic[0].Npixels / image[0].range;
     52    start = graphic[0].Npixels * image[0].zero / image[0].range;
     53  } else {
     54    slope = 1.0;
     55    start = image[0].zero;
     56  }
    3957
    4058  zoomscale = MAX (5, image[0].expand + 5);
     
    5674
    5775  data = out_pix = (unsigned char *) image[0].zoom.data;
    58   in_pix  = (unsigned char *) (image[0].matrix.buffer) + DX*(int)MAX(Ry,0) + (int)MAX(Rx,0);
     76  imdata  = (float *) image[0].matrix.buffer;
     77  in_pix  = &imdata[DX*(int)MAX(Ry,0) + (int)MAX(Rx,0)];
    5978
    6079  /********** below we do the mapping from buffer pixels (in) to picture pixels (out) **********/
     
    91110    if (expand_out == 1) {
    92111      for (i = i_start; i < i_end; i++, in_pix2+= expand_in, out_pix+=2) {
    93         out_pix[0] = pixel1[*in_pix2];
    94         out_pix[1] = pixel2[*in_pix2];
     112        pixelN = PixelLookup(*in_pix2);
     113        out_pix[0] = pixel1[pixelN];
     114        out_pix[1] = pixel2[pixelN];
    95115      }
    96     }
    97     else {
     116    } else {
    98117      for (i = i_start; i < i_end; i+= expand_out, in_pix2++, out_pix+= 2*expand_out) {
    99         pixvalue1 = pixel1[*in_pix2];
    100         pixvalue2 = pixel2[*in_pix2];
     118        pixelN = PixelLookup(*in_pix2);
     119        pixvalue1 = pixel1[pixelN];
     120        pixvalue2 = pixel2[pixelN];
    101121        out_pix2 = out_pix;
    102122        for (jj = 0; jj < expand_out; jj++, out_pix2+=2*(dx-expand_out)) {
     
    129149  }
    130150
    131   image[0].zoom.pix = XCreateImage (graphic[0].display, graphic[0].visual, 16, ZPixmap, 0,
    132                                         image[0].zoom.data, image[0].zoom.dx, image[0].zoom.dy, 32, 0);
     151  image[0].zoom.pix = XCreateImage (graphic[0].display, graphic[0].visual, graphic[0].depth, ZPixmap, 0,
     152                                        image[0].zoom.data, image[0].zoom.dx, image[0].zoom.dy, 16, 0);
    133153 
    134154}
  • trunk/Ohana/src/kapa2/src/CreateZoom24.c

    r13320 r13479  
    11# include "Ximage.h"
    2 # define XPIX(x,Rx,S) (x*S + Rx)
    3 # define ZPIX(value,Rz1,Rz2) (value*Rz1 - Rz2)
    42# define FRAC(a) ((a) - (int)(a))
     3
     4static float slope = 1.0;
     5static float start = 0.0;
     6static int MaxValue = 255;
     7
     8// XXX inline this if needed
     9static int PixelLookup(float value) {
     10  int out;
     11  out = MIN (MAX (slope * value - start, 0), MaxValue);
     12  return (out);
     13}
    514
    615void CreateZoom24 (KapaImageWidget *image, Graphic *graphic, double x, double y) {
     
    918  int i_start, i_end, j_start, j_end;
    1019  int dropback;  /* this is a bit of a kludge... */
    11   int dx, dy, DX, DY;
     20  int dx, dy, DX, DY, pixelN;
    1221  double expand, zoomscale, Rx, Ry;
    1322  int expand_in, expand_out;
    1423  unsigned char *out_pix, *out_pix2, *data;
    15   unsigned char *in_pix, *in_pix2;
     24  float *imdata, *in_pix, *in_pix2;
    1625  unsigned char pixel1[256], pixel2[256], pixel3[256];
    1726  unsigned char pixvalue1, pixvalue2, pixvalue3;
     
    4150  back3 = 0x0000ff & (back >> 16);
    4251
     52  // define the color transform parameters
     53  MaxValue = graphic[0].Npixels - 1;
     54  if (image[0].range != 0.0) {
     55    slope = graphic[0].Npixels / image[0].range;
     56    start = graphic[0].Npixels * image[0].zero / image[0].range;
     57  } else {
     58    slope = 1.0;
     59    start = image[0].zero;
     60  }
     61
    4362  zoomscale = MAX (5, image[0].expand + 5);
    4463  expand = 1 / zoomscale;
     
    5978
    6079  data = out_pix = (unsigned char *) image[0].zoom.data;
    61   in_pix  = (unsigned char *) (image[0].matrix.buffer) + DX*(int)MAX(Ry,0) + (int)MAX(Rx,0);
     80  imdata  = (float *) image[0].matrix.buffer;
     81  in_pix  = &imdata[DX*(int)MAX(Ry,0) + (int)MAX(Rx,0)];
    6282
    6383  /********** below we do the mapping from buffer pixels (in) to picture pixels (out) **********/
     
    97117    if (expand_out == 1) {
    98118      for (i = i_start; i < i_end; i++, in_pix2+= expand_in, out_pix+=3) {
    99         out_pix[0] = pixel1[*in_pix2];
    100         out_pix[1] = pixel2[*in_pix2];
    101         out_pix[2] = pixel3[*in_pix2];
     119        pixelN = PixelLookup(*in_pix2);
     120        out_pix[0] = pixel1[pixelN];
     121        out_pix[1] = pixel2[pixelN];
     122        out_pix[2] = pixel3[pixelN];
    102123      }
    103     }
    104     else {
     124    } else {
    105125      for (i = i_start; i < i_end; i+= expand_out, in_pix2++, out_pix+= 3*expand_out) {
    106         pixvalue1 = pixel1[*in_pix2];
    107         pixvalue2 = pixel2[*in_pix2];
    108         pixvalue3 = pixel3[*in_pix2];
     126        pixelN   = PixelLookup(*in_pix2);
     127        pixvalue1 = pixel1[pixelN];
     128        pixvalue2 = pixel2[pixelN];
     129        pixvalue3 = pixel3[pixelN];
    109130        out_pix2 = out_pix;
    110131        for (jj = 0; jj < expand_out; jj++, out_pix2+=3*(dx-expand_out)+extra) {
  • trunk/Ohana/src/kapa2/src/CreateZoom32.c

    r13320 r13479  
    11# include "Ximage.h"
    2 # define XPIX(x,Rx,S) (x*S + Rx)
    3 # define ZPIX(value,Rz1,Rz2) (value*Rz1 - Rz2)
    42# define FRAC(a) ((a) - (int)(a))
     3
     4static float slope = 1.0;
     5static float start = 0.0;
     6static int MaxValue = 255;
     7
     8// XXX inline this if needed
     9static int PixelLookup(float value) {
     10  int out;
     11  out = MIN (MAX (slope * value - start, 0), MaxValue);
     12  return (out);
     13}
    514
    615void CreateZoom32 (KapaImageWidget *image, Graphic *graphic, double x, double y) {
     
    918  int i_start, i_end, j_start, j_end;
    1019  int dropback;  /* this is a bit of a kludge... */
    11   int dx, dy, DX, DY;
     20  int dx, dy, DX, DY, pixelN;
    1221  double expand, zoomscale, Rx, Ry;
    1322  int expand_in, expand_out;
    14   unsigned int *out_pix, *out_pix2, *data;
    15   unsigned char  *in_pix, *in_pix2;
     23  unsigned int *out_pix, *out_pix2;
     24  float *imdata, *in_pix, *in_pix2;
    1625  unsigned long pixel[256], pixvalue;
    1726  unsigned long back;
     
    2837  }
    2938  back = graphic[0].back;
     39
     40  // define the color transform parameters
     41  MaxValue = graphic[0].Npixels - 1;
     42  if (image[0].range != 0.0) {
     43    slope = graphic[0].Npixels / image[0].range;
     44    start = graphic[0].Npixels * image[0].zero / image[0].range;
     45  } else {
     46    slope = 1.0;
     47    start = image[0].zero;
     48  }
    3049
    3150  zoomscale = MAX (5, image[0].expand + 5);
     
    4968
    5069  out_pix = (unsigned int *) image[0].zoom.data;
    51   data = (unsigned int *) image[0].zoom.data;
    52   in_pix  = (unsigned char *) (image[0].matrix.buffer) + DX*(int)MAX(Ry,0) + (int)MAX(Rx,0);
     70  imdata  = (float *) image[0].matrix.buffer;
     71  in_pix  = &imdata[DX*(int)MAX(Ry,0) + (int)MAX(Rx,0)];
    5372
    5473  /********** below we do the mapping from buffer pixels (in) to picture pixels (out) **********/
     
    81100    if (expand_out == 1) {
    82101      for (i = i_start; i < i_end; i++, in_pix2+= expand_in, out_pix++) {
    83         out_pix[0] = pixel[*in_pix2];
     102        pixelN = PixelLookup(*in_pix2);
     103        out_pix[0] = pixel[pixelN];
    84104      }
    85105    }
    86106    else {
    87107      for (i = i_start; i < i_end; i+= expand_out, in_pix2++, out_pix+= expand_out) {
    88         pixvalue = *(pixel + *in_pix2);
     108        pixelN   = PixelLookup(*in_pix2);
     109        pixvalue = pixel[pixelN];
    89110        out_pix2 = out_pix;
    90111        for (jj = 0; jj < expand_out; jj++, out_pix2+=(dx-expand_out)) {
  • trunk/Ohana/src/kapa2/src/CreateZoom8.c

    r13320 r13479  
    11# include "Ximage.h"
    2 # define XPIX(x,Rx,S) (x*S + Rx)
    3 # define ZPIX(value,Rz1,Rz2) (value*Rz1 - Rz2)
    42# define FRAC(a) ((a) - (int)(a))
     3
     4static float slope = 1.0;
     5static float start = 0.0;
     6static int MaxValue = 255;
     7
     8// XXX inline this if needed
     9static int PixelLookup(float value) {
     10  int out;
     11  out = MIN (MAX (slope * value - start, 0), MaxValue);
     12  return (out);
     13}
    514
    615void CreateZoom8 (KapaImageWidget *image, Graphic *graphic, double x, double y) {
     
    918  int i_start, i_end, j_start, j_end;
    1019  int dropback;  /* this is a bit of a kludge... */
    11   int dx, dy, DX, DY;
     20  int dx, dy, DX, DY, pixelN;
    1221  double expand, zoomscale, Rx, Ry;
    1322  int expand_in, expand_out;
    14   char *out_pix, *out_pix2;
    15   char  *in_pix, *in_pix2;
     23  unsigned char *out_pix, *out_pix2;
     24  float *imdata, *in_pix, *in_pix2;
    1625  unsigned long pixel[256], pixvalue;
    1726  unsigned long back;
     
    3039  back = graphic[0].back;
    3140
     41  // define the color transform parameters
     42  MaxValue = graphic[0].Npixels - 1;
     43  if (image[0].range != 0.0) {
     44    slope = graphic[0].Npixels / image[0].range;
     45    start = graphic[0].Npixels * image[0].zero / image[0].range;
     46  } else {
     47    slope = 1.0;
     48    start = image[0].zero;
     49  }
     50
    3251  zoomscale = MAX (5, image[0].expand + 5);
    3352  expand = 1 / zoomscale;
    3453  expand_out = (int) zoomscale;
    3554  expand_in  = 1;
    36 
    37   /*
    38   dx = image[0].zoom.dx;
    39   dy = image[0].zoom.dy;
    40   DX = image[0].matrix.Naxis[0];
    41   DY = image[0].matrix.Naxis[1];
    42   Rx = 0.5*(DX - (dx - 1)*expand) - x;
    43   Ry = 0.5*(DY - (dy - 1)*expand) - y;
    44   data coords of 0,0 point in pic array
    45   X = 0.5*image[0].matrix.Naxis[0] - expand*((int)(0.5*image[0].zoom.dx + 0.5) - 0.0) - image[0].X;
    46   Y = 0.5*image[0].matrix.Naxis[1] - expand*((int)(0.5*image[0].zoom.dy + 0.5) - 0.0) - image[0].Y; 
    47   i_start = MIN (MAX (-Rx / expand, 0), dx - expand_out + 1);
    48   j_start = MIN (MAX (-Ry / expand, 0), dy - expand_out + 1);
    49   i_end   = MAX (MIN ((DX-Rx) / expand, dx - expand_out + 1), 0);
    50   j_end   = MAX (MIN ((DY-Ry) / expand, dy - expand_out + 1), 0);
    51   dropback = expand_out - (i_end - i_start) % expand_out;
    52   if ((i_end - i_start) % expand_out == 0) dropback = 0;
    53 
    54   out_pix = image[0].zoom.data;
    55   in_pix  = (char *) (image[0].matrix.buffer) + DX*(int)MAX(Y,0) + (int)MAX(X,0);
    56 
    57   */
    5855
    5956  dx = image[0].zoom.dx;
     
    7269
    7370  out_pix = (char *) image[0].zoom.data;
    74   in_pix  = (char *) (image[0].matrix.buffer) + DX*(int)MAX(Ry,0) + (int)MAX(Rx,0);
     71  imdata  = (float *) image[0].matrix.buffer;
     72  in_pix  = &imdata[DX*(int)MAX(Ry,0) + (int)MAX(Rx,0)];
    7573
    7674  /********** below we do the mapping from buffer pixels (in) to picture pixels (out) **********/
     
    10098    in_pix2 = in_pix;
    10199    if (expand_out == 1) {
    102       for (i = i_start; i < i_end; i++, in_pix2+= expand_in, out_pix++)
    103         *out_pix = *(pixel + *in_pix2);
    104     }
    105     else {
     100      for (i = i_start; i < i_end; i++, in_pix2+= expand_in, out_pix++) {
     101        pixelN = PixelLookup(*in_pix2);
     102        *out_pix = pixel[pixelN];
     103      }
     104    } else {
    106105      for (i = i_start; i < i_end; i+= expand_out, in_pix2++, out_pix+= expand_out) {
    107         pixvalue = *(pixel + *in_pix2);
     106        pixelN   = PixelLookup(*in_pix2);
     107        pixvalue = pixel[pixelN];
    108108        out_pix2 = out_pix;
    109109        for (jj = 0; jj < expand_out; jj++, out_pix2+=(dx-expand_out)) {
     
    131131 
    132132  /**** fill in top area ****/
    133   for (j = 0; (j < dx*(dy - j_end)) && (out_pix - image[0].zoom.data < dx*dy); j++, out_pix++) {
     133  for (j = 0; (j < dx*(dy - j_end)) && (out_pix - (unsigned char *) image[0].zoom.data < dx*dy); j++, out_pix++) {
    134134    *out_pix = back;
    135135  }
  • trunk/Ohana/src/kapa2/src/DefineSection.c

    r13320 r13479  
    11# include "Ximage.h"
    22
    3 int DefineSection () {
     3// define the section, but do not create a graph or image
     4int DefineSection (int sock) {
    45 
    56  int i, N, MoveSection;
     
    1516  if (N < 0) {
    1617    section = AddSection (name, x, y, dx, dy);
    17     section->graph = InitGraph ();
    1818    MoveSection = TRUE;
    1919  } else {
     
    3333
    3434  if (MoveSection) {
    35     SetGraphSize (section);
     35    SetSectionSizes (section);
    3636    Refresh (1);
    3737  }
  • trunk/Ohana/src/kapa2/src/EraseCurrentPlot.c

    r13320 r13479  
    1111  section = GetActiveSection();
    1212  if (section->graph == NULL) return (TRUE);
     13
    1314  EraseGraph (section->graph);
    1415 
  • trunk/Ohana/src/kapa2/src/EraseOverlay.c

    r13331 r13479  
    11# include "Ximage.h"
    22
    3 int EraseOverlay () {
     3int EraseOverlay (int sock) {
    44
    55  char buffer[256];
     
    1212  section = GetActiveSection();
    1313  image = section->image;
     14  if (image == NULL) return (TRUE);
    1415
    1516  KiiScanCommand (sock, 16, "%*s %d", &N);
    1617
    1718  if (N > NOVERLAYS) {
    18     REALLOCATE (image[0].tickmarks.objects, Object, 1);
     19    REALLOCATE (image[0].tickmarks.objects, KiiOverlay, 1);
    1920    image[0].tickmarks.Nobjects = 0;
    2021  } else {
    2122    for (i = 0; i < image[0].overlay[N].Nobjects; i++) {
    22       if (!strcmp (image[0].overlay[N].objects[i].type, "TEXT")) {
     23      if (image[0].overlay[N].objects[i].type == KII_OVERLAY_TEXT) {
    2324        free (image[0].overlay[N].objects[i].text);
    2425      }
    2526    }
    26     REALLOCATE (image[0].overlay[N].objects, Object, 1);
     27    REALLOCATE (image[0].overlay[N].objects, KiiOverlay, 1);
    2728    image[0].overlay[N].Nobjects = 0;
    2829    image[0].overlay[N].active = FALSE;
  • trunk/Ohana/src/kapa2/src/GetPixelCount.c

    r13320 r13479  
    11# include "Ximage.h"
    22
    3 int GetPixelCount () {
     3int GetPixelCount (int sock) {
    44 
    55  int i;
  • trunk/Ohana/src/kapa2/src/Graphs.c

    r13320 r13479  
    2020    strcpy (graph[0].label[i].text, "");
    2121  }
     22
     23  graph[0].data.xmin = 0.0;
     24  graph[0].data.xmax = 1.0;
     25  graph[0].data.ymin = 0.0;
     26  graph[0].data.ymax = 1.0;
    2227
    2328  graph[0].Nobjects = 0;
     
    100105  FREE (graph[0].objects);
    101106  FREE (graph[0].textline);
     107  free (graph);
    102108  return;
    103109}
  • trunk/Ohana/src/kapa2/src/Image.c

    r13331 r13479  
    2121  image[0].start = 0;
    2222  image[0].slope = 1;
     23  image[0].location = 4;
    2324
    2425  image[0].coords.Npolyterms = 0;
    2526  for (i = 0; i < NOVERLAYS; i++) {
    2627    image[0].overlay[i].Nobjects = 0;
    27     ALLOCATE (image[0].overlay[i].objects, Object, 1);  /* allocate so later free will not crash! */
     28    ALLOCATE (image[0].overlay[i].objects, KiiOverlay, 1);  /* allocate so later free will not crash! */
    2829    image[0].overlay[i].active = FALSE;
    2930    image[0].overlay[i].color = graphic[0].overlay_color[i];
     
    9697  graphic = GetGraphic ();
    9798
    98   XSetForeground (graphic[0].display, graphic[0].gc, graphic[0].fore);
    99   XDrawRectangle (graphic[0].display, graphic[0].window, graphic[0].gc,
    100                   image[0].picture.x, image[0].picture.y,
    101                   image[0].picture.dx + 1, image[0].picture.dy + 1);
     99  XSetForeground (graphic[0].display,  graphic[0].gc, graphic[0].fore);
     100  XDrawRectangle (graphic[0].display,  graphic[0].window, graphic[0].gc,
     101                  image[0].picture.x,  image[0].picture.y,
     102                  image[0].picture.dx+1, image[0].picture.dy+1);
    102103 
    103104  XPutImage (graphic[0].display, graphic[0].window, graphic[0].gc,
     
    106107             image[0].picture.dx, image[0].picture.dy);
    107108
    108   XPutImage (graphic[0].display, graphic[0].window, graphic[0].gc,
    109              image[0].cmapbar.pix, 0, 0,
    110              image[0].cmapbar.x, image[0].cmapbar.y,
    111              image[0].cmapbar.dx, image[0].cmapbar.dy);
    112 
    113   CrossHairs (graphic, image);
    114 
    115109  for (i = 0; i < NOVERLAYS; i++) {
    116110    if (image[0].overlay[i].active) {
     
    118112    }
    119113  }
    120 # if (0)
    121   PaintTickmarks (graphic, image);
    122 # endif
    123114
    124   // XXX make this optional?a
    125   if (1) {
     115  if (image[0].location) {
     116    XPutImage (graphic[0].display, graphic[0].window, graphic[0].gc,
     117               image[0].cmapbar.pix, 0, 0,
     118               image[0].cmapbar.x, image[0].cmapbar.y,
     119               image[0].cmapbar.dx, image[0].cmapbar.dy);
     120
     121    CrossHairs (graphic, image);
     122 
    126123    /* erase everything below zoom box, then draw */
     124    /*
    127125    XSetForeground (graphic[0].display, graphic[0].gc, graphic[0].back);
    128126    XFillRectangle (graphic[0].display, graphic[0].window, graphic[0].gc,
    129                     image[0].text_x, image[0].text_x, image[0].zoom.dx, graphic[0].dy);
    130    
     127                    image[0].text_x, image[0].text_x, image[0].text_dx, image[0].text_dy);
     128    */   
    131129    DrawButton (graphic, &image[0].PS_button);
    132130    DrawButton (graphic, &image[0].recenter_button);
     
    139137      DrawButton (graphic, &image[0].overlay_button[i]);
    140138    }
     139    StatusBox (graphic, image);
    141140  }
    142 
    143   StatusBox (graphic, image);
    144141
    145142  FlushDisplay (graphic[0].display);
    146143}
     144
     145void FreeImage (KapaImageWidget *image) {
     146
     147  int i;
     148
     149  if (image == NULL) return;
     150
     151  for (i = 0; i < NOVERLAYS; i++) {
     152    free (image[0].overlay[i].objects);
     153  }
     154  free (image[0].matrix.buffer);
     155  free (image[0].picture.data);
     156  free (image[0].cmapbar.data);
     157  free (image[0].zoom.data);
     158
     159  free (image);
     160}
  • trunk/Ohana/src/kapa2/src/InterpretKeys.c

    r13333 r13479  
    33int InterpretKeys (Graphic *graphic, XKeyEvent *event) {
    44
    5   double           X, Y, offset;
    6   int              modstate;
     5  float           *imdata;
     6  double           X, Y, Z, R, D, offset;
     7  int              sock, DX, DY, modstate;
    78  char            *name, string[16], line[40];
    89  KeySym           keysym;
     
    2324  // XXX allow user to choose graph or image coords
    2425  if (ACTIVE_CURSOR) {
     26
     27    sock = GetActiveSocket ();
     28    if (sock == -1) goto skip_cursor;
     29
    2530    name = XKeysymToString (keysym);
    2631
     
    4348    if (!strcmp (name, "(null)")) goto skip_cursor;
    4449
     50    Z = -1;
     51
    4552    if (graph) {
    4653      X = (event[0].x - graph[0].axis[0].fx)*(graph[0].axis[0].max - graph[0].axis[0].min)/graph[0].axis[0].dfx + graph[0].axis[0].min;
    4754      Y = (event[0].y - graph[0].axis[1].fy)*(graph[0].axis[1].max - graph[0].axis[1].min)/graph[0].axis[1].dfy + graph[0].axis[1].min;
     55      XY_to_RD (&R, &D, X, Y, &graph[0].data.coords);
    4856    }
    4957    if (image && !graph) {
     
    5361      if (event[0].y > image[0].picture.y + image[0].picture.dy) goto skip_cursor;
    5462      Screen_to_Image (&X, &Y, (double)event[0].x, (double)event[0].y, image);
     63      XY_to_RD (&R, &D, X, Y, &image[0].coords);
     64
     65      DX = image[0].matrix.Naxis[0];
     66      DY = image[0].matrix.Naxis[1];
     67
     68      if (X < 0) goto off_image;
     69      if (Y < 0) goto off_image;
     70      if (X >= DX) goto off_image;
     71      if (Y >= DY) goto off_image;
     72      imdata = (float *) image[0].matrix.buffer;
     73      Z      = imdata[DX*(int)(Y) + (int)(X)];
    5574    }
    56     snprintf (line, 40, "%12s %12.6f %12.6f ", name, X, Y);
    57     write (sock, line, 40);
     75  off_image:
     76    KiiSendMessage (sock, "%12s %12.6f %12.6f %12.6f %12.6f %12.6f", name, X, Y, Z, R, D);
    5877  }
    5978
    6079skip_cursor:
     80  if (image == NULL) return (TRUE);
     81
    6182  // offset is in image pixels:
    6283  // 0.5 image pixels is 1 screen pixel for expand == +2
  • trunk/Ohana/src/kapa2/src/InterpretPresses.c

    r13333 r13479  
    33int InterpretPresses (Graphic *graphic, XButtonEvent *event) {
    44
    5   int              status, done, this_button, old_cursor;
     5  int              sock, DX, DY, status, done, this_button, old_cursor;
    66  char             name[16], line[40];
    7   double           X, Y;
     7  double           X, Y, Z, R, D;
     8  float           *imdata;
    89  KeySym           keysym;
    910  Button          *button;
     
    2021  // XXX allow user to choose graph or image coords
    2122  if (ACTIVE_CURSOR) {
     23    sock = GetActiveSocket ();
     24    if (sock == -1) goto skip_cursor;
     25
    2226    sprintf (name, "Button%d", event[0].button);
    2327    if (graph) {
    2428      X = (event[0].x - graph[0].axis[0].fx)*(graph[0].axis[0].max - graph[0].axis[0].min)/graph[0].axis[0].dfx + graph[0].axis[0].min;
    2529      Y = (event[0].y - graph[0].axis[1].fy)*(graph[0].axis[1].max - graph[0].axis[1].min)/graph[0].axis[1].dfy + graph[0].axis[1].min;
     30      XY_to_RD (&R, &D, X, Y, &graph[0].data.coords);
    2631    }
    2732    if (image && !graph) {
     
    3035      if (event[0].x > image[0].picture.x + image[0].picture.dx) goto skip_cursor;
    3136      if (event[0].y > image[0].picture.y + image[0].picture.dy) goto skip_cursor;
    32        
    3337      Screen_to_Image (&X, &Y, (double)event[0].x, (double)event[0].y, image);
     38
     39      XY_to_RD (&R, &D, X, Y, &image[0].coords);
     40
     41      DX = image[0].matrix.Naxis[0];
     42      DY = image[0].matrix.Naxis[1];
     43
     44      if (X < 0) goto off_image;
     45      if (Y < 0) goto off_image;
     46      if (X >= DX) goto off_image;
     47      if (Y >= DY) goto off_image;
     48      imdata = (float *) image[0].matrix.buffer;
     49      Z      = imdata[DX*(int)(Y) + (int)(X)];
    3450    }
    35     snprintf (line, 40, "%12s %12.6f %12.6f ", name, X, Y);
    36     write (sock, line, 40);
     51  off_image:
     52    KiiSendMessage (sock, "%12s %12.6f %12.6f %12.6f %12.6f %12.6f", name, X, Y, Z, R, D);
    3753  }
    3854
     
    4056  status = TRUE;
    4157  this_button = event[0].button;
     58
     59  // XXX add graph buttons here
     60  if (image == NULL) return (TRUE);
    4261 
    4362  if ((event[0].type == ButtonPress) && InPicture (event, &image[0].picture)) {
  • trunk/Ohana/src/kapa2/src/JPEGit24.c

    r13320 r13479  
    66# define WHITE_B 255
    77
    8 // XXX this currently writes out the jpeg for the active image
    9 int JPEGit24 () {
     8static float slope = 1.0;
     9static float start = 0.0;
     10static int MaxValue = 255;
     11
     12// XXX inline this if needed
     13static int PixelLookup(float value) {
     14  int out;
     15  out = MIN (MAX (slope * value - start, 0), MaxValue);
     16  return (out);
     17}
     18
     19// XXX this currently writes out the jpeg for just the active image
     20int JPEGit24 (int sock) {
    1021
    1122  struct jpeg_compress_struct cinfo;
     
    2132  int i_start, i_end, j_start, j_end;
    2233  int dropback;  /* this is a bit of a kludge... */
    23   int dx, dy, DX, DY;
     34  int dx, dy, DX, DY, pixelN;
    2435  int status, Nbytes, quality;
    2536  int expand_in, expand_out;
    2637  double expand, Rx, Ry, X, Y;
    27   unsigned char *out_pix, *in_pix, *in_pix_ref;
     38  unsigned char *out_pix;
     39  float *imdata, *in_pix, *in_pix_ref;
    2840  unsigned char pixel1[256], pixel2[256], pixel3[256];
    2941  char filename[1024];
    3042  FILE *f;
    3143
     44  /* expect a line telling the number of bytes and a filename */
     45  KiiScanMessage (sock, "%s", filename);
     46
    3247  graphic = GetGraphic();
    3348  section = GetActiveSection();
    3449  image   = section->image;
    35 
    36   /* expect a line telling the number of bytes and a filename */
    37   KiiScanMessage (sock, "%s", filename);
     50  if (image == NULL) return (TRUE);
    3851
    3952  /***** JPEG init calls */
     
    6982  }
    7083
     84  // define the color transform parameters
     85  MaxValue = graphic[0].Npixels - 1;
     86  if (image[0].range != 0.0) {
     87    slope = graphic[0].Npixels / image[0].range;
     88    start = graphic[0].Npixels * image[0].zero / image[0].range;
     89  } else {
     90    slope = 1.0;
     91    start = image[0].zero;
     92  }
     93
    7194  expand = expand_in = expand_out = 1.0;
    7295  if (image[0].expand == 0) /* set up expansions */
     
    122145  ALLOCATE (line_buffer, JSAMPLE, 3*dx);
    123146
    124   in_pix_ref  = (unsigned char *) (image[0].matrix.buffer) + DX*(int)MAX(Y,0) + (int)MAX(X,0);
     147  imdata = (float *) image[0].matrix.buffer;
     148  in_pix_ref = &imdata[DX*(int)MAX(Y,0) + (int)MAX(X,0)];
    125149
    126150  /********** below we do the mapping from buffer pixels (in) to picture pixels (out) **********/
     
    153177    /*** fill in the picture region ***/
    154178    for (i = i_start; i < i_end; i+=expand_out, in_pix+=expand_in) {
     179      pixelN = PixelLookup(*in_pix);
    155180      for (ii = 0; ii < expand_out; ii++, out_pix+=3) {
    156         out_pix[0] = pixel1[*in_pix];
    157         out_pix[1] = pixel2[*in_pix];
    158         out_pix[2] = pixel3[*in_pix];
     181        out_pix[0] = pixel1[pixelN];
     182        out_pix[1] = pixel2[pixelN];
     183        out_pix[2] = pixel3[pixelN];
    159184      }
    160185    }
  • trunk/Ohana/src/kapa2/src/Layout.c

    r13333 r13479  
    44void InitLayout (int argc, char **argv) {
    55
    6   int N, UseGraph;
     6  int N;
    77  Section *section;
    88
    9   UseGraph = FALSE;
    10   if ((N = get_argument (argc, argv, "-image"))) {
    11     remove_argument(N, &argc, argv);
    12     UseGraph = FALSE;
    13   }
    14 
    15   /** initiate connection with server **/
    16   if (!FOREGROUND) {   
    17     if (argc < 2) {
    18       fprintf (stderr, "socket path not specified\n");
    19       exit (0);
    20     }
    21     sock = KiiWait (argv[1]);
    22   }
     9  InitPipe();
    2310
    2411  ACTIVE_CURSOR = FALSE;
     
    3724  }
    3825
     26  /* move this out of here... */
     27  if (argc != 1) {
     28    fprintf (stderr, "USAGE: kapa\n");
     29    exit (0);
     30  }
     31
    3932  InitRotFonts ();
    4033
    41   /* create basic section */
     34  /* create basic section, empty of image or graph */
    4235  section = AddSection ("default", 0.0, 0.0, 1.0, 1.0);
    43   if (UseGraph) {
    44     section->graph = InitGraph ();
    45     SetGraphSize (section);
    46   } else {
    47     section->image = InitImage ();
    48     SetImageSize (section);
    49   }
    5036}
  • trunk/Ohana/src/kapa2/src/LoadFrame.c

    r13320 r13479  
    11# include "Ximage.h"
    22
    3 int LoadFrame () {
     3int LoadFrame (int sock) {
    44 
    55  int i, status;
     
    99
    1010  section = GetActiveSection();
     11  if (section->graph == NULL) {
     12    section->graph = InitGraph ();
     13    SetSectionSizes (section);
     14  }
    1115  graph = section->graph;
    1216
    13   // XXX what to do if graph is NULL?
    14  
    1517  KiiScanMessage (sock, "%lf %lf %lf %lf",
    1618                  &graph[0].axis[0].min, &graph[0].axis[0].max,
     
    6062  }
    6163
     64  SetSectionSizes (section);
    6265  if (USE_XWINDOW) DrawFrame (graph);
    6366  FlushDisplay ();
  • trunk/Ohana/src/kapa2/src/LoadLabels.c

    r13320 r13479  
    11# include "Ximage.h"
    22
    3 int LoadLabels () {
     3int LoadLabels (int sock) {
    44 
    55  char *c, *label;
     
    99
    1010  section = GetActiveSection();
     11  if (section->graph == NULL) {
     12    section->graph = InitGraph ();
     13    SetSectionSizes (section);
     14  }
    1115  graph = section->graph;
    12  
    13   fcntl (sock, F_SETFL, !O_NONBLOCK); 
    1416 
    1517  KiiScanMessage (sock, "%d", &mode);
     
    2123  strncpy (graph[0].label[mode].text, label, Nbytes);
    2224  label[Nbytes] = 0;
    23 
    24   fcntl (sock, F_SETFL, O_NONBLOCK); 
    2525 
    2626  c = GetRotFont (&size);
  • trunk/Ohana/src/kapa2/src/LoadObject.c

    r13320 r13479  
    11# include "Ximage.h"
    22# include <errno.h>
    3 
    4 int LoadObject () {
     3# define DEBUG 0
     4
     5int LoadObject (int sock) {
    56 
    67  int N;
     
    910
    1011  section = GetActiveSection();
     12  if (section->graph == NULL) {
     13    section->graph = InitGraph ();
     14    SetSectionSizes (section);
     15  }
    1116  graph = section->graph;
    12  
    13   fcntl (sock, F_SETFL, !O_NONBLOCK); 
    1417 
    1518  N = graph[0].Nobjects;
     
    4144                  &graph[0].objects[N].x0, &graph[0].objects[N].x1,
    4245                  &graph[0].objects[N].y0, &graph[0].objects[N].y1);
    43  
    44   fcntl (sock, F_SETFL, O_NONBLOCK); 
    45  
    46   if (!LoadVectorData (graph, N, "x")) {
     46
     47  // acknowledge receipt of the metadata
     48  KiiSendCommand (sock, 4, "DONE");
     49 
     50  // XXX Currently, I require these in a special order.  The data includes a message defining the
     51  // object type.  This could be made more flexible by using the information (though we still need
     52  // to know how many items will be sent)
     53
     54  if (!LoadVectorData (sock, graph, N, "x")) {
    4755    FreeObjectData (&graph[0].objects[N]);
    4856    graph[0].Nobjects --;
     
    5058  }
    5159   
    52   if (!LoadVectorData (graph, N, "y")) {
     60  if (!LoadVectorData (sock, graph, N, "y")) {
    5361    FreeObjectData (&graph[0].objects[N]);
    5462    graph[0].Nobjects --;
     
    5664  }
    5765  if (graph[0].objects[N].size < 0.0) {
    58     if (!LoadVectorData (graph, N, "z")) {
     66    if (!LoadVectorData (sock, graph, N, "z")) {
    5967      FreeObjectData (&graph[0].objects[N]);
    6068      graph[0].Nobjects --;
     
    6371  }
    6472  if (graph[0].objects[N].etype & 0x01) {
    65     if (!LoadVectorData (graph, N, "dym")) {
    66       FreeObjectData (&graph[0].objects[N]);
    67       graph[0].Nobjects --;
    68       REALLOCATE (graph[0].objects, Gobjects, MAX (1, graph[0].Nobjects));
    69     }
    70     if (!LoadVectorData (graph, N, "dyp")) {
     73    if (!LoadVectorData (sock, graph, N, "dym")) {
     74      FreeObjectData (&graph[0].objects[N]);
     75      graph[0].Nobjects --;
     76      REALLOCATE (graph[0].objects, Gobjects, MAX (1, graph[0].Nobjects));
     77    }
     78    if (!LoadVectorData (sock, graph, N, "dyp")) {
    7179      FreeObjectData (&graph[0].objects[N]);
    7280      graph[0].Nobjects --;
     
    7583  }
    7684  if (graph[0].objects[N].etype & 0x02) {
    77     if (!LoadVectorData (graph, N, "dxm")) {
    78       FreeObjectData (&graph[0].objects[N]);
    79       graph[0].Nobjects --;
    80       REALLOCATE (graph[0].objects, Gobjects, MAX (1, graph[0].Nobjects));
    81     }
    82     if (!LoadVectorData (graph, N, "dxp")) {
     85    if (!LoadVectorData (sock, graph, N, "dxm")) {
     86      FreeObjectData (&graph[0].objects[N]);
     87      graph[0].Nobjects --;
     88      REALLOCATE (graph[0].objects, Gobjects, MAX (1, graph[0].Nobjects));
     89    }
     90    if (!LoadVectorData (sock, graph, N, "dxp")) {
    8391      FreeObjectData (&graph[0].objects[N]);
    8492      graph[0].Nobjects --;
     
    96104}
    97105
    98 /* load data for the named component */
    99 int LoadVectorData (KapaGraphWidget *graph, int N, char *type) {
    100  
    101   int Npts, Ninpts, status, Ntry;
     106int LoadVectorData (int sock, KapaGraphWidget *graph, int N, char *type) {
     107 
     108  int i, Npts, Ninpts, status, Ntry;
    102109  int bytes_left;
    103   char *buff;
    104 
    105   buff = NULL;
     110  char *byte, *buffer, type_send[16], tmp;
     111  int Npts_send, Nbytes_send, swap_client, swap_host;
     112
     113  buffer = NULL;
    106114  Npts = graph[0].objects[N].Npts;
     115
     116  KiiWaitAnswer (sock, "PLOB");
     117  KiiScanMessage (sock, "%s %d %d %d", type_send, &Npts_send, &Nbytes_send, &swap_client);
     118  if (strcmp (type, type_send)) {
     119    fprintf (stderr, "Kapa Communication error: unexpected data type %s vs %s\n", type_send, type);
     120  }
     121  if (Npts_send != Npts) {
     122    fprintf (stderr, "Kapa Communication error: unexpected number of points %d vs %d\n", Npts_send, Npts);
     123  }
     124  if (Nbytes_send != Npts_send*sizeof(float)) {
     125    fprintf (stderr, "Kapa Communication error: unexpected data size %d vs %d\n", Nbytes_send, Npts_send*sizeof(float));
     126  }
     127
    107128  status = 1;
    108129  if (!strcmp (type, "x")) {
    109130    ALLOCATE (graph[0].objects[N].x, float, MAX (1, Npts));
    110     buff = (char *) graph[0].objects[N].x;
     131    buffer = (char *) graph[0].objects[N].x;
    111132  }
    112133  if (!strcmp (type, "y")) {
    113134    ALLOCATE (graph[0].objects[N].y, float, MAX (1, Npts));
    114     buff = (char *) graph[0].objects[N].y;
     135    buffer = (char *) graph[0].objects[N].y;
    115136  }
    116137  if (!strcmp (type, "z")) {
    117138    ALLOCATE (graph[0].objects[N].z, float, MAX (1, Npts));
    118     buff = (char *) graph[0].objects[N].z;
     139    buffer = (char *) graph[0].objects[N].z;
    119140  }
    120141  if (!strcmp (type, "dxm")) {
    121142    ALLOCATE (graph[0].objects[N].dxm, float, MAX (1, Npts));
    122     buff = (char *) graph[0].objects[N].dxm;
     143    buffer = (char *) graph[0].objects[N].dxm;
    123144  }
    124145  if (!strcmp (type, "dxp")) {
    125146    ALLOCATE (graph[0].objects[N].dxp, float, MAX (1, Npts));
    126     buff = (char *) graph[0].objects[N].dxp;
     147    buffer = (char *) graph[0].objects[N].dxp;
    127148  }
    128149  if (!strcmp (type, "dym")) {
    129150    ALLOCATE (graph[0].objects[N].dym, float, MAX (1, Npts));
    130     buff = (char *) graph[0].objects[N].dym;
     151    buffer = (char *) graph[0].objects[N].dym;
    131152  }
    132153  if (!strcmp (type, "dyp")) {
    133154    ALLOCATE (graph[0].objects[N].dyp, float, MAX (1, Npts));
    134     buff = (char *) graph[0].objects[N].dyp;
     155    buffer = (char *) graph[0].objects[N].dyp;
    135156  }
    136157
    137158  bytes_left = Npts*sizeof (float);
    138159
     160  fcntl (sock, F_SETFL, O_NONBLOCK); 
     161
     162  // read the vector data as raw binary in client machine byte order (floats)
    139163  Ntry = 0;
    140164  if (DEBUG) fprintf (stderr, "starting vector load\n");
    141165  Ninpts = 0;
     166  byte = buffer;
    142167  while (bytes_left > 0) {
    143     status = read (sock, buff, bytes_left);
     168    status = read (sock, byte, bytes_left);
    144169    if (DEBUG) fprintf (stderr, "status: %d, %d\n", status, bytes_left);
    145170    if (status == 0) {  /* No more pipe */
     
    150175      Ninpts += status;
    151176      bytes_left -= status;
    152       buff = (char *)(buff + status);
     177      byte = (char *)(byte + status);
    153178      Ntry = 0;
    154179      continue;
     
    165190    perror ("kapa load");
    166191  }
     192
     193  fcntl (sock, F_SETFL, !O_NONBLOCK); 
     194  KiiSendCommand (sock, 4, "DONE");
     195
     196# ifdef BYTE_SWAP
     197  swap_host = 1;
     198# else
     199  swap_host = 0;
     200# endif 
     201
     202  // if host and client have opposite swap parities, word swap the incoming data
     203  // SWAP_WORD is strangely defined... it takes the number of the start byte in a
     204  // buffer called 'byte'
     205  if ((swap_host && !swap_client) || (!swap_host && swap_client)) {
     206    byte = buffer;
     207    for (i = 0; i < Nbytes_send; i+=4) {
     208      SWAP_WORD (i);
     209    }
     210  }
     211
    167212  if (Ninpts != Npts*sizeof(float)) { 
    168213    fprintf (stderr, "error: expected %d bytes, but got only %d\n", Ninpts, (unsigned int)(Npts*sizeof(float)));
     
    185230  if (object[0].dyp != (float *) NULL) free (object[0].dyp);
    186231}
    187 
  • trunk/Ohana/src/kapa2/src/LoadOverlay.c

    r13331 r13479  
    11# include "Ximage.h"
    22
    3 // XXX this is a very inefficient method to send the data: binary would be better
    4 int LoadOverlay () {
     3int LoadOverlay (int sock) {
    54 
    6   char word[17], type[16], string[128];
    7   char *buffer, *buff;
    8   double x, y, dx, dy;
    9   int Nin, bytes, status;
    10   int i, N, NOBJECTS, Nobjects, Nstart;
     5  int i, j, Ntotal, Nbytes, Nread, Nfound, Ntext, Nobjects, overnum;
     6  int Noverlay, NOVERLAY, Ntextdata;
     7  char *textdata, *buffer, *p, *q;
    118  Section *section;
    129  KapaImageWidget *image;
    1310  Graphic *graphic;
     11  KiiOverlayBase *overlay;
    1412
    1513  graphic = GetGraphic ();
    1614  section = GetActiveSection();
    17   image   = section->image;
     15  if (section->image == NULL) {
     16    section->image = InitImage ();
     17    SetSectionSizes (section);
     18  }
     19  image = section->image;
    1820
    19   ALLOCATE (buffer, char, 65536);  /* space for 512 lines of 128 bytes */
    20   bzero (buffer, 65536);
     21  KiiScanMessage (sock, "%d %d %d %d", &overnum, &Noverlay, &Ntext, &Ntextdata);
    2122
    22   KiiScanCommand (sock, 16, "%*s %d", &N);
    23   Nstart = image[0].overlay[N].Nobjects;
     23  // XXX need to validate overnum
     24  if ((overnum < 0) || (overnum >= NOVERLAYS)) overnum = 0;
    2425
    25   while (1) {
    26     KiiScanCommand (sock, 16, "%s %d", word, &Nin);
    27     if (!strcmp (word, "DONE")) break;
    28     if (strcmp (word, "NLINES")) abort();
     26  // read the overlay data as binary
     27  Ntotal = 0;
     28  Nbytes = Noverlay*sizeof(KiiOverlayBase);
     29  fcntl (sock, F_SETFL, O_NONBLOCK); 
     30  ALLOCATE (overlay, KiiOverlayBase, Noverlay);
     31  buffer = (char *) overlay;
     32  while (Nbytes > 0) {
     33    Nread = read (sock, &buffer[Ntotal], Nbytes);
     34    // fprintf (stderr, "read: %d of %d remaining, %d so far, %d expected\n", Nread, Nbytes, Ntotal, Noverlay*sizeof(KiiOverlayBase));
     35    if (Nread == 0) {  /* No more pipe */
     36      fprintf (stderr, "error: pipe closed\n");
     37      free (overlay);
     38      fcntl (sock, F_SETFL, !O_NONBLOCK); 
     39      return (FALSE);
     40    }
     41    if (Nread != -1) { /* pipe has data */
     42      Nbytes -= Nread;
     43      Ntotal += Nread;
     44    }
     45  }
     46  fcntl (sock, F_SETFL, !O_NONBLOCK); 
     47  KiiSendCommand (sock,  4, "DONE");
    2948
    30     buff = buffer;
    31     bytes = 128*Nin;
     49  // read the textdata as binary
     50  Ntotal = 0;
     51  Nbytes = Ntextdata;
     52  fcntl (sock, F_SETFL, O_NONBLOCK); 
     53  ALLOCATE (textdata, char, Ntextdata);
     54  while (Nbytes > 0) {
     55    Nread = read (sock, &textdata[Ntotal], Nbytes);
     56    if (Nread == 0) {  /* No more pipe */
     57      fprintf (stderr, "error: pipe closed\n");
     58      free (textdata);
     59      free (overlay);
     60      fcntl (sock, F_SETFL, !O_NONBLOCK); 
     61      return (FALSE);
     62    }
     63    if (Nread != -1) { /* pipe has data */
     64      Nbytes -= Nread;
     65      Ntotal += Nread;
     66    }
     67  }
     68  fcntl (sock, F_SETFL, !O_NONBLOCK); 
     69  KiiSendCommand (sock,  4, "DONE");
    3270
    33     /* accept data from the socket until we have all of the bytes */
    34     fcntl (sock, F_SETFL, O_NONBLOCK); 
    35     while (bytes > 0) {
    36       status = read (sock, buff, bytes);
    37       if (status == 0) {  /* No more pipe */
    38         fprintf (stderr, "error: pipe closed\n");
    39         free (buffer);
    40         fcntl (sock, F_SETFL, O_NONBLOCK); 
    41         return (FALSE);
    42       }
    43       if (status != -1) { /* pipe has data */
    44         bytes -= status;
    45         buff = (char *)(buff + status);
    46       }
    47     }
    48     fcntl (sock, F_SETFL, !O_NONBLOCK); 
     71  // add new overlay objects to existing data
     72  Nobjects = image[0].overlay[overnum].Nobjects + Noverlay;
     73  REALLOCATE (image[0].overlay[overnum].objects, KiiOverlay, Nobjects);
    4974
    50     /* parse buffer data */
    51     NOBJECTS = image[0].overlay[N].Nobjects + Nin;
    52     Nobjects = image[0].overlay[N].Nobjects;
    53     REALLOCATE (image[0].overlay[N].objects, Object, NOBJECTS);
    54     for (i = 0; i < Nin; i++) {
    55       sscanf (&buffer[i*128], "%s %lf %lf %lf %lf\n", type, &x, &y, &dx, &dy);
    56 
    57       if (strcasecmp (type, "TEXT") && strcasecmp (type, "LINE") && strcasecmp (type, "BOX") && strcasecmp (type, "CIRCLE")) {  /* skip */
    58         fprintf (stderr, "don't know %s, skipping\n", type);
    59         continue;
    60       }
    61 
    62       if (!strcasecmp (type, "TEXT")) { /* end of objects */
    63         sscanf (&buffer[i*128], "%s %lf %lf %s\n", type, &x, &y, string);
    64       }
    65        
    66       strcpy (image[0].overlay[N].objects[Nobjects].type, type);
    67       image[0].overlay[N].objects[Nobjects].x = x;
    68       image[0].overlay[N].objects[Nobjects].y = y;
    69       if (!strcmp (type, "TEXT")) {
    70         image[0].overlay[N].objects[Nobjects].dx = 0;
    71         image[0].overlay[N].objects[Nobjects].dy = 0;
    72         image[0].overlay[N].objects[Nobjects].text = strcreate (string);
    73       } else {
    74         image[0].overlay[N].objects[Nobjects].dx = dx;
    75         image[0].overlay[N].objects[Nobjects].dy = dy;
    76       }
    77       Nobjects++;
    78     }
    79     REALLOCATE (image[0].overlay[N].objects, Object, MAX(Nobjects, 1));
    80     image[0].overlay[N].Nobjects = Nobjects;
     75  j = image[0].overlay[overnum].Nobjects;
     76  for (i = 0; i < Noverlay; i++, j++) {
     77    image[0].overlay[overnum].objects[j].x = overlay[i].x;
     78    image[0].overlay[overnum].objects[j].y = overlay[i].y;
     79    image[0].overlay[overnum].objects[j].dx = overlay[i].dx;
     80    image[0].overlay[overnum].objects[j].dy = overlay[i].dy;
     81    image[0].overlay[overnum].objects[j].type = overlay[i].type;
     82    image[0].overlay[overnum].objects[j].text = NULL;
    8183  }
    8284
    83   /* cleanup */
    84   free (buffer);
    85   REALLOCATE (image[0].overlay[N].objects, Object, MAX (1, image[0].overlay[N].Nobjects));
    86   image[0].overlay[N].active = TRUE;
    87   fcntl (sock, F_SETFL, O_NONBLOCK); 
     85  // parse the text data : text lines are separated by '\n', one per text entry
     86  p = textdata;
     87  Nfound = 0;
     88  for (i = 0; i < Noverlay; i++) {
     89    if (overlay[i].type != KII_OVERLAY_TEXT) continue;
     90    if (Nfound >= Ntext) {
     91      fprintf (stderr, "inconsistent number of text lines\n");
     92      break;
     93    }
     94    if (! *p) {
     95      fprintf (stderr, "inconsistent number of text lines\n");
     96      break;
     97    }
     98    q = strchr (p, '\n');
     99    if (q == NULL) {
     100      fprintf (stderr, "inconsistent text line\n");
     101      break;
     102    }
     103    j = image[0].overlay[overnum].Nobjects + i;
     104    image[0].overlay[overnum].objects[j].text = strncreate (p, q-p);
     105    p = q + 1;
     106    Nfound ++;
     107  }
     108  if (Nfound != Ntext) {
     109    fprintf (stderr, "read %d text lines, expected %d\n", Nfound, Ntext);
     110  }
     111
     112  free (textdata);
     113  free (overlay);
     114
     115  image[0].overlay[overnum].Nobjects = Nobjects;
     116  image[0].overlay[overnum].active = TRUE;
    88117
    89118  if (USE_XWINDOW) {
     
    93122      }
    94123    }
    95     PaintTickmarks (graphic, image);
    96124    XFlush (graphic[0].display);
    97125  }
  • trunk/Ohana/src/kapa2/src/LoadPicture.c

    r13320 r13479  
    11# include "Ximage.h"
    22
    3 int LoadPicture () {
     3int LoadPicture (int sock) {
    44
    55  Header header;
     
    1212  graphic = GetGraphic ();
    1313  section = GetActiveSection();
    14   image   = section->image;
     14  if (section->image == NULL) {
     15    section->image = InitImage ();
     16    SetSectionSizes (section);
     17  }
     18  image = section->image;
    1519 
    1620  KiiSendMessage (sock, "%d", graphic->Npixels);
    1721
    18   fcntl (sock, F_SETFL, !O_NONBLOCK); 
    19 
    2022  header.Naxes = 2;
    21 
    2223  KiiScanMessage (sock, "%d %d %d %d %lf %lf", &header.Naxis[0], &header.Naxis[1]);
    2324  KiiScanMessage (sock, "%d %d %d %d %lf %lf", &header.bitpix, &header.unsign, &header.bzero, &header.bscale);
    24   KiiScanMessage (sock, "%lf %lf",  &image[0].zero, &image[0].range);
     25  KiiScanMessage (sock, "%lf %lf %s",  &image[0].zero, &image[0].range, image[0].name, image[0].file);
    2526  KiiScanMessage (sock, "%lf %lf %d", &image[0].min,  &image[0].max, &header.size);
    2627  KiiScanMessage (sock, "%lf %f %f %f %f", &image[0].coords.crval1, &image[0].coords.crpix1, &image[0].coords.cdelt1, &image[0].coords.pc1_1, &image[0].coords.pc1_2);
    2728  KiiScanMessage (sock, "%lf %f %f %f %f", &image[0].coords.crval2, &image[0].coords.crpix2, &image[0].coords.cdelt2, &image[0].coords.pc2_1, &image[0].coords.pc2_2);
    28          
    29   KiiScanMessage (sock, "%s %s %s", image[0].coords.ctype, image[0].file, image[0].buffer_name);
     29  KiiScanMessage (sock, "%s", image[0].coords.ctype);
    3030
    3131  gfits_free_matrix (&image[0].matrix);
     
    5151  }
    5252
     53  fcntl (sock, F_SETFL, !O_NONBLOCK); 
     54
    5355  if (DEBUG) fprintf (stderr, "read %d bytes\n", image[0].matrix.size);
    5456  /* it it not obvious this condition should kill kii, but ... */
  • trunk/Ohana/src/kapa2/src/LoadTextlines.c

    r13320 r13479  
    11# include "Ximage.h"
    22
    3 int LoadTextlines () {
     3int LoadTextlines (int sock) {
    44 
    55  char *string;
     
    1111  section = GetActiveSection();
    1212  graph = section->graph;
    13  
    14   fcntl (sock, F_SETFL, !O_NONBLOCK); 
    15  
     13    if (section->graph == NULL) {
     14    section->graph = InitGraph ();
     15    SetSectionSizes (section);
     16  }
     17
    1618  graph[0].Ntextline = MAX (graph[0].Ntextline, 0);
    1719  N = graph[0].Ntextline;
     
    3436  strcpy (graph[0].textline[N].text, string);
    3537  free (string);
    36 
    37   fcntl (sock, F_SETFL, O_NONBLOCK); 
    3838 
    3939  string = GetRotFont (&size);
  • trunk/Ohana/src/kapa2/src/LoadTickmarks.c

    r13320 r13479  
    11# include "Ximage.h"
    22
    3 int LoadTickmarks () {
     3int LoadTickmarks (int sock) {
    44 
    55  char line[129], type[16];
     
    1010
    1111  section = GetActiveSection();
     12  if (section->image == NULL) {
     13    section->image = InitImage ();
     14    SetSectionSizes (section);
     15  }
    1216  image   = section->image;
    13   fcntl (sock, F_SETFL, !O_NONBLOCK); 
    1417
    1518  Nobjects = image[0].tickmarks.Nobjects;
    1619  NOBJECTS = Nobjects + 100;
    17   REALLOCATE (image[0].tickmarks.objects, Object, NOBJECTS);
     20  REALLOCATE (image[0].tickmarks.objects, KiiOverlay, NOBJECTS);
    1821 
    1922  done = FALSE;
     
    5154    if (Nobjects >= NOBJECTS) {
    5255      NOBJECTS = Nobjects + 100;
    53       REALLOCATE (image[0].tickmarks.objects, Object, NOBJECTS);
     56      REALLOCATE (image[0].tickmarks.objects, KiiOverlay, NOBJECTS);
    5457    }
    5558
    5659  }
    5760
    58   REALLOCATE (image[0].tickmarks.objects, Object, MAX(Nobjects, 1));
     61  REALLOCATE (image[0].tickmarks.objects, KiiOverlay, MAX(Nobjects, 1));
    5962  image[0].tickmarks.Nobjects = Nobjects;
    6063
    6164  if (USE_XWINDOW) Refresh ();
    62 
    63   fcntl (sock, F_SETFL, O_NONBLOCK); 
    6465  return (TRUE);
    65  
    6666}
  • trunk/Ohana/src/kapa2/src/PNGit.c

    r13320 r13479  
    11# include "Ximage.h"
    22
    3 int PNGit () {
     3int PNGit (int sock) {
    44
    55  FILE *f;
  • trunk/Ohana/src/kapa2/src/PPMit.c

    r13320 r13479  
    11# include "Ximage.h"
    22
    3 int PPMit () {
     3int PPMit (int sock) {
    44
    55  FILE *f;
  • trunk/Ohana/src/kapa2/src/PSOverlay.c

    r13331 r13479  
    3131    dY = (image[0].overlay[N].objects[i].dy)/expand;
    3232   
    33     if (!strcmp (image[0].overlay[N].objects[i].type, "LINE")) {
    34       if (((X < Xmin) && (X + dX < Xmin)) || ((X > Xmax) && (X + dX > Xmax)) ||
    35           ((Y < Ymin) && (Y + dY < Ymin)) || ((Y > Ymax) && (Y + dY > Ymax))) {
    36         continue;
    37       }
    38       fprintf (f, " %6.1f %6.1f %6.1f %6.1f L\n", X + extra, Y + extra, (X+dX + extra), (Y-dY + extra));
    39       continue;
     33    switch (image[0].overlay[N].objects[i].type) {
     34      case KII_OVERLAY_LINE:
     35        if (((X < Xmin) && (X + dX < Xmin)) || ((X > Xmax) && (X + dX > Xmax)) ||
     36            ((Y < Ymin) && (Y + dY < Ymin)) || ((Y > Ymax) && (Y + dY > Ymax))) {
     37          break;
     38        }
     39        fprintf (f, " %6.1f %6.1f %6.1f %6.1f L\n", X + extra, Y + extra, (X+dX + extra), (Y-dY + extra));
     40        break;
     41      case KII_OVERLAY_TEXT:
     42        if (((X < Xmin) && (X + dX < Xmin)) || ((X > Xmax) && (X + dX > Xmax)) ||
     43            ((Y < Ymin) && (Y + dY < Ymin)) || ((Y > Ymax) && (Y + dY > Ymax))) {
     44          break;
     45        }
     46        fprintf (f, "(%s) %6.1f %6.1f T\n", image[0].overlay[N].objects[i].text, X + extra, Y + extra);
     47        break;
     48      case KII_OVERLAY_BOX:
     49        if (((X - 0.5*dX < Xmin) && (X + 0.5*dX < Xmin)) || ((X - 0.5*dX > Xmax) && (X + 0.5*dX > Xmax)) ||
     50            ((Y - 0.5*dY < Ymin) && (Y + 0.5*dY < Ymin)) || ((Y - 0.5*dY > Ymax) && (Y + 0.5*dY > Ymax))) {
     51          break;
     52        }
     53        fprintf (f, " %6.1f %6.1f %6.1f %6.1f B\n", (dX + 2*extra), (dY + 2*extra), (X - 0.5*dX - extra), (Y - 0.5*dY - extra));
     54        break;
     55      case KII_OVERLAY_CIRCLE:
     56        if (((X - dX < Xmin) && (X + dX < Xmin)) || ((X - dX > Xmax) && (X + dX > Xmax)) ||
     57            ((Y - dY < Ymin) && (Y + dY < Ymin)) || ((Y - dY > Ymax) && (Y + dY > Ymax))) {
     58          break;
     59        }
     60        fprintf (f, " %6.1f %6.1f %6.1f C\n", X, Y, fabs(dX + extra));
     61        break;
     62      default:
     63        fprintf (stderr, "skipping unknown object\n");
     64        break;
    4065    }
    41     if (!strcmp (image[0].overlay[N].objects[i].type, "TEXT")) {
    42       if (((X < Xmin) && (X + dX < Xmin)) || ((X > Xmax) && (X + dX > Xmax)) ||
    43           ((Y < Ymin) && (Y + dY < Ymin)) || ((Y > Ymax) && (Y + dY > Ymax))) {
    44         continue;
    45       }
    46       fprintf (f, "(%s) %6.1f %6.1f T\n", image[0].overlay[N].objects[i].text, X + extra, Y + extra);
    47       continue;
    48     }
    49     if (!strcmp (image[0].overlay[N].objects[i].type, "BOX")) {
    50       if (((X - 0.5*dX < Xmin) && (X + 0.5*dX < Xmin)) || ((X - 0.5*dX > Xmax) && (X + 0.5*dX > Xmax)) ||
    51           ((Y - 0.5*dY < Ymin) && (Y + 0.5*dY < Ymin)) || ((Y - 0.5*dY > Ymax) && (Y + 0.5*dY > Ymax))) {
    52         continue;
    53       }
    54       fprintf (f, " %6.1f %6.1f %6.1f %6.1f B\n", (dX + 2*extra), (dY + 2*extra), (X - 0.5*dX - extra), (Y - 0.5*dY - extra));
    55       continue;
    56     }
    57     if (!strcmp (image[0].overlay[N].objects[i].type, "CIRCLE")) {
    58       if (((X - dX < Xmin) && (X + dX < Xmin)) || ((X - dX > Xmax) && (X + dX > Xmax)) ||
    59           ((Y - dY < Ymin) && (Y + dY < Ymin)) || ((Y - dY > Ymax) && (Y + dY > Ymax))) {
    60         continue;
    61       }
    62       fprintf (f, " %6.1f %6.1f %6.1f C\n", X, Y, fabs(dX + extra));
    63       continue;
    64     }
    65     fprintf (stderr, "don't know %s, skipping\n", image[0].overlay[N].objects[i].type);
    6666  }
    67  
    6867}
  • trunk/Ohana/src/kapa2/src/PSit.c

    r13331 r13479  
    66static Graphic *graphic;
    77
    8 int PScommand () {
     8int PScommand (int sock) {
    99
    1010  int status, scaleMode, pageMode;
  • trunk/Ohana/src/kapa2/src/PaintOverlay.c

    r13320 r13479  
    4141       for a BOX (x, y) is the center, (dx, dy) is the width */
    4242
    43     if (!strcasecmp (image[0].overlay[N].objects[i].type, "LINE")) {
    44       XDrawLine (graphic[0].display, graphic[0].window, graphic[0].gc, X, Y, (X+dX), (Y+dY));
    45       continue;
     43    switch (image[0].overlay[N].objects[i].type) {
     44      case KII_OVERLAY_LINE:
     45        XDrawLine (graphic[0].display, graphic[0].window, graphic[0].gc, X, Y, (X+dX), (Y+dY));
     46        break;
     47      case KII_OVERLAY_TEXT:
     48        XDrawString (graphic[0].display, graphic[0].window, graphic[0].gc, X, Y, image[0].overlay[N].objects[i].text, strlen(image[0].overlay[N].objects[i].text));
     49        break;
     50      case KII_OVERLAY_BOX:
     51        dx = MAX (abs(dX),2) / 2;
     52        dy = MAX (abs(dY),2) / 2;
     53        XDrawRectangle (graphic[0].display, graphic[0].window, graphic[0].gc, (X - dx), (Y - dy), 2*dx, 2*dy);
     54        break;
     55      case KII_OVERLAY_CIRCLE:
     56        dx = MAX (abs(dX),2);
     57        dy = MAX (abs(dY),2);
     58        XDrawArc (graphic[0].display, graphic[0].window, graphic[0].gc, (X - dx), (Y - dy), 2*dx, 2*dy, 0, 23040);
     59        break;
     60      default:
     61        fprintf (stderr, "skipping unknown object\n");
     62        break;
    4663    }
    47     if (!strcasecmp (image[0].overlay[N].objects[i].type, "TEXT")) {
    48       XDrawString (graphic[0].display, graphic[0].window, graphic[0].gc, X, Y, image[0].overlay[N].objects[i].text, strlen(image[0].overlay[N].objects[i].text));
    49       continue;
    50     }
    51     if (!strcasecmp (image[0].overlay[N].objects[i].type, "BOX")) {
    52       dx = MAX (abs(dX),2) / 2;
    53       dy = MAX (abs(dY),2) / 2;
    54       XDrawRectangle (graphic[0].display, graphic[0].window, graphic[0].gc, (X - dx), (Y - dy), 2*dx, 2*dy);
    55        continue;
    56     }
    57     if (!strcasecmp (image[0].overlay[N].objects[i].type, "CIRCLE")) {
    58       dx = MAX (abs(dX),2);
    59       dy = MAX (abs(dY),2);
    60       XDrawArc (graphic[0].display, graphic[0].window, graphic[0].gc, (X - dx), (Y - dy), 2*dx, 2*dy, 0, 23040);
    61       continue;
    62     }
    63     fprintf (stderr, "don't know %s, skipping (PO)\n", image[0].overlay[N].objects[i].type);
    6464  }
    6565 
  • trunk/Ohana/src/kapa2/src/PaintTickmarks.c

    r13320 r13479  
    2222    dY = image[0].tickmarks.objects[i].dy * Yrange;
    2323
    24     if (!strcmp (image[0].tickmarks.objects[i].type, "LINE")) {
    25       XDrawLine (graphic[0].display, graphic[0].window, graphic[0].gc, X, Y, (X+dX), (Y+dY));
    26       continue;
     24    switch (image[0].overlay[0].objects[i].type) {
     25      case KII_OVERLAY_LINE:
     26        XDrawLine (graphic[0].display, graphic[0].window, graphic[0].gc, X, Y, (X+dX), (Y+dY));
     27        break;
     28      case KII_OVERLAY_TEXT:
     29        if (image[0].tickmarks.objects[i].dy == 0) {
     30            XSetForeground (graphic[0].display, graphic[0].gc, graphic[0].back);
     31            XFillRectangle (graphic[0].display, graphic[0].window, graphic[0].gc, X, Y-11, 6*strlen(image[0].tickmarks.objects[i].text), 11);
     32            XSetForeground (graphic[0].display, graphic[0].gc, graphic[0].fore);
     33            XDrawString (graphic[0].display, graphic[0].window, graphic[0].gc, X, Y, image[0].tickmarks.objects[i].text, strlen(image[0].tickmarks.objects[i].text));
     34        }
     35        if (image[0].tickmarks.objects[i].dy == 90) {
     36            XSetForeground (graphic[0].display, graphic[0].gc, graphic[0].back);
     37            XFillRectangle (graphic[0].display, graphic[0].window, graphic[0].gc, X, Y-6*strlen(image[0].tickmarks.objects[i].text), 11, 6*strlen(image[0].tickmarks.objects[i].text));
     38            XSetForeground (graphic[0].display, graphic[0].gc, graphic[0].fore);
     39            /* XDrawRotString (graphic[0].display, graphic[0].window, graphic[0].gc, X, Y, image[0].tickmarks.objects[i].text, strlen(image[0].tickmarks.objects[i].text)); */
     40        }
     41        break;
     42      case KII_OVERLAY_BOX:
     43        XDrawRectangle (graphic[0].display, graphic[0].window, graphic[0].gc, (int)(X - 0.5*dX), (int)(Y - 0.5*dY), abs(dX), abs(dY));
     44        break;
     45      case KII_OVERLAY_CIRCLE:
     46        XDrawArc (graphic[0].display, graphic[0].window, graphic[0].gc, X - dX, Y - dY, abs(2*dX), abs(2*dY), 0, 23040);
     47        break;
     48      default:
     49        fprintf (stderr, "skipping unknown object\n");
     50        break;
    2751    }
    28     if (!strcmp (image[0].tickmarks.objects[i].type, "TEXT")) {
    29       if (image[0].tickmarks.objects[i].dy == 0) {
    30         XSetForeground (graphic[0].display, graphic[0].gc, graphic[0].back);
    31         XFillRectangle (graphic[0].display, graphic[0].window, graphic[0].gc, X, Y-11, 6*strlen(image[0].tickmarks.objects[i].text), 11);
    32         XSetForeground (graphic[0].display, graphic[0].gc, graphic[0].fore);
    33         XDrawString (graphic[0].display, graphic[0].window, graphic[0].gc, X, Y, image[0].tickmarks.objects[i].text, strlen(image[0].tickmarks.objects[i].text));
    34       }
    35       if (image[0].tickmarks.objects[i].dy == 90) {
    36         XSetForeground (graphic[0].display, graphic[0].gc, graphic[0].back);
    37         XFillRectangle (graphic[0].display, graphic[0].window, graphic[0].gc, X, Y-6*strlen(image[0].tickmarks.objects[i].text), 11, 6*strlen(image[0].tickmarks.objects[i].text));
    38         XSetForeground (graphic[0].display, graphic[0].gc, graphic[0].fore);
    39         /* XDrawRotString (graphic[0].display, graphic[0].window, graphic[0].gc, X, Y, image[0].tickmarks.objects[i].text, strlen(image[0].tickmarks.objects[i].text)); */
    40       }
    41       continue;
    42     }
    43     if (!strcmp (image[0].tickmarks.objects[i].type, "BOX")) {
    44       XDrawRectangle (graphic[0].display, graphic[0].window, graphic[0].gc, (int)(X - 0.5*dX), (int)(Y - 0.5*dY), abs(dX), abs(dY));
    45        continue;
    46     }
    47     if (!strcmp (image[0].tickmarks.objects[i].type, "CIRCLE")) {
    48       XDrawArc (graphic[0].display, graphic[0].window, graphic[0].gc, X - dX, Y - dY, abs(2*dX), abs(2*dY), 0, 23040);
    49       continue;
    50     }
    51     fprintf (stderr, "don't know %s, skipping (PO)\n", image[0].tickmarks.objects[i].type);
    5252  }
    53  
    5453  XSetForeground (graphic[0].display, graphic[0].gc, graphic[0].fore);
    55 
    5654}
  • trunk/Ohana/src/kapa2/src/Reconfig.c

    r13320 r13479  
    2525  for (i = 0; i < Nsection; i++) {
    2626      section = GetSectionByNumber (i);
    27       SetGraphSize (section);
    28       SetImageSize (section);
     27      SetSectionSizes (section);
    2928  }
    3029
  • trunk/Ohana/src/kapa2/src/Refresh.c

    r13320 r13479  
    2121  for (i = 0; i < Nsection; i++) {
    2222      section = GetSectionByNumber (i);
     23      DrawImage (section->image);
    2324      DrawGraph (section->graph);
    24       DrawImage (section->image);
    2525  }
    2626
  • trunk/Ohana/src/kapa2/src/Remap16.c

    r13320 r13479  
    11# include "Ximage.h"
    2 # define FRAC(a) ((a) - (int)(a))
     2
     3static float slope = 1.0;
     4static float start = 0.0;
     5static int MaxValue = 255;
     6
     7// XXX inline this if needed
     8static int PixelLookup(float value) {
     9  int out;
     10  out = MIN (MAX (slope * value - start, 0), MaxValue);
     11  return (out);
     12}
    313
    414void Remap16 (Graphic *graphic, KapaImageWidget *image, Matrix *matrix) {
     
    717  int i_start, i_end, j_start, j_end;
    818  int dropback;  /* this is a bit of a kludge... */
    9   int dx, dy, DX, DY;
     19  int dx, dy, DX, DY, pixelN;
    1020  double expand, Rx, Ry, X, Y;
    1121  int expand_in, expand_out;
    1222  unsigned char *out_pix, *out_pix2, *data;
    13   unsigned char *in_pix, *in_pix2;
    14   unsigned char pixel1[256], pixel2[256], pixel3[256];
     23  float *imdata, *in_pix, *in_pix2;
     24  unsigned char pixel1[256], pixel2[256];
    1525  unsigned char pixvalue1, pixvalue2;
    1626  unsigned long back;
    1727  unsigned char back1, back2;
    1828
     29  // local array for pixel values (is this working??)
    1930  for (i = 0; i < 256; i++) { /* set up pixel array */
    20     pixel1[i] = 0x0000ff &  graphic[0].cmap[i].pixel;
    21     pixel2[i] = 0x0000ff & (graphic[0].cmap[i].pixel >> 8);
    22     pixel3[i] = 0x0000ff & (graphic[0].cmap[i].pixel >> 16);
     31    pixel1[i] = 0x00ff &  graphic[0].cmap[i].pixel;
     32    pixel2[i] = 0x00ff & (graphic[0].cmap[i].pixel >> 8);
    2333  }
    2434  back = graphic[0].back;
     
    2636  back2 = 0x00ff & (back >> 8);
    2737
     38  // define the color transform parameters
     39  MaxValue = graphic[0].Npixels - 1;
     40  if (image[0].range != 0.0) {
     41    slope = graphic[0].Npixels / image[0].range;
     42    start = graphic[0].Npixels * image[0].zero / image[0].range;
     43  } else {
     44    slope = 1.0;
     45    start = image[0].zero;
     46  }
     47
     48  // set up expansions
    2849  expand = expand_in = expand_out = 1.0;
    2950  if (image[0].expand == 0) /* set up expansions */
     
    4061  }
    4162
     63  // define the image boundaries
    4264  dx = image[0].picture.dx;
    4365  dy = image[0].picture.dy;
     
    7698
    7799  data = out_pix = (unsigned char *) image[0].picture.data;
    78   in_pix  = (unsigned char *) (matrix[0].buffer) + DX*(int)MAX(Y,0) + (int)MAX(X,0);
     100  imdata  = (float *) matrix[0].buffer;
     101  in_pix  = &imdata[DX*(int)MAX(Y,0) + (int)MAX(X,0)];
    79102
    80103  /********** below we do the mapping from buffer pixels (in) to picture pixels (out) **********/
     
    105128    if (expand_out == 1) {
    106129      for (i = i_start; i < i_end; i++, in_pix2+= expand_in, out_pix+=2) {
    107         out_pix[0] = pixel1[*in_pix2];
    108         out_pix[1] = pixel2[*in_pix2];
     130        pixelN = PixelLookup(*in_pix2);
     131        out_pix[0] = pixel1[pixelN];
     132        out_pix[1] = pixel2[pixelN];
    109133      }
    110134    }
    111135    else {
    112136      for (i = i_start; i < i_end; i+= expand_out, in_pix2++, out_pix+= 2*expand_out) {
    113         pixvalue1 = pixel1[*in_pix2];
    114         pixvalue2 = pixel2[*in_pix2];
     137        pixelN    = PixelLookup(*in_pix2);
     138        pixvalue1 = pixel1[pixelN];
     139        pixvalue2 = pixel2[pixelN];
    115140        out_pix2 = out_pix;
    116141        for (jj = 0; jj < expand_out; jj++, out_pix2+=2*(dx-expand_out)) {
  • trunk/Ohana/src/kapa2/src/Remap24.c

    r13320 r13479  
    11# include "Ximage.h"
    2 # define FRAC(a) ((a) - (int)(a))
     2
     3static float slope = 1.0;
     4static float start = 0.0;
     5static int MaxValue = 255;
     6
     7// XXX inline this if needed
     8static int PixelLookup(float value) {
     9  int out;
     10  out = MIN (MAX (slope * value - start, 0), MaxValue);
     11  return (out);
     12}
    313
    414void Remap24 (Graphic *graphic, KapaImageWidget *image, Matrix *matrix) {
     
    717  int i_start, i_end, j_start, j_end;
    818  int dropback, extra;  /* this is a bit of a kludge... */
    9   int dx, dy, DX, DY;
     19  int dx, dy, DX, DY, pixelN;
    1020  double expand, Rx, Ry, X, Y;
    1121  int expand_in, expand_out;
    1222  unsigned char *out_pix, *out_pix2, *data;
    13   unsigned char *in_pix, *in_pix2;
     23  float *imdata, *in_pix, *in_pix2;
    1424  unsigned char pixel1[256], pixel2[256], pixel3[256];
    1525  unsigned char pixvalue1, pixvalue2, pixvalue3;
     
    1727  unsigned char back1, back2, back3;
    1828
     29  // local arrays for pixel values
    1930  for (i = 0; i < 256; i++) { /* set up pixel array */
    2031    pixel1[i] = 0x0000ff &  graphic[0].cmap[i].pixel;
     
    2738  back3 = 0x0000ff & (back >> 16);
    2839
     40  // define the color transform parameters
     41  MaxValue = graphic[0].Npixels - 1;
     42  if (image[0].range != 0.0) {
     43    slope = graphic[0].Npixels / image[0].range;
     44    start = graphic[0].Npixels * image[0].zero / image[0].range;
     45  } else {
     46    slope = 1.0;
     47    start = image[0].zero;
     48  }
     49
     50  // set up expansions
    2951  expand = expand_in = expand_out = 1.0;
    3052  if (image[0].expand == 0) /* set up expansions */
     
    78100
    79101  data = out_pix = (unsigned char *) image[0].picture.data;
    80   in_pix  = (unsigned char *) (matrix[0].buffer) + DX*(int)MAX(Y,0) + (int)MAX(X,0);
     102  imdata  = (float *) matrix[0].buffer;
     103  in_pix  = &imdata[DX*(int)MAX(Y,0) + (int)MAX(X,0)];
    81104
    82105  /********** below we do the mapping from buffer pixels (in) to picture pixels (out) **********/
     
    110133    if (expand_out == 1) {
    111134      for (i = i_start; i < i_end; i++, in_pix2+= expand_in, out_pix+=3) {
    112         out_pix[0] = pixel1[*in_pix2];
    113         out_pix[1] = pixel2[*in_pix2];
    114         out_pix[2] = pixel3[*in_pix2];
     135        pixelN = PixelLookup(*in_pix2);
     136        out_pix[0] = pixel1[pixelN];
     137        out_pix[1] = pixel2[pixelN];
     138        out_pix[2] = pixel3[pixelN];
    115139      }
    116     }
    117     else {
     140    } else {
    118141      for (i = i_start; i < i_end; i+= expand_out, in_pix2++, out_pix+= 3*expand_out) {
    119         pixvalue1 = pixel1[*in_pix2];
    120         pixvalue2 = pixel2[*in_pix2];
    121         pixvalue3 = pixel3[*in_pix2];
     142        pixelN = PixelLookup(*in_pix2);
     143        pixvalue1 = pixel1[pixelN];
     144        pixvalue2 = pixel2[pixelN];
     145        pixvalue3 = pixel3[pixelN];
    122146        out_pix2 = out_pix;
    123147        for (jj = 0; jj < expand_out; jj++, out_pix2+=3*(dx-expand_out)+extra) {
  • trunk/Ohana/src/kapa2/src/Remap32.c

    r13320 r13479  
    11# include "Ximage.h"
    2 # define FRAC(a) ((a) - (int)(a))
     2
     3static float slope = 1.0;
     4static float start = 0.0;
     5static int MaxValue = 255;
     6
     7// XXX inline this if needed
     8static int PixelLookup(float value) {
     9  int out;
     10  out = MIN (MAX (slope * value - start, 0), MaxValue);
     11  return (out);
     12}
    313
    414void Remap32 (Graphic *graphic, KapaImageWidget *image, Matrix *matrix) {
     
    717  int i_start, i_end, j_start, j_end;
    818  int dropback;  /* this is a bit of a kludge... */
    9   int dx, dy, DX, DY;
     19  int dx, dy, DX, DY, pixelN;
    1020  double expand, Rx, Ry, X, Y;
    1121  int expand_in, expand_out;
    1222  unsigned int *out_pix, *out_pix2;
    13   unsigned char *in_pix, *in_pix2;
     23  float *imdata, *in_pix, *in_pix2;
    1424  unsigned long pixel[256], pixvalue;
    1525  unsigned long back;
    1626
    17   for (i = 0; i < 256; i++) { /* set up pixel array */
     27  // local array for pixel values
     28  for (i = 0; i < 256; i++) {
    1829    pixel[i] = graphic[0].cmap[i].pixel;
    1930  }
    2031  back = graphic[0].back;
    2132
     33  // define the color transform parameters
     34  MaxValue = graphic[0].Npixels - 1;
     35  if (image[0].range != 0.0) {
     36    slope = graphic[0].Npixels / image[0].range;
     37    start = graphic[0].Npixels * image[0].zero / image[0].range;
     38  } else {
     39    slope = 1.0;
     40    start = image[0].zero;
     41  }
     42
     43  // set up expansions
    2244  expand = expand_in = expand_out = 1.0;
    23   if (image[0].expand == 0) /* set up expansions */
     45  if (image[0].expand == 0)
    2446    image[0].expand = 1;
    2547  if (image[0].expand > 0) {
     
    3456  }
    3557
     58  // define the image boundaries
    3659  dx = image[0].picture.dx;
    3760  dy = image[0].picture.dy;
     
    6992
    7093  out_pix = (unsigned int *) image[0].picture.data;
    71   in_pix  = (unsigned char *) (matrix[0].buffer) + DX*(int)MAX(Y,0) + (int)MAX(X,0);
     94  imdata  = (float *) matrix[0].buffer;
     95  in_pix  = &imdata[DX*(int)MAX(Y,0) + (int)MAX(X,0)];
    7296
    7397  /********** below we do the mapping from buffer pixels (in) to picture pixels (out) **********/
     
    92116    if (expand_out == 1) {
    93117      for (i = i_start; i < i_end; i++, in_pix2+= expand_in, out_pix++) {
    94         *out_pix = pixel[*in_pix2];
     118        pixelN = PixelLookup(*in_pix2);
     119        *out_pix = pixel[pixelN];
    95120      }
    96       /* *out_pix = *(pixel + *in_pix2);  */
    97121    }
    98122    else {
    99123      for (i = i_start; i < i_end; i+= expand_out, in_pix2++, out_pix+= expand_out) {
    100         pixvalue = pixel[*in_pix2];
     124        pixelN   = PixelLookup(*in_pix2);
     125        pixvalue = pixel[pixelN];
    101126        out_pix2 = out_pix;
    102127        for (jj = 0; jj < expand_out; jj++, out_pix2+=(dx-expand_out)) {
  • trunk/Ohana/src/kapa2/src/Remap8.c

    r13320 r13479  
    11# include "Ximage.h"
    2 # define FRAC(a) ((a) - (int)(a))
     2
     3static float slope = 1.0;
     4static float start = 0.0;
     5static int MaxValue = 255;
     6
     7// XXX inline this if needed
     8static int PixelLookup(float value) {
     9  int out;
     10  out = MIN (MAX (slope * value - start, 0), MaxValue);
     11  return (out);
     12}
    313
    414void Remap8 (Graphic *graphic, KapaImageWidget *image, Matrix *matrix) {
     
    717  int i_start, i_end, j_start, j_end;
    818  int dropback;  /* this is a bit of a kludge... */
    9   int dx, dy, DX, DY;
     19  int dx, dy, DX, DY, pixelN;
    1020  double expand, Rx, Ry, X, Y;
    1121  int expand_in, expand_out;
    1222  unsigned char *out_pix, *out_pix2;
    13   unsigned char *in_pix,  *in_pix2;
     23  float *imdata, *in_pix,  *in_pix2;
    1424  unsigned long pixel[256], pixvalue;
    1525  unsigned long back;
    1626
    17   for (i = 0; i < 256; i++) { /* set up pixel array */
     27  // local array for pixel values
     28  for (i = 0; i < 256; i++) {
    1829    pixel[i] = graphic[0].cmap[i].pixel;
    1930  }
    2031  back = graphic[0].back;
    2132
     33  // define the color transform parameters
     34  MaxValue = graphic[0].Npixels - 1;
     35  if (image[0].range != 0.0) {
     36    slope = graphic[0].Npixels / image[0].range;
     37    start = graphic[0].Npixels * image[0].zero / image[0].range;
     38  } else {
     39    slope = 1.0;
     40    start = image[0].zero;
     41  }
     42
     43  // set up expansions
    2244  expand = expand_in = expand_out = 1.0;
    2345  if (image[0].expand == 0) /* set up expansions */
     
    3456  }
    3557
     58  // define the image boundaries
    3659  dx = image[0].picture.dx;
    3760  dy = image[0].picture.dy;
    3861  DX = matrix[0].Naxis[0];
    3962  DY = matrix[0].Naxis[1];
     63
    4064  /* X,Y are the image coordinates of the first image pixel */
    4165  X = MAX(0.5*(DX - dx*expand) - image[0].X, 0);
     
    6993
    7094  out_pix = (unsigned char *) image[0].picture.data;
    71   in_pix  = (unsigned char *) matrix[0].buffer + DX*(int)MAX(Y,0) + (int)MAX(X,0);
     95  imdata  = (float *) matrix[0].buffer;
     96  in_pix  = &imdata[(int)(DX*(int)MAX(Y,0) + (int)MAX(X,0))];
    7297
    7398  /********** below we do the mapping from buffer pixels (in) to picture pixels (out) **********/
     
    92117    if (expand_out == 1) {
    93118      for (i = i_start; i < i_end; i++, in_pix2+= expand_in, out_pix++) {
    94         *out_pix = pixel[*in_pix2];
     119        pixelN = PixelLookup(*in_pix2);
     120        *out_pix = pixel[pixelN];
    95121      }
    96       /* *out_pix = *(pixel + *in_pix2);  */
    97     }
    98     else {
     122    } else {
    99123      for (i = i_start; i < i_end; i+= expand_out, in_pix2++, out_pix+= expand_out) {
    100         pixvalue = pixel[*in_pix2];
     124        pixelN   = PixelLookup(*in_pix2);
     125        pixvalue = pixel[pixelN];
    101126        out_pix2 = out_pix;
    102127        for (jj = 0; jj < expand_out; jj++, out_pix2+=(dx-expand_out)) {
  • trunk/Ohana/src/kapa2/src/Resize.c

    r13320 r13479  
    22
    33// XXX Should there be a base command + KiiMessage command?
    4 int Resize () {
     4int Resize (int sock) {
    55 
    66  int i, Nsection;
     
    3030  for (i = 0; i < Nsection; i++) {
    3131      section = GetSectionByNumber (i);
    32       SetGraphSize (section);
    33       SetImageSize (section);
     32      SetSectionSizes (section);
    3433  }
    3534
  • trunk/Ohana/src/kapa2/src/SaveOverlay.c

    r13320 r13479  
    11# include "Ximage.h"
    22
    3 int SaveOverlay () {
     3int SaveOverlay (int sock) {
    44
    55  int i, N;
    6   char filename[256];
     6  char filename[256], *type;
    77  FILE *f;
    88  Section *section;
     
    1111  section = GetActiveSection();
    1212  image   = section->image;
     13  if (image == NULL) return (TRUE);
    1314
    1415  KiiScanMessage (sock, "%*s %d %s", &N, filename);
     
    2122
    2223  for (i = 0; i < image[0].overlay[N].Nobjects; i++) {
     24    type = KiiOverlayTypeByNumber (image[0].overlay[N].objects[i].type);
     25    if (type == NULL) continue;
    2326    fprintf (f, "%s %lf %lf %lf %lf\n",
    24              image[0].overlay[N].objects[i].type,
     27             type,
    2528             image[0].overlay[N].objects[i].x,
    2629             image[0].overlay[N].objects[i].y,
     
    3134  return (TRUE);
    3235}
     36
     37/* this is asymmetric with LoadOverlay.c.  In that case, the client reads the file and sends
     38 * the overlay objects to kapa.  In this case, kapa writes the file directly...
     39 */
  • trunk/Ohana/src/kapa2/src/Sections.c

    r13320 r13479  
    2424
    2525  if (section == NULL) return;
    26   if (section[0].graph != NULL) FreeGraph (section[0].graph);
    27   // if (section[0].image != NULL) FreeImage (section[0].image);
    28   if (section[0].name  != NULL) free (section[0].name);
     26  FreeGraph (section[0].graph);
     27  FreeImage (section[0].image);
     28  FREE (section[0].name);
    2929  free (section);
    3030}
     
    4242}
    4343
    44 // XXX how to set the section type?
    45 // XXX set active section on Add?
    4644Section *AddSection (char *name, float x, float y, float dx, float dy) {
    4745
     
    116114}
    117115
    118 int ListSection () {
     116int ListSection (int sock) {
    119117 
    120118  int i, ThisSection;
     
    149147  return (TRUE);
    150148}
     149
     150void SetSectionSizes (Section *section) {
     151
     152    SetGraphSize (section);
     153    SetImageSize (section);
     154    return;
     155}
     156
     157// return TRUE even for nonsense cases to avoid quitting kapa
     158int MoveSection (int sock) {
     159
     160  int i, N;
     161  char name[128];
     162  char direction[16];
     163  Section *tmpSection = NULL;
     164
     165  KiiScanMessage (sock, "%s %s", name, direction);
     166 
     167  N = GetSectionByName (name);
     168  if (N < 0) {
     169    fprintf (stderr, "section %s not found\n", name);
     170    return (TRUE);
     171  }
     172
     173  if (!strcasecmp (direction, "up")) {
     174      if (N < 0) return (TRUE);
     175      if (N > Nsections - 2) return (TRUE);
     176      tmpSection = sections[N];
     177      sections[N] = sections[N+1];
     178      sections[N+1] = tmpSection;
     179      Refresh (1);
     180      return (TRUE);
     181  }
     182
     183  if (!strcasecmp (direction, "down")) {
     184      if (N < 1) return (TRUE);
     185      if (N > Nsections - 1) return (TRUE);
     186      tmpSection = sections[N];
     187      sections[N] = sections[N-1];
     188      sections[N-1] = tmpSection;
     189      Refresh (1);
     190      return (TRUE);
     191  }
     192
     193  if (!strcasecmp (direction, "top")) {
     194      if (N < 0) return (TRUE);
     195      if (N > Nsections - 2) return (TRUE);
     196      tmpSection = sections[N];
     197      for (i = N; i < Nsections - 1; i++) {
     198        sections[i] = sections[i+1];
     199      }
     200      sections[i] = tmpSection;
     201      Refresh (1);
     202      return (TRUE);
     203  }
     204
     205  if (!strcasecmp (direction, "bottom")) {
     206      if (N < 1) return (TRUE);
     207      if (N > Nsections - 1) return (TRUE);
     208      tmpSection = sections[N];
     209      for (i = N; i >= 1; i--) {
     210        sections[i] = sections[i-1];
     211      }
     212      sections[i] = tmpSection;
     213      Refresh (1);
     214      return (TRUE);
     215  }
     216  fprintf (stderr, "unknown direction %s for MoveSection\n", direction);
     217  return (TRUE);
     218}
  • trunk/Ohana/src/kapa2/src/SetFont.c

    r13320 r13479  
    11# include "Ximage.h"
    22
    3 int SetFont () {
     3int SetFont (int sock) {
    44 
    55  char name[64];
  • trunk/Ohana/src/kapa2/src/SetGraphSize.c

    r13320 r13479  
    77
    88  int fontsize, bump, Nc;
     9  int textpad, textdY, WdY;
    910  double PADx, PADy, Dx, Dy;
    1011  double PXm, PXp, PYm, PYp;
     
    3233  PYp = (graph[0].axis[2].islabel) ? 4*fontsize : 0;
    3334 
    34   /* size of the graph in Xwindow coordinates */
     35  /* basic size of the graph in Xwindow coordinates */
    3536  X0 = PADx + PXm + (Dx * section[0].x);
    3637  Y0 = PADy + PYm + (Dy * section[0].y);
    3738  dX = (Dx * section[0].dx) - PXp - PXm;
    3839  dY = (Dy * section[0].dy) - PYp - PYm;
     40
     41  // if we are tied to an image, make mods as needed
     42  if (section->image) {
     43    textpad = graphic[0].font[0].ascent;
     44    textdY = 6*textpad + 7*PAD1;
     45    WdY = MAX (ZOOM_Y, textdY + 2*BUTTON_HEIGHT + PAD1);
     46
     47    switch (section->image->location) {
     48      case 1:
     49        Y0 = graphic[0].dy * section[0].y + 2*PAD1 + WdY + 2; // tied to image in Y
     50        dY = graphic[0].dy * section[0].dy - 5*PAD1 - WdY - COLORPAD + 1;
     51        break;
     52      case 3:
     53        dY = graphic[0].dy * section[0].dy - 5*PAD1 - WdY - COLORPAD - PADy - PYm;
     54        break;
     55      case 2:
     56        X0 = graphic[0].dx * section[0].x  + 2*PAD1 + ZOOM_X;
     57        dX = graphic[0].dx * section[0].dx - 3*PAD1 - ZOOM_X;
     58        break;
     59      case 4:
     60        dX = graphic[0].dx * section[0].dx - 3*PAD1 - ZOOM_X - PADx - PXm;
     61        break;
     62    }
     63  }
    3964
    4065  /* define locations of coordinate axes */
  • trunk/Ohana/src/kapa2/src/SetImageSize.c

    r13320 r13479  
    77void SetImageSize (Section *section) {
    88
     9  int Xs, Ys, Xe, Ye, dX, dY;
     10  int textpad, textdY, WdY;
    911  KapaImageWidget *image;
     12  KapaGraphWidget *graph;
    1013  Graphic *graphic;
    1114
     
    1316  image = section->image;
    1417  if (image == NULL) return;
     18  graph = section->graph;
    1519
    1620  graphic = GetGraphic ();
    1721
    18   image[0].cmapbar.dx = graphic[0].dx - 2*PAD1;
    19   image[0].cmapbar.dy = COLORPAD;
    20   image[0].cmapbar.x = PAD1;
    21   image[0].cmapbar.y = PAD1;
    22 
    23   image[0].zoom.dx = ZOOM_X;
    24   image[0].zoom.dy = ZOOM_Y;
    25   image[0].zoom.x = graphic[0].dx - PAD1 - ZOOM_X;
    26   image[0].zoom.y = image[0].cmapbar.y + image[0].cmapbar.dy + PAD2;
    27 
    28   image[0].picture.dx = image[0].zoom.x - 2*PAD1 - 25;
    29   image[0].picture.dy = graphic[0].dy - 2*PAD1 - PAD2 - COLORPAD - 25;
    30   image[0].picture.x = PAD1 + 25;
    31   image[0].picture.y = PAD1 + PAD2 + COLORPAD;
    32 
    33   /** everything below is tied in x-dir to the zoom box **/
    34   image[0].text_x = image[0].zoom.x;
    35   image[0].text_y = image[0].zoom.y + image[0].zoom.dy + PAD2;
    36 
    37   /*  image[0].PS_button.y = graphic[0].dy - BUTTON_HEIGHT - PAD1; */
    38   image[0].PS_button.x = image[0].zoom.x + 5;
    39   image[0].PS_button.y = 2*ZOOM_Y;
    40 
    41   /** everything below is tied to the PS_button in y-dir **/
    42   image[0].grey_button.x = image[0].PS_button.x + image[0].PS_button.dx + PAD1;
    43   image[0].grey_button.y = image[0].PS_button.y;
    44 
    45   image[0].rainbow_button.x = image[0].grey_button.x + image[0].grey_button.dx + PAD1;
    46   image[0].rainbow_button.y = image[0].PS_button.y;
    47 
    48   image[0].puns_button.x = image[0].rainbow_button.x + image[0].rainbow_button.dx + PAD1;
    49   image[0].puns_button.y = image[0].PS_button.y;
    50 
    51   image[0].recenter_button.x = image[0].puns_button.x + image[0].puns_button.dx + PAD1;
    52   image[0].recenter_button.y = image[0].PS_button.y;
    53 
    54   image[0].overlay_button[0].x = image[0].zoom.x + 5;
    55   image[0].overlay_button[0].y = image[0].PS_button.y - BUTTON_HEIGHT - PAD1;
     22  /* the image is placed within the graphic window in region specified by section */
     23  Xs = graphic[0].dx * section[0].x;
     24  Ys = graphic[0].dy * (1 - section[0].y - section[0].dy);
     25  dX = graphic[0].dx * section[0].dx;
     26  dY = graphic[0].dy * section[0].dy;
     27
     28  switch (image[0].location) {
     29    case 0:
     30      if (section->graph) {
     31          image[0].picture.x  = graph[0].axis[0].fx;
     32          image[0].picture.y  = graph[0].axis[1].fy + graph[0].axis[1].dfy;
     33          image[0].picture.dx = MAX(graph[0].axis[0].dfx + 1, 1);
     34          image[0].picture.dy = MAX(fabs(graph[0].axis[1].dfy) - 1, 1);
     35      } else {
     36          image[0].picture.x  = Xs + PAD1;
     37          image[0].picture.y  = Ys + PAD1;
     38          image[0].picture.dx = dX - 2*PAD1;
     39          image[0].picture.dy = dY - 2*PAD1;
     40      }
     41      if (USE_XWINDOW) CreatePicture (image, graphic);
     42      Remap (graphic, image, &image[0].matrix);
     43      return;
     44
     45    case 1:
     46      textpad = graphic[0].font[0].ascent;
     47      textdY = 6*textpad + 7*PAD1;
     48      WdY = MAX (ZOOM_Y, textdY + 2*BUTTON_HEIGHT + PAD1);
     49
     50      if (section->graph) {
     51          image[0].picture.x = graph[0].axis[0].fx;
     52          image[0].picture.y = Ys + 2*PAD1 + COLORPAD;
     53          image[0].picture.dx = graph[0].axis[0].dfx;
     54          image[0].picture.dy = dY - 5*PAD1 - WdY - COLORPAD;
     55      } else {
     56          image[0].picture.x  = Xs + PAD1;
     57          image[0].picture.y  = Ys + 2*PAD1 + COLORPAD;
     58          image[0].picture.dx = dX - 2*PAD1;
     59          image[0].picture.dy = dY - 5*PAD1 - WdY - COLORPAD;
     60      }
     61
     62      image[0].cmapbar.dx = dX - 2*PAD1;
     63      image[0].cmapbar.dy = COLORPAD;
     64      image[0].cmapbar.x = Xs + PAD1;
     65      image[0].cmapbar.y = Ys + PAD1;
     66
     67      // XXX zoom should scale somewhat with the image? (with a min and a max)
     68      // XXX actually, it is limited by the buttons and status region
     69      image[0].zoom.dx = ZOOM_X;
     70      image[0].zoom.dy = ZOOM_Y;
     71      image[0].zoom.x = Xs + PAD1;
     72      image[0].zoom.y = image[0].picture.y + image[0].picture.dy + PAD1;
     73
     74      /** everything below is tied in x-dir to the zoom box **/
     75      image[0].text_x = image[0].zoom.x + image[0].zoom.dx + PAD1;
     76      image[0].text_y = image[0].zoom.y;
     77      image[0].text_dx = ZOOM_X;
     78      image[0].text_dy = 6*textpad + 7*PAD1;
     79
     80      image[0].overlay_button[0].x = image[0].text_x;
     81      image[0].overlay_button[0].y = image[0].text_y + image[0].text_dy + PAD1;
    5682   
    57   image[0].overlay_button[1].x = image[0].overlay_button[0].x + image[0].overlay_button[0].dx + PAD1;
    58   image[0].overlay_button[1].y = image[0].PS_button.y - BUTTON_HEIGHT - PAD1;
    59 
    60   image[0].overlay_button[2].x = image[0].overlay_button[1].x + image[0].overlay_button[1].dx + PAD1;
    61   image[0].overlay_button[2].y = image[0].PS_button.y - BUTTON_HEIGHT - PAD1;
    62 
    63   image[0].overlay_button[3].x = image[0].overlay_button[2].x + image[0].overlay_button[2].dx + PAD1;
    64   image[0].overlay_button[3].y = image[0].PS_button.y - BUTTON_HEIGHT - PAD1;
    65 
    66   image[0].hms_button.x = image[0].overlay_button[3].x + image[0].overlay_button[3].dx + PAD1;
    67   image[0].hms_button.y = image[0].PS_button.y - BUTTON_HEIGHT - PAD1;
     83      image[0].overlay_button[1].x = image[0].overlay_button[0].x + image[0].overlay_button[0].dx + PAD1;
     84      image[0].overlay_button[1].y = image[0].overlay_button[0].y;
     85
     86      image[0].overlay_button[2].x = image[0].overlay_button[1].x + image[0].overlay_button[1].dx + PAD1;
     87      image[0].overlay_button[2].y = image[0].overlay_button[0].y;
     88
     89      image[0].overlay_button[3].x = image[0].overlay_button[2].x + image[0].overlay_button[2].dx + PAD1;
     90      image[0].overlay_button[3].y = image[0].overlay_button[0].y;
     91
     92      image[0].hms_button.x = image[0].overlay_button[3].x + image[0].overlay_button[3].dx + PAD1;
     93      image[0].hms_button.y = image[0].overlay_button[0].y;
     94
     95      image[0].PS_button.x = image[0].text_x;
     96      image[0].PS_button.y = image[0].overlay_button[0].y + BUTTON_HEIGHT + PAD1;
     97
     98      /** everything below is tied to the PS_button in y-dir + the neighbor in x-dir **/
     99      image[0].grey_button.x = image[0].PS_button.x + image[0].PS_button.dx + PAD1;
     100      image[0].grey_button.y = image[0].PS_button.y;
     101
     102      image[0].rainbow_button.x = image[0].grey_button.x + image[0].grey_button.dx + PAD1;
     103      image[0].rainbow_button.y = image[0].PS_button.y;
     104
     105      image[0].puns_button.x = image[0].rainbow_button.x + image[0].rainbow_button.dx + PAD1;
     106      image[0].puns_button.y = image[0].PS_button.y;
     107
     108      image[0].recenter_button.x = image[0].puns_button.x + image[0].puns_button.dx + PAD1;
     109      image[0].recenter_button.y = image[0].PS_button.y;
     110      break;
     111
     112    case 3:
     113      textpad = graphic[0].font[0].ascent;
     114      textdY = 6*textpad + 7*PAD1;
     115      WdY = MAX (ZOOM_Y, textdY + 2*BUTTON_HEIGHT + PAD1);
     116
     117      if (section->graph) {
     118        image[0].picture.x = graph[0].axis[0].fx;
     119        image[0].picture.y = graph[0].axis[1].fy + graph[0].axis[1].dfy;
     120        image[0].picture.dx = MAX(graph[0].axis[0].dfx, 1);
     121        image[0].picture.dy = MAX(fabs(graph[0].axis[1].dfy) - 1, 1);
     122      } else {
     123        image[0].picture.dx = dX - 2*PAD1;
     124        image[0].picture.dy = dY - 5*PAD1 - WdY - COLORPAD;
     125        image[0].picture.x = Xs + PAD1;
     126        image[0].picture.y = Ys + 4*PAD1 + COLORPAD + WdY;
     127      }
     128
     129      image[0].cmapbar.dx = dX - 2*PAD1;
     130      image[0].cmapbar.dy = COLORPAD;
     131      image[0].cmapbar.x = Xs + PAD1;
     132      image[0].cmapbar.y = Ys + PAD1;
     133
     134      // XXX zoom should scale somewhat with the image? (with a min and a max)
     135      // XXX actually, it is limited by the buttons and status region
     136      image[0].zoom.dx = ZOOM_X;
     137      image[0].zoom.dy = ZOOM_Y;
     138      image[0].zoom.x = Xs + PAD1;
     139      image[0].zoom.y = Ys + 2*PAD1 + COLORPAD;
     140
     141      /** everything below is tied in x-dir to the zoom box **/
     142      image[0].text_x = image[0].zoom.x + image[0].zoom.dx + PAD1;
     143      image[0].text_y = image[0].zoom.y;
     144      image[0].text_dx = ZOOM_X;
     145      image[0].text_dy = 6*textpad + 7*PAD1;
     146
     147      image[0].overlay_button[0].x = image[0].text_x;
     148      image[0].overlay_button[0].y = image[0].text_y + image[0].text_dy + PAD1;
     149   
     150      image[0].overlay_button[1].x = image[0].overlay_button[0].x + image[0].overlay_button[0].dx + PAD1;
     151      image[0].overlay_button[1].y = image[0].overlay_button[0].y;
     152
     153      image[0].overlay_button[2].x = image[0].overlay_button[1].x + image[0].overlay_button[1].dx + PAD1;
     154      image[0].overlay_button[2].y = image[0].overlay_button[0].y;
     155
     156      image[0].overlay_button[3].x = image[0].overlay_button[2].x + image[0].overlay_button[2].dx + PAD1;
     157      image[0].overlay_button[3].y = image[0].overlay_button[0].y;
     158
     159      image[0].hms_button.x = image[0].overlay_button[3].x + image[0].overlay_button[3].dx + PAD1;
     160      image[0].hms_button.y = image[0].overlay_button[0].y;
     161
     162      image[0].PS_button.x = image[0].text_x;
     163      image[0].PS_button.y = image[0].overlay_button[0].y + BUTTON_HEIGHT + PAD1;
     164
     165      /** everything below is tied to the PS_button in y-dir + the neighbor in x-dir **/
     166      image[0].grey_button.x = image[0].PS_button.x + image[0].PS_button.dx + PAD1;
     167      image[0].grey_button.y = image[0].PS_button.y;
     168
     169      image[0].rainbow_button.x = image[0].grey_button.x + image[0].grey_button.dx + PAD1;
     170      image[0].rainbow_button.y = image[0].PS_button.y;
     171
     172      image[0].puns_button.x = image[0].rainbow_button.x + image[0].rainbow_button.dx + PAD1;
     173      image[0].puns_button.y = image[0].PS_button.y;
     174
     175      image[0].recenter_button.x = image[0].puns_button.x + image[0].puns_button.dx + PAD1;
     176      image[0].recenter_button.y = image[0].PS_button.y;
     177      break;
     178
     179    case 2:
     180
     181      if (section->graph) {
     182        image[0].picture.x = Xs + 2*PAD1 + ZOOM_X;
     183        image[0].picture.y = graph[0].axis[1].fy + graph[0].axis[1].dfy;
     184        image[0].picture.dx = dX - 3*PAD1 - ZOOM_X;
     185        image[0].picture.dy = MAX(fabs(graph[0].axis[1].dfy) - 1, 1);
     186      } else {
     187        image[0].picture.dx = dX - 3*PAD1 - ZOOM_X;
     188        image[0].picture.dy = dY - 3*PAD1 - COLORPAD;
     189        image[0].picture.x = Xs + 2*PAD1 + ZOOM_X;
     190        image[0].picture.y = Ys + 2*PAD1 + COLORPAD;
     191      }
     192
     193      image[0].cmapbar.dx = dX - 2*PAD1;
     194      image[0].cmapbar.dy = COLORPAD;
     195      image[0].cmapbar.x = Xs + PAD1;
     196      image[0].cmapbar.y = Ys + PAD1;
     197
     198      // XXX zoom should scale somewhat with the image? (with a min and a max)
     199      // XXX actually, it is limited by the buttons and status region
     200      image[0].zoom.dx = ZOOM_X;
     201      image[0].zoom.dy = ZOOM_Y;
     202      image[0].zoom.x = Xs + PAD1;
     203      image[0].zoom.y = image[0].picture.y;
     204
     205      /** everything below is tied in x-dir to the zoom box **/
     206      textpad = graphic[0].font[0].ascent;
     207      image[0].text_x = image[0].zoom.x;
     208      image[0].text_y = image[0].zoom.y + image[0].zoom.dy + PAD1;
     209      image[0].text_dx = ZOOM_X;
     210      image[0].text_dy = 6*textpad + 7*PAD1;
     211
     212      image[0].overlay_button[0].x = image[0].text_x;
     213      image[0].overlay_button[0].y = image[0].text_y + image[0].text_dy + PAD1;
     214   
     215      image[0].overlay_button[1].x = image[0].overlay_button[0].x + image[0].overlay_button[0].dx + PAD1;
     216      image[0].overlay_button[1].y = image[0].overlay_button[0].y;
     217
     218      image[0].overlay_button[2].x = image[0].overlay_button[1].x + image[0].overlay_button[1].dx + PAD1;
     219      image[0].overlay_button[2].y = image[0].overlay_button[0].y;
     220
     221      image[0].overlay_button[3].x = image[0].overlay_button[2].x + image[0].overlay_button[2].dx + PAD1;
     222      image[0].overlay_button[3].y = image[0].overlay_button[0].y;
     223
     224      image[0].hms_button.x = image[0].overlay_button[3].x + image[0].overlay_button[3].dx + PAD1;
     225      image[0].hms_button.y = image[0].overlay_button[0].y;
     226
     227      image[0].PS_button.x = image[0].zoom.x;
     228      image[0].PS_button.y = image[0].overlay_button[0].y + BUTTON_HEIGHT + PAD1;
     229
     230      /** everything below is tied to the PS_button in y-dir + the neighbor in x-dir **/
     231      image[0].grey_button.x = image[0].PS_button.x + image[0].PS_button.dx + PAD1;
     232      image[0].grey_button.y = image[0].PS_button.y;
     233
     234      image[0].rainbow_button.x = image[0].grey_button.x + image[0].grey_button.dx + PAD1;
     235      image[0].rainbow_button.y = image[0].PS_button.y;
     236
     237      image[0].puns_button.x = image[0].rainbow_button.x + image[0].rainbow_button.dx + PAD1;
     238      image[0].puns_button.y = image[0].PS_button.y;
     239
     240      image[0].recenter_button.x = image[0].puns_button.x + image[0].puns_button.dx + PAD1;
     241      image[0].recenter_button.y = image[0].PS_button.y;
     242      break;
     243
     244    case 4:
     245
     246      if (section->graph) {
     247        image[0].picture.x = graph[0].axis[0].fx;
     248        image[0].picture.y = graph[0].axis[1].fy + graph[0].axis[1].dfy;
     249        image[0].picture.dx = dX - 3*PAD1 - ZOOM_X - graph[0].axis[0].fx;
     250        image[0].picture.dy = MAX(fabs(graph[0].axis[1].dfy) - 1, 1);
     251      } else {
     252        image[0].picture.dx = dX - 3*PAD1 - ZOOM_X;
     253        image[0].picture.dy = dY - 3*PAD1 - COLORPAD;
     254        image[0].picture.x = Xs + PAD1;
     255        image[0].picture.y = Ys + 2*PAD1 + COLORPAD;
     256      }
     257
     258      image[0].cmapbar.dx = dX - 2*PAD1;
     259      image[0].cmapbar.dy = COLORPAD;
     260      image[0].cmapbar.x = Xs + PAD1;
     261      image[0].cmapbar.y = Ys + PAD1;
     262
     263      // XXX zoom should scale somewhat with the image? (with a min and a max)
     264      // XXX actually, it is limited by the buttons and status region
     265      image[0].zoom.dx = ZOOM_X;
     266      image[0].zoom.dy = ZOOM_Y;
     267      image[0].zoom.x = image[0].picture.x + image[0].picture.dx + PAD1;
     268      image[0].zoom.y = image[0].picture.y;
     269
     270      /** everything below is tied in x-dir to the zoom box **/
     271      textpad = graphic[0].font[0].ascent;
     272      image[0].text_x = image[0].zoom.x;
     273      image[0].text_y = image[0].zoom.y + image[0].zoom.dy + PAD1;
     274      image[0].text_dx = ZOOM_X;
     275      image[0].text_dy = 6*textpad + 7*PAD1;
     276
     277      image[0].overlay_button[0].x = image[0].text_x;
     278      image[0].overlay_button[0].y = image[0].text_y + image[0].text_dy + PAD1;
     279   
     280      image[0].overlay_button[1].x = image[0].overlay_button[0].x + image[0].overlay_button[0].dx + PAD1;
     281      image[0].overlay_button[1].y = image[0].overlay_button[0].y;
     282
     283      image[0].overlay_button[2].x = image[0].overlay_button[1].x + image[0].overlay_button[1].dx + PAD1;
     284      image[0].overlay_button[2].y = image[0].overlay_button[0].y;
     285
     286      image[0].overlay_button[3].x = image[0].overlay_button[2].x + image[0].overlay_button[2].dx + PAD1;
     287      image[0].overlay_button[3].y = image[0].overlay_button[0].y;
     288
     289      image[0].hms_button.x = image[0].overlay_button[3].x + image[0].overlay_button[3].dx + PAD1;
     290      image[0].hms_button.y = image[0].overlay_button[0].y;
     291
     292      image[0].PS_button.x = image[0].zoom.x;
     293      image[0].PS_button.y = image[0].overlay_button[0].y + BUTTON_HEIGHT + PAD1;
     294
     295      /** everything below is tied to the PS_button in y-dir + the neighbor in x-dir **/
     296      image[0].grey_button.x = image[0].PS_button.x + image[0].PS_button.dx + PAD1;
     297      image[0].grey_button.y = image[0].PS_button.y;
     298
     299      image[0].rainbow_button.x = image[0].grey_button.x + image[0].grey_button.dx + PAD1;
     300      image[0].rainbow_button.y = image[0].PS_button.y;
     301
     302      image[0].puns_button.x = image[0].rainbow_button.x + image[0].rainbow_button.dx + PAD1;
     303      image[0].puns_button.y = image[0].PS_button.y;
     304
     305      image[0].recenter_button.x = image[0].puns_button.x + image[0].puns_button.dx + PAD1;
     306      image[0].recenter_button.y = image[0].PS_button.y;
     307      break;
     308
     309    default:
     310      abort ();
     311      break;
     312  }
    68313
    69314  if (USE_XWINDOW) {
  • trunk/Ohana/src/kapa2/src/SetLimits.c

    r13320 r13479  
    11# include "Ximage.h"
    22
    3 int SetLimits () {
     3int SetLimits (int sock) {
    44 
    55  int i;
     
    1414
    1515  section = GetActiveSection();
    16   if (section->graph == NULL) return (TRUE);
     16  if (section->graph == NULL) {
     17    section->graph = InitGraph ();
     18    SetSectionSizes (section);
     19  }
    1720  graph = section->graph;
    18 
     21 
    1922  graph[0].axis[2].min = graph[0].axis[0].min = xmin;
    2023  graph[0].axis[2].max = graph[0].axis[0].max = xmax;
     
    3235  Refresh (1);
    3336
    34   return (TRUE);
    35  
     37  return (TRUE); 
    3638}
    3739
    38 int GetLimits () {
     40int GetLimits (int sock) {
    3941 
    4042  double dX, dY;
  • trunk/Ohana/src/kapa2/src/SetNormalHints.c

    r13320 r13479  
    1717
    1818  // XXX : can we drop the position flag
    19   sizehints[0].flags = USPosition | USSize | PMinSize;
     19  // sizehints[0].flags = USPosition | USSize | PMinSize;
     20  sizehints[0].flags = USSize | PMinSize;
    2021
    2122  sizehints[0].base_width = graphic->dx;
  • trunk/Ohana/src/kapa2/src/SetSection.c

    r13320 r13479  
    22
    33// set active section
    4 int SetSection () {
     4int SetSection (int sock) {
    55 
    66  int N;
  • trunk/Ohana/src/kapa2/src/UpdatePointer.c

    r13320 r13479  
    66  int textpad;
    77  double  x, y, z;
     8  float *data;
    89  char line[100];
    910  Section *section;
     
    1314  section = GetActiveSection();
    1415  image   = section->image;
     16  if (image == NULL) return (TRUE);
     17  if (!image[0].location) return (TRUE);
    1518
    1619  if (image[0].MovePointer && InPicture ((XButtonEvent *)event, &image[0].picture)) {
    1720
     21    data = (float *) image[0].matrix.buffer;
    1822    Screen_to_Image (&x, &y, (double)event[0].x, (double)event[0].y, image);
    1923
    20     if ((x >= 0) && (x < image[0].matrix.Naxis[0]) && (y >= 0) && (y < image[0].matrix.Naxis[1])) {
    21       /*
    22       X = event[0].x - image[0].picture.x;
    23       Y = event[0].y - image[0].picture.y;
    24       pix = MIN (MAX (X + Y*image[0].picture.dx, 0), image[0].picture.dx*image[0].picture.dy - 1);
    25       z = image[0].range * image[0].picture.data[pix] / image[0].Npixels + image[0].zero;
    26       */
    27       z = -1;
    28     }
    29     else
    30       z = -1;
     24    z = -1;
     25    if (x < 0) goto skip;
     26    if (x >= image[0].matrix.Naxis[0]) goto skip;
     27    if (y < 0) goto skip;
     28    if (y >= image[0].matrix.Naxis[1]) goto skip;
     29    z = data[(int)(y)*image[0].matrix.Naxis[0] + (int)(x)];
     30
     31  skip:
    3132    image[0].x = x;
    3233    image[0].y = y;
     
    4344    CrossHairs (graphic, image);
    4445    XFlush (graphic[0].display);
    45    
    4646  }
    4747 
     
    5454    XSetForeground (graphic[0].display, graphic[0].gc, graphic[0].fore);
    5555    bzero (line, 100);
    56     sprintf (line, "%25.2f", z);
     56    sprintf (line, "%22.3f", z);
    5757    XDrawString (graphic[0].display, graphic[0].window, graphic[0].gc,
    5858                 image[0].text_x + PAD1, image[0].text_y + textpad + PAD1,
  • trunk/Ohana/src/kapa2/src/UpdateStatusBox.c

    r13320 r13479  
    1414    XSetForeground (graphic[0].display, graphic[0].gc, graphic[0].back);
    1515    XFillRectangle (graphic[0].display, graphic[0].window, graphic[0].gc,
    16                     image[0].text_x, image[0].text_y, ZOOM_X, 6*textpad+7*PAD1); 
     16                    image[0].text_x, image[0].text_y, image[0].text_dx, image[0].text_dy); 
    1717    XSetForeground (graphic[0].display, graphic[0].gc, graphic[0].fore);
    1818    XDrawRectangle (graphic[0].display, graphic[0].window, graphic[0].gc,
    19                     image[0].text_x, image[0].text_y, ZOOM_X, 6*textpad+7*PAD1);
     19                    image[0].text_x, image[0].text_y, image[0].text_dx, image[0].text_dy);
    2020 
    2121    bzero (line, 100);
     
    3131   
    3232    bzero (line, 100);
    33     sprintf (line, "(%s)                                          ", image[0].buffer_name);
     33    sprintf (line, "(%s)                                          ", image[0].name);
    3434    XDrawString (graphic[0].display, graphic[0].window, graphic[0].gc,
    3535                 image[0].text_x + PAD1, image[0].text_y + 6*textpad + 6*PAD1, line, 25);
     
    3838    XSetForeground (graphic[0].display, graphic[0].gc, graphic[0].back);
    3939    XFillRectangle (graphic[0].display, graphic[0].window, graphic[0].gc,
    40                     image[0].text_x + 1, image[0].text_y + 1, ZOOM_X - 2, 3*textpad+3*PAD1 +1); 
     40                    image[0].text_x+1, image[0].text_y+1, image[0].text_dx-2, image[0].text_dy-2); 
    4141    XSetForeground (graphic[0].display, graphic[0].gc, graphic[0].fore);
    4242  }
    4343  bzero (line, 100);
    44   sprintf (line, "%25.3f", z);
     44  sprintf (line, "%22.3f", z);
    4545  XDrawString (graphic[0].display, graphic[0].window, graphic[0].gc,
    4646               image[0].text_x + PAD1, image[0].text_y + textpad + PAD1, line, strlen(line));
    4747 
    4848  bzero (line, 100);
    49   sprintf (line, "%12.1f %12.1f", x, y);
     49  sprintf (line, "%10.1f %10.1f", x, y);
    5050  XDrawString (graphic[0].display, graphic[0].window, graphic[0].gc,
    5151               image[0].text_x + PAD1, image[0].text_y + 2*textpad + 2*PAD1, line, strlen(line));
     
    5353  bzero (line, 100);
    5454  if (image[0].DecimalDegrees) {
    55     sprintf (line, "%12.6f %12.6f", ra, dec);
     55    sprintf (line, "%10.6f %10.6f", ra, dec);
    5656  } else {
    5757    hh_hms (line, ra, dec, ':');
  • trunk/Ohana/src/kapa2/src/bDrawIt.c

    r13320 r13479  
    2222      section = GetSectionByNumber (i);
    2323      bDrawGraph (section->graph);
    24       // bDrawImage (section->graph);
     24      // bDrawImage (section->image);
    2525  }
    2626
  • trunk/Ohana/src/kapa2/src/bDrawOverlay.c

    r13320 r13479  
    2323    expand = fabs((double)image[0].expand);
    2424  }
    25   /*
    26   X = 0.5*image[0].matrix.Naxis[0] - expand*((int)(0.5*image[0].picture.dx + 0.5) - 0.0) - image[0].X;
    27   Y = 0.5*image[0].matrix.Naxis[1] - expand*((int)(0.5*image[0].picture.dy + 0.5) - 0.0) - image[0].Y; 
    28   X0 =  (image[0].X + 1 - (int)(0.5*image[0].matrix.Naxis[0] + 0.5) - X + (int)X)/expand + image[0].picture.x + 0.5*image[0].picture.dx;
    29   Y0 =  (image[0].Y + 1 - (int)(0.5*image[0].matrix.Naxis[1] + 0.5) - Y + (int)Y)/expand + image[0].picture.y + 0.5*image[0].picture.dy;
    30   */
    3125
    3226  Image_to_Screen (&X0, &Y0, 0.0, 0.0, image);
     
    6256       for a BOX (x, y) is the center, (dx, dy) is the width */
    6357
    64     if (!strcasecmp (image[0].overlay[N].objects[i].type, "LINE")) {
    65       bDrawLine (X, Y, (X+dX), (Y+dY));
    66       continue;
     58    switch (image[0].overlay[N].objects[i].type) {
     59      case KII_OVERLAY_LINE:
     60        bDrawLine (X, Y, (X+dX), (Y+dY));
     61        break;
     62      case KII_OVERLAY_TEXT:
     63        bDrawRotText (X, Y, image[0].overlay[N].objects[i].text, 8, 0.0);
     64        break;
     65      case KII_OVERLAY_BOX:
     66        dx = MAX (abs(dX),2) / 2;
     67        dy = MAX (abs(dY),2) / 2;
     68        bDrawRectOpen ((X-dx), (Y-dy), (X+dx), (Y+dy));
     69        // bDrawRectOpen ((X-dx), (Y-dy), (X), (Y));
     70        break;
     71      case KII_OVERLAY_CIRCLE:
     72        dx = MAX (abs(dX),2);
     73        dy = MAX (abs(dY),2);
     74        bDrawArc (X, Y, dx, dy, 0, 360);
     75        break;
     76      default:
     77        fprintf (stderr, "skipping unknown object\n");
     78        break;
    6779    }
    68     if (!strcasecmp (image[0].overlay[N].objects[i].type, "TEXT")) {
    69       bDrawRotText (X, Y, image[0].overlay[N].objects[i].text, 8, 0.0);
    70       continue;
    71     }
    72     if (!strcasecmp (image[0].overlay[N].objects[i].type, "BOX")) {
    73       dx = MAX (abs(dX),2) / 2;
    74       dy = MAX (abs(dY),2) / 2;
    75       bDrawRectOpen ((X-dx), (Y-dy), (X+dx), (Y+dy));
    76       // bDrawRectOpen ((X-dx), (Y-dy), (X), (Y));
    77        continue;
    78     }
    79     if (!strcasecmp (image[0].overlay[N].objects[i].type, "CIRCLE")) {
    80       dx = MAX (abs(dX),2);
    81       dy = MAX (abs(dY),2);
    82       bDrawArc (X, Y, dx, dy, 0, 360);
    83       continue;
    84     }
    85     fprintf (stderr, "don't know %s, skipping (PO)\n", image[0].overlay[N].objects[i].type);
    8680  }
    8781 
  • trunk/Ohana/src/kapa2/src/kapa.c

    r13320 r13479  
    77  SetUpGraphic (&argc, argv);
    88
    9   // XXX get socket connection here?
    10 
    119  InitLayout (argc, argv);
    1210  EventLoop ();
Note: See TracChangeset for help on using the changeset viewer.