/* ******************************************************************
 * *                                                                *
 * * Header file for VTV library function prototypes                *
 * *                                                                *
 * ******************************************************************
 * File: include/vtv_lib.h
 *
 *   COPYRIGHT (c) 1992, 1995, 1998, 1999, 2000, 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_VTV_LIB_H
#define SIGMET_VTV_LIB_H 1

#ifdef __cplusplus
extern "C" {
#endif

#define BADIMS           1
#define VTV_BADIMS       (VTV_FACILITY+BADIMS   )
#define BADFONT          2
#define VTV_BADFONT      (VTV_FACILITY+BADFONT  )
#define BADPOS           3
#define VTV_BADPOS       (VTV_FACILITY+BADPOS   )
#define BADREPEAT        4
#define VTV_BADREPEAT    (VTV_FACILITY+BADREPEAT)
#define FILLPANIC        5
#define VTV_FILLPANIC    (VTV_FACILITY+FILLPANIC)
#define FONTFILE_BAD     6
#define VTV_FONTFILE_BAD (VTV_FACILITY+FONTFILE_BAD)
#define FONTFILE_MIS     7
#define VTV_FONTFILE_MIS (VTV_FACILITY+FONTFILE_MIS)
#define INV_FLAG         8
#define VTV_INV_FLAG     (VTV_FACILITY+INV_FLAG )
#define NO_UNIT          9
#define VTV_NO_UNIT      (VTV_FACILITY+NO_UNIT  )
#define NOROOM           10
#define VTV_NOROOM       (VTV_FACILITY+NOROOM   )
#define COLORS_UNSET     11
#define VTV_COLORS_UNSET (VTV_FACILITY+COLORS_UNSET )
#define COLOR_LIMITS     12
#define VTV_COLOR_LIMITS (VTV_FACILITY+COLOR_LIMITS )

#ifndef MESSAGE_ONLY

/*Largest screen size that can be requested */
  /* This is the max of the largest window and the largest product size */
#define VTV_MAX_WIDTH   (5000)
#define VTV_MAX_HEIGHT  (5000)

  /* Special VTV color numbers in color displays */
#define COLOR_NOSCAN_TEMP   (255)  /* used temporarily before overlay is merged */
#define COLOR_THRESH_TEMP   (254)  /* used temporarily before overlay is merged */
  
  /* Only used in for warning drawing */
#define COLOR_BOUNDARY_TEMP (253)  /* used temporarily for filling boundary */
#define COLOR_FILL_TEMP     (252)  /* used temporarily before filling with pattern */

#define COLOR_OVERLAY1      (0)
#define COLOR_OVERLAY2      (1)
#define COLOR_OVERLAY3      (2)
#define COLOR_OVER_TXT_BACK (3)
#define COLOR_LEGEND        (4)
#define COLOR_CENTROID      (5)
#define COLOR_BLINK         (6)
#define COLOR_TRACK         (7)
#define COLOR_HIGHLIGHT     (8)
#define COLOR_SHEARLINE     (9)
#define COLOR_WIND_BARBS    (10)
#define COLOR_RANGE_RINGS   (11)
#define COLOR_OVERLAY_COUNT (12)  /* First special colors will overlay */

#define COLOR_DROP_SHADOW   (12)  /* Could be overlay, but likely many blacks */
#define COLOR_BACKGROUND    (13)
#define COLOR_UNDERLAY1     (14)
#define COLOR_UNDERLAY2     (15)
#define COLOR_UNDERLAY3     (16)
#define COLOR_UNDERLAY1_NOSCAN (17)
#define COLOR_UNDERLAY2_NOSCAN (18)
#define COLOR_UNDERLAY3_NOSCAN (19)
#define COLOR_SPECIAL_COUNT    (20)  /* Set this one higher than the last special color */

#define  MAX_VTV_FONTS  (10)           /* Max # defined fonts */

/* Flags used to indicate fonts */
#define VTV_FONT_5X7   (0)   /* These old values should be phased out */
#define VTV_FONT_7X9   (1)

#define VTV_FONT0 (0)
#define VTV_FONT1 (1)
#define VTV_FONT2 (2)
#define VTV_FONT3 (3)

