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:
torstenandCopilot committed 2026-08-19 14:46:29 +02:00
1 parent 1881d68aef
commit d6b6ffce7c
848 files changed
+89305 -100020

No files matched your search

@@ -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
@@ -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
@@ -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
@@ -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)
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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