Migrates remaining include, viewer and DDS headers to rtiddsgen API
Converts accessor calls to plain member access and fixes SituationMap CMake.
This commit is contained in:
5 files changed
+85
-21
No files matched your search
@@ -6,6 +6,12 @@
|
||||
#include <AssetManagement/asm_data_plugin_interface.h>
|
||||
#include <ExerciseManagement/exm_data_plugin_interface.h>
|
||||
#include <Viewer/SituationMap/ElevationMap/elevation_map_manager.h>
|
||||
#include <Viewer/SituationMap/Common/resource_path.h>
|
||||
|
||||
#include <QDir>
|
||||
#include <QHash>
|
||||
#include <QSharedPointer>
|
||||
#include <QUrl>
|
||||
|
||||
static_assert((int)SituationMap::ElevationMapManager::LineOfSight::LOS_UNDEFINED ==
|
||||
(int)LtsElevation::LineOfSight::LOS_UNDEFINED,
|
||||
@@ -106,15 +112,71 @@ LtsElevationManager::createInstance(int exerciseId, const std::shared_ptr<Exerci
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QStringList filePaths_rough_to_fine;
|
||||
// Qt5 logic restored (the qt6 port had dropped the exerciseId->trainingAreaId
|
||||
// caching and always returned nullptr here).
|
||||
#ifdef BUILD_RTI
|
||||
filePaths_rough_to_fine = getFilenamesForExercise(exerciseId);
|
||||
int trainingAreaId = -1;
|
||||
|
||||
// remember for future calls
|
||||
// (so createInstance should work WITHOUT dtcs)
|
||||
// Idea: MainHandler: createInstance with exerciseId and valid dtcs
|
||||
// Plugin or simular: createInstance with exerciseId and no dtcs
|
||||
static QHash<int, int> s_exIdToTaIdStore;
|
||||
|
||||
const auto exTaIt = s_exIdToTaIdStore.find(exerciseId);
|
||||
if (exTaIt != s_exIdToTaIdStore.end())
|
||||
{
|
||||
// CASE 1:
|
||||
// already created:
|
||||
trainingAreaId = *exTaIt;
|
||||
}
|
||||
else
|
||||
{
|
||||
// CASE 2:
|
||||
// ... or create on demand:
|
||||
if (!exmDtc || !asmDtc)
|
||||
{
|
||||
ERROR_LOG(logger) << Q_FUNC_INFO << " no dtcs for exerciseId=" << exerciseId
|
||||
<< ", asmDtc=" << asmDtc
|
||||
<< ", exmDtc=" << exmDtc;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// exId to taId
|
||||
trainingAreaId = exerciseIdToTrainingAreaId(exerciseId, exmDtc);
|
||||
if (trainingAreaId <= 0)
|
||||
{
|
||||
ERROR_LOG(logger) << Q_FUNC_INFO << " Error getting trainingAreaId"
|
||||
<< ", exerciseId=" << exerciseId
|
||||
<< ", trainingAreaId=" << trainingAreaId;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// store and remember:
|
||||
s_exIdToTaIdStore[exerciseId] = trainingAreaId;
|
||||
}
|
||||
|
||||
// CASE 1: Following should work even with invalid asmDtc:
|
||||
LTS_ELEVATION_MANAGER_TYPE temp = createInstanceForTrainingAreaId(trainingAreaId, asmDtc);
|
||||
if (!temp)
|
||||
{
|
||||
ERROR_LOG(logger) << Q_FUNC_INFO << " Error on createInstanceForTrainingAreaId"
|
||||
<< ", exerciseId=" << exerciseId
|
||||
<< ", trainingAreaId=" << trainingAreaId;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// add exmDtc
|
||||
temp->initDDS(exmDtc, asmDtc);
|
||||
|
||||
TRACE_LOG(logger) << Q_FUNC_INFO << " END, exerciseId=" << exerciseId;
|
||||
return temp;
|
||||
#else
|
||||
Q_UNUSED(exerciseId);
|
||||
ERROR_LOG(logger) << Q_FUNC_INFO << " BUILD_RTI=OFF, cannot get filenames for exercise";
|
||||
#endif
|
||||
Q_UNUSED(filePaths_rough_to_fine);
|
||||
Q_UNUSED(exmDtc);
|
||||
Q_UNUSED(asmDtc);
|
||||
ERROR_LOG(logger) << Q_FUNC_INFO << " BUILD_RTI=OFF, cannot create instance";
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
LTS_ELEVATION_MANAGER_TYPE LtsElevationManager::getInstance(int exerciseId)
|
||||
@@ -291,19 +353,19 @@ QStringList LtsElevationManager::getFilenamesForTrainingArea(int trainingAreaId)
|
||||
{
|
||||
d->m_asmDtc->waitForHistoricalDataTrainingArea(1000);
|
||||
const AssetManagement::TrainingArea& ta = d->m_asmDtc->trainingArea(trainingAreaId);
|
||||
if (ta.id() != trainingAreaId)
|
||||
if (ta.id != trainingAreaId)
|
||||
{
|
||||
ERROR_LOG(m_logger) << Q_FUNC_INFO << " Error on s_asmDtc->trainingArea"
|
||||
<< ", trainingAreaId=" << trainingAreaId;
|
||||
return {};
|
||||
}
|
||||
const std::vector<AssetManagement::MapDescription>& mdVec = ta.elevation();
|
||||
const std::vector<AssetManagement::MapDescription>& mdVec = ta.elevation;
|
||||
filePaths_rough_to_fine.reserve(mdVec.size());
|
||||
|
||||
for (const AssetManagement::MapDescription& md : std::as_const(mdVec))
|
||||
{
|
||||
|
||||
QUrl url(QString::fromStdString(md.url()));
|
||||
QUrl url(QString::fromStdString(md.url));
|
||||
QString filePathAbs = url.toLocalFile();
|
||||
if (QDir::isRelativePath(filePathAbs))
|
||||
filePathAbs = SituationMap::getResourcePath() + QStringLiteral("/elevation/") + filePathAbs;
|
||||
@@ -372,13 +434,13 @@ int LtsElevationManager::exerciseIdToTrainingAreaId(int exerciseId,
|
||||
exmDtc->waitForHistoricalDataExercise(1000);
|
||||
|
||||
const ExerciseManagement::Exercise& exm = exmDtc->exercise(exerciseId);
|
||||
if (exm.id() != exerciseId)
|
||||
if (exm.id != exerciseId)
|
||||
{
|
||||
ERROR_LOG(logger) << Q_FUNC_INFO << " Error on m_exmDtc->exercise"
|
||||
<< ", exerciseId=" << exerciseId;
|
||||
return -1;
|
||||
}
|
||||
trainingAreaId = exm.trainingAreaId();
|
||||
trainingAreaId = exm.trainingAreaId;
|
||||
|
||||
if (trainingAreaId <= 0)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user