/* These are the normal expected font heights.  The values could differ if different
 * font definition files are installed.
 */
#define VTV_FONT0_HEIGHT (7)
#define VTV_FONT1_HEIGHT (9)
#define VTV_FONT2_HEIGHT (10)
#define VTV_FONT3_HEIGHT (13)

#define FONT_NAME_SIZE (16)

/* Each available font is described here */
struct  vtv_font_info
{
  SINT4 iBBwidth, iBBheight;       /* Bounding box */
  SINT4 iBBoffsetY, iBBoffsetX;    /* Bounding box offset to origin */
  SINT4 iPointSize;                /* Point size in 1/10 of a point */
  SINT4 iWidthInBytes;             /* Width of character cell in bytes */
  SINT4 ichar_size;                /* Number of bytes per character */
  SINT4 ichar_height;              /* Height of the number 0 */
  SINT4 ibytes;                    /* # bytes for whole font */
  char  sName[FONT_NAME_SIZE];     /* Name of the font */
};

struct vtv_font_list
{
  SINT4 icount;
  struct vtv_font_info font[MAX_VTV_FONTS];
};

struct vtv_colormap
{
  struct color_def rgb[256];
};

/* Function prototypes for the library routines */

void vtv_clear_window	     /* In file regions_c.c */
(VTV iunit_a );

#define VTV_PATTERN_SIZE (24)
typedef UINT1 *VTV_PATTERN;
void vtv_color_region        /* In file regions_c.c */
(VTV ivtv_a,
 UINT4 icolor_a,
 const VTV_PATTERN ipattern_a );

UINT4 VtvCompressColors      /* In file: colors.c */
(VTV Image_a,
 UINT4 iMaxColor_a,        /* Maximum color+1 in output */
 UINT4 iMinColor_a );      /* Minimum color in output */

void vtv_copy_area	     /* In file copying.c */
  (VTV isource_a,	     /* Image ID */
   VTV idest_a,              /* Image ID */
   SINT4 isrcx_a,
   SINT4 isrcy_a,
   SINT4 iwidth_a, 
   SINT4 iheight_a,
   SINT4 itarx_a,
   SINT4 itary_a
   );

/* Absolute copy, but possibly different colormaps */
void VtvCopyAreaMerge0
(VTV iSource_a,    /* Source vtv to merge from */
 VTV iTarget_a,    /* Target vtv to merge into */
 SINT4 iwidth_a,
 SINT4 iheight_a, 
 SINT4 itarx_a,
 SINT4 itary_a );

void VtvCopyAreaMerge1     /* In file copying.c */
  (VTV   isource_a,	     /* Image ID */
   VTV   idest_a,	     /* Image ID */
   SINT4 iwidth_a, 
   SINT4 iheight_a,
   SINT4 itarx_a,
   SINT4 itary_a
   );

void VtvCopyAreaMerge2    /* In file copying.c */
(VTV isource_a,
 VTV itarget_a,
 SINT4 iwidth_a,
 SINT4 iheight_a, 
 SINT4 itarx_a,
 SINT4 itary_a );

void VtvCopyAreaMerge3    /* In file copying.c */
(VTV iSource_a,
 VTV iTarget_a,
 SINT4 iwidth_a,
 SINT4 iheight_a,
 SINT4 itarx_a,
 SINT4 itary_a );

/* Custom merge routine to handle overlays and underlays properly.
 * It will not darken the underlay in areas not scanned. */
void VtvCopyAreaMerge3NoDark
(VTV iSource_a,
 VTV iTarget_a,
 SINT4 iwidth_a,   /* Size of region to merge */
 SINT4 iheight_a,
 SINT4 itarx_a,    /* Position of region in target */
 SINT4 itary_a );

void vtv_copy_area_ratio     /* In file copying.c */
(VTV isource_a,
 VTV itarget_a, 
 SINT4 isrcx_a,          /* Location of left of src */
 SINT4 isrcy_a,          /* Location of bottom of src */
 SINT4 isrc_width_a,     /* Width of source image in pixels */
 SINT4 isrc_height_a,    /* Height of source image in pixels */
 SINT4 itarx_a,          /* Location of left of target location */
 SINT4 itary_a,          /* Location of bottom of target location */
 SINT4 itar_width_a,     /* Width of target image in pixels */
 SINT4 itar_height_a);   /* Height of target image in pixels */

