Ref T180, formatting / const

This commit is contained in:
Klaus Basan
2017-11-01 03:12:58 +01:00
parent a23ccb5ac7
commit d5bb1733f4
17 changed files with 203 additions and 231 deletions

View File

@@ -67,11 +67,11 @@ namespace BlackCore
void ISimulator::emitSimulatorCombinedStatus(SimulatorStatus oldStatus)
{
const SimulatorStatus newStatus = getSimulatorStatus();
const SimulatorStatus newStatus = this->getSimulatorStatus();
if (oldStatus != newStatus)
{
// decouple, follow up of signal can include unloading
// simulator so this should happen asyncronously (which is like forcing Qt::QueuedConnection)
// simulator so this should happen strictly asyncronously (which is like forcing Qt::QueuedConnection)
QTimer::singleShot(0, this, [ = ]
{
emit this->simulatorStatusChanged(newStatus);
@@ -85,7 +85,7 @@ namespace BlackCore
this->setObjectName("ISimulatorListener:" + info.toQString());
// stop listener after it reports simulator ready
bool s = connect(this, &ISimulatorListener::simulatorStarted, this, &ISimulatorListener::stop, Qt::QueuedConnection);
const bool s = connect(this, &ISimulatorListener::simulatorStarted, this, &ISimulatorListener::stop, Qt::QueuedConnection);
Q_ASSERT_X(s, Q_FUNC_INFO, "connect failed");
Q_UNUSED(s)
}
@@ -104,13 +104,13 @@ namespace BlackCore
{
if (m_isRunning) { return; }
m_isRunning = true;
startImpl();
this->startImpl();
}
void ISimulatorListener::stop()
{
if (!m_isRunning) { return; }
stopImpl();
this->stopImpl();
m_isRunning = false;
}

View File

@@ -70,8 +70,8 @@ namespace BlackCore
// timer
connect(&m_oneSecondTimer, &QTimer::timeout, this, &CSimulatorCommon::oneSecondTimerTimeout);
this->m_oneSecondTimer.setObjectName(this->objectName().append(":m_oneSecondTimer"));
this->m_oneSecondTimer.start(1000);
m_oneSecondTimer.setObjectName(this->objectName().append(":m_oneSecondTimer"));
m_oneSecondTimer.start(1000);
// swift data
if (sApp && sApp->hasWebDataServices())
@@ -213,14 +213,14 @@ namespace BlackCore
void CSimulatorCommon::debugLogMessage(const QString &msg) const
{
if (!showDebugLogMessage()) { return; }
if (!this->showDebugLogMessage()) { return; }
if (msg.isEmpty()) { return; }
CLogMessage(this).info(msg);
}
void CSimulatorCommon::debugLogMessage(const QString &funcInfo, const QString &msg) const
{
if (!showDebugLogMessage()) { return; }
if (!this->showDebugLogMessage()) { return; }
if (msg.isEmpty()) { return; }
CLogMessage(this).info("%1 %2") << msg << funcInfo;
}

View File

@@ -75,11 +75,11 @@ namespace BlackGui
ui(new Ui::CLoginComponent)
{
ui->setupUi(this);
this->m_logoffCountdownTimer = new QTimer(this);
this->m_logoffCountdownTimer->setObjectName("CLoginComponent:m_logoffCountdownTimer");
m_logoffCountdownTimer = new QTimer(this);
m_logoffCountdownTimer->setObjectName("CLoginComponent:m_logoffCountdownTimer");
ui->pb_LogoffTimeout->setMaximum(LogoffIntervalSeconds);
ui->pb_LogoffTimeout->setValue(LogoffIntervalSeconds);
connect(this->m_logoffCountdownTimer, &QTimer::timeout, this, &CLoginComponent::logoffCountdown);
connect(m_logoffCountdownTimer, &QTimer::timeout, this, &CLoginComponent::logoffCountdown);
ui->selector_AircraftIcao->displayWithIcaoDescription(false);
ui->selector_AirlineIcao->displayWithIcaoDescription(false);
@@ -154,7 +154,7 @@ namespace BlackGui
this->validateAircraftValues();
this->validateVatsimValues();
this->onWebServiceDataRead(CEntityFlags::VatsimDataFile, CEntityFlags::ReadFinished, -1);
CServerList otherServers(this->m_otherTrafficNetworkServers.getThreadLocal());
CServerList otherServers(m_otherTrafficNetworkServers.getThreadLocal());
// add a testserver when no servers can be loaded
if (otherServers.isEmpty() && (sGui->isRunningInDeveloperEnvironment() || CBuildConfig::isDevBranch()))
@@ -176,12 +176,12 @@ namespace BlackGui
void CLoginComponent::mainInfoAreaChanged(const QWidget *currentWidget)
{
this->m_logoffCountdownTimer->stop(); // in any case stop the timer
m_logoffCountdownTimer->stop(); // in any case stop the timer
if (currentWidget != this && currentWidget != this->parentWidget())
{
const bool wasVisible = this->m_visible;
this->m_visible = false;
this->m_logoffCountdownTimer->stop();
const bool wasVisible = m_visible;
m_visible = false;
m_logoffCountdownTimer->stop();
if (wasVisible)
{
@@ -192,7 +192,7 @@ namespace BlackGui
else
{
this->setOwnModelAndIcaoValues();
if (this->m_visible)
if (m_visible)
{
// already visible:
// re-trigger! treat as same as OK
@@ -200,7 +200,7 @@ namespace BlackGui
}
else
{
this->m_visible = true;
m_visible = true;
const bool isConnected = sGui->getIContextNetwork()->isConnected();
this->setGuiVisibility(isConnected);
this->setOkButtonString(isConnected);
@@ -211,7 +211,7 @@ namespace BlackGui
void CLoginComponent::loginCancelled()
{
this->m_logoffCountdownTimer->stop();
m_logoffCountdownTimer->stop();
ui->pb_LogoffTimeout->setValue(LogoffIntervalSeconds);
emit this->loginOrLogoffCancelled();
}
@@ -293,8 +293,8 @@ namespace BlackGui
if (msg.isSuccess() && vatsimLogin)
{
Q_ASSERT_X(currentServer.isValidForLogin(), Q_FUNC_INFO, "invalid server");
this->m_currentVatsimServer.set(currentServer);
this->m_currentAircraftModel.setAndSave(ownAircraft.getModel());
m_currentVatsimServer.set(currentServer);
m_currentAircraftModel.setAndSave(ownAircraft.getModel());
}
}
else
@@ -334,7 +334,7 @@ namespace BlackGui
CServerList vatsimFsdServers = sGui->getIContextNetwork()->getVatsimFsdServers();
if (vatsimFsdServers.isEmpty()) { return; }
vatsimFsdServers.sortBy(&CServer::getName);
const CServer currentServer = this->m_currentVatsimServer.get();
const CServer currentServer = m_currentVatsimServer.get();
ui->comp_VatsimServer->setServers(vatsimFsdServers, true);
ui->comp_VatsimServer->preSelect(currentServer.getName());
}
@@ -346,7 +346,7 @@ namespace BlackGui
void CLoginComponent::loadRememberedVatsimData()
{
const CServer lastServer = this->m_currentVatsimServer.get();
const CServer lastServer = m_currentVatsimServer.get();
const CUser lastUser = lastServer.getUser();
if (lastUser.hasValidCallsign())
{
@@ -429,8 +429,8 @@ namespace BlackGui
void CLoginComponent::startLogoffTimerCountdown()
{
ui->pb_LogoffTimeout->setValue(LogoffIntervalSeconds);
this->m_logoffCountdownTimer->setInterval(1000);
this->m_logoffCountdownTimer->start();
m_logoffCountdownTimer->setInterval(1000);
m_logoffCountdownTimer->start();
}
void CLoginComponent::setOwnModelAndIcaoValues()
@@ -474,7 +474,7 @@ namespace BlackGui
const bool changedOwnAircraftIcaoValues = this->updateOwnAircaftIcaoValuesFromGuiValues();
if (changedOwnAircraftIcaoValues || changedOwnAircraftCallsignPilot)
{
this->m_changedLoginDataDigestSignal.inputSignal();
m_changedLoginDataDigestSignal.inputSignal();
}
}
@@ -560,7 +560,7 @@ namespace BlackGui
void CLoginComponent::reloadSettings()
{
CServerList otherServers(this->m_otherTrafficNetworkServers.getThreadLocal());
CServerList otherServers(m_otherTrafficNetworkServers.getThreadLocal());
ui->comp_OtherServers->setServers(otherServers);
}
@@ -572,7 +572,7 @@ namespace BlackGui
ui->pb_LogoffTimeout->setValue(v);
if (v <= 0)
{
this->m_logoffCountdownTimer->stop();
m_logoffCountdownTimer->stop();
this->toggleNetworkConnection();
}
}
@@ -598,7 +598,7 @@ namespace BlackGui
this->setOwnModelAndIcaoValues();
// open dialog for model mapping
if (this->m_autoPopupWizard && !model.isLoadedFromDb())
if (m_autoPopupWizard && !model.isLoadedFromDb())
{
this->mappingWizard();
}
@@ -607,29 +607,29 @@ namespace BlackGui
this->updateOwnAircraftCallsignAndPilotFromGuiValues();
// let others know data changed
this->m_changedLoginDataDigestSignal.inputSignal();
m_changedLoginDataDigestSignal.inputSignal();
}
void CLoginComponent::mappingWizard()
{
if (!this->m_mappingWizard)
if (!m_mappingWizard)
{
this->m_mappingWizard.reset(new CDbQuickMappingWizard(this));
m_mappingWizard.reset(new CDbQuickMappingWizard(this));
}
if (sGui->getIContextSimulator()->isSimulatorAvailable())
{
// preset on model
const CAircraftModel model(sGui->getIContextOwnAircraft()->getOwnAircraft().getModel());
this->m_mappingWizard->presetModel(model);
m_mappingWizard->presetModel(model);
}
else
{
// preset on GUI values only
const CAircraftIcaoCode icao(ui->selector_AircraftIcao->getAircraftIcao());
this->m_mappingWizard->presetAircraftIcao(icao);
m_mappingWizard->presetAircraftIcao(icao);
}
this->m_mappingWizard->show();
m_mappingWizard->show();
}
void CLoginComponent::toggleTimeout()
@@ -691,7 +691,7 @@ namespace BlackGui
CAircraftModel CLoginComponent::getPrefillModel() const
{
CAircraftModel model = this->m_currentAircraftModel.get();
CAircraftModel model = m_currentAircraftModel.get();
if (model.hasAircraftDesignator()) { return model; }
return IContextOwnAircraft::getDefaultOwnAircraftModel();
}

View File

@@ -31,7 +31,7 @@ namespace BlackGui
void CServerListSelector::setServers(const BlackMisc::Network::CServerList &servers, bool nameIsCountry)
{
if (this->m_servers == servers) { return; }
if (m_servers == servers) { return; }
this->setServerItems(servers, nameIsCountry);
if (!servers.isEmpty() && !m_pendingPreselect.isEmpty())
{
@@ -70,8 +70,8 @@ namespace BlackGui
{
QString currentlySelected(this->currentText());
int index = -1;
this->m_servers = servers;
this->m_items.clear();
m_servers = servers;
m_items.clear();
this->clear(); // ui
nameToCountry = nameToCountry && knowsAllCountries();
@@ -86,7 +86,7 @@ namespace BlackGui
if (nameToCountry)
{
const CCountry country(findCountry(server));
const CCountry country(this->findCountry(server));
if (country.getName().isEmpty())
{
this->addItem(d);
@@ -103,8 +103,8 @@ namespace BlackGui
}
// reselect
if (this->m_items.isEmpty()) { return; }
if (this->m_items.size() == 1)
if (m_items.isEmpty()) { return; }
if (m_items.size() == 1)
{
this->setCurrentIndex(0);
}
@@ -121,7 +121,7 @@ namespace BlackGui
CCountry CServerListSelector::findCountry(const CServer &server)
{
if (!knowsAllCountries()) { return CCountry(); }
if (!CServerListSelector::knowsAllCountries()) { return CCountry(); }
static const CCountryList countries(sGui->getWebDataServices()->getCountries());
return countries.findBestMatchByCountryName(server.getName());
}

View File

@@ -95,9 +95,10 @@ namespace BlackMisc
{
if (name.isEmpty() || m_name.isEmpty()) { return false; }
if (caseInsensitiveStringCompare(name, this->getDbKey())) { return true; } // exact ISO match
if (caseInsensitiveStringCompare(name, this->getIso3Code())) { return true; } // exact ISO match
if (caseInsensitiveStringCompare(name, this->getIso3Code())) { return true; } // exact ISO3 match
if (name.length() < 5)
{
// contains would be too fuzzy for short names
return caseInsensitiveStringCompare(name, m_name) || caseInsensitiveStringCompare(name, m_simplifiedName);
}
else

View File

@@ -37,7 +37,7 @@ namespace BlackMisc
thread_local const QRegularExpression reg("^[a-z]+", QRegularExpression::CaseInsensitiveOption);
QRegularExpressionMatch match = reg.match(countryName);
const QString cn(match.hasMatch() ? match.captured(0) : countryName);
CCountryList countries = this->findBy([&](const CCountry & country)
const CCountryList countries = this->findBy([&](const CCountry & country)
{
return country.matchesCountryName(cn);
});

View File

@@ -28,7 +28,7 @@ namespace BlackMisc
QString CCoordinateGeodetic::convertToQString(bool i18n) const
{
static const QString s = "Geodetic: {%1, %2, %3}";
return s.arg(this->latitude().valueRoundedWithUnit(6, i18n), this->longitude().valueRoundedWithUnit(6, i18n), this->m_geodeticHeight.valueRoundedWithUnit(6, i18n));
return s.arg(this->latitude().valueRoundedWithUnit(6, i18n), this->longitude().valueRoundedWithUnit(6, i18n), m_geodeticHeight.valueRoundedWithUnit(6, i18n));
}
CCoordinateGeodetic CCoordinateGeodetic::fromWgs84(const QString &latitudeWgs84, const QString &longitudeWgs84, const CAltitude &geodeticHeight)
@@ -81,7 +81,7 @@ namespace BlackMisc
bool ICoordinateGeodetic::canHandleIndex(const CPropertyIndex &index)
{
int i = index.frontCasted<int>();
const int i = index.frontCasted<int>();
return (i >= static_cast<int>(IndexLatitude)) && (i <= static_cast<int>(IndexNormalVector));
}
@@ -92,22 +92,14 @@ namespace BlackMisc
const ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i)
{
case IndexLatitude:
return this->latitude().propertyByIndex(index.copyFrontRemoved());
case IndexLongitude:
return this->longitude().propertyByIndex(index.copyFrontRemoved());
case IndexLatitudeAsString:
return CVariant(this->latitudeAsString());
case IndexLongitudeAsString:
return CVariant(this->longitudeAsString());
case IndexGeodeticHeight:
return this->geodeticHeight().propertyByIndex(index.copyFrontRemoved());
case IndexGeodeticHeightAsString:
return CVariant(this->geodeticHeightAsString());
case IndexNormalVector:
return CVariant::fromValue(this->normalVector());
default:
break;
case IndexLatitude: return this->latitude().propertyByIndex(index.copyFrontRemoved());
case IndexLongitude: return this->longitude().propertyByIndex(index.copyFrontRemoved());
case IndexLatitudeAsString: return CVariant(this->latitudeAsString());
case IndexLongitudeAsString: return CVariant(this->longitudeAsString());
case IndexGeodeticHeight: return this->geodeticHeight().propertyByIndex(index.copyFrontRemoved());
case IndexGeodeticHeightAsString: return CVariant(this->geodeticHeightAsString());
case IndexNormalVector: return CVariant::fromValue(this->normalVector());
default: break;
}
}
@@ -123,20 +115,13 @@ namespace BlackMisc
const ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i)
{
case IndexLatitude:
return this->latitude().comparePropertyByIndex(index.copyFrontRemoved(), compareValue.latitude());
case IndexLongitude:
return this->longitude().comparePropertyByIndex(index.copyFrontRemoved(), compareValue.longitude());
case IndexLatitudeAsString:
return this->latitudeAsString().compare(compareValue.latitudeAsString());
case IndexLongitudeAsString:
return this->longitudeAsString().compare(compareValue.longitudeAsString());
case IndexGeodeticHeight:
return this->geodeticHeight().comparePropertyByIndex(index.copyFrontRemoved(), compareValue.geodeticHeight());
case IndexGeodeticHeightAsString:
return this->geodeticHeightAsString().compare(compareValue.geodeticHeightAsString());
default:
break;
case IndexLatitude: return this->latitude().comparePropertyByIndex(index.copyFrontRemoved(), compareValue.latitude());
case IndexLongitude: return this->longitude().comparePropertyByIndex(index.copyFrontRemoved(), compareValue.longitude());
case IndexLatitudeAsString: return this->latitudeAsString().compare(compareValue.latitudeAsString());
case IndexLongitudeAsString: return this->longitudeAsString().compare(compareValue.longitudeAsString());
case IndexGeodeticHeight: return this->geodeticHeight().comparePropertyByIndex(index.copyFrontRemoved(), compareValue.geodeticHeight());
case IndexGeodeticHeightAsString: return this->geodeticHeightAsString().compare(compareValue.geodeticHeightAsString());
default: break;
}
}
@@ -173,7 +158,7 @@ namespace BlackMisc
switch (i)
{
case IndexGeodeticHeight:
this->m_geodeticHeight.setPropertyByIndex(index.copyFrontRemoved(), variant);
m_geodeticHeight.setPropertyByIndex(index.copyFrontRemoved(), variant);
break;
case IndexLatitude:
this->setLatitude(variant.value<CLatitude>());
@@ -188,7 +173,7 @@ namespace BlackMisc
this->setLongitude(CLongitude::fromWgs84(variant.toQString()));
break;
case IndexGeodeticHeightAsString:
this->m_geodeticHeight.parseFromString(variant.toQString());
m_geodeticHeight.parseFromString(variant.toQString());
break;
case IndexNormalVector:
this->setNormalVector(variant.value<QVector3D>());
@@ -226,6 +211,7 @@ namespace BlackMisc
CLongitude CCoordinateGeodetic::longitude() const
{
// in mathematics atan2 of 0,0 is undefined, with IEEE floating-point atan2(0,0) is either 0 or ±180°
return { std::atan2(m_y, m_x), PhysicalQuantities::CAngleUnit::rad() };
}
@@ -233,15 +219,15 @@ namespace BlackMisc
{
return
{
static_cast<float>(this->m_x),
static_cast<float>(this->m_y),
static_cast<float>(this->m_z)
static_cast<float>(m_x),
static_cast<float>(m_y),
static_cast<float>(m_z)
};
}
std::array<double, 3> CCoordinateGeodetic::normalVectorDouble() const
{
return { { this->m_x, this->m_y, this->m_z } };
return { { m_x, m_y, m_z } };
}
void CCoordinateGeodetic::setLatitude(const CLatitude &latitude)
@@ -256,28 +242,28 @@ namespace BlackMisc
void CCoordinateGeodetic::setLatLong(const CLatitude &latitude, const CLongitude &longitude)
{
this->m_x = latitude.cos() * longitude.cos();
this->m_y = latitude.cos() * longitude.sin();
this->m_z = latitude.sin();
m_x = latitude.cos() * longitude.cos();
m_y = latitude.cos() * longitude.sin();
m_z = latitude.sin();
}
CCoordinateGeodetic &CCoordinateGeodetic::switchUnit(const CLengthUnit &unit)
{
this->m_geodeticHeight.switchUnit(unit);
m_geodeticHeight.switchUnit(unit);
return *this;
}
CLength ICoordinateWithRelativePosition::calculcateAndUpdateRelativeDistance(const ICoordinateGeodetic &position)
{
this->m_relativeDistance = Geo::calculateGreatCircleDistance(*this, position);
return this->m_relativeDistance;
m_relativeDistance = Geo::calculateGreatCircleDistance(*this, position);
return m_relativeDistance;
}
CLength ICoordinateWithRelativePosition::calculcateAndUpdateRelativeDistanceAndBearing(const ICoordinateGeodetic &position)
{
this->m_relativeDistance = Geo::calculateGreatCircleDistance(*this, position);
this->m_relativeBearing = Geo::calculateBearing(*this, position);
return this->m_relativeDistance;
m_relativeDistance = Geo::calculateGreatCircleDistance(*this, position);
m_relativeBearing = Geo::calculateBearing(*this, position);
return m_relativeDistance;
}
CVariant ICoordinateWithRelativePosition::propertyByIndex(const CPropertyIndex &index) const
@@ -288,12 +274,9 @@ namespace BlackMisc
const ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i)
{
case IndexRelativeBearing:
return this->getRelativeBearing().propertyByIndex(index.copyFrontRemoved());
case IndexRelativeDistance:
return this->getRelativeDistance().propertyByIndex(index.copyFrontRemoved());
default:
break;
case IndexRelativeBearing: return this->getRelativeBearing().propertyByIndex(index.copyFrontRemoved());
case IndexRelativeDistance: return this->getRelativeDistance().propertyByIndex(index.copyFrontRemoved());
default: break;
}
}
const QString m = QString("no property, index ").append(index.toQString());
@@ -310,10 +293,10 @@ namespace BlackMisc
switch (i)
{
case IndexRelativeBearing:
this->m_relativeBearing.setPropertyByIndex(index.copyFrontRemoved(), variant);
m_relativeBearing.setPropertyByIndex(index.copyFrontRemoved(), variant);
break;
case IndexRelativeDistance:
this->m_relativeDistance.setPropertyByIndex(index.copyFrontRemoved(), variant);
m_relativeDistance.setPropertyByIndex(index.copyFrontRemoved(), variant);
break;
default:
const QString m = QString("no property, index ").append(index.toQString());
@@ -331,10 +314,8 @@ namespace BlackMisc
const ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i)
{
case IndexRelativeBearing:
return this->m_relativeBearing.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getRelativeBearing());
case IndexRelativeDistance:
return this->m_relativeDistance.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getRelativeDistance());
case IndexRelativeBearing: return m_relativeBearing.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getRelativeBearing());
case IndexRelativeDistance: return m_relativeDistance.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getRelativeDistance());
default:
const QString m = QString("no property, index ").append(index.toQString());
Q_ASSERT_X(false, Q_FUNC_INFO, m.toLocal8Bit().constData());
@@ -357,7 +338,7 @@ namespace BlackMisc
bool ICoordinateWithRelativePosition::canHandleIndex(const CPropertyIndex &index)
{
if (ICoordinateGeodetic::canHandleIndex(index)) { return true; }
int i = index.frontCasted<int>();
const int i = index.frontCasted<int>();
return (i >= static_cast<int>(IndexRelativeDistance)) && (i <= static_cast<int>(IndexRelativeBearing));
}
} // namespace

View File

@@ -45,7 +45,7 @@ namespace BlackMisc
//! Properties by index
enum ColumnIndex
{
IndexLatitude = BlackMisc::CPropertyIndex::GlobalIndexICoordinateGeodetic,
IndexLatitude = CPropertyIndex::GlobalIndexICoordinateGeodetic,
IndexLongitude,
IndexLatitudeAsString,
IndexLongitudeAsString,
@@ -72,7 +72,7 @@ namespace BlackMisc
//! By a similar convention, "elevation" is commonly used for objects that are fixed to the ground.
//! \sa see http://www.gmat.unsw.edu.au/snap/gps/clynch_pdfs/coordcvt.pdf page 5
//! \sa http://www.esri.com/news/arcuser/0703/geoid1of3.html
virtual const BlackMisc::Aviation::CAltitude &geodeticHeight() const = 0;
virtual const Aviation::CAltitude &geodeticHeight() const = 0;
//! Normal vector
//! \note QVector3D uses floats, so don't use if double precision is needed
@@ -92,31 +92,34 @@ namespace BlackMisc
//! Height as string
QString geodeticHeightAsString() const { return this->geodeticHeight().toQString(true); }
//! Geodetic height null?
bool isGeodeticHeightNull() { return this->geodeticHeight().isNull(); }
//! Great circle distance
BlackMisc::PhysicalQuantities::CLength calculateGreatCircleDistance(const ICoordinateGeodetic &otherCoordinate) const;
PhysicalQuantities::CLength calculateGreatCircleDistance(const ICoordinateGeodetic &otherCoordinate) const;
//! Initial bearing
BlackMisc::PhysicalQuantities::CAngle calculateBearing(const ICoordinateGeodetic &otherCoordinate) const;
PhysicalQuantities::CAngle calculateBearing(const ICoordinateGeodetic &otherCoordinate) const;
//! \copydoc BlackMisc::Mixin::Index::propertyByIndex
CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const;
//! \copydoc Mixin::Index::propertyByIndex
CVariant propertyByIndex(const CPropertyIndex &index) const;
//! Compare by index
int comparePropertyByIndex(const CPropertyIndex &index, const ICoordinateGeodetic &compareValue) const;
//! \copydoc BlackMisc::Mixin::String::toQString
//! \copydoc Mixin::String::toQString
QString convertToQString(bool i18n = false) const;
protected:
//! Can given index be handled?
static bool canHandleIndex(const BlackMisc::CPropertyIndex &index);
static bool canHandleIndex(const CPropertyIndex &index);
};
//! Great circle distance between points
BLACKMISC_EXPORT BlackMisc::PhysicalQuantities::CLength calculateGreatCircleDistance(const ICoordinateGeodetic &coordinate1, const ICoordinateGeodetic &coordinate2);
BLACKMISC_EXPORT PhysicalQuantities::CLength calculateGreatCircleDistance(const ICoordinateGeodetic &coordinate1, const ICoordinateGeodetic &coordinate2);
//! Initial bearing
BLACKMISC_EXPORT BlackMisc::PhysicalQuantities::CAngle calculateBearing(const ICoordinateGeodetic &coordinate1, const ICoordinateGeodetic &coordinate2);
BLACKMISC_EXPORT PhysicalQuantities::CAngle calculateBearing(const ICoordinateGeodetic &coordinate1, const ICoordinateGeodetic &coordinate2);
//! Euclidean distance between normal vectors
BLACKMISC_EXPORT double calculateEuclideanDistance(const ICoordinateGeodetic &coordinate1, const ICoordinateGeodetic &coordinate2);
@@ -131,44 +134,44 @@ namespace BlackMisc
//! Properties by index
enum ColumnIndex
{
IndexRelativeDistance = BlackMisc::CPropertyIndex::GlobalIndexICoordinateWithRelativePosition,
IndexRelativeDistance = CPropertyIndex::GlobalIndexICoordinateWithRelativePosition,
IndexRelativeBearing
};
//! Get the distance
const BlackMisc::PhysicalQuantities::CLength &getRelativeDistance() const { return m_relativeDistance; }
const PhysicalQuantities::CLength &getRelativeDistance() const { return m_relativeDistance; }
//! Set relative distance
void setRelativeDistance(const BlackMisc::PhysicalQuantities::CLength &distance) { this->m_relativeDistance = distance; }
void setRelativeDistance(const PhysicalQuantities::CLength &distance) { m_relativeDistance = distance; }
//! Get the relative bearing
const BlackMisc::PhysicalQuantities::CAngle &getRelativeBearing() const { return m_relativeBearing; }
const PhysicalQuantities::CAngle &getRelativeBearing() const { return m_relativeBearing; }
//! Set bearing to own plane
void setRelativeBearing(const BlackMisc::PhysicalQuantities::CAngle &angle) { this->m_relativeBearing = angle; }
void setRelativeBearing(const PhysicalQuantities::CAngle &angle) { m_relativeBearing = angle; }
//! Valid distance?
bool hasValidRelativeDistance() const { return !this->m_relativeDistance.isNull();}
bool hasValidRelativeDistance() const { return !m_relativeDistance.isNull();}
//! Valid bearing?
bool hasValidRelativeBearing() const { return !this->m_relativeBearing.isNull();}
bool hasValidRelativeBearing() const { return !m_relativeBearing.isNull();}
//! Calculcate distance, set it, and return distance
BlackMisc::PhysicalQuantities::CLength calculcateAndUpdateRelativeDistance(const BlackMisc::Geo::ICoordinateGeodetic &position);
PhysicalQuantities::CLength calculcateAndUpdateRelativeDistance(const Geo::ICoordinateGeodetic &position);
//! Calculcate distance and bearing to plane, set it, and return distance
BlackMisc::PhysicalQuantities::CLength calculcateAndUpdateRelativeDistanceAndBearing(const BlackMisc::Geo::ICoordinateGeodetic &position);
PhysicalQuantities::CLength calculcateAndUpdateRelativeDistanceAndBearing(const Geo::ICoordinateGeodetic &position);
//! \copydoc BlackMisc::Mixin::Index::propertyByIndex
CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const;
//! \copydoc Mixin::Index::propertyByIndex
CVariant propertyByIndex(const CPropertyIndex &index) const;
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
void setPropertyByIndex(const BlackMisc::CPropertyIndex &index, const CVariant &variant);
//! \copydoc Mixin::Index::setPropertyByIndex
void setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant);
//! Compare by index
int comparePropertyByIndex(const CPropertyIndex &index, const ICoordinateWithRelativePosition &compareValue) const;
//! \copydoc BlackMisc::Mixin::String::toQString
//! \copydoc Mixin::String::toQString
QString convertToQString(bool i18n = false) const;
protected:
@@ -176,10 +179,10 @@ namespace BlackMisc
ICoordinateWithRelativePosition();
//! Can given index be handled?
static bool canHandleIndex(const BlackMisc::CPropertyIndex &index);
static bool canHandleIndex(const CPropertyIndex &index);
BlackMisc::PhysicalQuantities::CAngle m_relativeBearing { 0, nullptr }; //!< temporary stored value
BlackMisc::PhysicalQuantities::CLength m_relativeDistance { 0, nullptr }; //!< temporary stored value
PhysicalQuantities::CAngle m_relativeBearing { 0, nullptr }; //!< temporary stored value
PhysicalQuantities::CLength m_relativeDistance { 0, nullptr }; //!< temporary stored value
};
//! Geodetic coordinate
@@ -193,7 +196,7 @@ namespace BlackMisc
CCoordinateGeodetic(const QVector3D &normal) : m_x(normal.x()), m_y(normal.y()), m_z(normal.z()) {}
//! Constructor by values
CCoordinateGeodetic(const CLatitude &latitude, const CLongitude &longitude, const BlackMisc::Aviation::CAltitude &geodeticHeight);
CCoordinateGeodetic(const CLatitude &latitude, const CLongitude &longitude, const Aviation::CAltitude &geodeticHeight);
//! Constructor by double values, but no geodetic height
CCoordinateGeodetic(double latitudeDegrees, double longitudeDegrees);
@@ -211,7 +214,7 @@ namespace BlackMisc
virtual CLongitude longitude() const override;
//! \copydoc ICoordinateGeodetic::geodeticHeight
virtual const BlackMisc::Aviation::CAltitude &geodeticHeight() const override { return this->m_geodeticHeight; }
virtual const Aviation::CAltitude &geodeticHeight() const override { return m_geodeticHeight; }
//! \copydoc ICoordinateGeodetic::normalVector
virtual QVector3D normalVector() const override;
@@ -219,14 +222,14 @@ namespace BlackMisc
//! \copydoc ICoordinateGeodetic::normalVectorDouble
virtual std::array<double, 3> normalVectorDouble() const override;
//! \copydoc BlackMisc::Mixin::Index::propertyByIndex
CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const;
//! \copydoc Mixin::Index::propertyByIndex
CVariant propertyByIndex(const CPropertyIndex &index) const;
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
void setPropertyByIndex(const BlackMisc::CPropertyIndex &index, const CVariant &variant);
//! \copydoc Mixin::Index::setPropertyByIndex
void setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant);
//! Switch unit of height
CCoordinateGeodetic &switchUnit(const BlackMisc::PhysicalQuantities::CLengthUnit &unit);
CCoordinateGeodetic &switchUnit(const PhysicalQuantities::CLengthUnit &unit);
//! Set latitude
void setLatitude(const CLatitude &latitude);
@@ -238,25 +241,28 @@ namespace BlackMisc
void setLatLong(const CLatitude &latitude, const CLongitude &longitude);
//! Set height (ellipsoidal or geodetic height)
void setGeodeticHeight(const BlackMisc::Aviation::CAltitude &height) { this->m_geodeticHeight = height; }
void setGeodeticHeight(const Aviation::CAltitude &height) { m_geodeticHeight = height; }
//! Set normal vector
void setNormalVector(const QVector3D &normal) { this->m_x = normal.x(); this->m_y = normal.y(); this->m_z = normal.z(); }
void setNormalVector(const QVector3D &normal) { m_x = normal.x(); m_y = normal.y(); m_z = normal.z(); }
//! Set normal vector
void setNormalVector(double x, double y, double z) { this->m_x = x; this->m_y = y; this->m_z = z; }
void setNormalVector(double x, double y, double z) { m_x = x; m_y = y; m_z = z; }
//! Coordinate by WGS84 position data
static CCoordinateGeodetic fromWgs84(const QString &latitudeWgs84, const QString &longitudeWgs84, const BlackMisc::Aviation::CAltitude &geodeticHeight = {});
static CCoordinateGeodetic fromWgs84(const QString &latitudeWgs84, const QString &longitudeWgs84, const Aviation::CAltitude &geodeticHeight = {});
//! \copydoc BlackMisc::Mixin::String::toQString
//! \copydoc Mixin::String::toQString
QString convertToQString(bool i18n = false) const;
private:
double m_x = 0; //!< normal vector
double m_y = 0; //!< normal vector
double m_z = 0; //!< normal vector
BlackMisc::Aviation::CAltitude m_geodeticHeight { 0, nullptr }; //!< height, ellipsoidal or geodetic height
// Coordinates are stored using `double` internally and use `double` for most calculations.
// They use `double` when converting to and from lat/lon representation.
// `QVector3D` is only used for calculating distance and bearing.
double m_x = 0; //!< normal vector [-1,1]
double m_y = 0; //!< normal vector [-1,1]
double m_z = 0; //!< normal vector [-1,1]
Aviation::CAltitude m_geodeticHeight { 0, nullptr }; //!< height, ellipsoidal or geodetic height
BLACK_METACLASS(
CCoordinateGeodetic,

View File

@@ -13,6 +13,7 @@
#include "blackmisc/pq/units.h"
#include "blackmisc/sequence.h"
#include <QStringBuilder>
#include <QtGlobal>
namespace BlackMisc
@@ -30,7 +31,7 @@ namespace BlackMisc
CIcons::IconIndex CIcon::getIndex() const
{
return this->m_index;
return m_index;
}
bool CIcon::isIndexBased() const
@@ -40,17 +41,17 @@ namespace BlackMisc
bool CIcon::isGenerated() const
{
return getIndex() == CIcons::IconIsGenerated;
return this->getIndex() == CIcons::IconIsGenerated;
}
bool CIcon::isFileBased() const
{
return getIndex() == CIcons::IconIsFile;
return this->getIndex() == CIcons::IconIsFile;
}
bool CIcon::isSet() const
{
return (this->m_index != CIcons::NotSet);
return (m_index != CIcons::NotSet);
}
QPixmap CIcon::toPixmap() const
@@ -59,7 +60,7 @@ namespace BlackMisc
{
if (this->isGenerated()) { return m_pixmap; }
if (this->isFileBased()) { return m_pixmap; }
return CIcons::pixmapByIndex(getIndex(), this->m_rotateDegrees);
return CIcons::pixmapByIndex(getIndex(), m_rotateDegrees);
}
else
{
@@ -74,13 +75,13 @@ namespace BlackMisc
void CIcon::setRotation(const PhysicalQuantities::CAngle &rotate)
{
this->m_rotateDegrees = static_cast<int>(rotate.valueRounded(PhysicalQuantities::CAngleUnit::deg(), 0));
m_rotateDegrees = static_cast<int>(rotate.valueRounded(PhysicalQuantities::CAngleUnit::deg(), 0));
}
QString CIcon::convertToQString(bool i18n) const
{
Q_UNUSED(i18n);
QString s = QString(this->m_descriptiveText).append(" ").append(this->m_index);
const QString s = m_descriptiveText % QStringLiteral(" ") % QString::number(m_index);
return s;
}

View File

@@ -180,23 +180,16 @@ namespace BlackMisc
CVariant CInterpolationAndRenderingSetup::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
{
if (index.isMyself()) { return CVariant::from(*this); }
ColumnIndex i = index.frontCasted<ColumnIndex>();
const ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i)
{
case IndexInterpolatorDebugMessages:
return CVariant::fromValue(m_interpolatorDebugMessage);
case IndexSimulatorDebugMessages:
return CVariant::fromValue(m_simulatorDebugMessages);
case IndexForceFullInterpolation:
return CVariant::fromValue(m_forceFullInterpolation);
case IndexMaxRenderedAircraft:
return CVariant::fromValue(m_maxRenderedAircraft);
case IndexMaxRenderedDistance:
return CVariant::fromValue(m_maxRenderedDistance);
case IndexEnabledAircraftParts:
return CVariant::fromValue(m_enabledAircraftParts);
default:
return CValueObject::propertyByIndex(index);
case IndexInterpolatorDebugMessages: return CVariant::fromValue(m_interpolatorDebugMessage);
case IndexSimulatorDebugMessages: return CVariant::fromValue(m_simulatorDebugMessages);
case IndexForceFullInterpolation: return CVariant::fromValue(m_forceFullInterpolation);
case IndexMaxRenderedAircraft: return CVariant::fromValue(m_maxRenderedAircraft);
case IndexMaxRenderedDistance: return CVariant::fromValue(m_maxRenderedDistance);
case IndexEnabledAircraftParts: return CVariant::fromValue(m_enabledAircraftParts);
default: return CValueObject::propertyByIndex(index);
}
}
@@ -207,30 +200,16 @@ namespace BlackMisc
*this = variant.value<CInterpolationAndRenderingSetup>();
return;
}
ColumnIndex i = index.frontCasted<ColumnIndex>();
const ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i)
{
case IndexInterpolatorDebugMessages:
m_interpolatorDebugMessage = variant.toBool();
break;
case IndexSimulatorDebugMessages:
m_simulatorDebugMessages = variant.toBool();
break;
case IndexForceFullInterpolation:
m_forceFullInterpolation = variant.toBool();
break;
case IndexMaxRenderedAircraft:
m_maxRenderedAircraft = variant.toInt();
break;
case IndexMaxRenderedDistance:
m_maxRenderedDistance = variant.value<CLength>();
break;
case IndexEnabledAircraftParts:
m_enabledAircraftParts = variant.toBool();
break;
default:
CValueObject::setPropertyByIndex(index, variant);
break;
case IndexInterpolatorDebugMessages: m_interpolatorDebugMessage = variant.toBool(); break;
case IndexSimulatorDebugMessages: m_simulatorDebugMessages = variant.toBool(); break;
case IndexForceFullInterpolation: m_forceFullInterpolation = variant.toBool(); break;
case IndexMaxRenderedAircraft: m_maxRenderedAircraft = variant.toInt(); break;
case IndexMaxRenderedDistance: m_maxRenderedDistance = variant.value<CLength>(); break;
case IndexEnabledAircraftParts: m_enabledAircraftParts = variant.toBool(); break;
default: CValueObject::setPropertyByIndex(index, variant); break;
}
}
} // ns

