Files
qt-migration-legatus/qt6-after/qt6-migrated-legatus/Lts/Services/CentralEffectSimulation/handler_building_data.h
T
torstenandCopilot 7a6be7474e Qt6 migration: Fix BUILD_RTI=OFF build errors in TrainingAreaBase
- training_area_telegrams.cpp: Fixed QJsonObject initializer syntax (Qt6 requires {{}} not ({}))
- training_area_telegrams.cpp: Fixed fromJson() methods to access m_* members directly
- training_area_telegrams.cpp: Fixed brace mismatches in multiple toJson() methods
- training_area_telegrams.h: Changed Header struct to public members for consistency
- tx_mixin.cpp: Fixed getEquipmentNumber() template for direct member access
- lts_coordinate.cpp: Added missing #include <iomanip>
- MIGRATION_STATUS.md: Added migration progress tracking document

C++17 constraint enforced due to RTI Connext DDS 7.7.0 incompatibility with C++20+

Build status: BUILD_RTI=OFF successful (0 errors, warnings only)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-08-23 20:49:23 +02:00

116 lines
4.2 KiB
C++
Executable File

/**
* Handler for player data
* $Id$
* $HeadURL$
* $Author$
* Created by gr, SLSE, 2017-02-20
*/
#pragma once
#include <CentralEffectSimulation/logger.h>
#include "svccesddscommon_export.h"
#include <CentralEffectSimulation/dds_handler.h>
#include <QtCore/QObject>
#include <QPolygonF>
#include <QtCore/QHash>
// Data for buildings
namespace CentralEffectSimulation
{
//------------------------------------------------------------------------------
// Helper function to calculate the (2D) center of a polygon like a (metric) footprint
//------------------------------------------------------------------------------
// Note:
// The centroid of a non-self-intersecting closed polygon defined by n vertices.
QPointF compute2DPolygonCentroid_deprecated(const QPolygonF &metricVertices);
//------------------------------------------------------------------------------
// class HandlerBuildingData
//------------------------------------------------------------------------------
class SVCCESDDSCOMMON_EXPORT HandlerBuildingData : public QObject
{
Q_OBJECT
public:
struct AssetPosition
{
int structureElementId;
InfrastructureManagement::MountingPointType mountingPointType;
QString hostname;
Core::RelativePosition relPosition;
Core::GeoPosition geoPosition;
QPointF positionUtm;
int zone;
};
struct Footprint
{
int mseId{-1};
int zone{-1};
Core::GeoPosition geoPosition;
QPolygonF polyUtm;
QRectF boundingBoxPolyUtm;
QPointF centroid; // centroid for concealment calculation (Verdeckung)
bool isValid() const { return mseId > 0; }
};
explicit HandlerBuildingData(const std::shared_ptr<CentralEffectSimulation::DdsHandler> &ddsHandler, QObject *parent = nullptr);
~HandlerBuildingData();
/**
* Initialize the handler to manage information from player management
*/
bool init();
int getFloorIdFromRoomId(int roomId) const { return m_floorRoom.value(roomId, -1); }
int getBuildingIdFromFloorId(int floorId) const { return m_buildingFloor.value(floorId, -1); }
int getBuildingIdFromRoomId(const int roomId);
QVector<int> polygonEncloseBuildings(const QPolygonF &polygon);
QVector<int> getFloorsFromStructureElementId(int structureElementId) const;
QVector<int> getFloorsFromBuilding(int buildingId) const;
InfrastructureManagement::MainStructureElement mainStructureElement(int mseId) const { return m_mainStructureElements.value(mseId); }
QHash<int, AssetPosition> getAssetPositions(){return m_assetPositions;}
void printAssetPositions();
QHash<int, Footprint> getFootprints(){return m_footprints;}
private:
void getFootprintsByExercise();
private Q_SLOTS:
/**
* Handle MainStructureElement from 'ISM'
*/
void onMainStructureElementChanged(const InfrastructureManagement::MainStructureElement &data, DataModification modType);
void onMountingPointAssetChanged(const InfrastructureManagement::MountingPointAsset &data, DataModification modType);
void onInstrumentationAssetChanged(const InfrastructureManagement::InstrumentationAsset &data, DataModification modType);
private: // attributes
std::shared_ptr<CentralEffectSimulation::DdsHandler> m_ddsHandler; ///< Pointer to VOM DDS handler
QHash<int, InfrastructureManagement::MainStructureElement> m_mainStructureElements;
QHash<int, int> m_floorRoom; // key = roomId, Value = floorId
QHash<int, int> m_structureElementToFloor; // key = floorId, Value = structureElementId
QHash<int, int> m_buildingFloor; // key = floorId, Value = buildingId (ism_main_structure_element)
QHash<int, int> m_ToFloor; // key = floorId, Value = structureElementId
QHash<int, int> m_mountingPointAsset; // key = structureElementId , Value = assetId;
QHash<int, int> m_assetMountingPoint; // key = assetId , Value = structureElementId;
QHash<int, QString> m_instrumentationAssets; // key = assetId, Value = hostname
QHash<int, AssetPosition> m_assetPositions; // key = structureElementId
QHash<int, Footprint> m_footprints; // key = footprint.mseId
int m_zone = -1;
CentralEffectSimulation::LOGGER_T &m_logger; ///< Interface to the Logging-Facility
};
} // namespace CentralEffectSimulation2D