/* ===========================================================================

 liveFunc.h    Global variables and functions for Cross Section Tool

=============================================================================*/
#ifdef LIVE_FUNC_ALLOCATE
#define EXTERN
#else
#define EXTERN extern
#endif

struct live_line
{
  FLT4  fLeft[2];
  FLT4 fRight[2];
};

struct LiveState 
{
  UINT4 iSiteNum;
  UINT4 iProductType;
  char  sTName[16];
  UINT2 iDataIn;          /* Input data type for the product */
  UINT2 iDataOut;         /* Output data type for the product */
  FLT4  fXSmoother;     /* Smoothing distances in km */
  FLT4  fYSmoother;
  struct ymds_time        ymdsTime;
  struct ymds_time        ymdsTimes[MAX_INGEST_FILES];
  SINT4 iXRad;
  SINT4 iYRad;
  SINT4 iMaxRange;
  SINT4 iRhiHeight;
  SINT4 iZrConst;
  SINT4 iZrExp;
  UINT4 iZrFlags;
  SINT4 iShearRadialSmooth;
  UINT2 lTaskNameChanged;
  UINT2 lTaskNameTimeChanged;


  struct cappi_psi_struct   cappi;
  struct ppi_psi_struct     ppi;
  struct rhi_psi_struct     rhi;
  struct shear_psi_struct   shear;
  struct sri_psi_struct     sri;
  struct top_psi_struct     top;
  struct vil_psi_struct     vil;
  struct ingest_header_long ismHdr;

};

class LiveFunc 
{
  public :
    LiveFunc( void );                       /* Constructor */
    void  buttonDown(SINT4 x_a, SINT4 y_a);  /* Button 1 was pressed */
    void  buttonDrag(SINT4 x_a, SINT4 y_a);  /* Button 1 dragged */
    void  buttonUp(SINT4 x_a, SINT4 y_a);    /* Button 1 was released */
    void  enterMode( void );                 /* Cross mode entered */
    void  exitMode( void );                  /* Cross mode exited */
    void  newProduct( void );                /* New product is on the screen */

    void  copyCurLiveStateToPrev(void);
    void  toggleLiveState(void);
    void  setSiteNum(UINT4 isite_num_a);
    UINT4 getSiteNum(void);
    void  setProductType(UINT4 iproduct_type_a);
    UINT4 getProductType(void);
    void  setTaskName(char *stask_name_a);
    char  *getTaskName(void);
    void  setTaskNameChanged(UINT2 ltask_name_changed_a);
    UINT2 getTaskNameChanged(void);
    void  setTaskNameTimeChanged(UINT2 ltask_name_time_changed_a);
    void  setProductNameChanged(UINT2 lproduct_name_changed_a);
    UINT2 getProductNameChanged(void);
    void  clrTaskNameChangedFlags(void);
    void  setZrRelation(SINT4 izr_const_a, SINT4 izr_exp_a);
    void  getZrRelation(SINT4 *izr_const_a, SINT4 *izr_exp_a);
    void  setZrRelationFlags(UINT4 izr_flags);
    UINT4 getZrRelationFlags(void);
    void  setMaxRange(SINT4 imax_range_a);
    SINT4 getMaxRange(void);
    void  setRadarPosition(SINT4 ix_rad_a, SINT4 iy_rad_a);

    void setYmdsTime(struct ymds_time ymds_time_a);
    void setYmdsTimes(UINT4 idx_a, struct ymds_time ymds_time_a);
    void getYmdsTimes(UINT4 idx_a, struct ymds_time *ymds_time_a);
    void setNumYmdsTimes(UINT4 inum_ymds_times_a);
    UINT4 getNumYmdsTimes(void);
    void setCurYmdsTimesIdx(UINT4 icur_ymds_times_idx_a);
    UINT4 getCurYmdsTimesIdx(void);

    void setCappiPsiStruct(struct cappi_psi_struct cappi_a);
    void getCappiPsiStruct(struct cappi_psi_struct *cappi_a);

    void setPpiPsiStruct(struct ppi_psi_struct ppi_a);
    void getPpiPsiStruct(struct ppi_psi_struct *ppi_a);

    void  setRhiPsiStruct(struct rhi_psi_struct rhi_a);
    void  getRhiPsiStruct(struct rhi_psi_struct *rhi_a);
    void  setRhiHeight(SINT4 iheight_a);
    SINT4 getRhiHeight(void);

    void  setShearPsiStruct(struct shear_psi_struct shear_a);
    void  getShearPsiStruct(struct shear_psi_struct *shear_a);
    void  setShearRadialSmooth(SINT4 ishear_radial_smooth_a );
    SINT4 getShearRadialSmooth(void);

    void setSriPsiStruct(struct sri_psi_struct sri_a);
    void getSriPsiStruct(struct sri_psi_struct *sri_a);