View File

@@ -127,9 +127,9 @@ namespace BlackMisc
private:
bool m_interpolatorDebugMessage = false; //! Debug messages in interpolator
bool m_simulatorDebugMessages = false; //! Debug messages of simulator (aka plugin)
bool m_forceFullInterpolation = false; //! always do a full interpolation, even if aircraft is not moving
bool m_enabledAircraftParts = true; //! Update aircraft parts
bool m_simulatorDebugMessages = false; //! Debug messages of simulator (aka plugin)
bool m_forceFullInterpolation = false; //! always do a full interpolation, even if aircraft is not moving
bool m_enabledAircraftParts = true; //! Update aircraft parts
int m_maxRenderedAircraft = InfiniteAircraft(); //!< max.rendered aircraft
BlackMisc::PhysicalQuantities::CLength m_maxRenderedDistance { 0, nullptr }; //!< max.distance for rendering
BlackMisc::Aviation::CCallsignSet m_callsignsToLog;

View File

@@ -24,7 +24,9 @@ namespace BlackMisc
{}
BlackMisc::Aviation::CAircraftSituation CInterpolatorMulti::getInterpolatedSituation(
qint64 currentTimeSinceEpoc, const CInterpolationAndRenderingSetup &setup, const CInterpolationHints &hints, CInterpolationStatus &status)
qint64 currentTimeSinceEpoc,
const CInterpolationAndRenderingSetup &setup,
const CInterpolationHints &hints, CInterpolationStatus &status)
{
switch (m_mode)
{

View File

@@ -32,12 +32,14 @@ namespace BlackMisc
//! \copydoc CInterpolator::getInterpolatedSituation
BlackMisc::Aviation::CAircraftSituation getInterpolatedSituation(
qint64 currentTimeSinceEpoc, const CInterpolationAndRenderingSetup &setup,
qint64 currentTimeSinceEpoc,
const CInterpolationAndRenderingSetup &setup,
const CInterpolationHints &hints, CInterpolationStatus &status);
//! \copydoc CInterpolator::getInterpolatedParts
BlackMisc::Aviation::CAircraftParts getInterpolatedParts(
qint64 currentTimeSinceEpoc, const CInterpolationAndRenderingSetup &setup,
qint64 currentTimeSinceEpoc,
const CInterpolationAndRenderingSetup &setup,
CPartsStatus &partsStatus, bool log = false);
//! \copydoc CInterpolator::addAircraftSituation

View File

@@ -80,7 +80,7 @@ namespace BlackSimPlugin
// reset flags
m_simPaused = false;
emitSimulatorCombinedStatus();
this->emitSimulatorCombinedStatus();
return true;
}

View File

@@ -138,10 +138,10 @@ namespace BlackSimPlugin
bool m_confirmedAdded = false;
bool m_pendingRemoved = false;
int m_lightsRequestedAt = -1;
DataDefinitionRemoteAircraftPartsWithoutLights m_partsAsSent {}; //!< parts as sent
BlackMisc::Aviation::CAircraftLights m_currentLightsInSim { nullptr }; //!< current lights to know state for toggling
BlackMisc::Aviation::CAircraftLights m_lightsAsSent { nullptr }; //!< lights as sent to simulator
SIMCONNECT_PERIOD m_requestSimDataPeriod = SIMCONNECT_PERIOD_NEVER; //!< how often do we query ground elevation
DataDefinitionRemoteAircraftPartsWithoutLights m_partsAsSent {}; //!< parts as sent
BlackMisc::Aviation::CAircraftLights m_currentLightsInSim { nullptr }; //!< current lights to know state for toggling
BlackMisc::Aviation::CAircraftLights m_lightsAsSent { nullptr }; //!< lights as sent to simulator
SIMCONNECT_PERIOD m_requestSimDataPeriod = SIMCONNECT_PERIOD_NEVER; //!< how often do we query ground elevation
QSharedPointer<BlackMisc::Simulation::CInterpolatorMulti> m_interpolator; //!< shared pointer because CSimConnectObject can be copied
};

