/* **********************************************************************
 * *                                                                    *
 * *  OUTPUT process function prototypes                                *
 * *                                                                    *
 * **********************************************************************
 * File: include/out_lib.h
 *
 * COPYRIGHT (c) 1993, 1995, 1996, 1997, 1998, 1999, 2001, 2002, 2003,
 *                              2004  BY
 *          SIGMET INCORPORATED, 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.
 */

#ifdef OUT_LIB_ALLOCATE
#define EXTERN
#else
#define EXTERN extern
#endif

#define     APO_TYPE        1
#define OUT_APO_TYPE        (OUT_FACILITY + APO_TYPE        )
#define     BAD_COLOR_ALLOC 2
#define OUT_BAD_COLOR_ALLOC (OUT_FACILITY + BAD_COLOR_ALLOC )
#define     BADDISID        3
#define OUT_BADDISID        (OUT_FACILITY + BADDISID        )
#define     BADDISPLAY      4
#define OUT_BADDISPLAY      (OUT_FACILITY + BADDISPLAY      )
#define     BADHID          5
#define OUT_BADHID          (OUT_FACILITY + BADHID          )
#define     BAD_LAT         6
#define OUT_BAD_LAT         (OUT_FACILITY + BAD_LAT         )
#define     BAD_SIZE        7
#define OUT_BAD_SIZE        (OUT_FACILITY + BAD_SIZE        )
#define     CANCELLED       8
#define OUT_CANCELLED       (OUT_FACILITY + CANCELLED       )
#define     CANT_RAW        9
#define OUT_CANT_RAW        (OUT_FACILITY + CANT_RAW        )
#define     CANT_STATUS     10
#define OUT_CANT_STATUS     (OUT_FACILITY + CANT_STATUS     )
#define     DATA_MISSING    11
#define OUT_DATA_MISSING    (OUT_FACILITY + DATA_MISSING    )
#define     DISPLAYBUSY     12
#define OUT_DISPLAYBUSY     (OUT_FACILITY + DISPLAYBUSY     )
#define     FILE_SIZE       13
#define OUT_FILE_SIZE       (OUT_FACILITY + FILE_SIZE       )
#define     FORK_CLAIMED    14
#define OUT_FORK_CLAIMED    (OUT_FACILITY + FORK_CLAIMED    )
#define     FORK_DEVICE     15
#define OUT_FORK_DEVICE     (OUT_FACILITY + FORK_DEVICE     )
#define     FORK_NUMBER     16
#define OUT_FORK_NUMBER     (OUT_FACILITY + FORK_NUMBER     )
#define     GIF_SIZE        17
#define OUT_GIF_SIZE        (OUT_FACILITY + GIF_SIZE        )
#define     NET_CLOSE       18
#define OUT_NET_CLOSE       (OUT_FACILITY + NET_CLOSE       )
#define     NET_COPY        19
#define OUT_NET_COPY        (OUT_FACILITY + NET_COPY        )
#define     NET_FILEFORMAT  20
#define OUT_NET_FILEFORMAT  (OUT_FACILITY + NET_FILEFORMAT  )
#define     NET_NOTIFY      23
#define OUT_NET_NOTIFY      (OUT_FACILITY + NET_NOTIFY      )
#define     NET_PORT        25
#define OUT_NET_PORT        (OUT_FACILITY + NET_PORT        )
#define     NET_WRITE       28
#define OUT_NET_WRITE       (OUT_FACILITY + NET_WRITE       )
#define     NO_OVERLAP      29
#define OUT_NO_OVERLAP      (OUT_FACILITY + NO_OVERLAP      )
#define     NOR_AREA        30
#define OUT_NOR_AREA        (OUT_FACILITY + NOR_AREA        )
#define     NOR_AREAFILE    32
#define OUT_NOR_AREAFILE    (OUT_FACILITY + NOR_AREAFILE    )
#define     NOR_DATA        33
#define OUT_NOR_DATA        (OUT_FACILITY + NOR_DATA        )
#define     NOR_PTYPE       35
#define OUT_NOR_PTYPE       (OUT_FACILITY + NOR_PTYPE       )
#define     PIPE_ERROR      36
#define OUT_PIPE_ERROR      (OUT_FACILITY + PIPE_ERROR      )
#define     READERROR       37
#define OUT_READERROR       (OUT_FACILITY + READERROR       )
#define     SMALL_SIZE      38
#define OUT_SMALL_SIZE      (OUT_FACILITY + SMALL_SIZE      )
#define     X_WAIT          40
#define OUT_X_WAIT          (OUT_FACILITY + X_WAIT          )
#define     NET_RCPHOST     41
#define OUT_NET_RCPHOST     (OUT_FACILITY + NET_RCPHOST     )
#define     STARTUP_IMAGE   42
#define OUT_STARTUP_IMAGE   (OUT_FACILITY + STARTUP_IMAGE   )


