Apply clang-format to Lts/Common and DTC/enum headers
- 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>
This commit is contained in:
848 files changed
+89305
-100020
No files matched your search
Executable → Regular
+2034
-2261
File diff suppressed because it is too large.
Load diff
Executable → Regular
+312
-334
@@ -1,25 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include <dtEntity/entityid.h>
|
||||
#include <osg/BoundingBox>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <osg/Vec3>
|
||||
#include <osg/Vec4>
|
||||
#include <osg/Matrix>
|
||||
#include <osg/Geode>
|
||||
#include <dtEntity/message.h>
|
||||
#include "cameraviewposition.h"
|
||||
#include "logger.h"
|
||||
#include "viewerinterface.h"
|
||||
|
||||
#include <QMutex>
|
||||
#include <QMutexLocker>
|
||||
#include <QPolygonF>
|
||||
|
||||
#include <set>
|
||||
#include <map>
|
||||
#include <dtEntity/entityid.h>
|
||||
#include <dtEntity/message.h>
|
||||
#include <functional>
|
||||
#include "viewerinterface.h"
|
||||
#include "cameraviewposition.h"
|
||||
#include "logger.h"
|
||||
#include <map>
|
||||
#include <osg/BoundingBox>
|
||||
#include <osg/Geode>
|
||||
#include <osg/Matrix>
|
||||
#include <osg/Vec3>
|
||||
#include <osg/Vec4>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace dtEntity
|
||||
{
|
||||
@@ -32,451 +31,430 @@ class IconComponent;
|
||||
class TextComponent;
|
||||
class ViewWidget;
|
||||
|
||||
|
||||
struct OBB
|
||||
{
|
||||
osg::Matrix mMatrix;
|
||||
osg::Matrix mMatrixInverse;
|
||||
osg::BoundingBox mBB;
|
||||
QPolygonF mPoly;
|
||||
dtEntity::StringId mBuilding = 0;
|
||||
osg::Matrix mMatrix;
|
||||
osg::Matrix mMatrixInverse;
|
||||
osg::BoundingBox mBB;
|
||||
QPolygonF mPoly;
|
||||
dtEntity::StringId mBuilding = 0;
|
||||
};
|
||||
|
||||
|
||||
struct BuildingData
|
||||
{
|
||||
std::string mDescription;
|
||||
std::string mDisplayName;
|
||||
std::string mFeatureId;
|
||||
std::string mFileName;
|
||||
std::string mBuildingXMLPath;
|
||||
double mX = 0;
|
||||
double mY = 0;
|
||||
double mZ = 0;
|
||||
double mOrientation = 0;
|
||||
int mBuildingGroup = 0;
|
||||
bool properlySpawned = false;
|
||||
bool roomBBoxedLoaded = false;
|
||||
std::string mDescription;
|
||||
std::string mDisplayName;
|
||||
std::string mFeatureId;
|
||||
std::string mFileName;
|
||||
std::string mBuildingXMLPath;
|
||||
double mX = 0;
|
||||
double mY = 0;
|
||||
double mZ = 0;
|
||||
double mOrientation = 0;
|
||||
int mBuildingGroup = 0;
|
||||
bool properlySpawned = false;
|
||||
bool roomBBoxedLoaded = false;
|
||||
};
|
||||
|
||||
|
||||
struct BuildingLevel
|
||||
{
|
||||
|
||||
dtEntity::EntityId mEntityId;
|
||||
|
||||
|
||||
int mFloorId;
|
||||
dtEntity::EntityId mEntityId;
|
||||
|
||||
|
||||
float mHeightAboveGround;
|
||||
int mFloorId;
|
||||
|
||||
|
||||
osg::Matrix mLocalToLevel;
|
||||
float mHeightAboveGround;
|
||||
|
||||
|
||||
osg::BoundingBox mBounds;
|
||||
osg::Matrix mLocalToLevel;
|
||||
|
||||
BuildingLevel(dtEntity::EntityId eid, int floorId, float h, const osg::BoundingBox &bb)
|
||||
: mEntityId(eid), mFloorId(floorId), mHeightAboveGround(h), mBounds(bb)
|
||||
{
|
||||
}
|
||||
osg::BoundingBox mBounds;
|
||||
|
||||
BuildingLevel(dtEntity::EntityId eid, int floorId, float h, const osg::BoundingBox& bb)
|
||||
: mEntityId(eid), mFloorId(floorId), mHeightAboveGround(h), mBounds(bb)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct PlayerPosition
|
||||
{
|
||||
osg::Vec2d mPosition;
|
||||
dtEntity::EntityId mWorldPlayerId = 0;
|
||||
osg::Vec2d mPosition;
|
||||
dtEntity::EntityId mWorldPlayerId = 0;
|
||||
};
|
||||
|
||||
|
||||
struct PlayerDisplay
|
||||
{
|
||||
dtEntity::EntityId mWorldPlayerId = 0;
|
||||
dtEntity::EntityId mLocalPlayerId = 0;
|
||||
IconComponent *mIcon = nullptr;
|
||||
dtEntity::EntityId mWorldPlayerId = 0;
|
||||
dtEntity::EntityId mLocalPlayerId = 0;
|
||||
IconComponent* mIcon = nullptr;
|
||||
};
|
||||
|
||||
|
||||
struct Device
|
||||
{
|
||||
dtEntity::EntityId mWorldPlayerId = 0;
|
||||
std::string mPath;
|
||||
osg::Vec3d mPosition;
|
||||
dtEntity::EntityId mWorldPlayerId = 0;
|
||||
std::string mPath;
|
||||
osg::Vec3d mPosition;
|
||||
};
|
||||
|
||||
|
||||
struct DeviceDisplay
|
||||
{
|
||||
Device *mDevice = nullptr;
|
||||
dtEntity::EntityId mWorldPlayerId = 0;
|
||||
dtEntity::EntityId mLocalPlayerId = 0;
|
||||
Device* mDevice = nullptr;
|
||||
dtEntity::EntityId mWorldPlayerId = 0;
|
||||
dtEntity::EntityId mLocalPlayerId = 0;
|
||||
};
|
||||
|
||||
|
||||
struct Name
|
||||
{
|
||||
dtEntity::EntityId mWorldPlayerId;
|
||||
std::string mtext;
|
||||
std::string mdistext;
|
||||
std::string mbuilding;
|
||||
osg::Vec3d mPosition;
|
||||
dtEntity::EntityId mWorldPlayerId;
|
||||
std::string mtext;
|
||||
std::string mdistext;
|
||||
std::string mbuilding;
|
||||
osg::Vec3d mPosition;
|
||||
};
|
||||
|
||||
|
||||
struct NameDisplay
|
||||
{
|
||||
Name* mName = nullptr;
|
||||
dtEntity::EntityId mWorldPlayerId = 0;
|
||||
dtEntity::EntityId mLocalPlayerId = 0;
|
||||
bool visible = false;
|
||||
Name* mName = nullptr;
|
||||
dtEntity::EntityId mWorldPlayerId = 0;
|
||||
dtEntity::EntityId mLocalPlayerId = 0;
|
||||
bool visible = false;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class Shot
|
||||
{
|
||||
public:
|
||||
Shot(const int32_t id,
|
||||
const osg::Vec3d& shooterPos,
|
||||
const osg::Vec3d& targetPos,
|
||||
int buildingIdSrc,
|
||||
int rommNumberSrc,
|
||||
int buildingIdDst,
|
||||
int rommNumberDst,
|
||||
int lineType,
|
||||
const osg::Vec4& color,
|
||||
unsigned int duration_s,
|
||||
unsigned int durationMax_s,
|
||||
double simTimeCreated) :
|
||||
mId(id)
|
||||
, mShooterPos(shooterPos)
|
||||
, mTargetPos(targetPos)
|
||||
, mBuildingIdSrc(buildingIdSrc)
|
||||
, mRoomNumberSrc(rommNumberSrc)
|
||||
, mBuildingIdDst(buildingIdDst)
|
||||
, mRoomNumberDst(rommNumberDst)
|
||||
, mLineType(lineType)
|
||||
, mColor(color)
|
||||
, mDuration_s(duration_s)
|
||||
, m_DurationMax_s(durationMax_s)
|
||||
, mSimTimeCreated(simTimeCreated) {
|
||||
public:
|
||||
Shot(const int32_t id, const osg::Vec3d& shooterPos, const osg::Vec3d& targetPos, int buildingIdSrc,
|
||||
int rommNumberSrc, int buildingIdDst, int rommNumberDst, int lineType, const osg::Vec4& color,
|
||||
unsigned int duration_s, unsigned int durationMax_s, double simTimeCreated)
|
||||
: mId(id), mShooterPos(shooterPos), mTargetPos(targetPos), mBuildingIdSrc(buildingIdSrc),
|
||||
mRoomNumberSrc(rommNumberSrc), mBuildingIdDst(buildingIdDst), mRoomNumberDst(rommNumberDst),
|
||||
mLineType(lineType), mColor(color), mDuration_s(duration_s), m_DurationMax_s(durationMax_s),
|
||||
mSimTimeCreated(simTimeCreated)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
void setDisplayTime(unsigned int duration_s)
|
||||
{
|
||||
if (duration_s > m_DurationMax_s)
|
||||
m_DurationMax_s = duration_s;
|
||||
mDuration_s = duration_s;
|
||||
}
|
||||
|
||||
void setDisplayTime(unsigned int duration_s) {
|
||||
if(duration_s > m_DurationMax_s)
|
||||
m_DurationMax_s = duration_s;
|
||||
mDuration_s = duration_s;
|
||||
}
|
||||
double simTimeCreated() const {
|
||||
return mSimTimeCreated;
|
||||
}
|
||||
double simTimeCreated() const
|
||||
{
|
||||
return mSimTimeCreated;
|
||||
}
|
||||
|
||||
double displayTime() const {
|
||||
return mSimTimeCreated + mDuration_s;
|
||||
}
|
||||
double displayTime() const
|
||||
{
|
||||
return mSimTimeCreated + mDuration_s;
|
||||
}
|
||||
|
||||
double lifeTime() const {
|
||||
return mSimTimeCreated + (m_DurationMax_s*2);
|
||||
}
|
||||
double lifeTime() const
|
||||
{
|
||||
return mSimTimeCreated + (m_DurationMax_s * 2);
|
||||
}
|
||||
|
||||
const osg::Vec3d& getShooterPos() const { return mShooterPos; }
|
||||
const osg::Vec3d& getTargetPos() const { return mTargetPos; }
|
||||
int getBuildingIdSrc() const { return mBuildingIdSrc; }
|
||||
double getSimeTimeCreated() const { return mSimTimeCreated; }
|
||||
int getRoomNumberSrc() const { return mRoomNumberSrc; }
|
||||
int getBuildingIdDst() const { return mBuildingIdDst; }
|
||||
int getRoomNumberDst() const { return mRoomNumberDst; }
|
||||
int getDuration() const { return mDuration_s; }
|
||||
int getLineType() const { return mLineType; }
|
||||
const osg::Vec3d& getShooterPos() const
|
||||
{
|
||||
return mShooterPos;
|
||||
}
|
||||
|
||||
const osg::Vec4& getColor() const { return mColor; }
|
||||
int32_t getId() const { return mId; }
|
||||
const osg::Vec3d& getTargetPos() const
|
||||
{
|
||||
return mTargetPos;
|
||||
}
|
||||
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
int32_t mId;
|
||||
osg::Vec3d mShooterPos;
|
||||
osg::Vec3d mTargetPos;
|
||||
int mBuildingIdSrc;
|
||||
int mRoomNumberSrc;
|
||||
int mBuildingIdDst;
|
||||
int mRoomNumberDst;
|
||||
int mLineType;
|
||||
osg::Vec4 mColor;
|
||||
unsigned int mDuration_s, m_DurationMax_s;
|
||||
double mSimTimeCreated;
|
||||
int getBuildingIdSrc() const
|
||||
{
|
||||
return mBuildingIdSrc;
|
||||
}
|
||||
|
||||
double getSimeTimeCreated() const
|
||||
{
|
||||
return mSimTimeCreated;
|
||||
}
|
||||
|
||||
int getRoomNumberSrc() const
|
||||
{
|
||||
return mRoomNumberSrc;
|
||||
}
|
||||
|
||||
int getBuildingIdDst() const
|
||||
{
|
||||
return mBuildingIdDst;
|
||||
}
|
||||
|
||||
int getRoomNumberDst() const
|
||||
{
|
||||
return mRoomNumberDst;
|
||||
}
|
||||
|
||||
int getDuration() const
|
||||
{
|
||||
return mDuration_s;
|
||||
}
|
||||
|
||||
int getLineType() const
|
||||
{
|
||||
return mLineType;
|
||||
}
|
||||
|
||||
const osg::Vec4& getColor() const
|
||||
{
|
||||
return mColor;
|
||||
}
|
||||
|
||||
int32_t getId() const
|
||||
{
|
||||
return mId;
|
||||
}
|
||||
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
int32_t mId;
|
||||
osg::Vec3d mShooterPos;
|
||||
osg::Vec3d mTargetPos;
|
||||
int mBuildingIdSrc;
|
||||
int mRoomNumberSrc;
|
||||
int mBuildingIdDst;
|
||||
int mRoomNumberDst;
|
||||
int mLineType;
|
||||
osg::Vec4 mColor;
|
||||
unsigned int mDuration_s, m_DurationMax_s;
|
||||
double mSimTimeCreated;
|
||||
};
|
||||
|
||||
|
||||
struct ShotDisplay
|
||||
{
|
||||
Shot *mShot = nullptr;
|
||||
osg::ref_ptr<osg::Geode> mGeode;
|
||||
Shot* mShot = nullptr;
|
||||
osg::ref_ptr<osg::Geode> mGeode;
|
||||
};
|
||||
|
||||
|
||||
struct Building;
|
||||
|
||||
|
||||
|
||||
|
||||
class OrthoMotionModelComponent;
|
||||
|
||||
struct BuildingDisplay
|
||||
{
|
||||
|
||||
unsigned int mContextId = 0;
|
||||
{
|
||||
|
||||
|
||||
dtEntity::EntityId mAttachPointId = 0;
|
||||
unsigned int mContextId = 0;
|
||||
|
||||
|
||||
std::vector<BuildingLevel> mLevels;
|
||||
dtEntity::EntityId mAttachPointId = 0;
|
||||
|
||||
|
||||
osg::BoundingBox mWorldBounds;
|
||||
std::vector<BuildingLevel> mLevels;
|
||||
|
||||
|
||||
osg::BoundingBox mLocalBounds;
|
||||
osg::BoundingBox mWorldBounds;
|
||||
|
||||
|
||||
dtEntity::EntityId mCameraId = 0;
|
||||
osg::BoundingBox mLocalBounds;
|
||||
|
||||
|
||||
dtEntity::EntityId mMotionModelId = 0;
|
||||
OrthoMotionModelComponent *pMotion = nullptr;
|
||||
dtEntity::EntityId mCameraId = 0;
|
||||
|
||||
|
||||
dtEntity::EntityId mLightId = 0;
|
||||
dtEntity::EntityId mMotionModelId = 0;
|
||||
OrthoMotionModelComponent* pMotion = nullptr;
|
||||
|
||||
|
||||
PlayerDisplayMode mPlayerDisplayMode = PlayerDisplayMode::Icons;
|
||||
dtEntity::EntityId mLightId = 0;
|
||||
|
||||
|
||||
ViewMode mViewMode = ViewMode::ISOMETRIC;
|
||||
PlayerDisplayMode mPlayerDisplayMode = PlayerDisplayMode::Icons;
|
||||
|
||||
|
||||
std::vector<PlayerDisplay> mPlayers;
|
||||
ViewMode mViewMode = ViewMode::ISOMETRIC;
|
||||
|
||||
|
||||
std::vector<ShotDisplay> mShotDisplays;
|
||||
std::vector<PlayerDisplay> mPlayers;
|
||||
|
||||
|
||||
std::vector<DeviceDisplay> mDeviceDisplays;
|
||||
std::vector<ShotDisplay> mShotDisplays;
|
||||
|
||||
|
||||
std::vector<NameDisplay> mNameDisplays;
|
||||
std::vector<DeviceDisplay> mDeviceDisplays;
|
||||
|
||||
|
||||
bool mLockRotation = false;
|
||||
std::vector<NameDisplay> mNameDisplays;
|
||||
|
||||
|
||||
bool mNameMode = false;
|
||||
bool mLockRotation = false;
|
||||
|
||||
|
||||
bool mLineMode = false;
|
||||
bool mNameMode = false;
|
||||
|
||||
BuildingDisplay() = default;
|
||||
bool mLineMode = false;
|
||||
|
||||
BuildingDisplay(unsigned int contextid, ViewMode vm)
|
||||
: mContextId(contextid)
|
||||
, mViewMode(vm)
|
||||
{
|
||||
}
|
||||
BuildingDisplay() = default;
|
||||
|
||||
BuildingDisplay(unsigned int contextid, ViewMode vm) : mContextId(contextid), mViewMode(vm) {}
|
||||
};
|
||||
|
||||
|
||||
struct Building
|
||||
{
|
||||
|
||||
dtEntity::EntityId mWorldBuildingId = 0;
|
||||
|
||||
|
||||
std::vector<BuildingDisplay> mDisplays;
|
||||
dtEntity::EntityId mWorldBuildingId = 0;
|
||||
|
||||
|
||||
osg::Matrix mWorldToLocal;
|
||||
std::vector<BuildingDisplay> mDisplays;
|
||||
|
||||
|
||||
osg::Matrix mLocalToWorld;
|
||||
osg::Matrix mWorldToLocal;
|
||||
|
||||
|
||||
std::string mNavMeshGrpName;
|
||||
osg::Matrix mLocalToWorld;
|
||||
|
||||
|
||||
std::vector<Shot *> mShots;
|
||||
std::string mNavMeshGrpName;
|
||||
|
||||
|
||||
std::vector<Device *> mDevices;
|
||||
std::vector<Shot*> mShots;
|
||||
|
||||
|
||||
std::string mBuildingDisplayName;
|
||||
std::vector<Device*> mDevices;
|
||||
|
||||
|
||||
std::vector<Name*> mNames;
|
||||
std::string mBuildingDisplayName;
|
||||
|
||||
|
||||
std::string mFeatureId;
|
||||
std::vector<Name*> mNames;
|
||||
|
||||
std::string mFeatureId;
|
||||
};
|
||||
|
||||
|
||||
class BuildingManager
|
||||
{
|
||||
|
||||
public:
|
||||
public:
|
||||
explicit BuildingManager(dtEntity::EntityManager& em);
|
||||
~BuildingManager();
|
||||
|
||||
explicit BuildingManager(dtEntity::EntityManager &em);
|
||||
~BuildingManager();
|
||||
void addBuilding(dtEntity::EntityId buildingid, const std::string& featureId);
|
||||
void deleteAllBuildings();
|
||||
|
||||
void addBuilding(dtEntity::EntityId buildingid, const std::string &featureId);
|
||||
void deleteAllBuildings();
|
||||
BuildingDisplay* getBuildingDisplay(unsigned int contextid);
|
||||
void applyViewModeToBuildingParts(const Building& bldg, BuildingDisplay& dspl) const;
|
||||
|
||||
BuildingDisplay *getBuildingDisplay(unsigned int contextid);
|
||||
void applyViewModeToBuildingParts(const Building &bldg, BuildingDisplay &dspl) const;
|
||||
bool displayBuilding(const std::string& featureId, unsigned int contextid, dtEntity::EntityId buildingid,
|
||||
const osg::Vec4& bgcolor, ViewMode viewmode, bool exactPos);
|
||||
bool displayBuilding(unsigned int contextid, dtEntity::EntityId buildingid, const osg::Vec4& bgcolor,
|
||||
ViewMode viewmode, bool exactPos);
|
||||
|
||||
bool displayBuilding(const std::string& featureId, unsigned int contextid, dtEntity::EntityId buildingid, const osg::Vec4 &bgcolor, ViewMode viewmode, bool exactPos);
|
||||
bool displayBuilding(unsigned int contextid, dtEntity::EntityId buildingid, const osg::Vec4 &bgcolor, ViewMode viewmode, bool exactPos);
|
||||
bool setCameraPosition(unsigned int contextid, const BuildingViewer::CameraViewPosition& pos);
|
||||
bool getCameraPosition(unsigned int contextid, BuildingViewer::CameraViewPosition& pos);
|
||||
bool setDefaultCameraPosition(unsigned int contextid);
|
||||
|
||||
bool setCameraPosition(unsigned int contextid, const BuildingViewer::CameraViewPosition& pos);
|
||||
bool getCameraPosition(unsigned int contextid, BuildingViewer::CameraViewPosition& pos);
|
||||
bool setDefaultCameraPosition(unsigned int contextid);
|
||||
void closeBuildingDisplay(unsigned int contextid);
|
||||
void changeViewMode(unsigned int contextId, ViewMode viewmode, bool useOriginViewPos = true);
|
||||
void changeLineMode(unsigned int contextId, bool line);
|
||||
void changeNameMode(unsigned int contextId, bool name);
|
||||
|
||||
void closeBuildingDisplay(unsigned int contextid);
|
||||
void changeViewMode(unsigned int contextId, ViewMode viewmode, bool useOriginViewPos = true);
|
||||
void changeLineMode(unsigned int contextId, bool line);
|
||||
void changeNameMode(unsigned int contextId, bool name);
|
||||
void applyMapRotation(const Building& bd, BuildingDisplay& dspl);
|
||||
void lockViewRotationToMapRotation(unsigned int contextId, bool lock);
|
||||
void setPlayerDisplayMode(unsigned int contextId, PlayerDisplayMode mode);
|
||||
void setWallTransparency(unsigned int contextId, float value);
|
||||
|
||||
void applyMapRotation(const Building &bd, BuildingDisplay &dspl);
|
||||
void lockViewRotationToMapRotation(unsigned int contextId, bool lock);
|
||||
void setPlayerDisplayMode(unsigned int contextId, PlayerDisplayMode mode);
|
||||
void setWallTransparency(unsigned int contextId, float value);
|
||||
float getMapRotation() const;
|
||||
void setMapRotation(float angle);
|
||||
|
||||
float getMapRotation() const;
|
||||
void setMapRotation(float angle);
|
||||
void openOverview(unsigned int contextid);
|
||||
|
||||
void openOverview(unsigned int contextid);
|
||||
void addPlayerToBuildings(const std::string& navmeshgrpname, dtEntity::EntityId eid, const osg::Vec4& color,
|
||||
const std::string& symbol, const osg::Vec3d& pos, bool visible);
|
||||
void removePlayerFromBuilding(const std::string& navmeshgrpname, dtEntity::EntityId eid,
|
||||
const std::string& roomname);
|
||||
void updatePlayerPosition(const std::string& navmeshgrpname, dtEntity::EntityId eid, const osg::Vec3d& pos,
|
||||
int roomNumber);
|
||||
|
||||
void addPlayerToBuildings(const std::string &navmeshgrpname, dtEntity::EntityId eid,
|
||||
const osg::Vec4 &color, const std::string &symbol,
|
||||
const osg::Vec3d &pos, bool visible);
|
||||
void removePlayerFromBuilding(const std::string &navmeshgrpname, dtEntity::EntityId eid, const std::string &roomname);
|
||||
void updatePlayerPosition(const std::string &navmeshgrpname, dtEntity::EntityId eid,
|
||||
const osg::Vec3d &pos, int roomNumber);
|
||||
osg::Vec3d remapPosition(const Building& bd, const BuildingDisplay& dspl, const osg::Vec3d& world,
|
||||
int roomNumber = -1);
|
||||
|
||||
osg::Vec3d remapPosition(const Building &bd, const BuildingDisplay &dspl, const osg::Vec3d &world, int roomNumber = -1);
|
||||
void setPlayerColor(dtEntity::EntityId eid, const osg::Vec4& color);
|
||||
void setPlayerIcon(dtEntity::EntityId eid, const std::string& path);
|
||||
void reloadPlayerIcons();
|
||||
void updatePlayerPartyColor(dtEntity::EntityId eid, const VCtrl::Color& col);
|
||||
void setShowPlayerSelection(dtEntity::EntityId eid, bool show);
|
||||
void setShowDisplayNamesSelection(dtEntity::EntityId eid, bool show);
|
||||
void setShowHidePlayer(dtEntity::EntityId eid, bool show);
|
||||
void setShowHideDisplayNames(dtEntity::EntityId eid, unsigned int contextId, bool show);
|
||||
void setRoomDestructionValue(dtEntity::EntityId eid, const std::string& roomname, float value);
|
||||
void setBuildingDestructionValue(dtEntity::EntityId eid, float value);
|
||||
void setBuildingDisplayName(const std::string& featureId, dtEntity::EntityId eid,
|
||||
const std::string& strDisplayName);
|
||||
void setBuildingDisplayName(dtEntity::EntityId eid, const std::string& strDisplayName);
|
||||
void setRoomDisplayName(const std::string& featureId, dtEntity::EntityId eid, const std::string& roomname,
|
||||
const std::string& strDisplayName);
|
||||
void setRoomDisplayName(Building* building, const std::string& roomname, const std::string& strDisplayName);
|
||||
|
||||
void setPlayerColor(dtEntity::EntityId eid, const osg::Vec4 &color);
|
||||
void setPlayerIcon(dtEntity::EntityId eid, const std::string &path);
|
||||
void reloadPlayerIcons();
|
||||
void updatePlayerPartyColor(dtEntity::EntityId eid, const VCtrl::Color& col);
|
||||
void setShowPlayerSelection(dtEntity::EntityId eid, bool show);
|
||||
void setShowDisplayNamesSelection(dtEntity::EntityId eid, bool show);
|
||||
void setShowHidePlayer(dtEntity::EntityId eid, bool show);
|
||||
void setShowHideDisplayNames(dtEntity::EntityId eid, unsigned int contextId, bool show);
|
||||
void setRoomDestructionValue(dtEntity::EntityId eid, const std::string &roomname, float value);
|
||||
void setBuildingDestructionValue(dtEntity::EntityId eid, float value);
|
||||
void setBuildingDisplayName(const std::string& featureId, dtEntity::EntityId eid, const std::string& strDisplayName);
|
||||
void setBuildingDisplayName(dtEntity::EntityId eid, const std::string& strDisplayName);
|
||||
void setRoomDisplayName(const std::string& featureId, dtEntity::EntityId eid, const std::string& roomname, const std::string& strDisplayName);
|
||||
void setRoomDisplayName(Building *building, const std::string &roomname, const std::string& strDisplayName);
|
||||
void removeShoot(int32_t id);
|
||||
void showShoot(int32_t id, dtEntity::EntityId shooter, dtEntity::EntityId target, const dtEntity::Vec3d& shooterPos,
|
||||
const dtEntity::Vec3d& targetPos, int buildingIdSrc, int roomNumberSrc, int buildingIdDst,
|
||||
int roomNumberDst, int lineType, float duration, double simTimeCreated);
|
||||
|
||||
void removeShoot(int32_t id);
|
||||
void showShoot(int32_t id, dtEntity::EntityId shooter, dtEntity::EntityId target,
|
||||
const dtEntity::Vec3d &shooterPos, const dtEntity::Vec3d &targetPos, int buildingIdSrc, int roomNumberSrc,
|
||||
int buildingIdDst, int roomNumberDst, int lineType, float duration, double simTimeCreated);
|
||||
dtEntity::EntityId getWorldPlayerIdFromLocalPlayer(dtEntity::EntityId local) const;
|
||||
dtEntity::EntityId getWorldNameIdFromLocalName(dtEntity::EntityId local, std::string& buildingName,
|
||||
std::string& room) const;
|
||||
|
||||
dtEntity::EntityId getWorldPlayerIdFromLocalPlayer(dtEntity::EntityId local) const;
|
||||
dtEntity::EntityId getWorldNameIdFromLocalName(dtEntity::EntityId local, std::string &buildingName, std::string &room) const;
|
||||
void addDeviceToBuilding(dtEntity::EntityId iconmainid, dtEntity::EntityId buildingid, const osg::Vec3d& pos,
|
||||
const std::string& iconpath);
|
||||
void removeDeviceFromBuilding(dtEntity::EntityId iconmainid);
|
||||
|
||||
void addDeviceToBuilding(dtEntity::EntityId iconmainid, dtEntity::EntityId buildingid,
|
||||
const osg::Vec3d &pos, const std::string &iconpath);
|
||||
void removeDeviceFromBuilding(dtEntity::EntityId iconmainid);
|
||||
bool AddRoomOBBs(const BuildingData&);
|
||||
|
||||
const std::map<std::string, VCtrl::OBB>& GetRoomOBBs() const
|
||||
{
|
||||
return mRooms;
|
||||
}
|
||||
|
||||
|
||||
bool AddRoomOBBs(const BuildingData &);
|
||||
const std::map<std::string, VCtrl::OBB> &GetRoomOBBs() const { return mRooms; }
|
||||
bool getRoomBounds(const std::string& bldgname, const std::string& roomname, VCtrl::OBB& obb) const;
|
||||
|
||||
|
||||
bool getRoomBounds(const std::string &bldgname, const std::string &roomname, VCtrl::OBB &obb) const;
|
||||
bool LoadBuildings(const std::string& path, std::vector<BuildingData>&);
|
||||
|
||||
size_t getNumBuildings() const;
|
||||
void getBuildingIds(std::vector<dtEntity::EntityId>& toFill) const;
|
||||
dtEntity::EntityId getNextBuilding(const osg::Vec3d& pos, float& distance, std::string& featureId) const;
|
||||
Building getBuildingFromFeatureId(const std::string& bldname) const;
|
||||
|
||||
bool LoadBuildings(const std::string &path, std::vector<BuildingData> &);
|
||||
using RoomPlayers = std::vector<PlayerPosition>;
|
||||
|
||||
size_t getNumBuildings() const;
|
||||
void getBuildingIds(std::vector<dtEntity::EntityId> &toFill) const;
|
||||
dtEntity::EntityId getNextBuilding(const osg::Vec3d &pos, float &distance, std::string &featureId) const;
|
||||
Building getBuildingFromFeatureId(const std::string &bldname) const;
|
||||
osg::Vec2d AddRoomUsages(const std::string& bldgname, const std::string& roomname, VCtrl::PlayerPosition& playPos);
|
||||
|
||||
|
||||
using RoomPlayers = std::vector<PlayerPosition>;
|
||||
|
||||
osg::Vec2d AddRoomUsages(const std::string& bldgname, const std::string& roomname, VCtrl::PlayerPosition& playPos);
|
||||
const std::map<std::string, RoomPlayers> &GetRoomUsages() const { return mUsedRooms; }
|
||||
|
||||
void deleteRoomUsagePlayer(const std::string& bldgname, const std::string& roomname, dtEntity::EntityId playerId);
|
||||
void SetExactPos(bool exactPos) { mExactPos = exactPos; }
|
||||
bool GetExactPos() const { return mExactPos; }
|
||||
void updateShotDuration(unsigned int newDuration_s);
|
||||
using CallbackCamPosChanged = std::function<void(unsigned int, const BuildingViewer::CameraViewPosition &)>;
|
||||
void setCallbackCamPosChanged(const CallbackCamPosChanged &cb);
|
||||
const std::map<std::string, RoomPlayers>& GetRoomUsages() const
|
||||
{
|
||||
return mUsedRooms;
|
||||
}
|
||||
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
void updateShots(const Building &bd, BuildingDisplay &dspl);
|
||||
void updateDevices(const Building &bd, BuildingDisplay &dspl);
|
||||
void createRoomNames(dtEntity::EntityId buildingid, Building& building);
|
||||
void updateNames(const Building& bd, BuildingDisplay& dspl);
|
||||
void repositionCamera(const Building &bd, const BuildingDisplay &dspl, bool useOriginViewPos = true);
|
||||
void updatePlayerPositions(const Building &bd, BuildingDisplay &dspl);
|
||||
void addPlayerToBuilding(const Building &bd, BuildingDisplay &dspl, dtEntity::EntityId eid,
|
||||
const osg::Vec4 &color, const std::string &symbol, const osg::Vec3d &pos,
|
||||
bool visible);
|
||||
static osg::Vec2d shiftPosition(const VCtrl::OBB& obb, const osg::Vec2d& pos, double& shiftValue);
|
||||
void cameraViewPositionChanged(unsigned int contextId, const BuildingViewer::CameraViewPosition &viewPos);
|
||||
void deleteRoomUsagePlayer(const std::string& bldgname, const std::string& roomname, dtEntity::EntityId playerId);
|
||||
|
||||
std::set<unsigned int> m_setInitialCameraPositionSet;
|
||||
void SetExactPos(bool exactPos)
|
||||
{
|
||||
mExactPos = exactPos;
|
||||
}
|
||||
|
||||
std::map<std::string, std::map<std::string, std::string>> m_mapBuildingRoomNames;
|
||||
std::map<std::string, std::string> m_mapBuildingDisplayNames;
|
||||
dtEntity::EntityManager *mEntityManager;
|
||||
bool GetExactPos() const
|
||||
{
|
||||
return mExactPos;
|
||||
}
|
||||
|
||||
std::vector<Building *> mBuildings;
|
||||
QMutex m_mutexShots;
|
||||
void updateShotDuration(unsigned int newDuration_s);
|
||||
using CallbackCamPosChanged = std::function<void(unsigned int, const BuildingViewer::CameraViewPosition&)>;
|
||||
void setCallbackCamPosChanged(const CallbackCamPosChanged& cb);
|
||||
|
||||
bool mShotOverview;
|
||||
bool mExactPos;
|
||||
float mMapRotation;
|
||||
dtEntity::MessageFunctor mTickFunctor;
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
void updateShots(const Building& bd, BuildingDisplay& dspl);
|
||||
void updateDevices(const Building& bd, BuildingDisplay& dspl);
|
||||
void createRoomNames(dtEntity::EntityId buildingid, Building& building);
|
||||
void updateNames(const Building& bd, BuildingDisplay& dspl);
|
||||
void repositionCamera(const Building& bd, const BuildingDisplay& dspl, bool useOriginViewPos = true);
|
||||
void updatePlayerPositions(const Building& bd, BuildingDisplay& dspl);
|
||||
void addPlayerToBuilding(const Building& bd, BuildingDisplay& dspl, dtEntity::EntityId eid, const osg::Vec4& color,
|
||||
const std::string& symbol, const osg::Vec3d& pos, bool visible);
|
||||
static osg::Vec2d shiftPosition(const VCtrl::OBB& obb, const osg::Vec2d& pos, double& shiftValue);
|
||||
void cameraViewPositionChanged(unsigned int contextId, const BuildingViewer::CameraViewPosition& viewPos);
|
||||
|
||||
void Tick(const dtEntity::Message &message);
|
||||
std::set<unsigned int> m_setInitialCameraPositionSet;
|
||||
|
||||
std::map<std::string, VCtrl::OBB> mRooms;
|
||||
std::map<std::string, RoomPlayers> mUsedRooms;
|
||||
CallbackCamPosChanged mCbCamPosChanged;
|
||||
std::map<std::string, std::map<std::string, std::string>> m_mapBuildingRoomNames;
|
||||
std::map<std::string, std::string> m_mapBuildingDisplayNames;
|
||||
dtEntity::EntityManager* mEntityManager;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bool getFloorOfRoom(const std::string &bdlgFeatureId, int roomNumber, int &floorOut) const;
|
||||
|
||||
|
||||
std::map<std::string, std::map<int,int> > mRoomToFloorPerBldg;
|
||||
std::vector<Building*> mBuildings;
|
||||
QMutex m_mutexShots;
|
||||
|
||||
bool mShotOverview;
|
||||
bool mExactPos;
|
||||
float mMapRotation;
|
||||
dtEntity::MessageFunctor mTickFunctor;
|
||||
|
||||
void Tick(const dtEntity::Message& message);
|
||||
|
||||
std::map<std::string, VCtrl::OBB> mRooms;
|
||||
std::map<std::string, RoomPlayers> mUsedRooms;
|
||||
CallbackCamPosChanged mCbCamPosChanged;
|
||||
|
||||
bool getFloorOfRoom(const std::string& bdlgFeatureId, int roomNumber, int& floorOut) const;
|
||||
|
||||
std::map<std::string, std::map<int, int>> mRoomToFloorPerBldg;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace VCtrl
|
||||
Executable → Regular
+176
-285
@@ -1,41 +1,39 @@
|
||||
#pragma once
|
||||
|
||||
#include "buildingmanager.h"
|
||||
#include "exccommands.h"
|
||||
#include "logger.h"
|
||||
#include "viewerinterface.h"
|
||||
#include "viewwidgetcontainer.h"
|
||||
#include <dtEntity/mapcomponent.h>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
#include "viewwidgetstate.h"
|
||||
|
||||
#include <QPointer>
|
||||
#include <QWidget>
|
||||
|
||||
#include <dtEntity/mapcomponent.h>
|
||||
#include <dtEntity/core.h>
|
||||
#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/positionattitudetransformcomponent.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 <osg/ComputeBoundsVisitor>
|
||||
#include <osgViewer/CompositeViewer>
|
||||
#include "buildingmanager.h"
|
||||
#include "exccommands.h"
|
||||
#include "viewwidgetstate.h"
|
||||
#include "logger.h"
|
||||
#include <string>
|
||||
|
||||
namespace dtEntity
|
||||
{
|
||||
class EntityManager;
|
||||
class MapSystem;
|
||||
class Message;
|
||||
}
|
||||
} // namespace dtEntity
|
||||
|
||||
namespace VCtrl
|
||||
{
|
||||
@@ -48,354 +46,247 @@ class CtrlMainWindow;
|
||||
|
||||
class CtrlImpl : public QObject, public ViewerInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Q_OBJECT
|
||||
public:
|
||||
CtrlImpl(dtEntity::EntityManager& em, QWidget* parentWidget);
|
||||
~CtrlImpl();
|
||||
|
||||
CtrlImpl(dtEntity::EntityManager &em, QWidget *parentWidget);
|
||||
~CtrlImpl();
|
||||
void SetViewerCallback(ViewerCallback*) override;
|
||||
void RemoveViewerCallback() override;
|
||||
|
||||
void SetViewerCallback(ViewerCallback *) override;
|
||||
void RemoveViewerCallback() override;
|
||||
void SetProjectDataPaths(const std::vector<std::string>& paths) override;
|
||||
|
||||
|
||||
QWidget* getMainWindow() override;
|
||||
quintptr requestMainWindowHandle() override;
|
||||
|
||||
void SetProjectDataPaths(const std::vector<std::string> &paths) override;
|
||||
void openViews(const std::vector<std::string>& bldIds, bool exactPos) override;
|
||||
bool isViewOpen(const std::string& strBldId) const override;
|
||||
|
||||
QWidget* getMainWindow() override;
|
||||
quintptr requestMainWindowHandle() override;
|
||||
void closeViews(const std::vector<std::string>& vecFeatureIDs) override;
|
||||
void closeAllViews();
|
||||
|
||||
void UseExactPositioning(bool exactPos) override;
|
||||
|
||||
void openViews(const std::vector<std::string> &bldIds, bool exactPos) override;
|
||||
bool isViewOpen(const std::string &strBldId) const 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 closeViews(const std::vector<std::string> &vecFeatureIDs) override;
|
||||
void closeAllViews();
|
||||
void CloseView(unsigned int contextid) override;
|
||||
|
||||
void UseExactPositioning(bool exactPos) override;
|
||||
void ChangeViewMode(unsigned int contextId, ViewMode viewmode) override;
|
||||
|
||||
|
||||
void LockViewRotationToMapRotation(unsigned int contextId, bool lock) 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 SetPlayerDisplayMode(unsigned int contextId, PlayerDisplayMode mode) override;
|
||||
|
||||
void SetWallTransparency(unsigned int contextId, float transparency) override;
|
||||
|
||||
|
||||
float GetMapRotation() const override;
|
||||
|
||||
void CloseView(unsigned int contextid) override;
|
||||
void SetMapRotation(float angle) override;
|
||||
|
||||
|
||||
void OpenOverview() override;
|
||||
|
||||
void ChangeViewMode(unsigned int contextId, ViewMode viewmode) override;
|
||||
bool LoadBuildingPositionMap(const std::string& path, bool loadAllAvailableBuildings) override;
|
||||
|
||||
|
||||
void LoadAllBuildings();
|
||||
|
||||
void LockViewRotationToMapRotation(unsigned int contextId, bool lock) override;
|
||||
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 SetPlayerDisplayMode(unsigned int contextId, PlayerDisplayMode mode) override;
|
||||
void SetPlayerColor(const std::string& id, const Color& color) override;
|
||||
|
||||
|
||||
void SetPlayerIcon(const std::string& id, const std::string& path) override;
|
||||
|
||||
void SetWallTransparency(unsigned int contextId, float transparency) override;
|
||||
void reloadPlayerIcons() override;
|
||||
|
||||
|
||||
void UpdatePlayerPartyColors(const std::map<std::string, VCtrl::Color>& mapPlayerColors) override;
|
||||
|
||||
float GetMapRotation() const override;
|
||||
size_t GetNumPlayers() const override;
|
||||
|
||||
|
||||
void GetPlayerIds(std::vector<std::string>& toFill) override;
|
||||
|
||||
void SetMapRotation(float angle) override;
|
||||
void SetPlayerShown(const std::string& id, bool show, double when = -1) override;
|
||||
|
||||
|
||||
size_t GetNumBuildings() const override;
|
||||
|
||||
void OpenOverview() 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;
|
||||
|
||||
bool LoadBuildingPositionMap(const std::string &path, bool loadAllAvailableBuildings) 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 LoadAllBuildings();
|
||||
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;
|
||||
|
||||
void CreatePlayer(const std::string &id, const std::string &iconpath, const Color &color) override;
|
||||
bool SetBuildingDestructionValue(const std::string& id, float value) override;
|
||||
|
||||
|
||||
void GetDeviceNames(const std::string& buildingId, std::vector<std::string>& names) override;
|
||||
|
||||
void DeletePlayer(const std::string &id, float seconds = 0) 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 SetPlayerColor(const std::string &id, const Color &color) 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;
|
||||
|
||||
void SetPlayerIcon(const std::string &id, const std::string &path) override;
|
||||
bool HideDeviceIcon(const std::string& id) override;
|
||||
|
||||
float GetTimeScale() const override;
|
||||
|
||||
void reloadPlayerIcons() override;
|
||||
void SetTimeScale(float scale) override;
|
||||
|
||||
void UpdatePlayerPartyColors(const std::map<std::string, VCtrl::Color>& mapPlayerColors) override;
|
||||
void SetSimulationTime(double t) override;
|
||||
|
||||
|
||||
double GetSimulationTime() const override;
|
||||
|
||||
size_t GetNumPlayers() const override;
|
||||
void SetPaused(bool) override;
|
||||
|
||||
|
||||
bool GetPaused() const override;
|
||||
|
||||
void GetPlayerIds(std::vector<std::string> &toFill) override;
|
||||
void FastForwardSimulationTo(double t) override;
|
||||
|
||||
|
||||
void DeleteQueuedCommands() override;
|
||||
|
||||
void SetPlayerShown(const std::string &id, bool show, double when = -1) override;
|
||||
void SetNonRealtimeMode(bool on) override;
|
||||
|
||||
|
||||
bool GetNonRealtimeMode() const override;
|
||||
|
||||
size_t GetNumBuildings() 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 GetBuildingIds(std::vector<std::string> &toFill) const override;
|
||||
void setTransparency(double percent) override;
|
||||
void setViewMode(ViewMode m) override;
|
||||
void setDisplayMode(PlayerDisplayMode m) 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())
|
||||
int GetFrameRate() const
|
||||
{
|
||||
if (!vw->isOpenGlWindowExposed())
|
||||
return false;
|
||||
return mFrameRate;
|
||||
}
|
||||
return !m_openedViewWidgets.getViewWidgets().empty();
|
||||
}
|
||||
|
||||
private:
|
||||
void OnShowMsgBox(const std::string& strText);
|
||||
|
||||
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);
|
||||
bool allViewWindowsExposed() const
|
||||
{
|
||||
for (auto* vw : m_openedViewWidgets.getViewWidgets())
|
||||
{
|
||||
if (!vw->isOpenGlWindowExposed())
|
||||
return false;
|
||||
}
|
||||
return !m_openedViewWidgets.getViewWidgets().empty();
|
||||
}
|
||||
|
||||
void onEXCOpen(const QString& strIDs, bool exactPos);
|
||||
void onEXCClose(const QString& strIDs);
|
||||
void convertAssetsToPngFiles();
|
||||
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 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);
|
||||
void onEXCOpen(const QString& strIDs, bool exactPos);
|
||||
void onEXCClose(const QString& strIDs);
|
||||
void convertAssetsToPngFiles();
|
||||
|
||||
bool SpawnBuilding(const BuildingData &b, bool useStaticMeshesFolder = true);
|
||||
void LoadBuilding(BuildingData& bd, bool useStaticMeshesFolder);
|
||||
void deleteAllBuildings();
|
||||
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);
|
||||
|
||||
bool getBuildingString(const std::string &strFeatureID, std::string *strBuildingNameID);
|
||||
void OnShoot(const dtEntity::Message& m);
|
||||
void OnShowHidePlayer(const dtEntity::Message& m);
|
||||
void OnDisplayNameClicked(const dtEntity::Message& m);
|
||||
|
||||
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);
|
||||
bool SpawnBuilding(const BuildingData& b, bool useStaticMeshesFolder = true);
|
||||
void LoadBuilding(BuildingData& bd, bool useStaticMeshesFolder);
|
||||
void deleteAllBuildings();
|
||||
|
||||
QPointer<CtrlMainWindow> m_pMainWindow;
|
||||
bool getBuildingString(const std::string& strFeatureID, std::string* strBuildingNameID);
|
||||
|
||||
dtEntity::EntityManager *mEntityManager;
|
||||
ViewerCallback *mViewerCallback;
|
||||
LogHandler* mLogHandler = nullptr;
|
||||
dtEntity::MapSystem *mMapSystem;
|
||||
PlayerSystem *mPlayerSystem;
|
||||
BuildingManager *mBuildingManager;
|
||||
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);
|
||||
|
||||
float mTimeScale;
|
||||
double mSimTime;
|
||||
bool mPaused;
|
||||
bool mNonRealtimeMode;
|
||||
int mFrameRate;
|
||||
std::map<unsigned int, ViewWidget *> mViewWidgets;
|
||||
QPointer<CtrlMainWindow> m_pMainWindow;
|
||||
|
||||
dtEntity::EntityManager* mEntityManager;
|
||||
ViewerCallback* mViewerCallback;
|
||||
LogHandler* mLogHandler = nullptr;
|
||||
dtEntity::MapSystem* mMapSystem;
|
||||
PlayerSystem* mPlayerSystem;
|
||||
BuildingManager* mBuildingManager;
|
||||
|
||||
ViewWidget *GetViewWidget(unsigned int contextid);
|
||||
void storeWidget(ViewWidget *pWidget, const std::string &strBuildingNameID, unsigned int contextid, VCtrl::ViewMode vmode, VCtrl::PlayerDisplayMode displayMode);
|
||||
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);
|
||||
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;
|
||||
std::unordered_map<std::string, BuildingData> m_loadedBuildings;
|
||||
|
||||
ViewWidgetContainer m_openedViewWidgets;
|
||||
bool m_isInFullscreenMode = false;
|
||||
ViewWidgetContainer m_openedViewWidgets;
|
||||
bool m_isInFullscreenMode = false;
|
||||
|
||||
|
||||
ViewMode m_desiredViewMode = ViewMode::ORTHOGRAPHIC;
|
||||
VCtrl::PlayerDisplayMode m_desiredPlayerDisplayMode = VCtrl::PlayerDisplayMode::Icons;
|
||||
ViewMode m_desiredViewMode = ViewMode::ORTHOGRAPHIC;
|
||||
VCtrl::PlayerDisplayMode m_desiredPlayerDisplayMode = VCtrl::PlayerDisplayMode::Icons;
|
||||
|
||||
void CloseView(ViewWidget *pWidget);
|
||||
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;
|
||||
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;
|
||||
|
||||
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);
|
||||
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
|
||||
Executable → Regular
+376
-418
File diff suppressed because it is too large.
Load diff
Executable → Regular
+109
-119
@@ -1,29 +1,25 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <string>
|
||||
#include "BgViewer/viewerCtrl/viewerinterface.h"
|
||||
#include "bdv_helper.h"
|
||||
#include "buildingviewercommon_export.h"
|
||||
#include "logger.h"
|
||||
|
||||
#include <BuildingViewer/share/exccommands.h>
|
||||
#include <InfrastructureManagement/Shared/ism_mounting_point.h>
|
||||
#include <LtsUtilsCore/qpoint3d.h>
|
||||
#include <ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
#include <QByteArray>
|
||||
#include <QHash>
|
||||
#include <QList>
|
||||
#include <QMap>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
#include <QVector3D>
|
||||
|
||||
#include "logger.h"
|
||||
#include "buildingviewercommon_export.h"
|
||||
#include <BuildingViewer/share/exccommands.h>
|
||||
#include <InfrastructureManagement/Shared/ism_mounting_point.h>
|
||||
#include <ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
#include <LtsUtilsCore/qpoint3d.h>
|
||||
|
||||
#include <QVector>
|
||||
#include <string>
|
||||
|
||||
namespace VCtrl
|
||||
{
|
||||
@@ -34,130 +30,124 @@ namespace BuildingViewer
|
||||
{
|
||||
struct DeviceInfo
|
||||
{
|
||||
QString deviceName;
|
||||
int buildingId = 0;
|
||||
QString deviceName;
|
||||
int buildingId = 0;
|
||||
|
||||
DeviceInfo() = default;
|
||||
DeviceInfo(int _buildingId, const QString &_deviceName)
|
||||
: deviceName(_deviceName)
|
||||
, buildingId(_buildingId)
|
||||
{}
|
||||
DeviceInfo() = default;
|
||||
|
||||
DeviceInfo(int _buildingId, const QString& _deviceName) : deviceName(_deviceName), buildingId(_buildingId) {}
|
||||
};
|
||||
|
||||
|
||||
|
||||
class BUILDINGVIEWERCOMMON_EXPORT CommunicationInterfaceInternal final : public QObject, public VCtrl::ViewerCallback
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CommunicationInterfaceInternal(VCtrl::ViewerInterface* pviewerInterface);
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CommunicationInterfaceInternal(VCtrl::ViewerInterface* pviewerInterface);
|
||||
|
||||
void playerCreate(int playerID, int partyID, const QString &strPathToSymbolFile,
|
||||
const LtsUtils::QPoint3D &pos, int buildingID , int roomNumber, Core::PositionReportingSource reportingSource);
|
||||
void playerPlace(int playerID, const LtsUtils::QPoint3D &pos,
|
||||
int buildingID, int roomNumber, Core::PositionReportingSource reportingSource);
|
||||
void playerDelete(int playerID);
|
||||
void setPlayerVisible(int playerID, bool bVisible);
|
||||
void playerClear();
|
||||
void playerUpdateSymbols();
|
||||
void playerUpdatePlayerSymbol(int playerID, const QString &strPathToSymbolFile);
|
||||
void playerHit(const int32_t id, int playerIdSrc, int playerIdDst,
|
||||
const LtsUtils::QPoint3D &posSrc, const LtsUtils::QPoint3D &posDst,
|
||||
int buildingIdSrc, int roomNumberSrc, int buildingIdDst, int roomNumberDst, int lineType,
|
||||
int64_t time);
|
||||
void buildingHit(const int32_t id, int buildingId, int damagePercent, const QMap<int, int> &mapRoomDestructions);
|
||||
void roomHit(const int32_t id, int playerIdSrc, int buildingId, int roomNumber, const LtsUtils::QPoint3D &posSrc, int lineType, int64_t time);
|
||||
void removeRoomHit(const int32_t id);
|
||||
void playerCreate(int playerID, int partyID, const QString& strPathToSymbolFile, const LtsUtils::QPoint3D& pos,
|
||||
int buildingID, int roomNumber, Core::PositionReportingSource reportingSource);
|
||||
void playerPlace(int playerID, const LtsUtils::QPoint3D& pos, int buildingID, int roomNumber,
|
||||
Core::PositionReportingSource reportingSource);
|
||||
void playerDelete(int playerID);
|
||||
void setPlayerVisible(int playerID, bool bVisible);
|
||||
void playerClear();
|
||||
void playerUpdateSymbols();
|
||||
void playerUpdatePlayerSymbol(int playerID, const QString& strPathToSymbolFile);
|
||||
void playerHit(const int32_t id, int playerIdSrc, int playerIdDst, const LtsUtils::QPoint3D& posSrc,
|
||||
const LtsUtils::QPoint3D& posDst, int buildingIdSrc, int roomNumberSrc, int buildingIdDst,
|
||||
int roomNumberDst, int lineType, int64_t time);
|
||||
void buildingHit(const int32_t id, int buildingId, int damagePercent, const QMap<int, int>& mapRoomDestructions);
|
||||
void roomHit(const int32_t id, int playerIdSrc, int buildingId, int roomNumber, const LtsUtils::QPoint3D& posSrc,
|
||||
int lineType, int64_t time);
|
||||
void removeRoomHit(const int32_t id);
|
||||
|
||||
void setTeamConfiguration(const QMap<qint32, ParticipantManagement::Party>& parties);
|
||||
void setTeamConfiguration(const QMap<qint32, ParticipantManagement::Party>& parties);
|
||||
|
||||
void systemSetSimulationTime(qint64 time);
|
||||
void setSimuationPace(double pace);
|
||||
void systemDisconnect();
|
||||
void systemSetPaused(bool bPaused);
|
||||
void systemSetMountingPoint(const InfrastructureManagement::MountingPoint &data, const QString &filename, bool show);
|
||||
void systemSetSimulationTime(qint64 time);
|
||||
void setSimuationPace(double pace);
|
||||
void systemDisconnect();
|
||||
void systemSetPaused(bool bPaused);
|
||||
void systemSetMountingPoint(const InfrastructureManagement::MountingPoint& data, const QString& filename,
|
||||
bool show);
|
||||
|
||||
void excConnect(const std::vector<std::string> &paths, const QString &strXMLFile = QString());
|
||||
void excDeleteBuildingList();
|
||||
void excSetHitlineDuration(uint32_t duration_s);
|
||||
void excUseExactPositioning(bool useExactPositioning);
|
||||
void excOpenView(const std::vector<std::string> &bldIds);
|
||||
void excCloseView(const std::vector<std::string> &bldIds);
|
||||
void excCloseAllViews();
|
||||
void excStartRecording(const QString &strPathOutputFolder, const QString &buildingId = QStringLiteral("all"),
|
||||
int w = 800, int h = 600, int framerate = 20, int quality = 100);
|
||||
void excStopRecording(const QString &buildingId = QStringLiteral("all"));
|
||||
void excHighlightView(const QString &buildingId);
|
||||
void excSetGlobalTransparency(double transparency);
|
||||
void excSetGlobalViewMode(bool useOrtho);
|
||||
void excSetGlobalDotsMode(bool useDots);
|
||||
void excGetBuildingList();
|
||||
void excRestoreViewState(const QJsonValue &val);
|
||||
void excGetViewState();
|
||||
void excSetRoomDisplayName(const QString &strFeatureID, const QString &strRoomName, const QString &strRoomDisplayName);
|
||||
void excSetBuildingDisplayName(const QString &buildingId, const QString &strBuildingDisplayName);
|
||||
void extSetMountingPointAsset(const QString &strFeatureID, const QString &strMountingPointId, const QVector3D &position, BuildingViewer::AssetTypes assetType);
|
||||
void extHideMountingPointAsset(const QString &strMountingPointId);
|
||||
void excConnect(const std::vector<std::string>& paths, const QString& strXMLFile = QString());
|
||||
void excDeleteBuildingList();
|
||||
void excSetHitlineDuration(uint32_t duration_s);
|
||||
void excUseExactPositioning(bool useExactPositioning);
|
||||
void excOpenView(const std::vector<std::string>& bldIds);
|
||||
void excCloseView(const std::vector<std::string>& bldIds);
|
||||
void excCloseAllViews();
|
||||
void excStartRecording(const QString& strPathOutputFolder, const QString& buildingId = QStringLiteral("all"),
|
||||
int w = 800, int h = 600, int framerate = 20, int quality = 100);
|
||||
void excStopRecording(const QString& buildingId = QStringLiteral("all"));
|
||||
void excHighlightView(const QString& buildingId);
|
||||
void excSetGlobalTransparency(double transparency);
|
||||
void excSetGlobalViewMode(bool useOrtho);
|
||||
void excSetGlobalDotsMode(bool useDots);
|
||||
void excGetBuildingList();
|
||||
void excRestoreViewState(const QJsonValue& val);
|
||||
void excGetViewState();
|
||||
void excSetRoomDisplayName(const QString& strFeatureID, const QString& strRoomName,
|
||||
const QString& strRoomDisplayName);
|
||||
void excSetBuildingDisplayName(const QString& buildingId, const QString& strBuildingDisplayName);
|
||||
void extSetMountingPointAsset(const QString& strFeatureID, const QString& strMountingPointId,
|
||||
const QVector3D& position, BuildingViewer::AssetTypes assetType);
|
||||
void extHideMountingPointAsset(const QString& strMountingPointId);
|
||||
|
||||
void SystemReady() override;
|
||||
void TransformChanged(const std::string& id, const VCtrl::Vec3d& pos, const VCtrl::Quat& attitude) override;
|
||||
void NavMeshGroupChanged(const std::string& id, const std::string& grpname) override;
|
||||
void PlayerPicked(const std::string& strId) override;
|
||||
void DisplayNamePicked(const std::string& buildingid, const std::string& roomname) override;
|
||||
void ViewCreated(unsigned int contextId, VCtrl::ViewMode viewmode) override;
|
||||
void ViewModeChanged(unsigned int contextId, VCtrl::ViewMode viewmode) override;
|
||||
void ViewLineModeChanged(unsigned int contextId, bool line) override;
|
||||
void ViewNameModeChanged(unsigned int contextId, bool name) override;
|
||||
void ViewLockRotationChanged(unsigned int contextId, bool lock) override;
|
||||
void ViewTransparencyChanged() override;
|
||||
void PlayerDisplayModeChanged(unsigned int contextId, VCtrl::PlayerDisplayMode mode) override;
|
||||
void ViewClosed(unsigned int contextId) override;
|
||||
void HandleViewerEvent(BuildingViewer::BgViewerEvents event, const std::vector<std::string>& args) override;
|
||||
void ViewZoomChanged(const std::string& buildingId, double top, double left, double bottom, double right) override;
|
||||
void LogMessage(Severity& severity, const std::string& filename, const std::string& methodname, int linenumber,
|
||||
const std::string& msg) override;
|
||||
|
||||
void SystemReady() override;
|
||||
void TransformChanged(const std::string &id, const VCtrl::Vec3d &pos, const VCtrl::Quat &attitude) override;
|
||||
void NavMeshGroupChanged(const std::string &id, const std::string &grpname) override;
|
||||
void PlayerPicked(const std::string &strId) override;
|
||||
void DisplayNamePicked(const std::string &buildingid, const std::string &roomname) override;
|
||||
void ViewCreated(unsigned int contextId, VCtrl::ViewMode viewmode) override;
|
||||
void ViewModeChanged(unsigned int contextId, VCtrl::ViewMode viewmode) override;
|
||||
void ViewLineModeChanged(unsigned int contextId, bool line) override;
|
||||
void ViewNameModeChanged(unsigned int contextId, bool name) override;
|
||||
void ViewLockRotationChanged(unsigned int contextId, bool lock) override;
|
||||
void ViewTransparencyChanged() override;
|
||||
void PlayerDisplayModeChanged(unsigned int contextId, VCtrl::PlayerDisplayMode mode) override;
|
||||
void ViewClosed(unsigned int contextId) override;
|
||||
void HandleViewerEvent(BuildingViewer::BgViewerEvents event,
|
||||
const std::vector<std::string> &args) override;
|
||||
void ViewZoomChanged(const std::string &buildingId, double top, double left, double bottom, double right) override;
|
||||
void LogMessage(Severity &severity, const std::string &filename, const std::string &methodname,
|
||||
int linenumber, const std::string &msg) override;
|
||||
Q_SIGNALS:
|
||||
void signalBgViewerInitFinished();
|
||||
void signalReceivedBuildingList(const QVector<BuildingTuple>& states);
|
||||
void signalReceivedViewState(const QJsonValue& state);
|
||||
|
||||
Q_SIGNALS:
|
||||
void signalBgViewerInitFinished();
|
||||
void signalReceivedBuildingList(const QVector<BuildingTuple> &states);
|
||||
void signalReceivedViewState(const QJsonValue &state);
|
||||
void signalPlayerPicked(int playerId);
|
||||
void signalAssetPicked(int structureElementId);
|
||||
void signalViewerEventWidgetClosed(const QString& featureID);
|
||||
void signalViewerEventWidgetMaximized(const QString& featureID);
|
||||
void signalViewerEventWidgetMinimized(const QString& featureID);
|
||||
void signalViewerEventWidgetFocused(const QString& featureID);
|
||||
void signalViewerEventButton();
|
||||
|
||||
void signalPlayerPicked(int playerId);
|
||||
void signalAssetPicked(int structureElementId);
|
||||
void signalViewerEventWidgetClosed(const QString &featureID);
|
||||
void signalViewerEventWidgetMaximized(const QString &featureID);
|
||||
void signalViewerEventWidgetMinimized(const QString &featureID);
|
||||
void signalViewerEventWidgetFocused(const QString &featureID);
|
||||
void signalViewerEventButton();
|
||||
void signalViewerEventRoomNameClicked(const QString& featureID, const QString& roomID);
|
||||
void signalViewerZoomChanged(const QString& featureId, double top, double left, double bottom, double right);
|
||||
|
||||
void signalViewerEventRoomNameClicked(const QString &featureID, const QString &roomID);
|
||||
void signalViewerZoomChanged(const QString &featureId, double top, double left, double bottom, double right);
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
void clearCameras();
|
||||
QHash<QString, DeviceInfo> m_deviceMap;
|
||||
|
||||
private:
|
||||
|
||||
struct BdvParty
|
||||
{
|
||||
QString name;
|
||||
VCtrl::Color color;
|
||||
int id = 0;
|
||||
};
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
void clearCameras();
|
||||
QHash<QString, DeviceInfo> m_deviceMap;
|
||||
QHash<int, BdvParty> m_teamMap;
|
||||
|
||||
|
||||
struct BdvParty
|
||||
{
|
||||
QString name;
|
||||
VCtrl::Color color;
|
||||
int id = 0;
|
||||
};
|
||||
QHash<int, BdvParty> m_teamMap;
|
||||
QHash<int, int> m_player2TeamMap;
|
||||
QHash<int, std::string> m_playerId2String;
|
||||
QMap<std::string, int> m_string2PlayerId;
|
||||
|
||||
|
||||
QHash<int, int> m_player2TeamMap;
|
||||
QHash<int, std::string> m_playerId2String;
|
||||
QMap<std::string, int> m_string2PlayerId;
|
||||
|
||||
VCtrl::ViewerInterface *m_pviewerInterface = nullptr;
|
||||
bool m_useExactPositioning = true;
|
||||
VCtrl::ViewerInterface* m_pviewerInterface = nullptr;
|
||||
bool m_useExactPositioning = true;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace BuildingViewer
|
||||
Executable → Regular
+241
-271
@@ -1,430 +1,400 @@
|
||||
|
||||
|
||||
|
||||
#include "bdv_controller.h"
|
||||
#include <utility>
|
||||
#include "bdv_dds_controller.h"
|
||||
#include "bdv_bgviewer_widget_container.h"
|
||||
|
||||
#include "bdv_bgviewer_widget_container.h"
|
||||
#include "bdv_dds_controller.h"
|
||||
|
||||
#include <Common/bdv_communication_interface_internal.h>
|
||||
#include <Common/bdv_plugin_provider.h>
|
||||
#include <LtsAppManager/lts_app_manager.h>
|
||||
#include <LtsPluginManager/lts_plugin_manager.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <Common/bdv_communication_interface_internal.h>
|
||||
#include <Common/bdv_plugin_provider.h>
|
||||
#include <ngltools/ngltools_filesystem.h>
|
||||
|
||||
#include <QDir>
|
||||
#include <QMessageBox>
|
||||
#include <ngltools/ngltools_filesystem.h>
|
||||
#include <utility>
|
||||
|
||||
namespace BuildingViewer
|
||||
{
|
||||
static int argc_dummy = 1;
|
||||
static char *argv_dummy[] = { (char*)"Dummy" };
|
||||
static char* argv_dummy[] = {(char*)"Dummy"};
|
||||
|
||||
BgViewerController::BgViewerController(QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_mainloop(argc_dummy, argv_dummy, nullptr)
|
||||
, m_widgetStolen(false)
|
||||
, m_comIfc(nullptr)
|
||||
, m_pBgViewerDDSController(nullptr)
|
||||
, m_bgvApp(nullptr)
|
||||
, m_tickTimer(new QTimer(this))
|
||||
BgViewerController::BgViewerController(QObject* parent)
|
||||
: QObject(parent), m_mainloop(argc_dummy, argv_dummy, nullptr), m_widgetStolen(false), m_comIfc(nullptr),
|
||||
m_pBgViewerDDSController(nullptr), m_bgvApp(nullptr), m_tickTimer(new QTimer(this))
|
||||
{
|
||||
m_tickTimer->setInterval(1000 / 25);
|
||||
connect(m_tickTimer, &QTimer::timeout, this, [this]() { m_mainloop.tick(); });
|
||||
m_tickTimer->setInterval(1000 / 25);
|
||||
connect(m_tickTimer, &QTimer::timeout, this, [this]() { m_mainloop.tick(); });
|
||||
|
||||
m_mainloop.getViewerInterface()->getMainWindow()->setMinimumSize(200, 200);
|
||||
m_mainloop.getViewerInterface()->getMainWindow()->setMinimumSize(200, 200);
|
||||
|
||||
m_viewerInterface = m_mainloop.getViewerInterface();
|
||||
m_comIfc = new CommunicationInterfaceInternal(m_viewerInterface);
|
||||
m_viewerInterface->SetViewerCallback(m_comIfc);
|
||||
m_viewerInterface = m_mainloop.getViewerInterface();
|
||||
m_comIfc = new CommunicationInterfaceInternal(m_viewerInterface);
|
||||
m_viewerInterface->SetViewerCallback(m_comIfc);
|
||||
|
||||
m_pBgViewerDDSController = new BuildingViewerDdsController(m_comIfc, m_viewerInterface);
|
||||
m_pBgViewerDDSController = new BuildingViewerDdsController(m_comIfc, m_viewerInterface);
|
||||
|
||||
connect(m_pBgViewerDDSController, &BuildingViewerDdsController::signalDdsInitFinished, this, [this]() {
|
||||
m_initExerciseWasSuccessful = true;
|
||||
});
|
||||
|
||||
connect(m_comIfc, &CommunicationInterfaceInternal::signalBgViewerInitFinished,
|
||||
this, &BgViewerController::signalBgViewerInitFinished);
|
||||
connect(m_comIfc, &CommunicationInterfaceInternal::signalReceivedBuildingList,
|
||||
this, &BgViewerController::signalReceivedBuildingList);
|
||||
connect(m_comIfc, &CommunicationInterfaceInternal::signalReceivedViewState,
|
||||
this, &BgViewerController::signalReceivedViewState);
|
||||
connect(m_comIfc, &CommunicationInterfaceInternal::signalPlayerPicked,
|
||||
this, &BgViewerController::signalPlayerPicked);
|
||||
connect(m_comIfc, &CommunicationInterfaceInternal::signalAssetPicked,
|
||||
this, &BgViewerController::signalAssetPicked);
|
||||
connect(m_comIfc, &CommunicationInterfaceInternal::signalViewerEventWidgetClosed,
|
||||
this, &BgViewerController::signalViewerEventWidgetClosed);
|
||||
connect(m_comIfc, &CommunicationInterfaceInternal::signalViewerEventWidgetMaximized,
|
||||
this, &BgViewerController::signalViewerEventWidgetMaximized);
|
||||
connect(m_comIfc, &CommunicationInterfaceInternal::signalViewerEventWidgetMinimized,
|
||||
this, &BgViewerController::signalViewerEventWidgetMinimized);
|
||||
connect(m_comIfc, &CommunicationInterfaceInternal::signalViewerEventWidgetFocused,
|
||||
this, &BgViewerController::signalViewerEventWidgetFocused);
|
||||
connect(m_comIfc, &CommunicationInterfaceInternal::signalViewerEventRoomNameClicked,
|
||||
this, &BgViewerController::signalViewerEventRoomNameClicked);
|
||||
connect(m_comIfc, &CommunicationInterfaceInternal::signalViewerZoomChanged,
|
||||
this, &BgViewerController::signalViewerZoomChanged);
|
||||
connect(m_comIfc, &CommunicationInterfaceInternal::signalViewerEventButton,
|
||||
this, &BgViewerController::signalViewerEventButton);
|
||||
connect(m_pBgViewerDDSController, &BuildingViewerDdsController::signalDdsInitFinished, this,
|
||||
[this]() { m_initExerciseWasSuccessful = true; });
|
||||
|
||||
connect(m_comIfc, &CommunicationInterfaceInternal::signalBgViewerInitFinished, this,
|
||||
&BgViewerController::signalBgViewerInitFinished);
|
||||
connect(m_comIfc, &CommunicationInterfaceInternal::signalReceivedBuildingList, this,
|
||||
&BgViewerController::signalReceivedBuildingList);
|
||||
connect(m_comIfc, &CommunicationInterfaceInternal::signalReceivedViewState, this,
|
||||
&BgViewerController::signalReceivedViewState);
|
||||
connect(m_comIfc, &CommunicationInterfaceInternal::signalPlayerPicked, this,
|
||||
&BgViewerController::signalPlayerPicked);
|
||||
connect(m_comIfc, &CommunicationInterfaceInternal::signalAssetPicked, this, &BgViewerController::signalAssetPicked);
|
||||
connect(m_comIfc, &CommunicationInterfaceInternal::signalViewerEventWidgetClosed, this,
|
||||
&BgViewerController::signalViewerEventWidgetClosed);
|
||||
connect(m_comIfc, &CommunicationInterfaceInternal::signalViewerEventWidgetMaximized, this,
|
||||
&BgViewerController::signalViewerEventWidgetMaximized);
|
||||
connect(m_comIfc, &CommunicationInterfaceInternal::signalViewerEventWidgetMinimized, this,
|
||||
&BgViewerController::signalViewerEventWidgetMinimized);
|
||||
connect(m_comIfc, &CommunicationInterfaceInternal::signalViewerEventWidgetFocused, this,
|
||||
&BgViewerController::signalViewerEventWidgetFocused);
|
||||
connect(m_comIfc, &CommunicationInterfaceInternal::signalViewerEventRoomNameClicked, this,
|
||||
&BgViewerController::signalViewerEventRoomNameClicked);
|
||||
connect(m_comIfc, &CommunicationInterfaceInternal::signalViewerZoomChanged, this,
|
||||
&BgViewerController::signalViewerZoomChanged);
|
||||
connect(m_comIfc, &CommunicationInterfaceInternal::signalViewerEventButton, this,
|
||||
&BgViewerController::signalViewerEventButton);
|
||||
}
|
||||
|
||||
|
||||
BgViewerController::~BgViewerController()
|
||||
{
|
||||
delete m_tickTimer;
|
||||
delete m_tickTimer;
|
||||
|
||||
if (m_bgvApp != nullptr)
|
||||
{
|
||||
m_bgvApp->disconnect();
|
||||
delete m_bgvApp;
|
||||
}
|
||||
if (m_bgvApp != nullptr)
|
||||
{
|
||||
m_bgvApp->disconnect();
|
||||
delete m_bgvApp;
|
||||
}
|
||||
|
||||
delete m_pBgViewerDDSController;
|
||||
delete m_comIfc;
|
||||
delete m_pBgViewerDDSController;
|
||||
delete m_comIfc;
|
||||
|
||||
m_bgvApp = nullptr;
|
||||
m_comIfc = nullptr;
|
||||
m_pBgViewerDDSController = nullptr;
|
||||
m_bgvApp = nullptr;
|
||||
m_comIfc = nullptr;
|
||||
m_pBgViewerDDSController = nullptr;
|
||||
}
|
||||
|
||||
|
||||
void BgViewerController::excConnect(const std::vector<std::string> &paths, const QString &strXMLFile)
|
||||
void BgViewerController::excConnect(const std::vector<std::string>& paths, const QString& strXMLFile)
|
||||
{
|
||||
if (m_comIfc)
|
||||
m_comIfc->excConnect(paths, strXMLFile);
|
||||
if (m_comIfc)
|
||||
m_comIfc->excConnect(paths, strXMLFile);
|
||||
}
|
||||
|
||||
void BgViewerController::excGetBuildingList()
|
||||
{
|
||||
if (m_comIfc)
|
||||
m_comIfc->excGetBuildingList();
|
||||
if (m_comIfc)
|
||||
m_comIfc->excGetBuildingList();
|
||||
}
|
||||
|
||||
void BgViewerController::excGetViewState()
|
||||
{
|
||||
if (m_comIfc)
|
||||
m_comIfc->excGetViewState();
|
||||
if (m_comIfc)
|
||||
m_comIfc->excGetViewState();
|
||||
}
|
||||
|
||||
void BgViewerController::excHighlightView(const QString &strFeatureID)
|
||||
void BgViewerController::excHighlightView(const QString& strFeatureID)
|
||||
{
|
||||
if (m_comIfc)
|
||||
m_comIfc->excHighlightView(strFeatureID);
|
||||
if (m_comIfc)
|
||||
m_comIfc->excHighlightView(strFeatureID);
|
||||
}
|
||||
|
||||
void BgViewerController::excRestoreViewState(const QJsonValue &state)
|
||||
void BgViewerController::excRestoreViewState(const QJsonValue& state)
|
||||
{
|
||||
if (m_comIfc)
|
||||
{
|
||||
m_comIfc->excRestoreViewState(state);
|
||||
m_comIfc->excGetBuildingList();
|
||||
}
|
||||
if (m_comIfc)
|
||||
{
|
||||
m_comIfc->excRestoreViewState(state);
|
||||
m_comIfc->excGetBuildingList();
|
||||
}
|
||||
}
|
||||
|
||||
void BgViewerController::excSetGlobalDotsMode(bool useDots)
|
||||
{
|
||||
if (m_comIfc)
|
||||
m_comIfc->excSetGlobalDotsMode(useDots);
|
||||
if (m_comIfc)
|
||||
m_comIfc->excSetGlobalDotsMode(useDots);
|
||||
}
|
||||
|
||||
void BgViewerController::excSetGlobalTransparency(double transparency)
|
||||
{
|
||||
if (m_comIfc)
|
||||
m_comIfc->excSetGlobalTransparency(transparency);
|
||||
if (m_comIfc)
|
||||
m_comIfc->excSetGlobalTransparency(transparency);
|
||||
}
|
||||
|
||||
void BgViewerController::excSetGlobalViewMode(bool useOrtho)
|
||||
{
|
||||
if (m_comIfc)
|
||||
m_comIfc->excSetGlobalViewMode(useOrtho);
|
||||
if (m_comIfc)
|
||||
m_comIfc->excSetGlobalViewMode(useOrtho);
|
||||
}
|
||||
|
||||
void BgViewerController::excSetHitlineDuration(uint32_t duration_s)
|
||||
{
|
||||
if (m_comIfc)
|
||||
m_comIfc->excSetHitlineDuration(duration_s);
|
||||
if (m_comIfc)
|
||||
m_comIfc->excSetHitlineDuration(duration_s);
|
||||
}
|
||||
|
||||
void BgViewerController::excStartRecording(const QString &strPathOutputFolder,
|
||||
const QString &strFeatureID,
|
||||
int w, int h, int framerate, int quality)
|
||||
void BgViewerController::excStartRecording(const QString& strPathOutputFolder, const QString& strFeatureID, int w,
|
||||
int h, int framerate, int quality)
|
||||
{
|
||||
if (m_comIfc)
|
||||
m_comIfc->excStartRecording(strPathOutputFolder, strFeatureID, w, h, framerate, quality);
|
||||
if (m_comIfc)
|
||||
m_comIfc->excStartRecording(strPathOutputFolder, strFeatureID, w, h, framerate, quality);
|
||||
}
|
||||
|
||||
void BgViewerController::excStopRecording(const QString &strFeatureID)
|
||||
void BgViewerController::excStopRecording(const QString& strFeatureID)
|
||||
{
|
||||
if (m_comIfc)
|
||||
m_comIfc->excStopRecording(strFeatureID);
|
||||
if (m_comIfc)
|
||||
m_comIfc->excStopRecording(strFeatureID);
|
||||
}
|
||||
|
||||
QString BgViewerController::buildingModelPath()
|
||||
{
|
||||
QVector<QString> directoriesToSearch = NGL::directories(NGL::FileType::ConfigFile);
|
||||
QVector<QString> directoriesToSearch = NGL::directories(NGL::FileType::ConfigFile);
|
||||
#ifndef WIN32
|
||||
directoriesToSearch += QStringLiteral("/opt");
|
||||
directoriesToSearch += QStringLiteral("/opt");
|
||||
#endif
|
||||
|
||||
for (const QString &d : std::as_const(directoriesToSearch))
|
||||
{
|
||||
const QDir dir(d + QStringLiteral("/BuildingModels/StaticMeshes/"));
|
||||
if (dir.exists() && dir.isReadable())
|
||||
return dir.absolutePath();
|
||||
INFO_LOG(getLogger("BgViewerController")) << "Map path '" << dir.absolutePath() << "' either does not exist or is not readable - skipping";
|
||||
}
|
||||
return QString();
|
||||
for (const QString& d : std::as_const(directoriesToSearch))
|
||||
{
|
||||
const QDir dir(d + QStringLiteral("/BuildingModels/StaticMeshes/"));
|
||||
if (dir.exists() && dir.isReadable())
|
||||
return dir.absolutePath();
|
||||
INFO_LOG(getLogger("BgViewerController"))
|
||||
<< "Map path '" << dir.absolutePath() << "' either does not exist or is not readable - skipping";
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
void BgViewerController::clearInterfaces(const LtsSession::DdsConnectionParams &conParams)
|
||||
void BgViewerController::clearInterfaces(const LtsSession::DdsConnectionParams& conParams)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "BgViewerControllerSingleton::clearInterfaces()";
|
||||
if (m_pBgViewerDDSController && m_currentDdsConnParams == conParams)
|
||||
{
|
||||
m_pBgViewerDDSController->uninitialize();
|
||||
m_currentDdsConnParams = LtsSession::DdsConnectionParams();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void BgViewerController::hideLiveVideo()
|
||||
{
|
||||
|
||||
|
||||
|
||||
DEBUG_LOG(m_logger) << "BgViewerControllerSingleton::clearInterfaces()";
|
||||
if (m_pBgViewerDDSController && m_currentDdsConnParams == conParams)
|
||||
{
|
||||
m_pBgViewerDDSController->uninitialize();
|
||||
m_currentDdsConnParams = LtsSession::DdsConnectionParams();
|
||||
}
|
||||
}
|
||||
|
||||
void BgViewerController::hideLiveVideo() {}
|
||||
|
||||
bool BgViewerController::isBgViewerApplicationRunning() const
|
||||
{
|
||||
return (m_bgvApp != nullptr);
|
||||
return (m_bgvApp != nullptr);
|
||||
}
|
||||
|
||||
|
||||
LtsSession::DdsConnectionParams BgViewerController::currentDdsConnParams() const
|
||||
{
|
||||
return m_currentDdsConnParams;
|
||||
return m_currentDdsConnParams;
|
||||
}
|
||||
|
||||
|
||||
PluginProvider *BgViewerController::activeSession() const
|
||||
PluginProvider* BgViewerController::activeSession() const
|
||||
{
|
||||
return m_pBgViewerDDSController->activeSession();
|
||||
return m_pBgViewerDDSController->activeSession();
|
||||
}
|
||||
|
||||
|
||||
bool BgViewerController::init(PluginProvider *pSession, bool bStartRendering, const QString &modelPath)
|
||||
bool BgViewerController::init(PluginProvider* pSession, bool bStartRendering, const QString& modelPath)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "getDdsController init: " << pSession->toString();
|
||||
DEBUG_LOG(m_logger) << "getDdsController init: " << pSession->toString();
|
||||
|
||||
if (m_currentDdsConnParams == pSession->connParams())
|
||||
{
|
||||
if (m_initExerciseWasSuccessful)
|
||||
if (m_currentDdsConnParams == pSession->connParams())
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "BgViewerControllerSingleton::init Already initialized";
|
||||
slotLoadBuilding();
|
||||
if (m_initExerciseWasSuccessful)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "BgViewerControllerSingleton::init Already initialized";
|
||||
slotLoadBuilding();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
m_currentDdsConnParams = pSession->connParams();
|
||||
m_initExerciseWasSuccessful = false;
|
||||
if (!m_pBgViewerDDSController->init(m_bgViewerBaseLayoutWidget, modelPath, pSession))
|
||||
return false;
|
||||
if (bStartRendering)
|
||||
{
|
||||
m_bgvAppIsInitialized = true;
|
||||
m_tickTimer->start();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
m_currentDdsConnParams = pSession->connParams();
|
||||
m_initExerciseWasSuccessful = false;
|
||||
if (!m_pBgViewerDDSController->init(m_bgViewerBaseLayoutWidget, modelPath, pSession))
|
||||
return false;
|
||||
if (bStartRendering)
|
||||
{
|
||||
m_bgvAppIsInitialized = true;
|
||||
m_tickTimer->start();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BgViewerController::forceInit(PluginProvider *pSession)
|
||||
bool BgViewerController::forceInit(PluginProvider* pSession)
|
||||
{
|
||||
delete m_pBgViewerDDSController;
|
||||
m_pBgViewerDDSController = new BuildingViewerDdsController(m_comIfc, m_viewerInterface);
|
||||
|
||||
DEBUG_LOG(m_logger) << "FORCE INIT! with " << pSession;
|
||||
return (m_pBgViewerDDSController->init(m_bgViewerBaseLayoutWidget, buildingModelPath(), pSession));
|
||||
delete m_pBgViewerDDSController;
|
||||
m_pBgViewerDDSController = new BuildingViewerDdsController(m_comIfc, m_viewerInterface);
|
||||
|
||||
DEBUG_LOG(m_logger) << "FORCE INIT! with " << pSession;
|
||||
return (m_pBgViewerDDSController->init(m_bgViewerBaseLayoutWidget, buildingModelPath(), pSession));
|
||||
}
|
||||
|
||||
void BgViewerController::showBgViewerInfoMessageBox()
|
||||
{
|
||||
static bool showMsgBox = true;
|
||||
static bool showMsgBox = true;
|
||||
|
||||
if (!showMsgBox)
|
||||
return;
|
||||
if (!showMsgBox)
|
||||
return;
|
||||
|
||||
QMessageBox msgbox;
|
||||
msgbox.setText(tr("BuildingViewer is currently used by another application.\nPlease close the corresponding application."));
|
||||
msgbox.setIcon(QMessageBox::Information);
|
||||
msgbox.addButton(QMessageBox::Ok);
|
||||
QMessageBox msgbox;
|
||||
msgbox.setText(
|
||||
tr("BuildingViewer is currently used by another application.\nPlease close the corresponding application."));
|
||||
msgbox.setIcon(QMessageBox::Information);
|
||||
msgbox.addButton(QMessageBox::Ok);
|
||||
|
||||
QCheckBox *cb = new QCheckBox(tr("Do not show this message again."));
|
||||
msgbox.setCheckBox(cb);
|
||||
QCheckBox* cb = new QCheckBox(tr("Do not show this message again."));
|
||||
msgbox.setCheckBox(cb);
|
||||
|
||||
connect(cb, &QCheckBox::stateChanged, [](int state) {
|
||||
showMsgBox = state != Qt::Checked;
|
||||
});
|
||||
connect(cb, &QCheckBox::stateChanged, [](int state) { showMsgBox = state != Qt::Checked; });
|
||||
|
||||
msgbox.exec();
|
||||
msgbox.exec();
|
||||
}
|
||||
|
||||
|
||||
bool BgViewerController::startBgViewerAppInSession(PluginProvider* pStartingSession)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << std::hex << this << " startBgViewerAppInSession " << (m_currentDdsConnParams == pStartingSession->connParams());
|
||||
DEBUG_LOG(m_logger) << std::hex << this << " startBgViewerAppInSession "
|
||||
<< (m_currentDdsConnParams == pStartingSession->connParams());
|
||||
|
||||
if (m_bgvApp && (m_currentDdsConnParams == pStartingSession->connParams()))
|
||||
{
|
||||
INFO_LOG(m_logger) << std::hex << this << " BuildingViewer already opened. Doing nothing...";
|
||||
return true;
|
||||
}
|
||||
if (m_bgvApp && (m_currentDdsConnParams == pStartingSession->connParams()))
|
||||
{
|
||||
INFO_LOG(m_logger) << std::hex << this << " BuildingViewer already opened. Doing nothing...";
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (!m_bgvApp && m_widgetStolen)
|
||||
{
|
||||
showBgViewerInfoMessageBox();
|
||||
return false;
|
||||
}
|
||||
if (!m_bgvApp && m_widgetStolen)
|
||||
{
|
||||
showBgViewerInfoMessageBox();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_bgvApp)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << std::hex << this << " Releasing m_bgvApp";
|
||||
delete m_bgvApp;
|
||||
m_bgvApp = nullptr;
|
||||
|
||||
clearInterfaces(m_currentDdsConnParams);
|
||||
m_comIfc->excCloseAllViews();
|
||||
}
|
||||
|
||||
m_bgvAppIsInitialized = false;
|
||||
m_bgvApp = LtsAppManager::LtsAppManager::getInstance()->createApp(LtsAppDescriptor::App::BuildingViewer, pStartingSession->connParams());
|
||||
if (!m_bgvApp || !m_bgvApp->sessions().size())
|
||||
{
|
||||
ERROR_LOG(m_logger) << std::hex << this << " m_bgvApp is nullptr or has no associated session!";
|
||||
return false;
|
||||
}
|
||||
|
||||
connect(m_bgvApp, &LtsPluginManager::LtsPluginManager::signalInitializationFinished,
|
||||
this, [this, pStartingSession]()
|
||||
{
|
||||
m_tickTimer->start();
|
||||
m_bgvAppIsInitialized = true;
|
||||
|
||||
QWidget *w = nullptr;
|
||||
if (m_bgvApp)
|
||||
{
|
||||
LtsSession::LtsSession *session = m_bgvApp->getSession(pStartingSession->connParams().partitionType, pStartingSession->connParams().partitionId);
|
||||
w = session->baseLayoutWidget();
|
||||
DEBUG_LOG(m_logger) << std::hex << this << " Releasing m_bgvApp";
|
||||
delete m_bgvApp;
|
||||
m_bgvApp = nullptr;
|
||||
|
||||
clearInterfaces(m_currentDdsConnParams);
|
||||
m_comIfc->excCloseAllViews();
|
||||
}
|
||||
m_bgViewerBaseLayoutWidget = w;
|
||||
|
||||
slotLoadBuilding();
|
||||
emit bgvAppIsInitialized();
|
||||
});
|
||||
|
||||
connect(m_bgvApp, &LtsPluginManager::LtsPluginManager::destroyed,
|
||||
this, [this]()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << std::hex << this << " LtsPluginManager destroyed m_bgvApp";
|
||||
m_tickTimer->stop();
|
||||
clearInterfaces(m_currentDdsConnParams);
|
||||
m_comIfc->excCloseAllViews();
|
||||
m_bgvAppIsInitialized = false;
|
||||
m_bgvApp = nullptr;
|
||||
m_bgViewerBaseLayoutWidget = nullptr;
|
||||
});
|
||||
m_bgvApp = LtsAppManager::LtsAppManager::getInstance()->createApp(LtsAppDescriptor::App::BuildingViewer,
|
||||
pStartingSession->connParams());
|
||||
if (!m_bgvApp || !m_bgvApp->sessions().size())
|
||||
{
|
||||
ERROR_LOG(m_logger) << std::hex << this << " m_bgvApp is nullptr or has no associated session!";
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
connect(m_bgvApp, &LtsPluginManager::LtsPluginManager::signalInitializationFinished, this,
|
||||
[this, pStartingSession]() {
|
||||
m_tickTimer->start();
|
||||
m_bgvAppIsInitialized = true;
|
||||
|
||||
QWidget* w = nullptr;
|
||||
if (m_bgvApp)
|
||||
{
|
||||
LtsSession::LtsSession* session = m_bgvApp->getSession(pStartingSession->connParams().partitionType,
|
||||
pStartingSession->connParams().partitionId);
|
||||
w = session->baseLayoutWidget();
|
||||
}
|
||||
m_bgViewerBaseLayoutWidget = w;
|
||||
|
||||
slotLoadBuilding();
|
||||
emit bgvAppIsInitialized();
|
||||
});
|
||||
|
||||
connect(m_bgvApp, &LtsPluginManager::LtsPluginManager::destroyed, this, [this]() {
|
||||
DEBUG_LOG(m_logger) << std::hex << this << " LtsPluginManager destroyed m_bgvApp";
|
||||
m_tickTimer->stop();
|
||||
clearInterfaces(m_currentDdsConnParams);
|
||||
m_comIfc->excCloseAllViews();
|
||||
m_bgvAppIsInitialized = false;
|
||||
m_bgvApp = nullptr;
|
||||
m_bgViewerBaseLayoutWidget = nullptr;
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
QWidget *BgViewerController::getBgViewerWidget()
|
||||
QWidget* BgViewerController::getBgViewerWidget()
|
||||
{
|
||||
if (m_widgetStolen)
|
||||
{
|
||||
showBgViewerInfoMessageBox();
|
||||
return nullptr;
|
||||
}
|
||||
if (m_widgetStolen)
|
||||
{
|
||||
showBgViewerInfoMessageBox();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BgViewerWidgetContainer *pDummy = new BgViewerWidgetContainer(m_mainloop.getViewerInterface()->getMainWindow());
|
||||
BgViewerWidgetContainer* pDummy = new BgViewerWidgetContainer(m_mainloop.getViewerInterface()->getMainWindow());
|
||||
|
||||
m_widgetStolen = true;
|
||||
connect(pDummy, &BgViewerWidgetContainer::signalWidgetReleased, this, &BgViewerController::slotWidgetReleased);
|
||||
return pDummy;
|
||||
m_widgetStolen = true;
|
||||
connect(pDummy, &BgViewerWidgetContainer::signalWidgetReleased, this, &BgViewerController::slotWidgetReleased);
|
||||
return pDummy;
|
||||
}
|
||||
|
||||
void BgViewerController::slotWidgetReleased()
|
||||
{
|
||||
m_widgetStolen = false;
|
||||
m_widgetStolen = false;
|
||||
}
|
||||
|
||||
void BgViewerController::openBuilding(const QString &strBuildingFeatureId)
|
||||
void BgViewerController::openBuilding(const QString& strBuildingFeatureId)
|
||||
{
|
||||
m_buildingsToShow.push_back(strBuildingFeatureId.toStdString());
|
||||
slotLoadBuilding();
|
||||
m_buildingsToShow.push_back(strBuildingFeatureId.toStdString());
|
||||
slotLoadBuilding();
|
||||
}
|
||||
|
||||
void BgViewerController::closeBuilding(const QString &strBuildingFeatureId)
|
||||
void BgViewerController::closeBuilding(const QString& strBuildingFeatureId)
|
||||
{
|
||||
if (!strBuildingFeatureId.isEmpty())
|
||||
{
|
||||
const std::string s = strBuildingFeatureId.toStdString();
|
||||
m_buildingsToShow.erase(std::remove_if(m_buildingsToShow.begin(), m_buildingsToShow.end(),
|
||||
[s](const std::string &str) { return s == str;}), m_buildingsToShow.end());
|
||||
}
|
||||
else
|
||||
m_buildingsToShow.clear();
|
||||
|
||||
if (m_comIfc)
|
||||
{
|
||||
if (strBuildingFeatureId.isEmpty())
|
||||
m_comIfc->excCloseAllViews();
|
||||
if (!strBuildingFeatureId.isEmpty())
|
||||
{
|
||||
const std::string s = strBuildingFeatureId.toStdString();
|
||||
m_buildingsToShow.erase(std::remove_if(m_buildingsToShow.begin(), m_buildingsToShow.end(),
|
||||
[s](const std::string& str) { return s == str; }),
|
||||
m_buildingsToShow.end());
|
||||
}
|
||||
else
|
||||
m_comIfc->excCloseView({strBuildingFeatureId.toStdString()});
|
||||
m_comIfc->excGetBuildingList();
|
||||
}
|
||||
m_buildingsToShow.clear();
|
||||
|
||||
if (m_comIfc)
|
||||
{
|
||||
if (strBuildingFeatureId.isEmpty())
|
||||
m_comIfc->excCloseAllViews();
|
||||
else
|
||||
m_comIfc->excCloseView({strBuildingFeatureId.toStdString()});
|
||||
m_comIfc->excGetBuildingList();
|
||||
}
|
||||
}
|
||||
|
||||
void BgViewerController::updatePlayerSymbols(int size)
|
||||
{
|
||||
m_pBgViewerDDSController->updatePlayerSymbols(size);
|
||||
m_pBgViewerDDSController->updatePlayerSymbols(size);
|
||||
}
|
||||
|
||||
void BgViewerController::closeAll()
|
||||
{
|
||||
m_bgvApp->deleteLater();
|
||||
m_bgvApp->deleteLater();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void BgViewerController::slotLoadBuilding()
|
||||
{
|
||||
if (!m_bgvAppIsInitialized)
|
||||
return;
|
||||
m_comIfc->excOpenView(m_buildingsToShow);
|
||||
m_comIfc->excGetBuildingList();
|
||||
m_buildingsToShow.clear();
|
||||
if (!m_bgvAppIsInitialized)
|
||||
return;
|
||||
m_comIfc->excOpenView(m_buildingsToShow);
|
||||
m_comIfc->excGetBuildingList();
|
||||
m_buildingsToShow.clear();
|
||||
}
|
||||
|
||||
void BgViewerController::slotStartRecording(const QString &strFolderPath, const QJsonValue &state)
|
||||
void BgViewerController::slotStartRecording(const QString& strFolderPath, const QJsonValue& state)
|
||||
{
|
||||
excRestoreViewState(state);
|
||||
excStartRecording(strFolderPath, QStringLiteral("all"), 800, 600, 15, 40);
|
||||
excRestoreViewState(state);
|
||||
excStartRecording(strFolderPath, QStringLiteral("all"), 800, 600, 15, 40);
|
||||
}
|
||||
|
||||
void BgViewerController::slotStopRecording()
|
||||
{
|
||||
excStopRecording();
|
||||
excStopRecording();
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace BuildingViewer
|
||||
Executable → Regular
+83
-89
@@ -1,30 +1,27 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <QObject>
|
||||
#include <QTimer>
|
||||
#include <QString>
|
||||
|
||||
#include "buildingviewercommon_export.h"
|
||||
#include <BuildingViewer/share/exccommands.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsSession/lts_session_data_dds.h>
|
||||
#include <memory>
|
||||
#include "logger.h"
|
||||
#include "bdv_helper.h"
|
||||
#include "BgViewer/viewerCtrl/mainloop.h"
|
||||
#include "bdv_helper.h"
|
||||
#include "buildingviewercommon_export.h"
|
||||
#include "logger.h"
|
||||
|
||||
#include <BuildingViewer/share/exccommands.h>
|
||||
#include <LtsSession/lts_session_data_dds.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QTimer>
|
||||
#include <memory>
|
||||
|
||||
class QWidget;
|
||||
|
||||
namespace LtsPluginManager
|
||||
{
|
||||
class LtsPluginManager;
|
||||
}
|
||||
|
||||
|
||||
|
||||
namespace BuildingViewer
|
||||
{
|
||||
class CommunicationInterfaceInternal;
|
||||
@@ -33,96 +30,93 @@ class PluginProvider;
|
||||
|
||||
class BUILDINGVIEWERCOMMON_EXPORT BgViewerController : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit BgViewerController(QObject *parent = nullptr);
|
||||
~BgViewerController();
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit BgViewerController(QObject* parent = nullptr);
|
||||
~BgViewerController();
|
||||
|
||||
void clearInterfaces(const LtsSession::DdsConnectionParams &conParams);
|
||||
void clearInterfaces(const LtsSession::DdsConnectionParams& conParams);
|
||||
|
||||
bool isBgViewerApplicationRunning() const;
|
||||
LtsSession::DdsConnectionParams currentDdsConnParams() const;
|
||||
bool isBgViewerApplicationRunning() const;
|
||||
LtsSession::DdsConnectionParams currentDdsConnParams() const;
|
||||
|
||||
bool startBgViewerAppInSession(PluginProvider *pStartingSession);
|
||||
void openBuilding(const QString &strBuildingFeatureId);
|
||||
void closeBuilding(const QString &strBuildingFeatureId = QString());
|
||||
bool forceInit(PluginProvider *pSession);
|
||||
void updatePlayerSymbols(int size);
|
||||
void closeAll();
|
||||
|
||||
QWidget *getBgViewerWidget();
|
||||
bool init(PluginProvider *pSession, bool bStartRendering = false, const QString &modelPath = buildingModelPath());
|
||||
PluginProvider *activeSession() const;
|
||||
bool startBgViewerAppInSession(PluginProvider* pStartingSession);
|
||||
void openBuilding(const QString& strBuildingFeatureId);
|
||||
void closeBuilding(const QString& strBuildingFeatureId = QString());
|
||||
bool forceInit(PluginProvider* pSession);
|
||||
void updatePlayerSymbols(int size);
|
||||
void closeAll();
|
||||
|
||||
|
||||
void excConnect(const std::vector<std::string> &paths, const QString &strXMLFile = QString());
|
||||
void excGetBuildingList();
|
||||
void excGetViewState();
|
||||
void excHighlightView(const QString &strFeatureID);
|
||||
void excRestoreViewState(const QJsonValue &state);
|
||||
void excSetGlobalDotsMode(bool useDots);
|
||||
void excSetGlobalTransparency(double transparency);
|
||||
void excSetGlobalViewMode(bool useOrtho);
|
||||
void excSetHitlineDuration(uint32_t duration_s);
|
||||
void excStartRecording(const QString &strPathOutputFolder,
|
||||
const QString &strFeatureID = QStringLiteral("all"),
|
||||
int w = 800, int h = 600,
|
||||
int framerate = 20, int quality = 100);
|
||||
void excStopRecording(const QString &strFeatureID = QStringLiteral("all"));
|
||||
QWidget* getBgViewerWidget();
|
||||
bool init(PluginProvider* pSession, bool bStartRendering = false, const QString& modelPath = buildingModelPath());
|
||||
PluginProvider* activeSession() const;
|
||||
|
||||
static QString buildingModelPath();
|
||||
void excConnect(const std::vector<std::string>& paths, const QString& strXMLFile = QString());
|
||||
void excGetBuildingList();
|
||||
void excGetViewState();
|
||||
void excHighlightView(const QString& strFeatureID);
|
||||
void excRestoreViewState(const QJsonValue& state);
|
||||
void excSetGlobalDotsMode(bool useDots);
|
||||
void excSetGlobalTransparency(double transparency);
|
||||
void excSetGlobalViewMode(bool useOrtho);
|
||||
void excSetHitlineDuration(uint32_t duration_s);
|
||||
void excStartRecording(const QString& strPathOutputFolder, const QString& strFeatureID = QStringLiteral("all"),
|
||||
int w = 800, int h = 600, int framerate = 20, int quality = 100);
|
||||
void excStopRecording(const QString& strFeatureID = QStringLiteral("all"));
|
||||
|
||||
LtsPluginManager::LtsPluginManager *app() { return m_bgvApp; }
|
||||
static QString buildingModelPath();
|
||||
|
||||
Q_SIGNALS:
|
||||
void bgvAppIsInitialized();
|
||||
LtsPluginManager::LtsPluginManager* app()
|
||||
{
|
||||
return m_bgvApp;
|
||||
}
|
||||
|
||||
|
||||
void signalBgViewerInitFinished();
|
||||
void signalReceivedBuildingList(const QVector<BuildingTuple> &list);
|
||||
void signalReceivedViewState(const QJsonValue &state);
|
||||
Q_SIGNALS:
|
||||
void bgvAppIsInitialized();
|
||||
|
||||
void signalViewerEventButton();
|
||||
void signalPlayerPicked(int playerId);
|
||||
void signalAssetPicked(int structureElementId);
|
||||
void signalViewerEventWidgetClosed(const QString &featureID);
|
||||
void signalViewerEventWidgetMaximized(const QString &featureID);
|
||||
void signalViewerEventWidgetMinimized(const QString &featureID);
|
||||
void signalViewerEventWidgetFocused(const QString &featureID);
|
||||
void signalViewerEventRoomNameClicked(const QString &featureID, const QString &roomID);
|
||||
void signalViewerZoomChanged(const QString &featureId, double top, double left, double bottom, double right);
|
||||
void signalBgViewerInitFinished();
|
||||
void signalReceivedBuildingList(const QVector<BuildingTuple>& list);
|
||||
void signalReceivedViewState(const QJsonValue& state);
|
||||
|
||||
public slots:
|
||||
void slotStartRecording(const QString &strFolderPath, const QJsonValue &state);
|
||||
void slotStopRecording();
|
||||
void hideLiveVideo();
|
||||
void signalViewerEventButton();
|
||||
void signalPlayerPicked(int playerId);
|
||||
void signalAssetPicked(int structureElementId);
|
||||
void signalViewerEventWidgetClosed(const QString& featureID);
|
||||
void signalViewerEventWidgetMaximized(const QString& featureID);
|
||||
void signalViewerEventWidgetMinimized(const QString& featureID);
|
||||
void signalViewerEventWidgetFocused(const QString& featureID);
|
||||
void signalViewerEventRoomNameClicked(const QString& featureID, const QString& roomID);
|
||||
void signalViewerZoomChanged(const QString& featureId, double top, double left, double bottom, double right);
|
||||
|
||||
private slots:
|
||||
void slotLoadBuilding();
|
||||
void slotWidgetReleased();
|
||||
public slots:
|
||||
void slotStartRecording(const QString& strFolderPath, const QJsonValue& state);
|
||||
void slotStopRecording();
|
||||
void hideLiveVideo();
|
||||
|
||||
private:
|
||||
private slots:
|
||||
void slotLoadBuilding();
|
||||
void slotWidgetReleased();
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
void showBgViewerInfoMessageBox();
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
void showBgViewerInfoMessageBox();
|
||||
|
||||
private:
|
||||
VCtrl::MainLoop m_mainloop;
|
||||
bool m_widgetStolen;
|
||||
private:
|
||||
VCtrl::MainLoop m_mainloop;
|
||||
bool m_widgetStolen;
|
||||
|
||||
std::vector<std::string> m_buildingsToShow;
|
||||
CommunicationInterfaceInternal *m_comIfc{nullptr};
|
||||
VCtrl::ViewerInterface *m_viewerInterface{nullptr};
|
||||
BuildingViewerDdsController *m_pBgViewerDDSController;
|
||||
std::vector<std::string> m_buildingsToShow;
|
||||
CommunicationInterfaceInternal* m_comIfc{nullptr};
|
||||
VCtrl::ViewerInterface* m_viewerInterface{nullptr};
|
||||
BuildingViewerDdsController* m_pBgViewerDDSController;
|
||||
|
||||
bool m_initExerciseWasSuccessful{false};
|
||||
LtsSession::DdsConnectionParams m_currentDdsConnParams;
|
||||
LtsPluginManager::LtsPluginManager *m_bgvApp;
|
||||
bool m_initExerciseWasSuccessful{false};
|
||||
LtsSession::DdsConnectionParams m_currentDdsConnParams;
|
||||
LtsPluginManager::LtsPluginManager* m_bgvApp;
|
||||
|
||||
bool m_bgvAppIsInitialized{false};
|
||||
bool m_bgvAppIsInitialized{false};
|
||||
|
||||
QTimer *m_tickTimer{nullptr};
|
||||
QWidget *m_bgViewerBaseLayoutWidget{nullptr};
|
||||
QTimer* m_tickTimer{nullptr};
|
||||
QWidget* m_bgViewerBaseLayoutWidget{nullptr};
|
||||
};
|
||||
}
|
||||
|
||||
} // namespace BuildingViewer
|
||||
Executable → Regular
+1282
-1363
File diff suppressed because it is too large.
Load diff
Executable → Regular
+146
-139
@@ -1,34 +1,30 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
#include <NGLLogger/INGLLogger.h>
|
||||
#include "buildingviewercommon_export.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QTimer>
|
||||
#include <QHash>
|
||||
#include <QVector>
|
||||
|
||||
#include <PluginInterfaces/gui_plugin_interface.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 <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/SituationReplay/srp_data_plugin_interface.h>
|
||||
#include <Plugins/Buildings/bld_info_gui_plugin_interface.h>
|
||||
#include <ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
|
||||
#include <ParticipantManagement/ppm_participant_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 <LtsCoordTrans/lts_coord_trans.h>
|
||||
#include <LtsUtilsCore/qpoint3d.h>
|
||||
#include "buildingviewercommon_export.h"
|
||||
#include <BuildingViewer/share/exccommands.h>
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
#include <viewerinterface.h>
|
||||
|
||||
#include <QHash>
|
||||
#include <QObject>
|
||||
#include <QTimer>
|
||||
#include <QVector>
|
||||
#include <functional>
|
||||
#include <viewerinterface.h>
|
||||
|
||||
namespace BuildingViewer
|
||||
{
|
||||
@@ -37,141 +33,152 @@ class PluginProvider;
|
||||
|
||||
class BuildingViewerDdsController : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit BuildingViewerDdsController(CommunicationInterfaceInternal *connection,
|
||||
VCtrl::ViewerInterface* viewerInterface);
|
||||
~BuildingViewerDdsController();
|
||||
bool init(QWidget *irreplacableWidget, const QString &modelPath, PluginProvider *session);
|
||||
void uninitialize();
|
||||
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 updatePlayerSymbols(const int sizeL, const int forParty = -1);
|
||||
|
||||
void clearAssets();
|
||||
PluginProvider *activeSession() const { return m_session; }
|
||||
void clearAssets();
|
||||
|
||||
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);
|
||||
PluginProvider* activeSession() const
|
||||
{
|
||||
return m_session;
|
||||
}
|
||||
|
||||
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);
|
||||
signals:
|
||||
void signalDdsInitFinished();
|
||||
|
||||
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());
|
||||
}
|
||||
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);
|
||||
|
||||
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 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);
|
||||
|
||||
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;
|
||||
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;
|
||||
|
||||
static QString buildPlayerSymbolFilePath(int playerID, int postfix = 0);
|
||||
inline bool isOutdatedPosition(const ParticipantManagement::ParticipantPosition& position) const
|
||||
{
|
||||
return position.participantId() <= 0 || isOutdatedPosition(position.sampleTime());
|
||||
}
|
||||
|
||||
struct SymbolInfo
|
||||
{
|
||||
QString strPathToSymbolFile;
|
||||
QColor color;
|
||||
int participantId = -1;
|
||||
bool useThisSymbolNow = false;
|
||||
};
|
||||
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;
|
||||
|
||||
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();
|
||||
}
|
||||
static QString buildPlayerSymbolFilePath(int playerID, int postfix = 0);
|
||||
|
||||
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;
|
||||
struct SymbolInfo
|
||||
{
|
||||
QString strPathToSymbolFile;
|
||||
QColor color;
|
||||
int participantId = -1;
|
||||
bool useThisSymbolNow = false;
|
||||
};
|
||||
|
||||
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;
|
||||
|
||||
QHash<int, qint64> m_participantGearEvents;
|
||||
QHash<int, qint64> m_lastPositionTime;
|
||||
|
||||
int m_bgviewer_simSyncTimeInterval_ms = 3000;
|
||||
struct BuildingHit
|
||||
{
|
||||
int32_t id = 0;
|
||||
int64_t sampleTime = 0;
|
||||
int originatorParticipantId = 0;
|
||||
int chargeTypeId = 0;
|
||||
};
|
||||
|
||||
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};
|
||||
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
|
||||
Executable → Regular
+184
-218
@@ -1,338 +1,304 @@
|
||||
|
||||
|
||||
|
||||
#include "bdv_building_edit.h"
|
||||
|
||||
#include "bdv_edit_item.h"
|
||||
#include "ui_bdv_building_edit.h"
|
||||
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <LtsUtilsSettings/settings.h>
|
||||
|
||||
#include <Buildings/bld_operator_rights.h>
|
||||
#include <Buildings/bld.hpp>
|
||||
#include <Buildings/bld_ftc.h>
|
||||
|
||||
#include <Buildings/bld_operator_rights.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <LtsUtilsSettings/settings.h>
|
||||
#include <nglwidgets/ngltreeitem.h>
|
||||
|
||||
namespace BuildingViewer
|
||||
{
|
||||
BuildingEdit::BuildingEdit(QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_ui(new Ui::BuildingEdit)
|
||||
BuildingEdit::BuildingEdit(QWidget* parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel),
|
||||
m_requestHelper(new LtsUtils::RequestHelper(this)), m_ui(new Ui::BuildingEdit)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_ui->setupUi(this);
|
||||
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Ok)->hide();
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &BuildingEdit::slotEditItem);
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Ok)->hide();
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &BuildingEdit::slotEditItem);
|
||||
|
||||
bool userHasRightsToEdit = LtsSessionData::LtsSessionData::getInstance()->hasOperatorRight(OperatorRights::BuildingViewerSettingsEdit);
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Edit)->setVisible(userHasRightsToEdit);
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Apply)->setVisible(userHasRightsToEdit);
|
||||
bool userHasRightsToEdit =
|
||||
LtsSessionData::LtsSessionData::getInstance()->hasOperatorRight(OperatorRights::BuildingViewerSettingsEdit);
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Edit)->setVisible(userHasRightsToEdit);
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Apply)->setVisible(userHasRightsToEdit);
|
||||
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Edit)->setEnabled(false);
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Edit)->setEnabled(false);
|
||||
|
||||
LtsUtils::ProjectSettings *ps = LtsUtils::ProjectSettings::getInstance();
|
||||
const bool enableGuiDestroyRooms = ps->value(QStringLiteral("bld"),
|
||||
QStringLiteral("enableGuiDestroyRooms")).toBool();
|
||||
|
||||
auto btnDestroy = m_buttonBox->getButton(LtsWidgets::DialogButton::Add);
|
||||
btnDestroy->setText(tr("Destroy"));
|
||||
btnDestroy->setVisible(enableGuiDestroyRooms);
|
||||
LtsUtils::ProjectSettings* ps = LtsUtils::ProjectSettings::getInstance();
|
||||
const bool enableGuiDestroyRooms =
|
||||
ps->value(QStringLiteral("bld"), QStringLiteral("enableGuiDestroyRooms")).toBool();
|
||||
|
||||
connect(btnDestroy, &QPushButton::pressed, this, &BuildingEdit::onDestroyElement);
|
||||
auto btnDestroy = m_buttonBox->getButton(LtsWidgets::DialogButton::Add);
|
||||
btnDestroy->setText(tr("Destroy"));
|
||||
btnDestroy->setVisible(enableGuiDestroyRooms);
|
||||
|
||||
connect(btnDestroy, &QPushButton::pressed, this, &BuildingEdit::onDestroyElement);
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Building_Viewer-Building_List"));
|
||||
setOnlineHelpFilename(QStringLiteral("Building_Viewer-Building_List"));
|
||||
}
|
||||
|
||||
|
||||
BuildingEdit::~BuildingEdit()
|
||||
{
|
||||
delete m_ui;
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
|
||||
void BuildingEdit::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("Building Edit: %1").arg(m_buildingName));
|
||||
translate(m_ui, tr("Building Edit: %1").arg(m_buildingName));
|
||||
}
|
||||
|
||||
|
||||
bool BuildingEdit::init(int32_t buildingDatabaseId,
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc> &ismDtc,
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Ftc> &ismFtc,
|
||||
const std::shared_ptr<Buildings::Interface::Dtc> &bldDtc,
|
||||
const std::shared_ptr<Buildings::Interface::Ftc> &bldFtc)
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc>& ismDtc,
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Ftc>& ismFtc,
|
||||
const std::shared_ptr<Buildings::Interface::Dtc>& bldDtc,
|
||||
const std::shared_ptr<Buildings::Interface::Ftc>& bldFtc)
|
||||
{
|
||||
if (m_ismDtc)
|
||||
return false;
|
||||
m_buildingDatabaseId = buildingDatabaseId;
|
||||
if (m_ismDtc)
|
||||
return false;
|
||||
m_buildingDatabaseId = buildingDatabaseId;
|
||||
|
||||
m_ismDtc = ismDtc;
|
||||
m_ismFtc = ismFtc;
|
||||
m_bldDtc = bldDtc;
|
||||
m_bldFtc = bldFtc;
|
||||
m_ismDtc = ismDtc;
|
||||
m_ismFtc = ismFtc;
|
||||
m_bldDtc = bldDtc;
|
||||
m_bldFtc = bldFtc;
|
||||
|
||||
|
||||
InfrastructureManagement::MainStructureElement building = m_ismDtc->mainStructureElement(m_buildingDatabaseId);
|
||||
m_buildingId = building.id();
|
||||
InfrastructureManagement::MainStructureElement building = m_ismDtc->mainStructureElement(m_buildingDatabaseId);
|
||||
m_buildingId = building.id();
|
||||
|
||||
buildModel();
|
||||
m_buildingName = m_model->getBuildingName();
|
||||
buildModel();
|
||||
m_buildingName = m_model->getBuildingName();
|
||||
|
||||
if (LtsSessionData::LtsSessionData::getInstance()->hasOperatorRight(OperatorRights::BuildingViewerSettingsEdit))
|
||||
{
|
||||
connect(m_ui->treeViewEdit, &QTreeView::clicked, this, &BuildingEdit::slotTreeViewClicked);
|
||||
connect(m_ui->treeViewEdit, &QTreeView::doubleClicked, this, &BuildingEdit::slotDoubleClicked);
|
||||
connect(m_model, &BuildingEditModel::signalModelDataChanged, this, &BuildingEdit::slotChangesMade);
|
||||
}
|
||||
if (LtsSessionData::LtsSessionData::getInstance()->hasOperatorRight(OperatorRights::BuildingViewerSettingsEdit))
|
||||
{
|
||||
connect(m_ui->treeViewEdit, &QTreeView::clicked, this, &BuildingEdit::slotTreeViewClicked);
|
||||
connect(m_ui->treeViewEdit, &QTreeView::doubleClicked, this, &BuildingEdit::slotDoubleClicked);
|
||||
connect(m_model, &BuildingEditModel::signalModelDataChanged, this, &BuildingEdit::slotChangesMade);
|
||||
}
|
||||
|
||||
connect(m_ismDtc.get(), &InfrastructureManagement::Interface::Dtc::mainStructureElementChanged,
|
||||
this, &BuildingEdit::slotMainStructureElementChanged);
|
||||
connect(m_ismDtc.get(), &InfrastructureManagement::Interface::Dtc::mainStructureElementChanged, this,
|
||||
&BuildingEdit::slotMainStructureElementChanged);
|
||||
|
||||
connect(m_bldDtc.get(), &Buildings::Interface::Dtc::buildingStateChanged,
|
||||
this, &BuildingEdit::slotBuildingStateChanged);
|
||||
connect(m_bldDtc.get(), &Buildings::Interface::Dtc::buildingStateChanged, this,
|
||||
&BuildingEdit::slotBuildingStateChanged);
|
||||
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void BuildingEdit::slotTreeViewClicked()
|
||||
{
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Edit)->setEnabled(selectedIndexView().isValid());
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Edit)->setEnabled(selectedIndexView().isValid());
|
||||
}
|
||||
|
||||
|
||||
void BuildingEdit::buildModel()
|
||||
{
|
||||
m_model = new BuildingEditModel(this, m_ismDtc, m_bldDtc);
|
||||
m_model = new BuildingEditModel(this, m_ismDtc, m_bldDtc);
|
||||
|
||||
|
||||
m_proxyModel = new BuildingEditProxyModel(this);
|
||||
m_proxyModel->setSourceModel(m_model);
|
||||
m_proxyModel = new BuildingEditProxyModel(this);
|
||||
m_proxyModel->setSourceModel(m_model);
|
||||
|
||||
|
||||
m_ui->treeViewEdit->setModel(m_proxyModel);
|
||||
m_ui->treeViewEdit->expandAll();
|
||||
m_ui->treeViewEdit->sortByColumn(BuildingEditModel::Building, Qt::AscendingOrder);
|
||||
m_ui->treeViewEdit->setModel(m_proxyModel);
|
||||
m_ui->treeViewEdit->expandAll();
|
||||
m_ui->treeViewEdit->sortByColumn(BuildingEditModel::Building, Qt::AscendingOrder);
|
||||
|
||||
|
||||
m_ui->treeViewEdit->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
m_ui->treeViewEdit->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
|
||||
m_model->init(m_buildingDatabaseId);
|
||||
m_ui->treeViewEdit->expandAll();
|
||||
m_ui->treeViewEdit->setColumnWidth(BuildingEditModel::Building, 230);
|
||||
m_model->init(m_buildingDatabaseId);
|
||||
m_ui->treeViewEdit->expandAll();
|
||||
m_ui->treeViewEdit->setColumnWidth(BuildingEditModel::Building, 230);
|
||||
#ifdef LTS_DEBUG
|
||||
m_ui->treeViewEdit->setColumnWidth(BuildingEditModel::Name, 150);
|
||||
m_ui->treeViewEdit->setColumnWidth(BuildingEditModel::MountingPointId, 120);
|
||||
m_ui->treeViewEdit->setColumnWidth(BuildingEditModel::StructureElementId, 80);
|
||||
m_ui->treeViewEdit->setColumnWidth(BuildingEditModel::Name, 150);
|
||||
m_ui->treeViewEdit->setColumnWidth(BuildingEditModel::MountingPointId, 120);
|
||||
m_ui->treeViewEdit->setColumnWidth(BuildingEditModel::StructureElementId, 80);
|
||||
#else
|
||||
m_ui->treeViewEdit->hideColumn(BuildingEditModel::Name);
|
||||
m_ui->treeViewEdit->hideColumn(BuildingEditModel::MountingPointId);
|
||||
m_ui->treeViewEdit->hideColumn(BuildingEditModel::StructureElementId);
|
||||
m_ui->treeViewEdit->hideColumn(BuildingEditModel::Name);
|
||||
m_ui->treeViewEdit->hideColumn(BuildingEditModel::MountingPointId);
|
||||
m_ui->treeViewEdit->hideColumn(BuildingEditModel::StructureElementId);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
QModelIndex BuildingEdit::selectedIndexView() const
|
||||
{
|
||||
QItemSelectionModel *selectionModel = m_ui->treeViewEdit->selectionModel();
|
||||
QModelIndexList indexL = selectionModel->selectedRows(0);
|
||||
if (indexL.size() == 0)
|
||||
return QModelIndex();
|
||||
QItemSelectionModel* selectionModel = m_ui->treeViewEdit->selectionModel();
|
||||
QModelIndexList indexL = selectionModel->selectedRows(0);
|
||||
if (indexL.size() == 0)
|
||||
return QModelIndex();
|
||||
|
||||
return m_proxyModel->mapToSource(indexL.at(0));
|
||||
return m_proxyModel->mapToSource(indexL.at(0));
|
||||
}
|
||||
|
||||
|
||||
void BuildingEdit::slotEditItem()
|
||||
{
|
||||
QModelIndex selIndex = selectedIndexView();
|
||||
if (!selIndex.isValid())
|
||||
return;
|
||||
QModelIndex selIndex = selectedIndexView();
|
||||
if (!selIndex.isValid())
|
||||
return;
|
||||
|
||||
BuildingViewer::TreeItem data = m_model->privateData(selIndex)->data().value<TreeItem>();
|
||||
BuildingViewer::TreeItem data = m_model->privateData(selIndex)->data().value<TreeItem>();
|
||||
|
||||
ParticipantEditItemWidget *newItemDlg = new ParticipantEditItemWidget(m_buildingName, data, this);
|
||||
newItemDlg->setAttribute(Qt::WA_DeleteOnClose);
|
||||
ParticipantEditItemWidget* newItemDlg = new ParticipantEditItemWidget(m_buildingName, data, this);
|
||||
newItemDlg->setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
connect(newItemDlg, &ParticipantEditItemWidget::signalItemUpdated,
|
||||
m_model, &BuildingEditModel::slotUpdateRow);
|
||||
connect(newItemDlg, &ParticipantEditItemWidget::signalItemUpdated, m_model, &BuildingEditModel::slotUpdateRow);
|
||||
|
||||
newItemDlg->show();
|
||||
newItemDlg->show();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool BuildingEdit::apply()
|
||||
{
|
||||
|
||||
|
||||
const auto fortifyFactors = m_model->getRoomsWithChangedFortifyFactors();
|
||||
|
||||
const auto fortifyFactors = m_model->getRoomsWithChangedFortifyFactors();
|
||||
|
||||
|
||||
DEBUG_LOG(m_logger) << "fortifyFactors.size()=" << fortifyFactors.size();
|
||||
if (fortifyFactors.size())
|
||||
{
|
||||
m_requestHelper->addRequest([this, fortifyFactors]()
|
||||
DEBUG_LOG(m_logger) << "fortifyFactors.size()=" << fortifyFactors.size();
|
||||
if (fortifyFactors.size())
|
||||
{
|
||||
Buildings::SetFortifyFactorRequest fortifyRequest;
|
||||
fortifyRequest.buildingId(m_buildingDatabaseId);
|
||||
m_requestHelper->addRequest([this, fortifyFactors]() {
|
||||
Buildings::SetFortifyFactorRequest fortifyRequest;
|
||||
fortifyRequest.buildingId(m_buildingDatabaseId);
|
||||
|
||||
|
||||
fortifyRequest.fortifyFactors().reserve(fortifyFactors.size());
|
||||
for (const auto &e : fortifyFactors)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "push_back= databaseId=" << e.structureElementId()
|
||||
<< " fortifyFactor=" << e.fortifyFactor();
|
||||
fortifyRequest.fortifyFactors().push_back(Buildings::FortifyFactor(e.structureElementId(), e.fortifyFactor()));
|
||||
}
|
||||
fortifyRequest.fortifyFactors().reserve(fortifyFactors.size());
|
||||
for (const auto& e : fortifyFactors)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "push_back= databaseId=" << e.structureElementId()
|
||||
<< " fortifyFactor=" << e.fortifyFactor();
|
||||
fortifyRequest.fortifyFactors().push_back(
|
||||
Buildings::FortifyFactor(e.structureElementId(), e.fortifyFactor()));
|
||||
}
|
||||
|
||||
return m_bldFtc->setFortifyFactorRequest(fortifyRequest, this);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
const auto displayNames = m_model->getRoomsWithChangedDisplayNames();
|
||||
|
||||
|
||||
|
||||
if (displayNames.size())
|
||||
{
|
||||
std::vector<InfrastructureManagement::StructureElement> vecModifiedRooms;
|
||||
vecModifiedRooms.reserve(displayNames.size());
|
||||
InfrastructureManagement::MainStructureElement building = m_ismDtc->mainStructureElement(m_buildingDatabaseId);
|
||||
|
||||
for (const auto &treeItem : displayNames)
|
||||
{
|
||||
|
||||
for (const auto &room : building.elements())
|
||||
{
|
||||
if (room.id() == treeItem.structureElementId())
|
||||
{
|
||||
auto copy = room;
|
||||
copy.displayName(treeItem.displayName().toStdString());
|
||||
vecModifiedRooms.push_back(copy);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return m_bldFtc->setFortifyFactorRequest(fortifyRequest, this);
|
||||
});
|
||||
}
|
||||
|
||||
m_requestHelper->addRequest([this, vecModifiedRooms]()
|
||||
{
|
||||
InfrastructureManagement::StructureElementModifyRequest request(m_buildingDatabaseId, vecModifiedRooms);
|
||||
return m_ismFtc->structureElementModifyRequest(request, this);
|
||||
});
|
||||
}
|
||||
return m_requestHelper->startRequests();
|
||||
}
|
||||
const auto displayNames = m_model->getRoomsWithChangedDisplayNames();
|
||||
|
||||
if (displayNames.size())
|
||||
{
|
||||
std::vector<InfrastructureManagement::StructureElement> vecModifiedRooms;
|
||||
vecModifiedRooms.reserve(displayNames.size());
|
||||
InfrastructureManagement::MainStructureElement building = m_ismDtc->mainStructureElement(m_buildingDatabaseId);
|
||||
|
||||
for (const auto& treeItem : displayNames)
|
||||
{
|
||||
|
||||
for (const auto& room : building.elements())
|
||||
{
|
||||
if (room.id() == treeItem.structureElementId())
|
||||
{
|
||||
auto copy = room;
|
||||
copy.displayName(treeItem.displayName().toStdString());
|
||||
vecModifiedRooms.push_back(copy);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_requestHelper->addRequest([this, vecModifiedRooms]() {
|
||||
InfrastructureManagement::StructureElementModifyRequest request(m_buildingDatabaseId, vecModifiedRooms);
|
||||
return m_ismFtc->structureElementModifyRequest(request, this);
|
||||
});
|
||||
}
|
||||
return m_requestHelper->startRequests();
|
||||
}
|
||||
|
||||
void BuildingEdit::selectRoomRow(int mountingPointId)
|
||||
{
|
||||
QModelIndex mIndex = m_model->modelIndexByStructureElementId(mountingPointId);
|
||||
m_ui->treeViewEdit->setCurrentIndex(mIndex);
|
||||
m_ui->treeViewEdit->selectionModel()->setCurrentIndex(mIndex, QItemSelectionModel::ClearAndSelect);
|
||||
QModelIndex mIndex = m_model->modelIndexByStructureElementId(mountingPointId);
|
||||
m_ui->treeViewEdit->setCurrentIndex(mIndex);
|
||||
m_ui->treeViewEdit->selectionModel()->setCurrentIndex(mIndex, QItemSelectionModel::ClearAndSelect);
|
||||
}
|
||||
|
||||
|
||||
void BuildingEdit::reinitModel()
|
||||
{
|
||||
m_model->init(m_buildingDatabaseId);
|
||||
m_ui->treeViewEdit->expandAll();
|
||||
m_model->init(m_buildingDatabaseId);
|
||||
m_ui->treeViewEdit->expandAll();
|
||||
}
|
||||
|
||||
|
||||
void BuildingEdit::slotDoubleClicked(const QModelIndex &selIndex)
|
||||
void BuildingEdit::slotDoubleClicked(const QModelIndex& selIndex)
|
||||
{
|
||||
if (!selIndex.isValid())
|
||||
return;
|
||||
if (!selIndex.isValid())
|
||||
return;
|
||||
|
||||
slotEditItem();
|
||||
slotEditItem();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void BuildingEdit::slotMainStructureElementChanged(const InfrastructureManagement::MainStructureElement &mse, DataModification modType)
|
||||
void BuildingEdit::slotMainStructureElementChanged(const InfrastructureManagement::MainStructureElement& mse,
|
||||
DataModification modType)
|
||||
{
|
||||
if(modType == DataModification::eRemoved)
|
||||
return;
|
||||
if (modType == DataModification::eRemoved)
|
||||
return;
|
||||
|
||||
if(mse.id() == m_buildingDatabaseId)
|
||||
{
|
||||
|
||||
slotHandleExternalDdsChange();
|
||||
}
|
||||
if (mse.id() == m_buildingDatabaseId)
|
||||
{
|
||||
|
||||
slotHandleExternalDdsChange();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void BuildingEdit::slotBuildingStateChanged(const Buildings::BuildingState &state, DataModification modType)
|
||||
void BuildingEdit::slotBuildingStateChanged(const Buildings::BuildingState& state, DataModification modType)
|
||||
{
|
||||
if(modType == DataModification::eRemoved)
|
||||
return;
|
||||
if (modType == DataModification::eRemoved)
|
||||
return;
|
||||
|
||||
if(state.id() == m_buildingDatabaseId)
|
||||
{
|
||||
|
||||
slotHandleExternalDdsChange();
|
||||
}
|
||||
if (state.id() == m_buildingDatabaseId)
|
||||
{
|
||||
|
||||
slotHandleExternalDdsChange();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void BuildingEdit::slotHandleExternalDdsChange()
|
||||
{
|
||||
reinitModel();
|
||||
reinitModel();
|
||||
}
|
||||
|
||||
bool BuildingEdit::sendBuildingStateRequest(ProjectDataManagement::VulnerabilityState state, std::vector<int32_t> structureElementIds)
|
||||
bool BuildingEdit::sendBuildingStateRequest(ProjectDataManagement::VulnerabilityState state,
|
||||
std::vector<int32_t> structureElementIds)
|
||||
{
|
||||
|
||||
m_requestHelper->addRequest([this, state, structureElementIds]()
|
||||
{
|
||||
Buildings::Building building;
|
||||
std::vector< Buildings::Building > buildings;
|
||||
buildings.resize(1);
|
||||
Buildings::SetBuildingStatesRequest requestData;
|
||||
|
||||
building.buildingId(m_buildingId);
|
||||
building.roomIds().set(structureElementIds);
|
||||
buildings[0] = building;
|
||||
requestData.buildings(buildings);
|
||||
requestData.vulnerabilityState(state);
|
||||
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << "currentData: " << state;
|
||||
m_requestHelper->addRequest([this, state, structureElementIds]() {
|
||||
Buildings::Building building;
|
||||
std::vector<Buildings::Building> buildings;
|
||||
buildings.resize(1);
|
||||
Buildings::SetBuildingStatesRequest requestData;
|
||||
|
||||
return m_bldFtc->setBuildingStatesRequest(requestData, this);
|
||||
});
|
||||
building.buildingId(m_buildingId);
|
||||
building.roomIds().set(structureElementIds);
|
||||
buildings[0] = building;
|
||||
requestData.buildings(buildings);
|
||||
requestData.vulnerabilityState(state);
|
||||
|
||||
return m_requestHelper->startRequests();
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << "currentData: " << state;
|
||||
|
||||
return m_bldFtc->setBuildingStatesRequest(requestData, this);
|
||||
});
|
||||
|
||||
return m_requestHelper->startRequests();
|
||||
}
|
||||
|
||||
void BuildingEdit::onDestroyElement()
|
||||
{
|
||||
QModelIndex selIndex = selectedIndexView();
|
||||
if (!selIndex.isValid())
|
||||
return;
|
||||
QModelIndex selIndex = selectedIndexView();
|
||||
if (!selIndex.isValid())
|
||||
return;
|
||||
|
||||
std::vector<int32_t> structureElementIds;
|
||||
getStructureElementIds(m_model->privateData(selIndex), structureElementIds);
|
||||
std::vector<int32_t> structureElementIds;
|
||||
getStructureElementIds(m_model->privateData(selIndex), structureElementIds);
|
||||
|
||||
sendBuildingStateRequest(ProjectDataManagement::VulnerabilityState_def::CatastrophicKill, structureElementIds);
|
||||
sendBuildingStateRequest(ProjectDataManagement::VulnerabilityState_def::CatastrophicKill, structureElementIds);
|
||||
}
|
||||
|
||||
void BuildingEdit::getStructureElementIds(NGLTreeItem *item, std::vector<int32_t> &structureElementIds)
|
||||
void BuildingEdit::getStructureElementIds(NGLTreeItem* item, std::vector<int32_t>& structureElementIds)
|
||||
{
|
||||
for (NGLTreeItem *child : item->children())
|
||||
getStructureElementIds(child, structureElementIds);
|
||||
for (NGLTreeItem* child : item->children())
|
||||
getStructureElementIds(child, structureElementIds);
|
||||
|
||||
BuildingViewer::TreeItem data = item->data().value<TreeItem>();
|
||||
if (data.isRoom())
|
||||
structureElementIds.push_back(data.structureElementId());
|
||||
BuildingViewer::TreeItem data = item->data().value<TreeItem>();
|
||||
if (data.isRoom())
|
||||
structureElementIds.push_back(data.structureElementId());
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace BuildingViewer
|
||||
Executable → Regular
+64
-56
@@ -1,19 +1,15 @@
|
||||
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "bdv_edit_model.h"
|
||||
|
||||
|
||||
#include <Common/logger.h>
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <Plugins/Buildings/bld_data_plugin_interface.h>
|
||||
#include <Plugins/InfrastructureManagement/ism_data_plugin_interface.h>
|
||||
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class BuildingEdit;
|
||||
@@ -21,68 +17,80 @@ class BuildingEdit;
|
||||
|
||||
namespace BuildingViewer
|
||||
{
|
||||
class BuildingEdit : public LtsWidgets::LtsDialog
|
||||
, protected Buildings::Interface::Ftc::SetFortifyFactorReplyHandler
|
||||
, protected Buildings::Interface::Ftc::SetBuildingStatesReplyHandler
|
||||
, protected InfrastructureManagement::Interface::Ftc::StructureElementModifyReplyHandler
|
||||
class BuildingEdit : public LtsWidgets::LtsDialog,
|
||||
protected Buildings::Interface::Ftc::SetFortifyFactorReplyHandler,
|
||||
protected Buildings::Interface::Ftc::SetBuildingStatesReplyHandler,
|
||||
protected InfrastructureManagement::Interface::Ftc::StructureElementModifyReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit BuildingEdit(QWidget *parent = nullptr);
|
||||
~BuildingEdit();
|
||||
public:
|
||||
explicit BuildingEdit(QWidget* parent = nullptr);
|
||||
~BuildingEdit();
|
||||
|
||||
bool init(int32_t buildingDatabaseId,
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc> &ismDtc,
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Ftc> &ismFtc,
|
||||
const std::shared_ptr<Buildings::Interface::Dtc> &bldDtc,
|
||||
const std::shared_ptr<Buildings::Interface::Ftc> &bldFtc);
|
||||
bool init(int32_t buildingDatabaseId, const std::shared_ptr<InfrastructureManagement::Interface::Dtc>& ismDtc,
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Ftc>& ismFtc,
|
||||
const std::shared_ptr<Buildings::Interface::Dtc>& bldDtc,
|
||||
const std::shared_ptr<Buildings::Interface::Ftc>& bldFtc);
|
||||
|
||||
void onSetFortifyFactorReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
|
||||
void onSetBuildingStatesReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
|
||||
void onStructureElementModifyReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
|
||||
void selectRoomRow(int mountingPointId);
|
||||
void onSetFortifyFactorReply(const Core::FunctionReplyObject& replyObject) override final
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
signals:
|
||||
void signalAccept();
|
||||
void onSetBuildingStatesReply(const Core::FunctionReplyObject& replyObject) override final
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
private slots:
|
||||
void slotEditItem();
|
||||
void slotDoubleClicked(const QModelIndex &selIndex);
|
||||
void slotMainStructureElementChanged(const InfrastructureManagement::MainStructureElement &mse, DataModification modType);
|
||||
void slotBuildingStateChanged(const Buildings::BuildingState &state, DataModification modType);
|
||||
void slotHandleExternalDdsChange();
|
||||
void slotTreeViewClicked();
|
||||
void onStructureElementModifyReply(const Core::FunctionReplyObject& replyObject) override final
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
bool sendBuildingStateRequest(ProjectDataManagement::VulnerabilityState state, std::vector<int32_t> structureElementId);
|
||||
void onDestroyElement();
|
||||
void selectRoomRow(int mountingPointId);
|
||||
|
||||
protected:
|
||||
signals:
|
||||
void signalAccept();
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
void retranslate() override;
|
||||
bool apply() override;
|
||||
private slots:
|
||||
void slotEditItem();
|
||||
void slotDoubleClicked(const QModelIndex& selIndex);
|
||||
void slotMainStructureElementChanged(const InfrastructureManagement::MainStructureElement& mse,
|
||||
DataModification modType);
|
||||
void slotBuildingStateChanged(const Buildings::BuildingState& state, DataModification modType);
|
||||
void slotHandleExternalDdsChange();
|
||||
void slotTreeViewClicked();
|
||||
|
||||
private:
|
||||
void getStructureElementIds(NGLTreeItem *item, std::vector<int32_t> &structureElementIds);
|
||||
void buildModel();
|
||||
QModelIndex selectedIndexView() const;
|
||||
void reinitModel();
|
||||
bool sendBuildingStateRequest(ProjectDataManagement::VulnerabilityState state,
|
||||
std::vector<int32_t> structureElementId);
|
||||
void onDestroyElement();
|
||||
|
||||
private:
|
||||
std::shared_ptr<InfrastructureManagement::Interface::Dtc> m_ismDtc;
|
||||
std::shared_ptr<InfrastructureManagement::Interface::Ftc> m_ismFtc;
|
||||
std::shared_ptr<Buildings::Interface::Dtc> m_bldDtc;
|
||||
std::shared_ptr<Buildings::Interface::Ftc> m_bldFtc;
|
||||
protected:
|
||||
NGL::INGLLogger& m_logger;
|
||||
void retranslate() override;
|
||||
bool apply() override;
|
||||
|
||||
BuildingEditModel *m_model = nullptr;
|
||||
BuildingEditProxyModel *m_proxyModel = nullptr;
|
||||
LtsUtils::RequestHelper *m_requestHelper = nullptr;
|
||||
Ui::BuildingEdit *m_ui = nullptr;
|
||||
private:
|
||||
void getStructureElementIds(NGLTreeItem* item, std::vector<int32_t>& structureElementIds);
|
||||
void buildModel();
|
||||
QModelIndex selectedIndexView() const;
|
||||
void reinitModel();
|
||||
|
||||
QString m_buildingName;
|
||||
int32_t m_buildingDatabaseId = 0;
|
||||
int32_t m_buildingId = 0;
|
||||
private:
|
||||
std::shared_ptr<InfrastructureManagement::Interface::Dtc> m_ismDtc;
|
||||
std::shared_ptr<InfrastructureManagement::Interface::Ftc> m_ismFtc;
|
||||
std::shared_ptr<Buildings::Interface::Dtc> m_bldDtc;
|
||||
std::shared_ptr<Buildings::Interface::Ftc> m_bldFtc;
|
||||
|
||||
BuildingEditModel* m_model = nullptr;
|
||||
BuildingEditProxyModel* m_proxyModel = nullptr;
|
||||
LtsUtils::RequestHelper* m_requestHelper = nullptr;
|
||||
Ui::BuildingEdit* m_ui = nullptr;
|
||||
|
||||
QString m_buildingName;
|
||||
int32_t m_buildingDatabaseId = 0;
|
||||
int32_t m_buildingId = 0;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace BuildingViewer
|
||||
Executable → Regular
+213
-242
@@ -1,297 +1,268 @@
|
||||
|
||||
|
||||
|
||||
#include "bdv_edit_model.h"
|
||||
#include <utility>
|
||||
#include <Common/logger.h>
|
||||
#include <Services/InfrastructureManagement/ism.hpp>
|
||||
#include <QtCore/QDebug>
|
||||
#include <QTableWidget>
|
||||
#include <QPalette>
|
||||
#include <QApplication>
|
||||
|
||||
#include <Common/logger.h>
|
||||
#include <QApplication>
|
||||
#include <QPalette>
|
||||
#include <QTableWidget>
|
||||
#include <QtCore/QDebug>
|
||||
#include <Services/InfrastructureManagement/ism.hpp>
|
||||
#include <nglwidgets/ngltreeitem.h>
|
||||
#include <utility>
|
||||
|
||||
namespace BuildingViewer
|
||||
{
|
||||
BuildingEditModel::BuildingEditModel(QObject *parent,
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc> &ismDtc,
|
||||
const std::shared_ptr<Buildings::Interface::Dtc> &bldDtc) : NGLTreeModel(parent, new NGLTreeItem(QVariant()),,
|
||||
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {
|
||||
tr("Selected Building"),
|
||||
QStringLiteral("Name (DEBUG)"),
|
||||
QStringLiteral("MountingPointId (DEBUG)"),
|
||||
QStringLiteral("StructureElementId (DEBUG)"),
|
||||
tr("Fortify Factor"),
|
||||
tr("Damage Percent")})
|
||||
, m_ismDtc(ismDtc)
|
||||
, m_bldDtc(bldDtc)
|
||||
, m_buildingName(QString())
|
||||
{}
|
||||
|
||||
QVariant BuildingEditModel::data(const QModelIndex &index, int role) const
|
||||
BuildingEditModel::BuildingEditModel(QObject* parent,
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc>& ismDtc,
|
||||
const std::shared_ptr<Buildings::Interface::Dtc>& bldDtc)
|
||||
: NGLTreeModel(parent, new NGLTreeItem(QVariant()), ,
|
||||
m_logger(NGL::NGLLoggerBootstrap::getLogger()){
|
||||
tr("Selected Building"), QStringLiteral("Name (DEBUG)"),
|
||||
QStringLiteral("MountingPointId (DEBUG)"), QStringLiteral("StructureElementId (DEBUG)"),
|
||||
tr("Fortify Factor"), tr("Damage Percent")}),
|
||||
m_ismDtc(ismDtc), m_bldDtc(bldDtc), m_buildingName(QString())
|
||||
{
|
||||
if (!index.isValid() || (role != Qt::BackgroundRole && role != Qt::DisplayRole))
|
||||
}
|
||||
|
||||
QVariant BuildingEditModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
if (!index.isValid() || (role != Qt::BackgroundRole && role != Qt::DisplayRole))
|
||||
return {};
|
||||
|
||||
NGLTreeItem* pNGLTreeItem = privateData(index);
|
||||
|
||||
if (pNGLTreeItem->data().canConvert<BuildingViewer::TreeItem>())
|
||||
{
|
||||
BuildingViewer::TreeItem item = pNGLTreeItem->data().value<BuildingViewer::TreeItem>();
|
||||
|
||||
if (role == Qt::BackgroundRole)
|
||||
{
|
||||
if (item.hasDisplayNameChanged() || item.hasFortifyFactorChanged())
|
||||
return QGuiApplication::palette().color(QPalette::Highlight);
|
||||
}
|
||||
else if (role == Qt::DisplayRole)
|
||||
{
|
||||
switch (index.column())
|
||||
{
|
||||
case BuildingEditModel::Building:
|
||||
return item.displayName();
|
||||
case BuildingEditModel::Name:
|
||||
return item.name();
|
||||
case BuildingEditModel::MountingPointId:
|
||||
if (item.hasMountingPointId())
|
||||
return item.mountingPointId();
|
||||
break;
|
||||
case BuildingEditModel::StructureElementId:
|
||||
return item.structureElementId();
|
||||
case BuildingEditModel::FortifyFactor:
|
||||
if (item.isRoom())
|
||||
return QString::number(item.fortifyFactor(), 'f', 1);
|
||||
break;
|
||||
case BuildingEditModel::DamagePercent:
|
||||
if (item.isRoom())
|
||||
return QString::number(item.damagePercent());
|
||||
}
|
||||
}
|
||||
}
|
||||
return {};
|
||||
|
||||
|
||||
NGLTreeItem *pNGLTreeItem = privateData(index);
|
||||
|
||||
if (pNGLTreeItem->data().canConvert<BuildingViewer::TreeItem>())
|
||||
{
|
||||
BuildingViewer::TreeItem item = pNGLTreeItem->data().value<BuildingViewer::TreeItem>();
|
||||
|
||||
if (role == Qt::BackgroundRole)
|
||||
{
|
||||
if (item.hasDisplayNameChanged() || item.hasFortifyFactorChanged())
|
||||
return QGuiApplication::palette().color(QPalette::Highlight);
|
||||
}
|
||||
else if (role == Qt::DisplayRole)
|
||||
{
|
||||
switch (index.column())
|
||||
{
|
||||
case BuildingEditModel::Building:
|
||||
return item.displayName();
|
||||
case BuildingEditModel::Name:
|
||||
return item.name();
|
||||
case BuildingEditModel::MountingPointId:
|
||||
if (item.hasMountingPointId())
|
||||
return item.mountingPointId();
|
||||
break;
|
||||
case BuildingEditModel::StructureElementId:
|
||||
return item.structureElementId();
|
||||
case BuildingEditModel::FortifyFactor:
|
||||
if (item.isRoom())
|
||||
return QString::number(item.fortifyFactor(),'f',1);
|
||||
break;
|
||||
case BuildingEditModel::DamagePercent:
|
||||
if (item.isRoom())
|
||||
return QString::number(item.damagePercent());
|
||||
}
|
||||
}
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
bool BuildingEditModel::slotUpdateRow(const BuildingViewer::TreeItem &room, const bool fortifyChanged)
|
||||
bool BuildingEditModel::slotUpdateRow(const BuildingViewer::TreeItem& room, const bool fortifyChanged)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "slotUpdateRow isBuilding=" << room.isBuilding()
|
||||
<< " isFloor" << room.isFloor()
|
||||
<< " isRoom" << room.isRoom();
|
||||
DEBUG_LOG(m_logger) << "slotUpdateRow isBuilding=" << room.isBuilding() << " isFloor" << room.isFloor() << " isRoom"
|
||||
<< room.isRoom();
|
||||
|
||||
QModelIndex idx = modelIndexByStructureElementId(room.structureElementId());
|
||||
|
||||
QModelIndex idx = modelIndexByStructureElementId(room.structureElementId());
|
||||
|
||||
if (fortifyChanged && ( !room.isRoom() || !qFuzzyIsNull(room.fortifyFactor())))
|
||||
{
|
||||
for (auto *item : privateData(idx)->children())
|
||||
if (fortifyChanged && (!room.isRoom() || !qFuzzyIsNull(room.fortifyFactor())))
|
||||
{
|
||||
TreeItem childItem = item->data().value<TreeItem>();
|
||||
childItem.setFortifyFactor(room.fortifyFactor());
|
||||
slotUpdateRow(childItem, fortifyChanged);
|
||||
for (auto* item : privateData(idx)->children())
|
||||
{
|
||||
TreeItem childItem = item->data().value<TreeItem>();
|
||||
childItem.setFortifyFactor(room.fortifyFactor());
|
||||
slotUpdateRow(childItem, fortifyChanged);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (room.hasDisplayNameChanged())
|
||||
m_mapRoomsWithChangedDisplayName[room.structureElementId()] = room;
|
||||
if (fortifyChanged && (room.isRoom() && room.hasFortifyFactorChanged()))
|
||||
m_mapRoomsWithChangedFortifyFactor[room.structureElementId()] = room;
|
||||
if (room.hasDisplayNameChanged())
|
||||
m_mapRoomsWithChangedDisplayName[room.structureElementId()] = room;
|
||||
if (fortifyChanged && (room.isRoom() && room.hasFortifyFactorChanged()))
|
||||
m_mapRoomsWithChangedFortifyFactor[room.structureElementId()] = room;
|
||||
|
||||
QVariant data;
|
||||
data.setValue(room);
|
||||
QVariant data;
|
||||
data.setValue(room);
|
||||
|
||||
emit signalModelDataChanged();
|
||||
return setItemData(idx, data, QIcon());
|
||||
emit signalModelDataChanged();
|
||||
return setItemData(idx, data, QIcon());
|
||||
}
|
||||
|
||||
|
||||
bool BuildingEditModel::onInsertRow(int &row, const QModelIndex &parent, const BuildingViewer::TreeItem &folderData)
|
||||
bool BuildingEditModel::onInsertRow(int& row, const QModelIndex& parent, const BuildingViewer::TreeItem& folderData)
|
||||
{
|
||||
row = rowCount(parent);
|
||||
QVariant data;
|
||||
data.setValue(folderData);
|
||||
NGLTreeItem *item = new NGLTreeItem(data, QIcon());
|
||||
item->setModified(true);
|
||||
row = rowCount(parent);
|
||||
QVariant data;
|
||||
data.setValue(folderData);
|
||||
NGLTreeItem* item = new NGLTreeItem(data, QIcon());
|
||||
item->setModified(true);
|
||||
|
||||
emit signalModelDataChanged();
|
||||
emit signalModelDataChanged();
|
||||
|
||||
return NGLTreeModel::insertRow(row, parent, item);
|
||||
return NGLTreeModel::insertRow(row, parent, item);
|
||||
}
|
||||
|
||||
|
||||
bool BuildingEditModel::init(int32_t mseId)
|
||||
{
|
||||
INFO_LOG(m_logger) << "init mseId=" << mseId;
|
||||
NGLTreeModel::resetModel();
|
||||
m_mapRoomsWithChangedFortifyFactor.clear();
|
||||
INFO_LOG(m_logger) << "init mseId=" << mseId;
|
||||
NGLTreeModel::resetModel();
|
||||
m_mapRoomsWithChangedFortifyFactor.clear();
|
||||
|
||||
QMap<qint32, BuildingViewer::TreeItem> treemap;
|
||||
QMap<qint32, qint32> lookupFloorId2TreeId;
|
||||
QString rootName;
|
||||
QMap<qint32, BuildingViewer::TreeItem> treemap;
|
||||
QMap<qint32, qint32> lookupFloorId2TreeId;
|
||||
QString rootName;
|
||||
|
||||
|
||||
InfrastructureManagement::MainStructureElement building = m_ismDtc->mainStructureElement(mseId);
|
||||
int rootId = 0;
|
||||
qint32 mapId = 0;
|
||||
|
||||
|
||||
|
||||
InfrastructureManagement::MainStructureElement building = m_ismDtc->mainStructureElement(mseId);
|
||||
int rootId = 0;
|
||||
qint32 mapId = 0;
|
||||
|
||||
const std::vector<InfrastructureManagement::StructureElement> &vecElements = building.elements();
|
||||
for (const auto &se : vecElements)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "se: " << se;
|
||||
if (se.structureElementTypeId() == InfrastructureManagement::StructureElementType::Building)
|
||||
const std::vector<InfrastructureManagement::StructureElement>& vecElements = building.elements();
|
||||
for (const auto& se : vecElements)
|
||||
{
|
||||
BuildingViewer::TreeItem rootItemBuilding(se);
|
||||
rootName =rootItemBuilding.name();
|
||||
m_buildingName = rootItemBuilding.displayName();
|
||||
mapId = rootId;
|
||||
treemap[mapId++] = rootItemBuilding;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
for (const auto &se : vecElements)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "se: =" << se;
|
||||
if (se.structureElementTypeId() == InfrastructureManagement::StructureElementType_def::Floor)
|
||||
{
|
||||
BuildingViewer::TreeItem itemRoom(se);
|
||||
itemRoom.setSuperior(rootId);
|
||||
|
||||
lookupFloorId2TreeId[se.id()] = mapId;
|
||||
treemap[mapId++] = itemRoom;
|
||||
}
|
||||
}
|
||||
|
||||
m_bldDtc->enableBuildingState();
|
||||
m_bldDtc->waitForHistoricalDataBuildingState(1000);
|
||||
|
||||
auto bs = m_bldDtc->buildingState(mseId);
|
||||
|
||||
QMap<int32_t, Buildings::RoomState> roomStates;
|
||||
for (const auto &e : bs.roomStates())
|
||||
roomStates[e.id()] = e;
|
||||
|
||||
|
||||
for (const auto &se : vecElements)
|
||||
{
|
||||
if (se.structureElementTypeId() == InfrastructureManagement::StructureElementType_def::Room)
|
||||
{
|
||||
|
||||
double fortifyFactor = 1.0;
|
||||
qint32 damagePercent = bs.damagePercent();
|
||||
if (roomStates.contains(se.id()))
|
||||
{
|
||||
fortifyFactor = roomStates[se.id()].fortifyFactor();
|
||||
damagePercent = roomStates[se.id()].damagePercent();
|
||||
}
|
||||
|
||||
BuildingViewer::TreeItem itemRoom(se, fortifyFactor, damagePercent);
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
|
||||
int32_t floorID = se.path()[1];
|
||||
itemRoom.setSuperior(lookupFloorId2TreeId[floorID]);
|
||||
}
|
||||
catch (const std::out_of_range &e)
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Caught exception while trying to get superior id for building " << rootName << " with room with mounting point id: " << se.mountingPointId() << ": " << e.what();
|
||||
return false;
|
||||
}
|
||||
|
||||
treemap[mapId++] = itemRoom;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QHash<int, QPersistentModelIndex> parentItemIndexCache;
|
||||
parentItemIndexCache.insert(rootId, QModelIndex());
|
||||
|
||||
for (auto iter = treemap.constBegin(); iter != treemap.constEnd(); ++iter)
|
||||
{
|
||||
int itemDatabaseId = iter.key();
|
||||
const BuildingViewer::TreeItem &item = iter.value();
|
||||
|
||||
QVariant data;
|
||||
data.setValue(item);
|
||||
|
||||
int parentId = item.hasSuperior() ? item.getSuperior() : rootId;
|
||||
if (!parentItemIndexCache.contains(parentId))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Invalid building structure! Tree can not be built!";
|
||||
return false;
|
||||
DEBUG_LOG(m_logger) << "se: " << se;
|
||||
if (se.structureElementTypeId() == InfrastructureManagement::StructureElementType::Building)
|
||||
{
|
||||
BuildingViewer::TreeItem rootItemBuilding(se);
|
||||
rootName = rootItemBuilding.name();
|
||||
m_buildingName = rootItemBuilding.displayName();
|
||||
mapId = rootId;
|
||||
treemap[mapId++] = rootItemBuilding;
|
||||
}
|
||||
}
|
||||
|
||||
QModelIndex pIndex = parentItemIndexCache.value(parentId);
|
||||
int rowPos = -1;
|
||||
for (const auto& se : vecElements)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "se: =" << se;
|
||||
if (se.structureElementTypeId() == InfrastructureManagement::StructureElementType_def::Floor)
|
||||
{
|
||||
BuildingViewer::TreeItem itemRoom(se);
|
||||
itemRoom.setSuperior(rootId);
|
||||
|
||||
onInsertRow(rowPos, pIndex, item);
|
||||
lookupFloorId2TreeId[se.id()] = mapId;
|
||||
treemap[mapId++] = itemRoom;
|
||||
}
|
||||
}
|
||||
|
||||
QPersistentModelIndex mIndex = index(rowPos, 0, pIndex);
|
||||
m_mapModelIndices[item.structureElementId()] = mIndex;
|
||||
parentItemIndexCache.insert(itemDatabaseId, mIndex);
|
||||
}
|
||||
m_bldDtc->enableBuildingState();
|
||||
m_bldDtc->waitForHistoricalDataBuildingState(1000);
|
||||
|
||||
return true;
|
||||
auto bs = m_bldDtc->buildingState(mseId);
|
||||
|
||||
QMap<int32_t, Buildings::RoomState> roomStates;
|
||||
for (const auto& e : bs.roomStates())
|
||||
roomStates[e.id()] = e;
|
||||
|
||||
for (const auto& se : vecElements)
|
||||
{
|
||||
if (se.structureElementTypeId() == InfrastructureManagement::StructureElementType_def::Room)
|
||||
{
|
||||
|
||||
double fortifyFactor = 1.0;
|
||||
qint32 damagePercent = bs.damagePercent();
|
||||
if (roomStates.contains(se.id()))
|
||||
{
|
||||
fortifyFactor = roomStates[se.id()].fortifyFactor();
|
||||
damagePercent = roomStates[se.id()].damagePercent();
|
||||
}
|
||||
|
||||
BuildingViewer::TreeItem itemRoom(se, fortifyFactor, damagePercent);
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
int32_t floorID = se.path()[1];
|
||||
itemRoom.setSuperior(lookupFloorId2TreeId[floorID]);
|
||||
}
|
||||
catch (const std::out_of_range& e)
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Caught exception while trying to get superior id for building " << rootName
|
||||
<< " with room with mounting point id: " << se.mountingPointId() << ": "
|
||||
<< e.what();
|
||||
return false;
|
||||
}
|
||||
|
||||
treemap[mapId++] = itemRoom;
|
||||
}
|
||||
}
|
||||
|
||||
QHash<int, QPersistentModelIndex> parentItemIndexCache;
|
||||
parentItemIndexCache.insert(rootId, QModelIndex());
|
||||
|
||||
for (auto iter = treemap.constBegin(); iter != treemap.constEnd(); ++iter)
|
||||
{
|
||||
int itemDatabaseId = iter.key();
|
||||
const BuildingViewer::TreeItem& item = iter.value();
|
||||
|
||||
QVariant data;
|
||||
data.setValue(item);
|
||||
|
||||
int parentId = item.hasSuperior() ? item.getSuperior() : rootId;
|
||||
if (!parentItemIndexCache.contains(parentId))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Invalid building structure! Tree can not be built!";
|
||||
return false;
|
||||
}
|
||||
|
||||
QModelIndex pIndex = parentItemIndexCache.value(parentId);
|
||||
int rowPos = -1;
|
||||
|
||||
onInsertRow(rowPos, pIndex, item);
|
||||
|
||||
QPersistentModelIndex mIndex = index(rowPos, 0, pIndex);
|
||||
m_mapModelIndices[item.structureElementId()] = mIndex;
|
||||
parentItemIndexCache.insert(itemDatabaseId, mIndex);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QModelIndex BuildingEditModel::modelIndexByMountingPointId(int mountingPointId) const
|
||||
{
|
||||
for(const QPersistentModelIndex &mi : std::as_const(m_mapModelIndices))
|
||||
{
|
||||
if (privateData(mi)->data().value<TreeItem>().mountingPointId() == mountingPointId)
|
||||
return mi;
|
||||
}
|
||||
WARNING_LOG(m_logger)<<"Could not find modelindex for given room mountig point id: " << mountingPointId;
|
||||
return {};
|
||||
for (const QPersistentModelIndex& mi : std::as_const(m_mapModelIndices))
|
||||
{
|
||||
if (privateData(mi)->data().value<TreeItem>().mountingPointId() == mountingPointId)
|
||||
return mi;
|
||||
}
|
||||
WARNING_LOG(m_logger) << "Could not find modelindex for given room mountig point id: " << mountingPointId;
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
QModelIndex BuildingEditModel::modelIndexByStructureElementId(int structureElementId) const
|
||||
{
|
||||
auto it = m_mapModelIndices.find(structureElementId);
|
||||
if (it == m_mapModelIndices.end())
|
||||
{
|
||||
WARNING_LOG(m_logger)<<"Could not find modelindex for given room structreElementId: " << structureElementId;
|
||||
return {};
|
||||
}
|
||||
return it.value();
|
||||
auto it = m_mapModelIndices.find(structureElementId);
|
||||
if (it == m_mapModelIndices.end())
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Could not find modelindex for given room structreElementId: " << structureElementId;
|
||||
return {};
|
||||
}
|
||||
return it.value();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void BuildingEditProxyModel::setSourceModel(QAbstractItemModel *sourceModel)
|
||||
void BuildingEditProxyModel::setSourceModel(QAbstractItemModel* sourceModel)
|
||||
{
|
||||
m_sourceModel = qobject_cast<BuildingEditModel*>(sourceModel);
|
||||
QSortFilterProxyModel::setSourceModel(m_sourceModel);
|
||||
m_sourceModel = qobject_cast<BuildingEditModel*>(sourceModel);
|
||||
QSortFilterProxyModel::setSourceModel(m_sourceModel);
|
||||
}
|
||||
|
||||
bool BuildingEditProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const
|
||||
bool BuildingEditProxyModel::lessThan(const QModelIndex& left, const QModelIndex& right) const
|
||||
{
|
||||
if (!m_sourceModel ||
|
||||
left.column() != 0 || right.column() != 0)
|
||||
if (!m_sourceModel || left.column() != 0 || right.column() != 0)
|
||||
return QSortFilterProxyModel::lessThan(left, right);
|
||||
|
||||
NGLTreeItem* itemLeft = m_sourceModel->privateData(left);
|
||||
NGLTreeItem* itemRight = m_sourceModel->privateData(right);
|
||||
if (itemLeft && itemRight)
|
||||
return (itemLeft->row() < itemRight->row());
|
||||
|
||||
return QSortFilterProxyModel::lessThan(left, right);
|
||||
|
||||
NGLTreeItem *itemLeft = m_sourceModel->privateData(left);
|
||||
NGLTreeItem *itemRight = m_sourceModel->privateData(right);
|
||||
if (itemLeft && itemRight)
|
||||
return (itemLeft->row() < itemRight->row());
|
||||
|
||||
return QSortFilterProxyModel::lessThan(left, right);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
} // namespace BuildingViewer
|
||||
Executable → Regular
+55
-52
@@ -2,13 +2,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Common/logger.h>
|
||||
|
||||
#include <Plugins/Buildings/bld_data_plugin_interface.h>
|
||||
#include <Plugins/InfrastructureManagement/ism_data_plugin_interface.h>
|
||||
|
||||
#include "bdv_treemodel_item.h"
|
||||
|
||||
#include <Common/logger.h>
|
||||
#include <Plugins/Buildings/bld_data_plugin_interface.h>
|
||||
#include <Plugins/InfrastructureManagement/ism_data_plugin_interface.h>
|
||||
#include <QMap>
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <functional>
|
||||
@@ -18,70 +16,75 @@ namespace BuildingViewer
|
||||
{
|
||||
class BuildingEditModel : public NGLTreeModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum Columns
|
||||
{
|
||||
Building,
|
||||
Name,
|
||||
MountingPointId,
|
||||
StructureElementId,
|
||||
FortifyFactor,
|
||||
DamagePercent,
|
||||
ColumnCount,
|
||||
};
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum Columns {
|
||||
Building,
|
||||
Name,
|
||||
MountingPointId,
|
||||
StructureElementId,
|
||||
FortifyFactor,
|
||||
DamagePercent,
|
||||
ColumnCount,
|
||||
};
|
||||
|
||||
BuildingEditModel(QObject *parent,
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc> &ismDtc,
|
||||
const std::shared_ptr<Buildings::Interface::Dtc> &bldDtc);
|
||||
BuildingEditModel(QObject* parent, const std::shared_ptr<InfrastructureManagement::Interface::Dtc>& ismDtc,
|
||||
const std::shared_ptr<Buildings::Interface::Dtc>& bldDtc);
|
||||
|
||||
QList<BuildingViewer::TreeItem> getRoomsWithChangedFortifyFactors() const { return m_mapRoomsWithChangedFortifyFactor.values(); }
|
||||
QList<BuildingViewer::TreeItem> getRoomsWithChangedDisplayNames() const { return m_mapRoomsWithChangedDisplayName.values(); }
|
||||
QList<BuildingViewer::TreeItem> getRoomsWithChangedFortifyFactors() const
|
||||
{
|
||||
return m_mapRoomsWithChangedFortifyFactor.values();
|
||||
}
|
||||
|
||||
bool init(int32_t buildingDatabaseId);
|
||||
QModelIndex modelIndexByMountingPointId(int mountingPointId) const;
|
||||
QModelIndex modelIndexByStructureElementId(int structureElementId) const;
|
||||
QString getBuildingName() const {return m_buildingName;}
|
||||
QList<BuildingViewer::TreeItem> getRoomsWithChangedDisplayNames() const
|
||||
{
|
||||
return m_mapRoomsWithChangedDisplayName.values();
|
||||
}
|
||||
|
||||
public slots:
|
||||
bool slotUpdateRow(const BuildingViewer::TreeItem &room, const bool fortifyChanged);
|
||||
bool init(int32_t buildingDatabaseId);
|
||||
QModelIndex modelIndexByMountingPointId(int mountingPointId) const;
|
||||
QModelIndex modelIndexByStructureElementId(int structureElementId) const;
|
||||
|
||||
signals:
|
||||
void signalModelDataChanged();
|
||||
QString getBuildingName() const
|
||||
{
|
||||
return m_buildingName;
|
||||
}
|
||||
|
||||
private:
|
||||
public slots:
|
||||
bool slotUpdateRow(const BuildingViewer::TreeItem& room, const bool fortifyChanged);
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
QVariant data(const QModelIndex &index, int role) const override final;
|
||||
bool onInsertRow(int &row, const QModelIndex &parent, const BuildingViewer::TreeItem &folderData);
|
||||
signals:
|
||||
void signalModelDataChanged();
|
||||
|
||||
QMap<int, QPersistentModelIndex> m_mapModelIndices;
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
QVariant data(const QModelIndex& index, int role) const override final;
|
||||
bool onInsertRow(int& row, const QModelIndex& parent, const BuildingViewer::TreeItem& folderData);
|
||||
|
||||
|
||||
QMap<int32_t, BuildingViewer::TreeItem> m_mapRoomsWithChangedFortifyFactor;
|
||||
QMap<int32_t, BuildingViewer::TreeItem> m_mapRoomsWithChangedDisplayName;
|
||||
QMap<int, QPersistentModelIndex> m_mapModelIndices;
|
||||
|
||||
std::shared_ptr<InfrastructureManagement::Interface::Dtc> m_ismDtc;
|
||||
std::shared_ptr<Buildings::Interface::Dtc> m_bldDtc;
|
||||
QMap<int32_t, BuildingViewer::TreeItem> m_mapRoomsWithChangedFortifyFactor;
|
||||
QMap<int32_t, BuildingViewer::TreeItem> m_mapRoomsWithChangedDisplayName;
|
||||
|
||||
QString m_buildingName;
|
||||
std::shared_ptr<InfrastructureManagement::Interface::Dtc> m_ismDtc;
|
||||
std::shared_ptr<Buildings::Interface::Dtc> m_bldDtc;
|
||||
|
||||
QString m_buildingName;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class BuildingEditProxyModel final : public QSortFilterProxyModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
using QSortFilterProxyModel::QSortFilterProxyModel;
|
||||
Q_OBJECT
|
||||
public:
|
||||
using QSortFilterProxyModel::QSortFilterProxyModel;
|
||||
|
||||
void setSourceModel(QAbstractItemModel *sourceModel) override;
|
||||
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
|
||||
private:
|
||||
BuildingEditModel *m_sourceModel = nullptr;
|
||||
void setSourceModel(QAbstractItemModel* sourceModel) override;
|
||||
bool lessThan(const QModelIndex& left, const QModelIndex& right) const override;
|
||||
|
||||
private:
|
||||
BuildingEditModel* m_sourceModel = nullptr;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace BuildingViewer
|
||||
|
||||
Q_DECLARE_METATYPE(BuildingViewer::TreeItem)
|
||||
|
||||
Executable → Regular
+61
-65
@@ -1,88 +1,84 @@
|
||||
|
||||
|
||||
|
||||
#include "bdv_replay_handler.h"
|
||||
|
||||
|
||||
namespace BuildingViewer
|
||||
{
|
||||
ReplayHandler::ReplayHandler(int buildingTopicStart_s, int buildingTopicEnd_s, const TopicReplay::Interface::SituationReplayTime &replay, QObject *parent) : QObject(parent)
|
||||
, m_actualReplayStart_ms(0)
|
||||
, m_actualReplayEnd_ms(0)
|
||||
, m_replayDuration_ms(0)
|
||||
, m_startOffset_ms(0)
|
||||
, m_replayInfo(replay),
|
||||
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {
|
||||
DEBUG_LOG(m_logger) << "buildingTopicStart_s = " << buildingTopicStart_s
|
||||
<< ", buildingTopicEnd_s = " << buildingTopicEnd_s
|
||||
<< ", replay.topicStart_s = " << replay.topicStart_s
|
||||
<< ", replay.topicEnd_s = " << replay.topicEnd_s
|
||||
<< ", replay.replayStart_ms = " << replay.replayStart_ms
|
||||
<< ", replay.replayEnd_ms = " << replay.replayEnd_ms;
|
||||
ReplayHandler::ReplayHandler(int buildingTopicStart_s, int buildingTopicEnd_s,
|
||||
const TopicReplay::Interface::SituationReplayTime& replay, QObject* parent)
|
||||
: QObject(parent), m_actualReplayStart_ms(0), m_actualReplayEnd_ms(0), m_replayDuration_ms(0), m_startOffset_ms(0),
|
||||
m_replayInfo(replay), m_logger(NGL::NGLLoggerBootstrap::getLogger())
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "buildingTopicStart_s = " << buildingTopicStart_s
|
||||
<< ", buildingTopicEnd_s = " << buildingTopicEnd_s
|
||||
<< ", replay.topicStart_s = " << replay.topicStart_s
|
||||
<< ", replay.topicEnd_s = " << replay.topicEnd_s
|
||||
<< ", replay.replayStart_ms = " << replay.replayStart_ms
|
||||
<< ", replay.replayEnd_ms = " << replay.replayEnd_ms;
|
||||
|
||||
|
||||
int start_diff_ms = (buildingTopicStart_s - replay.topicStart_s) * 1000;
|
||||
int start_diff_ms = (buildingTopicStart_s - replay.topicStart_s) * 1000;
|
||||
|
||||
if (start_diff_ms >= 0)
|
||||
{
|
||||
|
||||
if (start_diff_ms >= 0)
|
||||
{
|
||||
|
||||
m_actualReplayStart_ms = replay.replayStart_ms + start_diff_ms;
|
||||
m_startOffset_ms = 0;
|
||||
DEBUG_LOG(m_logger) << "Replay starts before Building-Topic: Shift replay starting point to m_actualReplayStart_ms = " << m_actualReplayStart_ms;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
m_actualReplayStart_ms = replay.replayStart_ms + start_diff_ms;
|
||||
m_startOffset_ms = 0;
|
||||
DEBUG_LOG(m_logger)
|
||||
<< "Replay starts before Building-Topic: Shift replay starting point to m_actualReplayStart_ms = "
|
||||
<< m_actualReplayStart_ms;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
m_actualReplayStart_ms = replay.replayStart_ms;
|
||||
m_startOffset_ms = std::abs(start_diff_ms);
|
||||
DEBUG_LOG(m_logger) << "Building-Topic starts before Replay: Starting Replay after " << m_startOffset_ms << "msec";
|
||||
}
|
||||
m_actualReplayStart_ms = replay.replayStart_ms;
|
||||
m_startOffset_ms = std::abs(start_diff_ms);
|
||||
DEBUG_LOG(m_logger) << "Building-Topic starts before Replay: Starting Replay after " << m_startOffset_ms
|
||||
<< "msec";
|
||||
}
|
||||
|
||||
|
||||
m_actualReplayEnd_ms = replay.replayEnd_ms;
|
||||
|
||||
if (replay.topicEnd_s > buildingTopicEnd_s)
|
||||
{
|
||||
m_actualReplayEnd_ms -= (replay.topicEnd_s - buildingTopicEnd_s) * 1000;
|
||||
DEBUG_LOG(m_logger) << "Replay longer than Building-Topic, cutting replay end to m_actualReplayEnd_ms = " << m_actualReplayEnd_ms;
|
||||
}
|
||||
m_actualReplayEnd_ms = replay.replayEnd_ms;
|
||||
|
||||
m_replayDuration_ms = m_actualReplayEnd_ms - m_actualReplayStart_ms;
|
||||
if (replay.topicEnd_s > buildingTopicEnd_s)
|
||||
{
|
||||
m_actualReplayEnd_ms -= (replay.topicEnd_s - buildingTopicEnd_s) * 1000;
|
||||
DEBUG_LOG(m_logger) << "Replay longer than Building-Topic, cutting replay end to m_actualReplayEnd_ms = "
|
||||
<< m_actualReplayEnd_ms;
|
||||
}
|
||||
|
||||
DEBUG_LOG(m_logger) << "Replay from " << m_actualReplayStart_ms << " to " << m_actualReplayEnd_ms << " (duration = " << m_replayDuration_ms << ")";
|
||||
m_replayDuration_ms = m_actualReplayEnd_ms - m_actualReplayStart_ms;
|
||||
|
||||
if (m_startOffset_ms == 0)
|
||||
m_startOffset_ms = -1;
|
||||
DEBUG_LOG(m_logger) << "Replay from " << m_actualReplayStart_ms << " to " << m_actualReplayEnd_ms
|
||||
<< " (duration = " << m_replayDuration_ms << ")";
|
||||
|
||||
if (m_startOffset_ms == 0)
|
||||
m_startOffset_ms = -1;
|
||||
}
|
||||
|
||||
|
||||
void ReplayHandler::tick(qint64 diffSinceLastTick)
|
||||
{
|
||||
if (isExpired())
|
||||
return;
|
||||
if (isExpired())
|
||||
return;
|
||||
|
||||
m_replayDuration_ms -= diffSinceLastTick;
|
||||
if (m_replayDuration_ms <= 0)
|
||||
{
|
||||
emit signalStopReplay();
|
||||
return;
|
||||
}
|
||||
m_replayDuration_ms -= diffSinceLastTick;
|
||||
if (m_replayDuration_ms <= 0)
|
||||
{
|
||||
emit signalStopReplay();
|
||||
return;
|
||||
}
|
||||
|
||||
DEBUG_LOG(m_logger) << "ReplayHandler::tick(): Remaining: " << m_replayDuration_ms << "msec";
|
||||
DEBUG_LOG(m_logger) << "ReplayHandler::tick(): Remaining: " << m_replayDuration_ms << "msec";
|
||||
|
||||
if (m_startOffset_ms == -1)
|
||||
{
|
||||
emit signalStartReplay(m_actualReplayStart_ms, m_actualReplayEnd_ms, m_replayInfo.replaySpeedFactor);
|
||||
m_startOffset_ms = 0;
|
||||
}
|
||||
if (m_startOffset_ms == -1)
|
||||
{
|
||||
emit signalStartReplay(m_actualReplayStart_ms, m_actualReplayEnd_ms, m_replayInfo.replaySpeedFactor);
|
||||
m_startOffset_ms = 0;
|
||||
}
|
||||
|
||||
if (m_startOffset_ms > 0)
|
||||
{
|
||||
m_startOffset_ms -= diffSinceLastTick;
|
||||
if (m_startOffset_ms <= 0)
|
||||
emit signalStartReplay(m_actualReplayStart_ms, m_actualReplayEnd_ms, m_replayInfo.replaySpeedFactor);
|
||||
}
|
||||
}
|
||||
if (m_startOffset_ms > 0)
|
||||
{
|
||||
m_startOffset_ms -= diffSinceLastTick;
|
||||
if (m_startOffset_ms <= 0)
|
||||
emit signalStartReplay(m_actualReplayStart_ms, m_actualReplayEnd_ms, m_replayInfo.replaySpeedFactor);
|
||||
}
|
||||
}
|
||||
} // namespace BuildingViewer
|
||||
Executable → Regular
+23
-21
@@ -1,37 +1,39 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <Plugins/SituationReplay/srp_gui_plugin_interface.h>
|
||||
#include <Plugins/BuildingViewer/bdv_viewer_gui_plugin_interface.h>
|
||||
#include <Plugins/BuildingViewer/Common/logger.h>
|
||||
#include <Plugins/BuildingViewer/bdv_viewer_gui_plugin_interface.h>
|
||||
#include <Plugins/SituationReplay/srp_gui_plugin_interface.h>
|
||||
#include <QObject>
|
||||
|
||||
namespace BuildingViewer
|
||||
{
|
||||
class ReplayHandler : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ReplayHandler(int buildingTopicStart_s, int buildingTopicEnd_s, const TopicReplay::Interface::SituationReplayTime &replay, QObject *parent = nullptr);
|
||||
Q_OBJECT
|
||||
public:
|
||||
ReplayHandler(int buildingTopicStart_s, int buildingTopicEnd_s,
|
||||
const TopicReplay::Interface::SituationReplayTime& replay, QObject* parent = nullptr);
|
||||
|
||||
void tick(qint64 diffSinceLastTick);
|
||||
void tick(qint64 diffSinceLastTick);
|
||||
|
||||
bool isExpired() const { return m_replayDuration_ms == 0; }
|
||||
bool isExpired() const
|
||||
{
|
||||
return m_replayDuration_ms == 0;
|
||||
}
|
||||
|
||||
signals:
|
||||
void signalStartReplay(qint64 start, qint64 end, double speed);
|
||||
void signalStopReplay();
|
||||
signals:
|
||||
void signalStartReplay(qint64 start, qint64 end, double speed);
|
||||
void signalStopReplay();
|
||||
|
||||
private:
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
qint64 m_actualReplayStart_ms;
|
||||
qint64 m_actualReplayEnd_ms;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
qint64 m_actualReplayStart_ms;
|
||||
qint64 m_actualReplayEnd_ms;
|
||||
|
||||
qint64 m_replayDuration_ms;
|
||||
qint64 m_startOffset_ms;
|
||||
TopicReplay::Interface::SituationReplayTime m_replayInfo;
|
||||
qint64 m_replayDuration_ms;
|
||||
qint64 m_startOffset_ms;
|
||||
TopicReplay::Interface::SituationReplayTime m_replayInfo;
|
||||
};
|
||||
}
|
||||
} // namespace BuildingViewer
|
||||
Executable → Regular
+78
-81
@@ -1,109 +1,106 @@
|
||||
|
||||
|
||||
|
||||
#include "bdv_thread_video_exporter.h"
|
||||
#include <utility>
|
||||
|
||||
#include "bdv_replay_handler.h"
|
||||
|
||||
#include <Common/TopicEditorBase/topic_editor_base.h>
|
||||
#include <QElapsedTimer>
|
||||
#include <QThread>
|
||||
|
||||
#include <Common/TopicEditorBase/topic_editor_base.h>
|
||||
#include <utility>
|
||||
|
||||
namespace BuildingViewer
|
||||
{
|
||||
VideoExporter::VideoExporter(QObject *parent)
|
||||
: QObject(parent)
|
||||
VideoExporter::VideoExporter(QObject* parent) : QObject(parent)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "ThreadVideoExporter has been created";
|
||||
DEBUG_LOG(m_logger) << "ThreadVideoExporter has been created";
|
||||
}
|
||||
|
||||
void VideoExporter::init(const VideoInformation &videoInfo)
|
||||
void VideoExporter::init(const VideoInformation& videoInfo)
|
||||
{
|
||||
m_vecVideosToExport.push_back(videoInfo);
|
||||
m_vecVideosToExport.push_back(videoInfo);
|
||||
}
|
||||
|
||||
|
||||
void VideoExporter::sendAliveSignals()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "sendAliveSignals() called";
|
||||
DEBUG_LOG(m_logger) << "sendAliveSignals() called";
|
||||
|
||||
for (auto &e : std::as_const(m_vecVideosToExport))
|
||||
emit e.m_pExportNotifier->stillAlive();
|
||||
for (auto& e : std::as_const(m_vecVideosToExport))
|
||||
emit e.m_pExportNotifier->stillAlive();
|
||||
|
||||
DEBUG_LOG(m_logger) << "\tSignals emitted, mutex unlocked";
|
||||
DEBUG_LOG(m_logger) << "\tSignals emitted, mutex unlocked";
|
||||
}
|
||||
|
||||
|
||||
void VideoExporter::doExport()
|
||||
{
|
||||
while (!m_vecVideosToExport.isEmpty())
|
||||
{
|
||||
if (QThread::currentThread()->isInterruptionRequested())
|
||||
break;
|
||||
VideoInformation toExport = m_vecVideosToExport.takeFirst();
|
||||
DEBUG_LOG(m_logger) << "Starting export of " << toExport.m_strFolderPath;
|
||||
|
||||
const auto state = toExport.m_bgViewerState.value(QStringLiteral("arrBuildingStates"));
|
||||
|
||||
if (!state.isArray())
|
||||
while (!m_vecVideosToExport.isEmpty())
|
||||
{
|
||||
WARNING_LOG(m_logger) << "No opened buildings, nothing to export, skipping video!";
|
||||
continue;
|
||||
if (QThread::currentThread()->isInterruptionRequested())
|
||||
break;
|
||||
VideoInformation toExport = m_vecVideosToExport.takeFirst();
|
||||
DEBUG_LOG(m_logger) << "Starting export of " << toExport.m_strFolderPath;
|
||||
|
||||
const auto state = toExport.m_bgViewerState.value(QStringLiteral("arrBuildingStates"));
|
||||
|
||||
if (!state.isArray())
|
||||
{
|
||||
WARNING_LOG(m_logger) << "No opened buildings, nothing to export, skipping video!";
|
||||
continue;
|
||||
}
|
||||
|
||||
DEBUG_LOG(m_logger) << "Emitting 'signalStartRecording'";
|
||||
emit signalStartRecording(toExport.m_strFolderPath, state);
|
||||
|
||||
QSharedPointer<ReplayHandler> pHandler;
|
||||
|
||||
QElapsedTimer elapsedTimer;
|
||||
qint64 last_tick_elapsed = 0;
|
||||
qint64 elapsed_sum_ms = 0;
|
||||
const qint64 record_duration_ms = toExport.m_record_duration_s * 1000;
|
||||
|
||||
elapsedTimer.start();
|
||||
while (elapsed_sum_ms <= record_duration_ms)
|
||||
{
|
||||
const qint64 curElapsed = elapsedTimer.restart();
|
||||
elapsed_sum_ms += curElapsed;
|
||||
sendAliveSignals();
|
||||
emit toExport.m_pExportNotifier->stillAlive();
|
||||
|
||||
if (!pHandler && toExport.m_vecReplayHandler.size())
|
||||
{
|
||||
pHandler = toExport.m_vecReplayHandler.front();
|
||||
connect(pHandler.data(), &ReplayHandler::signalStartReplay, this, &VideoExporter::signalStartReplay);
|
||||
connect(pHandler.data(), &ReplayHandler::signalStopReplay, this, &VideoExporter::signalStopReplay);
|
||||
toExport.m_vecReplayHandler.pop_front();
|
||||
}
|
||||
|
||||
const qint64 diff_ms = elapsed_sum_ms - last_tick_elapsed;
|
||||
|
||||
if (diff_ms >= 1000)
|
||||
{
|
||||
last_tick_elapsed = elapsed_sum_ms;
|
||||
DEBUG_LOG(m_logger) << "Export: " << elapsed_sum_ms / 1000 << "/" << record_duration_ms / 1000
|
||||
<< "[s] passed";
|
||||
}
|
||||
|
||||
if (pHandler)
|
||||
{
|
||||
pHandler->tick(curElapsed);
|
||||
|
||||
if (pHandler->isExpired())
|
||||
break;
|
||||
}
|
||||
QThread::msleep(100);
|
||||
if (QThread::currentThread()->isInterruptionRequested())
|
||||
break;
|
||||
}
|
||||
DEBUG_LOG(m_logger) << "Done. Emitting 'signalStopRecording'";
|
||||
emit signalStopRecording();
|
||||
|
||||
DEBUG_LOG(m_logger) << "Export done, emitting 'signalExportSuccessful'";
|
||||
toExport.m_pExportNotifier->setExportSuccessful(toExport.m_strFolderPath);
|
||||
DEBUG_LOG(m_logger) << "\tsignal emitted";
|
||||
}
|
||||
|
||||
DEBUG_LOG(m_logger) << "Emitting 'signalStartRecording'";
|
||||
emit signalStartRecording(toExport.m_strFolderPath, state);
|
||||
|
||||
QSharedPointer<ReplayHandler> pHandler;
|
||||
|
||||
QElapsedTimer elapsedTimer;
|
||||
qint64 last_tick_elapsed = 0;
|
||||
qint64 elapsed_sum_ms = 0;
|
||||
const qint64 record_duration_ms = toExport.m_record_duration_s * 1000;
|
||||
|
||||
elapsedTimer.start();
|
||||
while (elapsed_sum_ms <= record_duration_ms)
|
||||
{
|
||||
const qint64 curElapsed = elapsedTimer.restart();
|
||||
elapsed_sum_ms += curElapsed;
|
||||
sendAliveSignals();
|
||||
emit toExport.m_pExportNotifier->stillAlive();
|
||||
|
||||
if (!pHandler && toExport.m_vecReplayHandler.size())
|
||||
{
|
||||
pHandler = toExport.m_vecReplayHandler.front();
|
||||
connect(pHandler.data(), &ReplayHandler::signalStartReplay, this, &VideoExporter::signalStartReplay);
|
||||
connect(pHandler.data(), &ReplayHandler::signalStopReplay, this, &VideoExporter::signalStopReplay);
|
||||
toExport.m_vecReplayHandler.pop_front();
|
||||
}
|
||||
|
||||
const qint64 diff_ms = elapsed_sum_ms - last_tick_elapsed;
|
||||
|
||||
if (diff_ms >= 1000)
|
||||
{
|
||||
last_tick_elapsed = elapsed_sum_ms;
|
||||
DEBUG_LOG(m_logger) << "Export: " << elapsed_sum_ms / 1000 << "/" << record_duration_ms / 1000 << "[s] passed";
|
||||
}
|
||||
|
||||
if (pHandler)
|
||||
{
|
||||
pHandler->tick(curElapsed);
|
||||
|
||||
if (pHandler->isExpired())
|
||||
break;
|
||||
}
|
||||
QThread::msleep(100);
|
||||
if (QThread::currentThread()->isInterruptionRequested())
|
||||
break;
|
||||
}
|
||||
DEBUG_LOG(m_logger) << "Done. Emitting 'signalStopRecording'";
|
||||
emit signalStopRecording();
|
||||
|
||||
DEBUG_LOG(m_logger) <<"Export done, emitting 'signalExportSuccessful'";
|
||||
toExport.m_pExportNotifier->setExportSuccessful(toExport.m_strFolderPath);
|
||||
DEBUG_LOG(m_logger) <<"\tsignal emitted";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace BuildingViewer
|
||||
Executable → Regular
+31
-37
@@ -1,12 +1,11 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <SituationReplay/srp_gui_plugin_interface.h>
|
||||
#include <BuildingViewer/bdv_viewer_gui_plugin_interface.h>
|
||||
#include <Common/logger.h>
|
||||
#include <QSharedPointer>
|
||||
#include <SituationReplay/srp_gui_plugin_interface.h>
|
||||
|
||||
namespace BuildingViewer
|
||||
{
|
||||
@@ -14,49 +13,44 @@ class ReplayHandler;
|
||||
|
||||
class VideoInformation
|
||||
{
|
||||
public:
|
||||
VideoInformation() = default;
|
||||
VideoInformation(TopicEditorBase::ExportNotifier *pExportNotifier,
|
||||
const QString &strFolderPath,
|
||||
const QJsonObject &attributes,
|
||||
const QVector<QSharedPointer<ReplayHandler>> &vecReplayHandler,
|
||||
qint64 record_duration_s)
|
||||
: m_pExportNotifier(pExportNotifier)
|
||||
, m_record_duration_s(record_duration_s)
|
||||
, m_strFolderPath(strFolderPath)
|
||||
, m_bgViewerState(attributes)
|
||||
, m_vecReplayHandler(vecReplayHandler)
|
||||
{}
|
||||
public:
|
||||
VideoInformation() = default;
|
||||
|
||||
TopicEditorBase::ExportNotifier *m_pExportNotifier = nullptr;
|
||||
qint64 m_record_duration_s = -1;
|
||||
QString m_strFolderPath;
|
||||
QJsonObject m_bgViewerState;
|
||||
QVector<QSharedPointer<ReplayHandler>> m_vecReplayHandler;
|
||||
VideoInformation(TopicEditorBase::ExportNotifier* pExportNotifier, const QString& strFolderPath,
|
||||
const QJsonObject& attributes, const QVector<QSharedPointer<ReplayHandler>>& vecReplayHandler,
|
||||
qint64 record_duration_s)
|
||||
: m_pExportNotifier(pExportNotifier), m_record_duration_s(record_duration_s), m_strFolderPath(strFolderPath),
|
||||
m_bgViewerState(attributes), m_vecReplayHandler(vecReplayHandler)
|
||||
{
|
||||
}
|
||||
|
||||
TopicEditorBase::ExportNotifier* m_pExportNotifier = nullptr;
|
||||
qint64 m_record_duration_s = -1;
|
||||
QString m_strFolderPath;
|
||||
QJsonObject m_bgViewerState;
|
||||
QVector<QSharedPointer<ReplayHandler>> m_vecReplayHandler;
|
||||
};
|
||||
|
||||
|
||||
class VideoExporter : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
VideoExporter(QObject *parent = nullptr);
|
||||
Q_OBJECT
|
||||
public:
|
||||
VideoExporter(QObject* parent = nullptr);
|
||||
|
||||
void init(const VideoInformation &videoInfo);
|
||||
void doExport();
|
||||
void init(const VideoInformation& videoInfo);
|
||||
void doExport();
|
||||
|
||||
signals:
|
||||
void signalStartReplay(qint64 start, qint64 end, double speed);
|
||||
void signalStopReplay();
|
||||
signals:
|
||||
void signalStartReplay(qint64 start, qint64 end, double speed);
|
||||
void signalStopReplay();
|
||||
|
||||
void signalStartRecording(const QString &strFolderPath, const QJsonValue &state);
|
||||
void signalStopRecording();
|
||||
void signalStartRecording(const QString& strFolderPath, const QJsonValue& state);
|
||||
void signalStopRecording();
|
||||
|
||||
private:
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
void sendAliveSignals();
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
void sendAliveSignals();
|
||||
|
||||
QVector<VideoInformation> m_vecVideosToExport;
|
||||
QVector<VideoInformation> m_vecVideosToExport;
|
||||
};
|
||||
}
|
||||
} // namespace BuildingViewer
|
||||
Executable → Regular
+215
-234
@@ -1,23 +1,23 @@
|
||||
|
||||
|
||||
|
||||
#include "bdv_topic_replay_interface.h"
|
||||
#include <utility>
|
||||
#include "bdv_viewer_gui_plugin.h"
|
||||
#include "bdv_thread_video_exporter.h"
|
||||
|
||||
#include "bdv_replay_handler.h"
|
||||
#include "bdv_thread_video_exporter.h"
|
||||
#include "bdv_viewer_gui_plugin.h"
|
||||
|
||||
#include <Common/bdv_controller.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
|
||||
#include <QDir>
|
||||
#include <QJsonDocument>
|
||||
#include <ngltools/ngltools_filesystem.h>
|
||||
#include <utility>
|
||||
|
||||
#ifdef EXPORT_BDV_TOPIC_AS_JSON
|
||||
#include <QFile>
|
||||
#include <LtsUtilsCore/qpoint3d.h>
|
||||
#include <Common/bdv_helper.h>
|
||||
#include <Common/BgViewer/viewerCtrl/viewwidgetstate.h>
|
||||
#include <Common/bdv_helper.h>
|
||||
#include <LtsUtilsCore/qpoint3d.h>
|
||||
#include <QFile>
|
||||
#else
|
||||
#include <QThread>
|
||||
#endif
|
||||
@@ -25,292 +25,273 @@
|
||||
namespace BuildingViewer
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
TopicReplayInterface::TopicReplayInterface(BgViewerController *bgvController, LtsSession::LtsSession *session)
|
||||
: m_bgvController(bgvController)
|
||||
, m_session(session)
|
||||
TopicReplayInterface::TopicReplayInterface(BgViewerController* bgvController, LtsSession::LtsSession* session)
|
||||
: m_bgvController(bgvController), m_session(session)
|
||||
{
|
||||
session->getForeignGuiInterface<SituationReplay::ForeignGuiInterface>(m_replayIfc);
|
||||
session->getForeignGuiInterface<SituationReplay::ForeignGuiInterface>(m_replayIfc);
|
||||
}
|
||||
|
||||
|
||||
QWidget *TopicReplayInterface::createWidget()
|
||||
QWidget* TopicReplayInterface::createWidget()
|
||||
{
|
||||
delete m_pBgViewerWidget;
|
||||
m_pBgViewerWidget = m_bgvController ? m_bgvController->getBgViewerWidget() : nullptr;
|
||||
return m_pBgViewerWidget;
|
||||
delete m_pBgViewerWidget;
|
||||
m_pBgViewerWidget = m_bgvController ? m_bgvController->getBgViewerWidget() : nullptr;
|
||||
return m_pBgViewerWidget;
|
||||
}
|
||||
|
||||
|
||||
TopicReplayInterface::~TopicReplayInterface()
|
||||
{
|
||||
#ifndef EXPORT_BDV_TOPIC_AS_JSON
|
||||
if (m_tveThread)
|
||||
{
|
||||
m_tveThread->requestInterruption();
|
||||
m_tveThread->quit();
|
||||
m_tveThread->wait(20000);
|
||||
m_tveThread->terminate();
|
||||
}
|
||||
delete m_tveThread;
|
||||
if (m_tveThread)
|
||||
{
|
||||
m_tveThread->requestInterruption();
|
||||
m_tveThread->quit();
|
||||
m_tveThread->wait(20000);
|
||||
m_tveThread->terminate();
|
||||
}
|
||||
delete m_tveThread;
|
||||
#endif
|
||||
|
||||
|
||||
delete m_pBgViewerWidget;
|
||||
m_pBgViewerWidget = nullptr;
|
||||
delete m_pBgViewerWidget;
|
||||
m_pBgViewerWidget = nullptr;
|
||||
}
|
||||
|
||||
|
||||
bool TopicReplayInterface::playbackInit(const QJsonObject &attributes)
|
||||
bool TopicReplayInterface::playbackInit(const QJsonObject& attributes)
|
||||
{
|
||||
if (!m_bgvController)
|
||||
return false;
|
||||
m_bgvController->closeBuilding();
|
||||
m_bgvController->excRestoreViewState(attributes.value(QStringLiteral("arrBuildingStates")));
|
||||
if (!m_bgvController)
|
||||
return false;
|
||||
m_bgvController->closeBuilding();
|
||||
m_bgvController->excRestoreViewState(attributes.value(QStringLiteral("arrBuildingStates")));
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void TopicReplayInterface::slotStartReplay(qint64 start, qint64 end, double speed)
|
||||
{
|
||||
if (m_replayIfc)
|
||||
m_replayIfc->startReplay(start, end, speed);
|
||||
if (m_replayIfc)
|
||||
m_replayIfc->startReplay(start, end, speed);
|
||||
}
|
||||
|
||||
void TopicReplayInterface::slotStopReplay()
|
||||
{
|
||||
if (m_replayIfc)
|
||||
m_replayIfc->stopReplay();
|
||||
if (m_replayIfc)
|
||||
m_replayIfc->stopReplay();
|
||||
}
|
||||
|
||||
|
||||
void TopicReplayInterface::setExportPlaybackTimes(qint64 startTimeSec,
|
||||
qint64 durationSec,
|
||||
const QVector<SituationReplayTime> &sitReplayTimes)
|
||||
void TopicReplayInterface::setExportPlaybackTimes(qint64 startTimeSec, qint64 durationSec,
|
||||
const QVector<SituationReplayTime>& sitReplayTimes)
|
||||
{
|
||||
m_startTimeSec = startTimeSec;
|
||||
m_durationSec = durationSec;
|
||||
m_sitReplayTimes = sitReplayTimes;
|
||||
m_startTimeSec = startTimeSec;
|
||||
m_durationSec = durationSec;
|
||||
m_sitReplayTimes = sitReplayTimes;
|
||||
}
|
||||
|
||||
bool TopicReplayInterface::exportTopic(const QJsonObject &attributes,
|
||||
const QString &folderPath,
|
||||
TopicEditorBase::ExportNotifier *pExportNotifier)
|
||||
bool TopicReplayInterface::exportTopic(const QJsonObject& attributes, const QString& folderPath,
|
||||
TopicEditorBase::ExportNotifier* pExportNotifier)
|
||||
{
|
||||
#ifdef EXPORT_BDV_TOPIC_AS_JSON
|
||||
const QJsonArray states = attributes[QStringLiteral("arrBuildingStates")].toArray();
|
||||
if (states.isEmpty())
|
||||
{
|
||||
INFO_LOG(m_logger) << "Nothing to export";
|
||||
emit pExportNotifier->exportSuccessful(QString());
|
||||
return true;
|
||||
}
|
||||
|
||||
const QString filename(QStringLiteral("buildingViewer.json"));
|
||||
QFile f(folderPath + QLatin1Char('/') + filename);
|
||||
if (!f.open(QIODevice::WriteOnly))
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Can not open file '" << f.fileName() << "' for writing!";
|
||||
pExportNotifier->setExportFailed();
|
||||
return false;
|
||||
}
|
||||
QJsonObject obj;
|
||||
obj[QStringLiteral("attributes")] = attributes;
|
||||
obj[QStringLiteral("timeInPresentation")] = timeRange(m_startTimeSec * 1000,
|
||||
(m_startTimeSec + m_durationSec) * 1000);
|
||||
|
||||
QJsonArray arr;
|
||||
for (const SituationReplayTime &rt : std::as_const(m_sitReplayTimes))
|
||||
{
|
||||
if (m_startTimeSec > rt.topicEnd_s)
|
||||
continue;
|
||||
const double lenReplay = rt.replayEnd_ms - rt.replayStart_ms;
|
||||
const double endReplay = rt.replayStart_ms + lenReplay;
|
||||
|
||||
const double maxReplay = std::min(rt.replayStart_ms + m_durationSec * 1000. * rt.replaySpeedFactor, endReplay);
|
||||
arr.push_back(rt.toJson(maxReplay));
|
||||
}
|
||||
obj[QStringLiteral("replays")] = arr;
|
||||
f.write(QJsonDocument(obj).toJson(QJsonDocument::Indented));
|
||||
f.close();
|
||||
DEBUG_LOG(m_logger) << "BDV filename: " << f.fileName();
|
||||
|
||||
QVector<int> buildingIds;
|
||||
buildingIds.reserve(states.size());
|
||||
for (const auto &ele : states)
|
||||
{
|
||||
const ViewWidgetState vws(ele.toObject());
|
||||
int buildingId = featureId2DatabaseId(QString::fromStdString(vws.m_featureID));
|
||||
if (buildingId <= 0)
|
||||
const QJsonArray states = attributes[QStringLiteral("arrBuildingStates")].toArray();
|
||||
if (states.isEmpty())
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Could not retrieve building id from '" << vws.m_featureID << "' - skipping";
|
||||
continue;
|
||||
INFO_LOG(m_logger) << "Nothing to export";
|
||||
emit pExportNotifier->exportSuccessful(QString());
|
||||
return true;
|
||||
}
|
||||
buildingIds += buildingId;
|
||||
}
|
||||
|
||||
emit pExportNotifier->stillAlive();
|
||||
if (!exportBuildings(buildingIds) ||
|
||||
!exportShaders())
|
||||
{
|
||||
pExportNotifier->setExportFailed();
|
||||
return false;
|
||||
}
|
||||
|
||||
const QString outputPath(m_basePath + QStringLiteral("BuildingModels/"));
|
||||
QFile fBdv(outputPath + QStringLiteral("/buildings.json"));
|
||||
if (fBdv.exists())
|
||||
{
|
||||
fBdv.copy(folderPath + QStringLiteral("/../buildings.json"));
|
||||
}
|
||||
const QString filename(QStringLiteral("buildingViewer.json"));
|
||||
QFile f(folderPath + QLatin1Char('/') + filename);
|
||||
if (!f.open(QIODevice::WriteOnly))
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Can not open file '" << f.fileName() << "' for writing!";
|
||||
pExportNotifier->setExportFailed();
|
||||
return false;
|
||||
}
|
||||
QJsonObject obj;
|
||||
obj[QStringLiteral("attributes")] = attributes;
|
||||
obj[QStringLiteral("timeInPresentation")] =
|
||||
timeRange(m_startTimeSec * 1000, (m_startTimeSec + m_durationSec) * 1000);
|
||||
|
||||
emit pExportNotifier->exportSuccessful(filename);
|
||||
QJsonArray arr;
|
||||
for (const SituationReplayTime& rt : std::as_const(m_sitReplayTimes))
|
||||
{
|
||||
if (m_startTimeSec > rt.topicEnd_s)
|
||||
continue;
|
||||
const double lenReplay = rt.replayEnd_ms - rt.replayStart_ms;
|
||||
const double endReplay = rt.replayStart_ms + lenReplay;
|
||||
|
||||
const double maxReplay = std::min(rt.replayStart_ms + m_durationSec * 1000. * rt.replaySpeedFactor, endReplay);
|
||||
arr.push_back(rt.toJson(maxReplay));
|
||||
}
|
||||
obj[QStringLiteral("replays")] = arr;
|
||||
f.write(QJsonDocument(obj).toJson(QJsonDocument::Indented));
|
||||
f.close();
|
||||
DEBUG_LOG(m_logger) << "BDV filename: " << f.fileName();
|
||||
|
||||
QVector<int> buildingIds;
|
||||
buildingIds.reserve(states.size());
|
||||
for (const auto& ele : states)
|
||||
{
|
||||
const ViewWidgetState vws(ele.toObject());
|
||||
int buildingId = featureId2DatabaseId(QString::fromStdString(vws.m_featureID));
|
||||
if (buildingId <= 0)
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Could not retrieve building id from '" << vws.m_featureID << "' - skipping";
|
||||
continue;
|
||||
}
|
||||
buildingIds += buildingId;
|
||||
}
|
||||
|
||||
emit pExportNotifier->stillAlive();
|
||||
if (!exportBuildings(buildingIds) || !exportShaders())
|
||||
{
|
||||
pExportNotifier->setExportFailed();
|
||||
return false;
|
||||
}
|
||||
|
||||
const QString outputPath(m_basePath + QStringLiteral("BuildingModels/"));
|
||||
QFile fBdv(outputPath + QStringLiteral("/buildings.json"));
|
||||
if (fBdv.exists())
|
||||
{
|
||||
fBdv.copy(folderPath + QStringLiteral("/../buildings.json"));
|
||||
}
|
||||
|
||||
emit pExportNotifier->exportSuccessful(filename);
|
||||
#else
|
||||
|
||||
if (!m_replayIfc || !m_bgvController)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "BuildingViewer exportTopic: m_replayIfc==nullptr, can not start replay, aborting export";
|
||||
emit pExportNotifier->exportFailed();
|
||||
Q_ASSERT(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
playbackInit(attributes);
|
||||
if (!m_replayIfc || !m_bgvController)
|
||||
{
|
||||
ERROR_LOG(m_logger)
|
||||
<< "BuildingViewer exportTopic: m_replayIfc==nullptr, can not start replay, aborting export";
|
||||
emit pExportNotifier->exportFailed();
|
||||
Q_ASSERT(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
qint64 record_duration_s = m_durationSec + 2;
|
||||
|
||||
QVector<QSharedPointer<ReplayHandler>> vecReplayHandler;
|
||||
vecReplayHandler.reserve(m_sitReplayTimes.size());
|
||||
for (const SituationReplayTime &srt : std::as_const(m_sitReplayTimes))
|
||||
vecReplayHandler.push_back(QSharedPointer<ReplayHandler>(new ReplayHandler(m_startTimeSec, m_startTimeSec + m_durationSec, srt)));
|
||||
playbackInit(attributes);
|
||||
|
||||
VideoInformation info(pExportNotifier, folderPath, attributes, vecReplayHandler, record_duration_s);
|
||||
qint64 record_duration_s = m_durationSec + 2;
|
||||
|
||||
VideoExporter *videoExporter = new VideoExporter;
|
||||
videoExporter->init(info);
|
||||
QVector<QSharedPointer<ReplayHandler>> vecReplayHandler;
|
||||
vecReplayHandler.reserve(m_sitReplayTimes.size());
|
||||
for (const SituationReplayTime& srt : std::as_const(m_sitReplayTimes))
|
||||
vecReplayHandler.push_back(
|
||||
QSharedPointer<ReplayHandler>(new ReplayHandler(m_startTimeSec, m_startTimeSec + m_durationSec, srt)));
|
||||
|
||||
Q_ASSERT(!m_tveThread);
|
||||
m_tveThread = new QThread(this);
|
||||
videoExporter->moveToThread(m_tveThread);
|
||||
VideoInformation info(pExportNotifier, folderPath, attributes, vecReplayHandler, record_duration_s);
|
||||
|
||||
connect(videoExporter, &VideoExporter::signalStartReplay,
|
||||
this, &TopicReplayInterface::slotStartReplay);
|
||||
connect(videoExporter, &VideoExporter::signalStopReplay,
|
||||
this, &TopicReplayInterface::slotStopReplay);
|
||||
VideoExporter* videoExporter = new VideoExporter;
|
||||
videoExporter->init(info);
|
||||
|
||||
|
||||
Q_ASSERT(!m_tveThread);
|
||||
m_tveThread = new QThread(this);
|
||||
videoExporter->moveToThread(m_tveThread);
|
||||
|
||||
connect(videoExporter, &VideoExporter::signalStartRecording,
|
||||
m_bgvController, &BgViewerController::slotStartRecording, Qt::BlockingQueuedConnection);
|
||||
connect(videoExporter, &VideoExporter::signalStopRecording,
|
||||
m_bgvController, &BgViewerController::slotStopRecording, Qt::BlockingQueuedConnection);
|
||||
connect(videoExporter, &VideoExporter::signalStartReplay, this, &TopicReplayInterface::slotStartReplay);
|
||||
connect(videoExporter, &VideoExporter::signalStopReplay, this, &TopicReplayInterface::slotStopReplay);
|
||||
|
||||
connect(m_tveThread, &QThread::started, videoExporter, &VideoExporter::doExport);
|
||||
connect(m_tveThread, &QThread::finished, videoExporter, &VideoExporter::deleteLater);
|
||||
connect(videoExporter, &VideoExporter::signalStartRecording, m_bgvController,
|
||||
&BgViewerController::slotStartRecording, Qt::BlockingQueuedConnection);
|
||||
connect(videoExporter, &VideoExporter::signalStopRecording, m_bgvController, &BgViewerController::slotStopRecording,
|
||||
Qt::BlockingQueuedConnection);
|
||||
|
||||
m_tveThread->start();
|
||||
connect(m_tveThread, &QThread::started, videoExporter, &VideoExporter::doExport);
|
||||
connect(m_tveThread, &QThread::finished, videoExporter, &VideoExporter::deleteLater);
|
||||
|
||||
m_tveThread->start();
|
||||
#endif
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TopicReplayInterface::exportBuildings(const QVector<int> &buildingIds) const
|
||||
bool TopicReplayInterface::exportBuildings(const QVector<int>& buildingIds) const
|
||||
{
|
||||
std::shared_ptr<InfrastructureManagement::Interface::Dtc> ismDtc;
|
||||
if (!m_session->getDtc<InfrastructureManagement::DataInterface>(ismDtc))
|
||||
return false;
|
||||
const QString modelPath = BgViewerController::buildingModelPath();
|
||||
if (modelPath.isEmpty())
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Could not find path with building models - can not copy models";
|
||||
return false;
|
||||
}
|
||||
|
||||
const QString outputPath(m_basePath + QStringLiteral("BuildingModels/"));
|
||||
QDir dir(outputPath);
|
||||
if (!dir.exists() && !dir.mkpath(outputPath))
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Could not create path " << outputPath;
|
||||
return false;
|
||||
}
|
||||
QFile f(outputPath + QStringLiteral("/buildings.json"));
|
||||
if (!f.open(QIODevice::ReadWrite))
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Could not open file " << f.fileName() << " for read/write: " << f.errorString();
|
||||
return false;
|
||||
}
|
||||
const QJsonArray arr(QJsonDocument::fromJson(f.readAll()).array());
|
||||
QVector<BuildingInfo> knownBuildings;
|
||||
knownBuildings.reserve(arr.size());
|
||||
for (const auto &ele : arr)
|
||||
{
|
||||
const auto bi = BuildingInfo::fromJson(ele.toObject());
|
||||
if (bi.isValid())
|
||||
knownBuildings += bi;
|
||||
}
|
||||
|
||||
BuildingInfo bi;
|
||||
for (const int buildingId : buildingIds)
|
||||
{
|
||||
const auto mse = ismDtc->mainStructureElement(buildingId);
|
||||
if (mse.id() != buildingId)
|
||||
std::shared_ptr<InfrastructureManagement::Interface::Dtc> ismDtc;
|
||||
if (!m_session->getDtc<InfrastructureManagement::DataInterface>(ismDtc))
|
||||
return false;
|
||||
const QString modelPath = BgViewerController::buildingModelPath();
|
||||
if (modelPath.isEmpty())
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Could not find MainStructureElement for building with id " << buildingId << " - skipping";
|
||||
continue;
|
||||
WARNING_LOG(m_logger) << "Could not find path with building models - can not copy models";
|
||||
return false;
|
||||
}
|
||||
const QString fnIve = QString::fromStdString(mse.name()) + QStringLiteral(".flt.ive");
|
||||
const QString fnXml = QString::fromStdString(mse.name()) + QStringLiteral(".flt.xml");
|
||||
if (!copyFile(fnIve, modelPath, outputPath) ||
|
||||
!copyFile(fnXml, modelPath, outputPath))
|
||||
return false;
|
||||
bi.name = QString::fromStdString(mse.name());
|
||||
bi.position = LtsUtils::QPoint3D(mse.geoPosition().lon(), mse.geoPosition().lat(), mse.geoPosition().z());
|
||||
bi.angleDegree = mse.angle();
|
||||
bi.id = mse.id();
|
||||
|
||||
knownBuildings += bi;
|
||||
}
|
||||
const QString outputPath(m_basePath + QStringLiteral("BuildingModels/"));
|
||||
QDir dir(outputPath);
|
||||
if (!dir.exists() && !dir.mkpath(outputPath))
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Could not create path " << outputPath;
|
||||
return false;
|
||||
}
|
||||
QFile f(outputPath + QStringLiteral("/buildings.json"));
|
||||
if (!f.open(QIODevice::ReadWrite))
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Could not open file " << f.fileName() << " for read/write: " << f.errorString();
|
||||
return false;
|
||||
}
|
||||
const QJsonArray arr(QJsonDocument::fromJson(f.readAll()).array());
|
||||
QVector<BuildingInfo> knownBuildings;
|
||||
knownBuildings.reserve(arr.size());
|
||||
for (const auto& ele : arr)
|
||||
{
|
||||
const auto bi = BuildingInfo::fromJson(ele.toObject());
|
||||
if (bi.isValid())
|
||||
knownBuildings += bi;
|
||||
}
|
||||
|
||||
std::sort(knownBuildings.begin(), knownBuildings.end(),
|
||||
[](const BuildingInfo &a, const BuildingInfo &b)
|
||||
{
|
||||
return a.id < b.id;
|
||||
});
|
||||
knownBuildings.erase(std::unique(knownBuildings.begin(), knownBuildings.end()), knownBuildings.end());
|
||||
QJsonArray arrOut;
|
||||
for (const auto &b : std::as_const(knownBuildings))
|
||||
arrOut += b.toJson();
|
||||
BuildingInfo bi;
|
||||
for (const int buildingId : buildingIds)
|
||||
{
|
||||
const auto mse = ismDtc->mainStructureElement(buildingId);
|
||||
if (mse.id() != buildingId)
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Could not find MainStructureElement for building with id " << buildingId
|
||||
<< " - skipping";
|
||||
continue;
|
||||
}
|
||||
const QString fnIve = QString::fromStdString(mse.name()) + QStringLiteral(".flt.ive");
|
||||
const QString fnXml = QString::fromStdString(mse.name()) + QStringLiteral(".flt.xml");
|
||||
if (!copyFile(fnIve, modelPath, outputPath) || !copyFile(fnXml, modelPath, outputPath))
|
||||
return false;
|
||||
bi.name = QString::fromStdString(mse.name());
|
||||
bi.position = LtsUtils::QPoint3D(mse.geoPosition().lon(), mse.geoPosition().lat(), mse.geoPosition().z());
|
||||
bi.angleDegree = mse.angle();
|
||||
bi.id = mse.id();
|
||||
|
||||
f.resize(0);
|
||||
f.seek(0);
|
||||
f.write(QJsonDocument(arrOut).toJson());
|
||||
f.close();
|
||||
return true;
|
||||
knownBuildings += bi;
|
||||
}
|
||||
|
||||
std::sort(knownBuildings.begin(), knownBuildings.end(),
|
||||
[](const BuildingInfo& a, const BuildingInfo& b) { return a.id < b.id; });
|
||||
knownBuildings.erase(std::unique(knownBuildings.begin(), knownBuildings.end()), knownBuildings.end());
|
||||
QJsonArray arrOut;
|
||||
for (const auto& b : std::as_const(knownBuildings))
|
||||
arrOut += b.toJson();
|
||||
|
||||
f.resize(0);
|
||||
f.seek(0);
|
||||
f.write(QJsonDocument(arrOut).toJson());
|
||||
f.close();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TopicReplayInterface::exportShaders() const
|
||||
{
|
||||
const QString shaderPath(NGL::findFile(NGL::FileType::ConfigFile, QStringLiteral("shaders")));
|
||||
const QString outputPath(m_basePath + QStringLiteral("BuildingModels/shaders/"));
|
||||
DEBUG_LOG(m_logger) << "shaderPath: " << shaderPath << ", outputPath: " << outputPath;
|
||||
return NGL::copyDirContentsToDir(shaderPath, outputPath);
|
||||
const QString shaderPath(NGL::findFile(NGL::FileType::ConfigFile, QStringLiteral("shaders")));
|
||||
const QString outputPath(m_basePath + QStringLiteral("BuildingModels/shaders/"));
|
||||
DEBUG_LOG(m_logger) << "shaderPath: " << shaderPath << ", outputPath: " << outputPath;
|
||||
return NGL::copyDirContentsToDir(shaderPath, outputPath);
|
||||
}
|
||||
|
||||
|
||||
bool TopicReplayInterface::copyFile(const QString &srcFn, const QString &srcDir, const QString &dstDir) const
|
||||
bool TopicReplayInterface::copyFile(const QString& srcFn, const QString& srcDir, const QString& dstDir) const
|
||||
{
|
||||
const QString src = srcDir + QLatin1Char('/') + srcFn;
|
||||
const QString dst = dstDir + QLatin1Char('/') + srcFn;
|
||||
QFile f(src);
|
||||
if (!f.exists() || (!QFile::exists(dst) && !f.copy(dst)))
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Could not copy " << src << " to " << dst << ": " << f.errorString();
|
||||
return false;
|
||||
}
|
||||
DEBUG_LOG(m_logger) << "Copied from " << src << " to " << dst;
|
||||
return true;
|
||||
const QString src = srcDir + QLatin1Char('/') + srcFn;
|
||||
const QString dst = dstDir + QLatin1Char('/') + srcFn;
|
||||
QFile f(src);
|
||||
if (!f.exists() || (!QFile::exists(dst) && !f.copy(dst)))
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Could not copy " << src << " to " << dst << ": " << f.errorString();
|
||||
return false;
|
||||
}
|
||||
DEBUG_LOG(m_logger) << "Copied from " << src << " to " << dst;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace BuildingViewer
|
||||
Executable → Regular
+38
-36
@@ -1,18 +1,18 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Plugins/BuildingViewer/bdv_viewer_gui_plugin_interface.h>
|
||||
#include <Plugins/SituationReplay/srp_gui_plugin_interface.h>
|
||||
#include <QObject>
|
||||
#include <QVector>
|
||||
#include <Plugins/SituationReplay/srp_gui_plugin_interface.h>
|
||||
#include <Plugins/BuildingViewer/bdv_viewer_gui_plugin_interface.h>
|
||||
#include <memory>
|
||||
|
||||
namespace NGL
|
||||
{
|
||||
class INGLLogger;
|
||||
}
|
||||
|
||||
namespace LtsSession
|
||||
{
|
||||
class LtsSession;
|
||||
@@ -23,45 +23,47 @@ namespace BuildingViewer
|
||||
class InterfaceImpl;
|
||||
class BgViewerController;
|
||||
|
||||
|
||||
class TopicReplayInterface final : public QObject, public TopicReplay::Interface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TopicReplayInterface(BgViewerController *bgvController, LtsSession::LtsSession *session);
|
||||
~TopicReplayInterface();
|
||||
public:
|
||||
explicit TopicReplayInterface(BgViewerController* bgvController, LtsSession::LtsSession* session);
|
||||
~TopicReplayInterface();
|
||||
|
||||
QWidget *createWidget() override;
|
||||
bool playbackInit(const QJsonObject &attributes) override;
|
||||
void setExportPlaybackTimes(qint64 startTimeSec,
|
||||
qint64 durationSec,
|
||||
const QVector<SituationReplayTime> &sitReplayTimes) override;
|
||||
bool exportTopic(const QJsonObject &attributes,
|
||||
const QString &folderPath,
|
||||
TopicEditorBase::ExportNotifier *pExportNotifier) override;
|
||||
QWidget* createWidget() override;
|
||||
bool playbackInit(const QJsonObject& attributes) override;
|
||||
void setExportPlaybackTimes(qint64 startTimeSec, qint64 durationSec,
|
||||
const QVector<SituationReplayTime>& sitReplayTimes) override;
|
||||
bool exportTopic(const QJsonObject& attributes, const QString& folderPath,
|
||||
TopicEditorBase::ExportNotifier* pExportNotifier) override;
|
||||
|
||||
void setBasePath(const QString &basePath) override { m_basePath = basePath; }
|
||||
void setBasePath(const QString& basePath) override
|
||||
{
|
||||
m_basePath = basePath;
|
||||
}
|
||||
|
||||
private slots:
|
||||
void slotStartReplay(qint64 start, qint64 end, double speed);
|
||||
void slotStopReplay();
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
bool exportBuildings(const QVector<int> &buildingIds) const;
|
||||
bool exportShaders() const;
|
||||
bool copyFile(const QString &srcFn, const QString &srcDir, const QString &dstDir) const;
|
||||
private:
|
||||
qint64 m_startTimeSec = 0;
|
||||
qint64 m_durationSec = 0;
|
||||
QVector<SituationReplayTime> m_sitReplayTimes;
|
||||
std::shared_ptr<SituationReplay::ForeignGuiInterface> m_replayIfc;
|
||||
QString m_basePath;
|
||||
QWidget *m_pBgViewerWidget = nullptr;
|
||||
private slots:
|
||||
void slotStartReplay(qint64 start, qint64 end, double speed);
|
||||
void slotStopReplay();
|
||||
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
bool exportBuildings(const QVector<int>& buildingIds) const;
|
||||
bool exportShaders() const;
|
||||
bool copyFile(const QString& srcFn, const QString& srcDir, const QString& dstDir) const;
|
||||
|
||||
private:
|
||||
qint64 m_startTimeSec = 0;
|
||||
qint64 m_durationSec = 0;
|
||||
QVector<SituationReplayTime> m_sitReplayTimes;
|
||||
std::shared_ptr<SituationReplay::ForeignGuiInterface> m_replayIfc;
|
||||
QString m_basePath;
|
||||
QWidget* m_pBgViewerWidget = nullptr;
|
||||
#ifndef EXPORT_BDV_TOPIC_AS_JSON
|
||||
QThread *m_tveThread = nullptr;
|
||||
QThread* m_tveThread = nullptr;
|
||||
#endif
|
||||
BgViewerController *m_bgvController = nullptr;
|
||||
LtsSession::LtsSession *m_session = nullptr;
|
||||
BgViewerController* m_bgvController = nullptr;
|
||||
LtsSession::LtsSession* m_session = nullptr;
|
||||
};
|
||||
}
|
||||
} // namespace BuildingViewer
|
||||
Executable → Regular
+19
-20
@@ -1,44 +1,43 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Common/logger.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <Plugins/InfrastructureManagement/ism_data_plugin_interface.h>
|
||||
#include <Common/logger.h>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class BgViewerDataViewDialog;
|
||||
}
|
||||
|
||||
|
||||
namespace BuildingViewer
|
||||
{
|
||||
class BgViewerController;
|
||||
|
||||
class BgViewerDataViewDialog : public LtsWidgets::LtsDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit BgViewerDataViewDialog(QWidget *parent = nullptr);
|
||||
~BgViewerDataViewDialog();
|
||||
public:
|
||||
explicit BgViewerDataViewDialog(QWidget* parent = nullptr);
|
||||
~BgViewerDataViewDialog();
|
||||
|
||||
bool init(BgViewerController *pBdvController,
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc> &ismDtc,
|
||||
bool fetchBuildingDataOnCreation);
|
||||
bool init(BgViewerController* pBdvController,
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc>& ismDtc,
|
||||
bool fetchBuildingDataOnCreation);
|
||||
|
||||
public Q_SLOTS:
|
||||
void fetchBuildingList();
|
||||
protected:
|
||||
NGL::INGLLogger &m_logger;
|
||||
void retranslate() override;
|
||||
public Q_SLOTS:
|
||||
void fetchBuildingList();
|
||||
|
||||
signals:
|
||||
void signalEditBuilding(const QString &strFeatureID);
|
||||
protected:
|
||||
NGL::INGLLogger& m_logger;
|
||||
void retranslate() override;
|
||||
|
||||
private:
|
||||
Ui::BgViewerDataViewDialog *m_ui;
|
||||
signals:
|
||||
void signalEditBuilding(const QString& strFeatureID);
|
||||
|
||||
private:
|
||||
Ui::BgViewerDataViewDialog* m_ui;
|
||||
};
|
||||
}
|
||||
} // namespace BuildingViewer
|
||||
Executable → Regular
+29
-34
@@ -1,19 +1,16 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
#include <Plugins/InfrastructureManagement/ism_data_plugin_interface.h>
|
||||
#include <Common/logger.h>
|
||||
|
||||
#include <Plugins/InfrastructureManagement/ism_data_plugin_interface.h>
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class BgViewerDataView;
|
||||
}
|
||||
|
||||
|
||||
namespace BuildingViewer
|
||||
{
|
||||
class BgViewerDataViewModel;
|
||||
@@ -21,40 +18,38 @@ class BgViewerController;
|
||||
|
||||
class BgViewerDataView final : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit BgViewerDataView(QWidget *parent = nullptr);
|
||||
~BgViewerDataView();
|
||||
public:
|
||||
explicit BgViewerDataView(QWidget* parent = nullptr);
|
||||
~BgViewerDataView();
|
||||
|
||||
bool init(BgViewerController *pBgvController,
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc> &ismDtc,
|
||||
bool fetchBuildingDataOnCreation);
|
||||
bool init(BgViewerController* pBgvController,
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc>& ismDtc,
|
||||
bool fetchBuildingDataOnCreation);
|
||||
|
||||
bool eventFilter(QObject *object, QEvent *event) override;
|
||||
bool eventFilter(QObject* object, QEvent* event) override;
|
||||
|
||||
public slots:
|
||||
void fetchBuildingList();
|
||||
void onLtsDataView_DoubleClicked();
|
||||
void onLtsDataView_selectionChanged();
|
||||
void onLtsDataView_onEditBuilding();
|
||||
public slots:
|
||||
void fetchBuildingList();
|
||||
void onLtsDataView_DoubleClicked();
|
||||
void onLtsDataView_selectionChanged();
|
||||
void onLtsDataView_onEditBuilding();
|
||||
|
||||
signals:
|
||||
void signalUserActionPerformend();
|
||||
void signalCurrentSelectionChanged(const QModelIndex &idx);
|
||||
void signalEditBuilding(const QString &strFeatureID);
|
||||
signals:
|
||||
void signalUserActionPerformend();
|
||||
void signalCurrentSelectionChanged(const QModelIndex& idx);
|
||||
void signalEditBuilding(const QString& strFeatureID);
|
||||
|
||||
public slots:
|
||||
void onViewerEventWidgetMaximized(const QString& featureID);
|
||||
void onViewerEventWidgetFocused(const QString& featureID);
|
||||
|
||||
public slots:
|
||||
void onViewerEventWidgetMaximized(const QString &featureID);
|
||||
void onViewerEventWidgetFocused(const QString &featureID);
|
||||
|
||||
private:
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
Ui::BgViewerDataView *m_ui = nullptr;
|
||||
BgViewerDataViewModel *m_pModel = nullptr;
|
||||
BgViewerController *m_pBgvController = nullptr;
|
||||
int m_lastSelectedRow { -1 };
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
Ui::BgViewerDataView* m_ui = nullptr;
|
||||
BgViewerDataViewModel* m_pModel = nullptr;
|
||||
BgViewerController* m_pBgvController = nullptr;
|
||||
int m_lastSelectedRow{-1};
|
||||
};
|
||||
}
|
||||
} // namespace BuildingViewer
|
||||
Executable → Regular
+36
-45
@@ -1,87 +1,78 @@
|
||||
|
||||
|
||||
|
||||
#include "bdv_viewer_gui_plugin_provider.h"
|
||||
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <AdvancedSymbology/asb_data_plugin_interface.h>
|
||||
#include <AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
#include <AudioVideoManagement/avm_data_plugin_interface.h>
|
||||
#include <Buildings/bld_data_plugin_interface.h>
|
||||
#include <Buildings/bld_info_gui_plugin_interface.h>
|
||||
#include <InfrastructureManagement/ism_data_plugin_interface.h>
|
||||
#include <SituationReplay/srp_data_plugin_interface.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
#include <ProjectDataManagement/pdm_data_plugin_interface.h>
|
||||
#include <ParticipantManagement/ppm_participant_info_gui_plugin_interface.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <ProjectDataManagement/pdm_data_plugin_interface.h>
|
||||
#include <SituationReplay/srp_data_plugin_interface.h>
|
||||
|
||||
namespace BuildingViewer
|
||||
{
|
||||
|
||||
BdvPluginProvider::BdvPluginProvider(LtsSession::LtsSession *session, QObject *parent) : PluginProvider(parent)
|
||||
, m_session(session),
|
||||
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {}
|
||||
BdvPluginProvider::BdvPluginProvider(LtsSession::LtsSession* session, QObject* parent)
|
||||
: PluginProvider(parent), m_session(session), m_logger(NGL::NGLLoggerBootstrap::getLogger())
|
||||
{
|
||||
}
|
||||
|
||||
bool BdvPluginProvider::init()
|
||||
{
|
||||
m_session->getForeignDataInterface<AdvancedSymbology::DataInterface>(m_asbIfc);
|
||||
m_session->getDtc<SituationReplay::DataInterface>(m_srpDtc);
|
||||
m_session->getDtc<ProjectDataManagement::DataInterface>(m_pdmDtc);
|
||||
m_session->getDtc<AreaEffectSimulation::DataInterface>(m_aesDtc);
|
||||
m_session->getForeignDataInterface<AdvancedSymbology::DataInterface>(m_asbIfc);
|
||||
m_session->getDtc<SituationReplay::DataInterface>(m_srpDtc);
|
||||
m_session->getDtc<ProjectDataManagement::DataInterface>(m_pdmDtc);
|
||||
m_session->getDtc<AreaEffectSimulation::DataInterface>(m_aesDtc);
|
||||
|
||||
m_session->getForeignDataInterface_NEW<AudioVideoManagement::DataInterface>(m_avmDataIfc);
|
||||
m_session->getForeignDataInterface_NEW<AudioVideoManagement::DataInterface>(m_avmDataIfc);
|
||||
|
||||
if (!m_session->getDtc<Buildings::DataInterface>(m_bldDtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Fetching 'm_bldDtc' failed!";
|
||||
return false;
|
||||
}
|
||||
m_session->getForeignGuiInterface<Buildings::ForeignInfoGuiInterface>(m_bldInfoIfc);
|
||||
|
||||
if (!m_session->getDtc<Buildings::DataInterface>(m_bldDtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Fetching 'm_bldDtc' failed!";
|
||||
return false;
|
||||
}
|
||||
m_session->getForeignGuiInterface<Buildings::ForeignInfoGuiInterface>(m_bldInfoIfc);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (!m_session->getDtc<ParticipantManagement::DataInterface>(m_ppmDtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Fetching 'm_ppmDtc' failed!";
|
||||
return false;
|
||||
}
|
||||
m_session->getForeignGuiInterface<ParticipantManagement::ForeignParticipantInfoGuiInterface>(m_ppmParticipantInfoIfc);
|
||||
return true;
|
||||
if (!m_session->getDtc<ParticipantManagement::DataInterface>(m_ppmDtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Fetching 'm_ppmDtc' failed!";
|
||||
return false;
|
||||
}
|
||||
m_session->getForeignGuiInterface<ParticipantManagement::ForeignParticipantInfoGuiInterface>(
|
||||
m_ppmParticipantInfoIfc);
|
||||
return true;
|
||||
}
|
||||
|
||||
QString BdvPluginProvider::toString() const
|
||||
{
|
||||
return m_session ? m_session->toString() : QStringLiteral("????");
|
||||
return m_session ? m_session->toString() : QStringLiteral("????");
|
||||
}
|
||||
|
||||
LtsSession::DdsConnectionParams BdvPluginProvider::connParams() const
|
||||
{
|
||||
return m_session ? m_session->connParams() : LtsSession::DdsConnectionParams();
|
||||
return m_session ? m_session->connParams() : LtsSession::DdsConnectionParams();
|
||||
}
|
||||
|
||||
std::shared_ptr<InfrastructureManagement::ForeignDataInterface> BdvPluginProvider::ismDataIfc() const
|
||||
{
|
||||
if (!m_ismDataIfc)
|
||||
m_session->getForeignDataInterface<InfrastructureManagement::DataInterface>(m_ismDataIfc);
|
||||
if (!m_ismDataIfc)
|
||||
m_session->getForeignDataInterface<InfrastructureManagement::DataInterface>(m_ismDataIfc);
|
||||
|
||||
return m_ismDataIfc;
|
||||
return m_ismDataIfc;
|
||||
}
|
||||
|
||||
std::shared_ptr<InfrastructureManagement::Interface::Dtc> BdvPluginProvider::ismDtc() const
|
||||
{
|
||||
if (!m_ismDtc)
|
||||
m_session->getDtc<InfrastructureManagement::DataInterface>(m_ismDtc);
|
||||
if (!m_ismDtc)
|
||||
m_session->getDtc<InfrastructureManagement::DataInterface>(m_ismDtc);
|
||||
|
||||
return m_ismDtc;
|
||||
return m_ismDtc;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace BuildingViewer
|
||||
Executable → Regular
+89
-38
@@ -1,6 +1,5 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Common/bdv_plugin_provider.h>
|
||||
@@ -12,59 +11,111 @@ namespace LtsSession
|
||||
{
|
||||
class LtsSession;
|
||||
}
|
||||
|
||||
namespace BuildingViewer
|
||||
{
|
||||
|
||||
class BdvPluginProvider : public PluginProvider
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit BdvPluginProvider(LtsSession::LtsSession *session, QObject *parent = nullptr);
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit BdvPluginProvider(LtsSession::LtsSession* session, QObject* parent = nullptr);
|
||||
|
||||
bool init();
|
||||
bool init();
|
||||
|
||||
QString toString() const override;
|
||||
QString toString() const override;
|
||||
|
||||
int exerciseId() const override { return m_session ? m_session->exerciseId() : -1; }
|
||||
qint64 partitionTime() const override { return m_session ? m_session->partitionTime() : 0; }
|
||||
bool isReplayPartition() const override { return m_session ? m_session->isReplayPartition() : false; }
|
||||
bool isVisibleParty(int partyId) const override { return LtsSessionData::LtsSessionData::getInstance()->isVisibleParty(exerciseId(), partyId); }
|
||||
quintptr adr() const override {return (quintptr)m_session;}
|
||||
int exerciseId() const override
|
||||
{
|
||||
return m_session ? m_session->exerciseId() : -1;
|
||||
}
|
||||
|
||||
LtsSession::DdsConnectionParams connParams() const override;
|
||||
qint64 partitionTime() const override
|
||||
{
|
||||
return m_session ? m_session->partitionTime() : 0;
|
||||
}
|
||||
|
||||
std::shared_ptr<AdvancedSymbology::ForeignDataInterface> asbIfc() const override { return m_asbIfc; }
|
||||
std::shared_ptr<AudioVideoManagement::ForeignDataInterface> avmDataIfc() const override { return m_avmDataIfc; }
|
||||
std::shared_ptr<Buildings::Interface::Dtc> bldDtc() const override { return m_bldDtc; }
|
||||
std::shared_ptr<Buildings::ForeignInfoGuiInterface> bldInfoIfc() const override { return m_bldInfoIfc; }
|
||||
std::shared_ptr<InfrastructureManagement::Interface::Dtc> ismDtc() const override;
|
||||
std::shared_ptr<InfrastructureManagement::ForeignDataInterface> ismDataIfc() const override;
|
||||
std::shared_ptr<AreaEffectSimulation::Interface::Dtc> aesDtc() const override { return m_aesDtc; }
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> ppmDtc() const override { return m_ppmDtc; }
|
||||
std::shared_ptr<ProjectDataManagement::Interface::Dtc> pdmDtc() const override { return m_pdmDtc; }
|
||||
bool isReplayPartition() const override
|
||||
{
|
||||
return m_session ? m_session->isReplayPartition() : false;
|
||||
}
|
||||
|
||||
std::shared_ptr<SituationReplay::Interface::Dtc> srpDtc() const override { return m_srpDtc; }
|
||||
bool isVisibleParty(int partyId) const override
|
||||
{
|
||||
return LtsSessionData::LtsSessionData::getInstance()->isVisibleParty(exerciseId(), partyId);
|
||||
}
|
||||
|
||||
std::shared_ptr<ParticipantManagement::ForeignParticipantInfoGuiInterface> ppmParticipantInfoIfc() const override { return m_ppmParticipantInfoIfc; }
|
||||
quintptr adr() const override
|
||||
{
|
||||
return (quintptr)m_session;
|
||||
}
|
||||
|
||||
LtsSession::DdsConnectionParams connParams() const override;
|
||||
|
||||
LtsSession::LtsSession *m_session;
|
||||
std::shared_ptr<AdvancedSymbology::ForeignDataInterface> asbIfc() const override
|
||||
{
|
||||
return m_asbIfc;
|
||||
}
|
||||
|
||||
private:
|
||||
std::shared_ptr<AudioVideoManagement::ForeignDataInterface> avmDataIfc() const override
|
||||
{
|
||||
return m_avmDataIfc;
|
||||
}
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
std::shared_ptr<AdvancedSymbology::ForeignDataInterface> m_asbIfc;
|
||||
std::shared_ptr<AudioVideoManagement::ForeignDataInterface> m_avmDataIfc;
|
||||
std::shared_ptr<Buildings::Interface::Dtc> m_bldDtc;
|
||||
std::shared_ptr<Buildings::ForeignInfoGuiInterface> m_bldInfoIfc;
|
||||
mutable std::shared_ptr<InfrastructureManagement::Interface::Dtc> m_ismDtc;
|
||||
std::shared_ptr<Buildings::Interface::Dtc> bldDtc() const override
|
||||
{
|
||||
return m_bldDtc;
|
||||
}
|
||||
|
||||
mutable std::shared_ptr<InfrastructureManagement::ForeignDataInterface> m_ismDataIfc;
|
||||
std::shared_ptr<AreaEffectSimulation::Interface::Dtc> m_aesDtc;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
std::shared_ptr<SituationReplay::Interface::Dtc> m_srpDtc;
|
||||
std::shared_ptr<ProjectDataManagement::Interface::Dtc> m_pdmDtc;
|
||||
std::shared_ptr<ParticipantManagement::ForeignParticipantInfoGuiInterface> m_ppmParticipantInfoIfc;
|
||||
std::shared_ptr<Buildings::ForeignInfoGuiInterface> bldInfoIfc() const override
|
||||
{
|
||||
return m_bldInfoIfc;
|
||||
}
|
||||
|
||||
std::shared_ptr<InfrastructureManagement::Interface::Dtc> ismDtc() const override;
|
||||
std::shared_ptr<InfrastructureManagement::ForeignDataInterface> ismDataIfc() const override;
|
||||
|
||||
std::shared_ptr<AreaEffectSimulation::Interface::Dtc> aesDtc() const override
|
||||
{
|
||||
return m_aesDtc;
|
||||
}
|
||||
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> ppmDtc() const override
|
||||
{
|
||||
return m_ppmDtc;
|
||||
}
|
||||
|
||||
std::shared_ptr<ProjectDataManagement::Interface::Dtc> pdmDtc() const override
|
||||
{
|
||||
return m_pdmDtc;
|
||||
}
|
||||
|
||||
std::shared_ptr<SituationReplay::Interface::Dtc> srpDtc() const override
|
||||
{
|
||||
return m_srpDtc;
|
||||
}
|
||||
|
||||
std::shared_ptr<ParticipantManagement::ForeignParticipantInfoGuiInterface> ppmParticipantInfoIfc() const override
|
||||
{
|
||||
return m_ppmParticipantInfoIfc;
|
||||
}
|
||||
|
||||
LtsSession::LtsSession* m_session;
|
||||
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
std::shared_ptr<AdvancedSymbology::ForeignDataInterface> m_asbIfc;
|
||||
std::shared_ptr<AudioVideoManagement::ForeignDataInterface> m_avmDataIfc;
|
||||
std::shared_ptr<Buildings::Interface::Dtc> m_bldDtc;
|
||||
std::shared_ptr<Buildings::ForeignInfoGuiInterface> m_bldInfoIfc;
|
||||
mutable std::shared_ptr<InfrastructureManagement::Interface::Dtc> m_ismDtc;
|
||||
|
||||
mutable std::shared_ptr<InfrastructureManagement::ForeignDataInterface> m_ismDataIfc;
|
||||
std::shared_ptr<AreaEffectSimulation::Interface::Dtc> m_aesDtc;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
std::shared_ptr<SituationReplay::Interface::Dtc> m_srpDtc;
|
||||
std::shared_ptr<ProjectDataManagement::Interface::Dtc> m_pdmDtc;
|
||||
std::shared_ptr<ParticipantManagement::ForeignParticipantInfoGuiInterface> m_ppmParticipantInfoIfc;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace BuildingViewer
|
||||
Reference in new issue
Block a user