122 lines
3.4 KiB
C++
Executable File
122 lines
3.4 KiB
C++
Executable File
/**
|
|
*@RDE_HEADER@
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
* Created by Philipp Last, SLSE, 2018-03-06
|
|
*/
|
|
|
|
#include "info_dialog_base.h"
|
|
#include "bld_config_dialog.h"
|
|
#include <PluginInterfaces/gui_plugin_interface.h>
|
|
#include <Plugins/SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
|
#include <ServiceMonitor/smo_monitors_gui_plugin_interface.h>
|
|
#include <LtsSession/lts_session.h>
|
|
#include <QJsonDocument>
|
|
#include <QJsonArray>
|
|
|
|
//DDS
|
|
#include <Buildings/bld_data_plugin_interface.h>
|
|
#include <BuildingViewer/bdv_viewer_gui_plugin_interface.h>
|
|
#include <InfrastructureManagement/ism_data_plugin_interface.h>
|
|
|
|
namespace Buildings
|
|
{
|
|
|
|
InfoDialogBase::InfoDialogBase(int bldEntityId, const QString &menuGroup, const QString& strLogger, LtsWidgets::ButtonCombination bc, QWidget *parent)
|
|
: LtsWidgets::LtsDialog(parent, bc)
|
|
, m_mseId(bldEntityId)
|
|
, m_menuGroup(menuGroup)
|
|
, m_exerciseId(0)
|
|
, m_logger(getLogger(strLogger))
|
|
{
|
|
} // end of ctor()
|
|
|
|
bool InfoDialogBase::init(LtsSession::LtsSession *session)
|
|
{
|
|
m_session = session;
|
|
m_exerciseId = session->exerciseId();
|
|
if (!m_session->getDtc<Buildings::DataInterface>(m_dtc))
|
|
return false;
|
|
if (!m_session->getDtc<InfrastructureManagement::DataInterface>(m_ismDtc))
|
|
return false;
|
|
|
|
|
|
m_ismDtc->enableMainStructureElement();
|
|
/*!
|
|
\details
|
|
The dialog will be closed if the building is no mor in the same exercise
|
|
\author Niklas Schmidt
|
|
!*/
|
|
connect(m_ismDtc.get(), &InfrastructureManagement::Interface::Dtc::mainStructureElementChanged, this , [this](const InfrastructureManagement::MainStructureElement & mse, DataModification mod){
|
|
if(mod != DataModification::eModified)
|
|
return;
|
|
QJsonObject obj = QJsonDocument::fromJson(QByteArray::fromStdString(mse.properties())).object();
|
|
if(!obj.contains(QStringLiteral("available_in_exercise")))
|
|
{
|
|
deleteLater();
|
|
return;
|
|
}
|
|
int newExerciseId = obj.value(QStringLiteral("available_in_exercise")).toArray().at(0).toInt();
|
|
|
|
if(newExerciseId != m_exerciseId)
|
|
{
|
|
deleteLater();
|
|
return;
|
|
}
|
|
|
|
});
|
|
|
|
|
|
// Optional
|
|
m_session->getForeignGuiInterface<BuildingViewer::ForeignGuiInterface>(m_bdvGuiIfc);
|
|
|
|
// Optional
|
|
m_session->getForeignGuiInterface<ServiceMonitor::ForeignGuiInterface>(m_smoGuiIfc);
|
|
|
|
return true;
|
|
} // end of init()
|
|
|
|
|
|
void InfoDialogBase::onFindOnMap()
|
|
{
|
|
std::shared_ptr<SituationMap::ForeignGuiInterface> ifc;
|
|
if (m_session->getForeignGuiInterface<SituationMap::ForeignGuiInterface>(ifc))
|
|
ifc->centerMapToBuildingObject(m_mseId);
|
|
else
|
|
WARNING_LOG(m_logger) << LOGFUNCTION << "getForeignGuiInterface<SituationMap::ForeignGuiInterface> failed!";
|
|
} // end of onFindOnMap()
|
|
|
|
|
|
void InfoDialogBase::onShowDetails()
|
|
{
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION;
|
|
BldConfigDialog *dialog = new BldConfigDialog(m_mseId, buildingDisplayName(), this);
|
|
|
|
if (dialog->init(m_session))
|
|
addDialog(dialog, m_menuGroup, QStringLiteral("BuildingConfig %1").arg(m_mseId), LtsWidgets::LayoutArea::eDialogTab);
|
|
else
|
|
delete dialog;
|
|
|
|
} // end of onShowDetails()
|
|
|
|
|
|
void InfoDialogBase::onShowBuildingViewer()
|
|
{
|
|
if (!m_bdvGuiIfc)
|
|
return;
|
|
m_bdvGuiIfc->showBuildingViewer(m_session, m_mseId);
|
|
} // end of onShowBuildingViewer()
|
|
|
|
void InfoDialogBase::onShowEgcuMonitor()
|
|
{
|
|
if (!m_smoGuiIfc)
|
|
return;
|
|
int seId = m_ismDtc->mainStructureElement(m_mseId).structureElementId();
|
|
m_smoGuiIfc->showEgcuMonitor({seId},true);
|
|
|
|
} // end of onShowEgcuMonitor()
|
|
|
|
|
|
} // namespace Buildings
|