#ifndef MESSAGE_ONLY                      

/* Maximum number of additions VVP products in the time/height VVP display */
#define MAX_VVP_FILES (50)

/* Geometry of wind barbs */
#define BARB_MAIN_LENGTH (23.0)
#define BARB_FEATHER_LENGTH (6.0)
#define BARB_FEATHER_SPACE  (2.8)

#define BARB_GRID_SPACING (2.0+BARB_MAIN_LENGTH+BARB_FEATHER_SPACE)

/* Used to help draw lines for FCAST and SLINE products */
#define FLAG_FIRST    (0x01)
#define FLAG_FORECAST (0x02)
#define FLAG_LAST     (0x04)
#define FLAG_LABEL    (0x08)  /* Label the point/line */

/* Pointer to array of output definition structures */
struct out_legend_def
{
  /* The first four fields are used to find the correct entry */
  UINT4 iptype;      /*Product type, set to zero to indicate end of the list*/
  char  spname[16];  /*Product name, null terminated*/
  SINT4 ires;        /*Resolution (currently only 11 and 17 supported)*/
  SINT4 iline;       /*Which legend line (currently only 1 & 2 supported) */
  char  ipad_28x4[4];

  /* This information is used to specify what to display */
  char sformat[80];
  FLT8  fscale;     /*Optional scale factor to apply to data */
  UINT4 iflag;
#define LEGEND_FLAG_NONE  (0) /*Supply data as 4-byte integer*/
#define LEGEND_FLAG_SCALE (1) /*Convert data to double, and multiply by scale factor*/
#define LEGEND_FLAG_REF   (2) /*Pass data by reference. (useful for strings)*/
  SINT4 ioffset;     /* Byte offset in PSI structure */
};


/* Function prototypes of routines in the output directory. */

#ifdef SIGMET_PRODUCT_H
#ifdef SIGMET_MISC_LIB_H
void cartesian_draw                         /* File: ilayout.C */
( const struct product_hdr *pheader_a,  /* Product header */
  const UINT1 *pData_a,
  const struct layout_control *pconfig_a,
  const union level_control *plevel_a,
  VTV product_image_a );
#endif  /* #ifdef SIGMET_MISC_LIB_H */
#endif  /* #ifdef SIGMET_PRODUCT_H */


#ifdef SIGMET_PRODUCT_H
#ifdef SIGMET_PROJECTION_H
void catch_draw
  (const struct product_hdr *phdr_a,
   const struct on_screen_picture8 *onscreen_a,
   const union level_control *pLevel_a,   /* Level control may be different from onscreen */
   UINT2 iOutFlags_a,
   VTV   image_a,
   SINT4 icount_a );
#endif  /* #ifdef SIGMET_PROJECTION_H */
#endif  /* #ifdef SIGMET_PRODUCT_H */

#ifdef SIGMET_PRODUCT_H
#ifdef SIGMET_MISC_LIB_H
#ifdef SIGMET_PROJECTION_H
void color_legend
  (UINT4 image_a,
   SINT4 ix_a,
   SINT4 iy_a,
   const struct on_screen_picture8 *pOnScreen_a,  /* Could be modified */
   const struct scale_text *scale_a, /* Text to draw */
   UINT4 iflags_a
   );
