/** *@RDE_HEADER@ * $Id$ * $HeadURL$ * $Author$ * Created by Philipp Last, SLSE, 2018-03-06 */ #include "info_dialog_base.h" #include "bld_config_dialog.h" #include #include #include #include #include #include //DDS #include #include #include 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(m_dtc)) return false; if (!m_session->getDtc(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(m_bdvGuiIfc); // Optional m_session->getForeignGuiInterface(m_smoGuiIfc); return true; } // end of init() void InfoDialogBase::onFindOnMap() { std::shared_ptr ifc; if (m_session->getForeignGuiInterface(ifc)) ifc->centerMapToBuildingObject(m_mseId); else WARNING_LOG(m_logger) << LOGFUNCTION << "getForeignGuiInterface 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