IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 38439


Ignore:
Timestamp:
Jun 12, 2015, 5:00:31 PM (11 years ago)
Author:
eugene
Message:

allow kapa to dynamically set the NAN pixel colors

Location:
branches/eam_branches/ipp-20150419/Ohana/src
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20150419/Ohana/src/kapa2/include/prototypes.h

    r33650 r38439  
    8383int           SetChannel          PROTO((int sock));
    8484int           SetColormapFromPipe PROTO((int sock));
     85int           SetNanColorFromPipe PROTO((int sock));
    8586
    8687int           LoadVectorData      PROTO((int sock, KapaGraphWidget *graph, int N, char *type));
  • branches/eam_branches/ipp-20150419/Ohana/src/kapa2/include/structures.h

    r37807 r38439  
    3535  unsigned long *color;      // graph plotting colors
    3636  int            Ncolors;
     37  char          *colormapName;
    3738
    3839  unsigned long *pixels;      // image pixel colors
  • branches/eam_branches/ipp-20150419/Ohana/src/kapa2/src/CheckPipe.c

    r36833 r38439  
    316316  }
    317317
     318  if (!strcmp (word, "CNAN")) {
     319    status = SetNanColorFromPipe (sock);
     320    KiiSendCommand (sock, 4, "DONE");
     321    FINISHED (status);
     322  }
     323
    318324  if (!strcmp (word, "SAVE")) {
    319325    status = SaveOverlay (sock);
  • branches/eam_branches/ipp-20150419/Ohana/src/kapa2/src/InterpretKeys.c

    r38153 r38439  
    102102      UpdateStatusBox (graphic, image, X, Y, 0.0, 1); \
    103103      Remap (graphic, image); \
     104      Refresh (); \
    104105      break;
    105106
  • branches/eam_branches/ipp-20150419/Ohana/src/kapa2/src/SetChannel.c

    r37807 r38439  
    5757    // image = section->image;
    5858    SetColorScale (graphic, section->image);
    59     if (!USE_XWINDOW) return (TRUE);
     59    if (!USE_XWINDOW) return TRUE;
    6060    Remap (graphic, section->image);
    6161  }
     
    6666  return (TRUE);
    6767}
     68
     69int SetNanColorFromPipe (int sock) {
     70
     71  int i, red_value, green_value, blue_value;
     72  KiiScanMessage (sock, "%d %d %d", &red_value, &green_value, &blue_value);
     73
     74  NAN_RED   = red_value;
     75  NAN_GREEN = green_value;
     76  NAN_BLUE  = blue_value;
     77
     78  // use graphic->colormapName saved value
     79  SetColormap (NULL);
     80
     81  if (!USE_XWINDOW) return (TRUE);
     82 
     83  Graphic *graphic = GetGraphic ();
     84
     85  int NeedRefresh = FALSE;
     86  int Nsection = GetNumberOfSections ();
     87  for (i = 0; i < Nsection; i++) {
     88    Section *section = GetSectionByNumber (i);
     89    if (section->image) {
     90      NeedRefresh = TRUE;
     91      SetColorScale (graphic, section->image);
     92      Remap (graphic, section->image);
     93    }
     94  }
     95  if (NeedRefresh) {
     96    Refresh ();
     97    XFlush (graphic[0].display);
     98  }
     99
     100  return (TRUE);
     101}
  • branches/eam_branches/ipp-20150419/Ohana/src/kapa2/src/SetColormap.c

    r38153 r38439  
    1616// display of) an image, we simply remap the lit pixels (in Remap32.c, etc).
    1717
    18 int SetColormap (char *name) {
     18int SetColormap (char *inName) {
    1919
    2020  int i, red, blue, green;
     
    2424  graphic = GetGraphic();
    2525
     26  if (!inName && !graphic->colormapName) abort();
     27
     28  if (inName) {
     29    if (graphic->colormapName) free (graphic->colormapName);
     30    graphic->colormapName = strcreate (inName);
     31  }
     32
    2633  int NANValue = graphic[0].Npixels - 1;
    2734  int MaxValue = graphic[0].Npixels - 1;
     
    2936  // the "fullcolor" colormap is uniquely defined for each image;
    3037  // defer to the 'SetColorScale' step
    31   if (!strcasecmp (name, "fullcolor")) {
     38  if (!strcasecmp (graphic->colormapName, "fullcolor")) {
    3239    graphic[0].ColorScaleMode = KAPA_SCALE_3D_FULL;
    3340    if (SetColorCubeHistogram ()) return TRUE;
     
    4451
    4552  // very simple color model: evenly spaced cube
    46   if (!strcasecmp (name, "ruffcolor")) {
     53  if (!strcasecmp (graphic->colormapName, "ruffcolor")) {
    4754      graphic[0].nRed  = pow (graphic[0].Npixels, 0.333);
    4855      graphic[0].nBlue = pow (graphic[0].Npixels, 0.333);
     
    7986
    8087  /* greyscale */
    81   if ((!strcasecmp (name, "grayscale")) || (!strcasecmp (name, "greyscale"))) {
     88  if ((!strcasecmp (graphic->colormapName, "grayscale")) || (!strcasecmp (graphic->colormapName, "greyscale"))) {
    8289    for (i = 0; i < MaxValue; i++) { 
    8390      SETVALUE (graphic[0].cmap[i].red,   0xffff - i*scale, 0, 0xffff);
     
    8996  }
    9097  /* -grayscale */
    91   if ((!strcasecmp (name, "-grayscale")) || (!strcasecmp (name, "-greyscale"))) {
     98  if ((!strcasecmp (graphic->colormapName, "-grayscale")) || (!strcasecmp (graphic->colormapName, "-greyscale"))) {
    9299    for (i = 0; i < MaxValue; i++) { 
    93100      SETVALUE (graphic[0].cmap[i].red,   i*scale, 0, 0xffff);
     
    99106  }
    100107  /* heat */
    101   if (!strcasecmp (name, "Heat")) {
     108  if (!strcasecmp (graphic->colormapName, "Heat")) {
    102109    greenRef = 0.25*MaxValue*scale*2.0;
    103110    blueRef  = 0.50*MaxValue*scale*2.0;
     
    129136  }
    130137  /* rainbow */
    131   if (!strcasecmp (name, "Rainbow")) {
     138  if (!strcasecmp (graphic->colormapName, "Rainbow")) {
    132139    redRef   = 0.25*MaxValue*scale*4.0;
    133140    greenRef = 0.50*MaxValue*scale*4.0;
     
    167174  }
    168175  /* anuenue */
    169   if (!strcasecmp (name, "anuenue")) {
     176  if (!strcasecmp (graphic->colormapName, "anuenue")) {
    170177    redRef   = 0.25*MaxValue*scale*4.0; // value at 0.0
    171178    greenRef = 0.50*MaxValue*scale*4.0;
     
    207214
    208215  /* anuenue */
    209   if (!strncmp (name, "file:", 5)) {
    210     FILE *f = fopen (&name[5], "r");
     216  if (!strncmp (graphic->colormapName, "file:", 5)) {
     217    FILE *f = fopen (&graphic->colormapName[5], "r");
    211218    if (!f) {
    212       fprintf (stderr, "failed to open colormap file %s\n", &name[5]);
     219      fprintf (stderr, "failed to open colormap file %s\n", &graphic->colormapName[5]);
    213220      return FALSE;
    214221    }
  • branches/eam_branches/ipp-20150419/Ohana/src/kapa2/src/SetUpGraphic.c

    r32695 r38439  
    4242  CheckColors (graphic, argc, argv);
    4343
     44  graphic->colormapName = NULL;
     45
    4446  icon.width = icon_width;
    4547  icon.height = icon_height;
  • branches/eam_branches/ipp-20150419/Ohana/src/libkapa/include/kapa.h

    r35761 r38439  
    146146int KiiSetChannel (int fd, int channel);
    147147int KiiSetColormap (int fd, char *colormap);
     148int KiiSetNanColor (int fd, int red, int green, int blue);
    148149int KiiNewPicture1D (int fd, KiiImage *image, KapaImageData *data, Coords *coords);
    149150int KiiNewPicture2D (int fd, KiiImage *image, KapaImageData *data, Coords *coords);
  • branches/eam_branches/ipp-20150419/Ohana/src/libkapa/src/KiiPicture.c

    r36833 r38439  
    1414  KiiSendCommand (fd, 4, "CMAP"); /* tell kapa to look for the incoming image */
    1515  KiiSendMessage (fd, "%s", colormap);
     16 
     17  KiiWaitAnswer (fd, "DONE");
     18  return (TRUE);
     19}
     20
     21int KiiSetNanColor (int fd, int red, int green, int blue) {
     22
     23  KiiSendCommand (fd, 4, "CNAN"); /* tell kapa to look for the incoming image */
     24  KiiSendMessage (fd, "%d %d %d ", red, green, blue);
    1625 
    1726  KiiWaitAnswer (fd, "DONE");
  • branches/eam_branches/ipp-20150419/Ohana/src/opihi/cmd.data/tvcolors.c

    r31667 r38439  
    1616  FREE (name);
    1717
     18  int SetNAN = FALSE;
     19  int red, green, blue;
     20  if ((N = get_argument (argc, argv, "-nan"))) {
     21    if (N > argc - 4) {
     22      gprint (GP_ERR, "ERROR: -nan (red) (green) (blue) does not have enough arguments\n");
     23      return FALSE;
     24    }
     25    remove_argument (N, &argc, argv);
     26    red = strtol (argv[N], NULL, 0);
     27    remove_argument (N, &argc, argv);
     28    green = strtol (argv[N], NULL, 0);
     29    remove_argument (N, &argc, argv);
     30    blue = strtol (argv[N], NULL, 0);
     31    remove_argument (N, &argc, argv);
     32    SetNAN = TRUE;
     33  }
     34
    1835  // use the currently-set zero,range values if not supplied
    19   if (argc != 2) {
    20     gprint (GP_ERR, "USAGE: tvcolors (colormap)\n");
     36  if (!SetNAN && (argc != 2)) {
     37    gprint (GP_ERR, "USAGE: tvcolors (colormap) [-nan red green blue]\n");
    2138    gprint (GP_ERR, " colormap options : greyscale, -greyscale, rainbow, heat, fullcolor, ruffcolor (also grayscale, -grayscale)\n");
    2239    return (FALSE);
    2340  }
    2441
    25   KiiSetColormap (kapa, argv[1]);
     42  if (SetNAN) {
     43    KiiSetNanColor (kapa, red, green, blue);
     44  }
     45  if (argc == 2) {
     46    KiiSetColormap (kapa, argv[1]);
     47  }
    2648  return (TRUE);
    2749}
Note: See TracChangeset for help on using the changeset viewer.