View File

@@ -66,7 +66,7 @@ namespace BlackSimPlugin
CSimulatorFsxCommon::~CSimulatorFsxCommon()
{
disconnectFrom();
this->disconnectFrom();
// fsuipc is disconnected in CSimulatorFsCommon
}
@@ -92,8 +92,8 @@ namespace BlackSimPlugin
if (m_useFsuipc) { m_fsuipc->connect(); } // FSUIPC too
// set structures and move on
initEvents();
initDataDefinitionsWhenConnected();
this->initEvents();
this->initDataDefinitionsWhenConnected();
m_simConnectTimerId = startTimer(DispatchIntervalMs);
// do not start m_addPendingAircraftTimer here, it will be started when object was added
@@ -105,14 +105,14 @@ namespace BlackSimPlugin
if (!m_simConnected) { return true; }
if (m_simConnectTimerId >= 0) { killTimer(m_simConnectTimerId); }
m_simConnectTimerId = -1;
this->onSimStopped(); // treat as stopped
m_simSimulating = false; // treat as stopped, just setting the flag here avoids overhead of on onSimStopped
if (m_hSimConnect)
{
SimConnect_Close(m_hSimConnect);
m_hSimConnect = nullptr;
}
reset();
this->reset(); // mark as disconnected and reset all values
// emit status and disconnect FSUIPC
CSimulatorFsCommon::disconnectFrom();
@@ -327,15 +327,15 @@ namespace BlackSimPlugin
void CSimulatorFsxCommon::onSimStopped()
{
// stopping events in FSX: Load menu, weather and season
const SimulatorStatus oldStatus = getSimulatorStatus();
const SimulatorStatus oldStatus = this->getSimulatorStatus();
m_simSimulating = false;
m_simulatingChangedTs = QDateTime::currentMSecsSinceEpoch();
emitSimulatorCombinedStatus(oldStatus);
this->emitSimulatorCombinedStatus(oldStatus);
}
void CSimulatorFsxCommon::onSimFrame()
{
updateRemoteAircraft();
this->updateRemoteAircraft();
}
void CSimulatorFsxCommon::onSimExit()
@@ -559,7 +559,7 @@ namespace BlackSimPlugin
simObject.setConfirmedAdded(true);
// P3D also has SimConnect_AIReleaseControlEx;
const DWORD requestId = obtainRequestIdSimData();
const DWORD requestId = this->obtainRequestIdSimData();
const DWORD objectId = simObject.getObjectId();
HRESULT hr = SimConnect_AIReleaseControl(m_hSimConnect, objectId, static_cast<SIMCONNECT_DATA_REQUEST_ID>(requestId));
hr += SimConnect_TransmitClientEvent(m_hSimConnect, objectId, EventFreezeLat, 1,
@@ -729,7 +729,7 @@ namespace BlackSimPlugin
void CSimulatorFsxCommon::timerEvent(QTimerEvent *event)
{
Q_UNUSED(event);
dispatch();
this->dispatch();
}
const QString &CSimulatorFsxCommon::modeToString(CSimulatorFsxCommon::AircraftAddMode mode)
@@ -841,8 +841,8 @@ namespace BlackSimPlugin
const CAircraftModel aircraftModel = newRemoteAircraft.getModel();
CSimulatedAircraft addedAircraft(newRemoteAircraft);
const DWORD requestId = obtainRequestIdSimData();
SIMCONNECT_DATA_INITPOSITION initialPosition = aircraftSituationToFsxPosition(addedAircraft.getSituation());
const DWORD requestId = this->obtainRequestIdSimData();
const SIMCONNECT_DATA_INITPOSITION initialPosition = aircraftSituationToFsxPosition(addedAircraft.getSituation());
const QString modelString(addedAircraft.getModelString());
if (this->showDebugLogMessage()) { this->debugLogMessage(Q_FUNC_INFO, QString("Cs: '%1' model: '%2' request: %3, init pos: %4").arg(callsign.toQString(), modelString).arg(requestId).arg(fsxPositionToString(initialPosition))); }
@@ -851,7 +851,7 @@ namespace BlackSimPlugin
{
const CStatusMessage msg = CStatusMessage(this).error("SimConnect, can not create AI traffic: '%1' '%2'") << callsign.toQString() << aircraftModel.getModelString();
CLogMessage::preformatted(msg);
emit physicallyAddingRemoteModelFailed(addedAircraft, msg);
emit this->physicallyAddingRemoteModelFailed(addedAircraft, msg);
}
else
{
@@ -1424,7 +1424,7 @@ namespace BlackSimPlugin
m_requestIdSimData = RequestSimDataStart;
m_dispatchErrors = 0;
m_receiveExceptionCount = 0;
CSimulatorFsCommon::reset();
CSimulatorFsCommon::reset(); // clears all pending aircraft etc
}
void CSimulatorFsxCommon::clearAllAircraft()

View File

@@ -55,16 +55,16 @@ namespace BlackSimPlugin
const DWORD sendId = exception->dwSendID;
const DWORD index = exception->dwIndex;
const DWORD data = cbData;
const QString exStr(CSimConnectUtilities::simConnectExceptionToString((SIMCONNECT_EXCEPTION)exception->dwException));
QString ex;
ex.sprintf("Exception=%lu | SendID=%lu | Index=%lu | cbData=%lu", exceptionId, sendId, index, data);
switch (exceptionId)
{
case SIMCONNECT_EXCEPTION_OPERATION_INVALID_FOR_OBJECT_TYPE: break;
case SIMCONNECT_EXCEPTION_UNRECOGNIZED_ID: break;
default: break;
}
CLogMessage(simulatorFsx).warning("Caught FSX simConnect exception: %1 %2") << exStr << ex;
QString ex;
ex.sprintf("Exception=%lu | SendID=%lu | Index=%lu | cbData=%lu", exceptionId, sendId, index, data);
const QString exStr(CSimConnectUtilities::simConnectExceptionToString((SIMCONNECT_EXCEPTION)exception->dwException));
CLogMessage(simulatorFsx).warning("Caught simConnect exception: %1 %2") << exStr << ex;
break;
}
case SIMCONNECT_RECV_ID_QUIT:
@@ -74,7 +74,7 @@ namespace BlackSimPlugin
}
case SIMCONNECT_RECV_ID_EVENT:
{
SIMCONNECT_RECV_EVENT *event = static_cast<SIMCONNECT_RECV_EVENT *>(pData);
const SIMCONNECT_RECV_EVENT *event = static_cast<SIMCONNECT_RECV_EVENT *>(pData);
switch (event->uEventID)
{
case SystemEventSimStatus:
@@ -117,7 +117,7 @@ namespace BlackSimPlugin
// such an object is not necessarily one of ours
// for instance, I always see object "5" when I start the simulator
if (!simulatorFsx->getSimConnectObjects().isKnownSimObjectId(objectId)) break;
if (!simulatorFsx->getSimConnectObjects().isKnownSimObjectId(objectId)) { break; }
switch (event->uEventID)
{
case SystemEventObjectAdded:
@@ -133,7 +133,7 @@ namespace BlackSimPlugin
}
case SIMCONNECT_RECV_ID_EVENT_FRAME:
{
SIMCONNECT_RECV_EVENT_FRAME *event = (SIMCONNECT_RECV_EVENT_FRAME *) pData;
const SIMCONNECT_RECV_EVENT_FRAME *event = (SIMCONNECT_RECV_EVENT_FRAME *) pData;
switch (event->uEventID)
{
case SystemEventFrame:
@@ -147,7 +147,7 @@ namespace BlackSimPlugin
}
case SIMCONNECT_RECV_ID_ASSIGNED_OBJECT_ID:
{
SIMCONNECT_RECV_ASSIGNED_OBJECT_ID *event = static_cast<SIMCONNECT_RECV_ASSIGNED_OBJECT_ID *>(pData);
const SIMCONNECT_RECV_ASSIGNED_OBJECT_ID *event = static_cast<SIMCONNECT_RECV_ASSIGNED_OBJECT_ID *>(pData);
const DWORD requestId = event->dwRequestID;
const DWORD objectId = event->dwObjectID;
bool success = simulatorFsx->setSimConnectObjectId(requestId, objectId);
@@ -170,7 +170,7 @@ namespace BlackSimPlugin
}
case SIMCONNECT_RECV_ID_SIMOBJECT_DATA:
{
SIMCONNECT_RECV_SIMOBJECT_DATA *pObjData = (SIMCONNECT_RECV_SIMOBJECT_DATA *) pData;
const SIMCONNECT_RECV_SIMOBJECT_DATA *pObjData = (SIMCONNECT_RECV_SIMOBJECT_DATA *) pData;
const DWORD requestId = pObjData->dwRequestID;
switch (requestId)
{
@@ -249,10 +249,10 @@ namespace BlackSimPlugin
{
static const CLength maxDistance(200.0, CLengthUnit::NM());
const CCoordinateGeodetic posAircraft(simulatorFsx->getOwnAircraftPosition());
SIMCONNECT_RECV_AIRPORT_LIST *pAirportList = (SIMCONNECT_RECV_AIRPORT_LIST *) pData;
const SIMCONNECT_RECV_AIRPORT_LIST *pAirportList = (SIMCONNECT_RECV_AIRPORT_LIST *) pData;
for (unsigned i = 0; i < pAirportList->dwArraySize; ++i)
{
SIMCONNECT_DATA_FACILITY_AIRPORT *pFacilityAirport = pAirportList->rgData + i;
const SIMCONNECT_DATA_FACILITY_AIRPORT *pFacilityAirport = pAirportList->rgData + i;
if (!pFacilityAirport) { break; }
const QString icao(pFacilityAirport->Icao);
if (icao.isEmpty()) { continue; } // airfield without ICAO code
@@ -276,7 +276,7 @@ namespace BlackSimPlugin
case SIMCONNECT_RECV_ID_CLIENT_DATA:
{
if (!simulatorFsx->m_useSbOffsets) { break; }
SIMCONNECT_RECV_CLIENT_DATA *clientData = (SIMCONNECT_RECV_CLIENT_DATA *)pData;
const SIMCONNECT_RECV_CLIENT_DATA *clientData = (SIMCONNECT_RECV_CLIENT_DATA *)pData;
if (simulatorFsx->m_useSbOffsets && clientData->dwRequestID == CSimConnectDefinitions::RequestSbData)
{
//! \fixme FSUIPC vs SimConnect why is offset 19 ident 2/0? In FSUIPC it is 0/1, according to documentation it is 0/1 but I receive 2/0 here. Whoever knows, add comment or fix if wrong
@@ -287,7 +287,7 @@ namespace BlackSimPlugin
}
case SIMCONNECT_RECV_ID_EVENT_FILENAME:
{
SIMCONNECT_RECV_EVENT_FILENAME *event = static_cast<SIMCONNECT_RECV_EVENT_FILENAME *>(pData);
const SIMCONNECT_RECV_EVENT_FILENAME *event = static_cast<SIMCONNECT_RECV_EVENT_FILENAME *>(pData);
switch (event->uEventID)
{
case SystemEventFlightLoaded: break;