# include "Ximage.h"

static char *GREY = "greyscale";
static char *PUNS = "Puns";
static char *RAINBOW = "Rainbow";

int PSfunction (Graphic *graphic, KapaImageWidget *image) {

  int status;

  status = PSit ("kapa.ps", "default", TRUE, KAPA_PS_NEWPLOT);
  return (status);
}

int greycolors (Graphic *graphic, KapaImageWidget *image) {
  char *name;
  name = GREY;
  SetColormap (name);
  CreateColorbar (image, graphic);
  Remap (graphic, image, &image[0].matrix);
  CreateZoom (image, graphic, 0, 0); 
  Refresh ();
  XFlush (graphic[0].display);
  return (TRUE);
}

int puns (Graphic *graphic, KapaImageWidget *image) {
  char *name;
  name = PUNS;
  SetColormap (name);
  CreateColorbar (image, graphic);
  Remap (graphic, image, &image[0].matrix);
  CreateZoom (image, graphic, 0, 0); 
  Refresh ();
  XFlush (graphic[0].display);
  return (TRUE);
}

int rainbow (Graphic *graphic, KapaImageWidget *image) {
  char *name;
  name = RAINBOW;
  SetColormap (name);
  CreateColorbar (image, graphic);
  Remap (graphic, image, &image[0].matrix);
  CreateZoom (image, graphic, 0, 0); 
  Refresh ();
  XFlush (graphic[0].display);
  return (TRUE);
}

int Recenter (Graphic *graphic, KapaImageWidget *image) {

  image[0].X = 0;
  image[0].Y = 0;
 
  Remap (graphic, image, &image[0].matrix);
  Refresh ();
  FlushDisplay (graphic[0].display);
  return (TRUE);

}

int Rescale (Graphic *graphic, KapaImageWidget *image) {

  image[0].expand = 1;
  Remap (graphic, image, &image[0].matrix);
  Refresh ();
  FlushDisplay (graphic[0].display);
  return (TRUE);

}

int RecenterRescale (Graphic *graphic, KapaImageWidget *image) {

  image[0].X = 0;
  image[0].Y = 0;
  image[0].expand = 1;
 
  Remap (graphic, image, &image[0].matrix);
  Refresh ();
  FlushDisplay (graphic[0].display);
  return (TRUE);

}

int ToggleDEG (Graphic *graphic, KapaImageWidget *image) {

  image[0].DecimalDegrees = image[0].DecimalDegrees ^ TRUE;
  StatusBox (graphic, image);
  FlushDisplay (graphic[0].display);
  return (TRUE);

}

/*********** overlay_button functions ************/
int Overlay0 (Graphic *graphic, KapaImageWidget *image) {

  image[0].overlay[0].active = image[0].overlay[0].active ^ TRUE;
  Refresh ();
  FlushDisplay (graphic[0].display);
  return (TRUE);

}

int Overlay1 (Graphic *graphic, KapaImageWidget *image) {

  image[0].overlay[1].active = image[0].overlay[1].active ^ TRUE;
  Refresh ();
  FlushDisplay (graphic[0].display);
  return (TRUE);

}

int Overlay2 (Graphic *graphic, KapaImageWidget *image) {

  image[0].overlay[2].active = image[0].overlay[2].active ^ TRUE;
  Refresh ();
  FlushDisplay (graphic[0].display);
  return (TRUE);

}

int Overlay3 (Graphic *graphic, KapaImageWidget *image) {

  image[0].overlay[3].active = image[0].overlay[3].active ^ TRUE;
  Refresh ();
  FlushDisplay (graphic[0].display);
  return (TRUE);

}

/* this routine is NOT independent of the number of overlays */


