116 lines
4.2 KiB
C++
Executable File
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 <CentralEffectSimulation/svccesddscommon_export.h>
|
|
#include <CentralEffectSimulation/dds_handler.h>
|
|
|
|
#include <QObject>
|
|
#include <QPolygonF>
|
|
#include <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
|
|
|