Route-manager: is expose is-route property for UI
This commit is contained in:
parent
78e6a209f1
commit
e08eee587d
3 changed files with 91 additions and 45 deletions
77
docs-mini/README-structure.md
Normal file
77
docs-mini/README-structure.md
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
# Strucutral Overview
|
||||||
|
|
||||||
|
## Foundation Components
|
||||||
|
|
||||||
|
|
||||||
|
There is a group os basic objects used widely throughout the codebase, which
|
||||||
|
are useful building blocks in all major simulation elements.
|
||||||
|
|
||||||
|
### Properties
|
||||||
|
|
||||||
|
Properties form a hierarchy of named, typed values. The hierarchy can be extended
|
||||||
|
and modified at runtime by aircraft, simulation components and external protocols.
|
||||||
|
|
||||||
|
### Listeners
|
||||||
|
|
||||||
|
Listeners are a callback interface `SGPropertyChangeListener` which can implemented
|
||||||
|
to receive notification when a property is modified, or its children added/removed.
|
||||||
|
Most commonly listeners are used to look for a user input or simulation event
|
||||||
|
changing some value (for example, a switch being turned from on to off), but it's
|
||||||
|
possible to monitor an entire sub-tree of properties.
|
||||||
|
|
||||||
|
It's important than listeners do not block or perform excessive amounts of work, since
|
||||||
|
the code modifying the property may not expect this. If non-trivial work needs to be
|
||||||
|
performed in response to a property changing, the listener should set a dirty flag
|
||||||
|
and a subsystem (etc) should check this in its `update()` method.
|
||||||
|
|
||||||
|
### Tied properties
|
||||||
|
|
||||||
|
Tied properties allow a property to be defined by a C++ memory location (such as a class
|
||||||
|
member variable) or by callback functions implementation the get/set operations. This
|
||||||
|
is very convenient for the implementating code. However, by default it has the
|
||||||
|
problematic side-effect that listeners do not correctly, since they have no way to be
|
||||||
|
notified thst the underlying value (or result of invoking the getter) has changed.
|
||||||
|
|
||||||
|
It is therefore critical, when using tied properties, to _manually_ invoke `fireValueChanged`
|
||||||
|
on dependent proeprties, when updating the internal state producing them. Care should be
|
||||||
|
taken to only fire the change, when the result of the getters would actually change; it is
|
||||||
|
_not_ acceptable to simply call `fireValueChanged` each iteration, since any connected
|
||||||
|
listener will be run at the simulation rate.
|
||||||
|
|
||||||
|
### Conditions
|
||||||
|
|
||||||
|
_Conditions_ are predicates which can be evaluated on demand. They can contain
|
||||||
|
logical operations such as 'and' and 'or', and comparisoms: for example checking that
|
||||||
|
a property is equal to a constant value, or that a property is less than another
|
||||||
|
property.
|
||||||
|
|
||||||
|
Conditions are widely used to drive other state from properties; for example
|
||||||
|
enabling or disabling user-interface in a dialog, or activating an autopilot
|
||||||
|
element.
|
||||||
|
|
||||||
|
### Bindings
|
||||||
|
|
||||||
|
_Bindings_ are a command invocation with associated arguments. In the simplest case
|
||||||
|
this might be invoking the `property-set` command with an argument of 42. At its
|
||||||
|
most complex, the command might invoke a Nasal script, supplied as part of the
|
||||||
|
binding, and substituing a runtime value into the Nasal logic.
|
||||||
|
|
||||||
|
Bindings are typically used in response to user actions, such as a menu item, key
|
||||||
|
press or interacting with a cockpit control, to update some part of the simulator
|
||||||
|
state.
|
||||||
|
|
||||||
|
## Structural Components
|
||||||
|
|
||||||
|
Most code within FlightGear is organized into subsystems. Subsystems are isolated from each other;
|
||||||
|
a well designed subsytem can be added, remove or restarting independently. Many subystems do not
|
||||||
|
full conform to these goals, especially regarding runtime adding and removal, but an increasing
|
||||||
|
number do support it.
|
||||||
|
|
||||||
|
=== Subsystems ===
|
||||||
|
|
||||||
|
=== Commands ===
|
||||||
|
|
||||||
|
|
||||||
|
## Finding data files
|
||||||
|
|
||||||
|
## Subsysterm Lifecycle
|
|
@ -1,26 +1,8 @@
|
||||||
// route_mgr.cxx - manage a route (i.e. a collection of waypoints)
|
// route_mgr.cxx - manage a route (i.e. a collection of waypoints)
|
||||||
//
|
/*
|
||||||
// Written by Curtis Olson, started January 2004.
|
* SPDX-FileCopyrightText: (C) 2004 Curtis L. Olson http://www.flightgear.org/~curt
|
||||||
// Norman Vine
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
// Melchior FRANZ
|
*/
|
||||||
//
|
|
||||||
// Copyright (C) 2004 Curtis L. Olson - http://www.flightgear.org/~curt
|
|
||||||
//
|
|
||||||
// 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
|
|
||||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
//
|
|
||||||
// $Id$
|
|
||||||
|
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
@ -372,7 +354,8 @@ void FGRouteMgr::init() {
|
||||||
|
|
||||||
_edited = fgGetNode(RM "signals/edited", true);
|
_edited = fgGetNode(RM "signals/edited", true);
|
||||||
_flightplanChanged = fgGetNode(RM "signals/flightplan-changed", true);
|
_flightplanChanged = fgGetNode(RM "signals/flightplan-changed", true);
|
||||||
|
_isRoute = fgGetNode(RM "is-route", true);
|
||||||
|
|
||||||
_currentWpt = fgGetNode(RM "current-wp", true);
|
_currentWpt = fgGetNode(RM "current-wp", true);
|
||||||
_currentWpt->setAttribute(SGPropertyNode::LISTENER_SAFE, true);
|
_currentWpt->setAttribute(SGPropertyNode::LISTENER_SAFE, true);
|
||||||
_currentWpt->tie(SGRawValueMethods<FGRouteMgr, int>
|
_currentWpt->tie(SGRawValueMethods<FGRouteMgr, int>
|
||||||
|
@ -411,6 +394,8 @@ void FGRouteMgr::postinit()
|
||||||
loadRoute(path);
|
loadRoute(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_isRoute->setBoolValue(_plan->isRoute());
|
||||||
|
|
||||||
// this code only matters for the --wp option now - perhaps the option
|
// this code only matters for the --wp option now - perhaps the option
|
||||||
// should be deprecated in favour of an explicit flight-plan file?
|
// should be deprecated in favour of an explicit flight-plan file?
|
||||||
// then the global initial waypoint list could die.
|
// then the global initial waypoint list could die.
|
||||||
|
@ -486,7 +471,7 @@ void FGRouteMgr::setFlightPlan(const FlightPlanRef& plan)
|
||||||
|
|
||||||
_plan = plan;
|
_plan = plan;
|
||||||
_plan->addDelegate(this);
|
_plan->addDelegate(this);
|
||||||
|
_isRoute->setBoolValue(_plan->isRoute());
|
||||||
_flightplanChanged->fireValueChanged();
|
_flightplanChanged->fireValueChanged();
|
||||||
|
|
||||||
// fire all the callbacks!
|
// fire all the callbacks!
|
||||||
|
|
|
@ -1,24 +1,8 @@
|
||||||
// route_mgr.hxx - manage a route (i.e. a collection of waypoints)
|
// route_mgr.hxx - manage a route (i.e. a collection of waypoints)
|
||||||
//
|
/*
|
||||||
// Written by Curtis Olson, started January 2004.
|
* SPDX-FileCopyrightText: (C) 2004 Curtis L. Olson http://www.flightgear.org/~curt
|
||||||
//
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
// Copyright (C) 2004 Curtis L. Olson - http://www.flightgear.org/~curt
|
*/
|
||||||
//
|
|
||||||
// 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
|
|
||||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
//
|
|
||||||
// $Id$
|
|
||||||
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
@ -144,7 +128,7 @@ private:
|
||||||
|
|
||||||
SGPropertyNode_ptr _pathNode;
|
SGPropertyNode_ptr _pathNode;
|
||||||
SGPropertyNode_ptr _currentWpt;
|
SGPropertyNode_ptr _currentWpt;
|
||||||
|
SGPropertyNode_ptr _isRoute;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Signal property to notify people that the route was edited
|
* Signal property to notify people that the route was edited
|
||||||
|
|
Loading…
Reference in a new issue