158 lines
4.4 KiB
C++
Executable File
158 lines
4.4 KiB
C++
Executable File
/**
|
|
* @RDE_HEADER@
|
|
* Gui Plugin for BuildingViewer
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
*
|
|
* Created by Mike Wille, SLSE, 2017-05-15
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <PluginInterfaces/gui_plugin_interface.h>
|
|
#include <BuildingViewer/bdv_viewer_gui_plugin_interface.h>
|
|
#include <Plugins/InfrastructureManagement/ism_data_plugin_interface.h>
|
|
#include <Plugins/Buildings/bld_data_plugin_interface.h>
|
|
#include <LtsWidgets/lts_dialog.h>
|
|
#include <Common/logger.h>
|
|
#include "TopicEditor/topic_editor.h"
|
|
#include <QTimer>
|
|
|
|
|
|
class QVBoxLayout;
|
|
namespace BuildingViewer
|
|
{
|
|
class BuildingEdit;
|
|
class BgViewerController;
|
|
class BdvPluginProvider;
|
|
|
|
class GuiPlugin final : public QObject, public GuiPluginBase::Plugin
|
|
{
|
|
Q_PLUGIN_METADATA(IID "gui:3:bdv")
|
|
Q_INTERFACES(GuiPluginBase::Plugin)
|
|
|
|
Q_OBJECT
|
|
public:
|
|
explicit GuiPlugin() = default;
|
|
~GuiPlugin() = default;
|
|
|
|
QString pluginName() override
|
|
{
|
|
return QLatin1String("BuildingViewerGuiPlugin");
|
|
}
|
|
std::shared_ptr<GuiPluginBase::Interface> createGuiInterface(LtsSession::LtsSession *session) override;
|
|
bool availableInPartition(IDL::PartitionType partition) const override
|
|
{
|
|
return (partition == IDL::PartitionType::Exercise ||
|
|
partition == IDL::PartitionType::Replay);
|
|
}
|
|
};
|
|
|
|
|
|
/*
|
|
* Main widget of the BuildingViewer-Plugin.
|
|
* Used by InterfaceImpl::onShowBuildingViewerDialog
|
|
*/
|
|
class BuildingViewerLtsDialog : public LtsWidgets::LtsDialog
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
BuildingViewerLtsDialog()
|
|
: LtsWidgets::LtsDialog(nullptr, LtsWidgets::ButtonCombination::SeamlessDialog, false)
|
|
{
|
|
setUnchangeable(true);
|
|
}
|
|
|
|
void aboutToClose() override
|
|
{
|
|
emit signalHideLiveVideo();
|
|
}
|
|
|
|
signals:
|
|
void signalHideLiveVideo();
|
|
|
|
private:
|
|
void retranslate() override
|
|
{
|
|
// lupdate doesn't like translate(tr("foo")) ...
|
|
const QString txt(tr("Building Viewer"));
|
|
translate(txt);
|
|
}
|
|
};
|
|
|
|
|
|
class InterfaceImpl final : public QObject, public GuiPluginBase::Interface, public BuildingViewer::ForeignGuiInterface
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit InterfaceImpl(LtsSession::LtsSession *session);
|
|
|
|
QVector<LtsWidgets::PluginData> getActions() override;
|
|
QString menuGroup() const override
|
|
{
|
|
return tr("Building Viewer");
|
|
}
|
|
|
|
void init() override;
|
|
bool fetchInterfaces() override;
|
|
void clearInterfaces() override;
|
|
|
|
bool availableInPartition(IDL::PartitionType partition) const override
|
|
{
|
|
return (partition == IDL::PartitionType::Exercise ||
|
|
partition == IDL::PartitionType::Replay);
|
|
}
|
|
|
|
bool showBuildingViewer(LtsSession::LtsSession *parentSession, int buildingId = 0) override;
|
|
|
|
// Script Editor Topic Editor:
|
|
bool initTopicEditor() override;
|
|
void finishTopicEditor() override;
|
|
TopicEditorBase::TopicEditor *createTopicEditor(const TopicEditorBase::TopicData &data) override;
|
|
|
|
signals:
|
|
void signalFetchBuildingList();
|
|
void signalInitDone();
|
|
|
|
private slots:
|
|
BuildingViewer::BuildingEdit* onEditBuilding(const QString& featureId);
|
|
void onRoomNameClicked(const QString& featureId, const QString &strRoomId);
|
|
void closeAll(LtsSession::LtsSession *session);
|
|
bool takeOverBdv();
|
|
void onReceivedViewState(const QJsonValue &state) {m_viewState = state;}
|
|
|
|
private:
|
|
LtsWidgets::LtsDialog *onShowBuildingViewerDialog();
|
|
static std::shared_ptr<BgViewerController> getOrCreateBgViewer(bool bCreateIfNotExists = true);
|
|
// void setBgViewerSessionDependency(/*LtsSession::LtsSession *parentSession*/);
|
|
|
|
QJsonValue m_viewState;
|
|
/*
|
|
* 'InterfaceImpl::init()' is blocking the whole session/application.
|
|
* This timer emits 'slotPluginInitDone' in case the BuildingViewer
|
|
* initialization failed
|
|
*/
|
|
QTimer m_timerInitSaver;
|
|
|
|
LtsWidgets::LtsDialog *onShowSettings(QWidget *parent);
|
|
LtsWidgets::LtsDialog *onShowData(QWidget *parent);
|
|
LtsWidgets::LtsDialog *onShowState(QWidget *parent);
|
|
|
|
//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;
|
|
|
|
LtsWidgets::LtsDialog *m_pDialog = nullptr;
|
|
QVBoxLayout *m_pLayout = nullptr;
|
|
BdvPluginProvider *m_pluginProvider = nullptr;
|
|
std::shared_ptr<BgViewerController> m_bgViewerController;
|
|
int m_buildingId = 0;
|
|
bool m_iamTheApp = false;
|
|
|
|
TopicReplay::Interface *createInterface(TopicEditorBase::TopicType) override;
|
|
};
|
|
|
|
} // namespace BuildingViewer
|