#endif  /* #ifdef SIGMET_PROJECTION_H */
#endif  /* #ifdef SIGMET_MISC_LIB_H */
#endif  /* #ifdef SIGMET_PRODUCT_H */

void copy_image_scale                       /* File: copyimage.c */
(VTV ifile_a,
 const struct layout_control *config_a,
 VTV ivtv_a );

#ifdef SIGMET_PROJECTION_H
void copy_image_merge                       /* File: copyimage.c */
(VTV input_image_a,
 struct on_screen_picture8 *pOnScreen_a,
 VTV output_image_a );
#endif  /* #ifdef SIGMET_PROJECTION_H */

void draw_barb                              /* File: vvp_draw_c.c */
(UINT4 image_a,
 SINT4 ix_a,          /* Starting position */
 SINT4 iy_a,
 FLT4  fspeed_a,      /* Speed in 10 time full ticks */
 FLT4  fangle_a );    /* Direction in radians */

void draw_cross                             /* File: vvp_draw_c.c */
(UINT4 image_a,
 SINT4 ix_a,          /* Starting position */
 SINT4 iy_a );

void draw_highlight_string                  /* File: warn_draw.c */
(VTV image_a,
 SINT4 ix_a,
 SINT4 iy_a,
 const char *smessage_a,
 UINT4 iTextJustification_a,  /* Type of text justification */
 UINT4 icolor_back_a );

#ifdef SIGMET_TVSUBS_LIB_H
void draw_line_wide                         /* File: track_draw.c */
(const struct xypoint_FLT4 *pos1_a,
 const struct xypoint_FLT4 *pos2_a,
 UINT4 iunit_a );
#endif  /* #ifdef SIGMET_TVSUBS_LIB_H */

#ifdef SIGMET_PRODUCT_H
#ifdef SIGMET_MISC_LIB_H
#ifdef SIGMET_PROJECTION_H
void draw_legend                            /* File: out_legend.C */
(struct on_screen_picture8 *ponscreen_a,
 const struct scale_text scale_a[16],
 UINT4 final_image_a,
 const struct out_legend_def OutLegend_a[] );
#endif  /* #ifdef SIGMET_PROJECTION_H */
#endif  /* #ifdef SIGMET_MISC_LIB_H */
#endif  /* #ifdef SIGMET_PRODUCT_H */


void draw_point_vtv                         /* File: track_draw.c */
(const SINT4 ipoint_a[2],
 const FLT4 fwin_pos_a[2],
 const FLT4 fwin_size_a[2],
 SINT4 isize_a,
 VTV ivtv_a );


#ifdef SIGMET_PRODUCT_H
#ifdef SIGMET_SETUP_H
#ifdef SIGMET_PROJECTION_H
void draw_protected_plus_message            /* File: out_apo.C */
(const struct product_hdr *phdr_a,
 const struct on_screen_picture8 *onscreen_a,
 const struct warn_specific_options *pPso_a,
 VTV image_a,
 const struct protect_setup *prots_a,
 SINT4 icount_a );
#endif  /* #ifdef SIGMET_PROJECTION_H */
#endif  /* #ifdef SIGMET_SETUP_H */
#endif  /* #ifdef SIGMET_PRODUCT_H */

void draw_string                            /* File: vvp_draw_c.c */
(UINT4 image_a,
 SINT4 ix_a,          /* Starting position */
 SINT4 iy_a,
 FLT4 fmagnitude_a,   /* Magnitude of string */
 FLT4 fangle_a,       /* Direction of string */
 FLT4 fmaximum_a );   /* Magnitude to draw at max length */

void GetStandardColormap                    /* File: ilayout.C */
( volatile struct color_def Colormap_a[256] );

#ifdef SIGMET_PRODUCT_H
#ifdef SIGMET_PROJECTION_H
void find_apo                               /* File: out_apo.C */
(volatile const struct one_product_file *desc_a,
 volatile struct on_screen_picture8 *pOnScreen_a,
 volatile struct one_product_file *pApoFiles_a[4] );  /* First 3 for APO, last one for forecast */
#endif  /* #ifdef SIGMET_PROJECTION_H */
#endif  /* #ifdef SIGMET_PRODUCT_H */

