/** * Handler for player data * $Id$ * $HeadURL$ * $Author$ * Created by gr, SLSE, 2017-02-20 */ #pragma once #include #include #include #include #include #include // 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 &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 polygonEncloseBuildings(const QPolygonF &polygon); QVector getFloorsFromStructureElementId(int structureElementId) const; QVector getFloorsFromBuilding(int buildingId) const; InfrastructureManagement::MainStructureElement mainStructureElement(int mseId) const { return m_mainStructureElements.value(mseId); } QHash getAssetPositions(){return m_assetPositions;} void printAssetPositions(); QHash 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 m_ddsHandler; ///< Pointer to VOM DDS handler QHash m_mainStructureElements; QHash m_floorRoom; // key = roomId, Value = floorId QHash m_structureElementToFloor; // key = floorId, Value = structureElementId QHash m_buildingFloor; // key = floorId, Value = buildingId (ism_main_structure_element) QHash m_ToFloor; // key = floorId, Value = structureElementId QHash m_mountingPointAsset; // key = structureElementId , Value = assetId; QHash m_assetMountingPoint; // key = assetId , Value = structureElementId; QHash m_instrumentationAssets; // key = assetId, Value = hostname QHash m_assetPositions; // key = structureElementId QHash m_footprints; // key = footprint.mseId int m_zone = -1; CentralEffectSimulation::LOGGER_T &m_logger; ///< Interface to the Logging-Facility }; } // namespace CentralEffectSimulation2D