185 lines
7.8 KiB
C++
185 lines
7.8 KiB
C++
|
|
|
|
#pragma once
|
|
#include "buildingviewercommon_export.h"
|
|
|
|
#include <AdvancedSymbology/asb_data_plugin_interface.h>
|
|
#include <BuildingViewer/share/exccommands.h>
|
|
#include <LtsCoordTrans/lts_coord_trans.h>
|
|
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
|
#include <LtsUtils/LtsUtilsCore/qpoint3d.h>
|
|
#include <NGLLogger/INGLLogger.h>
|
|
#include <ParticipantManagement/ppm_data_plugin_interface.h>
|
|
#include <ParticipantManagement/ppm_participant_info_gui_plugin_interface.h>
|
|
#include <PluginInterfaces/gui_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/Buildings/bld_info_gui_plugin_interface.h>
|
|
#include <Plugins/InfrastructureManagement/ism_data_plugin_interface.h>
|
|
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
|
|
#include <Plugins/SituationReplay/srp_data_plugin_interface.h>
|
|
#include <QHash>
|
|
#include <QObject>
|
|
#include <QTimer>
|
|
#include <QVector>
|
|
#include <functional>
|
|
#include <viewerinterface.h>
|
|
|
|
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:
|
|
NGL::INGLLogger& m_logger;
|
|
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;
|
|
QHash<int, qint64> m_lastPositionTime;
|
|
|
|
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};
|
|
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;
|
|
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;
|
|
|
|
int m_bgviewer_simSyncTimeInterval_ms = 3000;
|
|
|
|
QHash<int, QHash<int, int>> m_roomId2RoomNumber;
|
|
CommunicationInterfaceInternal* m_connection{nullptr};
|
|
VCtrl::ViewerInterface* m_viewerInterface{nullptr};
|
|
QTimer* m_reCheckTimer{nullptr};
|
|
LtsCoordTrans::UtmCoordinate m_baseCoordinate;
|
|
QHash<int32_t, double> m_buildingHeight;
|
|
QWidget* m_irreplacableWidget{nullptr};
|
|
};
|
|
|
|
} // namespace BuildingViewer
|