1 // route_mgr.hxx - manage a route (i.e. a collection of waypoints)
3 // Written by Curtis Olson, started January 2004.
5 // Copyright (C) 2004 Curtis L. Olson - http://www.flightgear.org/~curt
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24 #ifndef _ROUTE_MGR_HXX
25 #define _ROUTE_MGR_HXX 1
27 #include <simgear/props/props.hxx>
28 #include <simgear/route/route.hxx>
29 #include <simgear/structure/subsystem_mgr.hxx>
33 * Top level route manager class
37 class FGRouteMgr : public SGSubsystem
45 SGPropertyNode_ptr lon;
46 SGPropertyNode_ptr lat;
47 SGPropertyNode_ptr alt;
50 SGPropertyNode_ptr true_hdg_deg;
51 SGPropertyNode_ptr target_altitude_ft;
52 SGPropertyNode_ptr altitude_lock;
54 SGPropertyNode_ptr wp0_id;
55 SGPropertyNode_ptr wp0_dist;
56 SGPropertyNode_ptr wp0_eta;
58 SGPropertyNode_ptr wp1_id;
59 SGPropertyNode_ptr wp1_dist;
60 SGPropertyNode_ptr wp1_eta;
62 SGPropertyNode_ptr wpn_id;
63 SGPropertyNode_ptr wpn_dist;
64 SGPropertyNode_ptr wpn_eta;
67 class Listener : public SGPropertyChangeListener {
69 Listener(FGRouteMgr *m) : mgr(m) {}
70 virtual void valueChanged (SGPropertyNode * prop);
75 SGPropertyNode_ptr input;
77 SGPropertyNode_ptr mirror;
80 SGWayPoint* make_waypoint(const string& target);
85 * Helper to set a string property to the estimated arrival time (ETA),
86 * formatted as either hours:minutes or minutes:seconds, based on a distance
87 * and the current groundspeed.
89 void setETAPropertyFromDistance(SGPropertyNode_ptr aProp, double aDistance);
92 * Helper to update the target_altitude_ft and altitude_set flag when wp0
95 void updateTargetAltitude();
105 void update (double dt);
109 void new_waypoint( const string& tgt_alt, int n = -1 );
110 void add_waypoint( const SGWayPoint& wp, int n = -1 );
111 SGWayPoint pop_waypoint( int i = 0 );
113 SGWayPoint get_waypoint( int i ) const {
114 return route->get_waypoint(i);
118 return route->size();
124 #endif // _ROUTE_MGR_HXX