2004-01-31 19:47:45 +00:00
|
|
|
// route_mgr.hxx - manage a route (i.e. a collection of waypoints)
|
|
|
|
//
|
|
|
|
// Written by Curtis Olson, started January 2004.
|
|
|
|
//
|
2004-11-19 22:10:41 +00:00
|
|
|
// Copyright (C) 2004 Curtis L. Olson - http://www.flightgear.org/~curt
|
2004-01-31 19:47:45 +00:00
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License as
|
|
|
|
// published by the Free Software Foundation; either version 2 of the
|
|
|
|
// License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful, but
|
|
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program; if not, write to the Free Software
|
2006-02-21 01:16:04 +00:00
|
|
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2004-01-31 19:47:45 +00:00
|
|
|
//
|
|
|
|
// $Id$
|
|
|
|
|
|
|
|
|
|
|
|
#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>
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Top level route manager class
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
class FGRouteMgr : public SGSubsystem
|
|
|
|
{
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
SGRoute *route;
|
|
|
|
|
|
|
|
// automatic inputs
|
2006-04-27 15:49:47 +00:00
|
|
|
SGPropertyNode_ptr lon;
|
|
|
|
SGPropertyNode_ptr lat;
|
|
|
|
SGPropertyNode_ptr alt;
|
2004-01-31 19:47:45 +00:00
|
|
|
|
|
|
|
// automatic outputs
|
2006-04-27 15:49:47 +00:00
|
|
|
SGPropertyNode_ptr true_hdg_deg;
|
2006-05-09 21:01:01 +00:00
|
|
|
SGPropertyNode_ptr target_altitude_ft;
|
|
|
|
SGPropertyNode_ptr altitude_lock;
|
2004-01-31 19:47:45 +00:00
|
|
|
|
2006-04-27 15:49:47 +00:00
|
|
|
SGPropertyNode_ptr wp0_id;
|
|
|
|
SGPropertyNode_ptr wp0_dist;
|
|
|
|
SGPropertyNode_ptr wp0_eta;
|
2004-01-31 19:47:45 +00:00
|
|
|
|
2006-04-27 15:49:47 +00:00
|
|
|
SGPropertyNode_ptr wp1_id;
|
|
|
|
SGPropertyNode_ptr wp1_dist;
|
|
|
|
SGPropertyNode_ptr wp1_eta;
|
2004-01-31 19:47:45 +00:00
|
|
|
|
2006-04-27 15:49:47 +00:00
|
|
|
SGPropertyNode_ptr wpn_id;
|
|
|
|
SGPropertyNode_ptr wpn_dist;
|
|
|
|
SGPropertyNode_ptr wpn_eta;
|
2004-01-31 19:47:45 +00:00
|
|
|
|
|
|
|
|
2006-05-08 14:35:29 +00:00
|
|
|
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;
|
2006-05-09 21:01:01 +00:00
|
|
|
bool altitude_set;
|
|
|
|
|
2006-05-12 15:37:25 +00:00
|
|
|
int make_waypoint( SGWayPoint **wp, const string& target );
|
2006-05-09 21:01:01 +00:00
|
|
|
void update_mirror();
|
2006-05-12 09:36:21 +00:00
|
|
|
bool near_ground();
|
2006-05-08 14:35:29 +00:00
|
|
|
|
2004-01-31 19:47:45 +00:00
|
|
|
public:
|
|
|
|
|
|
|
|
FGRouteMgr();
|
|
|
|
~FGRouteMgr();
|
|
|
|
|
|
|
|
void init ();
|
2006-04-27 15:30:42 +00:00
|
|
|
void postinit ();
|
2004-01-31 19:47:45 +00:00
|
|
|
void bind ();
|
|
|
|
void unbind ();
|
|
|
|
void update (double dt);
|
|
|
|
|
|
|
|
bool build ();
|
|
|
|
|
2006-05-08 14:35:29 +00:00
|
|
|
int new_waypoint( const string& tgt_alt, int n = -1 );
|
|
|
|
void add_waypoint( const SGWayPoint& wp, int n = -1 );
|
|
|
|
SGWayPoint pop_waypoint( int i = 0 );
|
2004-01-31 19:47:45 +00:00
|
|
|
|
|
|
|
SGWayPoint get_waypoint( int i ) const {
|
|
|
|
return route->get_waypoint(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
int size() const {
|
|
|
|
return route->size();
|
|
|
|
}
|
2006-05-08 14:35:29 +00:00
|
|
|
|
2004-01-31 19:47:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // _ROUTE_MGR_HXX
|