/* *********************************************************************
 * *                                                                   *
 * * Header file for TVSUBS function prototypes                        *
 * *                                                                   *
 * *********************************************************************
 * File: include/tvsubs_lib.h
 *
 * COPYRIGHT (c) 1991, 1995, 1996, 1997, 1998, 2000, 2002, 2003, 2004,
 *                              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.
 */
#ifndef SIGMET_TVSUBS_LIB_H
#define SIGMET_TVSUBS_LIB_H 1

#ifdef __cplusplus

////////////////////////////////////////////////////////////////////
// This is the base class. Instances can not be created from it.
// It only should be an inherited class
////////////////////////////////////////////////////////////////////

class LabelAxis
{
 private:

 protected:
  LabelAxis(void);          /* Constructor */
  /*  LabelAxis( int iLength_a, int iMinSpacing_a);  */         /* Constructor */
  int    iPixelLength;         /* Length of the axis line */
  int    iPixelMinSpacing;     /* Minimum spacing between ticks */
  int    iTickCount;           /* Number of ticks in the display */
  FLT8   fPixelTickStart;      /* Position of the first tick */
  FLT8   fPixelTickSpacing;    /* Spacing between ticks in pixels */
  char   sFaultString[80];     /* String indicating what is wrong */

 public:
  int  getCount( void );                 /* Returns the number of labels */
  int  getOnePosition( int iIndex_a );   /* Returns position of a label */
  int  getFaultString                    /* Returns nonzero on error */
    ( char sFaultString_a[], int iStringSize_a );
};

/*
 * Time axis
 */
class LabelAxisTime : public LabelAxis
{
 private:
    struct ymds_time DataFirstTick;        /* Time of the first tick */
    int   iDataTickSpacing;                /* Tick spacing in seconds */
    int   iDataTickResolution;
#define RESOLUTION_SECONDS 0
#define RESOLUTION_MINUTES 1
#define RESOLUTION_HOURS   2

  public :
    LabelAxisTime( int iLength_a, int iMinSpacing_a,   /* Constructor */
		   const struct ymds_time *pStart_a,
		   const struct ymds_time *pStop_a );

    void getOneLabel( int iIndex_a, 
		      char sLabel_a[],
		      int iLabelSize_a);   /* Returns string to draw */
    /* Returns the label for the axis */
    void getLegendLabel
      ( char sLabel_a[],
	int iLabelSize_a);
};

/*
 * FLT8 axis
 */
class LabelAxisFlt8 : public LabelAxis
{
 private:
    FLT8  fDataFirstTick;          /* First tick */
    FLT8  fDataTickSpacing;        /* Tick spacing */
    char  sLabelFormat[40];        /* Format statement used to make labels */

  public :
    LabelAxisFlt8( int iLength_a, int iMinSpacing_a,   /* Constructor */
		   FLT8 fStart_a, FLT8 fStop_a );

    void getOneLabel( int iIndex_a, 
		      char sLabel_a[],
		      int iLabelSize_a);   /* Returns string to draw */
};

