Replace BOOST_FOREACH by C++ 11 for range loop.
This commit is contained in:
parent
36f8036ce1
commit
fb65f64342
28 changed files with 495 additions and 544 deletions
|
@ -4,8 +4,6 @@
|
|||
|
||||
#include "performancedb.hxx"
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
#include <simgear/sg_inlines.h>
|
||||
#include <simgear/misc/sg_path.hxx>
|
||||
#include <simgear/props/props.hxx>
|
||||
|
@ -13,6 +11,7 @@
|
|||
#include <simgear/structure/exception.hxx>
|
||||
|
||||
#include <Main/globals.hxx>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
|
@ -73,7 +72,7 @@ PerformanceData* PerformanceDB::getDataFor(const string& acType, const string& a
|
|||
if (it != _db.end()) {
|
||||
return it->second;
|
||||
}
|
||||
|
||||
|
||||
const string& alias = findAlias(acType);
|
||||
it = _db.find(alias);
|
||||
if (it != _db.end()) {
|
||||
|
@ -131,13 +130,13 @@ void PerformanceDB::load(const SGPath& filename)
|
|||
"Error reading AI aircraft performance database: unknown base type " << baseName);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// clone base data to 'inherit' from it
|
||||
data = new PerformanceData(baseData);
|
||||
data = new PerformanceData(baseData);
|
||||
} else {
|
||||
data = new PerformanceData;
|
||||
}
|
||||
|
||||
|
||||
data->initFromProps(db_node);
|
||||
const string& name = db_node->getStringValue("type", "heavy_jet");
|
||||
registerPerformanceData(name, data);
|
||||
|
@ -147,8 +146,8 @@ void PerformanceDB::load(const SGPath& filename)
|
|||
SG_LOG(SG_AI, SG_ALERT, "performance DB alias entry with no <alias> definition");
|
||||
continue;
|
||||
}
|
||||
|
||||
BOOST_FOREACH(SGPropertyNode* matchNode, db_node->getChildren("match")) {
|
||||
|
||||
for (auto matchNode : db_node->getChildren("match")) {
|
||||
const string& match(matchNode->getStringValue());
|
||||
_aliases.push_back(StringPair(match, alias));
|
||||
}
|
||||
|
@ -160,12 +159,12 @@ void PerformanceDB::load(const SGPath& filename)
|
|||
|
||||
const string& PerformanceDB::findAlias(const string& acType) const
|
||||
{
|
||||
BOOST_FOREACH(const StringPair& alias, _aliases) {
|
||||
for (const auto& alias : _aliases) {
|
||||
if (acType.find(alias.first) == 0) { // matched!
|
||||
return alias.second;
|
||||
}
|
||||
} // of alias iteration
|
||||
|
||||
|
||||
static const string empty;
|
||||
return empty;
|
||||
}
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
#include <algorithm>
|
||||
#include <fstream>
|
||||
#include <map>
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
#include <osg/Geode>
|
||||
#include <osg/Geometry>
|
||||
|
@ -137,9 +136,9 @@ void FGGroundController::announcePosition(int id,
|
|||
if (leg == 2) {
|
||||
activeTraffic.push_front(rec);
|
||||
} else {
|
||||
activeTraffic.push_back(rec);
|
||||
activeTraffic.push_back(rec);
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
i->setPositionAndIntentions(currentPosition, intendedRoute);
|
||||
i->setPositionAndHeading(lat, lon, heading, speed, alt);
|
||||
|
@ -355,7 +354,7 @@ void FGGroundController::checkSpeedAdjustment(int id, double lat,
|
|||
closest = i;
|
||||
closestOnNetwork = i;
|
||||
// minbearing = bearing;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
//Check traffic at the tower controller
|
||||
|
@ -417,7 +416,7 @@ void FGGroundController::checkSpeedAdjustment(int id, double lat,
|
|||
current->setSpeedAdjustment(closest->getSpeed() *
|
||||
(mindist / 100));
|
||||
needBraking = true;
|
||||
|
||||
|
||||
// if (
|
||||
// closest->getAircraft()->getTakeOffStatus() &&
|
||||
// (current->getAircraft()->getTrafficRef()->getDepartureAirport() == closest->getAircraft()->getTrafficRef()->getDepartureAirport()) &&
|
||||
|
@ -476,7 +475,7 @@ void FGGroundController::checkHoldPosition(int id, double lat,
|
|||
"AI error: Trying to access non-existing aircraft in FGGroundNetwork::checkHoldPosition at " << SG_ORIGIN);
|
||||
}
|
||||
current = i;
|
||||
//
|
||||
//
|
||||
if (current->getAircraft()->getTakeOffStatus() == 1) {
|
||||
current->setHoldPosition(true);
|
||||
return;
|
||||
|
@ -496,7 +495,7 @@ void FGGroundController::checkHoldPosition(int id, double lat,
|
|||
nextRoute = (*(i->getIntentions().begin()));
|
||||
} else {
|
||||
nextRoute = 0;
|
||||
}
|
||||
}
|
||||
if (currentRoute > 0) {
|
||||
FGTaxiSegment *tx = network->findSegment(currentRoute);
|
||||
FGTaxiSegment *nx;
|
||||
|
@ -527,7 +526,7 @@ void FGGroundController::checkHoldPosition(int id, double lat,
|
|||
}
|
||||
ivi++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
bool currStatus = current->hasHoldPosition();
|
||||
current->setHoldPosition(origStatus);
|
||||
|
@ -788,7 +787,7 @@ void FGGroundController::render(bool visible)
|
|||
|
||||
for (TrafficVectorIterator i = activeTraffic.begin(); i != activeTraffic.end(); i++) {
|
||||
// Handle start point i.e. the segment that is connected to the aircraft itself on the starting end
|
||||
// and to the the first "real" taxi segment on the other end.
|
||||
// and to the the first "real" taxi segment on the other end.
|
||||
const int pos = i->getCurrentPosition();
|
||||
if (pos > 0) {
|
||||
FGTaxiSegment* segment = network->findSegment(pos);
|
||||
|
@ -869,7 +868,7 @@ void FGGroundController::render(bool visible)
|
|||
} else {
|
||||
//std::cerr << "BIG FAT WARNING: current position is here : " << pos << std::endl;
|
||||
}
|
||||
// Next: Draw the other taxi segments.
|
||||
// Next: Draw the other taxi segments.
|
||||
for (intVecIterator j = (i)->getIntentions().begin(); j != (i)->getIntentions().end(); j++) {
|
||||
osg::Matrix obj_pos;
|
||||
const int k = (*j);
|
||||
|
|
|
@ -24,8 +24,6 @@
|
|||
|
||||
#include "atcdialog.hxx"
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
#include <simgear/constants.h>
|
||||
#include <simgear/structure/commands.hxx>
|
||||
#include <simgear/compiler.h>
|
||||
|
@ -265,7 +263,7 @@ void FGATCDialogNew::update(double dt) {
|
|||
char buf[bufsize];
|
||||
int commandNr = 0;
|
||||
// loop over all entries that should fill up the dialog; use 10 items for now...
|
||||
BOOST_FOREACH(const std::string& i, commands) {
|
||||
for (const auto& i : commands) {
|
||||
snprintf(buf, bufsize, "/sim/atc/opt[%d]", commandNr);
|
||||
fgSetBool(buf, false);
|
||||
SGPropertyNode *entry = button_group->getNode("button", commandNr, true);
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
#include "FlightHistory.hxx"
|
||||
|
||||
#include <algorithm>
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
#include <simgear/sg_inlines.h>
|
||||
#include <simgear/debug/logstream.hxx>
|
||||
|
@ -58,7 +57,7 @@ void FGFlightHistory::init()
|
|||
<< ", defaulting to " << m_sampleInterval);
|
||||
m_sampleInterval = 1.0;
|
||||
}
|
||||
|
||||
|
||||
// cap memory use at 4MB
|
||||
m_maxMemoryUseBytes = fgGetInt("/sim/history/max-memory-use-bytes", 1024 * 1024 * 4);
|
||||
m_weightOnWheels = NULL;
|
||||
|
@ -67,7 +66,7 @@ void FGFlightHistory::init()
|
|||
m_weightOnWheels = fgGetNode("/gear/gear[1]/wow", 0, true);
|
||||
m_lastWoW = m_weightOnWheels->getBoolValue();
|
||||
}
|
||||
|
||||
|
||||
// force bucket re-allocation
|
||||
m_validSampleCount = SAMPLE_BUCKET_WIDTH;
|
||||
m_lastCaptureTime = globals->get_sim_time_sec();
|
||||
|
@ -89,15 +88,15 @@ void FGFlightHistory::update(double dt)
|
|||
if ((dt == 0.0) || !m_enabled->getBoolValue()) {
|
||||
return; // paused or disabled
|
||||
}
|
||||
|
||||
|
||||
if (m_weightOnWheels) {
|
||||
|
||||
|
||||
if (m_lastWoW && !m_weightOnWheels->getBoolValue()) {
|
||||
SG_LOG(SG_FLIGHT, SG_INFO, "history: detected main-gear takeoff, clearing history");
|
||||
clear();
|
||||
}
|
||||
} // of rest-on-takeoff enabled
|
||||
|
||||
|
||||
// spatial check - moved at least 1m since last capture
|
||||
if (!m_buckets.empty()) {
|
||||
SGVec3d lastCaptureCart(SGVec3d::fromGeod(m_buckets.back()->samples[m_validSampleCount - 1].position));
|
||||
|
@ -106,7 +105,7 @@ void FGFlightHistory::update(double dt)
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
double elapsed = globals->get_sim_time_sec() - m_lastCaptureTime;
|
||||
if (elapsed > m_sampleInterval) {
|
||||
capture();
|
||||
|
@ -122,7 +121,7 @@ void FGFlightHistory::allocateNewBucket()
|
|||
} else {
|
||||
bucket = new SampleBucket;
|
||||
}
|
||||
|
||||
|
||||
m_buckets.push_back(bucket);
|
||||
m_validSampleCount = 0;
|
||||
}
|
||||
|
@ -133,19 +132,19 @@ void FGFlightHistory::capture()
|
|||
// bucket is full, allocate a new one
|
||||
allocateNewBucket();
|
||||
}
|
||||
|
||||
|
||||
m_lastCaptureTime = globals->get_sim_time_sec();
|
||||
Sample* sample = m_buckets.back()->samples + m_validSampleCount;
|
||||
|
||||
|
||||
sample->simTimeMSec = static_cast<size_t>(m_lastCaptureTime * 1000.0);
|
||||
sample->position = globals->get_aircraft_position();
|
||||
|
||||
|
||||
double heading, pitch, roll;
|
||||
globals->get_aircraft_orientation(heading, pitch, roll);
|
||||
sample->heading = static_cast<float>(heading);
|
||||
sample->pitch = static_cast<float>(pitch);
|
||||
sample->roll = static_cast<float>(roll);
|
||||
|
||||
|
||||
++m_validSampleCount;
|
||||
}
|
||||
|
||||
|
@ -156,7 +155,7 @@ PagedPathForHistory_ptr FGFlightHistory::pagedPathForHistory(size_t max_entries,
|
|||
return result;
|
||||
}
|
||||
|
||||
BOOST_FOREACH(SampleBucket* bucket, m_buckets) {
|
||||
for (auto bucket : m_buckets) {
|
||||
unsigned int count = (bucket == m_buckets.back() ? m_validSampleCount : SAMPLE_BUCKET_WIDTH);
|
||||
|
||||
// iterate over all the valid samples in the bucket
|
||||
|
@ -189,14 +188,14 @@ SGGeodVec FGFlightHistory::pathForHistory(double minEdgeLengthM) const
|
|||
if (m_buckets.empty()) {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
result.push_back(m_buckets.front()->samples[0].position);
|
||||
SGVec3d lastOutputCart = SGVec3d::fromGeod(result.back());
|
||||
double minLengthSqr = minEdgeLengthM * minEdgeLengthM;
|
||||
|
||||
BOOST_FOREACH(SampleBucket* bucket, m_buckets) {
|
||||
|
||||
for (auto bucket : m_buckets) {
|
||||
unsigned int count = (bucket == m_buckets.back() ? m_validSampleCount : SAMPLE_BUCKET_WIDTH);
|
||||
|
||||
|
||||
// iterate over all the valid samples in the bucket
|
||||
for (unsigned int index = 0; index < count; ++index) {
|
||||
SGGeod g = bucket->samples[index].position;
|
||||
|
@ -207,13 +206,13 @@ SGGeodVec FGFlightHistory::pathForHistory(double minEdgeLengthM) const
|
|||
}
|
||||
} // of samples iteration
|
||||
} // of buckets iteration
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void FGFlightHistory::clear()
|
||||
{
|
||||
BOOST_FOREACH(SampleBucket* ptr, m_buckets) {
|
||||
for (auto ptr : m_buckets) {
|
||||
delete ptr;
|
||||
}
|
||||
m_buckets.clear();
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
#include <simgear/misc/sg_path.hxx>
|
||||
#include <simgear/props/props.hxx>
|
||||
|
@ -143,8 +142,7 @@ FGRunwayMap FGAirport::getRunwayMap() const
|
|||
|
||||
double minLengthFt = fgGetDouble("/sim/navdb/min-runway-length-ft");
|
||||
|
||||
BOOST_FOREACH(FGRunwayRef rwy, mRunways)
|
||||
{
|
||||
for (auto rwy : mRunways) {
|
||||
// ignore unusably short runways
|
||||
// TODO other methods don't check this...
|
||||
if( rwy->lengthFt() >= minLengthFt )
|
||||
|
@ -160,8 +158,7 @@ FGHelipadMap FGAirport::getHelipadMap() const
|
|||
loadHelipads();
|
||||
FGHelipadMap map;
|
||||
|
||||
BOOST_FOREACH(PositionedID id, mHelipads)
|
||||
{
|
||||
for (auto id : mHelipads) {
|
||||
FGHelipad* rwy = loadById<FGHelipad>(id);
|
||||
map[ rwy->ident() ] = rwy;
|
||||
}
|
||||
|
@ -173,7 +170,7 @@ FGHelipadMap FGAirport::getHelipadMap() const
|
|||
bool FGAirport::hasRunwayWithIdent(const std::string& aIdent) const
|
||||
{
|
||||
loadRunways();
|
||||
BOOST_FOREACH(FGRunwayRef rwy, mRunways) {
|
||||
for (auto rwy : mRunways) {
|
||||
if (rwy->ident() == aIdent) {
|
||||
return true;
|
||||
}
|
||||
|
@ -193,12 +190,12 @@ bool FGAirport::hasHelipadWithIdent(const std::string& aIdent) const
|
|||
FGRunwayRef FGAirport::getRunwayByIdent(const std::string& aIdent) const
|
||||
{
|
||||
loadRunways();
|
||||
BOOST_FOREACH(FGRunwayRef rwy, mRunways) {
|
||||
for (auto rwy : mRunways) {
|
||||
if (rwy->ident() == aIdent) {
|
||||
return rwy;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SG_LOG(SG_GENERAL, SG_ALERT, "no such runway '" << aIdent << "' at airport " << ident());
|
||||
throw sg_range_exception("unknown runway " + aIdent + " at airport:" + ident(), "FGAirport::getRunwayByIdent");
|
||||
}
|
||||
|
@ -219,10 +216,10 @@ FGHelipadRef FGAirport::getHelipadByIdent(const std::string& aIdent) const
|
|||
FGRunwayRef FGAirport::findBestRunwayForHeading(double aHeading, struct FindBestRunwayForHeadingParams * parms ) const
|
||||
{
|
||||
loadRunways();
|
||||
|
||||
|
||||
FGRunway* result = NULL;
|
||||
double currentBestQuality = 0.0;
|
||||
|
||||
|
||||
struct FindBestRunwayForHeadingParams fbrfhp;
|
||||
if( NULL != parms ) fbrfhp = *parms;
|
||||
|
||||
|
@ -234,14 +231,14 @@ FGRunwayRef FGAirport::findBestRunwayForHeading(double aHeading, struct FindBest
|
|||
fbrfhp.deviationWeight = searchNode->getDoubleValue("deviation-weight", fbrfhp.deviationWeight );
|
||||
fbrfhp.ilsWeight = searchNode->getDoubleValue("ils-weight", fbrfhp.ilsWeight );
|
||||
}
|
||||
|
||||
BOOST_FOREACH(FGRunwayRef rwy, mRunways) {
|
||||
|
||||
for (auto rwy : mRunways) {
|
||||
double good = rwy->score( fbrfhp.lengthWeight, fbrfhp.widthWeight, fbrfhp.surfaceWeight, fbrfhp.ilsWeight );
|
||||
double dev = aHeading - rwy->headingDeg();
|
||||
SG_NORMALIZE_RANGE(dev, -180.0, 180.0);
|
||||
double bad = fabs( fbrfhp.deviationWeight * dev) + 1e-20;
|
||||
double quality = good / bad;
|
||||
|
||||
|
||||
if (quality > currentBestQuality) {
|
||||
currentBestQuality = quality;
|
||||
result = rwy;
|
||||
|
@ -255,11 +252,11 @@ FGRunwayRef FGAirport::findBestRunwayForHeading(double aHeading, struct FindBest
|
|||
FGRunwayRef FGAirport::findBestRunwayForPos(const SGGeod& aPos) const
|
||||
{
|
||||
loadRunways();
|
||||
|
||||
|
||||
FGRunway* result = NULL;
|
||||
double currentLowestDev = 180.0;
|
||||
|
||||
BOOST_FOREACH(FGRunwayRef rwy, mRunways) {
|
||||
|
||||
for (auto rwy : mRunways) {
|
||||
double inboundCourse = SGGeodesy::courseDeg(aPos, rwy->end());
|
||||
double dev = inboundCourse - rwy->headingDeg();
|
||||
SG_NORMALIZE_RANGE(dev, -180.0, 180.0);
|
||||
|
@ -270,7 +267,7 @@ FGRunwayRef FGAirport::findBestRunwayForPos(const SGGeod& aPos) const
|
|||
result = rwy;
|
||||
}
|
||||
} // of runway iteration
|
||||
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
@ -279,8 +276,8 @@ FGRunwayRef FGAirport::findBestRunwayForPos(const SGGeod& aPos) const
|
|||
bool FGAirport::hasHardRunwayOfLengthFt(double aLengthFt) const
|
||||
{
|
||||
loadRunways();
|
||||
|
||||
BOOST_FOREACH(FGRunwayRef rwy, mRunways) {
|
||||
|
||||
for (auto rwy : mRunways) {
|
||||
if (rwy->isHardSurface() && (rwy->lengthFt() >= aLengthFt)) {
|
||||
return true; // we're done!
|
||||
}
|
||||
|
@ -294,7 +291,7 @@ FGRunwayRef FGAirport::longestRunway() const
|
|||
FGRunwayRef r;
|
||||
loadRunways();
|
||||
|
||||
BOOST_FOREACH(FGRunwayRef rwy, mRunways) {
|
||||
for (auto rwy : mRunways) {
|
||||
if (!r || (r->lengthFt() < rwy->lengthFt())) {
|
||||
r = rwy;
|
||||
}
|
||||
|
@ -315,10 +312,10 @@ FGRunwayList FGAirport::getRunways() const
|
|||
FGRunwayList FGAirport::getRunwaysWithoutReciprocals() const
|
||||
{
|
||||
loadRunways();
|
||||
|
||||
|
||||
FGRunwayList r;
|
||||
|
||||
BOOST_FOREACH(FGRunwayRef rwy, mRunways) {
|
||||
|
||||
for (auto rwy : mRunways) {
|
||||
FGRunway* recip = rwy->reciprocalRunway();
|
||||
if (recip) {
|
||||
FGRunwayList::iterator it = std::find(r.begin(), r.end(), recip);
|
||||
|
@ -326,10 +323,10 @@ FGRunwayList FGAirport::getRunwaysWithoutReciprocals() const
|
|||
continue; // reciprocal already in result set, don't include us
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
r.push_back(rwy);
|
||||
}
|
||||
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
|
@ -379,20 +376,20 @@ FGPavementList FGAirport::getPavements() const
|
|||
FGRunwayRef FGAirport::getActiveRunwayForUsage() const
|
||||
{
|
||||
FGEnvironmentMgr* envMgr = (FGEnvironmentMgr *) globals->get_subsystem("environment");
|
||||
|
||||
|
||||
// This forces West-facing rwys to be used in no-wind situations
|
||||
// which is consistent with Flightgear's initial setup.
|
||||
double hdg = 270;
|
||||
|
||||
|
||||
if (envMgr) {
|
||||
FGEnvironment stationWeather(envMgr->getEnvironment(geod()));
|
||||
|
||||
|
||||
double windSpeed = stationWeather.get_wind_speed_kt();
|
||||
if (windSpeed > 0.0) {
|
||||
hdg = stationWeather.get_wind_from_heading_deg();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return findBestRunwayForHeading(hdg);
|
||||
}
|
||||
|
||||
|
@ -404,7 +401,7 @@ FGAirportRef FGAirport::findClosest( const SGGeod& aPos,
|
|||
AirportFilter aptFilter;
|
||||
if( !filter )
|
||||
filter = &aptFilter;
|
||||
|
||||
|
||||
return static_pointer_cast<FGAirport>
|
||||
(
|
||||
FGPositioned::findClosest(aPos, aCuttofNm, filter)
|
||||
|
@ -495,7 +492,7 @@ const FGAirport *fgFindAirportID( const std::string& id)
|
|||
if ( id.empty() ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
return FGAirport::findByIdent(id);
|
||||
}
|
||||
|
||||
|
@ -510,12 +507,12 @@ void FGAirport::loadRunways() const
|
|||
if (mRunwaysLoaded) {
|
||||
return; // already loaded, great
|
||||
}
|
||||
|
||||
|
||||
loadSceneryDefinitions();
|
||||
|
||||
|
||||
mRunwaysLoaded = true;
|
||||
PositionedIDVec rwys(itemsOfType(FGPositioned::RUNWAY));
|
||||
BOOST_FOREACH(PositionedID id, rwys) {
|
||||
for (auto id : rwys) {
|
||||
mRunways.push_back(loadById<FGRunway>(id));
|
||||
}
|
||||
}
|
||||
|
@ -535,7 +532,7 @@ void FGAirport::loadTaxiways() const
|
|||
if (mTaxiwaysLoaded) {
|
||||
return; // already loaded, great
|
||||
}
|
||||
|
||||
|
||||
mTaxiwaysLoaded = true;
|
||||
mTaxiways = itemsOfType(FGPositioned::TAXIWAY);
|
||||
}
|
||||
|
@ -545,14 +542,14 @@ void FGAirport::loadProcedures() const
|
|||
if (mProceduresLoaded) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
mProceduresLoaded = true;
|
||||
SGPath path;
|
||||
if (!XMLLoader::findAirportData(ident(), "procedures", path)) {
|
||||
SG_LOG(SG_GENERAL, SG_INFO, "no procedures data available for " << ident());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
SG_LOG(SG_GENERAL, SG_INFO, ident() << ": loading procedures from " << path);
|
||||
RouteBase::loadAirportProcedures(path, const_cast<FGAirport*>(this));
|
||||
}
|
||||
|
@ -562,14 +559,14 @@ void FGAirport::loadSceneryDefinitions() const
|
|||
if (mThresholdDataLoaded) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
mThresholdDataLoaded = true;
|
||||
|
||||
|
||||
SGPath path;
|
||||
if (!XMLLoader::findAirportData(ident(), "threshold", path)) {
|
||||
return; // no XML threshold data
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
SGPropertyNode_ptr rootNode = new SGPropertyNode;
|
||||
readProperties(path, rootNode);
|
||||
|
@ -588,7 +585,7 @@ void FGAirport::readThresholdData(SGPropertyNode* aRoot)
|
|||
*t1 = runway->getChild("threshold", 1);
|
||||
assert(t0);
|
||||
assert(t1); // too strict? maybe we should finally allow single-ended runways
|
||||
|
||||
|
||||
processThreshold(t0);
|
||||
processThreshold(t1);
|
||||
} // of runways iteration
|
||||
|
@ -598,17 +595,17 @@ void FGAirport::processThreshold(SGPropertyNode* aThreshold)
|
|||
{
|
||||
// first, let's identify the current runway
|
||||
std::string rwyIdent(aThreshold->getStringValue("rwy"));
|
||||
NavDataCache* cache = NavDataCache::instance();
|
||||
NavDataCache* cache = NavDataCache::instance();
|
||||
PositionedID id = cache->airportItemWithIdent(guid(), FGPositioned::RUNWAY, rwyIdent);
|
||||
|
||||
|
||||
double lon = aThreshold->getDoubleValue("lon"),
|
||||
lat = aThreshold->getDoubleValue("lat");
|
||||
SGGeod newThreshold(SGGeod::fromDegM(lon, lat, elevationM()));
|
||||
|
||||
|
||||
double newHeading = aThreshold->getDoubleValue("hdg-deg");
|
||||
double newDisplacedThreshold = aThreshold->getDoubleValue("displ-m");
|
||||
double newStopway = aThreshold->getDoubleValue("stopw-m");
|
||||
|
||||
|
||||
if (id == 0) {
|
||||
SG_LOG(SG_GENERAL, SG_DEBUG, "FGAirport::processThreshold: "
|
||||
"found runway not defined in the global data:" << ident() << "/" << rwyIdent);
|
||||
|
@ -645,7 +642,7 @@ void FGAirport::validateTowerData() const
|
|||
if (mTowerDataLoaded) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
mTowerDataLoaded = true;
|
||||
|
||||
// first, load data from the cache (apt.dat)
|
||||
|
@ -672,12 +669,12 @@ void FGAirport::validateTowerData() const
|
|||
mTowerPosition = tower->geod();
|
||||
mHasTower = true;
|
||||
}
|
||||
|
||||
|
||||
SGPath path;
|
||||
if (!XMLLoader::findAirportData(ident(), "twr", path)) {
|
||||
return; // no XML tower data, base position is fine
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
SGPropertyNode_ptr rootNode = new SGPropertyNode;
|
||||
readProperties(path, rootNode);
|
||||
|
@ -691,9 +688,9 @@ void FGAirport::validateTowerData() const
|
|||
void FGAirport::readTowerData(SGPropertyNode* aRoot)
|
||||
{
|
||||
SGPropertyNode* twrNode = aRoot->getChild("tower")->getChild("twr");
|
||||
double lat = twrNode->getDoubleValue("lat"),
|
||||
lon = twrNode->getDoubleValue("lon"),
|
||||
elevM = twrNode->getDoubleValue("elev-m");
|
||||
double lat = twrNode->getDoubleValue("lat"),
|
||||
lon = twrNode->getDoubleValue("lon"),
|
||||
elevM = twrNode->getDoubleValue("elev-m");
|
||||
// tower elevation is AGL, not AMSL. Since we don't want to depend on the
|
||||
// scenery for a precise terrain elevation, we use the field elevation
|
||||
// (this is also what the apt.dat code does)
|
||||
|
@ -706,16 +703,16 @@ void FGAirport::validateILSData()
|
|||
if (mILSDataLoaded) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// to avoid re-entrancy on this code-path, ensure we set loaded
|
||||
// immediately.
|
||||
mILSDataLoaded = true;
|
||||
|
||||
|
||||
SGPath path;
|
||||
if (!XMLLoader::findAirportData(ident(), "ils", path)) {
|
||||
return; // no XML ILS data
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
SGPropertyNode_ptr rootNode = new SGPropertyNode;
|
||||
readProperties(path, rootNode);
|
||||
|
@ -732,7 +729,7 @@ bool FGAirport::hasTower() const
|
|||
}
|
||||
|
||||
void FGAirport::readILSData(SGPropertyNode* aRoot)
|
||||
{
|
||||
{
|
||||
NavDataCache* cache = NavDataCache::instance();
|
||||
// find the entry matching the runway
|
||||
SGPropertyNode* runwayNode, *ilsNode;
|
||||
|
@ -750,12 +747,12 @@ void FGAirport::readILSData(SGPropertyNode* aRoot)
|
|||
ilsNode->getStringValue("nav-id"));
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
double hdgDeg = ilsNode->getDoubleValue("hdg-deg"),
|
||||
lon = ilsNode->getDoubleValue("lon"),
|
||||
lat = ilsNode->getDoubleValue("lat"),
|
||||
elevM = ilsNode->getDoubleValue("elev-m");
|
||||
|
||||
|
||||
FGNavRecordRef nav(FGPositioned::loadById<FGNavRecord>(ils));
|
||||
assert(nav.valid());
|
||||
nav->updateFromXML(SGGeod::fromDegM(lon, lat, elevM), hdgDeg);
|
||||
|
@ -801,7 +798,7 @@ flightgear::SID* FGAirport::findSIDWithIdent(const std::string& aIdent) const
|
|||
return mSIDs[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -835,7 +832,7 @@ STAR* FGAirport::findSTARWithIdent(const std::string& aIdent) const
|
|||
return mSTARs[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -868,7 +865,7 @@ Approach* FGAirport::findApproachWithIdent(const std::string& aIdent) const
|
|||
return mApproaches[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -893,13 +890,12 @@ FGAirport::commStations() const
|
|||
{
|
||||
NavDataCache* cache = NavDataCache::instance();
|
||||
CommStationList result;
|
||||
BOOST_FOREACH(PositionedID pos, cache->airportItemsOfType(guid(),
|
||||
FGPositioned::FREQ_GROUND,
|
||||
FGPositioned::FREQ_UNICOM))
|
||||
{
|
||||
for (auto pos : cache->airportItemsOfType(guid(),
|
||||
FGPositioned::FREQ_GROUND,
|
||||
FGPositioned::FREQ_UNICOM)) {
|
||||
result.push_back( loadById<CommStation>(pos) );
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -908,10 +904,10 @@ FGAirport::commStationsOfType(FGPositioned::Type aTy) const
|
|||
{
|
||||
NavDataCache* cache = NavDataCache::instance();
|
||||
CommStationList result;
|
||||
BOOST_FOREACH(PositionedID pos, cache->airportItemsOfType(guid(), aTy)) {
|
||||
for (auto pos : cache->airportItemsOfType(guid(), aTy)) {
|
||||
result.push_back( loadById<CommStation>(pos) );
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -924,32 +920,32 @@ public:
|
|||
{
|
||||
assert(pos->type() == FGPositioned::AIRPORT);
|
||||
FGAirport* apt = static_cast<FGAirport*>(pos.get());
|
||||
BOOST_FOREACH(FGRunway* rwy, apt->getRunwaysWithoutReciprocals()) {
|
||||
for (auto rwy : apt->getRunwaysWithoutReciprocals()) {
|
||||
_sizeMetric += static_cast<int>(rwy->lengthFt());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool operator<(const AirportWithSize& other) const
|
||||
{
|
||||
return _sizeMetric < other._sizeMetric;
|
||||
}
|
||||
|
||||
|
||||
FGPositionedRef pos() const
|
||||
{ return _pos; }
|
||||
private:
|
||||
FGPositionedRef _pos;
|
||||
unsigned int _sizeMetric;
|
||||
|
||||
|
||||
};
|
||||
|
||||
void FGAirport::sortBySize(FGPositionedList& airportList)
|
||||
{
|
||||
std::vector<AirportWithSize> annotated;
|
||||
BOOST_FOREACH(FGPositionedRef p, airportList) {
|
||||
for (auto p : airportList) {
|
||||
annotated.push_back(AirportWithSize(p));
|
||||
}
|
||||
std::sort(annotated.begin(), annotated.end());
|
||||
|
||||
|
||||
for (unsigned int i=0; i<annotated.size(); ++i) {
|
||||
airportList[i] = annotated[i].pos();
|
||||
}
|
||||
|
|
|
@ -26,8 +26,6 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
|
||||
#include <Environment/environment_mgr.hxx>
|
||||
|
@ -67,24 +65,24 @@ public:
|
|||
assert(dyn);
|
||||
retain(); // initial count of 1
|
||||
}
|
||||
|
||||
|
||||
~ParkingAssignmentPrivate()
|
||||
{
|
||||
dynamics->releaseParking(parking);
|
||||
}
|
||||
|
||||
|
||||
void release()
|
||||
{
|
||||
if ((--refCount) == 0) {
|
||||
delete this;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void retain()
|
||||
{
|
||||
++refCount;
|
||||
}
|
||||
|
||||
|
||||
unsigned int refCount;
|
||||
FGParkingRef parking;
|
||||
FGAirportDynamicsRef dynamics;
|
||||
|
@ -101,7 +99,7 @@ ParkingAssignment::~ParkingAssignment()
|
|||
_sharedData->release();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ParkingAssignment::ParkingAssignment(FGParking* pk, FGAirportDynamics* dyn) :
|
||||
_sharedData(NULL)
|
||||
{
|
||||
|
@ -123,17 +121,17 @@ void ParkingAssignment::operator=(const ParkingAssignment& aOther)
|
|||
if (_sharedData == aOther._sharedData) {
|
||||
return; // self-assignment, special case
|
||||
}
|
||||
|
||||
|
||||
if (_sharedData) {
|
||||
_sharedData->release();
|
||||
}
|
||||
|
||||
|
||||
_sharedData = aOther._sharedData;
|
||||
if (_sharedData) {
|
||||
_sharedData->retain();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ParkingAssignment::release()
|
||||
{
|
||||
if (_sharedData) {
|
||||
|
@ -244,11 +242,11 @@ FGParking* FGAirportDynamics::innerGetAvailableParking(double radius, const stri
|
|||
if (!isParkingAvailable(parking)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (parking->getRadius() < radius) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (!flType.empty() && (parking->getType() != flType)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -269,7 +267,7 @@ FGParking* FGAirportDynamics::innerGetAvailableParking(double radius, const stri
|
|||
|
||||
candidates.push_back(parking);
|
||||
}
|
||||
|
||||
|
||||
if (candidates.empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -280,7 +278,7 @@ FGParking* FGAirportDynamics::innerGetAvailableParking(double radius, const stri
|
|||
[](const FGParkingRef& a, const FGParkingRef& b) {
|
||||
return a->getRadius() < b->getRadius();
|
||||
});
|
||||
|
||||
|
||||
setParkingAvailable(candidates.front(), false);
|
||||
return candidates.front();
|
||||
}
|
||||
|
@ -295,13 +293,13 @@ ParkingAssignment FGAirportDynamics::getAvailableParking(double radius, const st
|
|||
const string & airline)
|
||||
{
|
||||
SG_UNUSED(acType); // sadly not used at the moment
|
||||
|
||||
|
||||
// most exact seach - airline codes must be present and match
|
||||
FGParking* result = innerGetAvailableParking(radius, flType, airline, true);
|
||||
if (result) {
|
||||
return ParkingAssignment(result, this);
|
||||
}
|
||||
|
||||
|
||||
// more tolerant - gates with empty airline codes are permitted
|
||||
result = innerGetAvailableParking(radius, flType, airline, false);
|
||||
if (result) {
|
||||
|
@ -357,7 +355,7 @@ void FGAirportDynamics::releaseParking(FGParking* id)
|
|||
if (it == occupiedParkings.end()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
occupiedParkings.erase(it);
|
||||
}
|
||||
|
||||
|
@ -622,7 +620,7 @@ string FGAirportDynamics::fallbackGetActiveRunway(int action, double heading)
|
|||
|
||||
// assign takeoff and landing runways
|
||||
FallbackRunwayGroup bestGroup = groups.front();
|
||||
|
||||
|
||||
_lastFallbackUpdate.stamp();
|
||||
_fallbackRunwayCounter = 0;
|
||||
_fallbackDepartureRunways.clear();
|
||||
|
@ -721,7 +719,7 @@ bool FGAirportDynamics::innerGetActiveRunway(const string & trafficType,
|
|||
|
||||
// Keep a history of the currently active runways, to ensure
|
||||
// that an already established selection of runways will not
|
||||
// be overridden once a more preferred selection becomes
|
||||
// be overridden once a more preferred selection becomes
|
||||
// available as that can lead to random runway swapping.
|
||||
if (trafficType == "com") {
|
||||
currentlyActive = &comActive;
|
||||
|
@ -745,7 +743,7 @@ bool FGAirportDynamics::innerGetActiveRunway(const string & trafficType,
|
|||
windHeading,
|
||||
maxTail, maxCross, currentlyActive);
|
||||
|
||||
// Note that I SHOULD keep multiple lists in memory, one for
|
||||
// Note that I SHOULD keep multiple lists in memory, one for
|
||||
// general aviation, one for commercial and one for military
|
||||
// traffic.
|
||||
currentlyActive->clear();
|
||||
|
@ -757,7 +755,7 @@ bool FGAirportDynamics::innerGetActiveRunway(const string & trafficType,
|
|||
if (type == "landing") {
|
||||
landing.push_back(name);
|
||||
currentlyActive->push_back(name);
|
||||
//cerr << "Landing " << name << endl;
|
||||
//cerr << "Landing " << name << endl;
|
||||
}
|
||||
if (type == "takeoff") {
|
||||
takeoff.push_back(name);
|
||||
|
@ -768,7 +766,7 @@ bool FGAirportDynamics::innerGetActiveRunway(const string & trafficType,
|
|||
//cerr << endl;
|
||||
}
|
||||
|
||||
if (action == 1) // takeoff
|
||||
if (action == 1) // takeoff
|
||||
{
|
||||
int nr = takeoff.size();
|
||||
if (nr) {
|
||||
|
@ -806,7 +804,7 @@ string FGAirportDynamics::chooseRwyByHeading(stringVec rwys,
|
|||
" not found at " << _ap->ident());
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
FGRunway *rwy = _ap->getRunwayByIdent((*i));
|
||||
rwyHeading = rwy->headingDeg();
|
||||
headingError = fabs(heading - rwyHeading);
|
||||
|
@ -848,8 +846,8 @@ const string FGAirportDynamics::getId() const
|
|||
}
|
||||
|
||||
// Experimental: Return a different ground frequency depending on the leg of the
|
||||
// Flight. Leg should always have a minimum value of two when this function is called.
|
||||
// Note that in this scheme, the assignment of various frequencies to various ground
|
||||
// Flight. Leg should always have a minimum value of two when this function is called.
|
||||
// Note that in this scheme, the assignment of various frequencies to various ground
|
||||
// operations is completely arbitrary. As such, is a short cut I need to take now,
|
||||
// so that at least I can start working on assigning different frequencies to different
|
||||
// operations.
|
||||
|
@ -919,7 +917,7 @@ const std::string FGAirportDynamics::getAtisSequence()
|
|||
char atisSequenceString[2];
|
||||
atisSequenceString[0] = 'a' + atisSequenceIndex;
|
||||
atisSequenceString[1] = 0;
|
||||
|
||||
|
||||
return globals->get_locale()->getLocalizedString(atisSequenceString, "atc", "unknown");
|
||||
}
|
||||
|
||||
|
@ -937,8 +935,8 @@ int FGAirportDynamics::updateAtisSequence(int interval, bool forceUpdate)
|
|||
atisSequenceTimeStamp += (interval * steps);
|
||||
if (forceUpdate && (steps == 0)) {
|
||||
++steps; // a "special" ATIS update is required
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
atisSequenceIndex = (atisSequenceIndex + steps) % 26;
|
||||
// return a huge value if no update occurred
|
||||
return (atisSequenceIndex + (steps ? 0 : 26*1000));
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
#include "gnnode.hxx"
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
#include "groundnetwork.hxx"
|
||||
|
||||
#include <Navaids/NavDataCache.hxx>
|
||||
|
@ -25,7 +23,7 @@ FGTaxiNode::FGTaxiNode(int index, const SGGeod& pos,
|
|||
holdType(aHoldType),
|
||||
m_isPushback(false)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
FGTaxiNode::~FGTaxiNode()
|
||||
|
@ -54,7 +52,7 @@ double FGTaxiNode::getElevationFt()
|
|||
modifyPosition(newPos);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return pos.getElevationFt();
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
#include <algorithm>
|
||||
#include <fstream>
|
||||
#include <map>
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
#include <simgear/debug/logstream.hxx>
|
||||
#include <simgear/scene/util/OsgMath.hxx>
|
||||
|
@ -96,7 +95,7 @@ void FGTaxiSegment::block(int id, time_t blockTime, time_t now)
|
|||
{
|
||||
BlockListIterator i = blockTimes.begin();
|
||||
while (i != blockTimes.end()) {
|
||||
if (i->getId() == id)
|
||||
if (i->getId() == id)
|
||||
break;
|
||||
i++;
|
||||
}
|
||||
|
@ -123,7 +122,7 @@ void FGTaxiSegment::unblock(time_t now)
|
|||
{
|
||||
if (blockTimes.empty())
|
||||
return;
|
||||
|
||||
|
||||
if (blockTimes.front().getTimeStamp() < (now - 30)) {
|
||||
blockTimes.erase(blockTimes.begin());
|
||||
}
|
||||
|
@ -145,7 +144,7 @@ bool FGTaxiRoute::next(FGTaxiNodeRef& node, int *rte)
|
|||
*rte = *(currRoute);
|
||||
currRoute++;
|
||||
} else {
|
||||
// Handle special case for the first node.
|
||||
// Handle special case for the first node.
|
||||
*rte = -1 * *(currRoute);
|
||||
}
|
||||
currNode++;
|
||||
|
@ -167,7 +166,7 @@ FGGroundNetwork::FGGroundNetwork(FGAirport* airport) :
|
|||
FGGroundNetwork::~FGGroundNetwork()
|
||||
{
|
||||
|
||||
BOOST_FOREACH(FGTaxiSegment* seg, segments) {
|
||||
for (auto seg : segments) {
|
||||
delete seg;
|
||||
}
|
||||
}
|
||||
|
@ -180,16 +179,16 @@ void FGGroundNetwork::init()
|
|||
}
|
||||
|
||||
hasNetwork = true;
|
||||
int index = 1;
|
||||
|
||||
int index = 1;
|
||||
|
||||
// establish pairing of segments
|
||||
BOOST_FOREACH(FGTaxiSegment* segment, segments) {
|
||||
for (auto segment : segments) {
|
||||
segment->setIndex(index++);
|
||||
|
||||
|
||||
if (segment->oppositeDirection) {
|
||||
continue; // already established
|
||||
}
|
||||
|
||||
|
||||
FGTaxiSegment* opp = findSegment(segment->endNode, segment->startNode);
|
||||
if (opp) {
|
||||
assert(opp->oppositeDirection == NULL);
|
||||
|
@ -197,7 +196,7 @@ void FGGroundNetwork::init()
|
|||
opp->oppositeDirection = segment;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
networkInitialized = true;
|
||||
}
|
||||
|
||||
|
@ -290,7 +289,7 @@ const FGParkingList &FGGroundNetwork::allParkings() const
|
|||
}
|
||||
|
||||
FGTaxiSegment *FGGroundNetwork::findSegment(unsigned idx) const
|
||||
{
|
||||
{
|
||||
if ((idx > 0) && (idx <= segments.size()))
|
||||
return segments[idx - 1];
|
||||
else {
|
||||
|
@ -304,19 +303,19 @@ FGTaxiSegment* FGGroundNetwork::findSegment(const FGTaxiNode* from, const FGTaxi
|
|||
if (from == 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
// completely boring linear search of segments. Can be improved if/when
|
||||
// this ever becomes a hot-spot
|
||||
BOOST_FOREACH(FGTaxiSegment* seg, segments) {
|
||||
for (auto seg : segments) {
|
||||
if (seg->startNode != from) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if ((to == 0) || (seg->endNode == to)) {
|
||||
return seg;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return NULL; // not found
|
||||
}
|
||||
|
||||
|
@ -332,7 +331,7 @@ public:
|
|||
ShortestPathData() :
|
||||
score(HUGE_VAL)
|
||||
{}
|
||||
|
||||
|
||||
double score;
|
||||
FGTaxiNodeRef previousNode;
|
||||
};
|
||||
|
@ -352,12 +351,12 @@ FGTaxiRoute FGGroundNetwork::findShortestRoute(FGTaxiNode* start, FGTaxiNode* en
|
|||
while (!unvisited.empty()) {
|
||||
// find lowest scored unvisited
|
||||
FGTaxiNodeRef best = unvisited.front();
|
||||
BOOST_FOREACH(FGTaxiNodeRef i, unvisited) {
|
||||
for (auto i : unvisited) {
|
||||
if (searchData[i].score < searchData[best].score) {
|
||||
best = i;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// remove 'best' from the unvisited set
|
||||
FGTaxiNodeVectorIterator newend =
|
||||
remove(unvisited.begin(), unvisited.end(), best);
|
||||
|
@ -366,8 +365,8 @@ FGTaxiRoute FGGroundNetwork::findShortestRoute(FGTaxiNode* start, FGTaxiNode* en
|
|||
if (best == end) { // found route or best not connected
|
||||
break;
|
||||
}
|
||||
|
||||
BOOST_FOREACH(FGTaxiNodeRef target, segmentsFrom(best)) {
|
||||
|
||||
for (auto target : segmentsFrom(best)) {
|
||||
double edgeLength = dist(best->cart(), target->cart());
|
||||
double alt = searchData[best].score + edgeLength + edgePenalty(target);
|
||||
if (alt < searchData[target].score) { // Relax (u,v)
|
||||
|
@ -384,22 +383,22 @@ FGTaxiRoute FGGroundNetwork::findShortestRoute(FGTaxiNode* start, FGTaxiNode* en
|
|||
"Failed to find route from waypoint " << start << " to "
|
||||
<< end << " at " << parent->getId());
|
||||
}
|
||||
|
||||
|
||||
return FGTaxiRoute();
|
||||
}
|
||||
|
||||
|
||||
// assemble route from backtrace information
|
||||
FGTaxiNodeVector nodes;
|
||||
intVec routes;
|
||||
FGTaxiNode *bt = end;
|
||||
|
||||
|
||||
while (searchData[bt].previousNode != 0) {
|
||||
nodes.push_back(bt);
|
||||
FGTaxiSegment *segment = findSegment(searchData[bt].previousNode, bt);
|
||||
int idx = segment->getIndex();
|
||||
routes.push_back(idx);
|
||||
bt = searchData[bt].previousNode;
|
||||
|
||||
|
||||
}
|
||||
nodes.push_back(start);
|
||||
reverse(nodes.begin(), nodes.end());
|
||||
|
@ -513,4 +512,3 @@ const intVec& FGGroundNetwork::getGroundFrequencies() const
|
|||
{
|
||||
return freqGround;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,8 +29,6 @@
|
|||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
#include <simgear/debug/logstream.hxx>
|
||||
#include <simgear/misc/strutils.hxx>
|
||||
|
@ -154,7 +152,7 @@ void RunwayList::set(const std::string & tp, const std::string & lst)
|
|||
if ((ident.size() < 2) || !isdigit(ident[1])) {
|
||||
ident = "0" + ident;
|
||||
}
|
||||
|
||||
|
||||
preferredRunways.push_back(ident);
|
||||
}
|
||||
}
|
||||
|
@ -226,10 +224,10 @@ void RunwayGroup::setActive(const FGAirport * airport,
|
|||
// Test each runway listed in the preference to see if it's possible to use
|
||||
// If one runway of the selection isn't allowed, we need to exclude this
|
||||
// preference, however, we don't want to stop right there, because we also
|
||||
// don't want to randomly swap runway preferences, unless there is a need to.
|
||||
// don't want to randomly swap runway preferences, unless there is a need to.
|
||||
//
|
||||
validSelection = true;
|
||||
|
||||
|
||||
for (int j = 0; j < activeRwys; j++) {
|
||||
std::string ident(rwyList[j].getRwyList(i));
|
||||
if (!airport->hasRunwayWithIdent(ident)) {
|
||||
|
@ -288,7 +286,7 @@ void RunwayGroup::setActive(const FGAirport * airport,
|
|||
return;
|
||||
}
|
||||
// If this didn't work, due to heavy winds, try again
|
||||
// but select only one landing and one takeoff runway.
|
||||
// but select only one landing and one takeoff runway.
|
||||
choice[0] = 0;
|
||||
choice[1] = 0;
|
||||
for (int i = activeRwys - 1; i; i--) {
|
||||
|
|
|
@ -28,8 +28,6 @@
|
|||
#include <simgear/sg_inlines.h>
|
||||
#include <simgear/props/props_io.hxx>
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
#include <Main/fg_props.hxx>
|
||||
#include <Main/globals.hxx>
|
||||
|
||||
|
@ -41,7 +39,7 @@
|
|||
namespace flightgear
|
||||
{
|
||||
|
||||
CockpitDisplayManager::CockpitDisplayManager ()
|
||||
CockpitDisplayManager::CockpitDisplayManager ()
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -78,7 +76,7 @@ void CockpitDisplayManager::init()
|
|||
SG_LOG(SG_COCKPIT, SG_ALERT, "Failed to load instrumentation system model: "
|
||||
<< config << ":" << e.getFormattedMessage() );
|
||||
}
|
||||
|
||||
|
||||
SGSubsystemGroup::init();
|
||||
}
|
||||
|
||||
|
@ -95,7 +93,7 @@ bool CockpitDisplayManager::build (SGPropertyNode* config_props)
|
|||
if (index > 0)
|
||||
subsystemname << '['<< index << ']';
|
||||
std::string id = subsystemname.str();
|
||||
|
||||
|
||||
if ( name == "radar" ) {
|
||||
set_subsystem( id, new wxRadarBg ( node ) );
|
||||
|
||||
|
@ -104,10 +102,10 @@ bool CockpitDisplayManager::build (SGPropertyNode* config_props)
|
|||
|
||||
} else if ( name == "air-ground-radar" ) {
|
||||
set_subsystem( id, new agRadar( node ) );
|
||||
|
||||
|
||||
} else if ( name == "navigation-display" ) {
|
||||
set_subsystem( id, new NavDisplay( node ) );
|
||||
|
||||
|
||||
} else {
|
||||
// probably a regular instrument
|
||||
continue;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
// 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
|
||||
|
@ -49,7 +49,6 @@
|
|||
|
||||
#include "fnt.h"
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
#include <simgear/debug/logstream.hxx>
|
||||
#include <simgear/misc/sg_path.hxx>
|
||||
#include <simgear/misc/strutils.hxx>
|
||||
|
@ -61,7 +60,7 @@
|
|||
#include <Viewer/viewmgr.hxx>
|
||||
#include <Viewer/view.hxx>
|
||||
#include <Time/light.hxx>
|
||||
#include <GUI/FGFontCache.hxx>
|
||||
#include <GUI/FGFontCache.hxx>
|
||||
#include <Instrumentation/dclgps.hxx>
|
||||
|
||||
#define WIN_X 0
|
||||
|
@ -110,7 +109,7 @@ FGTextureManager::createTexture (const std::string &relativePath, bool staticTex
|
|||
texture = SGLoadTexture2D(staticTexture, tpath);
|
||||
|
||||
_textureMap[relativePath] = texture;
|
||||
if (!_textureMap[relativePath].valid())
|
||||
if (!_textureMap[relativePath].valid())
|
||||
SG_LOG( SG_COCKPIT, SG_ALERT, "Texture *still* doesn't exist" );
|
||||
SG_LOG( SG_COCKPIT, SG_DEBUG, "Created texture " << relativePath );
|
||||
}
|
||||
|
@ -220,15 +219,15 @@ double
|
|||
FGPanel::getAspectScale() const
|
||||
{
|
||||
// set corner-coordinates correctly
|
||||
|
||||
|
||||
int xsize = _xsize_node->getIntValue();
|
||||
int ysize = _ysize_node->getIntValue();
|
||||
float aspect_adjust = get_aspect_adjust(xsize, ysize);
|
||||
|
||||
|
||||
if (aspect_adjust < 1.0)
|
||||
return ysize / (double) WIN_H;
|
||||
else
|
||||
return xsize /(double) WIN_W;
|
||||
return xsize /(double) WIN_W;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -246,14 +245,14 @@ void FGPanel::updateMouseDelay(double dt)
|
|||
while (_mouseActionRepeat < 0.0) {
|
||||
_mouseActionRepeat += MOUSE_ACTION_REPEAT_INTERVAL;
|
||||
_mouseInstrument->doMouseAction(_mouseButton, 0, _mouseX, _mouseY);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
FGPanel::draw(osg::State& state)
|
||||
{
|
||||
|
||||
|
||||
// In 3D mode, it's possible that we are being drawn exactly on top
|
||||
// of an existing polygon. Use an offset to prevent z-fighting. In
|
||||
// 2D mode, this is a no-op.
|
||||
|
@ -268,7 +267,7 @@ FGPanel::draw(osg::State& state)
|
|||
panelStateSet->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
|
||||
panelStateSet->setMode(GL_BLEND, osg::StateAttribute::ON);
|
||||
panelStateSet->setMode(GL_ALPHA_TEST, osg::StateAttribute::ON);
|
||||
|
||||
|
||||
osg::Material* material = new osg::Material;
|
||||
material->setColorMode(osg::Material::AMBIENT_AND_DIFFUSE);
|
||||
material->setDiffuse(osg::Material::FRONT_AND_BACK, osg::Vec4(1, 1, 1, 1));
|
||||
|
@ -276,7 +275,7 @@ FGPanel::draw(osg::State& state)
|
|||
material->setSpecular(osg::Material::FRONT_AND_BACK, osg::Vec4(0, 0, 0, 1));
|
||||
material->setEmission(osg::Material::FRONT_AND_BACK, osg::Vec4(0, 0, 0, 1));
|
||||
panelStateSet->setAttribute(material);
|
||||
|
||||
|
||||
panelStateSet->setMode(GL_CULL_FACE, osg::StateAttribute::ON);
|
||||
panelStateSet->setAttributeAndModes(new osg::CullFace(osg::CullFace::BACK));
|
||||
panelStateSet->setAttributeAndModes(new osg::Depth(osg::Depth::LEQUAL));
|
||||
|
@ -419,7 +418,7 @@ FGPanel::draw(osg::State& state)
|
|||
glPushAttrib(GL_ENABLE_BIT);
|
||||
glDisable(GL_COLOR_MATERIAL);
|
||||
glColor3f(1, 1, 0);
|
||||
|
||||
|
||||
for ( unsigned int i = 0; i < _instruments.size(); i++ )
|
||||
_instruments[i]->drawHotspots(state);
|
||||
|
||||
|
@ -430,7 +429,7 @@ FGPanel::draw(osg::State& state)
|
|||
|
||||
int x0, y0, x1, y1;
|
||||
getLogicalExtent(x0, y0, x1, y1);
|
||||
|
||||
|
||||
glBegin(GL_LINE_LOOP);
|
||||
glVertex2f(x0, y0);
|
||||
glVertex2f(x1, y0);
|
||||
|
@ -438,7 +437,7 @@ FGPanel::draw(osg::State& state)
|
|||
glVertex2f(x0, y1);
|
||||
glEnd();
|
||||
#endif
|
||||
|
||||
|
||||
glPopAttrib();
|
||||
|
||||
state.popStateSet();
|
||||
|
@ -564,7 +563,7 @@ FGPanel::doMouseAction (int button, int updown, int x, int y)
|
|||
// Having fixed up the coordinates, fall through to the local
|
||||
// coordinate handler.
|
||||
return doLocalMouseAction(button, updown, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
void FGPanel::setDepthTest (bool enable) {
|
||||
_enable_depth_test = enable;
|
||||
|
@ -572,30 +571,30 @@ void FGPanel::setDepthTest (bool enable) {
|
|||
|
||||
class IntRect
|
||||
{
|
||||
|
||||
|
||||
public:
|
||||
IntRect() :
|
||||
x0(std::numeric_limits<int>::max()),
|
||||
y0(std::numeric_limits<int>::max()),
|
||||
x1(std::numeric_limits<int>::min()),
|
||||
y1(std::numeric_limits<int>::min())
|
||||
IntRect() :
|
||||
x0(std::numeric_limits<int>::max()),
|
||||
y0(std::numeric_limits<int>::max()),
|
||||
x1(std::numeric_limits<int>::min()),
|
||||
y1(std::numeric_limits<int>::min())
|
||||
{ }
|
||||
|
||||
|
||||
IntRect(int x, int y, int w, int h) :
|
||||
x0(x), y0(y), x1(x + w), y1( y + h)
|
||||
{
|
||||
{
|
||||
if (x1 < x0) {
|
||||
std::swap(x0, x1);
|
||||
}
|
||||
|
||||
|
||||
if (y1 < y0) {
|
||||
std::swap(y0, y1);
|
||||
}
|
||||
|
||||
|
||||
assert(x0 <= x1);
|
||||
assert(y0 <= y1);
|
||||
}
|
||||
|
||||
|
||||
void extend(const IntRect& r)
|
||||
{
|
||||
x0 = std::min(x0, r.x0);
|
||||
|
@ -603,17 +602,17 @@ public:
|
|||
x1 = std::max(x1, r.x1);
|
||||
y1 = std::max(y1, r.y1);
|
||||
}
|
||||
|
||||
|
||||
int x0, y0, x1, y1;
|
||||
};
|
||||
|
||||
void FGPanel::getLogicalExtent(int &x0, int& y0, int& x1, int &y1)
|
||||
{
|
||||
{
|
||||
IntRect result;
|
||||
BOOST_FOREACH(FGPanelInstrument *inst, _instruments) {
|
||||
for (auto inst : _instruments) {
|
||||
inst->extendRect(result);
|
||||
}
|
||||
|
||||
|
||||
x0 = result.x0;
|
||||
y0 = result.y0;
|
||||
x1 = result.x1;
|
||||
|
@ -771,9 +770,9 @@ FGPanelInstrument::extendRect(IntRect& r) const
|
|||
{
|
||||
IntRect instRect(_x, _y, _w, _h);
|
||||
r.extend(instRect);
|
||||
|
||||
BOOST_FOREACH(FGPanelAction* act, _actions) {
|
||||
r.extend(IntRect(getXPos() + act->getX(),
|
||||
|
||||
for (auto act : _actions) {
|
||||
r.extend(IntRect(getXPos() + act->getX(),
|
||||
getYPos() + act->getY(),
|
||||
act->getWidth(),
|
||||
act->getHeight()
|
||||
|
@ -827,7 +826,7 @@ FGLayeredInstrument::draw (osg::State& state)
|
|||
{
|
||||
if (!test())
|
||||
return;
|
||||
|
||||
|
||||
for (int i = 0; i < (int)_layers.size(); i++) {
|
||||
glPushMatrix();
|
||||
_layers[i]->draw(state);
|
||||
|
@ -930,7 +929,7 @@ FGInstrumentLayer::transform () const
|
|||
} else {
|
||||
val = t->table->interpolate(val) * t->factor + t->offset;
|
||||
}
|
||||
|
||||
|
||||
switch (t->type) {
|
||||
case FGPanelTransformation::XSHIFT:
|
||||
glTranslatef(val, 0.0, 0.0);
|
||||
|
@ -1012,7 +1011,7 @@ FGTexturedLayer::draw (osg::State& state)
|
|||
if (test()) {
|
||||
int w2 = _w / 2;
|
||||
int h2 = _h / 2;
|
||||
|
||||
|
||||
transform();
|
||||
state.pushStateSet(_texture.getTexture());
|
||||
state.apply();
|
||||
|
@ -1076,7 +1075,7 @@ FGTextLayer::draw (osg::State& state)
|
|||
if (!font) {
|
||||
return; // don't crash on missing fonts
|
||||
}
|
||||
|
||||
|
||||
text_renderer.setFont(font);
|
||||
|
||||
text_renderer.setPointSize(_pointSize);
|
||||
|
@ -1174,7 +1173,7 @@ FGTextLayer::Chunk::Chunk (const std::string &text, const std::string &fmt)
|
|||
_fmt(simgear::strutils::sanitizePrintfFormat(fmt))
|
||||
{
|
||||
_text = text;
|
||||
if (_fmt.empty())
|
||||
if (_fmt.empty())
|
||||
_fmt = "%s";
|
||||
}
|
||||
|
||||
|
|
|
@ -23,8 +23,6 @@
|
|||
#include <AppKit/NSSavePanel.h>
|
||||
#include <AppKit/NSOpenPanel.h>
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
#include <osgViewer/Viewer>
|
||||
#include <osgViewer/api/Cocoa/GraphicsWindowCocoa>
|
||||
|
||||
|
@ -47,14 +45,14 @@ public:
|
|||
CocoaFileDialogPrivate() :
|
||||
panel(nil)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
~CocoaFileDialogPrivate()
|
||||
{
|
||||
[panel release];
|
||||
}
|
||||
|
||||
|
||||
NSSavePanel* panel;
|
||||
};
|
||||
|
||||
|
@ -65,20 +63,20 @@ CocoaFileDialog::CocoaFileDialog(FGFileDialog::Usage use) :
|
|||
if (use == USE_SAVE_FILE) {
|
||||
d->panel = [NSSavePanel savePanel];
|
||||
} else {
|
||||
NSOpenPanel* openPanel = [NSOpenPanel openPanel];
|
||||
NSOpenPanel* openPanel = [NSOpenPanel openPanel];
|
||||
d->panel = openPanel;
|
||||
|
||||
|
||||
if (use == USE_CHOOSE_DIR) {
|
||||
[openPanel setCanChooseDirectories:YES];
|
||||
}
|
||||
} // of USE_OPEN_FILE or USE_CHOOSE_DIR -> building NSOpenPanel
|
||||
|
||||
|
||||
[d->panel retain];
|
||||
}
|
||||
|
||||
CocoaFileDialog::~CocoaFileDialog()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CocoaFileDialog::exec()
|
||||
|
@ -88,30 +86,30 @@ void CocoaFileDialog::exec()
|
|||
NSWindow* cocoaWindow = nil;
|
||||
std::vector<osgViewer::GraphicsWindow*> windows;
|
||||
globals->get_renderer()->getViewer()->getWindows(windows);
|
||||
|
||||
BOOST_FOREACH(osgViewer::GraphicsWindow* gw, windows) {
|
||||
|
||||
for (auto gw : windows) {
|
||||
// OSG doesn't use RTTI, so no dynamic cast. Let's check the class type
|
||||
// using OSG's own system, before we blindly static_cast<> and break
|
||||
// everything.
|
||||
if (strcmp(gw->className(), "GraphicsWindowCocoa")) {
|
||||
continue;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
osgViewer::GraphicsWindowCocoa* gwCocoa = static_cast<osgViewer::GraphicsWindowCocoa*>(gw);
|
||||
cocoaWindow = (NSWindow*) gwCocoa->getWindow();
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// setup the panel fields now we have collected all the data
|
||||
if (_usage == USE_SAVE_FILE) {
|
||||
[d->panel setNameFieldStringValue:stdStringToCocoa(_placeholder)];
|
||||
}
|
||||
|
||||
|
||||
if (_filterPatterns.empty()) {
|
||||
[d->panel setAllowedFileTypes:nil];
|
||||
} else {
|
||||
NSMutableArray* extensions = [NSMutableArray arrayWithCapacity:0];
|
||||
BOOST_FOREACH(std::string ext, _filterPatterns) {
|
||||
for (const auto& ext : _filterPatterns) {
|
||||
if (!simgear::strutils::starts_with(ext, "*.")) {
|
||||
SG_LOG(SG_GENERAL, SG_INFO, "can't use pattern on Cococa:" << ext);
|
||||
continue;
|
||||
|
@ -121,14 +119,14 @@ void CocoaFileDialog::exec()
|
|||
|
||||
[d->panel setAllowedFileTypes:extensions];
|
||||
}
|
||||
|
||||
|
||||
[d->panel setTitle:stdStringToCocoa(_title)];
|
||||
if (_showHidden) {
|
||||
[d->panel setShowsHiddenFiles:YES];
|
||||
}
|
||||
|
||||
|
||||
[d->panel setDirectoryURL: pathToNSURL(_initialPath)];
|
||||
|
||||
|
||||
[d->panel beginSheetModalForWindow:cocoaWindow completionHandler:^(NSInteger result)
|
||||
{
|
||||
if (result == NSFileHandlingPanelOKButton) {
|
||||
|
@ -144,4 +142,3 @@ void CocoaFileDialog::close()
|
|||
{
|
||||
[d->panel close];
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
#include <windows.h>
|
||||
#include <cstring>
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#include <osgViewer/Viewer>
|
||||
|
@ -39,12 +38,12 @@ HWND getMainViewerHWND()
|
|||
if (strcmp((*it)->className(), "GraphicsWindowWin32")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
osgViewer::GraphicsWindowWin32* platformWin =
|
||||
|
||||
osgViewer::GraphicsWindowWin32* platformWin =
|
||||
static_cast<osgViewer::GraphicsWindowWin32*>(*it);
|
||||
return platformWin->getHWND();
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -53,7 +52,7 @@ bool labelIsSeparator(const std::string& s)
|
|||
std::string t = "---";
|
||||
if (s.compare(0, t.length(), t) == 0)
|
||||
return true;
|
||||
else
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -63,7 +62,7 @@ LRESULT CALLBACK menubarWindowProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM
|
|||
|
||||
|
||||
return ::DefWindowProc(hwnd, uMsg, wParam, lParam);
|
||||
}
|
||||
}
|
||||
|
||||
} // of anonymous namespace
|
||||
|
||||
|
@ -79,7 +78,7 @@ public:
|
|||
{
|
||||
fireBindingList(itemBindings[commandId]);
|
||||
}
|
||||
|
||||
|
||||
HWND mainWindow;
|
||||
HMENU menuBar;
|
||||
bool visible;
|
||||
|
@ -90,15 +89,15 @@ public:
|
|||
|
||||
};
|
||||
|
||||
FGWindowsMenuBar::FGWindowsMenuBar() :
|
||||
FGWindowsMenuBar::FGWindowsMenuBar() :
|
||||
p(new WindowsMenuBarPrivate)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
FGWindowsMenuBar::~FGWindowsMenuBar()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
FGWindowsMenuBar::WindowsMenuBarPrivate::WindowsMenuBarPrivate() :
|
||||
|
@ -107,7 +106,7 @@ FGWindowsMenuBar::WindowsMenuBarPrivate::WindowsMenuBarPrivate() :
|
|||
mainWindow = getMainViewerHWND();
|
||||
menuBar = 0;
|
||||
}
|
||||
|
||||
|
||||
FGWindowsMenuBar::WindowsMenuBarPrivate::~WindowsMenuBarPrivate()
|
||||
{
|
||||
if (menuBar) {
|
||||
|
@ -117,19 +116,19 @@ FGWindowsMenuBar::WindowsMenuBarPrivate::~WindowsMenuBarPrivate()
|
|||
}
|
||||
|
||||
void FGWindowsMenuBar::init()
|
||||
{
|
||||
{
|
||||
int menuIndex = 0;
|
||||
SGPropertyNode_ptr props = fgGetNode("/sim/menubar/default",true);
|
||||
|
||||
|
||||
p->menuBar = CreateMenu();
|
||||
// p->baseMenuProc = (WNDPROC) ::SetWindowLongPtr((HWND) p->mainWindow, GWL_WNDPROC, (LONG_PTR) menubarWindowProc);
|
||||
|
||||
BOOST_FOREACH(SGPropertyNode_ptr n, props->getChildren("menu")) {
|
||||
for (auto n : props->getChildren("menu")) {
|
||||
// synchronise menu with properties
|
||||
std::string l = getLocalizedLabel(n);
|
||||
std::string label = strutils::simplify(l).c_str();
|
||||
HMENU menuItems = CreatePopupMenu();
|
||||
|
||||
|
||||
if (!n->hasValue("enabled")) {
|
||||
n->setBoolValue("enabled", true);
|
||||
}
|
||||
|
@ -138,12 +137,12 @@ void FGWindowsMenuBar::init()
|
|||
|
||||
UINT flags = MF_POPUP;
|
||||
AppendMenu(p->menuBar, flags, (UINT) menuItems, label.c_str());
|
||||
|
||||
|
||||
// submenu
|
||||
int subMenuIndex = 0;
|
||||
SGPropertyNode* menuNode = n;
|
||||
BOOST_FOREACH(SGPropertyNode_ptr n2, menuNode->getChildren("item")) {
|
||||
|
||||
for (auto n2 : menuNode->getChildren("item")) {
|
||||
|
||||
if (!n2->hasValue("enabled")) {
|
||||
n2->setBoolValue("enabled", true);
|
||||
}
|
||||
|
@ -151,7 +150,7 @@ void FGWindowsMenuBar::init()
|
|||
std::string l2 = getLocalizedLabel(n2);
|
||||
std::string label2 = strutils::simplify(l2).c_str();
|
||||
std::string shortcut = n2->getStringValue("key");
|
||||
|
||||
|
||||
SGBindingList bl = readBindingList(n->getChildren("binding"), globals->get_props());
|
||||
UINT commandId = p->itemBindings.size();
|
||||
p->itemBindings.push_back(bl);
|
||||
|
@ -181,7 +180,7 @@ bool FGWindowsMenuBar::isVisible() const
|
|||
}
|
||||
|
||||
void FGWindowsMenuBar::show()
|
||||
{
|
||||
{
|
||||
SetMenu(p->mainWindow, p->menuBar);
|
||||
p->visible = true;
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#include "MouseCursor.hxx"
|
||||
|
||||
#include <cstring>
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
#include <osgViewer/GraphicsWindow>
|
||||
#include <osgViewer/Viewer>
|
||||
|
@ -48,7 +47,7 @@
|
|||
|
||||
namespace
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @brief when no native cursor implementation is available, use the osgViewer support. This
|
||||
* has several limitations but is better than nothing
|
||||
|
@ -62,7 +61,7 @@ public:
|
|||
mCursor(osgViewer::GraphicsWindow::InheritCursor)
|
||||
{
|
||||
mActualCursor = mCursor;
|
||||
|
||||
|
||||
globals->get_renderer()->getViewer()->getWindows(mWindows);
|
||||
}
|
||||
|
||||
|
@ -71,27 +70,27 @@ public:
|
|||
mCursor = translateCursor(aCursor);
|
||||
updateCursor();
|
||||
}
|
||||
|
||||
|
||||
virtual void setCursorVisible(bool aVis)
|
||||
{
|
||||
if (mCursorObscured == aVis) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
mCursorVisible = aVis;
|
||||
updateCursor();
|
||||
}
|
||||
|
||||
|
||||
virtual void hideCursorUntilMouseMove()
|
||||
{
|
||||
if (mCursorObscured) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
mCursorObscured = true;
|
||||
updateCursor();
|
||||
}
|
||||
|
||||
|
||||
virtual void mouseMoved()
|
||||
{
|
||||
if (mCursorObscured) {
|
||||
|
@ -111,10 +110,10 @@ private:
|
|||
case CURSOR_LEFT_RIGHT: return osgViewer::GraphicsWindow::LeftRightCursor;
|
||||
case CURSOR_UP_DOWN: return osgViewer::GraphicsWindow::UpDownCursor;
|
||||
default:
|
||||
return osgViewer::GraphicsWindow::RightArrowCursor;
|
||||
return osgViewer::GraphicsWindow::RightArrowCursor;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void updateCursor()
|
||||
{
|
||||
osgViewer::GraphicsWindow::MouseCursor cur = osgViewer::GraphicsWindow::InheritCursor;
|
||||
|
@ -123,24 +122,24 @@ private:
|
|||
} else {
|
||||
cur = mCursor;
|
||||
}
|
||||
|
||||
|
||||
if (cur == mActualCursor) {
|
||||
return;
|
||||
}
|
||||
|
||||
BOOST_FOREACH(osgViewer::GraphicsWindow* gw, mWindows) {
|
||||
|
||||
for (auto gw : mWindows) {
|
||||
gw->setCursor(cur);
|
||||
}
|
||||
|
||||
|
||||
mActualCursor = cur;
|
||||
}
|
||||
|
||||
|
||||
bool mCursorObscured;
|
||||
bool mCursorVisible;
|
||||
osgViewer::GraphicsWindow::MouseCursor mCursor, mActualCursor;
|
||||
std::vector<osgViewer::GraphicsWindow*> mWindows;
|
||||
};
|
||||
|
||||
|
||||
} // of anonymous namespace
|
||||
|
||||
static FGMouseCursor* static_instance = NULL;
|
||||
|
@ -162,7 +161,7 @@ FGMouseCursor* FGMouseCursor::instance()
|
|||
// set osgViewer cursor inherit, otherwise it will interefere
|
||||
std::vector<osgViewer::GraphicsWindow*> gws;
|
||||
globals->get_renderer()->getViewer()->getWindows(gws);
|
||||
BOOST_FOREACH(osgViewer::GraphicsWindow* gw, gws) {
|
||||
for (auto gw : gws) {
|
||||
gw->setCursor(osgViewer::GraphicsWindow::InheritCursor);
|
||||
}
|
||||
|
||||
|
@ -173,18 +172,18 @@ FGMouseCursor* FGMouseCursor::instance()
|
|||
// and create our real implementation
|
||||
// static_instance = new WindowsMouseCursor;
|
||||
#endif
|
||||
|
||||
|
||||
// X11
|
||||
|
||||
|
||||
if (static_instance == NULL) {
|
||||
static_instance = new StockOSGCursor;
|
||||
}
|
||||
|
||||
|
||||
// initialise mouse-hide delay from global properties
|
||||
|
||||
|
||||
globals->get_commands()->addCommand("set-cursor", static_instance, &FGMouseCursor::setCursorCommand);
|
||||
}
|
||||
|
||||
|
||||
return static_instance;
|
||||
}
|
||||
|
||||
|
@ -197,7 +196,7 @@ void FGMouseCursor::setAutoHideTimeMsec(unsigned int aMsec)
|
|||
bool FGMouseCursor::setCursorCommand(const SGPropertyNode* arg, SGPropertyNode*)
|
||||
{
|
||||
// JMT 2013 - I would prefer this was a seperate 'warp' command, but
|
||||
// historically set-cursor has done both.
|
||||
// historically set-cursor has done both.
|
||||
if (arg->hasValue("x") || arg->hasValue("y")) {
|
||||
SGPropertyNode *mx = fgGetNode("/devices/status/mice/mouse/x", true);
|
||||
SGPropertyNode *my = fgGetNode("/devices/status/mice/mouse/y", true);
|
||||
|
@ -208,8 +207,8 @@ bool FGMouseCursor::setCursorCommand(const SGPropertyNode* arg, SGPropertyNode*)
|
|||
my->setIntValue(y);
|
||||
}
|
||||
|
||||
|
||||
Cursor c = cursorFromString(arg->getStringValue("cursor"));
|
||||
|
||||
Cursor c = cursorFromString(arg->getStringValue("cursor"));
|
||||
setCursor(c);
|
||||
return true;
|
||||
}
|
||||
|
@ -226,7 +225,7 @@ const MouseCursorMap mouse_cursor_map[] = {
|
|||
{ "hand", FGMouseCursor::CURSOR_HAND },
|
||||
{ "closed-hand", FGMouseCursor::CURSOR_CLOSED_HAND },
|
||||
{ "text", FGMouseCursor::CURSOR_IBEAM },
|
||||
|
||||
|
||||
// aliases
|
||||
{ "drag-horizontal", FGMouseCursor::CURSOR_LEFT_RIGHT },
|
||||
{ "drag-vertical", FGMouseCursor::CURSOR_UP_DOWN },
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
#include "PUIFileDialog.hxx"
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
#include <simgear/debug/logstream.hxx>
|
||||
#include <simgear/props/props_io.hxx>
|
||||
|
||||
|
@ -17,12 +15,12 @@ public:
|
|||
PathListener(PUIFileDialog* dlg) :
|
||||
_dialog(dlg)
|
||||
{ ; }
|
||||
|
||||
|
||||
virtual void valueChanged(SGPropertyNode* node)
|
||||
{
|
||||
_dialog->pathChanged(SGPath(node->getStringValue()));
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
PUIFileDialog* _dialog;
|
||||
};
|
||||
|
@ -48,35 +46,35 @@ void PUIFileDialog::exec()
|
|||
NewGUI* gui = static_cast<NewGUI*>(globals->get_subsystem("gui"));
|
||||
std::string name("native-file-0");
|
||||
_dialogRoot = fgGetNode("/sim/gui/dialogs/" + name, true);
|
||||
|
||||
|
||||
SGPropertyNode_ptr dlg = _dialogRoot->getChild("dialog", 0, true);
|
||||
SGPath dlgXML = globals->resolve_resource_path("gui/dialogs/file-select.xml");
|
||||
readProperties(dlgXML, dlg);
|
||||
|
||||
|
||||
dlg->setStringValue("name", name);
|
||||
gui->newDialog(dlg);
|
||||
|
||||
|
||||
_dialogRoot->setStringValue("title", _title);
|
||||
_dialogRoot->setStringValue("button", _buttonText);
|
||||
_dialogRoot->setStringValue("directory", _initialPath.utf8Str());
|
||||
_dialogRoot->setStringValue("selection", _placeholder);
|
||||
|
||||
|
||||
// convert patterns vector into pattern nodes
|
||||
_dialogRoot->removeChildren("pattern");
|
||||
int index=0;
|
||||
BOOST_FOREACH(std::string pat, _filterPatterns) {
|
||||
for (const auto& pat : _filterPatterns) {
|
||||
_dialogRoot->getNode("pattern", index++, true)->setStringValue(pat);
|
||||
}
|
||||
|
||||
|
||||
_dialogRoot->setBoolValue("show-files", _usage != USE_CHOOSE_DIR);
|
||||
_dialogRoot->setBoolValue("dotfiles", _showHidden);
|
||||
|
||||
|
||||
if (!_listener) {
|
||||
_listener = new PathListener(this);
|
||||
}
|
||||
SGPropertyNode_ptr path = _dialogRoot->getNode("path", 0, true);
|
||||
path->addChangeListener(_listener);
|
||||
|
||||
|
||||
gui->showDialog(name);
|
||||
}
|
||||
|
||||
|
|
18
src/GUI/WindowsFileDialog.cxx
Normal file → Executable file
18
src/GUI/WindowsFileDialog.cxx
Normal file → Executable file
|
@ -5,8 +5,6 @@
|
|||
#include <windows.h>
|
||||
#include <Shlobj.h>
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
#include <osgViewer/Viewer>
|
||||
#include <osgViewer/api/Win32/GraphicsWindowWin32>
|
||||
|
||||
|
@ -32,12 +30,12 @@ HWND getMainViewerHWND()
|
|||
if (strcmp((*it)->className(), "GraphicsWindowWin32")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
osgViewer::GraphicsWindowWin32* platformWin =
|
||||
|
||||
osgViewer::GraphicsWindowWin32* platformWin =
|
||||
static_cast<osgViewer::GraphicsWindowWin32*>(*it);
|
||||
return platformWin->getHWND();
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -78,7 +76,7 @@ void WindowsFileDialog::exec()
|
|||
std::string extensions;
|
||||
size_t extensionsLen;
|
||||
if (!_filterPatterns.empty()) {
|
||||
BOOST_FOREACH(std::string ext, _filterPatterns) {
|
||||
for (const auto& ext : _filterPatterns) {
|
||||
if (!simgear::strutils::starts_with(ext, "*.")) {
|
||||
SG_LOG(SG_GENERAL, SG_ALERT, "WindowsFileDialog: can't use pattern on Windows:" << ext);
|
||||
continue;
|
||||
|
@ -89,14 +87,14 @@ void WindowsFileDialog::exec()
|
|||
opf.lpstrFilter = (LPCSTR) malloc(extensionsLen);
|
||||
memcpy((void*)opf.lpstrFilter, (void*)extensions.data(), extensionsLen);
|
||||
}
|
||||
|
||||
|
||||
std::string s = _initialPath.local8BitStr();
|
||||
opf.lpstrInitialDir = const_cast<char *>(s.c_str());
|
||||
|
||||
|
||||
if (_showHidden) {
|
||||
opf.Flags = OFN_PATHMUSTEXIST;
|
||||
}
|
||||
|
||||
|
||||
if (_usage == USE_SAVE_FILE) {
|
||||
if (GetSaveFileNameA(&opf)) {
|
||||
std::string stringPath(opf.lpstrFile);
|
||||
|
@ -144,4 +142,4 @@ void WindowsFileDialog::chooseDir()
|
|||
CoTaskMemFree(results);
|
||||
|
||||
_callback->onFileDialogDone(this, SGPath(pathBuf));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,6 @@
|
|||
#include "FGDeviceConfigurationMap.hxx"
|
||||
#include <Main/fg_props.hxx>
|
||||
#include <Scripting/NasalSys.hxx>
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
using simgear::PropertyList;
|
||||
|
||||
|
@ -102,7 +101,7 @@ void FGJoystickInput::_remove(bool all)
|
|||
// do not remove predefined joysticks info on reinit
|
||||
if (all || (!joy->predefined))
|
||||
js_nodes->removeChild("js", i);
|
||||
|
||||
|
||||
joy->plibJS.reset();
|
||||
joy->clearAxesAndButtons();
|
||||
}
|
||||
|
@ -121,7 +120,7 @@ void FGJoystickInput::init()
|
|||
jsJoystick * js = new jsJoystick(i);
|
||||
joysticks[i].plibJS.reset(js);
|
||||
joysticks[i].initializing = true;
|
||||
|
||||
|
||||
if (js->notWorking()) {
|
||||
SG_LOG(SG_INPUT, SG_DEBUG, "Joystick " << i << " not found");
|
||||
continue;
|
||||
|
@ -261,7 +260,7 @@ void FGJoystickInput::postinit()
|
|||
n_axis = num_node->getIntValue("unix", -1);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// Silently ignore platforms that are not specified within the
|
||||
// <number></number> section
|
||||
if (n_axis < 0) {
|
||||
|
@ -300,7 +299,7 @@ void FGJoystickInput::postinit()
|
|||
// Initialize the buttons.
|
||||
//
|
||||
PropertyList buttons = js_node->getChildren("button");
|
||||
BOOST_FOREACH( SGPropertyNode * button_node, buttons ) {
|
||||
for (auto button_node : buttons ) {
|
||||
size_t n_but = button_node->getIndex();
|
||||
|
||||
const SGPropertyNode * num_node = button_node->getChild("number");
|
||||
|
@ -339,7 +338,7 @@ void FGJoystickInput::updateJoystick(int index, FGJoystickInput::joystick* joy,
|
|||
bool pressed, last_state;
|
||||
bool axes_initialized;
|
||||
float delay;
|
||||
|
||||
|
||||
jsJoystick * js = joy->plibJS.get();
|
||||
if (js == 0 || js->notWorking()) {
|
||||
joysticks[index].initializing = true;
|
||||
|
@ -352,7 +351,7 @@ void FGJoystickInput::updateJoystick(int index, FGJoystickInput::joystick* joy,
|
|||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
js->read(&buttons, axis_values);
|
||||
if (js->notWorking()) { // If js is disconnected
|
||||
joysticks[index].initializing = true;
|
||||
|
@ -380,7 +379,7 @@ void FGJoystickInput::updateJoystick(int index, FGJoystickInput::joystick* joy,
|
|||
axes_initialized = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Update device status
|
||||
SGPropertyNode_ptr status = status_node->getChild("joystick", index, true);
|
||||
if (axes_initialized) {
|
||||
|
@ -388,16 +387,16 @@ void FGJoystickInput::updateJoystick(int index, FGJoystickInput::joystick* joy,
|
|||
status->getChild("axis", j, true)->setFloatValue(axis_values[j]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (int j = 0; j < MAX_JOYSTICK_BUTTONS; j++) {
|
||||
status->getChild("button", j, true)->setBoolValue((buttons & (1u << j)) > 0 );
|
||||
}
|
||||
|
||||
|
||||
// Fire bindings for the axes.
|
||||
if (axes_initialized) {
|
||||
for (int j = 0; j < joy->naxes; j++) {
|
||||
axis &a = joy->axes[j];
|
||||
|
||||
|
||||
// Do nothing if the axis position
|
||||
// is unchanged; only a change in
|
||||
// position fires the bindings.
|
||||
|
@ -408,7 +407,7 @@ void FGJoystickInput::updateJoystick(int index, FGJoystickInput::joystick* joy,
|
|||
for (unsigned int k = 0; k < a.bindings[KEYMOD_NONE].size(); k++)
|
||||
a.bindings[KEYMOD_NONE][k]->fire(axis_values[j]);
|
||||
}
|
||||
|
||||
|
||||
// do we have to emulate axis buttons?
|
||||
last_state = joy->axes[j].low.last_state || joy->axes[j].high.last_state;
|
||||
pressed = axis_values[j] < a.low_threshold || axis_values[j] > a.high_threshold;
|
||||
|
@ -418,15 +417,15 @@ void FGJoystickInput::updateJoystick(int index, FGJoystickInput::joystick* joy,
|
|||
if(a.last_dt >= delay) {
|
||||
if (a.low.bindings[modifiers].size())
|
||||
joy->axes[j].low.update( modifiers, axis_values[j] < a.low_threshold );
|
||||
|
||||
|
||||
if (a.high.bindings[modifiers].size())
|
||||
joy->axes[j].high.update( modifiers, axis_values[j] > a.high_threshold );
|
||||
|
||||
|
||||
a.last_dt -= delay;
|
||||
}
|
||||
} // of axes iteration
|
||||
} // axes_initialized
|
||||
|
||||
|
||||
// Fire bindings for the buttons.
|
||||
for (int j = 0; j < joy->nbuttons; j++) {
|
||||
FGButton &b = joy->buttons[j];
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
|
||||
#include "FGMouseInput.hxx"
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
#include <osgGA/GUIEventAdapter>
|
||||
|
||||
#include <simgear/scene/util/SGPickCallback.hxx>
|
||||
|
@ -72,7 +71,7 @@ void ActivePickCallbacks::init( int button, const osgGA::GUIEventAdapter* ea )
|
|||
{
|
||||
osg::Vec2d windowPos;
|
||||
flightgear::eventToWindowCoords(ea, windowPos.x(), windowPos.y());
|
||||
|
||||
|
||||
// Get the list of hit callbacks. Take the first callback that
|
||||
// accepts the mouse button press and ignore the rest of them
|
||||
// That is they get sorted by distance and by scenegraph depth.
|
||||
|
@ -166,7 +165,7 @@ public:
|
|||
tooltipTimeoutDone = false;
|
||||
hoverPickScheduled = false;
|
||||
tooltipsEnabled = false;
|
||||
|
||||
|
||||
fgGetNode("/sim/mouse/hide-cursor", true )->addChangeListener(this, true);
|
||||
fgGetNode("/sim/mouse/cursor-timeout-sec", true )->addChangeListener(this, true);
|
||||
fgGetNode("/sim/mouse/right-button-mode-cycle-enabled", true)->addChangeListener(this, true);
|
||||
|
@ -176,22 +175,22 @@ public:
|
|||
fgGetNode("/sim/mouse/drag-sensitivity", true)->addChangeListener(this, true);
|
||||
fgGetNode("/sim/mouse/invert-mouse-wheel", true)->addChangeListener(this, true);
|
||||
}
|
||||
|
||||
|
||||
void centerMouseCursor(mouse& m)
|
||||
{
|
||||
{
|
||||
// center the cursor
|
||||
m.x = (xSizeNode ? xSizeNode->getIntValue() : 800) / 2;
|
||||
m.y = (ySizeNode ? ySizeNode->getIntValue() : 600) / 2;
|
||||
fgWarpMouse(m.x, m.y);
|
||||
haveWarped = true;
|
||||
}
|
||||
|
||||
|
||||
void constrainMouse(int x, int y)
|
||||
{
|
||||
int new_x=x,new_y=y;
|
||||
int xsize = xSizeNode ? xSizeNode->getIntValue() : 800;
|
||||
int ysize = ySizeNode ? ySizeNode->getIntValue() : 600;
|
||||
|
||||
|
||||
bool need_warp = false;
|
||||
if (x <= (xsize * .25) || x >= (xsize * .75)) {
|
||||
new_x = int(xsize * .5);
|
||||
|
@ -215,7 +214,7 @@ public:
|
|||
hoverPickScheduled = true;
|
||||
hoverPos = windowPos;
|
||||
}
|
||||
|
||||
|
||||
void doHoverPick(const osg::Vec2d& windowPos)
|
||||
{
|
||||
FGMouseCursor::Cursor cur = FGMouseCursor::CURSOR_ARROW;
|
||||
|
@ -234,7 +233,7 @@ public:
|
|||
explicitCursor = true;
|
||||
cur = FGMouseCursor::cursorFromString(curName.c_str());
|
||||
}
|
||||
|
||||
|
||||
// if the callback is of higher prioirty (lower enum index),
|
||||
// record that.
|
||||
if (i->callback->getPriority() < priority) {
|
||||
|
@ -255,11 +254,11 @@ public:
|
|||
i->callback->mouseLeave(windowPos);
|
||||
}
|
||||
_previous_picks = pickList;
|
||||
|
||||
|
||||
if (!explicitCursor && (priority == SGPickCallback::PriorityPanel)) {
|
||||
cur = FGMouseCursor::CURSOR_HAND;
|
||||
}
|
||||
|
||||
|
||||
FGMouseCursor::instance()->setCursor(cur);
|
||||
if (!didPick) {
|
||||
SGPropertyNode_ptr args(new SGPropertyNode);
|
||||
|
@ -267,11 +266,11 @@ public:
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void doMouseMoveWithCallbacks(const osgGA::GUIEventAdapter* ea)
|
||||
{
|
||||
FGMouseCursor::Cursor cur = FGMouseCursor::CURSOR_CLOSED_HAND;
|
||||
|
||||
|
||||
osg::Vec2d windowPos;
|
||||
flightgear::eventToWindowCoords(ea, windowPos.x(), windowPos.y());
|
||||
|
||||
|
@ -319,25 +318,25 @@ public:
|
|||
tooltipsEnabled = node->getBoolValue();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ActivePickCallbacks activePickCallbacks;
|
||||
SGSceneryPicks _previous_picks;
|
||||
|
||||
mouse mice[MAX_MICE];
|
||||
|
||||
|
||||
bool hideCursor, haveWarped;
|
||||
bool tooltipTimeoutDone;
|
||||
bool clickTriggersTooltip;
|
||||
int tooltipDelayMsec, cursorTimeoutMsec;
|
||||
bool rightClickModeCycle;
|
||||
bool tooltipsEnabled;
|
||||
|
||||
|
||||
SGPropertyNode_ptr xSizeNode;
|
||||
SGPropertyNode_ptr ySizeNode;
|
||||
SGPropertyNode_ptr xAccelNode;
|
||||
SGPropertyNode_ptr yAccelNode;
|
||||
SGPropertyNode_ptr mouseXNode, mouseYNode;
|
||||
|
||||
|
||||
bool hoverPickScheduled;
|
||||
osg::Vec2d hoverPos;
|
||||
};
|
||||
|
@ -409,7 +408,7 @@ void FGMouseInput::init()
|
|||
|
||||
// Read the mouse cursor for this mode
|
||||
m.modes[j].cursor = FGMouseCursor::cursorFromString(mode_node->getStringValue("cursor", "inherit"));
|
||||
|
||||
|
||||
// Read other properties for this mode
|
||||
m.modes[j].constrained = mode_node->getBoolValue("constrained", false);
|
||||
m.modes[j].pass_through = mode_node->getBoolValue("pass-through", false);
|
||||
|
@ -425,7 +424,7 @@ void FGMouseInput::init()
|
|||
// Read the axis bindings for this mode
|
||||
read_bindings(mode_node->getChild("x-axis", 0, true), m.modes[j].x_bindings, KEYMOD_NONE, module );
|
||||
read_bindings(mode_node->getChild("y-axis", 0, true), m.modes[j].y_bindings, KEYMOD_NONE, module );
|
||||
|
||||
|
||||
if (mode_node->hasChild("x-axis-ctrl")) {
|
||||
read_bindings(mode_node->getChild("x-axis-ctrl"), m.modes[j].x_bindings, KEYMOD_CTRL, module );
|
||||
}
|
||||
|
@ -435,7 +434,7 @@ void FGMouseInput::init()
|
|||
if (mode_node->hasChild("x-axis-ctrl-shift")) {
|
||||
read_bindings(mode_node->getChild("x-axis-ctrl-shift"), m.modes[j].x_bindings, KEYMOD_CTRL|KEYMOD_SHIFT, module );
|
||||
}
|
||||
|
||||
|
||||
if (mode_node->hasChild("y-axis-ctrl")) {
|
||||
read_bindings(mode_node->getChild("y-axis-ctrl"), m.modes[j].y_bindings, KEYMOD_CTRL, module );
|
||||
}
|
||||
|
@ -474,14 +473,14 @@ void FGMouseInput::update ( double dt )
|
|||
if (!d) {
|
||||
SG_LOG(SG_INPUT, SG_WARN, "update of mouse before init");
|
||||
}
|
||||
|
||||
|
||||
mouse &m = d->mice[0];
|
||||
int mode = m.mode_node->getIntValue();
|
||||
if (mode != m.current_mode) {
|
||||
// current mode has changed
|
||||
m.current_mode = mode;
|
||||
m.timeSinceLastMove.stamp();
|
||||
|
||||
|
||||
if (mode >= 0 && mode < m.nModes) {
|
||||
FGMouseCursor::instance()->setCursor(m.modes[mode].cursor);
|
||||
d->centerMouseCursor(m);
|
||||
|
@ -495,7 +494,7 @@ void FGMouseInput::update ( double dt )
|
|||
d->doHoverPick(d->hoverPos);
|
||||
d->hoverPickScheduled = false;
|
||||
}
|
||||
|
||||
|
||||
if ( !d->tooltipTimeoutDone &&
|
||||
d->tooltipsEnabled &&
|
||||
(m.timeSinceLastMove.elapsedMSec() > d->tooltipDelayMsec))
|
||||
|
@ -504,14 +503,14 @@ void FGMouseInput::update ( double dt )
|
|||
SGPropertyNode_ptr arg(new SGPropertyNode);
|
||||
globals->get_commands()->execute("tooltip-timeout", arg, nullptr);
|
||||
}
|
||||
|
||||
|
||||
if ( d->hideCursor ) {
|
||||
if ( m.timeSinceLastMove.elapsedMSec() > d->cursorTimeoutMsec) {
|
||||
FGMouseCursor::instance()->hideCursorUntilMouseMove();
|
||||
m.timeSinceLastMove.stamp();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
d->activePickCallbacks.update( dt, fgGetKeyModifiers() );
|
||||
}
|
||||
|
||||
|
@ -538,7 +537,7 @@ void FGMouseInput::doMouseClick (int b, int updown, int x, int y, bool mainWindo
|
|||
// can occur during reset
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
int modifiers = fgGetKeyModifiers();
|
||||
|
||||
mouse &m = d->mice[0];
|
||||
|
@ -551,7 +550,7 @@ void FGMouseInput::doMouseClick (int b, int updown, int x, int y, bool mainWindo
|
|||
// in spring-loaded look mode, ignore right clicks entirely here
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Pass on to PUI and the panel if
|
||||
// requested, and return if one of
|
||||
// them consumes the event.
|
||||
|
@ -583,7 +582,7 @@ void FGMouseInput::doMouseClick (int b, int updown, int x, int y, bool mainWindo
|
|||
// scenegraph intersection point corresponding to the mouse click
|
||||
if (updown == MOUSE_BUTTON_DOWN) {
|
||||
d->activePickCallbacks.init( b, ea );
|
||||
|
||||
|
||||
if (d->clickTriggersTooltip) {
|
||||
SGPropertyNode_ptr args(new SGPropertyNode);
|
||||
args->setStringValue("reason", "click");
|
||||
|
@ -602,7 +601,7 @@ void FGMouseInput::doMouseClick (int b, int updown, int x, int y, bool mainWindo
|
|||
return;
|
||||
}
|
||||
|
||||
m.modes[m.current_mode].buttons[b].update( modifiers, 0 != updown, x, y);
|
||||
m.modes[m.current_mode].buttons[b].update( modifiers, 0 != updown, x, y);
|
||||
}
|
||||
|
||||
void FGMouseInput::processMotion(int x, int y, const osgGA::GUIEventAdapter* ea)
|
||||
|
@ -611,7 +610,7 @@ void FGMouseInput::processMotion(int x, int y, const osgGA::GUIEventAdapter* ea)
|
|||
d->doMouseMoveWithCallbacks(ea);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
mouse &m = d->mice[0];
|
||||
int modeIndex = m.current_mode;
|
||||
// are we in spring-loaded look mode?
|
||||
|
@ -629,9 +628,9 @@ void FGMouseInput::processMotion(int x, int y, const osgGA::GUIEventAdapter* ea)
|
|||
// mouse has moved, so we may need to issue tooltip-timeout command again
|
||||
d->tooltipTimeoutDone = false;
|
||||
}
|
||||
|
||||
|
||||
mouse_mode &mode = m.modes[modeIndex];
|
||||
|
||||
|
||||
if (d->haveWarped)
|
||||
{
|
||||
// don't fire mouse-movement events at the first update after warping the mouse,
|
||||
|
@ -643,7 +642,7 @@ void FGMouseInput::processMotion(int x, int y, const osgGA::GUIEventAdapter* ea)
|
|||
int modifiers = fgGetKeyModifiers();
|
||||
int xsize = d->xSizeNode ? d->xSizeNode->getIntValue() : 800;
|
||||
int ysize = d->ySizeNode ? d->ySizeNode->getIntValue() : 600;
|
||||
|
||||
|
||||
// OK, PUI didn't want the event,
|
||||
// so we can play with it.
|
||||
if (x != m.x) {
|
||||
|
@ -659,7 +658,7 @@ void FGMouseInput::processMotion(int x, int y, const osgGA::GUIEventAdapter* ea)
|
|||
mode.y_bindings[modifiers][i]->fire(double(delta), double(ysize));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Constrain the mouse if requested
|
||||
if (mode.constrained) {
|
||||
d->constrainMouse(x, y);
|
||||
|
@ -672,7 +671,7 @@ void FGMouseInput::doMouseMotion (int x, int y, const osgGA::GUIEventAdapter* ea
|
|||
// can occur during reset
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
mouse &m = d->mice[0];
|
||||
|
||||
if (m.current_mode < 0 || m.current_mode >= m.nModes) {
|
||||
|
@ -685,11 +684,11 @@ void FGMouseInput::doMouseMotion (int x, int y, const osgGA::GUIEventAdapter* ea
|
|||
FGMouseCursor::instance()->mouseMoved();
|
||||
|
||||
// TODO Get rid of this as soon as soon as cursor hide timeout works globally
|
||||
|
||||
|
||||
if (!ea->getHandled()) {
|
||||
processMotion(x, y, ea);
|
||||
}
|
||||
|
||||
|
||||
m.x = x;
|
||||
m.y = y;
|
||||
d->mouseXNode->setIntValue(x);
|
||||
|
@ -710,13 +709,13 @@ bool FGMouseInput::isActiveModePassThrough() const
|
|||
if (!d) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
mouse &m = d->mice[0];
|
||||
int mode = m.current_mode;
|
||||
if (isRightDragToLookEnabled() && m.mouse_button_nodes[2]->getBoolValue()) {
|
||||
mode = 3;
|
||||
}
|
||||
|
||||
|
||||
return m.modes[mode].pass_through;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#endif
|
||||
|
||||
#include <cstring> // for strcmp()
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
#include <simgear/debug/logstream.hxx>
|
||||
|
@ -61,25 +60,25 @@ FGAircraftModel::~FGAircraftModel ()
|
|||
shutdown();
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
FGAircraftModel::init ()
|
||||
{
|
||||
if (_aircraft.get()) {
|
||||
SG_LOG(SG_AIRCRAFT, SG_ALERT, "FGAircraftModel::init: already inited");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
SGPropertyNode_ptr sim = fgGetNode("/sim", true);
|
||||
BOOST_FOREACH(SGPropertyNode_ptr model, sim->getChildren("model")) {
|
||||
for (auto model : sim->getChildren("model")) {
|
||||
std::string path = model->getStringValue("path", "Models/Geometry/glider.ac");
|
||||
std::string usage = model->getStringValue("usage", "external");
|
||||
|
||||
|
||||
SGPath resolvedPath = globals->resolve_aircraft_path(path);
|
||||
if (resolvedPath.isNull()) {
|
||||
SG_LOG(SG_AIRCRAFT, SG_ALERT, "Failed to find aircraft model: " << path);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
osg::Node* node = NULL;
|
||||
try {
|
||||
node = fgLoad3DModelPanel( resolvedPath, globals->get_props());
|
||||
|
@ -87,7 +86,7 @@ FGAircraftModel::init ()
|
|||
SG_LOG(SG_AIRCRAFT, SG_ALERT, "Failed to load aircraft from " << path << ':');
|
||||
SG_LOG(SG_AIRCRAFT, SG_ALERT, " " << ex.getFormattedMessage());
|
||||
}
|
||||
|
||||
|
||||
if (usage == "interior") {
|
||||
// interior model
|
||||
if (!_interior.get()) {
|
||||
|
@ -106,7 +105,7 @@ FGAircraftModel::init ()
|
|||
}
|
||||
} // of model usage switch
|
||||
} // of models iteration
|
||||
|
||||
|
||||
// no models loaded, load the glider instead
|
||||
if (!_aircraft.get()) {
|
||||
SG_LOG(SG_AIRCRAFT, SG_ALERT, "(Falling back to glider.ac.)");
|
||||
|
@ -119,7 +118,7 @@ FGAircraftModel::init ()
|
|||
|
||||
osg::Node* node = _aircraft->getSceneGraph();
|
||||
globals->get_scenery()->get_aircraft_branch()->addChild(node);
|
||||
|
||||
|
||||
if (_interior.get()) {
|
||||
node = _interior->getSceneGraph();
|
||||
globals->get_scenery()->get_interior_branch()->addChild(node);
|
||||
|
@ -182,13 +181,13 @@ FGAircraftModel::update (double dt)
|
|||
} else {
|
||||
_aircraft->setVisible(true);
|
||||
}
|
||||
|
||||
|
||||
double heading, pitch, roll;
|
||||
globals->get_aircraft_orientation(heading, pitch, roll);
|
||||
SGQuatd orient = SGQuatd::fromYawPitchRollDeg(heading, pitch, roll);
|
||||
|
||||
|
||||
SGGeod pos = globals->get_aircraft_position();
|
||||
|
||||
|
||||
_aircraft->setPosition(pos);
|
||||
_aircraft->setOrientation(orient);
|
||||
_aircraft->update();
|
||||
|
@ -198,11 +197,11 @@ FGAircraftModel::update (double dt)
|
|||
_interior->setOrientation(orient);
|
||||
_interior->update();
|
||||
}
|
||||
|
||||
|
||||
// update model's audio sample values
|
||||
_fx->set_position_geod( pos );
|
||||
_fx->set_orientation( orient );
|
||||
|
||||
|
||||
_velocity = SGVec3d( _speed_n->getDoubleValue(),
|
||||
_speed_e->getDoubleValue(),
|
||||
_speed_d->getDoubleValue() );
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
#include "PolyLine.hxx"
|
||||
|
||||
#include <cassert>
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
#include <simgear/math/sg_geodesy.hxx>
|
||||
#include <simgear/structure/exception.hxx>
|
||||
|
@ -44,7 +43,7 @@ PolyLine::PolyLine(Type aTy, const SGGeodVec& aPoints) :
|
|||
|
||||
PolyLine::~PolyLine()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
unsigned int PolyLine::numPoints() const
|
||||
|
@ -64,17 +63,17 @@ PolyLineList PolyLine::createChunked(Type aTy, const SGGeodVec& aRawPoints)
|
|||
if (aRawPoints.size() < 2) {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
const double maxDistanceSquaredM = 40000 * 40000; // 40km to start with
|
||||
|
||||
|
||||
SGVec3d chunkStartCart = SGVec3d::fromGeod(aRawPoints.front());
|
||||
SGGeodVec chunk;
|
||||
SGGeodVec::const_iterator it = aRawPoints.begin();
|
||||
|
||||
|
||||
while (it != aRawPoints.end()) {
|
||||
SGVec3d ptCart = SGVec3d::fromGeod(*it);
|
||||
double d2 = distSqr(chunkStartCart, ptCart);
|
||||
|
||||
|
||||
// distance check, but also ensure we generate actual valid line segments.
|
||||
if ((chunk.size() >= 2) && (d2 > maxDistanceSquaredM)) {
|
||||
chunk.push_back(*it); // close the segment
|
||||
|
@ -82,17 +81,17 @@ PolyLineList PolyLine::createChunked(Type aTy, const SGGeodVec& aRawPoints)
|
|||
chunkStartCart = ptCart;
|
||||
chunk.clear();
|
||||
}
|
||||
|
||||
|
||||
chunk.push_back(*it++); // add to open chunk
|
||||
}
|
||||
|
||||
|
||||
// if we have a single trailing point, we already added it as the last
|
||||
// point of the previous chunk, so we're ok. Otherwise, create the
|
||||
// final chunk's polyline
|
||||
if (chunk.size() > 1) {
|
||||
result.push_back(new PolyLine(aTy, chunk));
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -136,7 +135,7 @@ public:
|
|||
SingleTypeFilter(PolyLine::Type aTy) :
|
||||
m_type(aTy)
|
||||
{ }
|
||||
|
||||
|
||||
virtual bool pass(PolyLine::Type aTy) const
|
||||
{ return (aTy == m_type); }
|
||||
private:
|
||||
|
@ -152,30 +151,28 @@ PolyLineList PolyLine::linesNearPos(const SGGeod& aPos, double aRangeNm, Type aT
|
|||
PolyLineList PolyLine::linesNearPos(const SGGeod& aPos, double aRangeNm, const TypeFilter& aFilter)
|
||||
{
|
||||
std::set<PolyLineRef> resultSet;
|
||||
|
||||
|
||||
SGVec3d cart = SGVec3d::fromGeod(aPos);
|
||||
double cutoffM = aRangeNm * SG_NM_TO_METER;
|
||||
Octree::FindLinesDeque deque;
|
||||
deque.push_back(Octree::global_spatialOctree);
|
||||
|
||||
|
||||
while (!deque.empty()) {
|
||||
Octree::Node* nd = deque.front();
|
||||
deque.pop_front();
|
||||
|
||||
|
||||
PolyLineList lines;
|
||||
nd->visitForLines(cart, cutoffM, lines, deque);
|
||||
|
||||
|
||||
// merge into result set, filtering as we go.
|
||||
BOOST_FOREACH(PolyLineRef ref, lines) {
|
||||
for (auto ref : lines) {
|
||||
if (aFilter.pass(ref->type())) {
|
||||
resultSet.insert(ref);
|
||||
}
|
||||
}
|
||||
} // of deque iteration
|
||||
|
||||
|
||||
PolyLineList result;
|
||||
result.insert(result.end(), resultSet.begin(), resultSet.end());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* PositionedOctree - define a spatial octree containing Positioned items
|
||||
* arranged by their global cartesian position.
|
||||
*/
|
||||
|
||||
|
||||
// Written by James Turner, started 2012.
|
||||
//
|
||||
// Copyright (C) 2012 James Turner
|
||||
|
@ -33,8 +33,6 @@
|
|||
#include <cstring> // for memset
|
||||
#include <iostream>
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
#include <simgear/debug/logstream.hxx>
|
||||
#include <simgear/structure/exception.hxx>
|
||||
#include <simgear/timing/timestamp.hxx>
|
||||
|
@ -44,7 +42,7 @@ namespace flightgear
|
|||
|
||||
namespace Octree
|
||||
{
|
||||
|
||||
|
||||
Node* global_spatialOctree = NULL;
|
||||
|
||||
|
||||
|
@ -73,7 +71,7 @@ Leaf::Leaf(const SGBoxd& aBox, int64_t aIdent) :
|
|||
childrenLoaded(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void Leaf::visit(const SGVec3d& aPos, double aCutoff,
|
||||
FGPositioned::Filter* aFilter,
|
||||
FindNearestResults& aResults, FindNearestPQueue&)
|
||||
|
@ -81,35 +79,35 @@ void Leaf::visit(const SGVec3d& aPos, double aCutoff,
|
|||
int previousResultsSize = aResults.size();
|
||||
int addedCount = 0;
|
||||
NavDataCache* cache = NavDataCache::instance();
|
||||
|
||||
|
||||
loadChildren();
|
||||
|
||||
|
||||
ChildMap::const_iterator it = children.lower_bound(aFilter->minType());
|
||||
ChildMap::const_iterator end = children.upper_bound(aFilter->maxType());
|
||||
|
||||
|
||||
for (; it != end; ++it) {
|
||||
FGPositioned* p = cache->loadById(it->second);
|
||||
double d = dist(aPos, p->cart());
|
||||
if (d > aCutoff) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (aFilter && !aFilter->pass(p)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
++addedCount;
|
||||
aResults.push_back(OrderedPositioned(p, d));
|
||||
}
|
||||
|
||||
|
||||
if (addedCount == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// keep aResults sorted
|
||||
// sort the new items, usually just one or two items
|
||||
std::sort(aResults.begin() + previousResultsSize, aResults.end());
|
||||
|
||||
|
||||
// merge the two sorted ranges together - in linear time
|
||||
std::inplace_merge(aResults.begin(),
|
||||
aResults.begin() + previousResultsSize, aResults.end());
|
||||
|
@ -120,23 +118,23 @@ void Leaf::insertChild(FGPositioned::Type ty, PositionedID id)
|
|||
assert(childrenLoaded);
|
||||
children.insert(children.end(), TypedPositioned(ty, id));
|
||||
}
|
||||
|
||||
|
||||
void Leaf::loadChildren()
|
||||
{
|
||||
if (childrenLoaded) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
NavDataCache* cache = NavDataCache::instance();
|
||||
BOOST_FOREACH(TypedPositioned tp, cache->getOctreeLeafChildren(guid())) {
|
||||
for (const auto& tp : cache->getOctreeLeafChildren(guid())) {
|
||||
children.insert(children.end(), tp);
|
||||
} // of leaf members iteration
|
||||
|
||||
|
||||
childrenLoaded = true;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
Branch::Branch(const SGBoxd& aBox, int64_t aIdent) :
|
||||
Node(aBox, aIdent),
|
||||
childrenLoaded(false)
|
||||
|
@ -153,16 +151,16 @@ void Branch::visit(const SGVec3d& aPos, double aCutoff,
|
|||
if (!children[i]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
double d = children[i]->distToNearest(aPos);
|
||||
if (d > aCutoff) {
|
||||
continue; // exceeded cutoff
|
||||
}
|
||||
|
||||
|
||||
aQ.push(Ordered<Node*>(children[i], d));
|
||||
} // of child iteration
|
||||
}
|
||||
|
||||
|
||||
void Branch::visitForLines(const SGVec3d& aPos, double aCutoff,
|
||||
PolyLineList& aLines,
|
||||
FindLinesDeque& aQ) const
|
||||
|
@ -174,12 +172,12 @@ void Branch::visitForLines(const SGVec3d& aPos, double aCutoff,
|
|||
if (!children[i]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
double d = children[i]->distToNearest(aPos);
|
||||
if (d > aCutoff) {
|
||||
continue; // exceeded cutoff
|
||||
}
|
||||
|
||||
|
||||
aQ.push_back(children[i]);
|
||||
} // of child iteration
|
||||
}
|
||||
|
@ -217,21 +215,21 @@ Node* Branch::childForPos(const SGVec3d& aCart) const
|
|||
{
|
||||
assert(contains(aCart));
|
||||
int childIndex = 0;
|
||||
|
||||
|
||||
SGVec3d center(_box.getCenter());
|
||||
// tests must match indices in SGbox::getCorner
|
||||
if (aCart.x() < center.x()) {
|
||||
childIndex += 1;
|
||||
}
|
||||
|
||||
|
||||
if (aCart.y() < center.y()) {
|
||||
childIndex += 2;
|
||||
}
|
||||
|
||||
|
||||
if (aCart.z() < center.z()) {
|
||||
childIndex += 4;
|
||||
}
|
||||
|
||||
|
||||
return childAtIndex(childIndex);
|
||||
}
|
||||
|
||||
|
@ -241,21 +239,21 @@ Node* Branch::childAtIndex(int childIndex) const
|
|||
if (!child) { // lazy building of children
|
||||
SGBoxd cb(boxForChild(childIndex));
|
||||
double d2 = dot(cb.getSize(), cb.getSize());
|
||||
|
||||
|
||||
assert(((_ident << 3) >> 3) == _ident);
|
||||
|
||||
|
||||
// child index is 0..7, so 3-bits is sufficient, and hence we can
|
||||
// pack 20 levels of octree into a int64, which is plenty
|
||||
int64_t childIdent = (_ident << 3) | childIndex;
|
||||
|
||||
|
||||
if (d2 < LEAF_SIZE_SQR) {
|
||||
child = new Leaf(cb, childIdent);
|
||||
} else {
|
||||
child = new Branch(cb, childIdent);
|
||||
}
|
||||
|
||||
|
||||
children[childIndex] = child;
|
||||
|
||||
|
||||
if (childrenLoaded) {
|
||||
// childrenLoad is done, so we're defining a new node - add it to the
|
||||
// cache too.
|
||||
|
@ -265,25 +263,25 @@ Node* Branch::childAtIndex(int childIndex) const
|
|||
|
||||
return children[childIndex];
|
||||
}
|
||||
|
||||
|
||||
void Branch::loadChildren() const
|
||||
{
|
||||
if (childrenLoaded) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
int childrenMask = NavDataCache::instance()->getOctreeBranchChildren(guid());
|
||||
for (int i=0; i<8; ++i) {
|
||||
if ((1 << i) & childrenMask) {
|
||||
childAtIndex(i); // accessing will create!
|
||||
}
|
||||
} // of child index iteration
|
||||
|
||||
|
||||
// set this after creating the child nodes, so the cache update logic
|
||||
// in childAtIndex knows any future created children need to be added.
|
||||
childrenLoaded = true;
|
||||
}
|
||||
|
||||
|
||||
int Branch::childMask() const
|
||||
{
|
||||
int result = 0;
|
||||
|
@ -292,7 +290,7 @@ int Branch::childMask() const
|
|||
result |= 1 << i;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -306,7 +304,7 @@ bool findNearestN(const SGVec3d& aPos, unsigned int aN, double aCutoffM, FGPosit
|
|||
|
||||
SGTimeStamp tm;
|
||||
tm.stamp();
|
||||
|
||||
|
||||
while (!pq.empty() && (tm.elapsedMSec() < aCutoffMsec)) {
|
||||
if (!results.empty()) {
|
||||
// terminate the search if we have sufficent results, and we are
|
||||
|
@ -318,10 +316,10 @@ bool findNearestN(const SGVec3d& aPos, unsigned int aN, double aCutoffM, FGPosit
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Node* nd = pq.top().get();
|
||||
pq.pop();
|
||||
|
||||
|
||||
nd->visit(aPos, cut, aFilter, results, pq);
|
||||
} // of queue iteration
|
||||
|
||||
|
@ -333,7 +331,7 @@ bool findNearestN(const SGVec3d& aPos, unsigned int aN, double aCutoffM, FGPosit
|
|||
for (unsigned int r=0; r<numResults; ++r) {
|
||||
aResults[r] = results[r].get();
|
||||
}
|
||||
|
||||
|
||||
return !pq.empty();
|
||||
}
|
||||
|
||||
|
@ -347,11 +345,11 @@ bool findAllWithinRange(const SGVec3d& aPos, double aRangeM, FGPositioned::Filte
|
|||
|
||||
SGTimeStamp tm;
|
||||
tm.stamp();
|
||||
|
||||
|
||||
while (!pq.empty() && (tm.elapsedMSec() < aCutoffMsec)) {
|
||||
Node* nd = pq.top().get();
|
||||
pq.pop();
|
||||
|
||||
|
||||
nd->visit(aPos, rng, aFilter, results, pq);
|
||||
} // of queue iteration
|
||||
|
||||
|
@ -361,10 +359,10 @@ bool findAllWithinRange(const SGVec3d& aPos, double aRangeM, FGPositioned::Filte
|
|||
for (unsigned int r=0; r<numResults; ++r) {
|
||||
aResults[r] = results[r].get();
|
||||
}
|
||||
|
||||
|
||||
return !pq.empty();
|
||||
}
|
||||
|
||||
|
||||
} // of namespace Octree
|
||||
|
||||
} // of namespace flightgear
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
#endif
|
||||
|
||||
#include <cassert>
|
||||
#include <boost/foreach.hpp>
|
||||
#include <algorithm>
|
||||
|
||||
#include <simgear/debug/logstream.hxx>
|
||||
|
@ -48,7 +47,7 @@ class NavRecordDistanceSortPredicate
|
|||
public:
|
||||
NavRecordDistanceSortPredicate( const SGGeod & position ) :
|
||||
_position(SGVec3d::fromGeod(position)) {}
|
||||
|
||||
|
||||
bool operator()( const nav_rec_ptr & n1, const nav_rec_ptr & n2 )
|
||||
{
|
||||
if( n1 == NULL || n2 == NULL ) return false;
|
||||
|
@ -56,7 +55,7 @@ public:
|
|||
}
|
||||
private:
|
||||
SGVec3d _position;
|
||||
|
||||
|
||||
};
|
||||
|
||||
// discount navids if they conflict with another on the same frequency
|
||||
|
@ -68,15 +67,15 @@ bool navidUsable(FGNavRecord* aNav, const SGGeod &aircraft)
|
|||
if (!r || !r->reciprocalRunway()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// check if the runway frequency is paired
|
||||
FGNavRecord* locA = r->ILS();
|
||||
FGNavRecord* locB = r->reciprocalRunway()->ILS();
|
||||
|
||||
|
||||
if (!locA || !locB || (locA->get_freq() != locB->get_freq())) {
|
||||
return true; // not paired, ok
|
||||
}
|
||||
|
||||
|
||||
// okay, both ends have an ILS, and they're paired. We need to select based on
|
||||
// aircraft position. What we're going to use is *runway* (not navid) position,
|
||||
// ie whichever runway end we are closer too. This makes back-course / missed
|
||||
|
@ -86,7 +85,7 @@ bool navidUsable(FGNavRecord* aNav, const SGGeod &aircraft)
|
|||
SG_NORMALIZE_RANGE(hdgDiff, -180.0, 180.0);
|
||||
return (fabs(hdgDiff) < 90.0);
|
||||
}
|
||||
|
||||
|
||||
} // of anonymous namespace
|
||||
|
||||
// FGNavList ------------------------------------------------------------------
|
||||
|
@ -141,13 +140,13 @@ public:
|
|||
TypeFilter(FGPositioned::DME, FGPositioned::TACAN)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
virtual bool pass(FGPositioned* pos) const
|
||||
{
|
||||
if (pos->type() == FGPositioned::TACAN) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
assert(pos->type() == FGPositioned::DME);
|
||||
string::size_type loc1 = pos->name().find( "TACAN" );
|
||||
string::size_type loc2 = pos->name().find( "VORTAC" );
|
||||
|
@ -195,30 +194,30 @@ FGNavRecordRef FGNavList::findByFreq( double freq,
|
|||
if (stations.empty()) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
// now walk the (sorted) results list to find a usable, in-range navaid
|
||||
SGVec3d acCart(SGVec3d::fromGeod(position));
|
||||
double min_dist
|
||||
= FG_NAV_MAX_RANGE*SG_NM_TO_METER*FG_NAV_MAX_RANGE*SG_NM_TO_METER;
|
||||
|
||||
BOOST_FOREACH(PositionedID id, stations) {
|
||||
|
||||
for (auto id : stations) {
|
||||
FGNavRecordRef station = FGPositioned::loadById<FGNavRecord>(id);
|
||||
if (filter && !filter->pass(station)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
double d2 = distSqr(station->cart(), acCart);
|
||||
if (d2 > min_dist) {
|
||||
// since results are sorted by proximity, as soon as we pass the
|
||||
// distance cutoff we're done - fall out and return NULL
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (navidUsable(station, position)) {
|
||||
return station;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// fell out of the loop, no usable match
|
||||
return NULL;
|
||||
}
|
||||
|
@ -232,7 +231,7 @@ FGNavRecordRef FGNavList::findByFreq(double freq, TypeFilter* filter)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
BOOST_FOREACH(PositionedID id, stations) {
|
||||
for (auto id : stations) {
|
||||
FGNavRecordRef station = FGPositioned::loadById<FGNavRecord>(id);
|
||||
if (filter->pass(station)) {
|
||||
return station;
|
||||
|
@ -246,13 +245,13 @@ nav_list_type FGNavList::findAllByFreq( double freq, const SGGeod& position,
|
|||
TypeFilter* filter)
|
||||
{
|
||||
nav_list_type stations;
|
||||
|
||||
|
||||
flightgear::NavDataCache* cache = flightgear::NavDataCache::instance();
|
||||
// note this frequency is passed in 'database units', which depend on the
|
||||
// type of navaid being requested
|
||||
int f = static_cast<int>(freq * 100 + 0.5);
|
||||
PositionedIDVec ids(cache->findNavaidsByFreq(f, position, filter));
|
||||
|
||||
|
||||
for (PositionedID id : ids) {
|
||||
FGNavRecordRef station = FGPositioned::loadById<FGNavRecord>(id);
|
||||
if (!filter->pass(station)) {
|
||||
|
@ -261,7 +260,7 @@ nav_list_type FGNavList::findAllByFreq( double freq, const SGGeod& position,
|
|||
|
||||
stations.push_back(station);
|
||||
}
|
||||
|
||||
|
||||
return stations;
|
||||
}
|
||||
|
||||
|
@ -270,9 +269,9 @@ nav_list_type FGNavList::findByIdentAndFreq(const string& ident, const double fr
|
|||
{
|
||||
nav_list_type reply;
|
||||
int f = (int)(freq*100.0 + 0.5);
|
||||
|
||||
|
||||
FGPositionedList stations = FGPositioned::findAllWithIdent(ident, filter);
|
||||
BOOST_FOREACH(FGPositionedRef ref, stations) {
|
||||
for (auto ref : stations) {
|
||||
FGNavRecord* nav = static_cast<FGNavRecord*>(ref.ptr());
|
||||
if ( f <= 0.0 || nav->get_freq() == f) {
|
||||
reply.push_back( nav );
|
||||
|
@ -349,5 +348,3 @@ FGTACANRecord *FGTACANList::findByChannel( const string& channel )
|
|||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// SwiftAircraft.cpp - Class representing an aircraft generated by swift
|
||||
//
|
||||
// SwiftAircraft.cpp - Class representing an aircraft generated by swift
|
||||
//
|
||||
// Copyright (C) 2019 - swift Project Community / Contributors (http://swift-project.org/)
|
||||
// Adapted to Flightgear by Lars Toenning <dev@ltoenning.de>
|
||||
//
|
||||
|
@ -21,7 +21,6 @@
|
|||
|
||||
#include <simgear/compiler.h>
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
#include <string>
|
||||
|
||||
#include <osg/Node>
|
||||
|
@ -100,18 +99,18 @@ FGSwiftAircraft::~FGSwiftAircraft()
|
|||
}
|
||||
|
||||
double FGSwiftAircraft::getLatDeg() const
|
||||
{
|
||||
{
|
||||
return position.getLatitudeDeg();
|
||||
}
|
||||
|
||||
double FGSwiftAircraft::getLongDeg() const
|
||||
{
|
||||
{
|
||||
return position.getLongitudeDeg();
|
||||
}
|
||||
|
||||
double FGSwiftAircraft::getFudgeFactor() const
|
||||
{
|
||||
return 0;
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline bool FGSwiftAircraft::operator<(const std::string& extCallsign)
|
||||
|
@ -129,5 +128,5 @@ double FGSwiftAircraft::getGroundElevation(const SGGeod& pos) const
|
|||
posReq.setLongitudeDeg(pos.getLongitudeDeg());
|
||||
globals->get_scenery()->get_elevation_m(posReq,alt,0,_model.get());
|
||||
return alt;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
#include <algorithm>
|
||||
#include <functional>
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/algorithm/string/case_conv.hpp>
|
||||
|
||||
#include <simgear/misc/ListDiff.hxx>
|
||||
|
|
|
@ -36,7 +36,6 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
#include <simgear/sg_inlines.h>
|
||||
|
@ -85,12 +84,12 @@ FGAISchedule::FGAISchedule(const string& model,
|
|||
const string& port,
|
||||
const string& reg,
|
||||
const string& flightId,
|
||||
bool hvy,
|
||||
bool hvy,
|
||||
const string& act,
|
||||
const string& arln,
|
||||
const string& mclass,
|
||||
const string& fltpe,
|
||||
double rad,
|
||||
double rad,
|
||||
double grnd)
|
||||
: heavy(hvy),
|
||||
radius(rad),
|
||||
|
@ -106,8 +105,8 @@ FGAISchedule::FGAISchedule(const string& model,
|
|||
valid(true),
|
||||
scheduleComplete(false)
|
||||
{
|
||||
modelPath = model;
|
||||
livery = lvry;
|
||||
modelPath = model;
|
||||
livery = lvry;
|
||||
homePort = port;
|
||||
registration = reg;
|
||||
flightIdentifier = flightId;
|
||||
|
@ -166,7 +165,7 @@ FGAISchedule::~FGAISchedule()
|
|||
delete (*flt);
|
||||
}
|
||||
flights.clear();*/
|
||||
}
|
||||
}
|
||||
|
||||
bool FGAISchedule::init()
|
||||
{
|
||||
|
@ -176,10 +175,10 @@ bool FGAISchedule::init()
|
|||
//tm *temp = currTimeDate->getGmt();
|
||||
//char buffer[512];
|
||||
//sgTimeFormatTime(&targetTimeDate, buffer);
|
||||
//cout << "Scheduled Time " << buffer << endl;
|
||||
//cout << "Scheduled Time " << buffer << endl;
|
||||
//cout << "Time :" << time(NULL) << " SGTime : " << sgTimeGetGMT(temp) << endl;
|
||||
/*for (FGScheduledFlightVecIterator i = flights.begin();
|
||||
i != flights.end();
|
||||
/*for (FGScheduledFlightVecIterator i = flights.begin();
|
||||
i != flights.end();
|
||||
i++)
|
||||
{
|
||||
//i->adjustTime(now);
|
||||
|
@ -189,7 +188,7 @@ bool FGAISchedule::init()
|
|||
//sort(flights.begin(), flights.end());
|
||||
// Since time isn't initialized yet when this function is called,
|
||||
// Find the closest possible airport.
|
||||
// This should give a reasonable initialization order.
|
||||
// This should give a reasonable initialization order.
|
||||
//setClosestDistanceToUser();
|
||||
return true;
|
||||
}
|
||||
|
@ -227,23 +226,23 @@ bool FGAISchedule::update(time_t now, const SGVec3d& userCart)
|
|||
|
||||
// Sort all the scheduled flights according to scheduled departure time.
|
||||
// Because this is done at every update, we only need to check the status
|
||||
// of the first listed flight.
|
||||
// of the first listed flight.
|
||||
//sort(flights.begin(), flights.end(), compareScheduledFlights);
|
||||
|
||||
|
||||
if (firstRun) {
|
||||
if (fgGetBool("/sim/traffic-manager/instantaneous-action") == true) {
|
||||
deptime = now; // + rand() % 300; // Wait up to 5 minutes until traffic starts moving to prevent too many aircraft
|
||||
deptime = now; // + rand() % 300; // Wait up to 5 minutes until traffic starts moving to prevent too many aircraft
|
||||
// from cluttering the gate areas.
|
||||
}
|
||||
firstRun = false;
|
||||
}
|
||||
|
||||
|
||||
FGScheduledFlight* flight = flights.front();
|
||||
if (!deptime) {
|
||||
deptime = flight->getDepartureTime();
|
||||
//cerr << "Setting departure time " << deptime << endl;
|
||||
}
|
||||
|
||||
|
||||
if (aiAircraft) {
|
||||
if (aiAircraft->getDie()) {
|
||||
aiAircraft = NULL;
|
||||
|
@ -251,25 +250,25 @@ bool FGAISchedule::update(time_t now, const SGVec3d& userCart)
|
|||
return true; // in visual range, let the AIManager handle it
|
||||
}
|
||||
}
|
||||
|
||||
// This flight entry is entirely in the past, do we need to
|
||||
// push it forward in time to the next scheduled departure.
|
||||
|
||||
// This flight entry is entirely in the past, do we need to
|
||||
// push it forward in time to the next scheduled departure.
|
||||
if (flight->getArrivalTime() < now) {
|
||||
SG_LOG (SG_AI, SG_BULK, "Traffic Manager: Flight is in the Past");
|
||||
// Don't just update: check whether we need to load a new leg. etc.
|
||||
// This update occurs for distant aircraft, so we can update the current leg
|
||||
// and detach it from the current list of aircraft.
|
||||
// and detach it from the current list of aircraft.
|
||||
flight->update();
|
||||
flights.erase(flights.begin()); // pop_front(), effectively
|
||||
return true; // processing complete
|
||||
}
|
||||
|
||||
|
||||
FGAirport* dep = flight->getDepartureAirport();
|
||||
FGAirport* arr = flight->getArrivalAirport();
|
||||
if (!dep || !arr) {
|
||||
return true; // processing complete
|
||||
}
|
||||
|
||||
|
||||
double speed = 450.0;
|
||||
if (dep != arr) {
|
||||
totalTimeEnroute = flight->getArrivalTime() - flight->getDepartureTime();
|
||||
|
@ -277,16 +276,16 @@ bool FGAISchedule::update(time_t now, const SGVec3d& userCart)
|
|||
elapsedTimeEnroute = now - flight->getDepartureTime();
|
||||
//remainingTimeEnroute = totalTimeEnroute - elapsedTimeEnroute;
|
||||
double x = elapsedTimeEnroute / (double) totalTimeEnroute;
|
||||
|
||||
|
||||
// current pos is based on great-circle course between departure/arrival,
|
||||
// with percentage of distance travelled, based upon percentage of time
|
||||
// enroute elapsed.
|
||||
double course, az2, distanceM;
|
||||
SGGeodesy::inverse(dep->geod(), arr->geod(), course, az2, distanceM);
|
||||
double coveredDistance = distanceM * x;
|
||||
|
||||
|
||||
SGGeodesy::direct(dep->geod(), course, coveredDistance, position, az2);
|
||||
|
||||
|
||||
SG_LOG (SG_AI, SG_BULK, "Traffic Manager: Flight is in progress, %=" << x);
|
||||
speed = ((distanceM - coveredDistance) * SG_METER_TO_NM) / 3600.0;
|
||||
} else {
|
||||
|
@ -303,7 +302,7 @@ bool FGAISchedule::update(time_t now, const SGVec3d& userCart)
|
|||
elapsedTimeEnroute = 0;
|
||||
position = dep->geod();
|
||||
}
|
||||
|
||||
|
||||
// cartesian calculations are more numerically stable over the (potentially)
|
||||
// large distances involved here: see bug #80
|
||||
distanceToUser = dist(userCart, SGVec3d::fromGeod(position)) * SG_METER_TO_NM;
|
||||
|
@ -314,7 +313,7 @@ bool FGAISchedule::update(time_t now, const SGVec3d& userCart)
|
|||
// one hour flight time, so that would be a good approximate point
|
||||
// to start a more detailed simulation of this aircraft.
|
||||
SG_LOG (SG_AI, SG_BULK, "Traffic manager: " << registration << " is scheduled for a flight from "
|
||||
<< dep->getId() << " to " << arr->getId() << ". Current distance to user: "
|
||||
<< dep->getId() << " to " << arr->getId() << ". Current distance to user: "
|
||||
<< distanceToUser);
|
||||
if (distanceToUser >= TRAFFICTOAIDISTTOSTART) {
|
||||
return true; // out of visual range, for the moment.
|
||||
|
@ -335,15 +334,15 @@ bool FGAISchedule::validModelPath(const std::string& modelPath)
|
|||
|
||||
SGPath FGAISchedule::resolveModelPath(const std::string& modelPath)
|
||||
{
|
||||
BOOST_FOREACH(SGPath aiPath, globals->get_data_paths("AI")) {
|
||||
for (auto aiPath : globals->get_data_paths("AI")) {
|
||||
aiPath.append(modelPath);
|
||||
if (aiPath.exists()) {
|
||||
return aiPath;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// check aircraft dirs
|
||||
BOOST_FOREACH(SGPath aircraftPath, globals->get_aircraft_paths()) {
|
||||
for (auto aircraftPath : globals->get_aircraft_paths()) {
|
||||
SGPath mp = aircraftPath / modelPath;
|
||||
if (mp.exists()) {
|
||||
return mp;
|
||||
|
@ -371,14 +370,14 @@ bool FGAISchedule::createAIAircraft(FGScheduledFlight* flight, double speedKnots
|
|||
aiAircraft->setAltitude(flight->getCruiseAlt()*100); // convert from FL to feet
|
||||
aiAircraft->setSpeed(0);
|
||||
aiAircraft->setBank(0);
|
||||
|
||||
|
||||
courseToDest = SGGeodesy::courseDeg(position, arr->geod());
|
||||
std::unique_ptr<FGAIFlightPlan> fp(new FGAIFlightPlan(aiAircraft, flightPlanName, courseToDest, deptime,
|
||||
dep, arr, true, radius,
|
||||
flight->getCruiseAlt()*100,
|
||||
position.getLatitudeDeg(),
|
||||
position.getLongitudeDeg(),
|
||||
speedKnots, flightType, acType,
|
||||
dep, arr, true, radius,
|
||||
flight->getCruiseAlt()*100,
|
||||
position.getLatitudeDeg(),
|
||||
position.getLongitudeDeg(),
|
||||
speedKnots, flightType, acType,
|
||||
airline));
|
||||
if (fp->isValidPlan()) {
|
||||
aiAircraft->FGAIBase::setFlightPlan(std::move(fp));
|
||||
|
@ -390,7 +389,7 @@ bool FGAISchedule::createAIAircraft(FGScheduledFlight* flight, double speedKnots
|
|||
nodeForAircraft->getChild("departure-time-sec", 0, true)->setIntValue(deptime);
|
||||
}
|
||||
if (arr) {
|
||||
nodeForAircraft->getChild("arrival-airport-id", 0, true)->setStringValue(arr->getId());
|
||||
nodeForAircraft->getChild("arrival-airport-id", 0, true)->setStringValue(arr->getId());
|
||||
// arrival time not known here
|
||||
}
|
||||
}
|
||||
|
@ -407,8 +406,8 @@ bool FGAISchedule::createAIAircraft(FGScheduledFlight* flight, double speedKnots
|
|||
}
|
||||
|
||||
// Create an initial heading for user controlled aircraft.
|
||||
void FGAISchedule::setHeading()
|
||||
{
|
||||
void FGAISchedule::setHeading()
|
||||
{
|
||||
courseToDest = SGGeodesy::courseDeg((*flights.begin())->getDepartureAirport()->geod(), (*flights.begin())->getArrivalAirport()->geod());
|
||||
}
|
||||
|
||||
|
@ -449,7 +448,7 @@ bool FGAISchedule::scheduleFlights(time_t now)
|
|||
//runCount++;
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
|
||||
time_t arr, dep;
|
||||
dep = flight->getDepartureTime();
|
||||
arr = flight->getArrivalTime();
|
||||
|
@ -462,7 +461,7 @@ bool FGAISchedule::scheduleFlights(time_t now)
|
|||
<< " " << depT << ":"
|
||||
<< " \"" << flight->getArrivalAirport()->getId() << "\"" << ":"
|
||||
<< " " << arrT << ":");
|
||||
|
||||
|
||||
flights.push_back(flight);
|
||||
|
||||
// continue processing until complete, or preempt after timeout
|
||||
|
@ -485,12 +484,12 @@ bool FGAISchedule::next()
|
|||
flights.front()->release();
|
||||
flights.erase(flights.begin());
|
||||
}
|
||||
|
||||
|
||||
FGScheduledFlight *flight = findAvailableFlight(currentDestination, flightIdentifier);
|
||||
if (!flight) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
currentDestination = flight->getArrivalAirport()->getId();
|
||||
/*
|
||||
time_t arr, dep;
|
||||
|
@ -501,7 +500,7 @@ bool FGAISchedule::next()
|
|||
|
||||
depT = depT.substr(0,24);
|
||||
arrT = arrT.substr(0,24);
|
||||
//cerr << " " << flight->getCallSign() << ":"
|
||||
//cerr << " " << flight->getCallSign() << ":"
|
||||
// << " " << flight->getDepartureAirport()->getId() << ":"
|
||||
// << " " << depT << ":"
|
||||
// << " \"" << flight->getArrivalAirport()->getId() << "\"" << ":"
|
||||
|
@ -618,7 +617,7 @@ FGScheduledFlight* FGAISchedule::findAvailableFlight (const string ¤tDesti
|
|||
}
|
||||
|
||||
// So, if we actually get here, we have a winner
|
||||
//cerr << "found flight: " << req << " : " << currentDestination << " : " <<
|
||||
//cerr << "found flight: " << req << " : " << currentDestination << " : " <<
|
||||
// (*i)->getArrivalAirport()->getId() << endl;
|
||||
(*i)->lock();
|
||||
return (*i);
|
||||
|
@ -634,7 +633,7 @@ FGScheduledFlight* FGAISchedule::findAvailableFlight (const string ¤tDesti
|
|||
|
||||
int FGAISchedule::groundTimeFromRadius()
|
||||
{
|
||||
if (radius < 10)
|
||||
if (radius < 10)
|
||||
return 15 * 60;
|
||||
else if (radius < 15)
|
||||
return 20 * 60;
|
||||
|
@ -644,7 +643,7 @@ int FGAISchedule::groundTimeFromRadius()
|
|||
return 50 * 60;
|
||||
else if (radius < 30)
|
||||
return 90 * 60;
|
||||
else
|
||||
else
|
||||
return 120 * 60;
|
||||
}
|
||||
|
||||
|
@ -652,22 +651,22 @@ int FGAISchedule::groundTimeFromRadius()
|
|||
double FGAISchedule::getSpeed()
|
||||
{
|
||||
FGScheduledFlightVecIterator i = flights.begin();
|
||||
|
||||
|
||||
FGAirport* dep = (*i)->getDepartureAirport(),
|
||||
*arr = (*i)->getArrivalAirport();
|
||||
double dist = SGGeodesy::distanceNm(dep->geod(), arr->geod());
|
||||
double remainingTimeEnroute = (*i)->getArrivalTime() - (*i)->getDepartureTime();
|
||||
|
||||
double speed = 0.0;
|
||||
if (remainingTimeEnroute > 0.01)
|
||||
if (remainingTimeEnroute > 0.01)
|
||||
speed = dist / (remainingTimeEnroute/3600.0);
|
||||
|
||||
SG_CLAMP_RANGE(speed, 300.0, 500.0);
|
||||
return speed;
|
||||
}
|
||||
|
||||
void FGAISchedule::setScore ()
|
||||
{
|
||||
void FGAISchedule::setScore ()
|
||||
{
|
||||
if (runCount) {
|
||||
score = ((double) hits / (double) runCount);
|
||||
} else {
|
||||
|
@ -681,15 +680,14 @@ void FGAISchedule::setScore ()
|
|||
}
|
||||
|
||||
bool compareSchedules(FGAISchedule*a, FGAISchedule*b)
|
||||
{
|
||||
return (*a) < (*b);
|
||||
}
|
||||
{
|
||||
return (*a) < (*b);
|
||||
}
|
||||
|
||||
bool FGAISchedule::operator< (const FGAISchedule &other) const
|
||||
{
|
||||
{
|
||||
//cerr << "Sorting " << registration << " and " << other.registration << endl;
|
||||
double currentScore = score * (1.5 - lastRun);
|
||||
double otherScore = other.score * (1.5 - other.lastRun);
|
||||
return currentScore > otherScore;
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,6 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
#include <simgear/misc/sg_path.hxx>
|
||||
|
@ -130,7 +129,7 @@ public:
|
|||
|
||||
virtual void run()
|
||||
{
|
||||
BOOST_FOREACH(SGPath p, _trafficDirPaths) {
|
||||
for (const auto& p : _trafficDirPaths) {
|
||||
parseTrafficDir(p);
|
||||
if (_cancelThread) {
|
||||
return;
|
||||
|
@ -378,11 +377,11 @@ private:
|
|||
simgear::Dir trafficDir(path);
|
||||
simgear::PathList d = trafficDir.children(simgear::Dir::TYPE_DIR | simgear::Dir::NO_DOT_OR_DOTDOT);
|
||||
|
||||
BOOST_FOREACH(SGPath p, d) {
|
||||
for (const auto& p : d) {
|
||||
simgear::Dir d2(p);
|
||||
SG_LOG(SG_AI, SG_DEBUG, "parsing traffic in:" << p);
|
||||
simgear::PathList trafficFiles = d2.children(simgear::Dir::TYPE_FILE, ".xml");
|
||||
BOOST_FOREACH(SGPath xml, trafficFiles) {
|
||||
for (const auto& xml : trafficFiles) {
|
||||
readXML(xml, *this);
|
||||
if (_cancelThread) {
|
||||
return;
|
||||
|
@ -481,7 +480,7 @@ void FGTrafficManager::shutdown()
|
|||
}
|
||||
}
|
||||
|
||||
BOOST_FOREACH(FGAISchedule* acft, scheduledAircraft) {
|
||||
for (auto acft : scheduledAircraft) {
|
||||
if (saveData) {
|
||||
cachefile << acft->getRegistration() << " "
|
||||
<< acft->getRunCount() << " "
|
||||
|
@ -602,7 +601,7 @@ void FGTrafficManager::finishInit()
|
|||
loadHeuristics();
|
||||
PerformanceDB* perfDB = globals->get_subsystem<PerformanceDB>();
|
||||
// Do sorting and scoring separately, to take advantage of the "homeport" variable
|
||||
BOOST_FOREACH(FGAISchedule* schedule, scheduledAircraft) {
|
||||
for (auto schedule : scheduledAircraft) {
|
||||
schedule->setScore();
|
||||
if (!perfDB->havePerformanceDataForAircraftType(schedule->getAircraft())) {
|
||||
SG_LOG(SG_AI, SG_DEV_WARN, "AI-Traffic: schedule aircraft missing performance data:" << schedule->getAircraft());
|
||||
|
|
|
@ -33,8 +33,6 @@
|
|||
#include <vector>
|
||||
#include <typeinfo>
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
#include <osg/ref_ptr>
|
||||
#include <osg/AlphaFunc>
|
||||
#include <osg/BlendFunc>
|
||||
|
|
|
@ -33,8 +33,6 @@
|
|||
#include <vector>
|
||||
#include <typeinfo>
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
#include <osg/ref_ptr>
|
||||
#include <osg/AlphaFunc>
|
||||
#include <osg/BlendFunc>
|
||||
|
@ -753,7 +751,7 @@ void attachBufferToCamera( CameraInfo* info, osg::Camera* camera, osg::Camera::B
|
|||
}
|
||||
|
||||
void buildAttachments(CameraInfo* info, osg::Camera* camera, const std::string& name, const std::vector<ref_ptr<FGRenderingPipeline::Attachment> > &attachments) {
|
||||
BOOST_FOREACH(ref_ptr<FGRenderingPipeline::Attachment> attachment, attachments) {
|
||||
for (auto attachment : attachments) {
|
||||
if (attachment->valid())
|
||||
attachBufferToCamera( info, camera, attachment->component, name, attachment->buffer );
|
||||
}
|
||||
|
@ -1069,7 +1067,7 @@ FGRenderer::buildDeferredLightingCamera( flightgear::CameraInfo* info, osg::Grap
|
|||
|
||||
osg::Switch* lightingGroup = new osg::Switch;
|
||||
|
||||
BOOST_FOREACH( osg::ref_ptr<FGRenderingPipeline::Pass> pass, stage->passes ) {
|
||||
for (auto pass : stage->passes ) {
|
||||
ref_ptr<Node> node = buildPass(info, pass);
|
||||
if (node.valid()) {
|
||||
lightingGroup->addChild(node);
|
||||
|
|
Loading…
Add table
Reference in a new issue