    void setTopPsiStruct(struct top_psi_struct top_a);
    void getTopPsiStruct(struct top_psi_struct *top_a);

    void setVilPsiStruct(struct vil_psi_struct vil_a);
    void getVilPsiStruct(struct vil_psi_struct *vil_a);

    void setIsmHdrStruct(struct ingest_header_long ism_hdr_a);
    void getIsmHdrStruct(struct ingest_header_long *ism_hdr_a);

    void  clrMakingLiveProductFlag();          /* clear flag making live prod */
    void  makeButton( UINT2 lcross_sect_mode_a );      /* "Make" button was pressed */
    void  heightTyped( const char *string ); /* Height was typed in by user */
    void  sizeTyped( UINT2 iSize_a );        /* Size was typed in by user */
    void  setDataType                          /* Data was typed in by user */
      ( UINT2 iDataIn_a, UINT2 iDataOut_a );
    void  getDataType                          /* Data was typed in by user */
      ( UINT2 *iDataIn_a, UINT2 *iDataOut_a );
    void  xSectDataTyped                          /* Data was typed in by user */
      ( UINT2 iDataIn_a, UINT2 iDataOut_a );

    void  setSmoother                      /* New smoothing number type in by user */
      ( FLT4 fXSmooth_a, FLT4 fYSmooth_a );
    void  getSmoother                      /* New smoothing number type in by user */
      ( FLT4 *fXSmooth_a, FLT4 *fYSmooth_a );
    void  xSectSmootherTyped                      /* New smoothing number type in by user */
      ( FLT4 fXSmooth_a, FLT4 fYSmooth_a );

    void  notifyPeerEntered( void );         /* Another tool was entered */
    void  getCrossSize                       /* Get current cross section desired size */
      (SINT4 iSize_a[2] ); void  processServerReply                 /* Cross section command from server */ (char *stoks_a[8], const char *pdata, SINT4 isize );

  private :
    UINT2 lProductNameChanged_c;
    UINT4  iCurYmdsTimesIdx;
    UINT4  iNumYmdsTimes;
    struct LiveState curLiveState_c;
    struct LiveState prevLiveState_c;

    UINT2 lCrossSectMode_c; 
    UINT2 lInCrossMode_c;           /* Indicates which end we are attached to */
    UINT2 lAttachedToRight;         /* Indicates which end we are attached to */
    UINT2 lMakingLiveProduct;       /* Indicates if were are mak a live prod */
    UINT2 lSkippedLiveProduct;      /* Indicates if were are mak a live prod */
    FLT8 fSavedLeft[2];             /* Saved end location between modes */
    FLT8 fSavedRight[2];            /* These are distances from the radar in km */

    struct live_line currentLine;  /* The current cross section line definition */

    UINT2 iXSectDataIn_c;          /* Input data type for the product */
    UINT2 iXSectDataOut_c;         /* Output data type for the product */
    char  sPName_c[16];       /* Cross product name to make */
    struct serv_ymds_time time_c; /* Time to make cross section from.  This is 
				   * ingest time found when doing ingest check. 
				   * It may differ from the base product time if
				   * data is not there. */

    FLT8  fHeight_c;        /* Height of Cross section in km */
    UINT4 lValid_c;         /* Cross section info below is valid*/
    struct D2Polar8 CrossCenter_c;  /* Bearing from radar to center of cross section */
//    FLT8  fRange_c;         /* Range from radar to center of Cross section in km */
    //    FLT8  fAzimuth_c;       /* Azimuth from radar to center of Cross section */
    struct D2Polar8 CrossDir_c;  /* Direction and width of the  cross section */
    //    FLT8  fWidth_c;         /* Width of Cross section in km */
    //    FLT8  fAngle_c;         /* Orientation angle of Cross section in radians */
    FLT4  fXSectXSmoother_c;     /* Smoothing distances in km */
    FLT4  fXSectYSmoother_c;

    UINT4 iPSCState_c;      /* State of the cross product in the Schedule */
    SINT4 iWidth_c;         /* Width and height of the cross section window in pixels*/
    SINT4 iHeight_c;

    void RedrawCrossLine
      (void);
    void plantCrossLine
      (const struct live_line *line,   /* Position of the end points of the line */
       const struct on_screen_picture8 *onscreen_a,
       UINT2 lsave_a );
    void drawHeight
      ( UINT4 iunits_a );  /* Units to display in */
    void processCheckCommand
      (const char *pdata_a, SINT4 isize_a );
    void ConfigurePCF( void );
    void processIngCheckCommand
      (const char *spcf_a, UINT4 ilen_a );
    void processKeepCheckCommand
      (const char *phd_a, SINT4 ilen_a, const char* stat_a );
    void processSaveCommand( void );
    void processTimeCommand( void );

};
EXTERN LiveFunc liveFunc;

#undef EXTERN
