- Formatted all CodeGen module files (9 files) - Formatted LtsAppDescriptor module files - Formatted LtsAppManager/AppChooser files - Applied clang-format to all DTC and enum headers across modules - Removed coordTransTests from CommonUnitTestsPlaceholder (moved to tests/) Cosmetic changes only, no functional modifications. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
293 lines
11 KiB
C++
293 lines
11 KiB
C++
#pragma once
|
|
|
|
#include "buildingmanager.h"
|
|
#include "exccommands.h"
|
|
#include "logger.h"
|
|
#include "viewerinterface.h"
|
|
#include "viewwidgetcontainer.h"
|
|
#include "viewwidgetstate.h"
|
|
|
|
#include <QPointer>
|
|
#include <QWidget>
|
|
#include <algorithm>
|
|
#include <dtEntity/commandmessages.h>
|
|
#include <dtEntity/core.h>
|
|
#include <dtEntity/mapcomponent.h>
|
|
#include <dtEntity/systemmessages.h>
|
|
#include <dtEntity/windowinterface.h>
|
|
#include <dtEntityOSG/cameracomponent.h>
|
|
#include <dtEntityOSG/layercomponent.h>
|
|
#include <dtEntityOSG/osgsysteminterface.h>
|
|
#include <dtEntityOSG/positionattitudetransformcomponent.h>
|
|
#include <dtEntityOSG/staticmeshcomponent.h>
|
|
#include <map>
|
|
#include <osg/ComputeBoundsVisitor>
|
|
#include <osg/io_utils>
|
|
#include <osgDB/FileNameUtils>
|
|
#include <osgDB/FileUtils>
|
|
#include <osgViewer/CompositeViewer>
|
|
#include <string>
|
|
|
|
namespace dtEntity
|
|
{
|
|
class EntityManager;
|
|
class MapSystem;
|
|
class Message;
|
|
} // namespace dtEntity
|
|
|
|
namespace VCtrl
|
|
{
|
|
class PlayerSystem;
|
|
class BuildingManager;
|
|
class ViewWidget;
|
|
class LogHandler;
|
|
|
|
class CtrlMainWindow;
|
|
|
|
class CtrlImpl : public QObject, public ViewerInterface
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
CtrlImpl(dtEntity::EntityManager& em, QWidget* parentWidget);
|
|
~CtrlImpl();
|
|
|
|
void SetViewerCallback(ViewerCallback*) override;
|
|
void RemoveViewerCallback() override;
|
|
|
|
void SetProjectDataPaths(const std::vector<std::string>& paths) override;
|
|
|
|
QWidget* getMainWindow() override;
|
|
quintptr requestMainWindowHandle() override;
|
|
|
|
void openViews(const std::vector<std::string>& bldIds, bool exactPos) override;
|
|
bool isViewOpen(const std::string& strBldId) const override;
|
|
|
|
void closeViews(const std::vector<std::string>& vecFeatureIDs) override;
|
|
void closeAllViews();
|
|
|
|
void UseExactPositioning(bool exactPos) override;
|
|
|
|
bool OpenView(const std::string& buildingid, const std::string& windowtitle, const Color& col, ViewMode viewmode,
|
|
int screennum, bool fullscreen, int x, int y, int w, int h, unsigned int& contextid,
|
|
bool exactPos = true) override;
|
|
|
|
void CloseView(unsigned int contextid) override;
|
|
|
|
void ChangeViewMode(unsigned int contextId, ViewMode viewmode) override;
|
|
|
|
void LockViewRotationToMapRotation(unsigned int contextId, bool lock) override;
|
|
|
|
void SetPlayerDisplayMode(unsigned int contextId, PlayerDisplayMode mode) override;
|
|
|
|
void SetWallTransparency(unsigned int contextId, float transparency) override;
|
|
|
|
float GetMapRotation() const override;
|
|
|
|
void SetMapRotation(float angle) override;
|
|
|
|
void OpenOverview() override;
|
|
|
|
bool LoadBuildingPositionMap(const std::string& path, bool loadAllAvailableBuildings) override;
|
|
|
|
void LoadAllBuildings();
|
|
|
|
void CreatePlayer(const std::string& id, const std::string& iconpath, const Color& color) override;
|
|
|
|
void DeletePlayer(const std::string& id, float seconds = 0) override;
|
|
|
|
void SetPlayerColor(const std::string& id, const Color& color) override;
|
|
|
|
void SetPlayerIcon(const std::string& id, const std::string& path) override;
|
|
|
|
void reloadPlayerIcons() override;
|
|
|
|
void UpdatePlayerPartyColors(const std::map<std::string, VCtrl::Color>& mapPlayerColors) override;
|
|
|
|
size_t GetNumPlayers() const override;
|
|
|
|
void GetPlayerIds(std::vector<std::string>& toFill) override;
|
|
|
|
void SetPlayerShown(const std::string& id, bool show, double when = -1) override;
|
|
|
|
size_t GetNumBuildings() const override;
|
|
|
|
void GetBuildingIds(std::vector<std::string>& toFill) const override;
|
|
|
|
void SetShowSelectionBox(const std::string& id, bool show, float duration = -1) override;
|
|
|
|
void Shoot(const int32_t id, const std::string& shooter, const std::string& target, const Vec3d& shooterPos,
|
|
const Vec3d& targetPos, int buildingIdSrc, int roomNumberSrc, int buildingIdDst, int roomNumberDst,
|
|
int lineType, double when) override;
|
|
void Shoot(const int32_t id, const std::string& shooter, const std::string& targetBuildingId,
|
|
const std::string& targetRoomId, const Vec3d& shooterPos, int lineType, double when) override;
|
|
|
|
void removeShoot(const int32_t id) override;
|
|
|
|
void Teleport(const std::string& id, double when, const Vec3d& target, const std::string& bldgname, int roomNumber,
|
|
const std::string& roomname, ZValue zval) override;
|
|
|
|
void GetRoomNames(const std::string& id, std::vector<std::string>& names) override;
|
|
|
|
bool SetRoomDestructionValue(const std::string& id, const std::string& roomname, float value) override;
|
|
|
|
bool SetBuildingDestructionValue(const std::string& id, float value) override;
|
|
|
|
void GetDeviceNames(const std::string& buildingId, std::vector<std::string>& names) override;
|
|
|
|
bool ShowDeviceIcon(const std::string& id, const std::string& buildingid, const std::string& devicename,
|
|
const std::string& iconpath) override;
|
|
|
|
bool ShowDeviceIcon(const std::string& id, const std::string& buildingid, const Vec3d& position,
|
|
const std::string& iconpath) override;
|
|
|
|
void ChangeLineMode(unsigned int contextId, bool line) override;
|
|
void ChangeNameMode(unsigned int contextId, bool name) override;
|
|
|
|
bool SetDisplayName(const std::string& buildingid, const std::string& roomname,
|
|
const std::string& strDisplayName) override;
|
|
void ShowDisplayNames(const std::string& buildingid, bool show) override;
|
|
void SetShowDisplayNamesSelectionBox(const std::string& buildingid, const std::string& id, bool show,
|
|
float duration = -1) override;
|
|
void setHitLineDuration(uint32_t durationSec) override;
|
|
void setMountingPointAsset(const MountingPointDescription& asset) override;
|
|
std::vector<BuildingState> getBuildingState() const override;
|
|
|
|
bool HideDeviceIcon(const std::string& id) override;
|
|
|
|
float GetTimeScale() const override;
|
|
|
|
void SetTimeScale(float scale) override;
|
|
|
|
void SetSimulationTime(double t) override;
|
|
|
|
double GetSimulationTime() const override;
|
|
|
|
void SetPaused(bool) override;
|
|
|
|
bool GetPaused() const override;
|
|
|
|
void FastForwardSimulationTo(double t) override;
|
|
|
|
void DeleteQueuedCommands() override;
|
|
|
|
void SetNonRealtimeMode(bool on) override;
|
|
|
|
bool GetNonRealtimeMode() const override;
|
|
|
|
bool StartVideoRecording(unsigned int contextid, const std::string& path, int w, int h, int framerate,
|
|
int quality) override;
|
|
bool StartVideoRecording(const std::string& buildingId, const std::string& path, int w, int h, int framerate,
|
|
int quality) override;
|
|
|
|
bool StopVideoRecording(unsigned int contextid) override;
|
|
bool StopVideoRecording(const std::string& buildingId) override;
|
|
|
|
void setTransparency(double percent) override;
|
|
void setViewMode(ViewMode m) override;
|
|
void setDisplayMode(PlayerDisplayMode m) override;
|
|
|
|
int GetFrameRate() const
|
|
{
|
|
return mFrameRate;
|
|
}
|
|
|
|
void OnShowMsgBox(const std::string& strText);
|
|
|
|
bool allViewWindowsExposed() const
|
|
{
|
|
for (auto* vw : m_openedViewWidgets.getViewWidgets())
|
|
{
|
|
if (!vw->isOpenGlWindowExposed())
|
|
return false;
|
|
}
|
|
return !m_openedViewWidgets.getViewWidgets().empty();
|
|
}
|
|
|
|
private:
|
|
NGL::INGLLogger& m_logger;
|
|
bool open(const std::string& strFeatureID, bool exactPos);
|
|
bool open(const std::vector<std::string>& vecFeatureIDs, bool exactPos);
|
|
bool openAll(bool exactPos);
|
|
|
|
void onEXCOpen(const QString& strIDs, bool exactPos);
|
|
void onEXCClose(const QString& strIDs);
|
|
void convertAssetsToPngFiles();
|
|
|
|
void OnTransformSend(const dtEntity::Message& m);
|
|
void OnMapLoaded(const dtEntity::Message& m);
|
|
void OnMapUnloaded(const dtEntity::Message& m);
|
|
void OnNavMeshGroupChanged(const dtEntity::Message& m);
|
|
void OnPlayerPicked(const dtEntity::Message& m);
|
|
void OnHideSelection(const dtEntity::Message& m);
|
|
|
|
void OnShoot(const dtEntity::Message& m);
|
|
void OnShowHidePlayer(const dtEntity::Message& m);
|
|
void OnDisplayNameClicked(const dtEntity::Message& m);
|
|
|
|
bool SpawnBuilding(const BuildingData& b, bool useStaticMeshesFolder = true);
|
|
void LoadBuilding(BuildingData& bd, bool useStaticMeshesFolder);
|
|
void deleteAllBuildings();
|
|
|
|
bool getBuildingString(const std::string& strFeatureID, std::string* strBuildingNameID);
|
|
|
|
bool OpenView(unsigned int contextId);
|
|
bool CreateView(dtEntity::EntityId bid, const std::string& windowtitle, const Color& col, ViewMode viewmode,
|
|
int screennum, bool fullscreen, int x, int y, int w, int h, unsigned int& contextid, bool exactPos);
|
|
|
|
QPointer<CtrlMainWindow> m_pMainWindow;
|
|
|
|
dtEntity::EntityManager* mEntityManager;
|
|
ViewerCallback* mViewerCallback;
|
|
LogHandler* mLogHandler = nullptr;
|
|
dtEntity::MapSystem* mMapSystem;
|
|
PlayerSystem* mPlayerSystem;
|
|
BuildingManager* mBuildingManager;
|
|
|
|
float mTimeScale;
|
|
double mSimTime;
|
|
bool mPaused;
|
|
bool mNonRealtimeMode;
|
|
int mFrameRate;
|
|
std::map<unsigned int, ViewWidget*> mViewWidgets;
|
|
|
|
ViewWidget* GetViewWidget(unsigned int contextid);
|
|
void storeWidget(ViewWidget* pWidget, const std::string& strBuildingNameID, unsigned int contextid,
|
|
VCtrl::ViewMode vmode, VCtrl::PlayerDisplayMode displayMode);
|
|
|
|
const std::size_t m_maxParallelViewWidgets = 8;
|
|
|
|
unsigned int m_hitlineDuration_s = 10;
|
|
double m_desiredTransparencyValue = 0.75;
|
|
bool m_showHitLines = true;
|
|
ViewWidget* CreateMainWindowView(dtEntity::EntityId bid, const std::string& featureId, unsigned int& contextid,
|
|
bool exactPos);
|
|
|
|
std::unordered_map<std::string, BuildingData> m_loadedBuildings;
|
|
|
|
ViewWidgetContainer m_openedViewWidgets;
|
|
bool m_isInFullscreenMode = false;
|
|
|
|
ViewMode m_desiredViewMode = ViewMode::ORTHOGRAPHIC;
|
|
VCtrl::PlayerDisplayMode m_desiredPlayerDisplayMode = VCtrl::PlayerDisplayMode::Icons;
|
|
|
|
void CloseView(ViewWidget* pWidget);
|
|
|
|
void onExcRestoreViewState(const std::string& strFeatureID);
|
|
void restoreViewWidgetStates(const std::vector<BuildingViewer::ViewWidgetState>& vecStates);
|
|
void restoreViewWidgetStateDeferred(ViewWidget* pViewWidget);
|
|
std::unordered_map<std::string, BuildingViewer::ViewWidgetState> m_deferredViewStates;
|
|
|
|
QJsonValue getViewState() const override;
|
|
void setViewState(const QJsonValue& val) override;
|
|
void highlightView(const std::string& buildingId) override;
|
|
void setBuildingDisplayName(const std::string& buildingId, const std::string& displayName) override;
|
|
|
|
private slots:
|
|
void onViewWidget_MaximizeRequest(ViewWidget* pWidget);
|
|
void onViewWidget_MinimizeRequest(ViewWidget* pWidget);
|
|
void onViewWidget_CloseRequest(ViewWidget* pWidget);
|
|
void onViewWidget_FocusRequest(ViewWidget* pWidget);
|
|
void onViewWidget_Zoom(ViewWidget* pWidget, bool zoomIn);
|
|
};
|
|
} // namespace VCtrl
|