/* **********************************************************************
 * *	                                                                *
 * *     IRIS Setup Structure Minimum, Maximum, and Default Values      *
 * *                                                                    *
 * **********************************************************************
 * File: libs/config/setup_limits.c
 *
 *  COPYRIGHT (c) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
 *                       2004, 2005, 2006 BY
 *             VAISALA INC., WESTFORD MASSACHUSETTS, U.S.A.
 * 
 * THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED AND  COPIED
 * ONLY  IN  ACCORDANCE WITH  THE  TERMS  OF  SUCH  LICENSE  AND WITH THE
 * INCLUSION OF THE ABOVE COPYRIGHT NOTICE.  THIS SOFTWARE  OR  ANY OTHER
 * COPIES  THEREOF MAY NOT BE PROVIDED OR OTHERWISE MADE AVAILABLE TO ANY
 * OTHER PERSON.  NO TITLE TO AND OWNERSHIP OF  THE  SOFTWARE  IS  HEREBY
 * TRANSFERED.
 */
#include <string.h>
#include <stdio.h>
#include <stdlib.h>

#include "sigtypes.h"
#include "sigversion.h"
#include "setup.h"
#include "user_lib.h"

#define LIM_DEFINITIONS
#define LIM_KERNEL color_limits_kernel
#include "config_lib.h"

static MESSAGE LIM_KERNEL
( const char *sname_a,		/* Name of structure */
  void *item_a,			/* Pointer to structure */
  SINT4 ioper_a,		/* Operation to perform */
  const char *spath_a,		/* Full path name of fields */
  void *ioarg_a ) ;		/* Diagnostic messages, or NULL */

MESSAGE color_limits
( const char *sname_a,		/* Name of structure */
  volatile void *item_a,	/* Pointer to structure */
  SINT4 ioper_a,		/* Operation to perform */
  void *file_a )		/* Diagnostic messages, or NULL */
{
  return( lim_toplevel( sname_a, item_a, ioper_a, file_a, LIM_KERNEL ) ) ;
}

/* ======================================================================
 * Internal routine to recursively descend the structures.
 */
static MESSAGE LIM_KERNEL
( const char *sname_a,		/* Name of structure */
  void *item_a,			/* Pointer to structure */
  SINT4 ioper_a,		/* Operation to perform */
  const char *spath_a,		/* Full path name of fields */
  void *ioarg_a )		/* Diagnostic messages, or NULL */
{
  char spath[PATHNAME_SIZE], *sItem ; struct lim_inLine **pLine ;
  SINT4 idim1=0, idim2=0 ; MESSAGE istatus = SS_NORMAL ;
  UINT1 lActualSizes = USEACTUALSIZES( ioper_a ) ;

  /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  if( 0 == strcmp( "class_label_setup", sname_a ) ) {
    struct class_label_setup *item = item_a ;

    SCALAR   (  iLabelCount,     0, COLOR_HCLASS_LABEL_SIZE,   0 ) ;
    SUBSTRUCTURE_1D( class_label_table, Table, COLOR_HCLASS_LABEL_SIZE ) ;
  }
  /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  else if( 0 == strcmp( "class_label_table", sname_a ) ) {
    struct class_label_table *item = item_a ;

    SCALAR   (  iValue,     0, 255,   0 ) ;
    STRING   (  sLabel,    "" ) ;
  }
  /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  else if( 0 == strcmp( "color_def", sname_a ) ) {
    struct color_def *item = item_a ;

    if( (!lActualSizes) || item->ired || item->igreen || item->iblue ) {
      SCALAR(   ired, 0, 255, 0 ) ;
      SCALAR( igreen, 0, 255, 0 ) ;
      SCALAR(  iblue, 0, 255, 0 ) ;
    }
  }
  /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  else if( 0 == strcmp( "color_setup", sname_a ) ) {
    struct color_setup *item = item_a ;

    STRING( sVersion, IRIS_VERSION ) ;
    SUBSTRUCTURE( colormap_setup,  colormap ) ;
    SUBSTRUCTURE_1D( one_dtype_scales, dtype, SETUP_DTYPE_COUNT ) ;
    SUBSTRUCTURE( class_label_setup, ClassLabels ) ;
  }
  /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  else if( 0 == strcmp( "colormap_setup", sname_a ) ) {
    struct colormap_setup *item = item_a ;

    SUBSTRUCTURE( special_colors, special ) ;

    SUBSTRUCTURE_2D( color_def, colormap, COLOR_MAP_ZOOM, COLOR_MAP_MAX ) ;
    SUBSTRUCTURE_1D( colorset_setup, set, COLOR_SET_COUNT ) ;
  }
  /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  else if( 0 == strcmp( "colorset_setup", sname_a ) ) {
    struct colorset_setup *item = item_a ;

    STRING( sname, "" );

    if( (!lActualSizes) || item->sname[0] ) {
      SCALAR_1D( icolors, 1, COLOR_MAP_MAX, 10, 16 ) ;
    }
  }
  /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  else if( 0 == strcmp( "one_dtype_scales", sname_a ) ) {
    struct one_dtype_scales *item = item_a ;

    SUBSTRUCTURE_1D( setup_scale_def, scales, COLOR_SCALE_COUNT );
  }
  /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  else if( 0 == strcmp( "setup_scale_def", sname_a ) ) {
    struct setup_scale_def *item = item_a ;

    STRING( sname, "" );

    if( (!lActualSizes) || item->sname[0] ) {
      SCALAR_1D( ilevel_seams,     0,          0xFFFF,   0, 16 ) ;
      SCALAR   (  iflags,          0,      0xFFFFFFFF,   0 ) ;
      SCALAR   (  iset_number,     1, COLOR_SET_COUNT,   1 ) ;
      SCALAR   (  inum_levels,     2,              16,  10 ) ;
    }
  }
  /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  else if( 0 == strcmp( "special_colors", sname_a ) ) {
    struct special_colors *item = item_a ;

    SUBSTRUCTURE( color_def, background ) ;
    SUBSTRUCTURE( color_def, legend ) ;
    SUBSTRUCTURE( color_def, overlay1 ) ;
    SUBSTRUCTURE( color_def, underlay1 ) ;
    SUBSTRUCTURE( color_def, underlay2 ) ;
    SUBSTRUCTURE( color_def, underlay3 ) ;
    SUBSTRUCTURE( color_def, drop_shadow ) ;
    SUBSTRUCTURE( color_def, overlay2 ) ;
    SUBSTRUCTURE( color_def, overlay3 ) ;
    SUBSTRUCTURE( color_def, overlay_txt_back ) ;
    SUBSTRUCTURE( color_def, centroid ) ;
    SUBSTRUCTURE( color_def, track ) ;
    SUBSTRUCTURE( color_def, track_highlight ) ;
    SUBSTRUCTURE( color_def, Shearline ) ;
    SUBSTRUCTURE( color_def, WindBarbs ) ;
    SUBSTRUCTURE( color_def, RangeRings ) ;
  }
  /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  else
    istatus = iMessageMod_va( CONFIG_LIM_BADSTRUCT, 1, sname_a ) ;

  return( istatus ) ;
}