void vtv_copy_area_rep	     /* In file copying.c */
  (VTV   isource_a,	     /* Image ID */
   VTV   idest_a,	     /* Image ID */
   SINT4 isrcx_a,
   SINT4 isrcy_a,
   SINT4 iwidth_a,	     /* horizontal position to start string */
   SINT4 iheight_a,	     /* Vertical position to start string */
   SINT4 itarx_a,
   SINT4 itary_a,
   SINT4 ixrepeat_a,
   SINT4 iyrepeat_a
   );

MESSAGE vtv_create_image     /* In file allocate_c.c */
  (UINT4 iflags_a,	     /* Flags */
#define VTV_ALLOCATE (0)
#define VTV_USE_DATA (1)
   void* idata_a,	     /* Data array to optionally provide */
   SINT4 iwidth_a,	     /* horizontal position to start string */
   SINT4 iheight_a,	     /* Vertical position to start string */
   VTV*  image_a	     /* Image ID (returned) */
   );

void VtvDarkenColor             /* File: color.c */
( struct color_def *pDarkenedColor_a,
  const struct color_def *pInputColor_a );

MESSAGE vtv_destroy_image    /* In file allocate_c.c */
  (VTV   image_a	     /* Image ID */
   );

void vtv_draw_line	     /* In file lines_c.c */
  (VTV   image_a,
   SINT4 ix1_a,
   SINT4 iy1_a,
   SINT4 ix2_a,
   SINT4 iy2_a
   );

void vtv_draw_rectangle	     /* In file lines_c.c */
  (VTV   image_a,	     /* Image ID */
   SINT4 ix_a,		     /* Horizontal position */
   SINT4 iy_a,		     /* Vertical position */
   UINT4 iwidth_a,	     /* Width */
   UINT4 iheight_a	     /* Height */
   );

void vtv_draw_point	     /* In file dots.c */
  (VTV   image_a,	     /* Image ID */
   SINT4 ix_a,		     /* Horizontal position */
   SINT4 iy_a		     /* Vertical position */
   );

void VtvDrawString           /* In file text.c */
( VTV image_a, 
  SINT4 ix_a,
  SINT4 iy_a,
  const char *stext_a    /* Null terminated string */
  );

void vtv_draw_string	     /* In file text.c */
  (VTV   image_a,	     /* Image ID */
   SINT4 ix_a,		     /* horizontal position to start string */
   SINT4 iy_a,		     /* Vertical position to start string */
   const char* string_a,     /* String to draw  */
   SINT4 ilength_a	     /* Length of the string */
   );

void vtv_draw_string_vert    /* In file text.c */
  (VTV   image_a,	     /* Image ID */
   SINT4 ix_a,		     /* horizontal position to start string */
   SINT4 iy_a,		     /* Vertical position to start string */
   const char* string_a,     /* String to draw  */
   SINT4 ilength_a	     /* Length of the string */
   );

void VtvDrawStringVert       /* In file text.c */
( VTV image_a, 
  SINT4 ix_a,
  SINT4 iy_a,
  const char *stext_a    /* Null terminated string */
  );

void vtv_draw_wide_line	     /* In file lines_c.c */
  (VTV   image_a,
   SINT4 ix1_a,
   SINT4 iy1_a,
   SINT4 ix2_a,
   SINT4 iy2_a
   );

void vtv_drop_shadows	     /* In file regions_c.c */
  (VTV   image_a,
   SINT4 ix_a,
   SINT4 iy_a,
   SINT4 iwidth_a,
   SINT4 iheight_a,
   UINT4 ithresh_a,  /* Color of thresholded data */
   UINT4 idrop_a,    /* Color of drop shadows */
   UINT4 inoscan_a,  /* Color of area not scanned */
   SINT4 ilength_a
   );

