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

  CURSOR_FUNC.H    Global variables and functions for  CURSOR_FUNC 

=============================================================================*/
#ifndef CURSOR_FUNC_H
#define CURSOR_FUNC_H

#ifdef CURSOR_FUNC_ALLOCATE
#define EXTERN
#else
#define EXTERN extern
#endif


/* Used only for cursor mode: */
struct qlm_cursor_info8
  {
    UINT4 lvalid;                      /*Following status is valid*/
    UINT4 lel_hgt_valid;               /*Elevation, height and slant range are app.*/
    FLT8 faz;                          /* Angles in radians */
    FLT8 fel;
    FLT8 fRange;                       /* Horizontal range in km */
    FLT8 fEastRange;                   /* East range in km */
    FLT8 fNorthRange;                  /* North range in km */
    struct latlon8 latlon;             /*Latitude and longitude*/
    FLT4 fSlantRange;                  /* Slant range in km*/
    FLT4 fheight;                      /* Height in km */

    UINT4 idata_value;                 /*Data value */
  };

/* Flip Y axis between X and VTV conventions */
SINT4 flipY
( SINT4 iypos_a );
/* Convert to floating position */
FLT4 fFloatPos
( SINT4 iPos_a );
/* Convert to fixed position */
SINT4 iFixPos
( FLT4 fPos_a );

class CursorFunc 
{
  public :
    CursorFunc(void);                        /* Constructor */
    void  buttonDown(SINT4 x_a, SINT4 y_a);  /* Button 1 was pressed */
    void  buttonDrag(SINT4 x_a, SINT4 y_a);  /* Button 1 was dragged */
    void  mouseMotion(SINT4 x_a, SINT4 y_a); /* Mouse was moved */
    void  enterMode( void );                 /* Cursor mode entered */
    void  exitMode( void );                  /* Cursor mode exited */
    void  newProduct( void );                /* New product is on the screen */
    void  notifyPeerEntered( void );         /* Another mode entered */
    void  notifyPeerExited( void );          /* Another mode exited */

    void  getCurrentHome                     /* Gets home from cursor */
      ( struct home_point *pHome_a );
    void  loadHome( const struct home_point *pHome_a );
    void  plantHome( void );                 /* Call when plant home button pressed */

    void  drawHome                           /* Draw the home point, used by track */
      (const struct home_point *pHome_a);
    void EarthFromPixel
      (const FLT4 fPos_a[2],                 /* Input cursor position in pixels */
       struct qlm_cursor_info8 *cursor_a );
    void PixelFromEarth
      (const struct latlon8 *pEarth_a,
       FLT4  fHeight_a,
       SINT4 iPos_a[2],                      /* Gets cursor position in zoomed pixels */
       UINT2 lclip_a );

  private :
    struct latlon8 CursorLatLon_c;
    FLT8 fCursorHeight_c;                    /* Saved cursor location between modes */
    UINT2 lInCursorMode_c;
#define CURSOR_OFF         0
#define CURSOR_DOMINANT    1
#define CURSOR_SUBSERVIENT 2
    UINT2 iSubMode_c;                        /* Sub mode we are in */
    struct home_point Home_c;                /* Current home point */
    void setUserCursor
      (const SINT4 ipos_a[2],
       UINT2 lsave_a );
    void setHome( void );
    void patchRadarHome(void);               /* Fixes radar position, and text on screen */

};
EXTERN CursorFunc cursorFunc;

#undef EXTERN
#endif
