]> git.mxchange.org Git - flightgear.git/blobdiff - src/Instrumentation/dclgps.hxx
Merge branches 'jmt/dialog' and 'durk/scenery'
[flightgear.git] / src / Instrumentation / dclgps.hxx
index 3766e6932d831c35d651538b45420662327b3783..2f0d0f6e36f41e3415ef4bac7d1a954918de7d09 100644 (file)
 #include <vector>
 #include <map>
 
-#include <Navaids/navrecord.hxx>
-#include <Navaids/navlist.hxx>
-#include <Navaids/fixlist.hxx>
-#include <Airports/simple.hxx>
 #include <simgear/structure/subsystem_mgr.hxx>
-
-using namespace std;
+#include <Navaids/positioned.hxx>
 
 class SGTime;
+class FGPositioned;
+
+// XXX fix me
+class FGNavRecord;
+class FGAirport;
+class FGFix;
 
 enum GPSDistanceUnits {
        GPS_DIST_UNITS_NM = 0,
@@ -94,9 +95,7 @@ struct GPSWaypoint {
   
   GPSWaypoint(const std::string& aIdent, float lat, float lon, GPSWpType aType);
   
-  static GPSWaypoint* createFromFix(const FGFix* aFix);
-  static GPSWaypoint* createFromNav(const FGNavRecord* aNav);
-  static GPSWaypoint* createFromAirport(const FGAirport* aApt);
+  static GPSWaypoint* createFromPositioned(const FGPositioned* aFix);
   
     ~GPSWaypoint();
        string GetAprId();      // Returns the id with i, f, m or h added if appropriate. (Initial approach fix, final approach fix, etc)
@@ -187,72 +186,14 @@ private:
 
 // ------------------------------------------------------------------------------
 
-class DCLGPS;
-
-class GPSPage {
-       
-public:
-       GPSPage(DCLGPS* parent);
-       virtual ~GPSPage() = 0;
-       virtual void Update(double dt);
-       virtual void Knob1Left1();
-       virtual void Knob1Right1();     
-       virtual void Knob2Left1();
-       virtual void Knob2Right1();     
-       virtual void CrsrPressed();
-       virtual void EntPressed();
-       virtual void ClrPressed();
-       virtual void DtoPressed();
-       virtual void NrstPressed();
-       virtual void AltPressed();
-       virtual void OBSPressed();
-       virtual void MsgPressed();
-       
-       // Sometimes a page needs to maintain state for some return paths,
-       // but change it for others.  The CleanUp function can be used for
-       // changing state for non-ENT return  paths in conjunction with
-       // GPS::_cleanUpPage
-       virtual void CleanUp();
-       
-       // The LooseFocus function is called when a page or subpage looses focus
-       // and allows pages to clean up state that is maintained whilst focus is
-       // retained, but lost on return.
-       virtual void LooseFocus();
-       
-       // Allows pages that display info for a given ID to have it set/get if they implement these functions.
-       virtual void SetId(const string& s);
-       virtual const string& GetId()=0;
-       
-       inline int GetSubPage() { return(_subPage); }
-       
-       inline int GetNSubPages() { return(_nSubPages); }
-       
-       inline const string& GetName() { return(_name); }
-       
-protected:
-       DCLGPS* _parent;
-       string _name;   // eg. "APT", "NAV" etc
-       int _nSubPages;
-       // _subpage is zero based
-       int _subPage;   // The subpage gets remembered when other pages are displayed
-       string GPSitoa(int n);
-};
-
-/*-----------------------------------------------------------------------*/
-
-typedef vector<GPSPage*> gps_page_list_type;
-typedef gps_page_list_type::iterator gps_page_list_itr;
-
 // TODO - merge generic GPS functions instead and split out KLN specific stuff.
 class DCLGPS : public SGSubsystem {
        
-       friend class GPSPage;
-       
 public:
        DCLGPS(RenderArea2D* instrument);
        virtual ~DCLGPS() = 0;
        
-       virtual void draw();
+       virtual void draw(osg::State& state);
        
        virtual void init();
        virtual void bind();
@@ -267,18 +208,7 @@ public:
        // Render a char at a given position as above
        virtual void DrawChar(char c, int field, int px, int py, bool bold = false);
        
-       virtual void Knob1Right1();
-       virtual void Knob1Left1();
-       virtual void Knob2Right1();
-       virtual void Knob2Left1();
-       virtual void CrsrPressed();
-       virtual void EntPressed();
-       virtual void ClrPressed();
-       virtual void DtoPressed();
-       virtual void NrstPressed();
-       virtual void AltPressed();
-       virtual void OBSPressed();
-       virtual void MsgPressed();
+       virtual void ToggleOBSMode();
        
        // Set the number of fields
        inline void SetNumFields(int n) { _nFields = (n > _maxFields ? _maxFields : (n < 1 ? 1 : n)); }
@@ -310,7 +240,7 @@ public:
        
        void SetOBSFromWaypoint();
        
-       inline GPSWaypoint* GetActiveWaypoint() { return &_activeWaypoint; }
+       GPSWaypoint* GetActiveWaypoint();
        // Get the (zero-based) position of the active waypoint in the active flightplan
        // Returns -1 if no active waypoint.
        int GetActiveWaypointIndex();
@@ -318,7 +248,7 @@ public:
        int GetWaypointIndex(const string& id);
        
        // Returns meters
-       inline float GetDistToActiveWaypoint() { return _dist2Act; }
+       float GetDistToActiveWaypoint();
        // Returns degrees (magnetic)
        float GetHeadingToActiveWaypoint();
        // Returns degrees (magnetic)
@@ -384,14 +314,6 @@ protected:
        // 2D rendering area
        RenderArea2D* _instrument;
        
-       // The actual pages
-       gps_page_list_type _pages;
-       
-       // The currently active page
-       GPSPage* _activePage;
-       // And a facility to save the immediately preceeding active page
-       GPSPage* _lastActivePage;
-       
        // Units
        GPSSpeedUnits _velUnits;
        GPSDistanceUnits _distUnits;
@@ -428,6 +350,9 @@ protected:
        // Find the closest VOR to a position in RADIANS.
        FGNavRecord* FindClosestVor(double lat_rad, double lon_rad);
 
+  // helper to implement the above FindFirstXXX methods
+  FGPositioned* FindTypedFirstById(const std::string& id, FGPositioned::Type ty, bool &multi, bool exact);
+
        // Position, orientation and velocity.
        // These should be read from FG's built-in GPS logic if possible.
        // Use the property node pointers below to do this.