]> git.mxchange.org Git - flightgear.git/blobdiff - src/Autopilot/route_mgr.hxx
Cleanup, no functional change
[flightgear.git] / src / Autopilot / route_mgr.hxx
index a8168924807a5ec582759dfd63becd271d527ce6..696d43d618854f965fb24b4cb2889375e72a7fbe 100644 (file)
 #define _ROUTE_MGR_HXX 1
 
 #include <simgear/props/props.hxx>
-#include <simgear/route/waypoint.hxx>
 #include <simgear/structure/subsystem_mgr.hxx>
 
+#include <Navaids/FlightPlan.hxx>
+
 // forward decls
-class SGRoute;
 class SGPath;
-
-class FGAirport;
-typedef SGSharedPtr<FGAirport> FGAirportRef;
+class PropertyWatcher;
 
 /**
  * Top level route manager class
  * 
  */
 
-class FGRouteMgr : public SGSubsystem
+class FGRouteMgr : public SGSubsystem, 
+                   public flightgear::FlightPlan::Delegate
 {
+public:
+  FGRouteMgr();
+  ~FGRouteMgr();
+
+  void init ();
+  void postinit ();
+  void bind ();
+  void unbind ();
+  void update (double dt);
+  
+  bool isRouteActive() const;
+         
+  int currentIndex() const;
+  
+  void setFlightPlan(const flightgear::FlightPlanRef& plan);
+  flightgear::FlightPlanRef flightPlan() const;
+  
+  void clearRoute();
+  
+  flightgear::Waypt* currentWaypt() const;
+  
+  int numLegs() const;
+  
+// deprecated
+  int numWaypts() const
+  { return numLegs(); }
+  
+// deprecated
+  flightgear::Waypt* wayptAtIndex(int index) const;
+  
+  SGPropertyNode_ptr wayptNodeAtIndex(int index) const;
+  
+  void removeLegAtIndex(int aIndex);
+  
+  /**
+   * Activate a built route. This checks for various mandatory pieces of
+   * data, such as departure and destination airports, and creates waypoints
+   * for them on the route structure.
+   *
+   * returns true if the route was activated successfully, or false if the
+   * route could not be activated for some reason
+   */
+  bool activate();
+  
+  /**
+   * deactivate the route if active
+   */
+  void deactivate();
+
+  /**
+   * Set the current waypoint to the specified index.
+   */
+  void jumpToIndex(int index);
+  
+  bool saveRoute(const SGPath& p);
+  bool loadRoute(const SGPath& p);
+  
+  flightgear::WayptRef waypointFromString(const std::string& target);
 
 private:
-    SGRoute* _route;
+    bool commandDefineUserWaypoint(const SGPropertyNode* arg);
+    bool commandDeleteUserWaypoint(const SGPropertyNode* arg);
+    
+    flightgear::FlightPlanRef _plan;
+  
     time_t _takeoffTime;
     time_t _touchdownTime;
-    FGAirportRef _departure;
-    FGAirportRef _destination;
-    
+
     // automatic inputs
-    SGPropertyNode_ptr lon;
-    SGPropertyNode_ptr lat;
-    SGPropertyNode_ptr alt;
     SGPropertyNode_ptr magvar;
     
     // automatic outputs    
@@ -63,6 +119,7 @@ private:
     SGPropertyNode_ptr cruise; ///< cruise information
     
     SGPropertyNode_ptr totalDistance;
+    SGPropertyNode_ptr distanceToGo;
     SGPropertyNode_ptr ete;
     SGPropertyNode_ptr elapsedFlightTime;
     
@@ -88,8 +145,16 @@ private:
      */
     SGPropertyNode_ptr _finished;
     
+    SGPropertyNode_ptr _flightplanChanged;
+  
     void setETAPropertyFromDistance(SGPropertyNode_ptr aProp, double aDistance);
     
+    /**
+     * retrieve the cached path distance along a leg
+     */
+    double cachedLegPathDistanceM(int index) const;
+    double cachedWaypointPathTotalDistance(int index) const;
+  
     class InputListener : public SGPropertyChangeListener {
     public:
         InputListener(FGRouteMgr *m) : mgr(m) {}
@@ -100,107 +165,48 @@ private:
 
     SGPropertyNode_ptr input;
     SGPropertyNode_ptr weightOnWheels;
-    
+    SGPropertyNode_ptr groundSpeed;
+  
     InputListener *listener;
-    SGPropertyNode_ptr mirror;
-
+    SGPropertyNode_ptr mirror;    
+  
     /**
-     * Create a SGWayPoint from a string in the following format:
-     *  - simple identifier
-     *  - decimal-lon,decimal-lat
-     *  - airport-id/runway-id
-     *  - navaid/radial-deg/offset-nm
-     */
-    SGWayPoint* make_waypoint(const string& target);
-    
-    /**
-     * Helper to keep various pieces of state in sync when the SGRoute is
+     * Helper to keep various pieces of state in sync when the route is
      * modified (waypoints added, inserted, removed). Notably, this fires the
      * 'edited' signal.
      */
-    void waypointsChanged();
+    virtual void waypointsChanged();
     
     void update_mirror();
     
-    void currentWaypointChanged();
-    
-    /**
-     * Parse a route/wp node (from a saved, property-lsit formatted route)
-     */
-    void parseRouteWaypoint(SGPropertyNode* aWP);
-    
-    /**
-     * Check if we've reached the final waypoint. 
-     * Returns true if we have.
-     */
-    bool checkFinished();
+    virtual void currentWaypointChanged();
     
 // tied getters and setters
     const char* getDepartureICAO() const;
     const char* getDepartureName() const;
     void setDepartureICAO(const char* aIdent);
     
+    const char* getDepartureRunway() const;
+    void setDepartureRunway(const char* aIdent);
+  
+    const char* getSID() const;
+    void setSID(const char* aIdent);
+  
     const char* getDestinationICAO() const;
     const char* getDestinationName() const;
     void setDestinationICAO(const char* aIdent);
-    
-public:
-
-    FGRouteMgr();
-    ~FGRouteMgr();
-
-    void init ();
-    void postinit ();
-    void bind ();
-    void unbind ();
-    void update (double dt);
-
-    bool build ();
-
-    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;
-    int size() const;
-        
-    bool isRouteActive() const;
-        
-    int currentWaypoint() const;
-       
-    /**
-     * Find a waypoint in the route, by position, and return its index, or
-     * -1 if no matching waypoint was found in the route.
-     */
-    int findWaypoint(const SGGeod& aPos) const;
-          
-    /**
-     * Activate a built route. This checks for various mandatory pieces of
-     * data, such as departure and destination airports, and creates waypoints
-     * for them on the route structure.
-     *
-     * returns true if the route was activated successfully, or false if the
-     * route could not be activated for some reason
-     */
-    bool activate();
 
-    /**
-     * Step to the next waypoint on the active route
-     */
-    void sequence();
-    
-    /**
-     *
-     */
-    void jumpToIndex(int index);
-    
-    /**
-     * 
-     */
-    void setWaypointTargetAltitudeFt(unsigned int index, int altFt);
-    
-    void saveRoute();
-    void loadRoute();
+    const char* getDestinationRunway() const;
+    void setDestinationRunway(const char* aIdent);
+  
+    const char* getApproach() const;
+    void setApproach(const char* aIdent);
+  
+    const char* getSTAR() const;
+    void setSTAR(const char* aIdent);
+  
+    double getDepartureFieldElevation() const;  
+    double getDestinationFieldElevation() const;  
 };