extern "C" {
#endif

#define        CATCH_FAR      1
#define TVSUBS_CATCH_FAR      (TVSUBS_FACILITY + CATCH_FAR)
#define        LONG_RANGE     2
#define TVSUBS_LONG_RANGE     (TVSUBS_FACILITY + LONG_RANGE)
#define        OVER_FAR       3
#define TVSUBS_OVER_FAR       (TVSUBS_FACILITY + OVER_FAR)
#define        PRJ_NOOVERLAP  4
#define TVSUBS_PRJ_NOOVERLAP  (TVSUBS_FACILITY + PRJ_NOOVERLAP)
#define        FEW_COLORS     5
#define TVSUBS_FEW_COLORS     (TVSUBS_FACILITY + FEW_COLORS)
#define        NO_COLORS      6
#define TVSUBS_NO_COLORS      (TVSUBS_FACILITY + NO_COLORS)
#define        NO_CONTRAST    7
#define TVSUBS_NO_CONTRAST    (TVSUBS_FACILITY + NO_CONTRAST)


#ifndef MESSAGE_ONLY

  /* Should switch to XYPoint4 */
struct xypoint_FLT4
{
  FLT4 fx;
  FLT4 fy;
};

/* Function prototypes for the library routines */

void beam_grid            /* In file vertical_grids.c */
(const FLT4 fwin_pos_a[2],   /* Window position */
 const FLT4 fwin_size_a[2],  /* Window size, one less than width in pixels */
 const FLT4 fstart_a[2],     /* Starting position in degrees (ll corner) */
 const FLT4 fspan_a[2],      /* Size in degrees */
 UINT4 igrid_a,              /* Color to draw grid in */
 UINT4 iaxis_a,              /* Color to draw axis in */
 VTV  image_a,               /* VTV image */
 UINT2 lgrid_a,              /* Non-zero means draw grid on top of picture */
 UINT4 iFontHeight_a,        /* Height of font to use */
 UINT4 iUnits_a,             /* Units to draw grid in */
 const UINT1 iGridType_a[2]);/* Type of grid for each axis */

void bothout_points    /* In file bothout.c */
  (const struct xypoint_FLT4 *fpos1_a,  /* First input point */
   const struct xypoint_FLT4 *fpos2_a,  /* Second input point */
   struct xypoint_FLT4 *fnew1_a,        /* Relocated first point on the edge (exit) */
   struct xypoint_FLT4 *fnew2_a,        /* Relocated second point on the edge (exit) */
   const FLT4 fwin_pos_a[2],           /* Position of the window of interest. */
   const FLT4 fwin_size_a[2],          /* Size of window */
   UINT2* plmissed_a     /* Nonzero if the line misses the region entirely,
			  *  in which case the two new points are undefined. */
   ); 

void bothout_reduce      /* In file bothout.c */
  (const struct xypoint_FLT4 *fpos1_a,     /* First input point  */
   const struct xypoint_FLT4 *fpos2_a,     /* Second input point */
   FLT4* pfreduce1_a,       /* Proportion of line reduced from first point (exit) */
   FLT4* pfreduce2_a,       /* Proportion of line reduced from the second point. (exit) */ 
   const FLT4  fwin_pos_a[2],     /* Position of the window of interest.*/
   const FLT4  fwin_size_a[2],    /* Size of window*/
   UINT2* plmissed_a        /* Nonzero if the line misses the region entirely, in which 
			     *  case the two reduceX_a parameters are undefined. (exit) */
   );
void calcstep            /* In file getstep.c */
(BIN4 iangle_a,
 const FLT4 fradpos_a[2],
 FLT4 fstart_a,
 SINT2 icount_a, 
 const FLT4 fscale_a[2],
 const FLT4 fwin_pos_a[2],
 const FLT4 fwin_size_a[2],
 BIN4 *istep_a,
 UINT2 *lmissed_a );

void cross_grid          /* In file vertical_grids.c */
(const FLT4 fwin_pos_a[2],
 const FLT4 fwin_size_a[2],
 const FLT4 fscale_a[2],    /* Scale factors in km/pixel */
 const FLT4 fradpos_a[2],   /* Radar position in pixels */
 UINT4 igrid_a,
 UINT4 iaxis_a,
 VTV  image_a, 
 UINT2 lgrid_a,
 UINT4 iFontHeight_a,       /* Height of font to use */
 UINT4 iunits_a );

typedef void (*DRAW_LINE_FUNC)(VTV image, SINT4 x1, SINT4 y1, SINT4 x2, SINT4 y2 );
void draw_arrow             /* In file: inside.c */
(const SINT4 itip_a[2],     /* The tip of the arrow */
 const FLT4  fwin_pos_a[2], /* Window to clip drawing within */
 const FLT4  fwin_size_a[2],
 const FLT4  flengths_a[3], /* length in pixles of the body, wings, and backoff. */
 FLT4 fangle_a,             /* Direction the arrow points in, clockwise from north, radians*/
 UINT4 image_a,             /* Image ID (Note always VTV!) */
 DRAW_LINE_FUNC line_a );  /*Routine to draw the line */

#ifdef SIGMET_PROJECTION_H
  void  draw_catch     /* In file: DrawCatch.c */
  (const volatile struct catch_file_header8* pCatch_a,  /*Catch header */
   const volatile UINT1 iheap_a[],                   /*Heap of data */
   const volatile struct layer_dir* players_a,       /*Layer directory */
   const FLT4 fwin_pos_a[2],
   const FLT4 fwin_size_a[2],
   const struct mpj_projection8 *proj_a,
   const struct mpj_region8 *region_a,
   UINT4 iflag_a,
   VTV   itv_a                                      /* Which VTV to draw in */
   );
#endif  /* #ifdef SIGMET_PROJECTION_H */

UINT1 draw_clipped_line      /* In file protected.c */
(VTV image_a,
 const struct xypoint_FLT4 *point1_a, 
 const struct xypoint_FLT4 *point2_a,
 const FLT4 fwin_pos_a[2],
 const FLT4 fwin_size_a[2],
 DRAW_LINE_FUNC DrawLine_a,
 struct xypoint_FLT4 *pMidPoint_a );

#ifdef SIGMET_PROJECTION_H
void draw_icon         /* File: overlay.c */
(SINT4 ix_a,
 SINT4 iy_a,
 const FLT4 fwin_pos_a[2],
 const FLT4 fwin_size_a[2],
 const volatile struct icon_def *picon_a,
 const volatile UINT1 *icon_heap_a,
 UINT1 lbackground_a,       /* Need to highlight behind */
 UINT4 icolor_a,            /* Color to draw in */
 VTV itv_a );
#endif  /* #ifdef SIGMET_PROJECTION_H */

/* Flags used to control how the overlay is to be drawn.
 * Do not draw the underlay. N/A for catchment areas.
 */
#define OVR_NOUNDER_MASK (0x0001)

/* Draw just dots rather than filling underlay.  Do not fill catchment areas with color.
 */
#define OVR_NOFILL_MASK  (0x0002)

/* Do not draw the text of the overlay.  Do not draw catchment names.
 */
#define OVR_NOTEXT_MASK  (0x0004)

/* N/A for overlay.  Draw catchment icons rather than regions.
 */
#define OVR_CAT_ICONS_MASK  (0x0008)
/* N/A for overlay.  Do not draw the border lines.
 */
#define OVR_CAT_NOLINES_MASK  (0x0010)

#ifdef SIGMET_PROJECTION_H
  void DrawOverlay     /* In file: DrawOverlay.c */
(const volatile struct layer_dir *players_a,       /*Layer definition */
 const volatile struct overlay_file_header8* pheader_a,  /*Overlay header */
 const volatile UINT1 iheap_a[],                   /*Heap of data */
 const FLT4 fwin_pos_a[2],
 const FLT4 fwin_size_a[2],
 const struct mpj_projection8 *proj_a,
 const struct mpj_region8 *region_a,
 UINT4 ilayer_mask_a,
 UINT4 iflags_a,
 UINT4 iReservedColors_a,  /* These low colors are not used for GIF drawing */
 UINT4 ivtv_a
 );

void DrawOneCatch   /* In file: DrawCatch.c */
(const struct one_catch_header8 *pOneCatch_a,
 const volatile struct icon_inventory* pIcons_a,       /*Icon inventory */
 const FLT4 fwin_pos_a[2],
 const FLT4 fwin_size_a[2],
 const struct mpj_projection8 *proj_a,
 const struct mpj_region8 *region_a,
 UINT4 iflag_a,
 UINT4 iFillColor_a,      /* Color to fill icon with */
 UINT4 iMaskColor_a,      /* Color for icon mask and text and catch border */
 struct xypoint_FLT4 *pCenter_a,   /* Returns the center point */
 VTV   itv_a              /* Which VTV to draw in */
 );

void DrawOneIcon /* In file: overlay.c */
(UINT1 iIconNumber_a,                             /* Icon index */
 const char *sText_a,                             /* Text to draw next to the icon */
 const struct latlon8 *pGagePos_a,
 const volatile struct icon_inventory* pIcons_a,  /*Icon inventory */
 const FLT4 fwin_pos_a[2],
 const FLT4 fwin_size_a[2],
 const struct mpj_projection8 *proj_a,
 const struct mpj_region8 *region_a,
 UINT4 iFillColor_a,      /* Color to fill icon with */
 UINT4 iMaskColor_a,      /* Color for icon mask and text */
 FLT4  fRotation_a,       /* Rotation of icon, radians */
 VTV   itv_a              /* Which VTV to draw in */
 );

#ifdef SIGMET_SETUP_H
void  draw_protected /* In file protected.c */
  (const struct protect_setup* protected_a,  /*Protected area defs */
   const FLT4 fwin_pos_a[2],
   const FLT4 fwin_size_a[2],
   const struct mpj_projection8 *proj_a,
   const struct mpj_region8 *region_a,
   const FLT4 frad_pos_a[2],
   UINT4 picolor_a,
   UINT4 iHitColor_a,                 /*Which color to draw hits in*/
   UINT4 idraw_mask_a,
   UINT4 ihit_mask_a,
   VTV   image_a
   );
#endif  /* #ifdef SIGMET_SETUP_H */

#define RING_SPACING_AUTO (0)
void  draw_rangerings       /* In file rangerings.c */
  (
   const FLT4 fwin_pos_a[2],
   const FLT4 fwin_size_a[2],
   const struct mpj_projection8 *proj_a,
   const struct mpj_region8 *region_a,
   const struct  latlon8 *RingCenter_a, /*Ring Center in lat/long*/
   UINT4 icolor_a,             /*color to draw the rings in */
   UINT4 ibackcol_a,           /*background color*/
   UINT2 labels_a,             /*Flag to indicate if we are drawing labels*/
   UINT4 image_a,
   UINT4 iRingSpacing_a,       /* Ring spacing */
   UINT4 iunits_a              /*Specify units for rings*/
   );

void draw_single_rangering  /* In file rangerings.c */
(const FLT4 fwin_pos_a[2],
 const FLT4 fwin_size_a[2],
 const struct mpj_projection8 *proj_a,
 const struct mpj_region8 *region_a,
 volatile const struct latlon8 *RingCenter_a,
 FLT8 frange_a,
 FLT4 fstart_a,
 FLT4 fend_a,
 UINT4 icolor_a,
 UINT4 image_a );
#endif  /* #ifdef SIGMET_PROJECTION_H */

#define AXIS_CENTERED     1
#define AXIS_BOTTOM       0
#define AXIS_LEFT         0
#define AXIS_TOP          2
#define AXIS_RIGHT        2
#define AXIS_ENDS_IN      8   /* Both end labels are moved inwards */

#define AXIS_LABEL_INT    0
#define AXIS_LABEL_TIME  16   /* Label with time */
#define AXIS_LABEL_AZ    32   /* Label with azimuth (wrap at 360) */

void draw_vert_axis  /* In file plot.c */
(SINT4 ix_a,
 SINT4 iy_a,
 SINT4 ilen_a,
 FLT4  fscale_a,
 SINT4 istlabel_a, 
 SINT4 istep_a,
 SINT4 istpix_a,
 SINT4 iticks_a,
 UINT4 iflags_a,
 UINT4 ivtv_a );

void draw_horz_axis  /* In file plot.c */
(SINT4 ix_a,
 SINT4 iy_a,
 SINT4 ilen_a,
 FLT4  fscale_a,
 SINT4 istlabel_a, 
 SINT4 istep_a,
 SINT4 istpix_a,
 SINT4 iticks_a,
 UINT4 iflags_a,
 UINT4 ivtv_a );

#define GRID_IN_RANGE   (0)
#define GRID_IN_MINUTES (1)
#define GRID_IN_DEGREES (2)

  SINT4 GetGridStep       /* In file getstep.C */
  ( FLT4  fScale_a,       /* Scale in data/pixel */
    FLT4  fMinSpacing_a,  /* Minimum spacing in pixels between grid lines */
    UINT1 iDataType_a );  /* Type of data, (determines how to quantize) */
  
  SINT4 GetSecondStep     /* In file: getstep.C */
  (FLT8 fDesiredStep_a );

  FLT8 GetLogStep        /* In file: getstep.C */
  (FLT8 fDesiredStep_a,  /* Desired tick spacing */
   SINT4 *pLogTick_a );  /* Log of tick spacing, or negative of number of digits to display*/
       
/* Get index number of icon name supplied */
#define ICON_NOT_FOUND ((UINT1)-1)
#ifdef SIGMET_PROJECTION_H
UINT1 GetNamedIcon      /* In file overlay.c */
(volatile const struct icon_inventory *pIcons_a,
 const char *sName_a );
#endif  /* #ifdef SIGMET_PROJECTION_H */

#ifdef SIGMET_SIG_RTDISP_H
void insert_rtray         /* File: rtdisp_ray.c */
(Display* display_a,
 Window window_a,
 const UINT1 ray1_a[],
 const struct rtd_v1_ray_header *pray );
#endif  /* #ifdef SIGMET_SIG_RTDISP_H */

#ifdef INCLUDE_X11_PROTOTYPES
void insert_rtray_blank   /* File: rtdisp_ray.c */
( Display *display_a,
 Window window_a );
#endif  /* #ifdef INCLUDE_X11_PROTOTYPES */

struct rtray_config
{
  FLT4  fWinPos[2];      /* Position and size of the display window */
  FLT4  fWinSize[2];
  FLT4  fRadarPos[2];    /* Location of radar in the display window */
  FLT4  fmax_range;      /* Maximum range of the display in km */
  FLT4  fmax_height;     /* Maximum height of the display in km. RHI only */
  BIN4  imax_widen;      /* Maximum beam widening between rays */
  UINT4 isweep_color;    /* Color to draw sweep line in */
  UINT4 iImageDepth;     /* Depth of image in bits/pixel */
  UINT2 lsweep_line;     /* Draw a sweep line on screen */
  UINT1 lrhi_scan;       /* Draw data as RHI scan */
  UINT1 lrhi_lower_left; /* Draw RHI scan in lower left corner */
};

#ifdef SIGMET_SIG_RTDISP_H
void insert_rtray_init    /* File: rtdisp_ray.c */
  (UINT1 *pImageData_a,
   VTV background_image_a,
   volatile const struct rtd_v1_vol_header *phead_a,
   volatile const struct rtray_config *pconfig_a,
   const UINT4 vtv_to_image_map_a[256],
   volatile const UINT1 data_to_vtv_map_a[256] );
#endif  /* #ifdef SIGMET_SIG_RTDISP_H */

#ifdef INCLUDE_X11_PROTOTYPES
void insert_rtray_end    /* File: rtdisp_ray.c */
(Display* display_a,
 Window window_a );
#endif  /* #ifdef INCLUDE_X11_PROTOTYPES */

UINT2 inside_test       /* In file bothout.c */
  (const struct xypoint_FLT4 *ftest_pos_a,   /* Position to test */
   const FLT4 fwin_pos_a[2],    /* Window position  */
   const FLT4 fwin_size_a[2]    /* Size of window   */
   );

void  label_bottom      /* In file plot.c */
  (UINT4 image_a,
   const char* stext_a,
   const SINT4 iplot_pos_a[2],
   const SINT4 iplot_size_a[2]
   );

void  label_left        /* In file plot.c */
  (UINT4 image_a,
   const char* stext_a,
   const SINT4 iplot_pos_a[2],
   const SINT4 iplot_size_a[2]
   );

#ifdef SIGMET_PROJECTION_H
void lat_long_grid       /* In file lat_long_grid.c */
  (const FLT4 fwin_pos_a[2],      /*The window position in pixels for the display */
   const FLT4 fwin_size_a[2],     /*The window size */
   const struct mpj_projection8 *proj_a,  /* Projection */
   const struct mpj_region8 *region_a,    /* Region */
   UINT4 icolor_a,          /*Which color to draw in */
   UINT4 image_a            /*which vtv display unit to use */
   );
#endif  /* #ifdef SIGMET_PROJECTION_H */

UINT2 linside_move       /* In file: inside.c */
(SINT4 ipos_a[2],
 const FLT4 fwin_pos_a[2],
 const FLT4 fwin_size_a[2]);

UINT2 lInsideMove        /* In file: inside.c */
(FLT4       fPos_a[2],     /* Position in pixels */
 const FLT4 fwin_pos_a[2],
 const FLT4 fwin_size_a[2]);

#define COLOR_DONT_DRAW ((UINT4)-1)
void moveto_vtv          /* In file overlay.C */
(const struct xypoint_FLT4 *fpos_pix_a,   /* Pixel position to move to */
 UINT4 icolor_a,                  /* Color to draw it in */
 UINT4 ivtv_a                     /* VTV unit number to use */
 );

void one_out_point       /* In file bothout.c */
  (const struct xypoint_FLT4 *fpoint1_a,  /* First point */
   const struct xypoint_FLT4 *fpoint2_a,  /* Second point */
   struct xypoint_FLT4       *fedge_a,    /* Point on window edge allong line */
   const FLT4  fwin_pos_a[2],             /* Window position */
   const FLT4  fwin_size_a[2]             /* Window size */
   );

void one_out_reduce      /* In file bothout.c */
  (const struct xypoint_FLT4 *fpoint1_a,  /* First point */
   const struct xypoint_FLT4 *fpoint2_a,  /* Second point */
   FLT4* pfreduce_a,                      /* Proportion of line length reduced */
   const FLT4  fwin_pos_a[2],             /* Window position */
   const FLT4  fwin_size_a[2]             /* Window size */
   );

void overlaydot            /* In file overlay.c */
  (SINT4 ix_a,
   SINT4 iy_a,
   UINT4 ifont_a,
   UINT4 iunit_a );

#ifdef SIGMET_PROJECTION_H
  MESSAGE ReprojectTable     /* In file: ReprojectTable.c */
( const struct mpj_projection8 *pInProjection_a,
  const struct mpj_region8     *pInRegion,
  const struct mpj_projection8 *pOutProjection_a,
  const struct mpj_region8     *pOutRegion_a, 
  struct rpj_table *pTable_a );

  MESSAGE ReprojectVtv         /* In file: ReprojectVtv.c */
( VTV                           Input_a,
  const struct mpj_projection8 *pInProjection_a,
  const struct mpj_region8     *pInRegion_a,
  VTV                           Output_a,     /* Output data */
  const struct mpj_projection8 *pOutProjection_a,
  const struct mpj_region8     *pOutRegion_a,
  const FLT4 fwin_pos_a[2] );                 /* Offset of region in Output_a */

void ReprojectVtvCopy              /* File: ReprojectVtv.c */
( VTV Input_a,
  VTV Output_a,
  const FLT4 fwin_pos_a[2],                 /* Offset to to region in output */
  const struct rpj_table *pTablef_a );
#endif  /* #ifdef SIGMET_PROJECTION_H */

void rhi_grid              /* In Vertical_grids.c */
(const FLT4 fwin_pos_a[2],
 const FLT4 fwin_size_a[2],
 const FLT4 fscale_a[2],    /* Scale factors in km/pixel */
 const FLT4 fradpos_a[2],   /* Radar position in pixels */
 UINT4 igrid_a,
 UINT4 iaxis_a,
 VTV  image_a, 
 UINT2 lgrid_a,
 UINT4 iFontHeight_a,       /* Height of font to use */
 UINT4 iunits_a );

void text_corners 
  (VTV   image_a,
   SINT4 ix_a,
   SINT4 iy_a,
   volatile const char *sText_a,
   UINT4 itype_a,
   SINT4 *ixleft_a,         /* Position to draw the box at */
   SINT4 *iylow_a,
   SINT4 *ixhigh_a,
   SINT4 *iyhigh_a,
   SINT4 *iXText_a,         /* Position to draw the text at */
   SINT4 *iYText_a
   );

/* This routine is called by the output process to set up the color map for
 * the window.  This must be called before the windows process has been
 * started.  This routine will allocate shared color cells, and set them with
 * the correct values.
 */
#ifdef INCLUDE_X11_PROTOTYPES
void XsAllocStandardColors             /* File: colors.c */
(Display *display_a,
 Colormap Colormap_a,
 XVisualInfo *pVisualInfo_a,
 volatile const struct color_def StandardColors_a[256],
 volatile UINT4 StandardVtvMapClient_a[256] );  /* Mapping table for VTV to image */

  Widget XsAppInitialize                /* File: initialize.c */
(XtAppContext * app_context_return,
 const char* application_class,
 XrmOptionDescRec *options,
 Cardinal num_options,
 int *argc_in_out,
 String *argv_in_out,
 String *fallback_resources,
 ArgList args_in,
 Cardinal num_args_in,
 SINT4 iDesiredDepth_a,
 Colormap *pColormap_a,
 XVisualInfo *pVisualInfo_a );

/* Get the pixel value corresponding to black in the current
 * colormap environment.
 */
UINT4 XsBlackPixel             /* File: colors.c */
(Display *pDisplay_a,
 Colormap Colormap_a,
 const XVisualInfo *pVisualInfo_a );

/* Compute the mapping table required for a particular color map, given that
 * we have already allocated the standard colormap.  Note that the
 * iStandardVtvMapClient_a is only used for 8-bit psuedo-color mode,
 * so it does not really matter if it is a client map or a server
 * side map.
 */
void XsComputeMappingTable             /* File: colors.c */
(Display *pDisplay_a,
 Colormap Colormap_a,
 XVisualInfo *pVisualInfo_a,
 volatile const struct color_def StandardColors_a[256],
 volatile const UINT4 iStandardVtvMapClient_a[256],
 volatile const struct color_def Colors_a[256],
 UINT4 iVtvMapClient_a[256] );    /* Returns mapping to use here */

#ifdef SIGMET_FILEFORMATS_LIB_H
  void XsCreateAndFillImage           /* File: xscreateimage.c */
  (Display *disp_a, 
   const PICINFO *pinfo_a, 
   XImage **bg_image_a);
#endif  /* #ifdef SIGMET_FILEFORMATS_LIB_H */

#endif  /* #ifdef INCLUDE_X11_PROTOTYPES */

/* Search for the nearest color from an array of colors.  Return the
 * index.
 */
  UINT2 XsFindNearestColor            /* File: NearestColor.c */
( volatile const struct color_def *pColor_a,
  volatile const struct color_def Map_a[],
  SINT4 iColorCount_a );         /* Number of colors to search in the map, Max 2**16 */

/* This routine is called to possibly byte swap the VTV-to-Image 
 * mapping table.  This is only required when the client and server
 * byte conventions are different, and using more than 1 byte-per-pixel.
 */

#ifdef INCLUDE_X11_PROTOTYPES
void XsFixColorArray
(const XImage *pXImage_a,              /* Structure returned by XCreateImage */
 volatile UINT4 vtv_to_image_map_a[],  /* Table to convert */
 SINT4 iSize_a );                      /* Size of table */

void XsFixColorArrayNew
(const UINT4 iimage_depth_a,
 const UINT4 iimage_byte_order,
 volatile UINT4 vtv_to_image_map_a[],  /* Table to convert */
 SINT4 iSize_a );                      /* Size of table */

void XsFixVtvToImageMap             /* File: colors.c */
(const XImage *pXImage_a,           /* Structure returned by XCreateImage */
 volatile UINT4 vtv_to_image_map_a[256] );  /* Mapping table for VTV to image */

/* Search around for the best visual on the screen to use.  Return it along
 * with descriptive information.
 */
Visual* XsGetDesiredVisual             /* File: colors.c */
(Display  *pDisplay_a,
 int      iDesiredDepth_a,     /* Attempt to force a true color visual of this depth */
 Colormap *pFinalColormap_a,         /* Always filled in */
 XVisualInfo *pFinalVisualInfo_a );   /* Always filled in */
#endif  /* #ifdef INCLUDE_X11_PROTOTYPES */

/* Get the image depth from the visual depth.
 */
UINT4 XsImageDepthFromVisualDepth             /* File: colors.c */
(UINT4 iVisualDepth_a);

/* Indicate weather the specified visual class is read-only or not.
 */
UINT2 XsReadOnlyMap            /* File: colors.c */
( int iClass_a );

/* Get the pixel value corresponding to white in the current
 * colormap environment.
 */
#ifdef INCLUDE_X11_PROTOTYPES
UINT4 XsWhitePixel             /* File: colors.c */
(Display *pDisplay_a,
 Colormap Colormap_a,
 const XVisualInfo *pVisualInfo_a );
#endif  /* #ifdef INCLUDE_X11_PROTOTYPES */


#endif /* ifndef MESSAGE_ONLY */

#ifdef __cplusplus
}
#endif
#endif /* #ifndef SIGMET_TVSUBS_LIB_H */
