#ifndef _FLOATINGCOMPASS_H
#define _FLOATINGCOMPASS_H
static char FloatingCompass_h_id[] = "$Header: /usr/tiburon/unix/gui/tmacs/RCS/FloatingCompass.h,v 1.5 1997/10/24 11:20:31 oreilly Exp $";

/*
$Log: FloatingCompass.h,v $
Revision 1.5  1997/10/24 11:20:31  oreilly
*** empty log message ***

 * Revision 1.4  97/05/07  17:22:19  17:22:19  oreilly (Thomas C. O'Reilly)
 * Delete contained DmInputDetector in destructor
 * 
 * Revision 1.3  97/03/20  12:33:58  12:33:58  oreilly (Thomas C. O'Reilly)
 * *** empty log message ***
 * 
 * Revision 1.2  96/11/04  14:45:49  14:45:49  oreilly (Thomas C. O'Reilly)
 * Get vehicle turns from DM item instead of calculating it
 * 
 * Revision 1.1  96/10/28  09:13:42  09:13:42  oreilly (Thomas C. O'Reilly)
 * Initial revision
 * 
*/

#include <X11/IntrinsicP.h>
#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <X11/CoreP.h>
#include <Vk/VkPopupMenu.h>
#include "DmGuiObject.h"
#include "CompassFace.h"
#include "State.h"
#include "DynamicLabel.h"
#include "DmInputDetector.h"

#define NoPrevHeading -99999.
// #define nHistoryIntervals 60
#define nHistoryIntervals 120

/* Compass displays heading value */
class FloatingCompass : public DmGuiObject
{
  public:
  
  FloatingCompass(const char *name, Widget parent, int period,
		  int historyInterval            // Seconds
		  );

  ~FloatingCompass() 
  {
    if (_autoOnOff)
      delete _autoOnOff;
  }
  
  virtual const char *className()
  {
    return "FloatingCompass";
  }
  
  virtual void updateGui(DM_Item handle = 0);
  virtual void updateFromPeer(DmGuiObject *peer, void *clientData);

  
  protected:

  void resetTurns();
  static void resetCallback(Widget w, XtPointer clientData,
			    XtPointer callData);
  
  CompassFace *_face;
  DynamicLabel *_headingText;
  Widget _turnsText;
  Flt32 _prevHeading;
  int _prevTurns;
  Flt32 _turnsSetpoint;
  DmInputDetector *_autoOnOff;
  
  DmAttitudeObject *_dmAttitude;
  DmFlt32Object *_dmAutoHeading;
  DmBooleanObject *_dmAutoOnOff;
  DmInt16Object *_dmTurns;
  DmFlt32Object *_dmTurnsSetpoint;
  
  MBool _dmInDegrees;

  Boolean _saveHistory;
  int _historySampleInterval;
  MBool _autoHeadingOn;
  static VkMenuDesc _menuPane[];
  
  time_t _sampleTime;
};


#endif