#ifdef SIGMET_PRODUCT_H
#ifdef SIGMET_PROJECTION_H
UINT1 * ForecastShift                       /* File: forecast.c */
( const UINT1* pData_a,
  const struct on_screen_picture8 *pOnScreen_a,
  volatile const struct one_product_file *pForecastFile_a );
#endif  /* #ifdef SIGMET_PROJECTION_H */
#endif  /* #ifdef SIGMET_PRODUCT_H */

#ifdef SIGMET_PRODUCT_H
#ifdef SIGMET_PROJECTION_H
void gage_draw
  (const struct product_hdr *phdr_a,
   const struct on_screen_picture8 *onscreen_a,
   const union level_control *pLevel_a,   /* Level control may be different from onscreen */
   UINT2 iOutFlags_a,
   VTV   image_a,
   SINT4 icount_a );
#endif  /* #ifdef SIGMET_PROJECTION_H */
#endif  /* #ifdef SIGMET_PRODUCT_H */

void HatchTheCentroids                      /* File: warn_draw.c */
(VTV image_a );

#ifdef SIGMET_PRODUCT_H
#ifdef SIGMET_PROJECTION_H
MESSAGE idraw_whole_image
(UINT4 *image_a,
 volatile const struct one_product_file *desc_a,
 struct on_screen_picture8 *pOnScreen_a,      /* Filled in */
 UINT2 (*lstop_e)(void) );
#endif  /* #ifdef SIGMET_PROJECTION_H */
#endif  /* #ifdef SIGMET_PRODUCT_H */

#ifdef SIGMET_GENERIC_PRODUCT_DEFINED
#ifdef SIGMET_PROJECTION_H
MESSAGE ilayout                             /* File: ilayout.C */
  (const union generic_product *pProduct_a,    /* The product file */
   SINT4 idata_size_a,
   UINT4 final_image_a,
   volatile const struct one_product_file *desc_a,
   struct on_screen_picture8 *pOnScreen_a,
   SINT4 iDevice_a,                            /* Device number, origin 1 */
   const struct out_legend_def OutLegend_a[],     /* Legend def file info */
   UINT2 (*lstop_e)(void) );
#endif  /* #ifdef SIGMET_PROJECTION_H */
#endif  /* SIGMET_GENERIC_PRODUCT_DEFINED */

#ifdef SIGMET_PRODUCT_H
#ifdef SIGMET_PROJECTION_H
void image_draw
(const struct product_hdr *phdr_a,      /* Product header, data follows */
 const struct on_screen_picture8 *pOnScreen_a, /* On_Screen structure */
 VTV Vtv_a );                           /* vtv to put it in, colormap will change */
#endif  /* #ifdef SIGMET_PROJECTION_H */
#endif  /* SIGMET_PRODUCT_H */

#ifdef SIGMET_PRODUCT_H
#ifdef SIGMET_PROJECTION_H
MESSAGE LayoutForPipe                       /* File: ilayout.C */
  (const struct product_hdr *header_a,            /* The product file header */
   SINT4 idata_size_a,                            /* Size of data from file */
   volatile const struct one_product_file *desc_a,
   struct on_screen_picture8 *pOnScreen_a,         /* Fills in this structure */
   SINT4 iDevice_a                                /* Device number, origin 1 */
    );
#endif  /* #ifdef SIGMET_PROJECTION_H */
#endif  /* #ifdef SIGMET_PRODUCT_H */

UINT2 lProductUsesOverlay                   /* File: copyimage.c */
( UINT4 iPType_a );

#ifdef SIGMET_PRODUCT_H
#ifdef SIGMET_PROJECTION_H
void ndop_draw
(const struct product_hdr *phdr_a,               /* Product header from the file */
 const struct on_screen_picture8 *onscreen_a,
 const struct wind_specific_options *ppso_a,  /* Output options for wind */
 VTV image_a );                                  /* Image to draw in */
#endif  /* #ifdef SIGMET_PROJECTION_H */
#endif  /* #ifdef SIGMET_PRODUCT_H */

