/* *******************************************
 * *                                         *
 * *   Global varables for cursorFunc        *
 * *                                         *
 * *******************************************
 * File: iris/window/cursorFunc.h
 *
 *                     COPYRIGHT (c) 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. 
 */
#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.*/
    struct D2Polar8 Polar;             /* Range and Az */
    //    FLT8 faz;                          /* Angles in radians */
    FLT8 fel;                          /* Angles in radians */
    //    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 );
SINT4 flipYXsect
( SINT4 iypos_a );
/* Convert to floating position */
FLT4 fFloatPos
( SINT4 iPos_a );
/* Convert to fixed position */
SINT4 iFixPos
( FLT4 fPos_a );


#define CURSOR_OFF         0
#define CURSOR_DOMINANT    1
#define CURSOR_SUBSERVIENT 2

#define CURSOR_WINDOW_MAIN    0
#define CURSOR_WINDOW_XSECT   1

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  buttonDownDragXsect(SINT4 x_a, SINT4 y_a); /* Button 1 was pressed */
    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 EarthFromPixelXsect
      (const FLT4 fPos_a[2],                 /* Input cursor position in pixels */
       struct qlm_cursor_info8 *cursor_a, struct on_screen_picture8 *ponscreen_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;
    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,  UINT1 icursosr_window_type_a );
    void setHome( void );
    void patchRadarHome(void);               /* Fixes radar position, and text on screen */

};
EXTERN CursorFunc cursorFunc;

#undef EXTERN
#endif
