IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 13465


Ignore:
Timestamp:
May 21, 2007, 6:29:09 PM (19 years ago)
Author:
eugene
Message:

fixed cursor functions

Location:
branches/kapa-mods-2007-05/Ohana/src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • branches/kapa-mods-2007-05/Ohana/src/kapa2/src/CheckPipe.c

    r13434 r13465  
    1010  InitSocket = KapaServerInit (&Address);
    1111  return;
     12}
     13
     14int GetActiveSocket () {
     15  return (sock);
    1216}
    1317
     
    5761    if (strcmp (word, "NCUR")) {
    5862      fprintf (stderr, "wrong end message %s\n", word);
     63      KiiSendCommand (sock, 4, "DONE");
    5964      FINISHED (TRUE);
    6065    }
    6166    ACTIVE_CURSOR = FALSE;
     67    KiiSendCommand (sock, 4, "DONE");
    6268    FINISHED (TRUE);
    6369  }
     
    6773  if (!strcmp (word, "CURS")) {
    6874    ACTIVE_CURSOR = TRUE;
     75    KiiSendCommand (sock, 4, "DONE");
    6976    FINISHED (TRUE);
    7077  }
     
    269276
    270277  fprintf (stderr, "unknown signal %s\n", word);
     278  KiiSendCommand (sock, 4, "DONE");
    271279  FINISHED (TRUE);
    272280}
  • branches/kapa-mods-2007-05/Ohana/src/kapa2/src/InterpretKeys.c

    r13344 r13465  
    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     // XXX need to do something different here
    58     // xxx 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);
    5977  }
    6078
  • branches/kapa-mods-2007-05/Ohana/src/kapa2/src/InterpretPresses.c

    r13344 r13465  
    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     // need to do something different here...
    37     // xxx 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);
    3853  }
    3954
  • branches/kapa-mods-2007-05/Ohana/src/libkapa/include/kapa.h

    r13434 r13465  
    142142int KiiCursorOn (int fd);
    143143int KiiCursorOff (int fd);
    144 int KiiCursorRead (int fd, double *x, double *y, char *key);
     144int KiiCursorRead (int fd, double *x, double *y, double *z, double *r, double *d, char *key);
    145145
    146146/* KapaWindow.c */
  • branches/kapa-mods-2007-05/Ohana/src/libkapa/src/IOfuncs.c

    r13437 r13465  
    7575  /* make the string easy to parse */
    7676
    77   // fprintf (stderr, "message recv: %s\n", message);
     77  // fprintf (stderr, "recv: %s\n", message);
    7878
    7979  /* scan the incoming message */
     
    109109
    110110  write (device, string, length);
     111
     112  // fprintf (stderr, "send: %s\n", string);
     113
    111114  free (string);
    112115  return (TRUE);
  • branches/kapa-mods-2007-05/Ohana/src/libkapa/src/KiiCursor.c

    r13409 r13465  
    1515}
    1616
    17 int KiiCursorRead (int fd, double *x, double *y, char *key) {
     17int KiiCursorRead (int fd, double *x, double *y, double *z, double *r, double *d, char *key) {
    1818
    19   char buffer[40];
    20 
    21   bzero (buffer, 40);
    22   read (fd, buffer, 40);
    23   buffer[39] = 0;
    24 
    25   sscanf (buffer, "%s %lf %lf", key, x, y);
     19  KiiScanMessage (fd, "%s %lf %lf %lf %lf %lf", key, x, y, z, r, d);
    2620  if (ispunct(key[0])) strcpy (key, "_");
    27 
    2821  return (TRUE);
    2922}
  • branches/kapa-mods-2007-05/Ohana/src/opihi/cmd.data/cursor.c

    r13434 r13465  
    77  double X, Y, R, D, Z;
    88  void *oldsignal;
    9   Graphdata graphmode;
    10   Buffer *buf;
    119
    1210  // XXX need to be able to specify graph vs image coords
     
    2220    remove_argument (N, &argc, argv);
    2321  }
    24   if (!GetGraph (&graphmode, &kapa, name)) return (FALSE);
     22  if (!GetGraphData (NULL, &kapa, name)) return (FALSE);
    2523  FREE (name);
    2624
     
    3331  }
    3432 
    35   buf = NULL;
    36   // if (IsImage) buf = SelectBuffer (GetImageName(), OLDBUFFER, FALSE);
    37   // XXX this stuff will go away with 32bit image data
    38  
    3933  KiiCursorOn (kapa);
    4034 
    4135  oldsignal = signal (SIGINT, handle_interrupt);
    4236  interrupt = FALSE;
    43   Z = -1.0;
     37
    4438  for (i = 0; ((i < N) || (N == 0)) && !interrupt; i++) {
    4539
    46     // XXX have kapa return x,y,z,ra,dec for all options
    47     KiiCursorRead (kapa, &X, &Y, key);
     40    KiiCursorRead (kapa, &X, &Y, &Z, &R, &D, key);
    4841
    4942    sprintf (string, "X%s", key);
     
    5144    sprintf (string, "Y%s", key);
    5245    set_variable (string, Y);
     46    sprintf (string, "Z%s", key);
     47    set_variable (string, Z);
     48    sprintf (string, "R%s", key);
     49    set_variable (string, R);
     50    sprintf (string, "D%s", key);
     51    set_variable (string, D);
     52
    5353    set_str_variable ("KEY", key);
    5454   
    55     if (buf != NULL) {
    56       Z = gfits_get_matrix_value (&buf[0].matrix, (int) X, (int) Y);
    57       // gprint (GP_LOG, "%s %f %f  %f\n", key, X, Y, Z);
    58     } else {
    59       XY_to_RD (&R, &D, X, Y, &graphmode.coords);
    60       sprintf (string, "R%s", key);
    61       set_variable (string, R);
    62       sprintf (string, "D%s", key);
    63       set_variable (string, D);
    64       gprint (GP_LOG, "%s %f %f\n", key, X, Y);
    65     }
     55    gprint (GP_LOG, "%s %f %f %f %f %f\n", key, X, Y, Z, R, D);
     56
    6657    if (!strcasecmp (key, "Q")) break;
    6758  }
  • branches/kapa-mods-2007-05/Ohana/src/opihi/dvo/scripts/navigate

    r10847 r13465  
    1111  $KEY = "none"
    1212  while ("$KEY" != "q")
    13     cursor -g 1
     13    cursor 1
    1414
    1515    # help list
     
    147147      $ok = $KEY
    148148      echo "type 'd' again at endpoint"
    149       cursor -g 1
     149      cursor 1
    150150      $r1 = $R$KEY
    151151      $d1 = $D$KEY
     
    168168      $ok = $KEY
    169169      echo "type 'z' again at radius"
    170       cursor -g 1
     170      cursor 1
    171171      $r1 = $R$KEY
    172172      $d1 = $D$KEY
     
    400400    if ("$KEY" == "p")
    401401      echo "P - new coords; p - old coords"
    402       cursor -g 1
     402      cursor 1
    403403      exec echo $Rp $Dp $RP $DP >> fix.coords
    404404    end
  • branches/kapa-mods-2007-05/Ohana/src/relphot/src/plotstuff.c

    r13455 r13465  
    2424
    2525  sprintf (name, "gastro [%d]", N);
    26   Xgraph[N] = KapaOpen ("/home/kiawe/eugene/psconfig/dev.linux/bin/kapa2", name);
     26  Xgraph[N] = KapaOpen ("kapa2", name);
    2727
    2828  if (Xgraph[N] < 0) {
Note: See TracChangeset for help on using the changeset viewer.