IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 16270


Ignore:
Timestamp:
Feb 1, 2008, 10:23:33 AM (18 years ago)
Author:
eugene
Message:

adding wide-field view port and flipx,flipy capability

Location:
trunk/Ohana/src/kapa2
Files:
1 added
10 edited

Legend:

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

    r16256 r16270  
    7777$(SRC)/PSOverlay.$(ARCH).o                $(SRC)/SetChannel.$(ARCH).o         \
    7878$(SRC)/SetColorScale.$(ARCH).o            $(SRC)/ColorCube.$(ARCH).o          \
    79 $(SRC)/ColorHistogram.$(ARCH).o           
     79$(SRC)/ColorHistogram.$(ARCH).o           $(SRC)/CreateWide.$(ARCH).o
    8080
    8181#$(SRC)/CreateZoom8.$(ARCH).o              $(SRC)/CreateZoom16.$(ARCH).o       \
  • trunk/Ohana/src/kapa2/include/prototypes.h

    r16256 r16270  
    219219void          CreateColorbar (KapaImageWidget *image, Graphic *graphic);
    220220void          CreateZoom (Graphic *graphic, KapaImageWidget *image);
     221void          CreateWide (Graphic *graphic, KapaImageWidget *image);
    221222void          UpdateStatusBox (Graphic *graphic, KapaImageWidget *image, double x, double y, double z, int mode);
    222223
  • trunk/Ohana/src/kapa2/include/structures.h

    r16256 r16270  
    9595  int      expand;            // zoomscale
    9696  double   X,  Y;             // center of image in picture
     97  char     flipx, flipy;      // parity (0 = +; 1 = -)
    9798  XImage  *pix;
    9899  char    *data;
  • trunk/Ohana/src/kapa2/src/ButtonFunctions.c

    r16256 r16270  
    1515  Remap (graphic, image);
    1616  CreateZoom (graphic, image);
     17  CreateWide (graphic, image);
    1718  Refresh ();
    1819  XFlush (graphic[0].display);
     
    2627  Remap (graphic, image);
    2728  CreateZoom (graphic, image);
     29  CreateWide (graphic, image);
    2830  Refresh ();
    2931  XFlush (graphic[0].display);
     
    3739  Remap (graphic, image);
    3840  CreateZoom (graphic, image);
     41  CreateWide (graphic, image);
    3942  Refresh ();
    4043  XFlush (graphic[0].display);
     
    7982int ToggleDEG (Graphic *graphic, KapaImageWidget *image) {
    8083
     84  image[0].picture.flipy = !image[0].picture.flipy;
     85  image[0].zoom.flipy = !image[0].zoom.flipy;
     86  image[0].wide.flipy = !image[0].wide.flipy;
    8187  image[0].DecimalDegrees = image[0].DecimalDegrees ^ TRUE;
    8288  StatusBox (graphic, image);
  • trunk/Ohana/src/kapa2/src/CreatePicture.c

    r16256 r16270  
    1212  switch (graphic[0].Nbits) {
    1313  case 8:
     14    REALLOCATE (image[0].wide.data,    char, image[0].wide.dx*image[0].wide.dy);
     15    REALLOCATE (image[0].zoom.data,    char, image[0].zoom.dx*image[0].zoom.dy);
    1416    REALLOCATE (image[0].picture.data, char, image[0].picture.dx*image[0].picture.dy);
    1517    c = (unsigned char *) image[0].picture.data;
     
    2123
    2224  case 16:
     25    REALLOCATE (image[0].wide.data,    char, 2*image[0].wide.dx*image[0].wide.dy);
     26    REALLOCATE (image[0].zoom.data,    char, 2*image[0].zoom.dx*image[0].zoom.dy);
    2327    REALLOCATE (image[0].picture.data, char, 2*image[0].picture.dy*image[0].picture.dx);
    2428    c = (unsigned char *) image[0].picture.data;
     
    3741  case 24:
    3842    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));
    3945    REALLOCATE (image[0].picture.data, char, image[0].picture.dy*(3*image[0].picture.dx+extra));
    4046    c = (unsigned char *) image[0].picture.data;
     
    5561
    5662  case 32:
     63    REALLOCATE (image[0].wide.data,    char, 4*image[0].wide.dx*image[0].wide.dy);
    5764    REALLOCATE (image[0].zoom.data,    char, 4*image[0].zoom.dx*image[0].zoom.dy);
    5865    REALLOCATE (image[0].picture.data, char, 4*image[0].picture.dx*image[0].picture.dy);
  • trunk/Ohana/src/kapa2/src/CursorOps.c

    r16256 r16270  
    44void Picture_to_Image (double *x1, double *y1, double x2, double y2, Picture *picture) {
    55
    6   double expand;
     6  double expand, dx, dy;
    77
    88  expand = 1.0;
     
    1313  }
    1414 
     15  // pixel coordinates in picture frame
     16  dx = expand*(x2 - 0.5*picture[0].dx);
     17  dy = expand*(y2 - 0.5*picture[0].dy);
     18
    1519  // picture[0].X,Y is the image coordinate in the center of the picture
    16   *x1 = expand*(x2 - 0.5*picture[0].dx) + picture[0].X;
    17   *y1 = expand*(y2 - 0.5*picture[0].dy) + picture[0].Y;
     20  *x1 = picture[0].flipx ? picture[0].X - dx : picture[0].X + dx;
     21  *y1 = picture[0].flipy ? picture[0].Y - dy : picture[0].Y + dy;
    1822}
    1923
     
    3236void Image_to_Picture (double *x1, double *y1, double x2, double y2, Picture *picture) {
    3337
    34   double expand;
     38  double expand, dx, dy;
    3539
    3640  /* notice that here, expand is the reciprocal of the expand above */
     
    4347 
    4448  // pixel coordinates in picture frame
    45   *x1 = expand*(x2 - picture[0].X) + 0.5*picture[0].dx;
    46   *y1 = expand*(y2 - picture[0].Y) + 0.5*picture[0].dy;
     49  dx = picture[0].flipx ? picture[0].X - x2 : x2 - picture[0].X;
     50  dy = picture[0].flipy ? picture[0].Y - y2 : y2 - picture[0].Y;
     51   
     52  *x1 = expand*dx + 0.5*picture[0].dx;
     53  *y1 = expand*dy + 0.5*picture[0].dy;
    4754}
    4855
     
    7077  Iy = MIN (MAX (Iy, 0), matrix[0].Naxis[1]);
    7178
    72   // round up to nearest pixel boundary
    73   if (Ix > (int)(Ix)) Ix = (int)(Ix) + 1;
    74   if (Iy > (int)(Iy)) Iy = (int)(Iy) + 1;
     79  // round up (down) to nearest pixel boundary
     80  if (Ix > (int)(Ix)) {
     81    Ix = picture[0].flipx ? (int)(Ix) : (int)(Ix) + 1;
     82  }
     83  if (Iy > (int)(Iy)) {
     84    Iy = picture[0].flipy ? (int)(Iy) : (int)(Iy) + 1;
     85  }
    7586
    7687  // Sx, Sy are the screen coordinates of the Ix,Iy pixel
     
    94105  Iy = MIN (MAX (Iy, 0), matrix[0].Naxis[1]);
    95106
    96   // round down to nearest pixel boundary
    97   if (Ix > (int)(Ix)) Ix = (int)(Ix);
    98   if (Iy > (int)(Iy)) Iy = (int)(Iy);
     107  // round down (up) to nearest pixel boundary
     108  if (Ix > (int)(Ix)) {
     109    Ix = picture[0].flipx ? (int)(Ix) + 1 : (int)(Ix);
     110  }
     111  if (Iy > (int)(Iy)) {
     112    Iy = picture[0].flipy ? (int)(Iy) + 1: (int)(Iy);
     113  }
    99114
    100115  // Sx, Sy are the screen coordinates of the Ix,Iy pixel
  • trunk/Ohana/src/kapa2/src/Image.c

    r16256 r16270  
    5151  image[0].picture.Y      = 0.0;
    5252  image[0].picture.expand = 1;
     53  image[0].picture.flipx  = FALSE;
     54  image[0].picture.flipy  = FALSE;
    5355
    5456  image[0].zoom.X         = 0.0;
    5557  image[0].zoom.Y         = 0.0;
    5658  image[0].zoom.expand    = +5;
     59  image[0].zoom.flipx     = FALSE;
     60  image[0].zoom.flipy     = FALSE;
    5761
    5862  image[0].wide.X         = 0.0;
    5963  image[0].wide.Y         = 0.0;
    6064  image[0].wide.expand    = -5;
     65  image[0].wide.flipx     = FALSE;
     66  image[0].wide.flipy     = FALSE;
    6167
    6268  image[0].location = 4;
     
    6773  ALLOCATE (image[0].cmapbar.data, char, 1);   /* allocate so later free will not crash! */
    6874  ALLOCATE (image[0].zoom.data, char, 1);      /* allocate so later free will not crash! */
     75  ALLOCATE (image[0].wide.data, char, 1);      /* allocate so later free will not crash! */
    6976
    7077  InitButtonSize (&image[0].PS_button, PS_width, PS_height, PS_bits);
     
    147154               image[0].cmapbar.x, image[0].cmapbar.y,
    148155               image[0].cmapbar.dx, image[0].cmapbar.dy);
     156
     157    XPutImage (graphic[0].display, graphic[0].window, graphic[0].gc,
     158               image[0].wide.pix, 0, 0,
     159               image[0].wide.x, image[0].wide.y,
     160               image[0].wide.dx, image[0].wide.dy);
    149161
    150162    CrossHairs (graphic, &image[0].zoom);
     
    188200  free (image[0].cmapbar.data);
    189201  free (image[0].zoom.data);
     202  free (image[0].wide.data);
    190203
    191204  free (image);
  • trunk/Ohana/src/kapa2/src/LoadPicture.c

    r16256 r16270  
    99  KapaImageWidget *image;
    1010  Graphic *graphic;
    11   double Xoffset, Yoffset;
     11  double Xoffset, Yoffset, wx;
    1212
    1313  graphic = GetGraphic ();
     
    4646  image[0].picture.Y = 0.5*header.Naxis[1] + Yoffset;
    4747
     48  // choose expand for wide to guarantee we fit:
     49  wx = MAX ((header.Naxis[0] / (float) image[0].wide.dx), (header.Naxis[1] / (float) image[0].wide.dy));
     50  if (wx > 1.0) {
     51    image[0].wide.expand = -wx;
     52  } else {
     53    image[0].wide.expand = 1.0 / wx;
     54  }   
     55  image[0].wide.X = 0.5*header.Naxis[0];
     56  image[0].wide.Y = 0.5*header.Naxis[1];
     57
    4858  fcntl (sock, F_SETFL, O_NONBLOCK); 
    4959
     
    7888  SetColorScale (graphic, image);
    7989  Remap (graphic, image);
     90  CreateWide (graphic, image);
    8091  if (DEBUG) fprintf (stderr, "remapped image\n");
    8192  Refresh ();
  • trunk/Ohana/src/kapa2/src/Remap32.c

    r16256 r16270  
    11# include "Ximage.h"
     2
     3# ifndef ISWAP
     4# define ISWAP(X,Y) {int tmp=(X); (X) = (Y); (Y) = tmp;}
     5# endif
    26
    37void Remap32 (Graphic *graphic, KapaImageWidget *image, Picture *picture, Matrix *matrix) {
     
    59  int i, j, ii, jj;
    610  int i_start, i_end, j_start, j_end;
    7   int dropback;
     11  int dropback, inDX, inDY;
    812  int dx, dy, DX, DY;
    913  double expand, Ix, Iy;
     
    4852  Picture_Upper (&i_end, &j_end, matrix, picture);
    4953
     54  if (i_end < i_start) ISWAP (i_start, i_end);
     55  if (j_end < j_start) ISWAP (j_start, j_end);
     56
    5057  // Ix,Iy are the first displayed image pixel
    5158  Picture_to_Image (&Ix, &Iy, i_start, j_start, picture);
     59  Ix = MIN (MAX (0, Ix), DX - 1);
     60  Iy = MIN (MAX (0, Iy), DY - 1);
     61  // XXX not completely consistent with the i_start, i_end range...
     62
     63  // we need to offset because i_start points to the bottom edge of Ix
     64  // if (picture[0].flipx) Ix -= 1.0;
     65  // if (picture[0].flipy) Iy -= 1.0;
     66
     67  inDX = picture[0].flipx ? -1 : +1;
     68  inDY = picture[0].flipy ? -1 : +1;
    5269
    5370  dropback = expand_out - (i_end - i_start) % expand_out;
     
    6481  }
    6582 
    66   for (j = j_start; j < j_end; j+= expand_out, out_pix+=(expand_out-1)*dx, in_pix += expand_in*DX) {
     83  for (j = j_start; j < j_end; j+= expand_out, out_pix+=(expand_out-1)*dx, in_pix += inDY*expand_in*DX) {
    6784
    6885    /**** fill in area to the left of the picture ****/
     
    7895    in_pix2 = in_pix;
    7996    if (expand_out == 1) {
    80       for (i = i_start; i < i_end; i++, in_pix2+= expand_in, out_pix++) {
     97      for (i = i_start; i < i_end; i++, in_pix2 += inDX*expand_in, out_pix++) {
    8198        *out_pix = pixel[*in_pix2];
    8299      }
    83100    } else {
    84       for (i = i_start; i < i_end; i+= expand_out, in_pix2++, out_pix+= expand_out) {
     101      for (i = i_start; i < i_end; i+= expand_out, in_pix2 += inDX, out_pix+= expand_out) {
    85102        pixvalue = pixel[*in_pix2];
    86103        out_pix2 = out_pix;
     
    94111    out_pix -= dropback;
    95112   
     113    // assert (in_pix2 - image[0].pixmap <= DX*DY);
     114    // assert (in_pix2 - image[0].pixmap >= 0);
     115    // assert (in_pix - image[0].pixmap <= DX*DY);
     116    // assert (in_pix - image[0].pixmap >= 0);
     117
    96118    /**** fill in area to the right of the picture ****/
    97119    for (jj = 0; jj < expand_out; jj++) {
     
    102124    }
    103125    out_pix += (dx - i_end);
     126    // assert (out_pix - (unsigned int *)picture[0].data <= dx*dy);
     127    // assert (out_pix - (unsigned int *)picture[0].data >= 0);
    104128  }
    105129 
     
    107131    out_pix -= expand_out - (j_end - j_start) % expand_out;
    108132 
     133  // assert (out_pix - (unsigned int *)picture[0].data <= dx*dy);
     134  // assert (out_pix - (unsigned int *)picture[0].data >= 0);
     135
    109136  /**** fill in top area ****/
    110137  for (j = 0; (j < dx*(dy - j_end)) && (out_pix - (unsigned int *)picture[0].data < dx*dy); j++, out_pix++) {
  • trunk/Ohana/src/kapa2/src/SetImageSize.c

    r16256 r16270  
    109109      image[0].recenter_button.x = image[0].heat_button.x + image[0].heat_button.dx + PAD1;
    110110      image[0].recenter_button.y = image[0].PS_button.y;
     111
     112      // XXX zoom should scale somewhat with the image? (with a min and a max)
     113      // XXX actually, it is limited by the buttons and status region
     114      image[0].wide.dx = ZOOM_X;
     115      image[0].wide.dy = ZOOM_Y;
     116      image[0].wide.x = image[0].recenter_button.x + image[0].recenter_button.dx + PAD1;
     117      image[0].wide.y = image[0].PS_button.y;
    111118      break;
    112119
     
    177184      image[0].recenter_button.x = image[0].heat_button.x + image[0].heat_button.dx + PAD1;
    178185      image[0].recenter_button.y = image[0].PS_button.y;
     186
     187      // XXX zoom should scale somewhat with the image? (with a min and a max)
     188      // XXX actually, it is limited by the buttons and status region
     189      image[0].wide.dx = ZOOM_X;
     190      image[0].wide.dy = ZOOM_Y;
     191      image[0].wide.x = image[0].PS_button.x;
     192      image[0].wide.y = image[0].PS_button.y + BUTTON_HEIGHT + PAD1;
    179193      break;
    180194
     
    243257      image[0].recenter_button.x = image[0].heat_button.x + image[0].heat_button.dx + PAD1;
    244258      image[0].recenter_button.y = image[0].PS_button.y;
     259
     260      // XXX zoom should scale somewhat with the image? (with a min and a max)
     261      // XXX actually, it is limited by the buttons and status region
     262      image[0].wide.dx = ZOOM_X;
     263      image[0].wide.dy = ZOOM_Y;
     264      image[0].wide.x = image[0].recenter_button.x + image[0].recenter_button.dx + PAD1;
     265      image[0].wide.y = image[0].PS_button.y;
    245266      break;
    246267
     
    309330      image[0].recenter_button.x = image[0].heat_button.x + image[0].heat_button.dx + PAD1;
    310331      image[0].recenter_button.y = image[0].PS_button.y;
     332
     333      // XXX zoom should scale somewhat with the image? (with a min and a max)
     334      // XXX actually, it is limited by the buttons and status region
     335      image[0].wide.dx = ZOOM_X;
     336      image[0].wide.dy = ZOOM_Y;
     337      image[0].wide.x = image[0].PS_button.x;
     338      image[0].wide.y = image[0].PS_button.y + BUTTON_HEIGHT + PAD1;
    311339      break;
    312340
     
    320348    CreateColorbar (image, graphic);
    321349    CreateZoom (graphic, image);
     350    CreateWide (graphic, image);
    322351  }
    323352  Remap (graphic, image);
Note: See TracChangeset for help on using the changeset viewer.