IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 11, 2015, 2:14:39 PM (12 years ago)
Author:
eugene
Message:

merge changes from eam branch ipp-20140904

Location:
trunk/Ohana
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana

  • trunk/Ohana/src/kapa2/include/constants.h

    r36084 r37807  
    1010 | PointerMotionMask)
    1111
    12 # define NCHANNELS 3
     12# define NCHANNELS 10
    1313# define NPIXELS_DYNAMIC 128
    1414
  • trunk/Ohana/src/kapa2/include/structures.h

    r32695 r37807  
    217217  KapaImageChannel *image;
    218218  KapaImageChannel channel[NCHANNELS];
     219  int currentChannel;
    219220} KapaImageWidget;
    220221
  • trunk/Ohana/src/kapa2/src/CreatePicture.c

    r16270 r37807  
    4040
    4141  case 24:
     42   
     43    extra = 4 - (image[0].wide.dx * 3) % 4;
     44    REALLOCATE (image[0].wide.data, char, image[0].wide.dy*(3*image[0].wide.dx+extra));
     45
     46    extra = 4 - (image[0].zoom.dx * 3) % 4;
     47    REALLOCATE (image[0].zoom.data, char, image[0].zoom.dy*(3*image[0].zoom.dx+extra));
     48
    4249    extra = 4 - (image[0].picture.dx * 3) % 4;
    43     REALLOCATE (image[0].wide.data, char, image[0].wide.dy*(3*image[0].wide.dx+extra));
    44     REALLOCATE (image[0].zoom.data, char, image[0].zoom.dy*(3*image[0].zoom.dx+extra));
    4550    REALLOCATE (image[0].picture.data, char, image[0].picture.dy*(3*image[0].picture.dx+extra));
    4651    c = (unsigned char *) image[0].picture.data;
  • trunk/Ohana/src/kapa2/src/CursorOps.c

    r25757 r37807  
    100100  // Sx, Sy are the screen coordinates of the Ix,Iy pixel
    101101  Image_to_Picture (&Sx, &Sy, Ix, Iy, picture);
     102 
     103  // Sx,Sy should be forced into the pixel
     104  int Sxi = Sx + 0.5;
     105  int Syi = Sy + 0.5;
    102106
    103107  // i_start, j_start are now limited to valid screen coordinates
    104   *i_start = MIN (MAX (Sx, 0), picture[0].dx);
    105   *j_start = MIN (MAX (Sy, 0), picture[0].dy);
     108  *i_start = MIN (MAX (Sxi, 0), picture[0].dx);
     109  *j_start = MIN (MAX (Syi, 0), picture[0].dy);
    106110}
    107111 
     
    127131  Iy = MIN (MAX (Iy, 0), matrix[0].Naxis[1]);
    128132
    129   // I_end, J_end are the last displayed image pixel
    130   // *I_end = Ix;
    131   // *J_end = Iy;
    132 
    133133  // Sx, Sy are the screen coordinates of the Ix,Iy pixel
    134134  Image_to_Picture (&Sx, &Sy, Ix, Iy, picture);
    135135
     136  // Sx,Sy should be forced into the pixel
     137  int Sxi = Sx + 0.5;
     138  int Syi = Sy + 0.5;
     139
     140  // double IxTest, IyTest;
     141  // Picture_to_Image (&IxTest, &IyTest, Sx, Sy, picture);
     142  // fprintf (stderr, "dx,dy: %d,%d : %f,%f : %f,%f : %f:%f\n", picture[0].dx, picture[0].dy, Ix, Iy, Sx, Sy, IxTest, IyTest);
     143
    136144  // i_start, j_start are now limited to valid screen coordinates
    137   *i_end = MIN (MAX (Sx, 0), picture[0].dx);
    138   *j_end = MIN (MAX (Sy, 0), picture[0].dy);
     145  // XXX: i_end, j_end *should* be the last valid screen pixel plus 1
     146  *i_end = MIN (MAX (Sxi, 0), picture[0].dx);
     147  *j_end = MIN (MAX (Syi, 0), picture[0].dy);
    139148
    140149  // round off error can leave us with a small number of extra pixels here.
  • trunk/Ohana/src/kapa2/src/Graphs.c

    r36487 r37807  
    5757  graph[0].data.flipnorth = FALSE;      // +North = +Y by default
    5858
    59   graph[0].data.coords.pc1_1 = graph[0].data.coords.pc2_2 = 1.0;
    60   graph[0].data.coords.pc1_2 = graph[0].data.coords.pc2_1 = 0.0;
    61   graph[0].data.coords.crval1 = 0.0;
    62   graph[0].data.coords.crval2 = 0.0;
    63   graph[0].data.coords.crpix1 = 0.0;
    64   graph[0].data.coords.crpix2 = 0.0;
    65   graph[0].data.coords.cdelt1 = graph[0].data.coords.cdelt2 = 1.0;
    66   strcpy (graph[0].data.coords.ctype, "DEC--LIN");
     59  InitCoords (&graph[0].data.coords, "DEC--LIN");
    6760  strcpy (graph[0].data.axis, "2222");
    6861  strcpy (graph[0].data.ticks, "2222");
  • trunk/Ohana/src/kapa2/src/Image.c

    r36487 r37807  
    1111  channel->slope = 1;
    1212
    13   channel->coords.pc1_1 = channel->coords.pc2_2 = 1.0;
    14   channel->coords.pc1_2 = channel->coords.pc2_1 = 0.0;
    15   channel->coords.crval1 = 0.0;
    16   channel->coords.crval2 = 0.0;
    17   channel->coords.crpix1 = 0.0;
    18   channel->coords.crpix2 = 0.0;
    19   channel->coords.cdelt1 = channel->coords.cdelt2 = 1.0;
    20   strcpy (channel->coords.ctype, "DEC--LIN");
    21   channel->coords.Npolyterms = 0;
     13  InitCoords (&channel->coords, "DEC--LIN");
    2214
    2315  channel->matrix.datasize = 0; /* a flag to show there is no data in the matrix */
     
    4234    InitImageChannel (&image[0].channel[i]);
    4335  }
    44   image[0].image = &image[0].channel[0];
     36
     37  image[0].currentChannel = 0;
     38  image[0].image = &image[0].channel[image[0].currentChannel];
    4539
    4640  image[0].nPixels = 0;
  • trunk/Ohana/src/kapa2/src/InterpretKeys.c

    r37412 r37807  
    9090  switch (keysym) {
    9191
    92     case XK_F1:
    93       image[0].image = &image[0].channel[0];
    94       SetColorScale (graphic, image);
    95       Remap (graphic, image);
    96       Reorient (graphic, image, image[0].picture.Xc, image[0].picture.Yc, 0);
     92# define SET_CHANNEL_CASE(NCHAN) \
     93    case XK_F##NCHAN: \
     94      image[0].currentChannel = NCHAN-1; \
     95      image[0].image = &image[0].channel[NCHAN-1]; \
     96      SetColorScale (graphic, image); \
     97      Reorient (graphic, image, image[0].picture.Xc, image[0].picture.Yc, 0); \
     98      Screen_to_Image (&X, &Y, (double)(event[0].x + 0.5), (double)(event[0].y + 0.5), &image[0].picture); \
     99      UpdateStatusBox (graphic, image, X, Y, 0.0, 1); \
    97100      break;
    98101
    99     case XK_F2:
    100       image[0].image = &image[0].channel[1];
    101       SetColorScale (graphic, image);
    102       Remap (graphic, image);
    103       Reorient (graphic, image, image[0].picture.Xc, image[0].picture.Yc, 0);
    104       break;
     102//    Remap (graphic, image);
    105103
    106     case XK_F3:
    107       image[0].image = &image[0].channel[2];
    108       SetColorScale (graphic, image);
    109       Remap (graphic, image);
    110       Reorient (graphic, image, image[0].picture.Xc, image[0].picture.Yc, 0);
    111       break;
     104    // the number of entries here must match the value of NCHANNELS in contants.h
     105    SET_CHANNEL_CASE(1);
     106    SET_CHANNEL_CASE(2);
     107    SET_CHANNEL_CASE(3);
     108    SET_CHANNEL_CASE(4);
     109    SET_CHANNEL_CASE(5);
     110    SET_CHANNEL_CASE(6);
     111    SET_CHANNEL_CASE(7);
     112    SET_CHANNEL_CASE(8);
     113    SET_CHANNEL_CASE(9);
     114    SET_CHANNEL_CASE(10);
    112115
    113116    case XK_KP_Home:
  • trunk/Ohana/src/kapa2/src/LoadPicture.c

    r28241 r37807  
    5555  // choose expand for wide to guarantee we fit:
    5656  wx = MAX ((header.Naxis[0] / (float) image[0].wide.dx), (header.Naxis[1] / (float) image[0].wide.dy));
    57   if (wx > 1.0) {
    58     image[0].wide.expand = -wx;
    59   } else {
    60     image[0].wide.expand = 1.0 / wx;
    61   }   
     57
     58  // -4.002 -> -5
     59  // image[0].wide.expand = (wx > 1.0) ? ceil (-wx) : floor (1.0 / wx);
     60  image[0].wide.expand = (wx > 1.0) ? floor (-wx) : ceil (1.0 / wx);
     61  // fprintf (stderr, "%d : %f\n", image[0].wide.expand, wx);
     62  image[0].wide.expand = (wx > 1.0) ? ceil (-wx) : floor (1.0 / wx);
     63
    6264  image[0].wide.Xc = 0.5*header.Naxis[0];
    6365  image[0].wide.Yc = 0.5*header.Naxis[1];
  • trunk/Ohana/src/kapa2/src/Reconfig.c

    r21153 r37807  
    1515
    1616  // if the new size is the same as the old size, do nothing.
    17   if ((graphic->dx == NX) && (graphic->dy == NY)) return (TRUE);
     17  if ((graphic->dx == NX) && (graphic->dy == NY)) {
     18    if (USE_XWINDOW) XClearWindow (graphic->display, graphic->window);
     19    Refresh ();
     20    return (TRUE);
     21  }
    1822
    1923  // set the new window size
  • trunk/Ohana/src/kapa2/src/Remap32.c

    r34088 r37807  
    3737  swap_client = 0;
    3838# endif 
    39 
    4039  swap_server = ImageByteOrder (graphic[0].display);
    4140  swap_bytes = !(swap_client ^ swap_server);
     
    9190  in_pix  = &image[0].pixmap[DX*(int)MAX(Iy,0) + (int)MAX(Ix,0)];
    9291
     92  unsigned short *in_base = image[0].pixmap;
     93  OUT_TYPE *out_base = (OUT_TYPE *) picture[0].data;
     94
     95  int Ninmax = matrix[0].Naxis[0] * matrix[0].Naxis[1];
     96  int Noutmax = picture[0].dx * picture[0].dy;
     97
    9398  /********** below we do the mapping from buffer pixels (in) to picture pixels (out) **********/
    9499
    95100  /**** fill in bottom area ****/
    96101  for (j = 0; j < dx*j_start; j++, out_pix++) {
     102    myAssert (out_pix - out_base < Noutmax, "too far out");
    97103    *out_pix = back;
    98104  }
     
    105111      out_pix2 = out_pix + jj*dx;
    106112      for (i = 0; i < i_start; i++, out_pix2++) {
     113        myAssert (out_pix2 - out_base < Noutmax, "too far out");
    107114        *out_pix2 = back;
    108115      }
     
    114121    if (expand_out == 1) {
    115122      for (i = i_start; i < i_end; i++, in_pix2 += inDX*expand_in, out_pix++) {
     123        myAssert (out_pix - out_base < Noutmax, "too far out");
     124        myAssert (in_pix2 - in_base < Ninmax, "too far in");
    116125        *out_pix = pixel[*in_pix2];
    117126      }
    118127    } else {
    119128      for (i = i_start; i < i_end; i+= expand_out, in_pix2 += inDX, out_pix+= expand_out) {
     129        myAssert (in_pix2 - in_base < Ninmax, "too far in");
    120130        pixvalue = pixel[*in_pix2];
    121131        out_pix2 = out_pix;
    122132        for (jj = 0; (jj < expand_out) && (j + jj < dy); jj++, out_pix2+=(dx-expand_out)) {
    123133          for (ii = 0; ii < expand_out; ii++, out_pix2++) {
     134            myAssert (out_pix2 - out_base < Noutmax, "too far out");
    124135            *out_pix2 = pixvalue;
    125136          }
     
    133144      out_pix2 = out_pix + jj*dx;
    134145      for (i = i_end; i < dx; i++, out_pix2++) {
     146        myAssert (out_pix2 - out_base < Noutmax, "too far out");
    135147        *out_pix2 = back;
    136148      }
     
    142154  for (j = 0; j < dy - j_end; j++) {
    143155    for (i = 0; i < dx; i++, out_pix ++) {
     156      myAssert (out_pix - out_base < Noutmax, "too far out");
    144157      *out_pix = back;
    145158    }
  • trunk/Ohana/src/kapa2/src/SetChannel.c

    r31665 r37807  
    2121  if (Nchannel >= NCHANNELS) return (TRUE);
    2222 
    23   image[0].image = &image[0].channel[Nchannel];
     23  image[0].currentChannel = Nchannel;
     24  image[0].image = &image[0].channel[image[0].currentChannel];
    2425  SetColorScale (graphic, image);
    2526
     
    6162
    6263  Refresh ();
    63   XFlush (graphic[0].display);
     64  if (USE_XWINDOW) XFlush (graphic[0].display);
    6465
    6566  return (TRUE);
  • trunk/Ohana/src/kapa2/src/UpdateStatusBox.c

    r30606 r37807  
    2020 
    2121    bzero (line, 100);
    22     snprintf (line, 100, "(%d x %d) @ %d                                         ",
    23              image[0].picture.dx, image[0].picture.dy, image[0].picture.expand);
     22    snprintf (line, 100, "(%d x %d) @ %d   ch: %d                                     ",
     23              image[0].picture.dx, image[0].picture.dy, image[0].picture.expand, image[0].currentChannel+1);
    2424    XDrawString (graphic[0].display, graphic[0].window, graphic[0].gc,
    2525                 image[0].text_x + PAD1, image[0].text_y + 4*textpad + 4*PAD1, line, 25);
Note: See TracChangeset for help on using the changeset viewer.