]> git.mxchange.org Git - flightgear.git/blobdiff - src/Autopilot/route_mgr.hxx
Tie samplegroup 'avionics' to the listener, just in case no other device is created...
[flightgear.git] / src / Autopilot / route_mgr.hxx
index 0cc05250fe279dcae3af0944db814478a14d3485..8806cae2746a918d18d53bfacf3c95a2479c7e4e 100644 (file)
 #ifndef _ROUTE_MGR_HXX
 #define _ROUTE_MGR_HXX 1
 
-#ifndef __cplusplus
-# error This library requires C++
-#endif
-
-#ifdef HAVE_CONFIG_H
-#  include <config.h>
-#endif
-
-#include <simgear/compiler.h>
-
-#include STL_STRING
-#include <vector>
-
-SG_USING_STD(string);
-SG_USING_STD(vector);
-
 #include <simgear/props/props.hxx>
 #include <simgear/route/route.hxx>
 #include <simgear/structure/subsystem_mgr.hxx>
@@ -64,6 +48,8 @@ private:
 
     // automatic outputs
     SGPropertyNode_ptr true_hdg_deg;
+    SGPropertyNode_ptr target_altitude_ft;
+    SGPropertyNode_ptr altitude_lock;
 
     SGPropertyNode_ptr wp0_id;
     SGPropertyNode_ptr wp0_dist;
@@ -78,6 +64,35 @@ private:
     SGPropertyNode_ptr wpn_eta;
 
 
+    class Listener : public SGPropertyChangeListener {
+    public:
+        Listener(FGRouteMgr *m) : mgr(m) {}
+        virtual void valueChanged (SGPropertyNode * prop);
+    private:
+        FGRouteMgr *mgr;
+    };
+
+    SGPropertyNode_ptr input;
+    Listener *listener;
+    SGPropertyNode_ptr mirror;
+    bool altitude_set;
+
+    SGWayPoint* make_waypoint(const string& target);
+    void update_mirror();
+    bool near_ground();
+
+    /**
+     * Helper to set a string property to the estimated arrival time (ETA),
+     * formatted as either hours:minutes or minutes:seconds, based on a distance
+     * and the current groundspeed.
+     */
+    void setETAPropertyFromDistance(SGPropertyNode_ptr aProp, double aDistance);
+    
+    /**
+     * Helper to update the target_altitude_ft and altitude_set flag when wp0
+     * changes
+     */
+    void updateTargetAltitude();
 public:
 
     FGRouteMgr();
@@ -91,19 +106,18 @@ public:
 
     bool build ();
 
-    void add_waypoint( const SGWayPoint& wp ) {
-        route->add_waypoint( wp );
-    }
+    void new_waypoint( const string& tgt_alt, int n = -1 );
+    void add_waypoint( const SGWayPoint& wp, int n = -1 );
+    SGWayPoint pop_waypoint( int i = 0 );
 
     SGWayPoint get_waypoint( int i ) const {
         return route->get_waypoint(i);
     }
 
-    SGWayPoint pop_waypoint();
-
     int size() const {
         return route->size();
     }
+
 };