#ifdef SIGMET_PRODUCT_H
#ifdef SIGMET_PROJECTION_H
void out_apo_new                            /* File: out_apo.C */
  (volatile struct one_product_file *pApoFiles_a[3],
   struct on_screen_picture8 *onscreen,
   VTV image_a,
   SINT4 iDevice_a );      /* Device number, origin 1 */
#endif  /* #ifdef SIGMET_PROJECTION_H */
#endif  /* #ifdef SIGMET_PRODUCT_H */

MESSAGE out_legend_load                     /* File: out_legend_load.C */
( struct out_legend_def **pOutLegend_a );

#ifdef SIGMET_OUTPUT_H
#ifdef SIGMET_PRODUCT_H
#ifdef SIGMET_PROJECTION_H
void out_overbuf                            /* File: overlay_buffer.c */
  (const struct on_screen_picture8 *pscreen,
   UINT4 Image_a,
   UINT2 (*lstop_e)(void) );
#endif  /* #ifdef SIGMET_PROJECTION_H */
#endif  /* #ifdef SIGMET_PRODUCT_H */
#endif  /* #ifdef SIGMET_OUTPUT_H */

#ifdef SIGMET_PRODUCT_H
#ifdef SIGMET_PROJECTION_H
#ifdef SIGMET_VTV_LIB_H
void track_draw
(const struct product_hdr *phead_a,
 const struct on_screen_picture8 *onscreen_a,
 const struct warn_specific_options *pPso_a,
 VTV   image_a,
 SINT4 icount_a );    /* Index of which APO this is */
#endif  /* #ifdef SIGMET_VTV_LIB_H */
#endif  /* #ifdef SIGMET_PROJECTION_H */
#endif  /* #ifdef SIGMET_PRODUCT_H */

volatile struct one_product_file *pProductToOutput /* File: header_from_onscreen */
  (SINT4 idevice_a );

#ifdef SIGMET_PRODUCT_H
#ifdef SIGMET_PROJECTION_H
void sline_draw                              /* File: sline_draw.c */
(const struct product_hdr *phead_a,
 const struct on_screen_picture8 *onscreen_a,
 VTV   image_a,
 SINT4 icount_a );
#endif  /* #ifdef SIGMET_PROJECTION_H */
#endif  /* #ifdef SIGMET_PRODUCT_H */

#ifdef SIGMET_PRODUCT_H
#ifdef SIGMET_PROJECTION_H
void sline_draw_one                          /* File: sline_draw.c */
(const struct on_screen_picture8 *onscreen_a,
 VTV image_a, 
 const struct sline_results *pResults_a,
 SINT4 iForecastTime_a,     /* Maximum forecast time in seconds, zero means dont */
 UINT1 lTwoFcast_a );       /* Draw two FCAST lines */
#endif  /* #ifdef SIGMET_PROJECTION_H */
#endif  /* #ifdef SIGMET_PRODUCT_H */

#ifdef SIGMET_PRODUCT_H
#ifdef SIGMET_PROJECTION_H
char *sPsiText17                             /* File: psitext.c */
  (const struct on_screen_picture8 *pOnScreen_a,
   SINT4 iline_a,
   const struct out_legend_def OutLegend_a[] );

char *sPsiText13                             /* File: psitext.c */
  (const struct on_screen_picture8 *pOnScreen_a,
   SINT4 iline_a,
   const struct out_legend_def OutLegend_a[] );

#endif  /* #ifdef SIGMET_PROJECTION_H */
#endif  /* #ifdef SIGMET_PRODUCT_H */

#ifdef SIGMET_PRODUCT_H
#ifdef SIGMET_PROJECTION_H
void tdwr_draw                               /* File: tdwr_draw.c */
(const struct tdwr_product *pTdwr_a,
 const struct on_screen_picture8 *onscreen_a,
 const struct warn_specific_options *pPso_a,
 VTV   image_a,
 SINT4 icount_a );
#endif  /* #ifdef SIGMET_PROJECTION_H */
#endif  /* #ifdef SIGMET_PRODUCT_H */

