/**C*
 *
 * Vaisala software source code file
 *
 * Copyright (c) Vaisala Oyj 1992, 1995, 1998, 1999, 2000, 2003, 2004, 2006,
 * 2007, 2011, 2012.
 * All rights reserved.
 *
 **C*/

/** @file
 *
 * Header file for VTV library function prototypes
 *
 * $URL: https://subversion.vaisala.com/svn/repos/sigmet/wr_iris_rda/tags/release8.13.6/base/vtv_lib/vtv_lib.h $
 *
 * $Id: vtv_lib.h 28688 2012-11-19 16:39:17Z jho $
 *
 */

#ifndef SIGMET_VTV_LIB_H
#define SIGMET_VTV_LIB_H 1

#ifdef __cplusplus
extern "C" {
#endif
#if 0
}
#endif

#define VTV_BADIMS       (VTV_FACILITY+1)
#define VTV_BADFONT      (VTV_FACILITY+2)
#define VTV_BADPOS       (VTV_FACILITY+3)
#define VTV_BADREPEAT    (VTV_FACILITY+4)
#define VTV_FILLPANIC    (VTV_FACILITY+5)
#define VTV_FONTFILE_BAD (VTV_FACILITY+6)
#define VTV_FONTFILE_MIS (VTV_FACILITY+7)
#define VTV_INV_FLAG     (VTV_FACILITY+8)
#define VTV_NO_UNIT      (VTV_FACILITY+9)
#define VTV_NOROOM       (VTV_FACILITY+10)
#define VTV_COLORS_UNSET (VTV_FACILITY+11)
#define VTV_COLOR_LIMITS (VTV_FACILITY+12)

/*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_DEFAULT       (251)  /* used for all other cases */

#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
{
    int32_t iBBwidth, iBBheight;     /* Bounding box */
    int32_t iBBoffsetY, iBBoffsetX;  /* Bounding box offset to origin */
    int32_t iPointSize;              /* Point size in 1/10 of a point */
    int32_t iWidthInBytes;           /* Width of character cell in bytes */
    int32_t ichar_size;              /* Number of bytes per character */
    int32_t ichar_height;            /* Height of the number 0 */
    int32_t ibytes;                  /* # bytes for whole font */
    char  sName[FONT_NAME_SIZE];     /* Name of the font */
};

