X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FInstrumentation%2Fdclgps.hxx;h=e2b2ee269df6426d497bc2b7d39251a036740276;hb=db85ebff95b5e7bcb469d99ae25e062b733d090b;hp=435f7899a25e51f53e5ca4ed2a229a8eee3bcfac;hpb=e2bf85e67ebe9d53a6d9b3664988d263b3cc412a;p=flightgear.git diff --git a/src/Instrumentation/dclgps.hxx b/src/Instrumentation/dclgps.hxx index 435f7899a..e2b2ee269 100644 --- a/src/Instrumentation/dclgps.hxx +++ b/src/Instrumentation/dclgps.hxx @@ -33,6 +33,7 @@ #include #include +#include #include class SGTime; @@ -43,27 +44,6 @@ class FGNavRecord; class FGAirport; class FGFix; -enum GPSDistanceUnits { - GPS_DIST_UNITS_NM = 0, - GPS_DIST_UNITS_KM -}; - -enum GPSSpeedUnits { - GPS_VEL_UNITS_KT, - GPS_VEL_UNITS_KPH -}; - -enum GPSAltitudeUnits { - GPS_ALT_UNITS_FT, - GPS_ALT_UNITS_M -}; - -enum GPSPressureUnits { - GPS_PRES_UNITS_IN = 1, - GPS_PRES_UNITS_MB, - GPS_PRES_UNITS_HP -}; - // --------------------- Waypoint / Flightplan stuff ----------------------------- // This should be merged with other similar stuff in FG at some point. @@ -126,9 +106,9 @@ public: virtual ~FGIAP() = 0; //protected: - string _id; // The ID of the airport this approach is for - string _name; // The approach name, eg "VOR/DME OR GPS-B" - string _abbrev; // The abbreviation the GPS unit uses - eg "VOR/D" in this instance. Possibly GPS model specific. + string _aptIdent; // The ident of the airport this approach is for + string _ident; // The approach ident. + string _name; // The full approach name. string _rwyStr; // The string used to specify the rwy - eg "B" in this instance. bool _precision; // True for precision approach, false for non-precision. }; @@ -140,10 +120,10 @@ public: ~FGNPIAP(); //private: public: - vector _IAF; // The initial approach fix(es) + vector _approachRoutes; // The approach route(s) from the IAF(s) to the IF. + // NOTE: It is an assumption in the code that uses this that there is a unique IAF per approach route. vector _IAP; // The compulsory waypoints of the approach procedure (may duplicate one of the above). - // _IAP includes the FAF and MAF. - vector _MAP; // The missed approach procedure (doesn't include the MAF). + // _IAP includes the FAF and MAF, and the missed approach waypoints. }; typedef vector < FGIAP* > iap_list_type; @@ -186,77 +166,22 @@ 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 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(); virtual void unbind(); virtual void update(double dt); + + // Expand a SIAP ident to the full procedure name. + string ExpandSIAPIdent(const string& ident); // Render string s in display field field at position x, y // WHERE POSITION IS IN CHARACTER UNITS! @@ -266,36 +191,11 @@ 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)); } - // Set Units - // m if true, ft if false - inline void SetAltUnitsSI(bool b) { _altUnits = (b ? GPS_ALT_UNITS_M : GPS_ALT_UNITS_FT); } - // Returns true if alt units are SI (m), false if ft - inline bool GetAltUnitsSI() { return(_altUnits == GPS_ALT_UNITS_M ? true : false); } - // km and k/h if true, nm and kt if false - inline void SetDistVelUnitsSI(bool b) { _distUnits = (b ? GPS_DIST_UNITS_KM : GPS_DIST_UNITS_NM); _velUnits = (b ? GPS_VEL_UNITS_KPH : GPS_VEL_UNITS_KT); } - // Returns true if dist/vel units are SI - inline bool GetDistVelUnitsSI() { return(_distUnits == GPS_DIST_UNITS_KM && _velUnits == GPS_VEL_UNITS_KPH ? true : false); } - // Set baro units - 1 = in, 2 = mB, 3 = hP Wrapping if for the convienience of the GPS setter. - void SetBaroUnits(int n, bool wrap = false); - // Get baro units: 1 = in, 2 = mB, 3 = hP - inline int GetBaroUnits() { return((int)_baroUnits); } - // It is expected that specific GPS units will override these functions. // Increase the CDI full-scale deflection (ie. increase the nm per dot) one (GPS unit dependent) increment. Wraps if necessary (GPS unit dependent). virtual void CDIFSDIncrease(); @@ -309,7 +209,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(); @@ -317,7 +217,7 @@ public: int GetWaypointIndex(const string& id); // Returns meters - inline float GetDistToActiveWaypoint() { return _dist2Act; } + float GetDistToActiveWaypoint(); // Returns degrees (magnetic) float GetHeadingToActiveWaypoint(); // Returns degrees (magnetic) @@ -353,7 +253,7 @@ public: inline bool GetToFlag() const { return(_headingBugTo); } // Initiate Direct To operation to the supplied ID. - void DtoInitiate(const string& id); + virtual void DtoInitiate(const string& id); // Cancel Direct To operation void DtoCancel(); @@ -383,20 +283,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; - GPSPressureUnits _baroUnits; - GPSAltitudeUnits _altUnits; - // CDI full-scale deflection, specified either as an index into a vector of values (standard values) or as a double precision float (intermediate values). // This will influence how an externally driven CDI will display as well as the NAV1 page. // Hence the variables are located here, not in the nav page class. @@ -416,9 +302,11 @@ protected: protected: + void LoadApproachData(); + // Find first of any type of waypoint by id. (TODO - Possibly we should return multiple waypoints here). - GPSWaypoint* FindFirstById(const string& id) const; - GPSWaypoint* FindFirstByExactId(const string& id) const; + GPSWaypoint* FindFirstById(const string& id) const; + GPSWaypoint* FindFirstByExactId(const string& id) const; FGNavRecord* FindFirstVorById(const string& id, bool &multi, bool exact = false); FGNavRecord* FindFirstNDBById(const string& id, bool &multi, bool exact = false); @@ -427,8 +315,8 @@ 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); + // 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. @@ -545,10 +433,6 @@ protected: // Configuration that affects flightplan operation bool _turnAnticipationEnabled; - - // Configuration that affects general operation - bool _suaAlertEnabled; // Alert user to potential SUA entry - bool _altAlertEnabled; // Alert user to min safe alt violation // Magvar stuff. Might get some of this stuff (such as time) from FG in future. SGTime* _time;