void vtv_expand_image   /* In file csubs.c */
  (const UINT1 *inarray_a,   /* Input array of bytes */
   SINT4 ixinsize_a,	     /* Input array dimensions */
   SINT4 iyinsize_a,
   UINT1 *outarray_a,	     /* Output array of bytes */
   SINT4 ixoutsize_a,	     /* Output array dimensions */
   SINT4 iyoutsize_a,
   SINT4 ixoff_a,	     /* Pan/Scroll offsets in input */
   SINT4 iyoff_a,
   SINT4 izoom_a,	     /* Zoom (1, 2, 3, or 4) */
   SINT4 iDepth_a            /* Depth of image in bits/pixel */
   ) ;

void vtv_fill_rectangle	     /* In file regions_c.c */
  (VTV   image_a,	     /* Image ID */
   SINT4 ix_a,		     /* Horizontal position */
   SINT4 iy_a,		     /* Vertical position */
   UINT4 iwidth_a,	     /* Width */
   UINT4 iheight_a	     /* Height */
   );

void vtv_fill_window         /* In file regions_c.c */
  (VTV   image_a	     /* Image ID */
   );

#define VTV_FILL_PATCH       (0x01) /* Change the color of a region */
#define VTV_FILL_TO_BOUNDARY (0x02) /* Fill till hitting a boundary color */
#define VTV_FILL_NOSMALL     (0x04) /* Do not fill small areas (prevents leaks) */

void vtv_fill_region	     /* In file regions_c.c */
  (VTV   image_a,	     /* Image ID */
   SINT4 ix_a,		     /* Horizontal position */
   SINT4 iy_a,		     /* Vertical position */
   UINT4 imatch_a,	     /* Match color */
   SINT4 style_a	     /* Type of fill to perform */
   );

void vtv_flip_window         /* In file regions_c.c */
(VTV ivtv_a );

void VtvGetColormap          /* In file: colors.c */
(VTV image_a,
 struct color_def Colormap_a[256] );

UINT1* vtv_get_data_pointer  /* In file allocate_c.c */
(VTV   image_a,	     /* Image ID */
 SINT4 ix_a,		     /* Horizontal position */
 SINT4 iy_a		     /* Vertical position */
 );

UINT4 vtv_get_font	     /* In file text.c */
(VTV   image_a	     /* Image ID */
 );

void vtv_get_fontinfo        /* In file text.c */
(VTV image_a,
 struct vtv_font_info *pvfi_a 
 );

void vtv_get_fontlist        /* In file text.c */
(VTV image_a,
 struct vtv_font_list *pfonts_a
 );

UINT4 vtv_get_foreground     /* In file text.c */
  (VTV   image_a	     /* Image ID */
   );

void vtv_get_size	     /* In file allocate_c.c */
  (VTV   image_a,	     /* Image ID */
   SINT4 *iwidth_a,	     /* Width */
   SINT4 *iheight_a	     /* Height */
   );

/* Replaces all values of one color with another
 */
void vtv_replace_color       /* In file: regions_c.c */
(VTV ivtv_a,
 UINT4 iOldColor_a,
 UINT4 iNewColor_a );

void VtvSetColormap          /* In file: colors.c */
(VTV image_a,
 const struct color_def Colormap_a[256] );

void VtvSetColormapSubSet    /* In file: colors.c */
(VTV image_a,
 const struct color_def Colormap_a[],
 SINT4 iStartColor_a,
 SINT4 iColorCount_a );

void vtv_set_dashes	     /* In file lines_c.c */
  (VTV   image_a,	     /* Image ID */
   UINT4 ipattern_a	     /* Dotted line pattern */
   );

void vtv_set_font            /* In file text.c */
  (VTV   image_a,	     /* Image ID */
   UINT4 ifont_a	     /* Font ID */
   );

UINT4 vtv_set_font_by_height /* In file text.c */
( VTV image_a,               /*Image Id */
  UINT4 iHeight_a            /*Desired height of Font */
  );

void vtv_set_foreground      /* In file text.c */
  (VTV   image_a,	     /* Image ID */
   UINT4 iforeground_a	     /* Foreground color */
   );

void vtv_set_line_width
  (VTV   image_a,	     /* Image ID */
   SINT4 iwidth_a	     /* Line width in 1/1000 of pixels */
   );

SINT4 vtv_text_width
  (VTV   image_a,	     /* Image ID */
   volatile const char* stext_a	/* Text to check, null terminated*/
   );

#endif /* #ifndef MESSAGE_ONLY */

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