struct vtv_font_list
{
    int32_t 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 VTV_PIXEL *VTV_PATTERN;
void vtv_color_region       /* In file regions_c.c */
(VTV ivtv_a,
 uint8_t iAuxColor_a,
 const VTV_PATTERN ipattern_a );

/* Return AUX value, if wanted */
uint8_t VtvColorFromPixel   /* In file: color.c */
(VTV ivtv_a,
 struct color_def *pColor_a,
 VTV_PIXEL iPixel_a );

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

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

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

void VtvCopyAreaMerge3      /* In file copying.c */
(VTV iSource_a,
 VTV iTarget_a,
 int32_t iwidth_a,
 int32_t iheight_a,
 int32_t itarx_a,
 int32_t 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,
 int32_t iwidth_a,          /* Size of region to merge */
 int32_t iheight_a,
 int32_t itarx_a,           /* Position of region in target */
 int32_t itary_a );

void vtv_copy_area_ratio    /* In file copying.c */
(VTV isource_a,
 VTV itarget_a, 
 int32_t isrcx_a,           /* Location of left of src */
 int32_t isrcy_a,           /* Location of bottom of src */
 int32_t isrc_width_a,      /* Width of source image in pixels */
 int32_t isrc_height_a,     /* Height of source image in pixels */
 int32_t itarx_a,           /* Location of left of target location */
 int32_t itary_a,           /* Location of bottom of target location */
 int32_t itar_width_a,      /* Width of target image in pixels */
 int32_t 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 */
 int32_t isrcx_a,
 int32_t isrcy_a,
 int32_t iwidth_a,          /* horizontal position to start string */
 int32_t iheight_a,         /* Vertical position to start string */
 int32_t itarx_a,
 int32_t itary_a,
 int32_t ixrepeat_a,
 int32_t iyrepeat_a
    );

void VtvCopyVisualInfo
(VTV iTargetImage_a,
 VTV iSourceImage_a );

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

void VtvFillImageWithData8  /* In file copying.c */
( VTV vtv_a,
  const uint8_t *pdata_a    /* Data array fill with  */
    );

void VtvFillImageWithData16 /* In file copying.c */
( VTV vtv_a,
  const uint16_t *pdata_a   /* Data array fill with  */
    );

void VtvFillImageWithDataRatio8
(VTV itarget_a,
 const uint8_t *pDataSrc_a, 
 int32_t isrc_width_a,      /* Width of source image in pixels */
 int32_t isrc_height_a,     /* Height of source image in pixels */
 int32_t itar_width_a,      /* Width of target image in pixels */
 int32_t itar_height_a);    /* Height of target image in pixels */

void VtvFillImageWithDataRatio16
(VTV itarget_a,
 const uint16_t *pDataSrc_a, 
 int32_t isrc_width_a,      /* Width of source image in pixels */
 int32_t isrc_height_a,     /* Height of source image in pixels */
 int32_t itar_width_a,      /* Width of target image in pixels */
 int32_t itar_height_a);    /* Height of target image in pixels */

void VtvFillImageWithPseudoColor8     /* In file allocate_c.c */
( VTV image_a,
  uint8_t *pdata_a,         /* Data array fill with  */
  const struct color_def Colormap_a[256] 
    );

/* Returns malloced array, you must free after use, NULL on error */
uint8_t *VtvExtractPic24Image /* In file colors.c */
( VTV image_a
    );

/* Returns malloced array, you must free after use, NULL on error */
uint8_t *VtvExtractPic32Image /* In file colors.c */
( VTV image_a,
  uint8_t btransparent_a,   /* Background is transparent */
  uint32_t ibg_color_a      /* Background color. Only valid if trans is true */
    );

/* Returns malloced array, you must free after use, NULL on error */
uint8_t *VtvExtractAux8Image /* In file colors.c */
( VTV vtv_a );

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_circle        /* File: lines_c.c */
(VTV image_a,
 int32_t ix_center_a,       /* Center location */
 int32_t iy_center_a,
 double  fRadius_a);        /* Radius */

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

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

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

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

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

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

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

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

void vtv_drop_shadows       /* In file regions_c.c */
(VTV   image_a,
 int32_t ix_a,
 int32_t iy_a,
 int32_t iwidth_a,
 int32_t iheight_a,
 uint8_t ithresh_a,         /* Aux flag of thresholded data */
 VTV_PIXEL pdrop_a,         /* Color of drop shadows */
 uint8_t inoscan_a,         /* Aux flags of area not scanned */
 int32_t ilength_a
    );

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

void vtv_fill_rectangle     /* In file regions_c.c */
(VTV   image_a,             /* Image ID */
 int32_t ix_a,              /* Horizontal position */
 int32_t iy_a,              /* Vertical position */
 uint32_t iwidth_a,         /* Width */
 uint32_t 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 */
 int32_t ix_a,              /* Horizontal position */
 int32_t iy_a,              /* Vertical position */
 uint8_t iAuxBoundary_a,    /* Boundary aux value */
 int32_t istyle_a 
    );

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

#ifdef INCLUDE_X11_PROTOTYPES
void VtvGetVisualInfo       /* In file: colors.c */
(VTV image_a,
 XVisualInfo *pVisualInfo_a );
#endif  /* #ifdef INCLUDE_X11_PROTOTYPES */

VTV_PIXEL *VtvGetDataPointer /* In file allocate_c.c */
(VTV   image_a,             /* Image ID */
 int32_t ix_a,              /* Horizontal position */
 int32_t iy_a               /* Vertical position */
    );

uint32_t 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
    );

VTV_PIXEL VtvGetForeground  /* In file text.c */
(VTV   image_a              /* Image ID */
    );

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

void vtv_lib_nls_init(void);
#define VTV_LIB_INIT vtv_lib_nls_init()

VTV_PIXEL VtvPixelFromColor /* In file: color.c */
(VTV ivtv_a,
 volatile const struct color_def *pColor_a,
 uint8_t iAux_a );

#ifdef INCLUDE_X11_PROTOTYPES
/* Function does not require initialized VTV */
VTV_PIXEL VtvPixelFromColorInfo    /* In file: color.c */
( volatile const struct color_def *pColor_a,
  uint8_t iAux_a,
  const XVisualInfo *pVisualInfo_a );
#endif  /* #ifdef INCLUDE_X11_PROTOTYPES */

#ifdef INCLUDE_X11_PROTOTYPES
/* Function does not require initialized VTV */
void VtvPixelsFromColorInfo
( VTV_PIXEL iPixels_a[],
  volatile const struct color_def pColor_a[],
  uint8_t iAux_a,
  const XVisualInfo *pVisualInfo_a,
  int   iPixelCount_a );
#endif  /* #ifdef INCLUDE_X11_PROTOTYPES */

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

#ifdef INCLUDE_X11_PROTOTYPES
void VtvSetVisualInfo       /* In file: colors.c */
(VTV image_a,
 const XVisualInfo *pVisualInfo_a );
#endif  /* #ifdef INCLUDE_X11_PROTOTYPES */

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

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

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

void VtvSetForeground       /* In file text.c */
(VTV   image_a,             /* Image ID */
 VTV_PIXEL foreground_a     /* Foreground color */
    );

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

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

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