186 lines
8.1 KiB
C++
Executable File
186 lines
8.1 KiB
C++
Executable File
/**
|
|
* @RDE_HEADER@
|
|
* DDS IFC to BuildingViewer
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
* Created by Patric Karwat, SLSE, 2016-08-17
|
|
*/
|
|
|
|
#pragma once
|
|
#include <NGLLogger/INGLLogger.h>
|
|
|
|
#include <QObject>
|
|
#include <QTimer>
|
|
#include <QHash>
|
|
#include <QVector>
|
|
|
|
#include <PluginInterfaces/gui_plugin_interface.h>
|
|
#include <Plugins/AdvancedSymbology/asb_data_plugin_interface.h>
|
|
#include <Plugins/AreaEffectSimulation/aes_data_plugin_interface.h>
|
|
#include <Plugins/AudioVideoManagement/avm_data_plugin_interface.h>
|
|
#include <Plugins/Buildings/bld_data_plugin_interface.h>
|
|
#include <Plugins/SituationReplay/srp_data_plugin_interface.h>
|
|
#include <Plugins/Buildings/bld_info_gui_plugin_interface.h>
|
|
#include <Plugins/ParticipantManagement/ppm_data_plugin_interface.h>
|
|
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
|
|
#include <Plugins/ParticipantManagement/ppm_participant_info_gui_plugin_interface.h>
|
|
#include <Plugins/InfrastructureManagement/ism_data_plugin_interface.h>
|
|
#include <Plugins/SituationReplay/srp_data_plugin_interface.h>
|
|
#include <LtsCoordTrans/lts_coord_trans.h>
|
|
#include <LtsUtilsCore/qpoint3d.h>
|
|
#include <Common/buildingviewercommon_export.h>
|
|
#include <BuildingViewer/share/exccommands.h>
|
|
#include <LtsUtilsGuiDds/request_helper.h>
|
|
#include <viewerinterface.h>
|
|
|
|
#include <functional>
|
|
|
|
namespace BuildingViewer
|
|
{
|
|
class CommunicationInterfaceInternal;
|
|
class PluginProvider;
|
|
|
|
class BuildingViewerDdsController : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit BuildingViewerDdsController(CommunicationInterfaceInternal *connection,
|
|
VCtrl::ViewerInterface* viewerInterface);
|
|
~BuildingViewerDdsController();
|
|
bool init(QWidget *irreplacableWidget, const QString &modelPath, PluginProvider *session);
|
|
void uninitialize();
|
|
|
|
void updatePlayerSymbols(const int sizeL, const int forParty = -1);
|
|
|
|
void clearAssets();
|
|
PluginProvider *activeSession() const { return m_session; }
|
|
|
|
signals:
|
|
void signalDdsInitFinished();
|
|
private:
|
|
void setCurrentTrainingAreaMap(const QString &modelPath);
|
|
private slots:
|
|
void onPartyChanged(const ParticipantManagement::Party &party, DataModification modType);
|
|
void onBgViewerInitFinished();
|
|
void onFireEventFlashTimer();
|
|
void onSynchronizeSimulationTime();
|
|
void onBoobyTrapChanged(const AreaEffectSimulation::BoobyTrap &boobyTrap, DataModification modType);
|
|
void onParticipantChanged(const ParticipantManagement::Participant &participant, DataModification modType);
|
|
void onDynParticipantChanged(const ParticipantManagement::DynamicParticipantData &data, DataModification modType);
|
|
void onPositionChanged(const ParticipantManagement::ParticipantPosition &position, DataModification modType);
|
|
void onHitLineInfoChanged(const ParticipantManagement::HitLineInfo &hli, DataModification modType);
|
|
void onParticipantGearEventChanged(const ParticipantManagement::ParticipantGearEvent &data, DataModification modType);
|
|
|
|
void onPlayerPicked(int playerId);
|
|
void onAssetPicked(int structureElementId);
|
|
void onMountingPointChanged(const InfrastructureManagement::MountingPoint &data, DataModification modType);
|
|
void onBuildingStateChanged(const Buildings::BuildingState &data, DataModification modType);
|
|
void onCleanupBuildingHitlines();
|
|
void onBuildingHitLineInfoChanged(const Buildings::BuildingHitLineInfo &hli, DataModification modType);
|
|
void onMainStructureElementChanged(const InfrastructureManagement::MainStructureElement &mse, DataModification modType);
|
|
|
|
private:
|
|
QPointF toRelativePosition(const Core::GeoPosition &geoPos) const;
|
|
LtsUtils::QPoint3D toRelative3D(const Core::GeoPosition &geoPos) const;
|
|
bool clear();
|
|
bool syncTeams();
|
|
bool setPaused(bool bPaused);
|
|
bool isOutdatedPosition(qint64 sampleTime) const;
|
|
inline bool isOutdatedPosition(const ParticipantManagement::ParticipantPosition &position) const
|
|
{
|
|
return position.participantId() <= 0 || isOutdatedPosition(position.sampleTime());
|
|
}
|
|
|
|
bool calcBaseCoordinate(const QMap<qint32, InfrastructureManagement::MainStructureElement> &mseMap);
|
|
void sendAssets();
|
|
void handleMountingPoint(const InfrastructureManagement::MountingPoint &mp, DataModification modType);
|
|
void onReplayChanged(const SituationReplay::SitReplay &srp, DataModification modType);
|
|
void effectGenerationUnitPicked(int structureElementId);
|
|
QHash<int, BuildingViewer::AssetTypes> m_mountingPointId2AssetType;
|
|
QHash<int, QString> m_knownAssetsInBgViewer;
|
|
|
|
void createBoobyTraps();
|
|
void createParticipants();
|
|
bool isValidParticipant(const ParticipantManagement::Participant &participant) const;
|
|
void createParticipant(const ParticipantManagement::Participant &participant, const ParticipantManagement::ParticipantPosition &position, int sizeL);
|
|
void createBoobyTrap(const AreaEffectSimulation::BoobyTrap &trap, int sizeL);
|
|
void deleteParticipant(int participantId);
|
|
void updateBuildingRoomNames(const InfrastructureManagement::MainStructureElement& building);
|
|
bool writeBuildingDataToXML(const QString &modelPath);
|
|
QString getBuildingConfigurationXml() const;
|
|
|
|
static QString buildPlayerSymbolFilePath(int playerID, int postfix = 0);
|
|
|
|
struct SymbolInfo
|
|
{
|
|
QString strPathToSymbolFile;
|
|
QColor color;
|
|
int participantId = -1;
|
|
bool useThisSymbolNow = false;
|
|
};
|
|
|
|
|
|
QHash<int, qint64> m_participantGearEvents; // <playerId, sampleTime>
|
|
QHash<int, qint64> m_lastPositionTime; // <playerId, sampleTime>
|
|
struct BuildingHit
|
|
{
|
|
int32_t id = 0;
|
|
int64_t sampleTime = 0;
|
|
int originatorParticipantId = 0;
|
|
int chargeTypeId = 0;
|
|
};
|
|
QHash<int, QVector<BuildingHit>> m_buildingHits;
|
|
QVector<int> m_knownBuildings;
|
|
inline bool isBuildingKnown(int id) const
|
|
{
|
|
return std::find(m_knownBuildings.cbegin(), m_knownBuildings.cend(), id) != m_knownBuildings.cend();
|
|
}
|
|
|
|
const int cColorSymbolId = 0;
|
|
const QVector<QColor> m_vecFlashColors = {QColor(), Qt::white, Qt::gray}; // First color is invalid -> actual party color will be used
|
|
void createPlayerSymbols(const ParticipantManagement::Participant &participant, const int sizeL);
|
|
void createSymbolResultWatcher(const ParticipantManagement::Participant &participant, const SymbolInfo &symbolInfo, const int sizeL);
|
|
QHash<AdvancedSymbology::SymbolResultWatcher *, SymbolInfo> m_mapActiveSymbolResultWatcher; // ResultWatcher address -> Player id to update symbol for
|
|
void reCheckHitLine();
|
|
QString getSessionInfo() const;
|
|
PluginProvider *m_session = nullptr;
|
|
int m_exerciseId = -1;
|
|
std::shared_ptr<AudioVideoManagement::ForeignDataInterface> m_avmIfc;
|
|
std::shared_ptr<AdvancedSymbology::ForeignDataInterface> m_asbIfc;
|
|
std::shared_ptr<AreaEffectSimulation::Interface::Dtc> m_aesDtc;
|
|
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
|
std::shared_ptr<ProjectDataManagement::Interface::Dtc> m_pdmDtc;
|
|
std::shared_ptr<ParticipantManagement::ForeignParticipantInfoGuiInterface> m_ppmGuiIfc;
|
|
std::shared_ptr<InfrastructureManagement::Interface::Dtc> m_ismDtc;
|
|
std::shared_ptr<InfrastructureManagement::ForeignDataInterface> m_ismIfc;
|
|
std::shared_ptr<Buildings::Interface::Dtc> m_bldDtc;
|
|
std::shared_ptr<SituationReplay::Interface::Dtc> m_srpDtc;
|
|
std::shared_ptr<Buildings::ForeignInfoGuiInterface> m_blgGuiIfc;
|
|
|
|
void stopAndClearTimer();
|
|
QTimer *m_pSimTimeSyncTimer = nullptr;
|
|
QTimer *m_pFireEventFlashTimer = nullptr;
|
|
QTimer *m_pBuildingHitlineCleanupTimer = nullptr;
|
|
bool m_ddsInitFinished = false;
|
|
int m_dtc_timeout_ms = 10000;
|
|
int m_hitlineDuration_ms = 10 * 1000;
|
|
/*
|
|
* Updating the simulation time causes the BgViewer to freeze for short moments from time to time.
|
|
* E.g., 1000ms is a bad value. We stay with 10 seconds for now.
|
|
*/
|
|
int m_bgviewer_simSyncTimeInterval_ms = 3000; //10000;
|
|
|
|
QHash<int, QHash<int, int>> m_roomId2RoomNumber; // QHash<buildingId, QHash<roomId, roomNumber>> // roomNumber of xmlFile
|
|
CommunicationInterfaceInternal *m_connection{nullptr};
|
|
VCtrl::ViewerInterface* m_viewerInterface{nullptr};
|
|
QTimer *m_reCheckTimer{nullptr};
|
|
LtsCoordTrans::UtmCoordinate m_baseCoordinate;
|
|
QHash < int32_t, double > m_buildingHeight; // Key = BuildingId, Value z-value from geoPosition of the building
|
|
QWidget *m_irreplacableWidget {nullptr};
|
|
NGL::INGLLogger &m_logger;
|
|
};
|
|
|
|
} //namespace BuildingViewer
|