#ifdef SIGMET_VTV_LIB_H
#ifdef SIGMET_PRODUCT_H
#ifdef SIGMET_PROJECTION_H
MESSAGE vtv_to_link
(VTV ivtv_a,
 volatile const struct one_product_file *desc_a,
 volatile const char *spath_a,   /* Device file or file Path name */
 UINT4 iFormat_a,                /* Link format */
 SINT4 iunit_a,                  /* Link unit number, 0 means write to file */
 const struct on_screen_picture8 *pOnScreen_a, 
 UINT2 (*lstop_e)(void) );       /* Function used to stop transmission */
#endif  /* #ifdef SIGMET_PROJECTION_H */
#endif  /* #ifdef SIGMET_PRODUCT_H */
#endif  /* #ifdef SIGMET_VTV_LIB_H */

#ifdef SIGMET_VTV_LIB_H
#ifdef SIGMET_SETUP_H
void vtv_to_printer                         /* File: vtv_to_printer.C */
  (VTV ivtv_a,
   volatile const struct device_def *pDevice_a );
#endif  /* #ifdef SIGMET_SETUP_H */
#endif  /* #ifdef SIGMET_VTV_LIB_H */

#ifdef SIGMET_PRODUCT_H
MESSAGE vtv_to_file_format
(UINT4 ivtv_a,                          /* VTV pointer */
 const struct product_hdr *pPHeader_a,  /* Description of picture */
 const char *sdest_path_a,              /* Path name to place tiff file */
 UINT1 iCompress_a,                     /* Compression scheme to use */
 UINT2 file_format_type_a);
#endif  /* #ifdef SIGMET_PRODUCT_H */

#ifdef SIGMET_PRODUCT_H
#ifdef SIGMET_MISC_LIB_H
void vvp_draw                               /* File: vvp_draw_c.c */
(const struct product_hdr *phead_a,
 const struct vvp_results vvp_a[],
 UINT4 iunits_a,
 const struct vvp_specific_options *pvvp_options_a,
 volatile struct one_product_file *pVvpFiles_a[],
 const union level_control *level,
 UINT4 pimage_a );
#endif  /* #ifdef SIGMET_MISC_LIB_H */
#endif  /* SIGMET_PRODUCT_H */

void WaitForEvent                           /* File: output_state_c.c */
( UINT1 iDeviceType_a );

#ifdef SIGMET_PRODUCT_H
#ifdef SIGMET_VTV_LIB_H
#ifdef SIGMET_PROJECTION_H
void warn_draw                              /* File: warn_draw.c */
  (const struct product_hdr *phead_a,
   const struct on_screen_picture8 *onscreen_a,
   const struct warn_specific_options *pPso_a,
   VTV image_a,
   SINT4 icount_a );    /* Index of which APO this is */
#endif  /* #ifdef SIGMET_PROJECTION_H */
#endif  /* SIGMET_VTV_LIB_H */
#endif  /* SIGMET_PRODUCT_H */

#ifdef SIGMET_PRODUCT_H
#ifdef SIGMET_VTV_LIB_H
#ifdef SIGMET_PROJECTION_H
void warning_draw_one                       /* File: warn_draw.c */
( const struct warning_results *pResults_a,
  const struct on_screen_picture8 *onscreen_a,
  const struct warn_specific_options *pPso_a,
  VTV image_a,
  UINT1 lPrintLabel_a );   /* Print text label, if any */
#endif  /* #ifdef SIGMET_PROJECTION_H */
#endif  /* SIGMET_VTV_LIB_H */
#endif  /* SIGMET_PRODUCT_H */

#ifdef SIGMET_PRODUCT_H
#ifdef SIGMET_PROJECTION_H
void wind_draw                              /* File: wind_draw.c */
(const struct product_hdr *phdr_a,
 const struct on_screen_picture8 *onscreen_a,
 const struct wind_specific_options *pso_a,
 UINT4 image_a );
#endif  /* #ifdef SIGMET_PROJECTION_H */
#endif  /* SIGMET_PRODUCT_H */

#endif  /* #ifndef MESSAGE_ONLY */

#undef EXTERN

