mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-18 11:25:33 +08:00
Ref T180, formatting / const
This commit is contained in:
@@ -67,11 +67,11 @@ namespace BlackCore
|
|||||||
|
|
||||||
void ISimulator::emitSimulatorCombinedStatus(SimulatorStatus oldStatus)
|
void ISimulator::emitSimulatorCombinedStatus(SimulatorStatus oldStatus)
|
||||||
{
|
{
|
||||||
const SimulatorStatus newStatus = getSimulatorStatus();
|
const SimulatorStatus newStatus = this->getSimulatorStatus();
|
||||||
if (oldStatus != newStatus)
|
if (oldStatus != newStatus)
|
||||||
{
|
{
|
||||||
// decouple, follow up of signal can include unloading
|
// 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, [ = ]
|
QTimer::singleShot(0, this, [ = ]
|
||||||
{
|
{
|
||||||
emit this->simulatorStatusChanged(newStatus);
|
emit this->simulatorStatusChanged(newStatus);
|
||||||
@@ -85,7 +85,7 @@ namespace BlackCore
|
|||||||
this->setObjectName("ISimulatorListener:" + info.toQString());
|
this->setObjectName("ISimulatorListener:" + info.toQString());
|
||||||
|
|
||||||
// stop listener after it reports simulator ready
|
// 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_ASSERT_X(s, Q_FUNC_INFO, "connect failed");
|
||||||
Q_UNUSED(s)
|
Q_UNUSED(s)
|
||||||
}
|
}
|
||||||
@@ -104,13 +104,13 @@ namespace BlackCore
|
|||||||
{
|
{
|
||||||
if (m_isRunning) { return; }
|
if (m_isRunning) { return; }
|
||||||
m_isRunning = true;
|
m_isRunning = true;
|
||||||
startImpl();
|
this->startImpl();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ISimulatorListener::stop()
|
void ISimulatorListener::stop()
|
||||||
{
|
{
|
||||||
if (!m_isRunning) { return; }
|
if (!m_isRunning) { return; }
|
||||||
stopImpl();
|
this->stopImpl();
|
||||||
m_isRunning = false;
|
m_isRunning = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -70,8 +70,8 @@ namespace BlackCore
|
|||||||
|
|
||||||
// timer
|
// timer
|
||||||
connect(&m_oneSecondTimer, &QTimer::timeout, this, &CSimulatorCommon::oneSecondTimerTimeout);
|
connect(&m_oneSecondTimer, &QTimer::timeout, this, &CSimulatorCommon::oneSecondTimerTimeout);
|
||||||
this->m_oneSecondTimer.setObjectName(this->objectName().append(":m_oneSecondTimer"));
|
m_oneSecondTimer.setObjectName(this->objectName().append(":m_oneSecondTimer"));
|
||||||
this->m_oneSecondTimer.start(1000);
|
m_oneSecondTimer.start(1000);
|
||||||
|
|
||||||
// swift data
|
// swift data
|
||||||
if (sApp && sApp->hasWebDataServices())
|
if (sApp && sApp->hasWebDataServices())
|
||||||
@@ -213,14 +213,14 @@ namespace BlackCore
|
|||||||
|
|
||||||
void CSimulatorCommon::debugLogMessage(const QString &msg) const
|
void CSimulatorCommon::debugLogMessage(const QString &msg) const
|
||||||
{
|
{
|
||||||
if (!showDebugLogMessage()) { return; }
|
if (!this->showDebugLogMessage()) { return; }
|
||||||
if (msg.isEmpty()) { return; }
|
if (msg.isEmpty()) { return; }
|
||||||
CLogMessage(this).info(msg);
|
CLogMessage(this).info(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSimulatorCommon::debugLogMessage(const QString &funcInfo, const QString &msg) const
|
void CSimulatorCommon::debugLogMessage(const QString &funcInfo, const QString &msg) const
|
||||||
{
|
{
|
||||||
if (!showDebugLogMessage()) { return; }
|
if (!this->showDebugLogMessage()) { return; }
|
||||||
if (msg.isEmpty()) { return; }
|
if (msg.isEmpty()) { return; }
|
||||||
CLogMessage(this).info("%1 %2") << msg << funcInfo;
|
CLogMessage(this).info("%1 %2") << msg << funcInfo;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,11 +75,11 @@ namespace BlackGui
|
|||||||
ui(new Ui::CLoginComponent)
|
ui(new Ui::CLoginComponent)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
this->m_logoffCountdownTimer = new QTimer(this);
|
m_logoffCountdownTimer = new QTimer(this);
|
||||||
this->m_logoffCountdownTimer->setObjectName("CLoginComponent:m_logoffCountdownTimer");
|
m_logoffCountdownTimer->setObjectName("CLoginComponent:m_logoffCountdownTimer");
|
||||||
ui->pb_LogoffTimeout->setMaximum(LogoffIntervalSeconds);
|
ui->pb_LogoffTimeout->setMaximum(LogoffIntervalSeconds);
|
||||||
ui->pb_LogoffTimeout->setValue(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_AircraftIcao->displayWithIcaoDescription(false);
|
||||||
ui->selector_AirlineIcao->displayWithIcaoDescription(false);
|
ui->selector_AirlineIcao->displayWithIcaoDescription(false);
|
||||||
@@ -154,7 +154,7 @@ namespace BlackGui
|
|||||||
this->validateAircraftValues();
|
this->validateAircraftValues();
|
||||||
this->validateVatsimValues();
|
this->validateVatsimValues();
|
||||||
this->onWebServiceDataRead(CEntityFlags::VatsimDataFile, CEntityFlags::ReadFinished, -1);
|
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
|
// add a testserver when no servers can be loaded
|
||||||
if (otherServers.isEmpty() && (sGui->isRunningInDeveloperEnvironment() || CBuildConfig::isDevBranch()))
|
if (otherServers.isEmpty() && (sGui->isRunningInDeveloperEnvironment() || CBuildConfig::isDevBranch()))
|
||||||
@@ -176,12 +176,12 @@ namespace BlackGui
|
|||||||
|
|
||||||
void CLoginComponent::mainInfoAreaChanged(const QWidget *currentWidget)
|
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())
|
if (currentWidget != this && currentWidget != this->parentWidget())
|
||||||
{
|
{
|
||||||
const bool wasVisible = this->m_visible;
|
const bool wasVisible = m_visible;
|
||||||
this->m_visible = false;
|
m_visible = false;
|
||||||
this->m_logoffCountdownTimer->stop();
|
m_logoffCountdownTimer->stop();
|
||||||
|
|
||||||
if (wasVisible)
|
if (wasVisible)
|
||||||
{
|
{
|
||||||
@@ -192,7 +192,7 @@ namespace BlackGui
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
this->setOwnModelAndIcaoValues();
|
this->setOwnModelAndIcaoValues();
|
||||||
if (this->m_visible)
|
if (m_visible)
|
||||||
{
|
{
|
||||||
// already visible:
|
// already visible:
|
||||||
// re-trigger! treat as same as OK
|
// re-trigger! treat as same as OK
|
||||||
@@ -200,7 +200,7 @@ namespace BlackGui
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this->m_visible = true;
|
m_visible = true;
|
||||||
const bool isConnected = sGui->getIContextNetwork()->isConnected();
|
const bool isConnected = sGui->getIContextNetwork()->isConnected();
|
||||||
this->setGuiVisibility(isConnected);
|
this->setGuiVisibility(isConnected);
|
||||||
this->setOkButtonString(isConnected);
|
this->setOkButtonString(isConnected);
|
||||||
@@ -211,7 +211,7 @@ namespace BlackGui
|
|||||||
|
|
||||||
void CLoginComponent::loginCancelled()
|
void CLoginComponent::loginCancelled()
|
||||||
{
|
{
|
||||||
this->m_logoffCountdownTimer->stop();
|
m_logoffCountdownTimer->stop();
|
||||||
ui->pb_LogoffTimeout->setValue(LogoffIntervalSeconds);
|
ui->pb_LogoffTimeout->setValue(LogoffIntervalSeconds);
|
||||||
emit this->loginOrLogoffCancelled();
|
emit this->loginOrLogoffCancelled();
|
||||||
}
|
}
|
||||||
@@ -293,8 +293,8 @@ namespace BlackGui
|
|||||||
if (msg.isSuccess() && vatsimLogin)
|
if (msg.isSuccess() && vatsimLogin)
|
||||||
{
|
{
|
||||||
Q_ASSERT_X(currentServer.isValidForLogin(), Q_FUNC_INFO, "invalid server");
|
Q_ASSERT_X(currentServer.isValidForLogin(), Q_FUNC_INFO, "invalid server");
|
||||||
this->m_currentVatsimServer.set(currentServer);
|
m_currentVatsimServer.set(currentServer);
|
||||||
this->m_currentAircraftModel.setAndSave(ownAircraft.getModel());
|
m_currentAircraftModel.setAndSave(ownAircraft.getModel());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -334,7 +334,7 @@ namespace BlackGui
|
|||||||
CServerList vatsimFsdServers = sGui->getIContextNetwork()->getVatsimFsdServers();
|
CServerList vatsimFsdServers = sGui->getIContextNetwork()->getVatsimFsdServers();
|
||||||
if (vatsimFsdServers.isEmpty()) { return; }
|
if (vatsimFsdServers.isEmpty()) { return; }
|
||||||
vatsimFsdServers.sortBy(&CServer::getName);
|
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->setServers(vatsimFsdServers, true);
|
||||||
ui->comp_VatsimServer->preSelect(currentServer.getName());
|
ui->comp_VatsimServer->preSelect(currentServer.getName());
|
||||||
}
|
}
|
||||||
@@ -346,7 +346,7 @@ namespace BlackGui
|
|||||||
|
|
||||||
void CLoginComponent::loadRememberedVatsimData()
|
void CLoginComponent::loadRememberedVatsimData()
|
||||||
{
|
{
|
||||||
const CServer lastServer = this->m_currentVatsimServer.get();
|
const CServer lastServer = m_currentVatsimServer.get();
|
||||||
const CUser lastUser = lastServer.getUser();
|
const CUser lastUser = lastServer.getUser();
|
||||||
if (lastUser.hasValidCallsign())
|
if (lastUser.hasValidCallsign())
|
||||||
{
|
{
|
||||||
@@ -429,8 +429,8 @@ namespace BlackGui
|
|||||||
void CLoginComponent::startLogoffTimerCountdown()
|
void CLoginComponent::startLogoffTimerCountdown()
|
||||||
{
|
{
|
||||||
ui->pb_LogoffTimeout->setValue(LogoffIntervalSeconds);
|
ui->pb_LogoffTimeout->setValue(LogoffIntervalSeconds);
|
||||||
this->m_logoffCountdownTimer->setInterval(1000);
|
m_logoffCountdownTimer->setInterval(1000);
|
||||||
this->m_logoffCountdownTimer->start();
|
m_logoffCountdownTimer->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLoginComponent::setOwnModelAndIcaoValues()
|
void CLoginComponent::setOwnModelAndIcaoValues()
|
||||||
@@ -474,7 +474,7 @@ namespace BlackGui
|
|||||||
const bool changedOwnAircraftIcaoValues = this->updateOwnAircaftIcaoValuesFromGuiValues();
|
const bool changedOwnAircraftIcaoValues = this->updateOwnAircaftIcaoValuesFromGuiValues();
|
||||||
if (changedOwnAircraftIcaoValues || changedOwnAircraftCallsignPilot)
|
if (changedOwnAircraftIcaoValues || changedOwnAircraftCallsignPilot)
|
||||||
{
|
{
|
||||||
this->m_changedLoginDataDigestSignal.inputSignal();
|
m_changedLoginDataDigestSignal.inputSignal();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -560,7 +560,7 @@ namespace BlackGui
|
|||||||
|
|
||||||
void CLoginComponent::reloadSettings()
|
void CLoginComponent::reloadSettings()
|
||||||
{
|
{
|
||||||
CServerList otherServers(this->m_otherTrafficNetworkServers.getThreadLocal());
|
CServerList otherServers(m_otherTrafficNetworkServers.getThreadLocal());
|
||||||
ui->comp_OtherServers->setServers(otherServers);
|
ui->comp_OtherServers->setServers(otherServers);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -572,7 +572,7 @@ namespace BlackGui
|
|||||||
ui->pb_LogoffTimeout->setValue(v);
|
ui->pb_LogoffTimeout->setValue(v);
|
||||||
if (v <= 0)
|
if (v <= 0)
|
||||||
{
|
{
|
||||||
this->m_logoffCountdownTimer->stop();
|
m_logoffCountdownTimer->stop();
|
||||||
this->toggleNetworkConnection();
|
this->toggleNetworkConnection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -598,7 +598,7 @@ namespace BlackGui
|
|||||||
this->setOwnModelAndIcaoValues();
|
this->setOwnModelAndIcaoValues();
|
||||||
|
|
||||||
// open dialog for model mapping
|
// open dialog for model mapping
|
||||||
if (this->m_autoPopupWizard && !model.isLoadedFromDb())
|
if (m_autoPopupWizard && !model.isLoadedFromDb())
|
||||||
{
|
{
|
||||||
this->mappingWizard();
|
this->mappingWizard();
|
||||||
}
|
}
|
||||||
@@ -607,29 +607,29 @@ namespace BlackGui
|
|||||||
this->updateOwnAircraftCallsignAndPilotFromGuiValues();
|
this->updateOwnAircraftCallsignAndPilotFromGuiValues();
|
||||||
|
|
||||||
// let others know data changed
|
// let others know data changed
|
||||||
this->m_changedLoginDataDigestSignal.inputSignal();
|
m_changedLoginDataDigestSignal.inputSignal();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLoginComponent::mappingWizard()
|
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())
|
if (sGui->getIContextSimulator()->isSimulatorAvailable())
|
||||||
{
|
{
|
||||||
// preset on model
|
// preset on model
|
||||||
const CAircraftModel model(sGui->getIContextOwnAircraft()->getOwnAircraft().getModel());
|
const CAircraftModel model(sGui->getIContextOwnAircraft()->getOwnAircraft().getModel());
|
||||||
this->m_mappingWizard->presetModel(model);
|
m_mappingWizard->presetModel(model);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// preset on GUI values only
|
// preset on GUI values only
|
||||||
const CAircraftIcaoCode icao(ui->selector_AircraftIcao->getAircraftIcao());
|
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()
|
void CLoginComponent::toggleTimeout()
|
||||||
@@ -691,7 +691,7 @@ namespace BlackGui
|
|||||||
|
|
||||||
CAircraftModel CLoginComponent::getPrefillModel() const
|
CAircraftModel CLoginComponent::getPrefillModel() const
|
||||||
{
|
{
|
||||||
CAircraftModel model = this->m_currentAircraftModel.get();
|
CAircraftModel model = m_currentAircraftModel.get();
|
||||||
if (model.hasAircraftDesignator()) { return model; }
|
if (model.hasAircraftDesignator()) { return model; }
|
||||||
return IContextOwnAircraft::getDefaultOwnAircraftModel();
|
return IContextOwnAircraft::getDefaultOwnAircraftModel();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ namespace BlackGui
|
|||||||
|
|
||||||
void CServerListSelector::setServers(const BlackMisc::Network::CServerList &servers, bool nameIsCountry)
|
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);
|
this->setServerItems(servers, nameIsCountry);
|
||||||
if (!servers.isEmpty() && !m_pendingPreselect.isEmpty())
|
if (!servers.isEmpty() && !m_pendingPreselect.isEmpty())
|
||||||
{
|
{
|
||||||
@@ -70,8 +70,8 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
QString currentlySelected(this->currentText());
|
QString currentlySelected(this->currentText());
|
||||||
int index = -1;
|
int index = -1;
|
||||||
this->m_servers = servers;
|
m_servers = servers;
|
||||||
this->m_items.clear();
|
m_items.clear();
|
||||||
this->clear(); // ui
|
this->clear(); // ui
|
||||||
|
|
||||||
nameToCountry = nameToCountry && knowsAllCountries();
|
nameToCountry = nameToCountry && knowsAllCountries();
|
||||||
@@ -86,7 +86,7 @@ namespace BlackGui
|
|||||||
|
|
||||||
if (nameToCountry)
|
if (nameToCountry)
|
||||||
{
|
{
|
||||||
const CCountry country(findCountry(server));
|
const CCountry country(this->findCountry(server));
|
||||||
if (country.getName().isEmpty())
|
if (country.getName().isEmpty())
|
||||||
{
|
{
|
||||||
this->addItem(d);
|
this->addItem(d);
|
||||||
@@ -103,8 +103,8 @@ namespace BlackGui
|
|||||||
}
|
}
|
||||||
|
|
||||||
// reselect
|
// reselect
|
||||||
if (this->m_items.isEmpty()) { return; }
|
if (m_items.isEmpty()) { return; }
|
||||||
if (this->m_items.size() == 1)
|
if (m_items.size() == 1)
|
||||||
{
|
{
|
||||||
this->setCurrentIndex(0);
|
this->setCurrentIndex(0);
|
||||||
}
|
}
|
||||||
@@ -121,7 +121,7 @@ namespace BlackGui
|
|||||||
|
|
||||||
CCountry CServerListSelector::findCountry(const CServer &server)
|
CCountry CServerListSelector::findCountry(const CServer &server)
|
||||||
{
|
{
|
||||||
if (!knowsAllCountries()) { return CCountry(); }
|
if (!CServerListSelector::knowsAllCountries()) { return CCountry(); }
|
||||||
static const CCountryList countries(sGui->getWebDataServices()->getCountries());
|
static const CCountryList countries(sGui->getWebDataServices()->getCountries());
|
||||||
return countries.findBestMatchByCountryName(server.getName());
|
return countries.findBestMatchByCountryName(server.getName());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,9 +95,10 @@ namespace BlackMisc
|
|||||||
{
|
{
|
||||||
if (name.isEmpty() || m_name.isEmpty()) { return false; }
|
if (name.isEmpty() || m_name.isEmpty()) { return false; }
|
||||||
if (caseInsensitiveStringCompare(name, this->getDbKey())) { return true; } // exact ISO match
|
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)
|
if (name.length() < 5)
|
||||||
{
|
{
|
||||||
|
// contains would be too fuzzy for short names
|
||||||
return caseInsensitiveStringCompare(name, m_name) || caseInsensitiveStringCompare(name, m_simplifiedName);
|
return caseInsensitiveStringCompare(name, m_name) || caseInsensitiveStringCompare(name, m_simplifiedName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ namespace BlackMisc
|
|||||||
thread_local const QRegularExpression reg("^[a-z]+", QRegularExpression::CaseInsensitiveOption);
|
thread_local const QRegularExpression reg("^[a-z]+", QRegularExpression::CaseInsensitiveOption);
|
||||||
QRegularExpressionMatch match = reg.match(countryName);
|
QRegularExpressionMatch match = reg.match(countryName);
|
||||||
const QString cn(match.hasMatch() ? match.captured(0) : 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);
|
return country.matchesCountryName(cn);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ namespace BlackMisc
|
|||||||
QString CCoordinateGeodetic::convertToQString(bool i18n) const
|
QString CCoordinateGeodetic::convertToQString(bool i18n) const
|
||||||
{
|
{
|
||||||
static const QString s = "Geodetic: {%1, %2, %3}";
|
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)
|
CCoordinateGeodetic CCoordinateGeodetic::fromWgs84(const QString &latitudeWgs84, const QString &longitudeWgs84, const CAltitude &geodeticHeight)
|
||||||
@@ -81,7 +81,7 @@ namespace BlackMisc
|
|||||||
|
|
||||||
bool ICoordinateGeodetic::canHandleIndex(const CPropertyIndex &index)
|
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));
|
return (i >= static_cast<int>(IndexLatitude)) && (i <= static_cast<int>(IndexNormalVector));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,22 +92,14 @@ namespace BlackMisc
|
|||||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||||
switch (i)
|
switch (i)
|
||||||
{
|
{
|
||||||
case IndexLatitude:
|
case IndexLatitude: return this->latitude().propertyByIndex(index.copyFrontRemoved());
|
||||||
return this->latitude().propertyByIndex(index.copyFrontRemoved());
|
case IndexLongitude: return this->longitude().propertyByIndex(index.copyFrontRemoved());
|
||||||
case IndexLongitude:
|
case IndexLatitudeAsString: return CVariant(this->latitudeAsString());
|
||||||
return this->longitude().propertyByIndex(index.copyFrontRemoved());
|
case IndexLongitudeAsString: return CVariant(this->longitudeAsString());
|
||||||
case IndexLatitudeAsString:
|
case IndexGeodeticHeight: return this->geodeticHeight().propertyByIndex(index.copyFrontRemoved());
|
||||||
return CVariant(this->latitudeAsString());
|
case IndexGeodeticHeightAsString: return CVariant(this->geodeticHeightAsString());
|
||||||
case IndexLongitudeAsString:
|
case IndexNormalVector: return CVariant::fromValue(this->normalVector());
|
||||||
return CVariant(this->longitudeAsString());
|
default: break;
|
||||||
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>();
|
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||||
switch (i)
|
switch (i)
|
||||||
{
|
{
|
||||||
case IndexLatitude:
|
case IndexLatitude: return this->latitude().comparePropertyByIndex(index.copyFrontRemoved(), compareValue.latitude());
|
||||||
return this->latitude().comparePropertyByIndex(index.copyFrontRemoved(), compareValue.latitude());
|
case IndexLongitude: return this->longitude().comparePropertyByIndex(index.copyFrontRemoved(), compareValue.longitude());
|
||||||
case IndexLongitude:
|
case IndexLatitudeAsString: return this->latitudeAsString().compare(compareValue.latitudeAsString());
|
||||||
return this->longitude().comparePropertyByIndex(index.copyFrontRemoved(), compareValue.longitude());
|
case IndexLongitudeAsString: return this->longitudeAsString().compare(compareValue.longitudeAsString());
|
||||||
case IndexLatitudeAsString:
|
case IndexGeodeticHeight: return this->geodeticHeight().comparePropertyByIndex(index.copyFrontRemoved(), compareValue.geodeticHeight());
|
||||||
return this->latitudeAsString().compare(compareValue.latitudeAsString());
|
case IndexGeodeticHeightAsString: return this->geodeticHeightAsString().compare(compareValue.geodeticHeightAsString());
|
||||||
case IndexLongitudeAsString:
|
default: break;
|
||||||
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)
|
switch (i)
|
||||||
{
|
{
|
||||||
case IndexGeodeticHeight:
|
case IndexGeodeticHeight:
|
||||||
this->m_geodeticHeight.setPropertyByIndex(index.copyFrontRemoved(), variant);
|
m_geodeticHeight.setPropertyByIndex(index.copyFrontRemoved(), variant);
|
||||||
break;
|
break;
|
||||||
case IndexLatitude:
|
case IndexLatitude:
|
||||||
this->setLatitude(variant.value<CLatitude>());
|
this->setLatitude(variant.value<CLatitude>());
|
||||||
@@ -188,7 +173,7 @@ namespace BlackMisc
|
|||||||
this->setLongitude(CLongitude::fromWgs84(variant.toQString()));
|
this->setLongitude(CLongitude::fromWgs84(variant.toQString()));
|
||||||
break;
|
break;
|
||||||
case IndexGeodeticHeightAsString:
|
case IndexGeodeticHeightAsString:
|
||||||
this->m_geodeticHeight.parseFromString(variant.toQString());
|
m_geodeticHeight.parseFromString(variant.toQString());
|
||||||
break;
|
break;
|
||||||
case IndexNormalVector:
|
case IndexNormalVector:
|
||||||
this->setNormalVector(variant.value<QVector3D>());
|
this->setNormalVector(variant.value<QVector3D>());
|
||||||
@@ -226,6 +211,7 @@ namespace BlackMisc
|
|||||||
|
|
||||||
CLongitude CCoordinateGeodetic::longitude() const
|
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() };
|
return { std::atan2(m_y, m_x), PhysicalQuantities::CAngleUnit::rad() };
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -233,15 +219,15 @@ namespace BlackMisc
|
|||||||
{
|
{
|
||||||
return
|
return
|
||||||
{
|
{
|
||||||
static_cast<float>(this->m_x),
|
static_cast<float>(m_x),
|
||||||
static_cast<float>(this->m_y),
|
static_cast<float>(m_y),
|
||||||
static_cast<float>(this->m_z)
|
static_cast<float>(m_z)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::array<double, 3> CCoordinateGeodetic::normalVectorDouble() const
|
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)
|
void CCoordinateGeodetic::setLatitude(const CLatitude &latitude)
|
||||||
@@ -256,28 +242,28 @@ namespace BlackMisc
|
|||||||
|
|
||||||
void CCoordinateGeodetic::setLatLong(const CLatitude &latitude, const CLongitude &longitude)
|
void CCoordinateGeodetic::setLatLong(const CLatitude &latitude, const CLongitude &longitude)
|
||||||
{
|
{
|
||||||
this->m_x = latitude.cos() * longitude.cos();
|
m_x = latitude.cos() * longitude.cos();
|
||||||
this->m_y = latitude.cos() * longitude.sin();
|
m_y = latitude.cos() * longitude.sin();
|
||||||
this->m_z = latitude.sin();
|
m_z = latitude.sin();
|
||||||
}
|
}
|
||||||
|
|
||||||
CCoordinateGeodetic &CCoordinateGeodetic::switchUnit(const CLengthUnit &unit)
|
CCoordinateGeodetic &CCoordinateGeodetic::switchUnit(const CLengthUnit &unit)
|
||||||
{
|
{
|
||||||
this->m_geodeticHeight.switchUnit(unit);
|
m_geodeticHeight.switchUnit(unit);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
CLength ICoordinateWithRelativePosition::calculcateAndUpdateRelativeDistance(const ICoordinateGeodetic &position)
|
CLength ICoordinateWithRelativePosition::calculcateAndUpdateRelativeDistance(const ICoordinateGeodetic &position)
|
||||||
{
|
{
|
||||||
this->m_relativeDistance = Geo::calculateGreatCircleDistance(*this, position);
|
m_relativeDistance = Geo::calculateGreatCircleDistance(*this, position);
|
||||||
return this->m_relativeDistance;
|
return m_relativeDistance;
|
||||||
}
|
}
|
||||||
|
|
||||||
CLength ICoordinateWithRelativePosition::calculcateAndUpdateRelativeDistanceAndBearing(const ICoordinateGeodetic &position)
|
CLength ICoordinateWithRelativePosition::calculcateAndUpdateRelativeDistanceAndBearing(const ICoordinateGeodetic &position)
|
||||||
{
|
{
|
||||||
this->m_relativeDistance = Geo::calculateGreatCircleDistance(*this, position);
|
m_relativeDistance = Geo::calculateGreatCircleDistance(*this, position);
|
||||||
this->m_relativeBearing = Geo::calculateBearing(*this, position);
|
m_relativeBearing = Geo::calculateBearing(*this, position);
|
||||||
return this->m_relativeDistance;
|
return m_relativeDistance;
|
||||||
}
|
}
|
||||||
|
|
||||||
CVariant ICoordinateWithRelativePosition::propertyByIndex(const CPropertyIndex &index) const
|
CVariant ICoordinateWithRelativePosition::propertyByIndex(const CPropertyIndex &index) const
|
||||||
@@ -288,12 +274,9 @@ namespace BlackMisc
|
|||||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||||
switch (i)
|
switch (i)
|
||||||
{
|
{
|
||||||
case IndexRelativeBearing:
|
case IndexRelativeBearing: return this->getRelativeBearing().propertyByIndex(index.copyFrontRemoved());
|
||||||
return this->getRelativeBearing().propertyByIndex(index.copyFrontRemoved());
|
case IndexRelativeDistance: return this->getRelativeDistance().propertyByIndex(index.copyFrontRemoved());
|
||||||
case IndexRelativeDistance:
|
default: break;
|
||||||
return this->getRelativeDistance().propertyByIndex(index.copyFrontRemoved());
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const QString m = QString("no property, index ").append(index.toQString());
|
const QString m = QString("no property, index ").append(index.toQString());
|
||||||
@@ -310,10 +293,10 @@ namespace BlackMisc
|
|||||||
switch (i)
|
switch (i)
|
||||||
{
|
{
|
||||||
case IndexRelativeBearing:
|
case IndexRelativeBearing:
|
||||||
this->m_relativeBearing.setPropertyByIndex(index.copyFrontRemoved(), variant);
|
m_relativeBearing.setPropertyByIndex(index.copyFrontRemoved(), variant);
|
||||||
break;
|
break;
|
||||||
case IndexRelativeDistance:
|
case IndexRelativeDistance:
|
||||||
this->m_relativeDistance.setPropertyByIndex(index.copyFrontRemoved(), variant);
|
m_relativeDistance.setPropertyByIndex(index.copyFrontRemoved(), variant);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
const QString m = QString("no property, index ").append(index.toQString());
|
const QString m = QString("no property, index ").append(index.toQString());
|
||||||
@@ -331,10 +314,8 @@ namespace BlackMisc
|
|||||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||||
switch (i)
|
switch (i)
|
||||||
{
|
{
|
||||||
case IndexRelativeBearing:
|
case IndexRelativeBearing: return m_relativeBearing.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getRelativeBearing());
|
||||||
return this->m_relativeBearing.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getRelativeBearing());
|
case IndexRelativeDistance: return m_relativeDistance.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getRelativeDistance());
|
||||||
case IndexRelativeDistance:
|
|
||||||
return this->m_relativeDistance.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getRelativeDistance());
|
|
||||||
default:
|
default:
|
||||||
const QString m = QString("no property, index ").append(index.toQString());
|
const QString m = QString("no property, index ").append(index.toQString());
|
||||||
Q_ASSERT_X(false, Q_FUNC_INFO, m.toLocal8Bit().constData());
|
Q_ASSERT_X(false, Q_FUNC_INFO, m.toLocal8Bit().constData());
|
||||||
@@ -357,7 +338,7 @@ namespace BlackMisc
|
|||||||
bool ICoordinateWithRelativePosition::canHandleIndex(const CPropertyIndex &index)
|
bool ICoordinateWithRelativePosition::canHandleIndex(const CPropertyIndex &index)
|
||||||
{
|
{
|
||||||
if (ICoordinateGeodetic::canHandleIndex(index)) { return true; }
|
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));
|
return (i >= static_cast<int>(IndexRelativeDistance)) && (i <= static_cast<int>(IndexRelativeBearing));
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ namespace BlackMisc
|
|||||||
//! Properties by index
|
//! Properties by index
|
||||||
enum ColumnIndex
|
enum ColumnIndex
|
||||||
{
|
{
|
||||||
IndexLatitude = BlackMisc::CPropertyIndex::GlobalIndexICoordinateGeodetic,
|
IndexLatitude = CPropertyIndex::GlobalIndexICoordinateGeodetic,
|
||||||
IndexLongitude,
|
IndexLongitude,
|
||||||
IndexLatitudeAsString,
|
IndexLatitudeAsString,
|
||||||
IndexLongitudeAsString,
|
IndexLongitudeAsString,
|
||||||
@@ -72,7 +72,7 @@ namespace BlackMisc
|
|||||||
//! By a similar convention, "elevation" is commonly used for objects that are fixed to the ground.
|
//! 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 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
|
//! \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
|
//! Normal vector
|
||||||
//! \note QVector3D uses floats, so don't use if double precision is needed
|
//! \note QVector3D uses floats, so don't use if double precision is needed
|
||||||
@@ -92,31 +92,34 @@ namespace BlackMisc
|
|||||||
//! Height as string
|
//! Height as string
|
||||||
QString geodeticHeightAsString() const { return this->geodeticHeight().toQString(true); }
|
QString geodeticHeightAsString() const { return this->geodeticHeight().toQString(true); }
|
||||||
|
|
||||||
|
//! Geodetic height null?
|
||||||
|
bool isGeodeticHeightNull() { return this->geodeticHeight().isNull(); }
|
||||||
|
|
||||||
//! Great circle distance
|
//! Great circle distance
|
||||||
BlackMisc::PhysicalQuantities::CLength calculateGreatCircleDistance(const ICoordinateGeodetic &otherCoordinate) const;
|
PhysicalQuantities::CLength calculateGreatCircleDistance(const ICoordinateGeodetic &otherCoordinate) const;
|
||||||
|
|
||||||
//! Initial bearing
|
//! Initial bearing
|
||||||
BlackMisc::PhysicalQuantities::CAngle calculateBearing(const ICoordinateGeodetic &otherCoordinate) const;
|
PhysicalQuantities::CAngle calculateBearing(const ICoordinateGeodetic &otherCoordinate) const;
|
||||||
|
|
||||||
//! \copydoc BlackMisc::Mixin::Index::propertyByIndex
|
//! \copydoc Mixin::Index::propertyByIndex
|
||||||
CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const;
|
CVariant propertyByIndex(const CPropertyIndex &index) const;
|
||||||
|
|
||||||
//! Compare by index
|
//! Compare by index
|
||||||
int comparePropertyByIndex(const CPropertyIndex &index, const ICoordinateGeodetic &compareValue) const;
|
int comparePropertyByIndex(const CPropertyIndex &index, const ICoordinateGeodetic &compareValue) const;
|
||||||
|
|
||||||
//! \copydoc BlackMisc::Mixin::String::toQString
|
//! \copydoc Mixin::String::toQString
|
||||||
QString convertToQString(bool i18n = false) const;
|
QString convertToQString(bool i18n = false) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//! Can given index be handled?
|
//! Can given index be handled?
|
||||||
static bool canHandleIndex(const BlackMisc::CPropertyIndex &index);
|
static bool canHandleIndex(const CPropertyIndex &index);
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Great circle distance between points
|
//! 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
|
//! 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
|
//! Euclidean distance between normal vectors
|
||||||
BLACKMISC_EXPORT double calculateEuclideanDistance(const ICoordinateGeodetic &coordinate1, const ICoordinateGeodetic &coordinate2);
|
BLACKMISC_EXPORT double calculateEuclideanDistance(const ICoordinateGeodetic &coordinate1, const ICoordinateGeodetic &coordinate2);
|
||||||
@@ -131,44 +134,44 @@ namespace BlackMisc
|
|||||||
//! Properties by index
|
//! Properties by index
|
||||||
enum ColumnIndex
|
enum ColumnIndex
|
||||||
{
|
{
|
||||||
IndexRelativeDistance = BlackMisc::CPropertyIndex::GlobalIndexICoordinateWithRelativePosition,
|
IndexRelativeDistance = CPropertyIndex::GlobalIndexICoordinateWithRelativePosition,
|
||||||
IndexRelativeBearing
|
IndexRelativeBearing
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Get the distance
|
//! Get the distance
|
||||||
const BlackMisc::PhysicalQuantities::CLength &getRelativeDistance() const { return m_relativeDistance; }
|
const PhysicalQuantities::CLength &getRelativeDistance() const { return m_relativeDistance; }
|
||||||
|
|
||||||
//! Set relative distance
|
//! 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
|
//! 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
|
//! 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?
|
//! Valid distance?
|
||||||
bool hasValidRelativeDistance() const { return !this->m_relativeDistance.isNull();}
|
bool hasValidRelativeDistance() const { return !m_relativeDistance.isNull();}
|
||||||
|
|
||||||
//! Valid bearing?
|
//! Valid bearing?
|
||||||
bool hasValidRelativeBearing() const { return !this->m_relativeBearing.isNull();}
|
bool hasValidRelativeBearing() const { return !m_relativeBearing.isNull();}
|
||||||
|
|
||||||
//! Calculcate distance, set it, and return distance
|
//! 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
|
//! 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
|
//! \copydoc Mixin::Index::propertyByIndex
|
||||||
CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const;
|
CVariant propertyByIndex(const CPropertyIndex &index) const;
|
||||||
|
|
||||||
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
|
//! \copydoc Mixin::Index::setPropertyByIndex
|
||||||
void setPropertyByIndex(const BlackMisc::CPropertyIndex &index, const CVariant &variant);
|
void setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant);
|
||||||
|
|
||||||
//! Compare by index
|
//! Compare by index
|
||||||
int comparePropertyByIndex(const CPropertyIndex &index, const ICoordinateWithRelativePosition &compareValue) const;
|
int comparePropertyByIndex(const CPropertyIndex &index, const ICoordinateWithRelativePosition &compareValue) const;
|
||||||
|
|
||||||
//! \copydoc BlackMisc::Mixin::String::toQString
|
//! \copydoc Mixin::String::toQString
|
||||||
QString convertToQString(bool i18n = false) const;
|
QString convertToQString(bool i18n = false) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -176,10 +179,10 @@ namespace BlackMisc
|
|||||||
ICoordinateWithRelativePosition();
|
ICoordinateWithRelativePosition();
|
||||||
|
|
||||||
//! Can given index be handled?
|
//! 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
|
PhysicalQuantities::CAngle m_relativeBearing { 0, nullptr }; //!< temporary stored value
|
||||||
BlackMisc::PhysicalQuantities::CLength m_relativeDistance { 0, nullptr }; //!< temporary stored value
|
PhysicalQuantities::CLength m_relativeDistance { 0, nullptr }; //!< temporary stored value
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Geodetic coordinate
|
//! Geodetic coordinate
|
||||||
@@ -193,7 +196,7 @@ namespace BlackMisc
|
|||||||
CCoordinateGeodetic(const QVector3D &normal) : m_x(normal.x()), m_y(normal.y()), m_z(normal.z()) {}
|
CCoordinateGeodetic(const QVector3D &normal) : m_x(normal.x()), m_y(normal.y()), m_z(normal.z()) {}
|
||||||
|
|
||||||
//! Constructor by values
|
//! 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
|
//! Constructor by double values, but no geodetic height
|
||||||
CCoordinateGeodetic(double latitudeDegrees, double longitudeDegrees);
|
CCoordinateGeodetic(double latitudeDegrees, double longitudeDegrees);
|
||||||
@@ -211,7 +214,7 @@ namespace BlackMisc
|
|||||||
virtual CLongitude longitude() const override;
|
virtual CLongitude longitude() const override;
|
||||||
|
|
||||||
//! \copydoc ICoordinateGeodetic::geodeticHeight
|
//! \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
|
//! \copydoc ICoordinateGeodetic::normalVector
|
||||||
virtual QVector3D normalVector() const override;
|
virtual QVector3D normalVector() const override;
|
||||||
@@ -219,14 +222,14 @@ namespace BlackMisc
|
|||||||
//! \copydoc ICoordinateGeodetic::normalVectorDouble
|
//! \copydoc ICoordinateGeodetic::normalVectorDouble
|
||||||
virtual std::array<double, 3> normalVectorDouble() const override;
|
virtual std::array<double, 3> normalVectorDouble() const override;
|
||||||
|
|
||||||
//! \copydoc BlackMisc::Mixin::Index::propertyByIndex
|
//! \copydoc Mixin::Index::propertyByIndex
|
||||||
CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const;
|
CVariant propertyByIndex(const CPropertyIndex &index) const;
|
||||||
|
|
||||||
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
|
//! \copydoc Mixin::Index::setPropertyByIndex
|
||||||
void setPropertyByIndex(const BlackMisc::CPropertyIndex &index, const CVariant &variant);
|
void setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant);
|
||||||
|
|
||||||
//! Switch unit of height
|
//! Switch unit of height
|
||||||
CCoordinateGeodetic &switchUnit(const BlackMisc::PhysicalQuantities::CLengthUnit &unit);
|
CCoordinateGeodetic &switchUnit(const PhysicalQuantities::CLengthUnit &unit);
|
||||||
|
|
||||||
//! Set latitude
|
//! Set latitude
|
||||||
void setLatitude(const CLatitude &latitude);
|
void setLatitude(const CLatitude &latitude);
|
||||||
@@ -238,25 +241,28 @@ namespace BlackMisc
|
|||||||
void setLatLong(const CLatitude &latitude, const CLongitude &longitude);
|
void setLatLong(const CLatitude &latitude, const CLongitude &longitude);
|
||||||
|
|
||||||
//! Set height (ellipsoidal or geodetic height)
|
//! 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
|
//! 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
|
//! 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
|
//! 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;
|
QString convertToQString(bool i18n = false) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
double m_x = 0; //!< normal vector
|
// Coordinates are stored using `double` internally and use `double` for most calculations.
|
||||||
double m_y = 0; //!< normal vector
|
// They use `double` when converting to and from lat/lon representation.
|
||||||
double m_z = 0; //!< normal vector
|
// `QVector3D` is only used for calculating distance and bearing.
|
||||||
BlackMisc::Aviation::CAltitude m_geodeticHeight { 0, nullptr }; //!< height, ellipsoidal or geodetic height
|
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(
|
BLACK_METACLASS(
|
||||||
CCoordinateGeodetic,
|
CCoordinateGeodetic,
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
#include "blackmisc/pq/units.h"
|
#include "blackmisc/pq/units.h"
|
||||||
#include "blackmisc/sequence.h"
|
#include "blackmisc/sequence.h"
|
||||||
|
|
||||||
|
#include <QStringBuilder>
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
|
||||||
namespace BlackMisc
|
namespace BlackMisc
|
||||||
@@ -30,7 +31,7 @@ namespace BlackMisc
|
|||||||
|
|
||||||
CIcons::IconIndex CIcon::getIndex() const
|
CIcons::IconIndex CIcon::getIndex() const
|
||||||
{
|
{
|
||||||
return this->m_index;
|
return m_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CIcon::isIndexBased() const
|
bool CIcon::isIndexBased() const
|
||||||
@@ -40,17 +41,17 @@ namespace BlackMisc
|
|||||||
|
|
||||||
bool CIcon::isGenerated() const
|
bool CIcon::isGenerated() const
|
||||||
{
|
{
|
||||||
return getIndex() == CIcons::IconIsGenerated;
|
return this->getIndex() == CIcons::IconIsGenerated;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CIcon::isFileBased() const
|
bool CIcon::isFileBased() const
|
||||||
{
|
{
|
||||||
return getIndex() == CIcons::IconIsFile;
|
return this->getIndex() == CIcons::IconIsFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CIcon::isSet() const
|
bool CIcon::isSet() const
|
||||||
{
|
{
|
||||||
return (this->m_index != CIcons::NotSet);
|
return (m_index != CIcons::NotSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
QPixmap CIcon::toPixmap() const
|
QPixmap CIcon::toPixmap() const
|
||||||
@@ -59,7 +60,7 @@ namespace BlackMisc
|
|||||||
{
|
{
|
||||||
if (this->isGenerated()) { return m_pixmap; }
|
if (this->isGenerated()) { return m_pixmap; }
|
||||||
if (this->isFileBased()) { return m_pixmap; }
|
if (this->isFileBased()) { return m_pixmap; }
|
||||||
return CIcons::pixmapByIndex(getIndex(), this->m_rotateDegrees);
|
return CIcons::pixmapByIndex(getIndex(), m_rotateDegrees);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -74,13 +75,13 @@ namespace BlackMisc
|
|||||||
|
|
||||||
void CIcon::setRotation(const PhysicalQuantities::CAngle &rotate)
|
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
|
QString CIcon::convertToQString(bool i18n) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(i18n);
|
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;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -180,23 +180,16 @@ namespace BlackMisc
|
|||||||
CVariant CInterpolationAndRenderingSetup::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
CVariant CInterpolationAndRenderingSetup::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
||||||
{
|
{
|
||||||
if (index.isMyself()) { return CVariant::from(*this); }
|
if (index.isMyself()) { return CVariant::from(*this); }
|
||||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||||
switch (i)
|
switch (i)
|
||||||
{
|
{
|
||||||
case IndexInterpolatorDebugMessages:
|
case IndexInterpolatorDebugMessages: return CVariant::fromValue(m_interpolatorDebugMessage);
|
||||||
return CVariant::fromValue(m_interpolatorDebugMessage);
|
case IndexSimulatorDebugMessages: return CVariant::fromValue(m_simulatorDebugMessages);
|
||||||
case IndexSimulatorDebugMessages:
|
case IndexForceFullInterpolation: return CVariant::fromValue(m_forceFullInterpolation);
|
||||||
return CVariant::fromValue(m_simulatorDebugMessages);
|
case IndexMaxRenderedAircraft: return CVariant::fromValue(m_maxRenderedAircraft);
|
||||||
case IndexForceFullInterpolation:
|
case IndexMaxRenderedDistance: return CVariant::fromValue(m_maxRenderedDistance);
|
||||||
return CVariant::fromValue(m_forceFullInterpolation);
|
case IndexEnabledAircraftParts: return CVariant::fromValue(m_enabledAircraftParts);
|
||||||
case IndexMaxRenderedAircraft:
|
default: return CValueObject::propertyByIndex(index);
|
||||||
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>();
|
*this = variant.value<CInterpolationAndRenderingSetup>();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||||
switch (i)
|
switch (i)
|
||||||
{
|
{
|
||||||
case IndexInterpolatorDebugMessages:
|
case IndexInterpolatorDebugMessages: m_interpolatorDebugMessage = variant.toBool(); break;
|
||||||
m_interpolatorDebugMessage = variant.toBool();
|
case IndexSimulatorDebugMessages: m_simulatorDebugMessages = variant.toBool(); break;
|
||||||
break;
|
case IndexForceFullInterpolation: m_forceFullInterpolation = variant.toBool(); break;
|
||||||
case IndexSimulatorDebugMessages:
|
case IndexMaxRenderedAircraft: m_maxRenderedAircraft = variant.toInt(); break;
|
||||||
m_simulatorDebugMessages = variant.toBool();
|
case IndexMaxRenderedDistance: m_maxRenderedDistance = variant.value<CLength>(); break;
|
||||||
break;
|
case IndexEnabledAircraftParts: m_enabledAircraftParts = variant.toBool(); break;
|
||||||
case IndexForceFullInterpolation:
|
default: CValueObject::setPropertyByIndex(index, variant); break;
|
||||||
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
|
} // ns
|
||||||
|
|||||||
@@ -24,7 +24,9 @@ namespace BlackMisc
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
BlackMisc::Aviation::CAircraftSituation CInterpolatorMulti::getInterpolatedSituation(
|
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)
|
switch (m_mode)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -32,12 +32,14 @@ namespace BlackMisc
|
|||||||
|
|
||||||
//! \copydoc CInterpolator::getInterpolatedSituation
|
//! \copydoc CInterpolator::getInterpolatedSituation
|
||||||
BlackMisc::Aviation::CAircraftSituation getInterpolatedSituation(
|
BlackMisc::Aviation::CAircraftSituation getInterpolatedSituation(
|
||||||
qint64 currentTimeSinceEpoc, const CInterpolationAndRenderingSetup &setup,
|
qint64 currentTimeSinceEpoc,
|
||||||
|
const CInterpolationAndRenderingSetup &setup,
|
||||||
const CInterpolationHints &hints, CInterpolationStatus &status);
|
const CInterpolationHints &hints, CInterpolationStatus &status);
|
||||||
|
|
||||||
//! \copydoc CInterpolator::getInterpolatedParts
|
//! \copydoc CInterpolator::getInterpolatedParts
|
||||||
BlackMisc::Aviation::CAircraftParts getInterpolatedParts(
|
BlackMisc::Aviation::CAircraftParts getInterpolatedParts(
|
||||||
qint64 currentTimeSinceEpoc, const CInterpolationAndRenderingSetup &setup,
|
qint64 currentTimeSinceEpoc,
|
||||||
|
const CInterpolationAndRenderingSetup &setup,
|
||||||
CPartsStatus &partsStatus, bool log = false);
|
CPartsStatus &partsStatus, bool log = false);
|
||||||
|
|
||||||
//! \copydoc CInterpolator::addAircraftSituation
|
//! \copydoc CInterpolator::addAircraftSituation
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ namespace BlackSimPlugin
|
|||||||
|
|
||||||
// reset flags
|
// reset flags
|
||||||
m_simPaused = false;
|
m_simPaused = false;
|
||||||
emitSimulatorCombinedStatus();
|
this->emitSimulatorCombinedStatus();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ namespace BlackSimPlugin
|
|||||||
|
|
||||||
CSimulatorFsxCommon::~CSimulatorFsxCommon()
|
CSimulatorFsxCommon::~CSimulatorFsxCommon()
|
||||||
{
|
{
|
||||||
disconnectFrom();
|
this->disconnectFrom();
|
||||||
// fsuipc is disconnected in CSimulatorFsCommon
|
// fsuipc is disconnected in CSimulatorFsCommon
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,8 +92,8 @@ namespace BlackSimPlugin
|
|||||||
if (m_useFsuipc) { m_fsuipc->connect(); } // FSUIPC too
|
if (m_useFsuipc) { m_fsuipc->connect(); } // FSUIPC too
|
||||||
|
|
||||||
// set structures and move on
|
// set structures and move on
|
||||||
initEvents();
|
this->initEvents();
|
||||||
initDataDefinitionsWhenConnected();
|
this->initDataDefinitionsWhenConnected();
|
||||||
m_simConnectTimerId = startTimer(DispatchIntervalMs);
|
m_simConnectTimerId = startTimer(DispatchIntervalMs);
|
||||||
// do not start m_addPendingAircraftTimer here, it will be started when object was added
|
// 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_simConnected) { return true; }
|
||||||
if (m_simConnectTimerId >= 0) { killTimer(m_simConnectTimerId); }
|
if (m_simConnectTimerId >= 0) { killTimer(m_simConnectTimerId); }
|
||||||
m_simConnectTimerId = -1;
|
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)
|
if (m_hSimConnect)
|
||||||
{
|
{
|
||||||
SimConnect_Close(m_hSimConnect);
|
SimConnect_Close(m_hSimConnect);
|
||||||
m_hSimConnect = nullptr;
|
m_hSimConnect = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
reset();
|
this->reset(); // mark as disconnected and reset all values
|
||||||
|
|
||||||
// emit status and disconnect FSUIPC
|
// emit status and disconnect FSUIPC
|
||||||
CSimulatorFsCommon::disconnectFrom();
|
CSimulatorFsCommon::disconnectFrom();
|
||||||
@@ -327,15 +327,15 @@ namespace BlackSimPlugin
|
|||||||
void CSimulatorFsxCommon::onSimStopped()
|
void CSimulatorFsxCommon::onSimStopped()
|
||||||
{
|
{
|
||||||
// stopping events in FSX: Load menu, weather and season
|
// stopping events in FSX: Load menu, weather and season
|
||||||
const SimulatorStatus oldStatus = getSimulatorStatus();
|
const SimulatorStatus oldStatus = this->getSimulatorStatus();
|
||||||
m_simSimulating = false;
|
m_simSimulating = false;
|
||||||
m_simulatingChangedTs = QDateTime::currentMSecsSinceEpoch();
|
m_simulatingChangedTs = QDateTime::currentMSecsSinceEpoch();
|
||||||
emitSimulatorCombinedStatus(oldStatus);
|
this->emitSimulatorCombinedStatus(oldStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSimulatorFsxCommon::onSimFrame()
|
void CSimulatorFsxCommon::onSimFrame()
|
||||||
{
|
{
|
||||||
updateRemoteAircraft();
|
this->updateRemoteAircraft();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSimulatorFsxCommon::onSimExit()
|
void CSimulatorFsxCommon::onSimExit()
|
||||||
@@ -559,7 +559,7 @@ namespace BlackSimPlugin
|
|||||||
simObject.setConfirmedAdded(true);
|
simObject.setConfirmedAdded(true);
|
||||||
|
|
||||||
// P3D also has SimConnect_AIReleaseControlEx;
|
// P3D also has SimConnect_AIReleaseControlEx;
|
||||||
const DWORD requestId = obtainRequestIdSimData();
|
const DWORD requestId = this->obtainRequestIdSimData();
|
||||||
const DWORD objectId = simObject.getObjectId();
|
const DWORD objectId = simObject.getObjectId();
|
||||||
HRESULT hr = SimConnect_AIReleaseControl(m_hSimConnect, objectId, static_cast<SIMCONNECT_DATA_REQUEST_ID>(requestId));
|
HRESULT hr = SimConnect_AIReleaseControl(m_hSimConnect, objectId, static_cast<SIMCONNECT_DATA_REQUEST_ID>(requestId));
|
||||||
hr += SimConnect_TransmitClientEvent(m_hSimConnect, objectId, EventFreezeLat, 1,
|
hr += SimConnect_TransmitClientEvent(m_hSimConnect, objectId, EventFreezeLat, 1,
|
||||||
@@ -729,7 +729,7 @@ namespace BlackSimPlugin
|
|||||||
void CSimulatorFsxCommon::timerEvent(QTimerEvent *event)
|
void CSimulatorFsxCommon::timerEvent(QTimerEvent *event)
|
||||||
{
|
{
|
||||||
Q_UNUSED(event);
|
Q_UNUSED(event);
|
||||||
dispatch();
|
this->dispatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString &CSimulatorFsxCommon::modeToString(CSimulatorFsxCommon::AircraftAddMode mode)
|
const QString &CSimulatorFsxCommon::modeToString(CSimulatorFsxCommon::AircraftAddMode mode)
|
||||||
@@ -841,8 +841,8 @@ namespace BlackSimPlugin
|
|||||||
const CAircraftModel aircraftModel = newRemoteAircraft.getModel();
|
const CAircraftModel aircraftModel = newRemoteAircraft.getModel();
|
||||||
CSimulatedAircraft addedAircraft(newRemoteAircraft);
|
CSimulatedAircraft addedAircraft(newRemoteAircraft);
|
||||||
|
|
||||||
const DWORD requestId = obtainRequestIdSimData();
|
const DWORD requestId = this->obtainRequestIdSimData();
|
||||||
SIMCONNECT_DATA_INITPOSITION initialPosition = aircraftSituationToFsxPosition(addedAircraft.getSituation());
|
const SIMCONNECT_DATA_INITPOSITION initialPosition = aircraftSituationToFsxPosition(addedAircraft.getSituation());
|
||||||
const QString modelString(addedAircraft.getModelString());
|
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))); }
|
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();
|
const CStatusMessage msg = CStatusMessage(this).error("SimConnect, can not create AI traffic: '%1' '%2'") << callsign.toQString() << aircraftModel.getModelString();
|
||||||
CLogMessage::preformatted(msg);
|
CLogMessage::preformatted(msg);
|
||||||
emit physicallyAddingRemoteModelFailed(addedAircraft, msg);
|
emit this->physicallyAddingRemoteModelFailed(addedAircraft, msg);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1424,7 +1424,7 @@ namespace BlackSimPlugin
|
|||||||
m_requestIdSimData = RequestSimDataStart;
|
m_requestIdSimData = RequestSimDataStart;
|
||||||
m_dispatchErrors = 0;
|
m_dispatchErrors = 0;
|
||||||
m_receiveExceptionCount = 0;
|
m_receiveExceptionCount = 0;
|
||||||
CSimulatorFsCommon::reset();
|
CSimulatorFsCommon::reset(); // clears all pending aircraft etc
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSimulatorFsxCommon::clearAllAircraft()
|
void CSimulatorFsxCommon::clearAllAircraft()
|
||||||
|
|||||||
@@ -55,16 +55,16 @@ namespace BlackSimPlugin
|
|||||||
const DWORD sendId = exception->dwSendID;
|
const DWORD sendId = exception->dwSendID;
|
||||||
const DWORD index = exception->dwIndex;
|
const DWORD index = exception->dwIndex;
|
||||||
const DWORD data = cbData;
|
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)
|
switch (exceptionId)
|
||||||
{
|
{
|
||||||
case SIMCONNECT_EXCEPTION_OPERATION_INVALID_FOR_OBJECT_TYPE: break;
|
case SIMCONNECT_EXCEPTION_OPERATION_INVALID_FOR_OBJECT_TYPE: break;
|
||||||
case SIMCONNECT_EXCEPTION_UNRECOGNIZED_ID: break;
|
case SIMCONNECT_EXCEPTION_UNRECOGNIZED_ID: break;
|
||||||
default: 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;
|
break;
|
||||||
}
|
}
|
||||||
case SIMCONNECT_RECV_ID_QUIT:
|
case SIMCONNECT_RECV_ID_QUIT:
|
||||||
@@ -74,7 +74,7 @@ namespace BlackSimPlugin
|
|||||||
}
|
}
|
||||||
case SIMCONNECT_RECV_ID_EVENT:
|
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)
|
switch (event->uEventID)
|
||||||
{
|
{
|
||||||
case SystemEventSimStatus:
|
case SystemEventSimStatus:
|
||||||
@@ -117,7 +117,7 @@ namespace BlackSimPlugin
|
|||||||
|
|
||||||
// such an object is not necessarily one of ours
|
// such an object is not necessarily one of ours
|
||||||
// for instance, I always see object "5" when I start the simulator
|
// 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)
|
switch (event->uEventID)
|
||||||
{
|
{
|
||||||
case SystemEventObjectAdded:
|
case SystemEventObjectAdded:
|
||||||
@@ -133,7 +133,7 @@ namespace BlackSimPlugin
|
|||||||
}
|
}
|
||||||
case SIMCONNECT_RECV_ID_EVENT_FRAME:
|
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)
|
switch (event->uEventID)
|
||||||
{
|
{
|
||||||
case SystemEventFrame:
|
case SystemEventFrame:
|
||||||
@@ -147,7 +147,7 @@ namespace BlackSimPlugin
|
|||||||
}
|
}
|
||||||
case SIMCONNECT_RECV_ID_ASSIGNED_OBJECT_ID:
|
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 requestId = event->dwRequestID;
|
||||||
const DWORD objectId = event->dwObjectID;
|
const DWORD objectId = event->dwObjectID;
|
||||||
bool success = simulatorFsx->setSimConnectObjectId(requestId, objectId);
|
bool success = simulatorFsx->setSimConnectObjectId(requestId, objectId);
|
||||||
@@ -170,7 +170,7 @@ namespace BlackSimPlugin
|
|||||||
}
|
}
|
||||||
case SIMCONNECT_RECV_ID_SIMOBJECT_DATA:
|
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;
|
const DWORD requestId = pObjData->dwRequestID;
|
||||||
switch (requestId)
|
switch (requestId)
|
||||||
{
|
{
|
||||||
@@ -249,10 +249,10 @@ namespace BlackSimPlugin
|
|||||||
{
|
{
|
||||||
static const CLength maxDistance(200.0, CLengthUnit::NM());
|
static const CLength maxDistance(200.0, CLengthUnit::NM());
|
||||||
const CCoordinateGeodetic posAircraft(simulatorFsx->getOwnAircraftPosition());
|
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)
|
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; }
|
if (!pFacilityAirport) { break; }
|
||||||
const QString icao(pFacilityAirport->Icao);
|
const QString icao(pFacilityAirport->Icao);
|
||||||
if (icao.isEmpty()) { continue; } // airfield without ICAO code
|
if (icao.isEmpty()) { continue; } // airfield without ICAO code
|
||||||
@@ -276,7 +276,7 @@ namespace BlackSimPlugin
|
|||||||
case SIMCONNECT_RECV_ID_CLIENT_DATA:
|
case SIMCONNECT_RECV_ID_CLIENT_DATA:
|
||||||
{
|
{
|
||||||
if (!simulatorFsx->m_useSbOffsets) { break; }
|
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)
|
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
|
//! \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:
|
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)
|
switch (event->uEventID)
|
||||||
{
|
{
|
||||||
case SystemEventFlightLoaded: break;
|
case SystemEventFlightLoaded: break;
|
||||||
|
|||||||
Reference in New Issue
Block a user