Files
qt5-legatus-legacy/Lts/Services/CentralEffectSimulation/Plugins/Buildings/handler_building_model.h
T
2026-08-13 18:33:10 +02:00

119 lines
4.5 KiB
C++
Executable File

/**
* Handler for building models.
* $Id$
* $HeadURL$
* $Author$
* Created by biedziak_f, SLTE, 2021-03-23
*/
#pragma once
#include "ces_building_model.h"
#include "handler_aes_data.h"
// for interface
#include "../../proxy_building.h"
#include <CentralEffectSimulation/dds_handler.h>
#include <QObject>
#include <QMap>
namespace NGL
{
class INGLLogger;
}
namespace CesBuildings
{
///////////////////////////////////////////////////////////////////////////////////////////////////
// HandlerBuildingModel
//
/**
* @brief The HandlerBuildingModel class contains building and rooms geometry in detail.
* Based on that LineOfSight operations could be offered.
*/
class HandlerBuildingModel final
: public QObject
, public HandlerBuildingModelInterface
, protected CentralEffectSimulation::Interface::Fts::GetLineBuildingIntersectionRequestHandler
, protected CentralEffectSimulation::Interface::Fts::GetLineBuildingIntersectsRequestHandler
, protected CentralEffectSimulation::Interface::Fts::DetonationLocationRequestHandler
{
Q_OBJECT
public:
explicit HandlerBuildingModel(
const std::shared_ptr<CentralEffectSimulation::DdsHandler> &ddsHandler, const std::shared_ptr<HandlerAesData> &aesDataHandler, QObject *parent = nullptr
);
~HandlerBuildingModel();
bool init();
const QMap<int, BuildingModel *> &buildingModels() const { return m_buildingModels; }
/*! \name implementation of synchron calls of HandlerBuildingModel - LineOfSight etc*/
//@{
///< LineOfSight: find exact intersection
LineBuildingIntersectionResult getLineBuildingIntersection(const std::vector<Core::GeoPosition> &line,
const std::string &requestIdOpt = {}) override;
///< LineOfSight: find if lingOfSight is given or not
LineBuildingIntersectsResult getLineBuildingIntersects(const std::vector<Core::GeoPosition> &line,
const std::string &requestIdOpt = {}) override;
//@}
protected:
///< LineOfSight: find exact intersection
void onGetLineBuildingIntersectionRequest(const rti::core::SampleIdentity &cookie, const CentralEffectSimulation::GetLineBuildingIntersectionRequest &request) override final;
///< LineOfSight: find if lingOfSight is given or not
void onGetLineBuildingIntersectsRequest(const rti::core::SampleIdentity &cookie, const CentralEffectSimulation::GetLineBuildingIntersectsRequest &request) override final;
///< special request for AreaEffectSimulation
void onDetonationLocationRequest(const rti::core::SampleIdentity &cookie, const CentralEffectSimulation::DetonationLocationRequest &request) override final;
private Q_SLOTS:
/**
* Handle MainStructureElement from 'ISM'
*/
void onMainStructureElementChanged(const InfrastructureManagement::MainStructureElement &data, DataModification modType);
private:
/*!
* \brief getLineBuildingIntersectionInternal
* \param request more or less genral request
* \param justForLineOfSight stop on first intersection or find exact intersection?
* \param segmentIdxOfIntersectionPtrOut intersection of intersection
* \return reply
*/
CentralEffectSimulation::GetLineBuildingIntersectionReply getLineBuildingIntersectionInternal(const CentralEffectSimulation::GetLineBuildingIntersectionRequest &request,
bool justForLineOfSight = false,
int *buildingIdOut = nullptr,
int *segmentIdxOfIntersectionPtrOut = nullptr
) const;
///< special request for AreaEffectSimulation
CentralEffectSimulation::DetonationLocationReply handleDetonationLocationRequest(const CentralEffectSimulation::DetonationLocationRequest &request) const;
Core::GeoPosition calculateDetonationLocation(const std::vector<Core::GeoPosition> &trajectoryGeometry, double detonationDistance) const;
private:
std::shared_ptr<CentralEffectSimulation::DdsHandler> m_ddsHandler;
std::shared_ptr<HandlerAesData> m_aesDataHandler;
QMap<int, BuildingModel *> m_buildingModels; // key = buildingId
CentralEffectSimulation::LOGGER_T m_logger;
}; // class HandlerBuildingModel
} // namespace CesBuildings