#include <plib/puAux.h>
-#include <simgear/route/waypoint.hxx>
#include <simgear/structure/callback.hxx>
#include <simgear/sg_inlines.h>
_fp(fp)
{
SGPropertyNode* routeEdited = fgGetNode("/autopilot/route-manager/signals/edited", true);
+ SGPropertyNode* flightplanChanged = fgGetNode("/autopilot/route-manager/signals/flightplan-changed", true);
routeEdited->addChangeListener(this);
+ flightplanChanged->addChangeListener(this);
}
~FlightPlanWaypointModel()
{
SGPropertyNode* routeEdited = fgGetNode("/autopilot/route-manager/signals/edited", true);
+ SGPropertyNode* flightplanChanged = fgGetNode("/autopilot/route-manager/signals/flightplan-changed", true);
routeEdited->removeChangeListener(this);
+ flightplanChanged->removeChangeListener(this);
}
// implement WaypointList::Model
--destIndex;
}
- unsigned int currentWpIndex = currentWaypoint();
- WayptRef w(waypointAt(currentWpIndex));
- _fp->deleteIndex(currentWpIndex);
+ int currentWpIndex = currentWaypoint();
- SG_LOG(SG_GENERAL, SG_INFO, "wpt:" << w->ident());
+ WayptRef w = _fp->legAtIndex(srcIndex)->waypoint();
+ _fp->deleteIndex(srcIndex);
_fp->insertWayptAtIndex(w, destIndex);
- if (srcIndex == currentWpIndex) {
+ if ((signed int) srcIndex == currentWpIndex) {
// current waypoint was moved
_fp->setCurrentIndex(destIndex);
}
// implement SGPropertyChangeListener
void valueChanged(SGPropertyNode *prop)
{
- if (_cb) {
- (*_cb)();
+ if (prop->getNameString() == "edited") {
+ if (_cb) {
+ (*_cb)();
+ }
+ }
+
+ if (prop->getNameString() == "flightplan-changed") {
+ _fp =
+ static_cast<FGRouteMgr*>(globals->get_subsystem("route-manager"))->flightPlan();
}
}
private:
if (wp->flag(WPT_MISS)) {
drawBox = true;
puSetColor(col, 1.0, 0.0, 0.0, 0.3); // red
- } else if (wp->flag(WPT_ARRIVAL)) {
+ } else if (wp->flag(WPT_ARRIVAL) || wp->flag(WPT_DEPARTURE)) {
drawBox = true;
puSetColor(col, 0.0, 0.0, 0.0, 0.3);
- } else if (wp->flag(WPT_DEPARTURE)) {
+ } else if (wp->flag(WPT_APPROACH)) {
drawBox = true;
- puSetColor(col, 0.0, 0.0, 0.0, 0.3);
+ puSetColor(col, 0.0, 0.0, 0.1, 0.3);
}
if (isDragSource) {