Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+77
@@ -0,0 +1,77 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
# Created by hjl, SLSE, 2017-04-05
|
||||
#
|
||||
SET(bld_info_gui_SRCS
|
||||
info_dialog_base.cpp
|
||||
info_dialog_base.h
|
||||
bld_info_gui_plugin.h
|
||||
bld_info_gui_plugin.cpp
|
||||
bld_info_dialog.h
|
||||
bld_info_dialog.cpp
|
||||
egcu_info_dialog.h
|
||||
egcu_info_dialog.cpp
|
||||
bld_config_dialog.h
|
||||
bld_config_dialog.cpp
|
||||
bld_history_dialog.h
|
||||
bld_history_dialog.cpp
|
||||
bld_history_dialog_model.h
|
||||
bld_history_dialog_model.cpp
|
||||
bld_hitline_info_dialog.h
|
||||
bld_hitline_info_dialog.cpp
|
||||
bld_search.h
|
||||
bld_search.cpp
|
||||
relay_info.cpp
|
||||
relay_info.h
|
||||
bridge_info_dialog.cpp
|
||||
bridge_info_dialog.h
|
||||
bridge_history_dialog.h
|
||||
bridge_history_dialog.cpp
|
||||
bridge_history_dialog_model.h
|
||||
bridge_history_dialog_model.cpp
|
||||
)
|
||||
|
||||
NGL_WRAP_UI(bld_info_gui_SRCS
|
||||
bld_info_dialog.ui
|
||||
egcu_info_dialog.ui
|
||||
bld_config_dialog.ui
|
||||
bld_history_dialog.ui
|
||||
bld_hitline_info_dialog.ui
|
||||
relay_info.ui
|
||||
bridge_info_dialog.ui
|
||||
bridge_history_dialog.ui
|
||||
bld_search.ui
|
||||
)
|
||||
|
||||
NGL_ADD_LIBRARY(WS BldInfoGuiPlugin MODULE ${bld_info_gui_SRCS})
|
||||
NGL_TARGET_LINK_LIBRARIES(BldInfoGuiPlugin
|
||||
Qt5::Core
|
||||
BldInfoGuiPluginInterface
|
||||
BuildingViewerCommon
|
||||
NGLLogger
|
||||
ngltools
|
||||
nglsettings
|
||||
svcBldClient
|
||||
svcAsmClient
|
||||
svcBldCommon
|
||||
Qt5::Widgets
|
||||
Qt5::Network
|
||||
LtsWidgets
|
||||
LtsSession
|
||||
LtsUtilsSettings
|
||||
SituationMapGuiPluginInterface
|
||||
LtsUtilsGuiDds
|
||||
AesDataPluginInterface
|
||||
IsmDataPluginInterface
|
||||
PpmDataPluginInterface
|
||||
CesDataPluginInterface
|
||||
BdvViewerGuiPluginInterface
|
||||
SmoMonitorsGuiPluginInterface
|
||||
LtsDataView
|
||||
GuiPluginInterface
|
||||
|
||||
)
|
||||
|
||||
NGL_INSTALL_TARGET(BldInfoGuiPlugin)
|
||||
@@ -0,0 +1,169 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Buildings - BuildingsConfigDialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2017-04-20
|
||||
*/
|
||||
|
||||
#include "bld_config_dialog.h"
|
||||
#include "ui_bld_config_dialog.h"
|
||||
|
||||
// DDS
|
||||
#include <ProjectDataManagement/pdm_to_string.h>
|
||||
|
||||
// Lts
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsUtilsSettings/settings.h>
|
||||
|
||||
// Qt
|
||||
#include <QComboBox>
|
||||
|
||||
|
||||
namespace Buildings
|
||||
{
|
||||
|
||||
BldConfigDialog::BldConfigDialog(int bldEntityId, const QString &displayName, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel)
|
||||
, m_bldEntityId(bldEntityId)
|
||||
, m_displayName(displayName)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_ui(new Ui::BldConfigDialog)
|
||||
, m_logger(getLogger("BuildingConfigDialog"))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Ok)->setText(tr("Send and Close"));
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Apply)->setText(tr("Send"));
|
||||
connect(m_ui->cmbStatus, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
|
||||
&BldConfigDialog::slotCmbStatusCurrentIndexChanged);
|
||||
|
||||
} // end of ctor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
BldConfigDialog::~BldConfigDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
} // end of dtor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void BldConfigDialog::retranslate()
|
||||
{
|
||||
translate(m_ui, m_displayName, false, tr("Building Status"));
|
||||
fillCbx();
|
||||
}
|
||||
|
||||
bool BldConfigDialog::init(LtsSession::LtsSession *session)
|
||||
{
|
||||
if (!session->getFtc<Buildings::DataInterface>(m_ftc))
|
||||
return false;
|
||||
if (!session->getFtc<CentralEffectSimulation::DataInterface>(m_cesFtc))
|
||||
return false;
|
||||
|
||||
std::shared_ptr<Buildings::Interface::Dtc> dtc;
|
||||
if (!session->getDtc<Buildings::DataInterface>(dtc))
|
||||
return false;
|
||||
if ( dtc != NULL)
|
||||
m_bldState = dtc->buildingState(m_bldEntityId);
|
||||
|
||||
|
||||
// TODO: Reactivate later:
|
||||
|
||||
// if (m_bldState.id() < 1)
|
||||
// {
|
||||
// LtsWidgets::LtsMessageDialog::showMessage(this, tr("The selected Building does not exist!"), tr("Invalid Building"));
|
||||
// return false;
|
||||
// }
|
||||
|
||||
slotChangesMade();
|
||||
const bool showBuildingOwnershp = LtsUtils::ProjectSettings::isFunctionEnabled(QStringLiteral("Buildings"),
|
||||
QStringLiteral("Ownership"));
|
||||
|
||||
if ( showBuildingOwnershp == false)
|
||||
{
|
||||
m_ui->gbOwnership->setVisible(false);
|
||||
}
|
||||
|
||||
return true;
|
||||
} // end of init()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void BldConfigDialog::fillCbx()
|
||||
{
|
||||
m_ui->cmbStatus->clear();
|
||||
m_ui->cmbStatus->addItem(toString(ProjectDataManagement::VulnerabilityState::NoChange),
|
||||
ProjectDataManagement::VulnerabilityState::NoChange);
|
||||
m_ui->cmbStatus->addItem(toString(ProjectDataManagement::VulnerabilityState::CombatReady),
|
||||
ProjectDataManagement::VulnerabilityState::CombatReady);
|
||||
m_ui->cmbStatus->addItem(toString(ProjectDataManagement::VulnerabilityState::CatastrophicKill),
|
||||
ProjectDataManagement::VulnerabilityState::CatastrophicKill);
|
||||
m_ui->cmbStatus->setCurrentIndex(m_ui->cmbStatus->findData(m_bldState.vulnerabilityState().underlying()));
|
||||
|
||||
} // end of fillCbx()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool BldConfigDialog::apply()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION;
|
||||
|
||||
if (m_ui->chbOwnership->isChecked())
|
||||
{
|
||||
CentralEffectSimulation::SetOwnershipRequest req(m_bldEntityId, 0);
|
||||
m_requestHelper->addRequest([req, this]()
|
||||
{
|
||||
return m_cesFtc->setOwnershipRequest(req, this);
|
||||
});
|
||||
}
|
||||
|
||||
// aktuellen state aus Cbx ermitteln und LTS-SetBuildingStates aufrufen
|
||||
m_requestHelper->addRequest([this]()
|
||||
{
|
||||
// ich habe hier mal etwas aufgeraeumt:
|
||||
|
||||
// a) prepare Building
|
||||
Buildings::Building building;
|
||||
building.buildingId(m_bldEntityId);
|
||||
|
||||
// since the 'bracket initialization', this step could be skipped :-)
|
||||
// b) prepare buildingVec
|
||||
// use simply ...ldings({building});
|
||||
// std::vector<Buildings::Building> buildingVec;
|
||||
// buildingVec.resize(1);
|
||||
// buildingVec.push_back(building);
|
||||
|
||||
// c) prepare request
|
||||
SetBuildingStatesRequest requestData;
|
||||
requestData.buildings({building}); // <- 'bracket initialization' - helpfull to skip explicit vector :-)
|
||||
|
||||
ProjectDataManagement::VulnerabilityState state = static_cast<ProjectDataManagement::VulnerabilityState_def::type>(m_ui->cmbStatus->currentData().toInt());
|
||||
requestData.vulnerabilityState(state);
|
||||
|
||||
requestData.resetContamination(m_ui->chbResetContamination->isChecked());
|
||||
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION << "currentIndex: " << m_ui->cmbStatus->currentIndex();
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION << "currentData: " << state;
|
||||
|
||||
return m_ftc->setBuildingStatesRequest(requestData, this);
|
||||
});
|
||||
|
||||
return m_requestHelper->startRequests();
|
||||
|
||||
} // end of apply()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
} // namespace Buildings
|
||||
|
||||
void Buildings::BldConfigDialog::slotCmbStatusCurrentIndexChanged(int index)
|
||||
{
|
||||
Q_UNUSED(index)
|
||||
ProjectDataManagement::VulnerabilityState state = static_cast<ProjectDataManagement::VulnerabilityState_def::type>(m_ui->cmbStatus->currentData().toInt());
|
||||
if (state == ProjectDataManagement::VulnerabilityState_def::CatastrophicKill)
|
||||
{
|
||||
m_ui->chbResetContamination->setEnabled(true);
|
||||
m_ui->chbResetContamination->setChecked(false);
|
||||
}
|
||||
else
|
||||
m_ui->chbResetContamination->setEnabled(true);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Buildings - BuildingsConfigDialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2017-04-20
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
//Lts
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsUtilsGuiDds/request_helper.h>
|
||||
|
||||
//Buildings
|
||||
#include <Buildings/logger.h>
|
||||
|
||||
//DDS
|
||||
#include <Plugins/Buildings/bld_data_plugin_interface.h>
|
||||
#include <Plugins/CentralEffectSimulation/ces_data_plugin_interface.h>
|
||||
|
||||
namespace Ui {
|
||||
class BldConfigDialog;
|
||||
}
|
||||
namespace LtsSession {
|
||||
class LtsSession;
|
||||
}
|
||||
|
||||
namespace Buildings
|
||||
{
|
||||
// --------------------------------------------------------
|
||||
// BldConfigDialog
|
||||
// --------------------------------------------------------
|
||||
class BldConfigDialog : public LtsWidgets::LtsDialog
|
||||
, protected Buildings::Interface::Ftc::SetBuildingStatesReplyHandler
|
||||
, protected CentralEffectSimulation::Interface::Ftc::SetOwnershipReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit BldConfigDialog(int bldEntityId, const QString &displayName, QWidget *parent = nullptr);
|
||||
~BldConfigDialog();
|
||||
|
||||
bool init(LtsSession::LtsSession *session);
|
||||
|
||||
void onSetBuildingStatesReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
|
||||
void onSetOwnershipReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
|
||||
|
||||
private slots:
|
||||
void slotCmbStatusCurrentIndexChanged(int index);
|
||||
|
||||
private:
|
||||
void fillCbx();
|
||||
|
||||
private:
|
||||
void retranslate() override;
|
||||
bool apply() override final;
|
||||
|
||||
int m_bldEntityId = 0;
|
||||
|
||||
QString m_displayName;
|
||||
|
||||
std::shared_ptr<Buildings::Interface::Ftc> m_ftc;
|
||||
std::shared_ptr<CentralEffectSimulation::Interface::Ftc> m_cesFtc;
|
||||
|
||||
Buildings::BuildingState m_bldState;
|
||||
LtsUtils::RequestHelper *m_requestHelper = nullptr;
|
||||
|
||||
Ui::BldConfigDialog *m_ui = nullptr;
|
||||
|
||||
LOGGER_T m_logger;
|
||||
};
|
||||
} // namespace Buildings
|
||||
+128
@@ -0,0 +1,128 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>BldConfigDialog</class>
|
||||
<widget class="QWidget" name="BldConfigDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>874</width>
|
||||
<height>342</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>692</width>
|
||||
<height>342</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Building Configuration</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="1">
|
||||
<widget class="QGroupBox" name="gbOwnership">
|
||||
<property name="title">
|
||||
<string>Ownership</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="1">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="chbOwnership">
|
||||
<property name="text">
|
||||
<string>Reset Building Ownership</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="gbState">
|
||||
<property name="title">
|
||||
<string>State</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="1">
|
||||
<widget class="LtsWidgets::LtsComboBox" name="cmbStatus"/>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="3">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>138</width>
|
||||
<height>223</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>257</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lblStatus">
|
||||
<property name="text">
|
||||
<string>Status:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="chbResetContamination">
|
||||
<property name="text">
|
||||
<string>Reset Contamination</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LtsWidgets::LtsComboBox</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header>LtsWidgets/lts_combo_box.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* GUI Plugin for BuildingManagement - BuildingHistoryDialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-07-07
|
||||
*/
|
||||
|
||||
#include "bld_history_dialog.h"
|
||||
#include "ui_bld_history_dialog.h"
|
||||
|
||||
#include "bld_history_dialog_model.h"
|
||||
|
||||
namespace Buildings
|
||||
{
|
||||
BuildingHistoryDialog::BuildingHistoryDialog(const QString &bldName, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_bldName(bldName)
|
||||
, m_model(new BuildingHistoryDialogModel(this))
|
||||
, m_proxyModel(new BuildingHistoryDialogProxyModel(this))
|
||||
, m_ui(new Ui::BuildingHistoryDialog)
|
||||
, m_logger(getLogger("BuildingHistoryDialog"))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_proxyModel->setSourceModel(m_model);
|
||||
m_ui->tvHistory->setModel(m_proxyModel);
|
||||
|
||||
setUnchangeable();
|
||||
}
|
||||
|
||||
BuildingHistoryDialog::~BuildingHistoryDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void BuildingHistoryDialog::retranslate()
|
||||
{
|
||||
translate(m_ui, m_bldName, false, tr("Building History"));
|
||||
}
|
||||
|
||||
bool BuildingHistoryDialog::init(int ddsId, LtsSession::LtsSession *session)
|
||||
{
|
||||
return m_model->initModel(ddsId, session);
|
||||
}
|
||||
|
||||
} // namespace BuildingManagement
|
||||
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* BuildingManagement - BuildingHistoryDialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-07-07
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
//Lts
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
|
||||
//BuildingManagement
|
||||
#include <Buildings/logger.h>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class BuildingHistoryDialog;
|
||||
}
|
||||
|
||||
namespace LtsSession {
|
||||
class LtsSession;
|
||||
}
|
||||
|
||||
namespace Buildings
|
||||
{
|
||||
class BuildingHistoryDialogModel;
|
||||
class BuildingHistoryDialogProxyModel;
|
||||
|
||||
// --------------------------------------------------------
|
||||
// BuildingHistoryDialog
|
||||
// --------------------------------------------------------
|
||||
class BuildingHistoryDialog final : public LtsWidgets::LtsDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit BuildingHistoryDialog(const QString &bldName, QWidget *parent = nullptr);
|
||||
~BuildingHistoryDialog();
|
||||
|
||||
bool init(int ddsId, LtsSession::LtsSession *session);
|
||||
|
||||
private:
|
||||
void retranslate() override;
|
||||
|
||||
private:
|
||||
QString m_bldName;
|
||||
|
||||
BuildingHistoryDialogModel *m_model = nullptr;
|
||||
BuildingHistoryDialogProxyModel *m_proxyModel = nullptr;
|
||||
|
||||
Ui::BuildingHistoryDialog *m_ui = nullptr;
|
||||
LOGGER_T m_logger;
|
||||
};
|
||||
} // namespace BuildingManagement
|
||||
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>BuildingHistoryDialog</class>
|
||||
<widget class="QWidget" name="BuildingHistoryDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>408</width>
|
||||
<height>230</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Player History </string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="LtsDataView::LtsDataView" name="tvHistory"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LtsDataView::LtsDataView</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>LtsDataView/lts_data_view.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,317 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Model for ParticipantHistory
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-07-07
|
||||
*/
|
||||
|
||||
#include "bld_history_dialog_model.h"
|
||||
|
||||
#include <Buildings/bld_data_plugin_interface.h>
|
||||
#include <ProjectDataManagement/pdm_to_string.h>
|
||||
#include <ProjectDataManagement/pdm_data_plugin_interface.h>
|
||||
#include <ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
#include <AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <ngltools/ngltools_dtg.h>
|
||||
|
||||
namespace Buildings
|
||||
{
|
||||
//---------------------------------
|
||||
// BuildingHistoryDialogModel
|
||||
//---------------------------------
|
||||
BuildingHistoryDialogModel::BuildingHistoryDialogModel(QObject *parent)
|
||||
: LtsWidgets::LtsAbstractTableModel<Buildings::HistoryStateItemEx>(
|
||||
{
|
||||
tr("Time"),
|
||||
tr("Charge Type"),
|
||||
tr("Originator"),
|
||||
tr("Damage [%]"),
|
||||
tr("Contamination")
|
||||
},
|
||||
parent)
|
||||
, m_mseId(-1)
|
||||
, m_logger(getLogger("BuildingHistoryDialogModel"))
|
||||
{}
|
||||
|
||||
bool BuildingHistoryDialogModel::initModel(int mseId,
|
||||
LtsSession::LtsSession *session)
|
||||
{
|
||||
std::shared_ptr<Interface::Dtc> dtc;
|
||||
if (!session->getDtc<Buildings::DataInterface>(dtc))
|
||||
return false;
|
||||
m_mseId = mseId;
|
||||
|
||||
if (!session->getDtc<ProjectDataManagement::DataInterface>(m_pdmDtc))
|
||||
return false;
|
||||
if (!session->getDtc<ParticipantManagement::DataInterface>(m_ppmDtc))
|
||||
return false;
|
||||
if (!session->getDtc<AreaEffectSimulation::DataInterface>(m_aesDtc))
|
||||
return false;
|
||||
|
||||
connect(dtc.get(), &Interface::Dtc::historyStateChanged,
|
||||
this, &BuildingHistoryDialogModel::onHistoryStateChanged);
|
||||
|
||||
DEBUG_LOG(m_logger) << "m_mseId=" << m_mseId;
|
||||
reinitModel(dtc->historyState(m_mseId).stateHistory());
|
||||
return true;
|
||||
}
|
||||
|
||||
QVariant BuildingHistoryDialogModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!indexIsValid(index))
|
||||
return QVariant();
|
||||
|
||||
if (role != Qt::DisplayRole)
|
||||
return QVariant();
|
||||
|
||||
const HistoryStateItemEx &data = m_vecData[index.row()];
|
||||
switch (index.column())
|
||||
{
|
||||
case Time:
|
||||
return QDateTime::fromMSecsSinceEpoch(data.time());
|
||||
case Charge:
|
||||
return data.chargeTypeName;
|
||||
case Originator:
|
||||
return data.originatorName;
|
||||
case Damage:
|
||||
return data.damagePercent();
|
||||
case Contamination:
|
||||
return getContaminations(data.contaminationStates());
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
void BuildingHistoryDialogModel::onHistoryStateChanged(const Buildings::HistoryState &data, DataModification modType)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "onHistoryStateChanged";
|
||||
if (m_mseId != data.mseId())
|
||||
return;
|
||||
|
||||
if (modType == DataModification::eRemoved)
|
||||
{
|
||||
beginResetModel();
|
||||
m_vecData.clear();
|
||||
endResetModel();
|
||||
return;
|
||||
}
|
||||
reinitModel(data.stateHistory());
|
||||
}
|
||||
|
||||
QString BuildingHistoryDialogModel::getChargeTypeName(int chargeTypeId, bool shortName) const
|
||||
{
|
||||
if (shortName)
|
||||
return m_pdmDtc->trChargeTypeShortName(chargeTypeId);
|
||||
|
||||
return m_pdmDtc->trChargeTypeName(chargeTypeId);
|
||||
}
|
||||
|
||||
|
||||
QString BuildingHistoryDialogModel::getOriginatorName(const HistoryStateItemEx &data) const
|
||||
{
|
||||
QString originatorType(ProjectDataManagement::toString(data.originatorType()));
|
||||
QString originator;
|
||||
switch (data.originatorType().underlying())
|
||||
{
|
||||
case ProjectDataManagement::StateChangeOriginator::Participant:
|
||||
{
|
||||
//when originatorParticipantId is negative, originator remains empty
|
||||
if (data.originatorParticipantId() > 0)
|
||||
{
|
||||
ParticipantManagement::Participant participant = m_ppmDtc->participant(data.originatorParticipantId());
|
||||
if (participant.equipmentNumber().is_set())
|
||||
originator = QString::number(participant.equipmentNumber().get());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::StateChangeOriginator::AreaEffectSimulation:
|
||||
case ProjectDataManagement::StateChangeOriginator::FunctionalArea:
|
||||
{
|
||||
AreaEffectSimulation::AesItem aesItem;
|
||||
m_aesDtc->aesItemFromId(data.aesId(), aesItem);
|
||||
if (aesItem.id() > 0)
|
||||
originator = QString::fromStdString(aesItem.name());
|
||||
break;
|
||||
}
|
||||
case ProjectDataManagement::StateChangeOriginator::ImprovisedExplosiveDevice: // should not be possible atm
|
||||
case ProjectDataManagement::StateChangeOriginator::DusMine: // should not be possible atm
|
||||
case ProjectDataManagement::StateChangeOriginator::ExerciseControl:
|
||||
case ProjectDataManagement::StateChangeOriginator::ObserverController:
|
||||
case ProjectDataManagement::StateChangeOriginator::WoundTreatmentDevice:
|
||||
case ProjectDataManagement::StateChangeOriginator::MedicalTimeout:
|
||||
case ProjectDataManagement::StateChangeOriginator::MaintainanceDevice:
|
||||
case ProjectDataManagement::StateChangeOriginator::Initialization:
|
||||
case ProjectDataManagement::StateChangeOriginator::Sanitation:
|
||||
case ProjectDataManagement::StateChangeOriginator::Unknown:
|
||||
return ProjectDataManagement::toString(data.originatorType());
|
||||
}
|
||||
|
||||
QString chargeTypeShortName = getChargeTypeName(data.chargeTypeId());
|
||||
if (!originator.isEmpty() && !chargeTypeShortName.isEmpty())
|
||||
originatorType += QStringLiteral("(%1 - %2)").arg(originator, chargeTypeShortName);
|
||||
else if (!originator.isEmpty())
|
||||
originatorType += QStringLiteral(" (%1)").arg(originator);
|
||||
else if (!chargeTypeShortName.isEmpty())
|
||||
originatorType += QStringLiteral(" (%1)").arg(chargeTypeShortName);
|
||||
return originatorType;
|
||||
}
|
||||
|
||||
QString BuildingHistoryDialogModel::getContaminations(const std::vector< Buildings::ContaminationState > &contaminationStates) const
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "BuildingHistoryDialogModel::getContaminations";
|
||||
QStringList contaminationList;
|
||||
for (const auto &cs : contaminationStates)
|
||||
{
|
||||
AreaEffectSimulation::AesItem item;
|
||||
m_aesDtc->aesItemFromId(cs.aesId(), item);
|
||||
const ProjectDataManagement::GearClass &gc = m_pdmDtc->gearClassFromChargeTypeId(item.chargeStruct().chargeTypeId());
|
||||
DEBUG_LOG(m_logger) << "gc=" << gc;
|
||||
if (gc == ProjectDataManagement::GearClass::Unknown)
|
||||
continue;
|
||||
QString gearClassName = ProjectDataManagement::toString(gc).trimmed();
|
||||
gearClassName.chop(gearClassName.size() - 1); // get only the First letter: Nuclear -> 'N'
|
||||
if (!contaminationList.contains(gearClassName))
|
||||
contaminationList.append(gearClassName);
|
||||
else
|
||||
DEBUG_LOG(m_logger) << "contaminationList.contains(gearClassName)" << gearClassName;
|
||||
}
|
||||
return contaminationList.join(QStringLiteral("+"));
|
||||
}
|
||||
|
||||
void BuildingHistoryDialogModel::reinitModel(const std::vector<Buildings::HistoryStateItem> &newData)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "BuildingHistoryDialogModel::reinitModel size=" << newData.size();
|
||||
int indexModel = 0;
|
||||
// Wenn die Kontaminationen zurueckgesetzt werden, faengt er neu an zu zaehlen
|
||||
int contaminationOffest = 0;
|
||||
beginResetModel();
|
||||
|
||||
if (newData.size() == 0)
|
||||
return;
|
||||
m_vecData.resize(newData.size() + newData[0].contaminationStates().size());
|
||||
contaminationOffest = 0;
|
||||
// Schleife ueber alle History-States
|
||||
for (size_t stateHistoryIndex = 0; stateHistoryIndex < newData.size(); ++stateHistoryIndex)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "\n\nstateHistoryIndex=" << stateHistoryIndex;
|
||||
|
||||
// Wenn neue Kontaminationen da sind, sind nur diese relevant.
|
||||
if (((newData.at(stateHistoryIndex).contaminationStates().size() > 0 && stateHistoryIndex == 0)
|
||||
|| (stateHistoryIndex > 0 && (newData.at(stateHistoryIndex).contaminationStates().size() > newData.at(stateHistoryIndex - 1).contaminationStates().size())))
|
||||
&& (stateHistoryIndex > 0))
|
||||
DEBUG_LOG(m_logger) << "1. State ist Kontamination";
|
||||
else
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "State aus StateItem nehmen: stateHistoryIndex=" << stateHistoryIndex;
|
||||
auto &data = m_vecData[stateHistoryIndex];
|
||||
data = HistoryStateItemEx(newData.at(stateHistoryIndex));
|
||||
data.chargeTypeName = getChargeTypeName(data.chargeTypeId());
|
||||
QString originatorName= getOriginatorName(data);
|
||||
// originatorName.append(QStringLiteral(" indexModel"));
|
||||
// originatorName.append(QString::number(indexModel));
|
||||
// originatorName.append(QStringLiteral(" stateHistoryIndex="));
|
||||
// originatorName.append(QString::number(stateHistoryIndex));
|
||||
data.originatorName = originatorName;
|
||||
if (newData.at(stateHistoryIndex).contaminationStates().empty())
|
||||
data.contamination.clear();
|
||||
else
|
||||
data.contamination = QStringLiteral("C");
|
||||
DEBUG_LOG(m_logger) << "indexModel=" << indexModel
|
||||
<< " chargeTypeId=" << data.chargeTypeId()
|
||||
<< " chargeTypeName=" << getChargeTypeName(data.chargeTypeId())
|
||||
<< " originatorName=" << getOriginatorName(data);
|
||||
indexModel++;
|
||||
}
|
||||
|
||||
|
||||
unsigned int contaminationIndex = 0;
|
||||
// Schleife ueber alle Kontaminationen
|
||||
for (const auto &contaminationState : newData.at(stateHistoryIndex).contaminationStates())
|
||||
{
|
||||
|
||||
AreaEffectSimulation::AesItem item;
|
||||
m_aesDtc->aesItemFromId(contaminationState.aesId(), item);
|
||||
DEBUG_LOG(m_logger) << "m_vecData.size=" << m_vecData.size()
|
||||
<< " indexModel=" << indexModel
|
||||
<< " newData.size()=" << newData.size()
|
||||
<< " contaminationOffest=" << contaminationOffest;
|
||||
|
||||
// Nur zusaetzliche Kontaminationen verwenden:
|
||||
if (stateHistoryIndex > 0)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "stateHistoryIndex=" << stateHistoryIndex
|
||||
<< " contaminationIndex="
|
||||
<< " newData.at(stateHistoryIndex-1).contaminationStates().size() =" << newData.at(stateHistoryIndex - 1).contaminationStates().size();
|
||||
if (contaminationIndex < newData.at(stateHistoryIndex - 1).contaminationStates().size())
|
||||
{
|
||||
contaminationIndex++;
|
||||
DEBUG_LOG(m_logger) << "continue";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_vecData.size() < indexModel + 1)
|
||||
m_vecData.resize(indexModel + 1);
|
||||
auto &data = m_vecData[indexModel];
|
||||
|
||||
data = HistoryStateItemEx(newData.at(stateHistoryIndex));
|
||||
data.chargeTypeName = getChargeTypeName(item.chargeStruct().chargeTypeId());
|
||||
QString originatorName= QString::fromStdString(item.name());
|
||||
// originatorName.append(QStringLiteral(" indexModel="));
|
||||
// originatorName.append(QString::number(indexModel));
|
||||
// originatorName.append(QStringLiteral(" stateHistoryIndex="));
|
||||
// originatorName.append(QString::number(stateHistoryIndex));
|
||||
|
||||
data.originatorName = originatorName;
|
||||
data.contamination = QStringLiteral("C");
|
||||
::rti::core::int64 time = item.effectStart().get();
|
||||
data.time(time);
|
||||
DEBUG_LOG(m_logger) << " indexModel=" << indexModel
|
||||
<< " AesId=" << contaminationState.aesId()
|
||||
<< " chargeTypeId=" << data.chargeTypeId()
|
||||
<< " chargeTypeName=" << getChargeTypeName(data.chargeTypeId())
|
||||
<< " originatorName=" << getOriginatorName(data);
|
||||
//data.chargeTypeId = item.chargeTypeId();
|
||||
indexModel++;
|
||||
contaminationIndex++;
|
||||
}
|
||||
}
|
||||
this->sort(0);
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
//
|
||||
// ExercisePhaseProxyModel
|
||||
//
|
||||
void BuildingHistoryDialogProxyModel::setSourceModel(QAbstractItemModel *sourceModel)
|
||||
{
|
||||
m_sourceModel = qobject_cast<BuildingHistoryDialogModel *>(sourceModel);
|
||||
LtsWidgets::LtsColumnFilterProxyModel::setSourceModel(sourceModel);
|
||||
}
|
||||
|
||||
bool BuildingHistoryDialogProxyModel::lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const
|
||||
{
|
||||
if (!m_sourceModel ||
|
||||
source_left.column() != source_right.column() ||
|
||||
!source_left.isValid() ||
|
||||
!source_right.isValid())
|
||||
return LtsWidgets::LtsColumnFilterProxyModel::lessThan(source_left, source_right);
|
||||
const auto &dataLeft = m_sourceModel->m_vecData.at(source_left.row());
|
||||
const auto dataRight = m_sourceModel->m_vecData.at(source_right.row());
|
||||
switch (source_left.column())
|
||||
{
|
||||
case BuildingHistoryDialogModel::Time:
|
||||
return dataLeft.time() < dataRight.time();
|
||||
case BuildingHistoryDialogModel::Charge:
|
||||
case BuildingHistoryDialogModel::Originator:
|
||||
case BuildingHistoryDialogModel::Damage:
|
||||
case BuildingHistoryDialogModel::Contamination:
|
||||
break;
|
||||
}
|
||||
return LtsWidgets::LtsColumnFilterProxyModel::lessThan(source_left, source_right);
|
||||
}
|
||||
|
||||
} // namespace ParticipantManagement
|
||||
@@ -0,0 +1,116 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Model for Participant History
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-07-07
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
//Lts
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
#include <LtsWidgets/lts_column_filter_proxy_model.h>
|
||||
|
||||
//Buildings
|
||||
#include <Buildings/logger.h>
|
||||
#include <Buildings/bld.hpp>
|
||||
|
||||
namespace LtsSession {
|
||||
class LtsSession;
|
||||
}
|
||||
|
||||
namespace ProjectDataManagement
|
||||
{
|
||||
namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
|
||||
namespace Buildings
|
||||
{
|
||||
|
||||
|
||||
class HistoryStateItemEx : public HistoryStateItem
|
||||
{
|
||||
public:
|
||||
QVariant chargeTypeName;
|
||||
QVariant originatorName;
|
||||
QVariant contamination;
|
||||
HistoryStateItemEx() = default;
|
||||
explicit HistoryStateItemEx(const HistoryStateItem &item)
|
||||
: HistoryStateItem(item)
|
||||
{}
|
||||
};
|
||||
// --------------------------------------------------------
|
||||
// BuildingHistoryDialogModel
|
||||
// --------------------------------------------------------
|
||||
class BuildingHistoryDialogModel final : public LtsWidgets::LtsAbstractTableModel<HistoryStateItemEx>
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum Column
|
||||
{
|
||||
Time,
|
||||
Charge,
|
||||
Originator,
|
||||
Damage,
|
||||
Contamination
|
||||
};
|
||||
explicit BuildingHistoryDialogModel(QObject *parent = nullptr);
|
||||
|
||||
bool initModel(int mseId,
|
||||
LtsSession::LtsSession *session);
|
||||
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
|
||||
private Q_SLOTS:
|
||||
void onHistoryStateChanged(const HistoryState &data, DataModification modType);
|
||||
|
||||
private:
|
||||
void reinitModel(const std::vector<Buildings::HistoryStateItem> &newData);
|
||||
QString getChargeTypeName(int chargeTypeId, bool shortName = true) const;
|
||||
QString getOriginatorName(const HistoryStateItemEx &data) const;
|
||||
QString getContaminations(const std::vector<ContaminationState> &contaminationStates) const;
|
||||
|
||||
int m_mseId;
|
||||
|
||||
std::shared_ptr<ProjectDataManagement::Interface::Dtc> m_pdmDtc;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
std::shared_ptr<AreaEffectSimulation::Interface::Dtc> m_aesDtc;
|
||||
|
||||
LOGGER_T m_logger;
|
||||
|
||||
friend class BuildingHistoryDialogProxyModel;
|
||||
};
|
||||
|
||||
class BuildingHistoryDialogProxyModel final : public LtsWidgets::LtsColumnFilterProxyModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
using LtsWidgets::LtsColumnFilterProxyModel::LtsColumnFilterProxyModel;
|
||||
void setSourceModel(QAbstractItemModel *sourceModel) override;
|
||||
protected:
|
||||
bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const override;
|
||||
private:
|
||||
BuildingHistoryDialogModel *m_sourceModel = nullptr;
|
||||
};
|
||||
} //namespace ParticipantManagement
|
||||
@@ -0,0 +1,201 @@
|
||||
/**
|
||||
*@RDE_HEADER@
|
||||
* GUI Plugin for Building HitLine - Info
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, NLE, 2018-09-13
|
||||
*/
|
||||
|
||||
#include "bld_hitline_info_dialog.h"
|
||||
#include "ui_bld_hitline_info_dialog.h"
|
||||
#include <ParticipantManagement/ppm_translation.h>
|
||||
#include <ProjectDataManagement/pdm_to_string.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
|
||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||
#include <ngltools/ngltools_dtg.h>
|
||||
|
||||
|
||||
//DDS
|
||||
#include <InfrastructureManagement/ism_data_plugin_interface.h>
|
||||
#include <ProjectDataManagement/pdm_data_plugin_interface.h>
|
||||
#include <ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
#include <AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
#include <Buildings/bld_data_plugin_interface.h>
|
||||
|
||||
//SituationMap
|
||||
#include <SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
|
||||
namespace Buildings
|
||||
{
|
||||
|
||||
HitLineInfoDialog::HitLineInfoDialog(int hitLineId, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_hitLineId(hitLineId)
|
||||
, m_ui(new Ui::HitLineInfoDialog)
|
||||
, m_logger(getLogger("BuildingHitLineInfoDialog"))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
connect(m_ui->pbOriginatorFindOnMap, &QToolButton::clicked,
|
||||
this, &HitLineInfoDialog::onFindOriginatorOnMap);
|
||||
connect(m_ui->pbBuildingFindOnMap, &QToolButton::clicked,
|
||||
this, &HitLineInfoDialog::onFindBuildingOnMap);
|
||||
|
||||
// Debug Infos
|
||||
#ifndef LTS_DEBUG
|
||||
m_ui->lbHitLineId->hide();
|
||||
m_ui->lblHitLineId->hide();
|
||||
m_ui->lbChargeTypeId->hide();
|
||||
m_ui->lblChargeTypeId->hide();
|
||||
m_ui->lbBuildingId->hide();
|
||||
m_ui->lblBuildingId->hide();
|
||||
// m_ui->lbChargeType->hide();
|
||||
// m_ui->lblChargeType->hide();
|
||||
#endif
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Info_Dialog-Building_Hitline"));
|
||||
} // end of ctor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
HitLineInfoDialog::~HitLineInfoDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
} // end of dtor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void HitLineInfoDialog::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("Building Hit Line Info"));
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool HitLineInfoDialog::init(LtsSession::LtsSession *session)
|
||||
{
|
||||
if (!session->getDtc<Buildings::DataInterface>(m_bldDtc))
|
||||
return false;
|
||||
if (!session->getDtc<ParticipantManagement::DataInterface>(m_ppmDtc))
|
||||
return false;
|
||||
if (!session->getDtc<ProjectDataManagement::DataInterface>(m_pdmDtc))
|
||||
return false;
|
||||
if (!session->getDtc<AreaEffectSimulation::DataInterface>(m_aesDtc))
|
||||
return false;
|
||||
|
||||
session->getDtc<InfrastructureManagement::DataInterface>(m_ismDtc);
|
||||
session->getForeignGuiInterface<SituationMap::ForeignGuiInterface>(m_sitMapGuiIfc);
|
||||
|
||||
// Geht ueber alle BuildingHitLineInfos in der Map
|
||||
m_bldDtc->buildingHitLineInfos([this](const BuildingHitLineInfo &data)
|
||||
{
|
||||
if (data.id() == m_hitLineId)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Found Building HitLine Id: " << data.id();
|
||||
m_hitLineInfo = data;
|
||||
m_participantOriginator = m_ppmDtc->participant(data.originatorParticipantId());
|
||||
showHitLineInfos();
|
||||
}
|
||||
});
|
||||
|
||||
if (!m_isInitialized)
|
||||
WARNING_LOG(m_logger) << "Non Building HitLineInfo data found for id: " << m_hitLineId;
|
||||
return m_isInitialized;
|
||||
} // end of init()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void HitLineInfoDialog::showHitLineInfos()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION << " id:" << m_hitLineId;
|
||||
|
||||
if (m_hitLineInfo.buildingId() <= 0 || m_hitLineInfo.originatorParticipantId() <= 0)
|
||||
return;
|
||||
|
||||
m_ui->lblHitLineId->setText(QString::number(m_hitLineId));
|
||||
|
||||
// SampleTime
|
||||
m_ui->lblSampleTime->setText(DTG::toStringMSec(m_hitLineInfo.sampleTime()));
|
||||
|
||||
// Originator
|
||||
m_ui->lblOriginatorEquipNr->setText(QString::number(m_participantOriginator.equipmentNumber().get()));
|
||||
|
||||
m_ui->lblOriginatorParty->setText(ParticipantManagement::trPartyName(m_ppmDtc->party(m_hitLineInfo.originatorPartyId()).name()));
|
||||
|
||||
m_ui->lblOriginatorDesignator->setText(QString::fromStdString(m_participantOriginator.designator()));
|
||||
|
||||
m_ui->lblOriginatorTactIdentifier->setText(QString::fromStdString(m_participantOriginator.tacticalIdentifier()));
|
||||
|
||||
m_ui->lblOriginatorType->setText(ParticipantManagement::trTypeName(m_ppmDtc->type(m_participantOriginator.typeId()).name()));
|
||||
|
||||
QString mgrs = LtsCoordTrans::mgrsFromGeographic(m_hitLineInfo.originatorPos().lon(), m_hitLineInfo.originatorPos().lat());
|
||||
if (qFuzzyIsNull(m_hitLineInfo.originatorPos().z()))
|
||||
m_ui->lblOriginatorPos->setText(tr("Position: %1").arg(mgrs));
|
||||
else
|
||||
m_ui->lblOriginatorPos->setText(tr("Position: %1 %2").arg(mgrs).arg(m_hitLineInfo.originatorPos().z()));
|
||||
|
||||
// Building
|
||||
m_ui->lblBuildingId->setText(QString::number(m_hitLineInfo.buildingId()));
|
||||
if (m_ismDtc)
|
||||
m_ui->lblBuildingName->setText(m_ismDtc->getBuildingDisplayName(m_hitLineInfo.buildingId()));
|
||||
|
||||
mgrs = LtsCoordTrans::mgrsFromGeographic(m_hitLineInfo.buildingPos().lon(), m_hitLineInfo.buildingPos().lat());
|
||||
if (qFuzzyIsNull(m_hitLineInfo.buildingPos().z()))
|
||||
m_ui->lblBuildingPos->setText(tr("Position: %1").arg(mgrs));
|
||||
else
|
||||
m_ui->lblBuildingPos->setText(tr("Position: %1 %2").arg(mgrs).arg(m_hitLineInfo.buildingPos().z()));
|
||||
|
||||
Buildings::BuildingState bldState = m_bldDtc->buildingState((m_hitLineInfo.buildingId()));
|
||||
ProjectDataManagement::VulnerabilityState st = bldState.vulnerabilityState();
|
||||
m_ui->lblBuildingStatus->setText(toString(st));
|
||||
|
||||
m_ui->lblBuildingDamagePercent->setText(QString::number(bldState.damagePercent()));
|
||||
|
||||
m_ui->lblBuildingDamageOldPercent->setText(QString::number(bldState.damagePercentOld()));
|
||||
|
||||
m_ui->lblChargeTypeId->setText(QString::number(m_hitLineInfo.chargeTypeId()));
|
||||
|
||||
m_ui->lblChargeType->setText(m_pdmDtc->trChargeTypeShortName(m_hitLineInfo.chargeTypeId()));
|
||||
|
||||
const QString contamination = getContaminations(m_hitLineInfo.contaminationStates());
|
||||
m_ui->lbContamination->setHidden(contamination.isEmpty());
|
||||
m_ui->lblContamination->setHidden(contamination.isEmpty());
|
||||
m_ui->lblContamination->setText(contamination.isEmpty() ? QStringLiteral("-") : contamination);
|
||||
|
||||
m_isInitialized = true;
|
||||
}
|
||||
|
||||
QString HitLineInfoDialog::getContaminations(const std::vector< Buildings::ContaminationState > &contaminationStates) const
|
||||
{
|
||||
QStringList contaminationList;
|
||||
for(const auto &cs : contaminationStates){
|
||||
AreaEffectSimulation::AesItem item;
|
||||
m_aesDtc->aesItemFromId(cs.aesId(), item);
|
||||
const ProjectDataManagement::GearClass &gc = m_pdmDtc->gearClassFromChargeTypeId(item.chargeStruct().chargeTypeId());
|
||||
if (gc == ProjectDataManagement::GearClass::Unknown)
|
||||
continue;
|
||||
QString gearClassName = ProjectDataManagement::toString(gc).trimmed();
|
||||
gearClassName.chop(gearClassName.size()-1); // get only the First letter: Nuclear -> 'N'
|
||||
if (!contaminationList.contains(gearClassName))
|
||||
contaminationList.append(gearClassName);
|
||||
}
|
||||
return contaminationList.join(QStringLiteral("+"));
|
||||
}
|
||||
// end of showHitLineInfos()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void HitLineInfoDialog::onFindOriginatorOnMap()
|
||||
{
|
||||
if (m_sitMapGuiIfc)
|
||||
m_sitMapGuiIfc->centerMapToParticipant(m_participantOriginator.id());
|
||||
} // end of onFindOriginatorOnMap()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void HitLineInfoDialog::onFindBuildingOnMap()
|
||||
{
|
||||
if (m_sitMapGuiIfc)
|
||||
m_sitMapGuiIfc->centerMapToBuildingObject(m_hitLineInfo.buildingId());
|
||||
} // end of onFindBuildingOnMap()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
} // namespace Buildings
|
||||
@@ -0,0 +1,111 @@
|
||||
/**
|
||||
*@RDE_HEADER@
|
||||
* GUI Plugin for Building HitLine - Info
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, NLE, 2018-09-13
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
//Lts
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
|
||||
|
||||
// BuildingManagement
|
||||
#include <Buildings/logger.h>
|
||||
#include <Buildings/bld.hpp>
|
||||
#include <ParticipantManagement/ppm.hpp>
|
||||
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class HitLineInfoDialog;
|
||||
}
|
||||
|
||||
namespace LtsSession
|
||||
{
|
||||
class LtsSession;
|
||||
}
|
||||
namespace ProjectDataManagement
|
||||
{
|
||||
namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
namespace InfrastructureManagement
|
||||
{
|
||||
namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
namespace SituationMap
|
||||
{
|
||||
|
||||
class ForeignGuiInterface;
|
||||
}
|
||||
|
||||
namespace Buildings
|
||||
{
|
||||
namespace Interface {
|
||||
class Dtc;
|
||||
}
|
||||
// --------------------------------------------------------
|
||||
// HitLineInfoDialog
|
||||
// --------------------------------------------------------
|
||||
class HitLineInfoDialog : public LtsWidgets::LtsDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit HitLineInfoDialog(int hitLineId, QWidget *parent = nullptr);
|
||||
~HitLineInfoDialog();
|
||||
|
||||
bool init(LtsSession::LtsSession *session);
|
||||
|
||||
private:
|
||||
void retranslate() override;
|
||||
void showHitLineInfos();
|
||||
QString getContaminations(const std::vector<ContaminationState> &contaminationStates) const;
|
||||
|
||||
|
||||
private Q_SLOTS:
|
||||
void onFindBuildingOnMap();
|
||||
void onFindOriginatorOnMap();
|
||||
|
||||
private:
|
||||
int m_hitLineId = 0;
|
||||
BuildingHitLineInfo m_hitLineInfo;
|
||||
ParticipantManagement::Participant m_participantOriginator;
|
||||
bool m_isInitialized = false;
|
||||
|
||||
std::shared_ptr<Buildings::Interface::Dtc> m_bldDtc;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
std::shared_ptr<ProjectDataManagement::Interface::Dtc> m_pdmDtc;
|
||||
std::shared_ptr<InfrastructureManagement::Interface::Dtc> m_ismDtc;
|
||||
std::shared_ptr<AreaEffectSimulation::Interface::Dtc> m_aesDtc;
|
||||
std::shared_ptr<SituationMap::ForeignGuiInterface> m_sitMapGuiIfc;
|
||||
|
||||
|
||||
Ui::HitLineInfoDialog *m_ui = nullptr;
|
||||
LOGGER_T m_logger;
|
||||
};
|
||||
|
||||
} // namespace Buildings
|
||||
@@ -0,0 +1,432 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>HitLineInfoDialog</class>
|
||||
<widget class="QWidget" name="HitLineInfoDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>341</width>
|
||||
<height>696</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>257</width>
|
||||
<height>320</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Hit Line Info</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>93</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lblIcon">
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>127</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lbHitLineId">
|
||||
<property name="text">
|
||||
<string>HitLine Id:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="lblHitLineId">
|
||||
<property name="text">
|
||||
<string notr="true"><HITLINE_ID></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lbSampleTime">
|
||||
<property name="text">
|
||||
<string>Time:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLabel" name="lblSampleTime">
|
||||
<property name="text">
|
||||
<string notr="true"><SAMPLETIME></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="3">
|
||||
<spacer name="horizontalSpacer_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>51</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="3" column="3">
|
||||
<spacer name="verticalSpacer_6">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Minimum</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>17</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="4">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Originator</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lbOriginatorEquipNr">
|
||||
<property name="text">
|
||||
<string>Equip. No:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="lblOriginatorEquipNr">
|
||||
<property name="text">
|
||||
<string notr="true"><ORIGINATOR_EQUIP_NO></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lbOriginatorParty">
|
||||
<property name="text">
|
||||
<string>Party:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="lblOriginatorParty">
|
||||
<property name="text">
|
||||
<string notr="true"><ORIGINATOR_PARTY></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lbOriginatorTactIdentifier">
|
||||
<property name="text">
|
||||
<string>Tact. Identifier:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLabel" name="lblOriginatorTactIdentifier">
|
||||
<property name="text">
|
||||
<string notr="true"><ORIGINATOR_TACTIDENTIFIER></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="lbOriginatorDesignator">
|
||||
<property name="text">
|
||||
<string>Designator:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLabel" name="lblOriginatorDesignator">
|
||||
<property name="text">
|
||||
<string notr="true"><ORIGINATOR_DESIGNATOR></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="lbOriginatorType">
|
||||
<property name="text">
|
||||
<string>Type:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QLabel" name="lblOriginatorType">
|
||||
<property name="text">
|
||||
<string notr="true"><ORIGINATOR_TYPE></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0" colspan="2">
|
||||
<widget class="QLabel" name="lblOriginatorPos">
|
||||
<property name="text">
|
||||
<string notr="true"><ORIGINATOR_POS></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="2">
|
||||
<widget class="QToolButton" name="pbOriginatorFindOnMap">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Find on Map</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/style/center_to_object.svg</normaloff>:/style/center_to_object.svg</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="3">
|
||||
<spacer name="verticalSpacer_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Minimum</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>17</width>
|
||||
<height>18</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="6" column="0" colspan="4">
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Building</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="lblBuildingName">
|
||||
<property name="text">
|
||||
<string notr="true"><BUILDING_NAME></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="lblBuildingId">
|
||||
<property name="text">
|
||||
<string notr="true"><BUILDING_ID></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="lbDamageOldPercent">
|
||||
<property name="text">
|
||||
<string>Damage Old Percent:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLabel" name="lblBuildingDamageOldPercent">
|
||||
<property name="text">
|
||||
<string notr="true"><BUILDING_DAMAGE_OLD_PERCENT></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lbBuildingName">
|
||||
<property name="text">
|
||||
<string>Building Name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1" colspan="2">
|
||||
<widget class="QLabel" name="lblBuildingStatus">
|
||||
<property name="text">
|
||||
<string notr="true"><BUILDING_STATE></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0" colspan="2">
|
||||
<widget class="QLabel" name="lblBuildingPos">
|
||||
<property name="text">
|
||||
<string notr="true"><BUILDING_POS></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLabel" name="lblBuildingDamagePercent">
|
||||
<property name="text">
|
||||
<string notr="true"><BUILDING_DAMAGE_PERCENT></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lbBuildingDamagePercent">
|
||||
<property name="text">
|
||||
<string>Damage Percent:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lbBuildingId">
|
||||
<property name="text">
|
||||
<string>Building Id:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="lbInjuryStatus">
|
||||
<property name="text">
|
||||
<string>Status:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="2">
|
||||
<widget class="QToolButton" name="pbBuildingFindOnMap">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Find on Map</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/style/center_to_object.svg</normaloff>:/style/center_to_object.svg</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="lbContamination">
|
||||
<property name="text">
|
||||
<string>Contamination:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="QLabel" name="lblContamination">
|
||||
<property name="text">
|
||||
<string notr="true"><CONTAMINATION></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="2">
|
||||
<spacer name="verticalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Minimum</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>17</width>
|
||||
<height>27</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<widget class="QLabel" name="lbChargeTypeId">
|
||||
<property name="text">
|
||||
<string>Charge Type Id:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="0">
|
||||
<widget class="QLabel" name="lbChargeType">
|
||||
<property name="text">
|
||||
<string>Charge Type:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="2">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="8" column="1" colspan="3">
|
||||
<widget class="QLabel" name="lblChargeTypeId">
|
||||
<property name="text">
|
||||
<string notr="true"><CHARGETYPEID></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="1" colspan="3">
|
||||
<widget class="QLabel" name="lblChargeType">
|
||||
<property name="text">
|
||||
<string notr="true"><CHARGETYPE></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
+1139
File diff suppressed because it is too large.
Load diff
+143
@@ -0,0 +1,143 @@
|
||||
/**
|
||||
*@RDE_HEADER@
|
||||
* GUI Plugin for Building- Info
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2017-04-05
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "info_dialog_base.h"
|
||||
#include <CentralEffectSimulation/ces.hpp>
|
||||
|
||||
// DDS
|
||||
#include <InfrastructureManagement/ism.hpp>
|
||||
#include <CentralEffectSimulation/ces.hpp>
|
||||
#include <Buildings/bld.hpp>
|
||||
#include <LtsUtilsCore/data_modification_enum.h>
|
||||
#include <ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
|
||||
// Qt
|
||||
#include <QMap>
|
||||
#include <QPair>
|
||||
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class BldInfoDialog;
|
||||
}
|
||||
namespace CentralEffectSimulation
|
||||
{
|
||||
namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
namespace ProjectDataManagement
|
||||
{
|
||||
namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
|
||||
namespace Buildings
|
||||
{
|
||||
constexpr int ICON_RESOLUTION = 64;
|
||||
|
||||
// --------------------------------------------------------
|
||||
// BuildingInfoDialog
|
||||
// --------------------------------------------------------
|
||||
class BldInfoDialog : public InfoDialogBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit BldInfoDialog(int bldEntityId, const QString &menuGroup, QWidget *parent = nullptr);
|
||||
~BldInfoDialog();
|
||||
|
||||
bool init(LtsSession::LtsSession *session) override;
|
||||
|
||||
private:
|
||||
template <typename ReturnType, typename Container, typename Key>
|
||||
static ReturnType constFinder(const Container &container, const Key &key) noexcept(false)
|
||||
{
|
||||
auto it = container.constFind(key);
|
||||
|
||||
if (it == container.constEnd())
|
||||
throw QStringLiteral("constFinder: cannot find '%1' in container").arg(keyToString(key));
|
||||
|
||||
return it.value();
|
||||
}
|
||||
|
||||
void retranslate() override;
|
||||
void showBuildingInfos() override;
|
||||
void showBuildingInfos(const Buildings::BuildingState &bldState);
|
||||
void fillOwnership(int buildingId);
|
||||
void fillOwnership(const CentralEffectSimulation::BuildingOwnership &ownership);
|
||||
void clearColumn(int column);
|
||||
void fillContaminationTable(const Buildings::BuildingState &bldState);
|
||||
QString buildingDisplayName() const override;
|
||||
bool egcuVisibility();
|
||||
|
||||
// FloorParticipantCount stuff:
|
||||
void updateFloorParticipantTable();
|
||||
bool getRoom(int roomSeId, InfrastructureManagement::StructureElement &roomSe);
|
||||
QString getFloorName(int floorSeId);
|
||||
int findFloorIdByRoomId(int roomId) noexcept(false);
|
||||
|
||||
private slots:
|
||||
void onBuildingStateChanged(const Buildings::BuildingState &data, const DataModification &modType);
|
||||
void onBuildingOwnershipChanged(const CentralEffectSimulation::BuildingOwnership &data,
|
||||
const DataModification &modType);
|
||||
void onMainStructureElementChanged(const InfrastructureManagement::MainStructureElement &data,
|
||||
const DataModification &modType);
|
||||
void onMountingPointAssetChanged(const InfrastructureManagement::MountingPointAsset &data,
|
||||
const DataModification &modType);
|
||||
void onOpenHistory();
|
||||
void onEgcuInfoDialogRequested();
|
||||
|
||||
// FloorParticipantCount stuff:
|
||||
void onPositionChanged(const ParticipantManagement::ParticipantPosition &data, DataModification modType);
|
||||
void addParticipantPosition(const ParticipantManagement::ParticipantPosition &data, DataModification modType);
|
||||
|
||||
private:
|
||||
Ui::BldInfoDialog *m_ui;
|
||||
InfrastructureManagement::MainStructureElement m_mse;
|
||||
|
||||
// FloorParticipantCount stuff:
|
||||
// QMap<int /* participant */, int /* party */> m_participantToPartyMapping;
|
||||
// QMap<int /* participant */, int /* floor */> m_participantToFloorMapping;
|
||||
// QMap<QPair<int /* floor */, int /* party */>, int /* participant count */> m_floorPartyParticipantCount;
|
||||
// QMap<int /* floor */, QVector<int /* party */> > m_floorToPartyMapping; // needed to have something to iterate better than the mess that m_floorPartyParticipantCount is
|
||||
|
||||
QMap<int /* floor's sei */, QString /* floor name */> m_floorNames;
|
||||
QMap<int, int> m_rowToFloorId; // Key = row Value = floorId;
|
||||
QMap<int, int> m_floorIdToRow; // Key = floorId Value = row;
|
||||
QMap<int /* room */, int /* floor */> m_roomToFloorCache;
|
||||
QMap<int /* room */, InfrastructureManagement::StructureElement /* se */> m_roomStructureElementCache;
|
||||
QMap<int /* participant */, QPair<int /* floor */, int /* party */> > m_rawParticipantCount;
|
||||
|
||||
std::shared_ptr<CentralEffectSimulation::Interface::Dtc> m_cesDtc;
|
||||
std::shared_ptr<AreaEffectSimulation::Interface::Dtc> m_aesDtc;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
std::shared_ptr<ProjectDataManagement::Interface::Dtc> m_pdmDtc;
|
||||
|
||||
};
|
||||
} // namespace Buildings
|
||||
+474
@@ -0,0 +1,474 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>BldInfoDialog</class>
|
||||
<widget class="QWidget" name="BldInfoDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>352</width>
|
||||
<height>665</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Building Info</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="10" column="3">
|
||||
<widget class="QToolButton" name="pbDetails">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/style/pi_set_player_mode.svg</normaloff>:/style/pi_set_player_mode.svg</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="12" column="0">
|
||||
<widget class="QLabel" name="lbFloorParticipantCount">
|
||||
<property name="text">
|
||||
<string>Floor participant count:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="0">
|
||||
<widget class="LtsWidgets::LtsElidedLabel" name="lbStatus">
|
||||
<property name="text">
|
||||
<string>Status:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1" colspan="4">
|
||||
<widget class="QLabel" name="lblAssetId">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"><ASSETID></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="LtsWidgets::LtsElidedLabel" name="lbBldName">
|
||||
<property name="text">
|
||||
<string>Building Name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1" colspan="4">
|
||||
<widget class="QLabel" name="lblStructElementId">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"><STRUCTELEMENTID></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="4">
|
||||
<widget class="QToolButton" name="pbHistory">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/style/pi_tact_status_history.svg</normaloff>:/style/pi_tact_status_history.svg</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="16" column="0" colspan="5">
|
||||
<widget class="QGroupBox" name="gbSegments">
|
||||
<property name="title">
|
||||
<string>Segments</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="17" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="1" colspan="4">
|
||||
<widget class="QLabel" name="lblBldId">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"><BLDID></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="1" colspan="2">
|
||||
<widget class="QLabel" name="lblStatus">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"><STATUS></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1" colspan="4">
|
||||
<widget class="QLabel" name="lblBldName">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"><BLDNAME></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="11" column="3">
|
||||
<widget class="QToolButton" name="pbFindOnMap">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/style/center_to_object.svg</normaloff>:/style/center_to_object.svg</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1" colspan="4">
|
||||
<widget class="QLabel" name="lblOrganisatorParticipantId">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"><ORGANISATORPARTICIPANTID></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="11" column="4">
|
||||
<widget class="QToolButton" name="pbBuildingViewer">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/style/3d_viewer.svg</normaloff>:/style/3d_viewer.svg</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<widget class="LtsWidgets::LtsElidedLabel" name="lbDamagePercentOld">
|
||||
<property name="text">
|
||||
<string>Damage Percent Old:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="1" colspan="4">
|
||||
<widget class="QLabel" name="lblDamagePercentOld">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"><DAMAGEPERCENTOLD></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="LtsWidgets::LtsElidedLabel" name="lbDamagePercent">
|
||||
<property name="text">
|
||||
<string>Damage Percent:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1" colspan="4">
|
||||
<widget class="QLabel" name="lblDamagePercent">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"><DAMAGEPERCENT></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="5">
|
||||
<layout class="QHBoxLayout" name="m_horizontalLayoutIcon">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lblIcon">
|
||||
<property name="text">
|
||||
<string notr="true"><ICON></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="11" column="2">
|
||||
<widget class="QToolButton" name="pbMonitor">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/style/system_status.svg</normaloff>:/style/system_status.svg</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="14" column="0">
|
||||
<widget class="QLabel" name="lbOwnership">
|
||||
<property name="text">
|
||||
<string>Ownership:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="13" column="0" colspan="5">
|
||||
<widget class="QTableWidget" name="twFloorParticipantCount">
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
<attribute name="horizontalHeaderStretchLastSection">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Floor</string>
|
||||
</property>
|
||||
</column>
|
||||
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Count</string>
|
||||
</property>
|
||||
</column>
|
||||
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Contamination</string>
|
||||
</property>
|
||||
</column>
|
||||
|
||||
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="LtsWidgets::LtsElidedLabel" name="lbBldId">
|
||||
<property name="text">
|
||||
<string>Bld Id:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="LtsWidgets::LtsElidedLabel" name="lbAssetId">
|
||||
<property name="text">
|
||||
<string>Asset Id:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="LtsWidgets::LtsElidedLabel" name="lbOrganisatorParticipantId">
|
||||
<property name="text">
|
||||
<string>Originator:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="LtsWidgets::LtsElidedLabel" name="lbStructElementId">
|
||||
<property name="text">
|
||||
<string>Struct Element Id:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="15" column="0" colspan="5">
|
||||
<widget class="QTableWidget" name="twOwnership">
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
<attribute name="horizontalHeaderStretchLastSection">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Floor</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Owner</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Contamination</string>
|
||||
</property>
|
||||
</column>
|
||||
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="0">
|
||||
<widget class="LtsWidgets::LtsElidedLabel" name="lbContamination">
|
||||
<property name="text">
|
||||
<string>Contamination:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="1" colspan="4">
|
||||
<widget class="QLabel" name="lblContamination">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"><CONTAMINATION></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LtsWidgets::LtsElidedLabel</class>
|
||||
<extends>QLabel</extends>
|
||||
<header>LtsWidgets/lts_elided_label.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>pbDetails</tabstop>
|
||||
<tabstop>pbHistory</tabstop>
|
||||
<tabstop>pbFindOnMap</tabstop>
|
||||
<tabstop>pbBuildingViewer</tabstop>
|
||||
<tabstop>twOwnership</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,388 @@
|
||||
/**
|
||||
*@RDE_HEADER@
|
||||
* Gui Plugin for Building - Info
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2017-04-05
|
||||
*/
|
||||
|
||||
#include "bld_info_gui_plugin.h"
|
||||
#include "bld_info_dialog.h"
|
||||
#include "egcu_info_dialog.h"
|
||||
#include "egcu_operational.h"
|
||||
#include "bld_hitline_info_dialog.h"
|
||||
#include "bridge_info_dialog.h"
|
||||
|
||||
// DDS
|
||||
#include <Buildings/bld_operator_rights.h>
|
||||
#include <InfrastructureManagement/ism_data_plugin_interface.h>
|
||||
#include <SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
|
||||
|
||||
// Lts
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsWidgets/lts_base_layout_widget.h>
|
||||
#include <LtsUtilsSettings/settings.h>
|
||||
|
||||
//Qt
|
||||
#include <QShortcut>
|
||||
|
||||
|
||||
namespace Buildings
|
||||
{
|
||||
|
||||
std::shared_ptr<GuiPluginBase::Interface> GuiPlugin::createGuiInterface(LtsSession::LtsSession *session)
|
||||
{
|
||||
return std::make_shared<InterfaceImpl>(session);
|
||||
} // end of createGuiInterface()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
InterfaceImpl::InterfaceImpl(LtsSession::LtsSession *session)
|
||||
: GuiPluginBase::Interface(session, getLogger("BldInfo"))
|
||||
{} // end of ctor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool InterfaceImpl::fetchInterfaces()
|
||||
{
|
||||
if (!m_session->getDtc<InfrastructureManagement::DataInterface>(m_ismDtc))
|
||||
return false;
|
||||
|
||||
if (!m_session->getForeignDataInterface<InfrastructureManagement::DataInterface>(m_ismDataIfc))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
||||
} // end of fetchInterfaces()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void InterfaceImpl::clearInterfaces()
|
||||
{
|
||||
m_ismDtc = nullptr;
|
||||
m_ismDataIfc = nullptr;
|
||||
} // end of clearInterfaces()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
QString InterfaceImpl::menuGroup() const
|
||||
{
|
||||
return tr("Building Info");
|
||||
}
|
||||
|
||||
|
||||
QVector<LtsWidgets::PluginData> InterfaceImpl::getActions()
|
||||
{
|
||||
QVector<LtsWidgets::PluginData> ret;
|
||||
|
||||
LtsWidgets::PluginData plData2;
|
||||
plData2.menuGroup = menuGroup();
|
||||
plData2.createInstant = LtsWidgets::CreateInstantType::CreateInstantAndDiscardAction;
|
||||
plData2.directFunc = [this](const LtsWidgets::PluginData &)
|
||||
{
|
||||
if (m_session->app() == LtsAppDescriptor::App::Situation ||
|
||||
m_session->app() == LtsAppDescriptor::App::ResourceManager ||
|
||||
m_session->app() == LtsAppDescriptor::App::Snapshot
|
||||
)
|
||||
{
|
||||
if (!m_scSearchBuilding)
|
||||
{
|
||||
m_scSearchBuilding = new QShortcut(QKeySequence((Qt::ShiftModifier + Qt::Key_F4)), m_session->baseLayout());
|
||||
m_scSearchBuilding->setContext(Qt::WindowShortcut);
|
||||
connect(m_scSearchBuilding, &QShortcut::activated,
|
||||
this, &InterfaceImpl::showBuildingSearchDialog);
|
||||
}
|
||||
} // if (m_session->app() == LtsAp
|
||||
};
|
||||
ret.append(plData2);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void InterfaceImpl::showBuildingSearchDialog()
|
||||
{
|
||||
if (m_buildingShowModalPtr)
|
||||
return;
|
||||
|
||||
if (appId() != LtsAppDescriptor::App::OC)
|
||||
{
|
||||
m_buildingShowModalPtr = new BuildingSearchModal(m_session->baseLayout());
|
||||
m_buildingShowModalPtr->setAttribute(Qt::WA_DeleteOnClose); // auto delete on close
|
||||
|
||||
// #define TEST_LIFETIME
|
||||
#ifdef TEST_LIFETIME // Ein Test fuer wen's interessiert
|
||||
QTimer *t = new QTimer(m_buildingShowModalPtr.data());
|
||||
connect(t, &QTimer::timeout, this, [this, t]() { ERROR_LOG(m_logger) << "TEST_LIFETIME: " << (qintptr)t << " @ " << (qintptr)m_session->baseLayout() << " still alive"; });
|
||||
t->start(1000);
|
||||
#endif
|
||||
|
||||
connect(m_buildingShowModalPtr.data(), &BuildingSearchModal::selectedSearchString,
|
||||
this, &InterfaceImpl::onBuildinSearchStringEntered);
|
||||
|
||||
m_buildingShowModalPtr->show();
|
||||
|
||||
} else {
|
||||
|
||||
//
|
||||
// LtsAppDescriptor::App::OC:
|
||||
//
|
||||
|
||||
if (m_buildingShowQWidgetPtr)
|
||||
{
|
||||
m_buildingShowQWidgetPtr->show();
|
||||
m_buildingShowQWidgetPtr->raise();
|
||||
m_buildingShowQWidgetPtr->activateWindow();
|
||||
return;
|
||||
}
|
||||
|
||||
m_buildingShowQWidgetPtr = new BuildingSearchWidget(m_session->baseLayout());
|
||||
m_buildingShowQWidgetPtr->setAttribute(Qt::WA_DeleteOnClose); // auto delete on close
|
||||
|
||||
// #define TEST_LIFETIME
|
||||
#ifdef TEST_LIFETIME // Ein Test fuer wen's interessiert
|
||||
QTimer *t = new QTimer(m_buildingShowQWidgetPtr.data());
|
||||
connect(t, &QTimer::timeout, this, [this, t]() { ERROR_LOG(m_logger) << "TEST_LIFETIME: " << (qintptr)t << " @ " << (qintptr)m_session->baseLayout() << " still alive"; });
|
||||
t->start(1000);
|
||||
#endif
|
||||
|
||||
connect(m_buildingShowQWidgetPtr.data(), &BuildingSearchWidget::selectedSearchString,
|
||||
this, &InterfaceImpl::onBuildinSearchStringEntered);
|
||||
|
||||
|
||||
// specific:
|
||||
m_buildingShowQWidgetPtr->setWindowFlags( Qt::Window | Qt::CustomizeWindowHint | Qt::WindowTitleHint ); // hints..
|
||||
QPoint wPos = m_session->baseLayout()->geometry().center();
|
||||
wPos.setX(wPos.x() - m_buildingShowQWidgetPtr->size().width());
|
||||
wPos.setY(wPos.y()/2);
|
||||
m_buildingShowQWidgetPtr->move(wPos);
|
||||
|
||||
m_buildingShowQWidgetPtr->show();
|
||||
}
|
||||
}
|
||||
|
||||
void InterfaceImpl::onBuildinSearchStringEntered(const QString &searchString)
|
||||
{
|
||||
TRACE_LOG(m_logger) << " BuildingSearch -> searchString='" << searchString << "'";
|
||||
|
||||
QVector<int> bldIdCont;
|
||||
bldIdCont.reserve(1000);
|
||||
|
||||
QVector<int> bridgeIdCont;
|
||||
bridgeIdCont.reserve(1000);
|
||||
|
||||
// Following callback takes ~20ms for ~500bldgs
|
||||
// if (displayName.contains(txt, Qt::CaseSensitivity::CaseInsensitive))
|
||||
// Norbert Thoden ; CTCAP15
|
||||
|
||||
// cb to iterate over the items and break loop (return) if one item is found:
|
||||
const auto cb = [this, searchString, &bldIdCont, &bridgeIdCont](const InfrastructureManagement::MainStructureElement & data) -> void
|
||||
{
|
||||
if (data.isDeleted())
|
||||
return;
|
||||
|
||||
const std::vector<InfrastructureManagement::StructureElement>& elements = data.elements();
|
||||
if (elements.empty())
|
||||
return;
|
||||
|
||||
const InfrastructureManagement::StructureElement &firstElement = elements.front(); // per definition, element of type Building is at first position
|
||||
|
||||
const InfrastructureManagement::StructureElementType_def::type type = firstElement.structureElementTypeId().underlying();
|
||||
|
||||
if (type == InfrastructureManagement::StructureElementType_def::Building)
|
||||
{
|
||||
if (!(m_ismDataIfc && m_ismDataIfc->isBuildingsInCurrentExercise(data.id())))
|
||||
return;
|
||||
} else if (type != InfrastructureManagement::StructureElementType_def::Bridge) // GUEZE-1631: Brücken via Gebäudesuche finden.
|
||||
return;
|
||||
|
||||
// qCritical() << " searchString='" << searchString << "'"
|
||||
// << ", data.id=" << data.id()
|
||||
// << ", data.type=" << type
|
||||
// << ", mfp.ele.size()=" << m_ismDtc->mainFootprint(data.id()).elements().size();
|
||||
|
||||
// Only objects that could be displayed.
|
||||
// So a footprint is required.
|
||||
// Some internal objects (GUEZ: 300 -> 'Outdoor Cameras / Announcement Units') do not have a footprint -> skip
|
||||
if (m_ismDtc->mainFootprint(data.id()).elements().size() < 3)
|
||||
return;
|
||||
|
||||
const QString &displayName = firstElement.displayName().empty() ? QString::fromStdString(firstElement.name()) : QString::fromStdString(firstElement.displayName());
|
||||
|
||||
// qCritical() << " searchString='" << searchString << "'"
|
||||
// << ", data.id=" << data.id()
|
||||
// << ", data.type=" << type
|
||||
// << ", displayName='" << displayName << "'";
|
||||
|
||||
if (displayName.contains(searchString, Qt::CaseSensitivity::CaseInsensitive))
|
||||
{
|
||||
switch (type) {
|
||||
case InfrastructureManagement::StructureElementType_def::Building:
|
||||
bldIdCont.append(data.id());
|
||||
break;
|
||||
case InfrastructureManagement::StructureElementType_def::Bridge:
|
||||
bridgeIdCont.append(data.id());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
//// return true; // break loop
|
||||
}
|
||||
};
|
||||
// sonst kann sich der compiler nicht zwischen bool und void entscheiden... !?
|
||||
std::function<void(const InfrastructureManagement::MainStructureElement &data)> cb1 = cb;
|
||||
m_ismDtc->mainStructureElements(cb1);
|
||||
|
||||
DEBUG_LOG(m_logger) << " BuildingSearch (searchString='" << searchString << "') -> "
|
||||
<< " bldIdCont=" << bldIdCont.size()
|
||||
<< ", bridgeIdCont=" << bridgeIdCont.size();
|
||||
|
||||
if (bldIdCont.isEmpty() && bridgeIdCont.isEmpty())
|
||||
{
|
||||
WARNING_LOG(m_logger) << " BuildingSearch (searchString='" << searchString << "'), "
|
||||
<< " no matching buildings/bridges";
|
||||
return;
|
||||
}
|
||||
|
||||
// exact one Bldg?
|
||||
if ((bldIdCont.size() == 1) && bridgeIdCont.isEmpty())
|
||||
{
|
||||
DEBUG_LOG(m_logger) << " BuildingSearch -> bldId='" << bldIdCont.first();
|
||||
showInfoWindow(bldIdCont.first());
|
||||
return;
|
||||
|
||||
} else if ((bridgeIdCont.size() == 1) && bldIdCont.isEmpty()) // // exact one Bridge?
|
||||
{
|
||||
DEBUG_LOG(m_logger) << " BuildingSearch -> bridgeIdCont='" << bridgeIdCont.first();
|
||||
showBridgeInfoWindow(bridgeIdCont.first());
|
||||
return;
|
||||
}
|
||||
|
||||
// mixed results:
|
||||
|
||||
// mapObjectSelection / Vorauswahlfenster @ SitMap
|
||||
std::shared_ptr<SituationMap::ForeignGuiInterface> sitMapGuiIfc;
|
||||
m_session->getForeignGuiInterface<SituationMap::ForeignGuiInterface>(sitMapGuiIfc);
|
||||
if (!sitMapGuiIfc)
|
||||
{
|
||||
ERROR_LOG(m_logger) << LOGFUNCTION << " error, no sitMapGuiIfc";
|
||||
return;
|
||||
}
|
||||
|
||||
QVector<SituationMap::ForeignGuiInterface::MapObjectTypeEntityId> mapObjectTypeEntityIdPairs;
|
||||
mapObjectTypeEntityIdPairs += SituationMap::ForeignGuiInterface::MapObjectTypeEntityId(SituationMap::MapObjectType::MOT_Building, bldIdCont);
|
||||
mapObjectTypeEntityIdPairs += SituationMap::ForeignGuiInterface::MapObjectTypeEntityId(SituationMap::MapObjectType::MOT_Bridge, bridgeIdCont);
|
||||
|
||||
if (!sitMapGuiIfc->openMapObjectSelection(mapObjectTypeEntityIdPairs))
|
||||
ERROR_LOG(m_logger) << " openMapObjectSelection failed (searchString='" << searchString << "')";
|
||||
}
|
||||
|
||||
// wird nur von 'aussen' verwendet
|
||||
void InterfaceImpl::showInfoWindow(const QVector<int> &bldEntityIds)
|
||||
{
|
||||
for (auto id : bldEntityIds)
|
||||
this->showInfoWindow(id);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void InterfaceImpl::showInfoWindow(int bldEntityId)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION << " bldEntityId: " << bldEntityId;
|
||||
|
||||
std::shared_ptr<InfrastructureManagement::Interface::Dtc> ismDtc;
|
||||
if (!m_session->getDtc<InfrastructureManagement::DataInterface>(ismDtc))
|
||||
{
|
||||
new LtsWidgets::LtsMessageDialogNew(m_session->baseLayout(), tr("The Infrastructure Management is not available!"), tr("Cannot open Building Info Dialog"));
|
||||
return;
|
||||
}
|
||||
|
||||
BldInfoDialog *dialog = new BldInfoDialog(bldEntityId, menuGroup());
|
||||
if (!dialog->init(m_session))
|
||||
{
|
||||
delete dialog;
|
||||
return;
|
||||
}
|
||||
m_session->addWidget(dialog, menuGroup(), QString::number(bldEntityId), LtsWidgets::LayoutArea::eInfoTab);
|
||||
} // end of showInfoWindow()
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void InterfaceImpl::showBridgeInfoWindow(const QVector<int> &bldEntityIds)
|
||||
{
|
||||
for (auto id : bldEntityIds)
|
||||
this->showBridgeInfoWindow(id);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void InterfaceImpl::showBridgeInfoWindow(int buildingId)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION << " bldEntityId: " << buildingId;
|
||||
|
||||
std::shared_ptr<InfrastructureManagement::Interface::Dtc> ismDtc;
|
||||
if (!m_session->getDtc<InfrastructureManagement::DataInterface>(ismDtc))
|
||||
{
|
||||
new LtsWidgets::LtsMessageDialogNew(m_session->baseLayout(), tr("The Infrastructure Management is not available!"), tr("Cannot open Building Info Dialog"));
|
||||
return;
|
||||
}
|
||||
|
||||
BridgeInfoDialog *dialog = new BridgeInfoDialog(buildingId, menuGroup());
|
||||
if (!dialog->init(m_session))
|
||||
{
|
||||
delete dialog;
|
||||
return;
|
||||
}
|
||||
m_session->addWidget(dialog, menuGroup(), QString::number(buildingId), LtsWidgets::LayoutArea::eInfoTab);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void InterfaceImpl::showEffectGenerationUnitWindow(int mountingPointId)
|
||||
{
|
||||
|
||||
std::shared_ptr<InfrastructureManagement::Interface::Dtc> ismDtc;
|
||||
if (!m_session->getDtc<InfrastructureManagement::DataInterface>(ismDtc))
|
||||
{
|
||||
new LtsWidgets::LtsMessageDialogNew(m_session->baseLayout(), tr("The Infrastructure Management is not available!"), tr("Cannot open Effect Generation Unit"));
|
||||
return;
|
||||
}
|
||||
|
||||
int mpaId;
|
||||
ismDtc->getMountingPointAssetId(mountingPointId, 0, mpaId);
|
||||
if (mpaId == 0)
|
||||
return;
|
||||
|
||||
auto mpa = ismDtc->mountingPointAsset(mpaId);
|
||||
int assetId = mpa.assetId();
|
||||
|
||||
EgcuInfoDialog *dialog = new EgcuInfoDialog(assetId, menuGroup());
|
||||
DEBUG_LOG(m_logger) << " new EgcuInfoDialog: ";
|
||||
if (!dialog->init(m_session))
|
||||
{
|
||||
delete dialog;
|
||||
return;
|
||||
}
|
||||
m_session->addWidget(dialog, menuGroup(), dialog->egcuName(), LtsWidgets::LayoutArea::eInfoTab);
|
||||
}
|
||||
|
||||
void InterfaceImpl::showHitLineInfoWindow(const QVector<int> &hitLineIds)
|
||||
{
|
||||
for (auto id : hitLineIds)
|
||||
this->showHitLineInfoWindow(id);
|
||||
}
|
||||
|
||||
void InterfaceImpl::showHitLineInfoWindow(int hitLineId)
|
||||
{
|
||||
std::shared_ptr<InfrastructureManagement::Interface::Dtc> ismDtc;
|
||||
if (!m_session->getDtc<InfrastructureManagement::DataInterface>(ismDtc))
|
||||
{
|
||||
new LtsWidgets::LtsMessageDialogNew(m_session->baseLayout(), tr("The Infrastructure Management is not available!"), tr("Cannot open Hit Line Info"));
|
||||
return;
|
||||
}
|
||||
|
||||
HitLineInfoDialog *hli = new HitLineInfoDialog(hitLineId);
|
||||
if (!hli->init(m_session))
|
||||
{
|
||||
delete hli;
|
||||
return;
|
||||
}
|
||||
|
||||
m_session->addWidget(hli, menuGroup(), QStringLiteral("HitLineInfo%1").arg(hitLineId), LtsWidgets::LayoutArea::eInfoTab);
|
||||
}
|
||||
|
||||
} // namespace Buildings
|
||||
@@ -0,0 +1,93 @@
|
||||
/**
|
||||
*@RDE_HEADER@
|
||||
* Gui Plugin for Building - Info
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2017-04-05
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
//Buildings
|
||||
#include "bld_search.h"
|
||||
#include <Buildings/logger.h>
|
||||
#include <Buildings/bld_info_gui_plugin_interface.h>
|
||||
#include <Plugins/InfrastructureManagement/ism_data_plugin_interface.h>
|
||||
|
||||
// Common
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
// Forward:
|
||||
class QShortcut;
|
||||
|
||||
namespace Buildings
|
||||
{
|
||||
|
||||
class GuiPlugin final : public QObject, public GuiPluginBase::Plugin
|
||||
{
|
||||
Q_PLUGIN_METADATA(IID "gui:3:bld.info")
|
||||
Q_INTERFACES(GuiPluginBase::Plugin)
|
||||
|
||||
Q_OBJECT
|
||||
public:
|
||||
GuiPlugin() = default;
|
||||
~GuiPlugin() = default;
|
||||
|
||||
QString pluginName() override { return QLatin1String("BuildingInfoGui"); }
|
||||
std::shared_ptr<GuiPluginBase::Interface> createGuiInterface(LtsSession::LtsSession *session) override;
|
||||
bool availableInPartition(IDL::PartitionType partition) const override
|
||||
{
|
||||
return (partition == IDL::PartitionType::Global) || // for App 'ResourceManager'
|
||||
(partition == IDL::PartitionType::Exercise) ||
|
||||
(partition == IDL::PartitionType::Replay);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class InterfaceImpl final : public QObject, public Buildings::ForeignInfoGuiInterface, public GuiPluginBase::Interface
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit InterfaceImpl(LtsSession::LtsSession *session);
|
||||
|
||||
bool fetchInterfaces() override;
|
||||
void clearInterfaces() override;
|
||||
QString menuGroup() const override;
|
||||
|
||||
// anders als in GuiPlugin - hmm, Mike sagt, so lassen - hmm:
|
||||
bool availableInPartition(IDL::PartitionType partition) const override
|
||||
{
|
||||
return (partition == IDL::PartitionType::Global) ||
|
||||
(partition == IDL::PartitionType::Exercise) ||
|
||||
(partition == IDL::PartitionType::Replay);
|
||||
}
|
||||
|
||||
QVector<LtsWidgets::PluginData> getActions() override;
|
||||
|
||||
|
||||
// ForeignDataInterface
|
||||
void showInfoWindow(const QVector<int> &bldEntityIds) override;
|
||||
void showInfoWindow(int bldEntityId) override;
|
||||
void showEffectGenerationUnitWindow(int mountingPointId) override;
|
||||
void showHitLineInfoWindow(const QVector<int> &hitLineIds) override;
|
||||
void showHitLineInfoWindow(int hitLineId) override;
|
||||
void showBridgeInfoWindow(const QVector<int> &bldEntityIds) override;
|
||||
void showBridgeInfoWindow(int buildingId) override;
|
||||
|
||||
private Q_SLOTS:
|
||||
void showBuildingSearchDialog();
|
||||
void onBuildinSearchStringEntered(const QString &searchString);
|
||||
|
||||
private:
|
||||
QShortcut *m_scSearchBuilding{nullptr};
|
||||
QPointer<BuildingSearchModal> m_buildingShowModalPtr;
|
||||
QPointer<BuildingSearchWidget> m_buildingShowQWidgetPtr; // for OC
|
||||
std::shared_ptr<InfrastructureManagement::Interface::Dtc> m_ismDtc;
|
||||
std::shared_ptr<InfrastructureManagement::ForeignDataInterface> m_ismDataIfc;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Buildings
|
||||
+89
@@ -0,0 +1,89 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* OperatorManagement - Operator Change Password (Frameless) Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Malte Diers, SLSE, 2017-10-11
|
||||
*/
|
||||
|
||||
#include "bld_search.h"
|
||||
#include "ui_bld_search.h"
|
||||
#include <LtsSession/lts_session_data_dds.h>
|
||||
//#include <Plugins/ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
#include <Plugins/Buildings/bld_data_plugin_interface.h>
|
||||
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
|
||||
namespace Buildings
|
||||
{
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// BuildingSearchModal
|
||||
//------------------------------------------------------------------------------
|
||||
BuildingSearchModal::BuildingSearchModal(QWidget *parent)
|
||||
: BaseClass(parent)
|
||||
, m_ui(new Ui::BuildingSearch_WIDGET)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_ui->lblSearch->setText(tr("Building Name:"));
|
||||
connect(m_ui->pbCancel, &QPushButton::clicked, this, &BuildingSearchModal::reject); // LtsFramelessDialog -> QDialog -> reject
|
||||
connect(m_ui->pbOk, &QPushButton::clicked, this, &BuildingSearchModal::onOkay);
|
||||
}
|
||||
|
||||
BuildingSearchModal::~BuildingSearchModal()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void BuildingSearchModal::showEvent(QShowEvent *e)
|
||||
{
|
||||
BaseClass::showEvent(e);
|
||||
m_ui->leSearch->clear();
|
||||
m_ui->leSearch->setFocus();
|
||||
}
|
||||
|
||||
void BuildingSearchModal::onOkay()
|
||||
{
|
||||
const QString &searchString = m_ui->leSearch->text();
|
||||
if (!searchString.isEmpty())
|
||||
emit selectedSearchString(searchString);
|
||||
|
||||
close();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// BuildingSearchWidget (for OC)
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
BuildingSearchWidget::BuildingSearchWidget(QWidget *parent)
|
||||
: BaseClass(parent)
|
||||
, m_ui(new Ui::BuildingSearch_WIDGET)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
connect(m_ui->pbCancel, &QPushButton::clicked, this, &BuildingSearchWidget::close); // QWidget -> close
|
||||
connect(m_ui->pbOk, &QPushButton::clicked, this, &BuildingSearchWidget::onOkay);
|
||||
}
|
||||
|
||||
BuildingSearchWidget::~BuildingSearchWidget()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void BuildingSearchWidget::showEvent(QShowEvent *e)
|
||||
{
|
||||
BaseClass::showEvent(e);
|
||||
m_ui->leSearch->clear();
|
||||
m_ui->leSearch->setFocus();
|
||||
}
|
||||
|
||||
void BuildingSearchWidget::onOkay()
|
||||
{
|
||||
const QString &searchString = m_ui->leSearch->text();
|
||||
if (!searchString.isEmpty())
|
||||
emit selectedSearchString(searchString);
|
||||
|
||||
close();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* ParticipantManagement - Show ParticipantInfo by Equipment No
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Malte Diers, NLSE, 2018-04-20
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <LtsWidgets/lts_frameless_dialog.h>
|
||||
#include <QMap>
|
||||
#include <memory>
|
||||
|
||||
enum class DataModification;
|
||||
namespace Ui
|
||||
{
|
||||
class BuildingSearch_WIDGET;
|
||||
}
|
||||
|
||||
namespace Buildings
|
||||
{
|
||||
class Participant;
|
||||
namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
|
||||
|
||||
// Following classes are using ONE ui-file. Deriving from QWidget
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Class #1 - BuildingSearchModal
|
||||
//------------------------------------------------------------------------------
|
||||
class BuildingSearchModal : public LtsWidgets::LtsFramelessDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
using BaseClass = LtsWidgets::LtsFramelessDialog;
|
||||
|
||||
public:
|
||||
explicit BuildingSearchModal(QWidget *parent = nullptr);
|
||||
~BuildingSearchModal();
|
||||
void showEvent(QShowEvent *e) override;
|
||||
|
||||
private Q_SLOTS:
|
||||
void onOkay();
|
||||
|
||||
signals:
|
||||
void selectedSearchString(QString searchString);
|
||||
|
||||
private:
|
||||
Ui::BuildingSearch_WIDGET *m_ui;
|
||||
};
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Class #2 - BuildingSearchWidget (for OC)
|
||||
//------------------------------------------------------------------------------
|
||||
class BuildingSearchWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
using BaseClass = QWidget;
|
||||
|
||||
public:
|
||||
explicit BuildingSearchWidget(QWidget *parent = nullptr);
|
||||
~BuildingSearchWidget();
|
||||
void showEvent(QShowEvent *e) override;
|
||||
|
||||
private Q_SLOTS:
|
||||
void onOkay();
|
||||
|
||||
signals:
|
||||
void selectedSearchString(QString searchString);
|
||||
|
||||
private:
|
||||
Ui::BuildingSearch_WIDGET *m_ui;
|
||||
};
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>BuildingSearch_WIDGET</class>
|
||||
<widget class="QWidget" name="BuildingSearch_WIDGET">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>194</width>
|
||||
<height>88</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="2" column="0" colspan="3">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pbOk">
|
||||
<property name="text">
|
||||
<string>OK</string>
|
||||
</property>
|
||||
<property name="default">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pbCancel">
|
||||
<property name="text">
|
||||
<string>Cancel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="leSearch"/>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lblSearch">
|
||||
<property name="text">
|
||||
<string>Building Name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* GUI Plugin for BuildingManagement - BuildingHistoryDialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-07-07
|
||||
*/
|
||||
|
||||
#include "bridge_history_dialog.h"
|
||||
#include "ui_bridge_history_dialog.h"
|
||||
|
||||
#include "bridge_history_dialog_model.h"
|
||||
|
||||
namespace Buildings
|
||||
{
|
||||
BridgeHistoryDialog::BridgeHistoryDialog(const QString &bldName, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_bldName(bldName)
|
||||
, m_model(new BridgeHistoryDialogModel(this))
|
||||
, m_proxyModel(new BridgeHistoryDialogProxyModel(this))
|
||||
, m_ui(new Ui::BridgeHistoryDialog)
|
||||
, m_logger(getLogger("BridgeHistoryDialog"))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_proxyModel->setSourceModel(m_model);
|
||||
m_ui->tvHistory->setModel(m_proxyModel);
|
||||
|
||||
setUnchangeable();
|
||||
}
|
||||
|
||||
BridgeHistoryDialog::~BridgeHistoryDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void BridgeHistoryDialog::retranslate()
|
||||
{
|
||||
translate(m_ui, m_bldName, false, tr("Bridge History"));
|
||||
}
|
||||
|
||||
bool BridgeHistoryDialog::init(int ddsId, LtsSession::LtsSession *session)
|
||||
{
|
||||
return m_model->initModel(ddsId, session);
|
||||
}
|
||||
|
||||
} // namespace Buildings
|
||||
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* BuildingManagement - BuildingHistoryDialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-07-07
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
//Lts
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
|
||||
//BuildingManagement
|
||||
#include <Buildings/logger.h>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class BridgeHistoryDialog;
|
||||
}
|
||||
|
||||
namespace LtsSession {
|
||||
class LtsSession;
|
||||
}
|
||||
|
||||
namespace Buildings
|
||||
{
|
||||
class BridgeHistoryDialogModel;
|
||||
class BridgeHistoryDialogProxyModel;
|
||||
|
||||
// --------------------------------------------------------
|
||||
// BuildingHistoryDialog
|
||||
// --------------------------------------------------------
|
||||
class BridgeHistoryDialog final : public LtsWidgets::LtsDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit BridgeHistoryDialog(const QString &bldName, QWidget *parent = nullptr);
|
||||
~BridgeHistoryDialog();
|
||||
|
||||
bool init(int ddsId, LtsSession::LtsSession *session);
|
||||
|
||||
private:
|
||||
void retranslate() override;
|
||||
|
||||
private:
|
||||
QString m_bldName;
|
||||
|
||||
BridgeHistoryDialogModel *m_model = nullptr;
|
||||
BridgeHistoryDialogProxyModel *m_proxyModel = nullptr;
|
||||
|
||||
Ui::BridgeHistoryDialog *m_ui = nullptr;
|
||||
LOGGER_T m_logger;
|
||||
};
|
||||
} // namespace Buildings
|
||||
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>BridgeHistoryDialog</class>
|
||||
<widget class="QWidget" name="BridgeHistoryDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>408</width>
|
||||
<height>230</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Player History </string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="LtsDataView::LtsDataView" name="tvHistory" native="true"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LtsDataView::LtsDataView</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>LtsDataView/lts_data_view.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,148 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Model for ParticipantHistory
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-07-07
|
||||
*/
|
||||
|
||||
#include "bridge_history_dialog_model.h"
|
||||
|
||||
#include <Buildings/bld_data_plugin_interface.h>
|
||||
#include <ProjectDataManagement/pdm_to_string.h>
|
||||
#include <ProjectDataManagement/pdm_data_plugin_interface.h>
|
||||
#include <ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
#include <AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <ngltools/ngltools_dtg.h>
|
||||
|
||||
#include <InfrastructureManagement/ism_enums.hpp>
|
||||
#include <InfrastructureManagement/ism_translation.h>
|
||||
|
||||
namespace Buildings
|
||||
{
|
||||
//---------------------------------
|
||||
// BridgeHistoryDialogModel
|
||||
//---------------------------------
|
||||
BridgeHistoryDialogModel::BridgeHistoryDialogModel(QObject *parent)
|
||||
: LtsWidgets::LtsAbstractTableModel<Buildings::BridgeStatus>(
|
||||
{
|
||||
tr("Time"),
|
||||
tr("State")
|
||||
},
|
||||
parent)
|
||||
, m_ddsId(-1)
|
||||
, m_logger(getLogger("BridgeHistoryDialogModel"))
|
||||
{}
|
||||
|
||||
bool BridgeHistoryDialogModel::initModel(int dds_id,
|
||||
LtsSession::LtsSession *session)
|
||||
{
|
||||
if (!session->getDtc<Buildings::DataInterface>(m_dtc))
|
||||
return false;
|
||||
m_ddsId = dds_id;
|
||||
|
||||
connect(m_dtc.get(), &Interface::Dtc::bridgeStatusChanged,
|
||||
this, &BridgeHistoryDialogModel::onHistoryStateChanged);
|
||||
|
||||
reinitModel(m_dtc->bridgeStatuss());
|
||||
return true;
|
||||
}
|
||||
|
||||
QVariant BridgeHistoryDialogModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!indexIsValid(index))
|
||||
return QVariant();
|
||||
|
||||
if (role != Qt::DisplayRole)
|
||||
return QVariant();
|
||||
|
||||
const BridgeStatus &data = m_vecData[index.row()];
|
||||
switch (index.column())
|
||||
{
|
||||
case Time:
|
||||
return QDateTime::fromMSecsSinceEpoch(data.sampleTime());
|
||||
case State:
|
||||
if(data.status() == 0) //Intact
|
||||
{
|
||||
return QString(toString(InfrastructureManagement::BridgeStatus::Intact));
|
||||
}
|
||||
else if (data.status() == 1) //Broken
|
||||
{
|
||||
return QString(toString(InfrastructureManagement::BridgeStatus::Broken));
|
||||
}
|
||||
return data.status();
|
||||
}
|
||||
return QVariant();
|
||||
|
||||
}
|
||||
|
||||
void BridgeHistoryDialogModel::onHistoryStateChanged(const BridgeStatus &/*data*/, DataModification modType)
|
||||
{
|
||||
if(!m_dtc)
|
||||
return;
|
||||
|
||||
if (modType == DataModification::eRemoved)
|
||||
{
|
||||
beginResetModel();
|
||||
m_vecData.clear();
|
||||
endResetModel();
|
||||
return;
|
||||
}
|
||||
reinitModel(m_dtc->bridgeStatuss());
|
||||
}
|
||||
|
||||
void BridgeHistoryDialogModel::reinitModel(const QMap<int, Buildings::BridgeStatus> &newData)
|
||||
{
|
||||
//only find create History for this BridgeID
|
||||
QVector<Buildings::BridgeStatus> relevantStates;
|
||||
for (auto& status : newData )
|
||||
{
|
||||
if(status.buildingId() != m_ddsId)
|
||||
continue;
|
||||
relevantStates.append(status);
|
||||
}
|
||||
|
||||
|
||||
beginResetModel();
|
||||
m_vecData.resize(relevantStates.size());
|
||||
|
||||
for(int i = 0; i <relevantStates.size(); ++i)
|
||||
{
|
||||
auto &data = m_vecData[i];
|
||||
data = relevantStates[i];
|
||||
}
|
||||
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
//
|
||||
// ExercisePhaseProxyModel
|
||||
//
|
||||
void BridgeHistoryDialogProxyModel::setSourceModel(QAbstractItemModel *sourceModel)
|
||||
{
|
||||
m_sourceModel = qobject_cast<BridgeHistoryDialogModel *>(sourceModel);
|
||||
LtsWidgets::LtsColumnFilterProxyModel::setSourceModel(sourceModel);
|
||||
}
|
||||
|
||||
bool BridgeHistoryDialogProxyModel::lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const
|
||||
{
|
||||
if (!m_sourceModel ||
|
||||
source_left.column() != source_right.column() ||
|
||||
!source_left.isValid() ||
|
||||
!source_right.isValid())
|
||||
return LtsWidgets::LtsColumnFilterProxyModel::lessThan(source_left, source_right);
|
||||
const auto &dataLeft = m_sourceModel->m_vecData.at(source_left.row());
|
||||
const auto dataRight = m_sourceModel->m_vecData.at(source_right.row());
|
||||
switch (source_left.column())
|
||||
{
|
||||
case BridgeHistoryDialogModel::Time:
|
||||
return dataLeft.sampleTime() < dataRight.sampleTime();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace Building
|
||||
@@ -0,0 +1,96 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Model for Participant History
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-07-07
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
//Lts
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
#include <LtsWidgets/lts_column_filter_proxy_model.h>
|
||||
|
||||
//Buildings
|
||||
#include <Buildings/logger.h>
|
||||
#include <Buildings/bld.hpp>
|
||||
|
||||
#include <Buildings/bld_data_plugin_interface.h>
|
||||
|
||||
namespace LtsSession {
|
||||
class LtsSession;
|
||||
}
|
||||
|
||||
namespace ProjectDataManagement
|
||||
{
|
||||
namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
|
||||
namespace Buildings
|
||||
{
|
||||
|
||||
// --------------------------------------------------------
|
||||
// BridgeHistoryDialogModel
|
||||
// --------------------------------------------------------
|
||||
class BridgeHistoryDialogModel final : public LtsWidgets::LtsAbstractTableModel<BridgeStatus>
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum Column
|
||||
{
|
||||
Time,
|
||||
State
|
||||
};
|
||||
explicit BridgeHistoryDialogModel(QObject *parent = nullptr);
|
||||
|
||||
bool initModel(int dds_id,
|
||||
LtsSession::LtsSession *session);
|
||||
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
|
||||
private Q_SLOTS:
|
||||
void onHistoryStateChanged(const BridgeStatus &data, DataModification modType);
|
||||
|
||||
private:
|
||||
void reinitModel(const QMap<int, BridgeStatus> &newData);
|
||||
int m_ddsId;
|
||||
std::shared_ptr<Interface::Dtc> m_dtc;
|
||||
|
||||
LOGGER_T m_logger;
|
||||
|
||||
friend class BridgeHistoryDialogProxyModel;
|
||||
};
|
||||
|
||||
class BridgeHistoryDialogProxyModel final : public LtsWidgets::LtsColumnFilterProxyModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
using LtsWidgets::LtsColumnFilterProxyModel::LtsColumnFilterProxyModel;
|
||||
void setSourceModel(QAbstractItemModel *sourceModel) override;
|
||||
protected:
|
||||
bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const override;
|
||||
private:
|
||||
BridgeHistoryDialogModel *m_sourceModel = nullptr;
|
||||
};
|
||||
} //namespace ParticipantManagement
|
||||
@@ -0,0 +1,257 @@
|
||||
/**
|
||||
*@RDE_HEADER@
|
||||
* GUI Plugin for Building - Info
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2017-04-05
|
||||
*/
|
||||
|
||||
#include "bridge_info_dialog.h"
|
||||
#include "ui_bridge_info_dialog.h"
|
||||
#include "bridge_history_dialog.h"
|
||||
#include "bridge_history_dialog_model.h"
|
||||
#include "relay_info.h"
|
||||
|
||||
// Lts
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsWidgets/lts_global_wait_dialog.h>
|
||||
#include <InfrastructureManagement/ism_enums.hpp>
|
||||
#include <InfrastructureManagement/ism_translation.h>
|
||||
|
||||
// DDS
|
||||
#include <AssetManagement/asm_data_plugin_interface.h>
|
||||
#include <InfrastructureManagement/ism_dtc.h>
|
||||
#include <Buildings/bld_dtc.h>
|
||||
|
||||
#include <QPainter>
|
||||
|
||||
namespace Buildings
|
||||
{
|
||||
|
||||
int ICON_SIZE = 64;
|
||||
|
||||
QImage renderBridge(bool intact, const QColor &color, qreal dpr)
|
||||
{
|
||||
int size = ICON_SIZE;
|
||||
QPixmap preIcon(QSize(size, size) * dpr);
|
||||
preIcon.fill(Qt::transparent);
|
||||
preIcon.setDevicePixelRatio(dpr);
|
||||
|
||||
QImage image(preIcon.toImage().convertToFormat(QImage::Format_ARGB32));
|
||||
image.fill(Qt::transparent);
|
||||
|
||||
QPainter painter(&image);
|
||||
painter.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
|
||||
|
||||
// fillPattern:
|
||||
painter.setPen(QPen(Qt::NoPen)); // rect with no outter line
|
||||
if (intact)
|
||||
painter.setBrush(QBrush(color, Qt::SolidPattern)); // fillPattern (Dense4Pattern .. Dense6Pattern)
|
||||
else
|
||||
painter.setBrush(QBrush(color, Qt::DiagCrossPattern));
|
||||
painter.drawRect(image.rect());
|
||||
|
||||
|
||||
// prepare remaining:
|
||||
QPen pen(Qt::black);
|
||||
pen.setWidth(3);
|
||||
painter.setPen(pen);
|
||||
|
||||
const int sizeQuarter = size / 3.0;
|
||||
|
||||
// lines
|
||||
QLine newLine(size*0.2, sizeQuarter, size*0.8, sizeQuarter);
|
||||
painter.drawLine(newLine);
|
||||
|
||||
newLine = QLine(size*0.2, size-sizeQuarter, size*0.8, size-sizeQuarter);
|
||||
painter.drawLine(newLine);
|
||||
|
||||
painter.end();
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
BridgeInfoDialog::BridgeInfoDialog(int assetId, const QString &menuGroup, QWidget *parent)
|
||||
: InfoDialogBase(assetId, menuGroup, QStringLiteral("BridgeInfoDialog"), LtsWidgets::ButtonCombination::CloseOnly, parent)
|
||||
, m_ui(new Ui::BridgeInfoDialog)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Info_Dialog-Bridge"));
|
||||
} // end of ctor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
BridgeInfoDialog::~BridgeInfoDialog()
|
||||
{
|
||||
//delete m_stateTimer;
|
||||
delete m_ui;
|
||||
} // end of dtor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void BridgeInfoDialog::retranslate()
|
||||
{
|
||||
if (m_mse.structureElementTypeId() == InfrastructureManagement::StructureElementType::Bridge)
|
||||
translate(m_ui, tr("Bridge: %1").arg( m_ismDtc->getBuildingDisplayName(m_mse)));
|
||||
else
|
||||
translate(m_ui, tr("Building: %1").arg( m_ismDtc->getBuildingDisplayName(m_mse)));
|
||||
}
|
||||
|
||||
bool BridgeInfoDialog::init(LtsSession::LtsSession *session)
|
||||
{
|
||||
if (!InfoDialogBase::init(session))
|
||||
return false;
|
||||
|
||||
if (!m_session->getForeignGuiInterface<InfrastructureManagement::ForeignGuiComboboxInterface>(m_ismCbxIfc))
|
||||
return false;
|
||||
|
||||
if (!m_session->getFtc<InfrastructureManagement::DataInterface>(m_ismFtc))
|
||||
return false;
|
||||
|
||||
m_ismDtc->enableMainStructureElement();
|
||||
m_ismDtc->enableBridgeChangeStatus();
|
||||
|
||||
m_ismDtc->waitForHistoricalDataMainStructureElement();
|
||||
m_ismDtc->waitForHistoricalDataBridgeChangeStatus();
|
||||
|
||||
m_ismFtc->enableMainStructureElementModifyBridgeStatus();
|
||||
|
||||
m_mse = m_ismDtc->mainStructureElement(m_mseId);
|
||||
|
||||
//render Icons
|
||||
const auto dpr = devicePixelRatioF();
|
||||
m_icon_pixmaps[InfrastructureManagement::BridgeStatus::Intact] = QPixmap::fromImage(renderBridge(true, Qt::darkGray, dpr ));
|
||||
m_icon_pixmaps[InfrastructureManagement::BridgeStatus::Broken] = QPixmap::fromImage(renderBridge(false, Qt::lightGray, dpr ));
|
||||
|
||||
initUI();
|
||||
|
||||
connect(m_ismDtc.get(), &InfrastructureManagement::Interface::Dtc::mainStructureElementChanged,
|
||||
this, &BridgeInfoDialog::onMainStructureElementChanged);
|
||||
|
||||
showBridgeInfos();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QString BridgeInfoDialog::buildingDisplayName() const
|
||||
{
|
||||
return m_ismDtc->getBuildingDisplayName(m_mse);
|
||||
}
|
||||
|
||||
|
||||
void BridgeInfoDialog::showBuildingInfos()
|
||||
{
|
||||
// Nothing to do...
|
||||
}
|
||||
|
||||
|
||||
void BridgeInfoDialog::onMainStructureElementChanged(const InfrastructureManagement::MainStructureElement &/*data*/, DataModification modType)
|
||||
{
|
||||
if (modType == DataModification::eRemoved)
|
||||
return;
|
||||
showBridgeInfos();
|
||||
}
|
||||
|
||||
void BridgeInfoDialog::showBridgeInfos()
|
||||
{
|
||||
m_ui->lblBuildingName->setText(buildingDisplayName());
|
||||
|
||||
if (m_mse.structureElementTypeId() == InfrastructureManagement::StructureElementType::Bridge)
|
||||
{
|
||||
m_ui->lbStatus->show();
|
||||
m_ui->cbStatus->show();
|
||||
m_ui->cbStatus->blockSignals(true);
|
||||
m_ui->cbStatus->setCurrentText(InfrastructureManagement::toString(m_ismDtc->getBridgeStatus(m_mseId)));
|
||||
m_ui->lblIcon->setPixmap(m_icon_pixmaps[m_ismDtc->getBridgeStatus(m_mseId)]);
|
||||
m_ui->cbStatus->blockSignals(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ui->lbStatus->hide();
|
||||
m_ui->cbStatus->hide();
|
||||
}
|
||||
}
|
||||
|
||||
void BridgeInfoDialog::initUI()
|
||||
{
|
||||
m_ui->lblIcon->setVisible(true);
|
||||
// m_ui->lblIcon->setFixedSize(ICON_SIZE, ICON_SIZE);
|
||||
|
||||
m_ui->lblIcon->setPixmap(m_icon_pixmaps[m_ismDtc->getBridgeStatus(m_mseId)]);
|
||||
|
||||
m_ui->cbStatus->blockSignals(true);
|
||||
m_ismCbxIfc->fillBridgeStatusComboBox(m_ui->cbStatus);
|
||||
m_ui->cbStatus->blockSignals(false);
|
||||
|
||||
|
||||
m_ui->pbHistory->setToolTip(tr("Show bridge history"));
|
||||
// SET UI Infos
|
||||
|
||||
m_ui->pbFindOnMap->hide();
|
||||
m_ui->pbFindOnMap->setToolTip(tr("Locate bridge on map"));
|
||||
m_ui->pbDetails->hide();
|
||||
m_ui->pbDetails->setToolTip(tr("Show bridge status"));
|
||||
m_ui->pbBuildingViewer->hide();
|
||||
m_ui->pbBuildingViewer->setToolTip(tr("Show bridge in BuildingViewer"));
|
||||
m_ui->pbMonitor->hide();
|
||||
m_ui->pbMonitor->setToolTip(tr("Show EGCU monitor"));
|
||||
|
||||
connect(m_ui->cbStatus, &LtsWidgets::LtsComboBox::currentTextChanged, this, &BridgeInfoDialog::bridgeStatusChanged);
|
||||
|
||||
connect(m_ui->pbHistory, &QToolButton::clicked, this, &BridgeInfoDialog::onOpenHistory);
|
||||
connect(m_ui->pbFindOnMap, &QToolButton::clicked, this, &BridgeInfoDialog::onFindOnMap);
|
||||
connect(m_ui->pbDetails, &QToolButton::clicked, this, &BridgeInfoDialog::onShowDetails);
|
||||
connect(m_ui->pbBuildingViewer, &QToolButton::clicked, this, &BridgeInfoDialog::onShowBuildingViewer);
|
||||
connect(m_ui->pbMonitor, &QToolButton::clicked, this, &BridgeInfoDialog::onShowEgcuMonitor);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void BridgeInfoDialog::bridgeStatusChanged()
|
||||
{
|
||||
INFO_LOG(m_logger) << "trying to send MainStructureElementModifyBridgeStatusRequest ";
|
||||
|
||||
InfrastructureManagement::MainStructureElementModifyBridgeStatusRequest data;
|
||||
|
||||
// creating ModifyRequest
|
||||
data.id(m_mse.id());
|
||||
switch (m_ui->cbStatus->currentData().toInt())
|
||||
{
|
||||
case InfrastructureManagement::BridgeStatus::Intact:
|
||||
data.status(InfrastructureManagement::BridgeStatus::Intact);
|
||||
break;
|
||||
case InfrastructureManagement::BridgeStatus_def::Broken:
|
||||
data.status(InfrastructureManagement::BridgeStatus::Broken);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// E-01562-142 Absturz der Excon durch Bruecke
|
||||
// Request Aufruf geaendert, da der Dialog bei Statusaenderung geschlossen wird.
|
||||
// this ist dadurch nicht mehr gültig
|
||||
try
|
||||
{
|
||||
Waiter _(this);
|
||||
m_ismFtc->mainStructureElementModifyBridgeStatusRequest(data);
|
||||
}
|
||||
catch (const std::exception& ex)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error requesting modify bridge status: " << ex.what();
|
||||
}
|
||||
}
|
||||
|
||||
void BridgeInfoDialog::onOpenHistory()
|
||||
{
|
||||
BridgeHistoryDialog *diag = new BridgeHistoryDialog(buildingDisplayName(), this);
|
||||
if (diag->init(m_mseId, m_session))
|
||||
{
|
||||
addDialog(diag, m_menuGroup, QStringLiteral("Building History") + QString::number(m_mseId), LtsWidgets::LayoutArea::eDialogTab);
|
||||
}
|
||||
else
|
||||
{
|
||||
delete diag;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Buildings
|
||||
@@ -0,0 +1,89 @@
|
||||
/**
|
||||
*@RDE_HEADER@
|
||||
* GUI Plugin for Building- Info
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2017-04-05
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
//Buildings
|
||||
#include "info_dialog_base.h"
|
||||
|
||||
// DDS
|
||||
#include <AssetManagement/asm.hpp>
|
||||
#include <InfrastructureManagement/ism.hpp>
|
||||
#include <LtsUtilsCore/data_modification_enum.h>
|
||||
#include <Plugins/Buildings/bld_data_plugin_interface.h>
|
||||
|
||||
#include <InfrastructureManagement/ism_combobox_gui_plugin_interface.h>
|
||||
//#include <InfrastructureManagement/ism_resource_management_gui_plugin_interface.h>
|
||||
#include <InfrastructureManagement/ism_data_plugin_interface.h>
|
||||
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
|
||||
class QUrl;
|
||||
class QVBoxLayout;
|
||||
|
||||
namespace InfrastructureManagement
|
||||
{
|
||||
class ForeignGuiComboboxInterface;
|
||||
class ForeignDataInterface;
|
||||
}
|
||||
namespace Ui
|
||||
{
|
||||
class BridgeInfoDialog;
|
||||
}
|
||||
namespace AssetManagement
|
||||
{
|
||||
namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
namespace LtsSession
|
||||
{
|
||||
class LtsSession;
|
||||
}
|
||||
|
||||
namespace Buildings
|
||||
{
|
||||
// --------------------------------------------------------
|
||||
// BridgeInfoDialog
|
||||
// --------------------------------------------------------
|
||||
class BridgeInfoDialog : public InfoDialogBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit BridgeInfoDialog(int assetId, const QString &menuGroup, QWidget *parent = nullptr);
|
||||
~BridgeInfoDialog();
|
||||
|
||||
bool init(LtsSession::LtsSession *session) override;
|
||||
|
||||
QString buildingDisplayName() const override;
|
||||
|
||||
private:
|
||||
void retranslate() override;
|
||||
void showBuildingInfos() override;
|
||||
//void startRequest(const QUrl &requestedUrl);
|
||||
void showBridgeInfos();
|
||||
void initUI();
|
||||
|
||||
private slots:
|
||||
void onMainStructureElementChanged(const InfrastructureManagement::MainStructureElement &data, DataModification modType);
|
||||
void bridgeStatusChanged();
|
||||
void onOpenHistory();
|
||||
|
||||
private:
|
||||
Ui::BridgeInfoDialog *m_ui {nullptr};
|
||||
std::shared_ptr<Buildings::Interface::Ftc> m_ftc;
|
||||
std::shared_ptr<Buildings::Interface::Dtc> m_bldDtc;
|
||||
InfrastructureManagement::MainStructureElement m_mse;
|
||||
std::shared_ptr<InfrastructureManagement::ForeignGuiComboboxInterface> m_ismCbxIfc {nullptr};
|
||||
std::shared_ptr<InfrastructureManagement::Interface::Ftc> m_ismFtc {nullptr};
|
||||
QMap<InfrastructureManagement::BridgeStatus, QPixmap> m_icon_pixmaps;
|
||||
};
|
||||
} // namespace Buildings
|
||||
@@ -0,0 +1,242 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>BridgeInfoDialog</class>
|
||||
<widget class="QWidget" name="BridgeInfoDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>257</width>
|
||||
<height>701</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>257</width>
|
||||
<height>320</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Segment Info</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout" columnstretch="0,0,0,0,0,0">
|
||||
<item row="3" column="3">
|
||||
<widget class="QToolButton" name="pbFindOnMap">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/style/center_to_object.svg</normaloff>:/style/center_to_object.svg</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="4">
|
||||
<widget class="QToolButton" name="pbBuildingViewer">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>39</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/style/3d_viewer.svg</normaloff>:/style/3d_viewer.svg</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0" colspan="2">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="3">
|
||||
<widget class="QToolButton" name="pbDetails">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/style/pi_set_player_mode.svg</normaloff>:/style/pi_set_player_mode.svg</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QToolButton" name="pbMonitor">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/style/system_status.svg</normaloff>:/style/system_status.svg</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lbxBuildingName">
|
||||
<property name="text">
|
||||
<string>Bridge:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="lblBuildingName">
|
||||
<property name="text">
|
||||
<string notr="true"><BUILDINGNAME></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="4">
|
||||
<widget class="QToolButton" name="pbHistory">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/style/pi_tact_status_history.svg</normaloff>:/style/pi_tact_status_history.svg</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lbStatus">
|
||||
<property name="text">
|
||||
<string>Status:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="LtsWidgets::LtsComboBox" name="cbStatus"/>
|
||||
</item>
|
||||
<item row="3" column="5">
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="5">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lblIcon">
|
||||
<property name="text">
|
||||
<string notr="true"><ICON></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LtsWidgets::LtsComboBox</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header>LtsWidgets/lts_combo_box.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
+381
@@ -0,0 +1,381 @@
|
||||
/**
|
||||
*@RDE_HEADER@
|
||||
* GUI Plugin for Building - Info
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2017-04-05
|
||||
*/
|
||||
|
||||
#include "egcu_info_dialog.h"
|
||||
#include "ui_egcu_info_dialog.h"
|
||||
#include "relay_info.h"
|
||||
|
||||
// Lts
|
||||
#include <LtsSession/lts_session.h>
|
||||
|
||||
// DDS
|
||||
#include <AssetManagement/asm_data_plugin_interface.h>
|
||||
#include <InfrastructureManagement/ism_dtc.h>
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonArray>
|
||||
|
||||
namespace Buildings
|
||||
{
|
||||
|
||||
EgcuInfoDialog::EgcuInfoDialog(int assetId, const QString &menuGroup, QWidget *parent)
|
||||
: InfoDialogBase(assetId, menuGroup, QStringLiteral("EgcuInfoDialog"), LtsWidgets::ButtonCombination::CloseOnly, parent)
|
||||
, m_ui(new Ui::EgcuInfoDialog)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_assetId(assetId)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "EgcuInfoDialog::EgcuInfoDialog";
|
||||
m_ui->setupUi(this);
|
||||
m_ui->lblIcon->setPixmap(QPixmap(QStringLiteral(":/icons/svg/bgv_effect_generation_unit.svg")));
|
||||
setOnlineHelpFilename(QStringLiteral("Info_Dialog-Effect_Generation_Control_Unit"));
|
||||
|
||||
#ifndef LTS_DEBUG
|
||||
m_ui->lblAssetId->hide();
|
||||
m_ui->lbxAssetId->hide();
|
||||
m_ui->lblAssetName->hide();
|
||||
m_ui->lbxAssetName->hide();
|
||||
#endif
|
||||
|
||||
} // end of ctor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
EgcuInfoDialog::~EgcuInfoDialog()
|
||||
{
|
||||
//delete m_stateTimer;
|
||||
delete m_ui;
|
||||
DEBUG_LOG(m_logger) << "EgcuInfoDialog::~EgcuInfoDialog";
|
||||
} // end of dtor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void EgcuInfoDialog::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("Segment: %1").arg(m_ui->lblSegment->text().isEmpty() ? m_ui->lblAssetName->text() : m_ui->lblSegment->text()));
|
||||
}
|
||||
|
||||
bool EgcuInfoDialog::init(LtsSession::LtsSession *session)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "EgcuInfoDialog::init";
|
||||
if (!InfoDialogBase::init(session))
|
||||
return false;
|
||||
|
||||
// Get ASM DTC for RelayInfos
|
||||
if (!m_session->getDtc<AssetManagement::DataInterface>(m_asmDtc))
|
||||
return false;
|
||||
m_asmDtc->enableRelayInfo();
|
||||
|
||||
m_relayLayout = new QVBoxLayout(m_ui->widgetRelais);
|
||||
m_relayLayout->setMargin(0);
|
||||
m_ui->widgetRelais->setLayout(m_relayLayout);
|
||||
|
||||
auto cbRelayInfos = [this](const AssetManagement::RelayInfo & c)
|
||||
{
|
||||
onRelayInfoChanged(c, DataModification::eAdded);
|
||||
};
|
||||
|
||||
m_asmDtc->waitForHistoricalDataRelayInfo();
|
||||
m_asmDtc->relayInfos(cbRelayInfos);
|
||||
|
||||
connect(m_asmDtc.get(), &AssetManagement::Interface::Dtc::relayInfoChanged,
|
||||
this, &EgcuInfoDialog::onRelayInfoChanged);
|
||||
|
||||
|
||||
// FTC for sending Relay changes:
|
||||
if (!session->getFtc<InfrastructureManagement::DataInterface>(m_ftc))
|
||||
return false;
|
||||
// m_ftc->enableMainStructureElementModify();
|
||||
m_ftc->enableStructureElementUpdateEffectOverride();
|
||||
|
||||
|
||||
// Which EGCU is on this MountingPoint?
|
||||
m_ismDtc->enableMountingPointAsset();
|
||||
auto cbMountPoint = [this](const InfrastructureManagement::MountingPointAsset & c)
|
||||
{
|
||||
onMountPointAssetChanged(c, DataModification::eAdded);
|
||||
};
|
||||
// used by onMountPointAssetChanged
|
||||
m_ismDtc->enableInstrumentationAsset();
|
||||
m_ismDtc->mountingPointAssets(cbMountPoint);
|
||||
|
||||
|
||||
connect(m_ismDtc.get(), &InfrastructureManagement::Interface::Dtc::instrumentationAssetChanged,
|
||||
this, &EgcuInfoDialog::onInstrumentationAssetChanged);
|
||||
connect(m_ismDtc.get(), &InfrastructureManagement::Interface::Dtc::mainStructureElementChanged,
|
||||
this, &EgcuInfoDialog::onMainStructureElementChanged);
|
||||
connect(m_ismDtc.get(), &InfrastructureManagement::Interface::Dtc::mountingPointAssetChanged,
|
||||
this, &EgcuInfoDialog::onMountPointAssetChanged);
|
||||
|
||||
////////////////////
|
||||
/// Relay State ///
|
||||
////////////////////
|
||||
|
||||
m_dtc->enableRelayState();
|
||||
m_dtc->waitForHistoricalDataRelayState(10000);
|
||||
|
||||
m_dtc->relayStates([this](const Buildings::RelayState & sample)
|
||||
{
|
||||
onRelayStateChanged(sample, DataModification::eAdded);
|
||||
});
|
||||
|
||||
connect(m_dtc.get(), &Buildings::Interface::Dtc::relayStateChanged,
|
||||
this, &EgcuInfoDialog::onRelayStateChanged);
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QString EgcuInfoDialog::buildingDisplayName() const
|
||||
{
|
||||
return m_ui->lblBuildingName->text();
|
||||
}
|
||||
|
||||
QString EgcuInfoDialog::structureElementName(int seId)
|
||||
{
|
||||
InfrastructureManagement::StructureElement se;
|
||||
m_ismDtc->getStructureElementById(seId, se);
|
||||
return QString::fromStdString(se.displayName());
|
||||
}
|
||||
|
||||
void EgcuInfoDialog::showBuildingInfos()
|
||||
{
|
||||
// Nothing to do...
|
||||
}
|
||||
|
||||
void EgcuInfoDialog::onInstrumentationAssetChanged(
|
||||
const InfrastructureManagement::InstrumentationAsset &data, DataModification modType)
|
||||
{
|
||||
if (modType != DataModification::eAdded &&
|
||||
modType != DataModification::eModified)
|
||||
return;
|
||||
DEBUG_LOG(m_logger) << "onInstrumentationAssetChanged id:" << data.id();
|
||||
// Todo: Check, wether this impacts functionality!
|
||||
// if (data.mountingPointTypeId() == InfrastructureManagement::MountingPointType_def::EffectGenerationControlUnit
|
||||
// && data.assetStateId() == InfrastructureManagement::InstrumentationAssetState_def::Mounted)
|
||||
if (data.id() != m_instrumentationAsset.id())
|
||||
return;
|
||||
DEBUG_LOG(m_logger) << "Insert instrumentation asset id=" << data.id();
|
||||
m_instrumentationAsset = data;
|
||||
showEgcuInfos();
|
||||
}
|
||||
|
||||
void EgcuInfoDialog::onMainStructureElementChanged(const InfrastructureManagement::MainStructureElement &data, DataModification modType)
|
||||
{
|
||||
if (modType == DataModification::eRemoved)
|
||||
return;
|
||||
|
||||
if (data.id() != m_structureElement.mainStructureElementId())
|
||||
return;
|
||||
for (const auto &se : data.elements())
|
||||
{
|
||||
if (se.id() != m_structureElement.id())
|
||||
continue;
|
||||
m_structureElement = se;
|
||||
showEgcuInfos(se);
|
||||
}
|
||||
}
|
||||
|
||||
void EgcuInfoDialog::onEffectOverrideChanged(int relayId, InfrastructureManagement::EffectOverride override)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "onEffectOverrideChanged"
|
||||
<< " m_structureElement.id=" << m_structureElement.id()
|
||||
<< " relayId=" << relayId
|
||||
<< " override=" << override;
|
||||
// auto copy = m_structureElement;
|
||||
// udpatePropertiesForRelayOverride(relayId, override, copy);
|
||||
// InfrastructureManagement::StructureElementModifyRequest request;
|
||||
// request.mainStructureElementId(copy.mainStructureElementId());
|
||||
// request.elements().resize(1);
|
||||
// request.elements().at(0) = copy;
|
||||
// m_requestHelper->startSingleRequest([request, this]()
|
||||
// {
|
||||
// return m_ftc->structureElementModifyRequest(request, this);
|
||||
// });
|
||||
InfrastructureManagement::StructureElementUpdateEffectOverrideRequest request;
|
||||
request.structureElementId(m_structureElement.id());
|
||||
request.effectId(relayId);
|
||||
request.effectOverride(override);
|
||||
m_requestHelper->startSingleRequest([request, this]()
|
||||
{
|
||||
return m_ftc->structureElementUpdateEffectOverrideRequest(request, this);
|
||||
});
|
||||
}
|
||||
|
||||
void EgcuInfoDialog::onRelayInfoChanged(const AssetManagement::RelayInfo &data, DataModification modType)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "onRelayInfosChanged id:" << data.id();
|
||||
if (modType == DataModification::eRemoved)
|
||||
{
|
||||
if (m_relayInfoWidgets.contains(data.id()))
|
||||
{
|
||||
m_relayInfoWidgets[data.id()]->deleteLater();
|
||||
m_relayInfoWidgets.remove(data.id());
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (m_relayInfoWidgets.contains(data.id()))
|
||||
{
|
||||
m_relayInfoWidgets[data.id()]->setName(QString::fromStdString(data.name()));
|
||||
DEBUG_LOG(m_logger) << "contains Name=" << QString::fromStdString(data.name());
|
||||
}
|
||||
else
|
||||
{
|
||||
RelayInfoWidget *w = new RelayInfoWidget(data.id(), this);
|
||||
m_relayInfoWidgets.insert(data.id(), w);
|
||||
w->setName(QString::fromStdString(data.name()));
|
||||
DEBUG_LOG(m_logger) << "Name=" << QString::fromStdString(data.name());
|
||||
connect(w, &RelayInfoWidget::effectOverrideChanged, this, &EgcuInfoDialog::onEffectOverrideChanged);
|
||||
w->setEffectOverrideEnabled(InfrastructureManagement::EffectOverride::PermanentOn, readAllowance(InfrastructureManagement::EffectOverride::PermanentOn, data.property()));
|
||||
w->setEffectOverrideEnabled(InfrastructureManagement::EffectOverride::PermanentOff, readAllowance(InfrastructureManagement::EffectOverride::PermanentOff, data.property()));
|
||||
w->setLedVisible(readShowStatus(data.property()));
|
||||
m_relayLayout->addWidget(w);
|
||||
}
|
||||
|
||||
DEBUG_LOG(m_logger) << "data.name=" << data.name();
|
||||
} // end of onRelayInfosChanged()
|
||||
|
||||
bool EgcuInfoDialog::readAllowance(InfrastructureManagement::EffectOverride eo, const std::string &properties)
|
||||
{
|
||||
QJsonParseError parserError;
|
||||
QByteArray content = QByteArray::fromStdString(properties);
|
||||
const QJsonDocument doc(QJsonDocument::fromJson(content, &parserError));
|
||||
|
||||
if (parserError.error != QJsonParseError::NoError)
|
||||
return true;
|
||||
|
||||
QJsonObject docObj = QJsonObject(doc.object());
|
||||
if (eo == InfrastructureManagement::EffectOverride_def::PermanentOn)
|
||||
return docObj.value(QStringLiteral("allowPermanentOn")).toBool(true);
|
||||
else if (eo == InfrastructureManagement::EffectOverride_def::PermanentOff)
|
||||
return docObj.value(QStringLiteral("allowPermanentOff")).toBool(true);
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EgcuInfoDialog::readShowStatus(const std::string &properties)
|
||||
{
|
||||
QJsonParseError parserError;
|
||||
QByteArray content = QByteArray::fromStdString(properties);
|
||||
const QJsonDocument doc(QJsonDocument::fromJson(content, &parserError));
|
||||
|
||||
if (parserError.error != QJsonParseError::NoError)
|
||||
return true;
|
||||
|
||||
QJsonObject docObj = QJsonObject(doc.object());
|
||||
return docObj.value(QStringLiteral("showStatus")).toBool(true);
|
||||
}
|
||||
|
||||
void EgcuInfoDialog::onRelayStateChanged(const Buildings::RelayState &data, DataModification modType)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "onRelayStateChanged id:" << data.id();
|
||||
if (modType != DataModification::eAdded &&
|
||||
modType != DataModification::eModified)
|
||||
return;
|
||||
|
||||
if (data.id() != m_instrumentationAsset.id())
|
||||
return;
|
||||
|
||||
for (const Buildings::RelayStateItem &relayState : data.relayStates())
|
||||
{
|
||||
if (!m_relayInfoWidgets.contains(relayState.id()))
|
||||
continue;
|
||||
m_relayInfoWidgets[relayState.id()]->setState(relayState.state(),
|
||||
data.stateTime(),
|
||||
data.offlineTime());
|
||||
}
|
||||
} // end of onRelayInfosChanged()
|
||||
|
||||
void EgcuInfoDialog::onMountPointAssetChanged(const InfrastructureManagement::MountingPointAsset &data, DataModification modType)
|
||||
{
|
||||
if (m_assetId != data.assetId())
|
||||
return;
|
||||
|
||||
if (modType != DataModification::eAdded &&
|
||||
modType != DataModification::eModified)
|
||||
{
|
||||
deleteLater();
|
||||
return;
|
||||
}
|
||||
|
||||
m_instrumentationAsset = m_ismDtc->instrumentationAsset(data.assetId());
|
||||
m_ismDtc->getStructureElementById(data.structureElementId(), m_structureElement);
|
||||
m_ui->lblSegment->setText(QString::fromStdString(data.name()));
|
||||
showEgcuInfos(m_structureElement);
|
||||
// To change title:
|
||||
retranslate();
|
||||
}
|
||||
// end of onMountPointAssetChanged()
|
||||
|
||||
|
||||
void EgcuInfoDialog::showEgcuInfos(const InfrastructureManagement::StructureElement &se)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "EgcuInfoDialog::showEgcuInfos";
|
||||
m_ui->lblAssetName->setText(QString::fromStdString(m_instrumentationAsset.name()));
|
||||
m_ui->lblAssetId->setText(QString::number(m_instrumentationAsset.id()));
|
||||
m_ui->lblHostName->setText(QString::fromStdString(m_instrumentationAsset.hostname()));
|
||||
// SET UI Infos
|
||||
|
||||
if (se.id() == 0)
|
||||
return;
|
||||
|
||||
m_ui->lblRoom->hide();
|
||||
m_ui->lbxRoom->hide();
|
||||
m_ui->lblFloor->hide();
|
||||
m_ui->lbxFloor->hide();
|
||||
|
||||
switch (se.path().size()) {
|
||||
case 4:
|
||||
m_ui->lblRoom->setText(structureElementName(se.path()[2]));
|
||||
m_ui->lblRoom->show();
|
||||
m_ui->lbxRoom->show();
|
||||
Q_FALLTHROUGH();
|
||||
case 3:
|
||||
m_ui->lblFloor->setText(structureElementName(se.path()[1]));
|
||||
m_ui->lblFloor->show();
|
||||
m_ui->lbxFloor->show();
|
||||
Q_FALLTHROUGH();
|
||||
case 2:
|
||||
{
|
||||
m_ui->lblBuildingName->setText(structureElementName(se.path()[0]));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Set the correct Button down:
|
||||
|
||||
QJsonParseError parserError;
|
||||
QByteArray content = QByteArray::fromStdString(se.properties());
|
||||
const QJsonDocument doc(QJsonDocument::fromJson(content, &parserError));
|
||||
|
||||
if (parserError.error != QJsonParseError::NoError)
|
||||
return;
|
||||
|
||||
QJsonObject docObj = QJsonObject(doc.object());
|
||||
|
||||
QJsonObject overridesObj = docObj.value(QStringLiteral("Overrides")).toObject();
|
||||
QJsonArray arrRelays = overridesObj.value(QStringLiteral("relays")).toArray();
|
||||
|
||||
QList<int> allRelayIds = m_relayInfoWidgets.keys();
|
||||
for (int i=0; i<arrRelays.size(); ++i)
|
||||
{
|
||||
QJsonObject objState = arrRelays[i].toObject();
|
||||
QStringList relayIds = objState.keys();
|
||||
QString relayIdString = relayIds.at(0);
|
||||
int relayId = relayIdString.toInt();
|
||||
allRelayIds.removeOne(relayId);
|
||||
int value = objState.value(relayIdString).toInt();
|
||||
if (m_relayInfoWidgets.contains(relayId))
|
||||
m_relayInfoWidgets[relayId]->setEffectOverride(static_cast<InfrastructureManagement::EffectOverride::inner_enum>(value));
|
||||
}
|
||||
for (auto relayId : qAsConst(allRelayIds))
|
||||
m_relayInfoWidgets[relayId]->setEffectOverride(InfrastructureManagement::EffectOverride_def::Automatic);
|
||||
}
|
||||
|
||||
} // namespace Buildings
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
/**
|
||||
*@RDE_HEADER@
|
||||
* GUI Plugin for Building- Info
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2017-04-05
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
//Lts
|
||||
#include <LtsUtilsGuiDds/request_helper.h>
|
||||
|
||||
//Buildings
|
||||
#include "info_dialog_base.h"
|
||||
|
||||
// DDS
|
||||
#include <AssetManagement/asm.hpp>
|
||||
#include <InfrastructureManagement/ism.hpp>
|
||||
#include <LtsUtilsCore/data_modification_enum.h>
|
||||
#include <Buildings/bld_data_plugin_interface.h>
|
||||
#include <Plugins/InfrastructureManagement/ism_data_plugin_interface.h>
|
||||
|
||||
class QUrl;
|
||||
class QVBoxLayout;
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class EgcuInfoDialog;
|
||||
}
|
||||
namespace AssetManagement
|
||||
{
|
||||
namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
namespace LtsSession
|
||||
{
|
||||
class LtsSession;
|
||||
}
|
||||
|
||||
namespace Buildings
|
||||
{
|
||||
|
||||
class RelayInfoWidget;
|
||||
|
||||
// --------------------------------------------------------
|
||||
// BuildingInfoDialog
|
||||
// --------------------------------------------------------
|
||||
class EgcuInfoDialog : public InfoDialogBase
|
||||
//, protected InfrastructureManagement::Interface::Ftc::StructureElementModifyReplyHandler
|
||||
, protected InfrastructureManagement::Interface::Ftc::StructureElementUpdateEffectOverrideReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit EgcuInfoDialog(int assetId, const QString &menuGroup, QWidget *parent = nullptr);
|
||||
~EgcuInfoDialog();
|
||||
|
||||
bool init(LtsSession::LtsSession *session) override;
|
||||
|
||||
//void onStructureElementModifyReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
|
||||
void onStructureElementUpdateEffectOverrideReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
|
||||
|
||||
QString buildingDisplayName() const override;
|
||||
QString egcuName() const { return QString::fromStdString(m_instrumentationAsset.name()); }
|
||||
|
||||
private:
|
||||
void retranslate() override;
|
||||
void showBuildingInfos() override;
|
||||
//void startRequest(const QUrl &requestedUrl);
|
||||
void showEgcuInfos(const InfrastructureManagement::StructureElement &se = {});
|
||||
QString structureElementName(int seId);
|
||||
|
||||
static bool readAllowance(InfrastructureManagement::EffectOverride eo, const std::string &properties);
|
||||
static bool readShowStatus(const std::string &properties);
|
||||
|
||||
private slots:
|
||||
|
||||
void onRelayInfoChanged(const AssetManagement::RelayInfo &data, DataModification modType);
|
||||
void onRelayStateChanged(const Buildings::RelayState &data, DataModification modType);
|
||||
void onInstrumentationAssetChanged(const InfrastructureManagement::InstrumentationAsset &data, DataModification modType);
|
||||
void onMountPointAssetChanged(const InfrastructureManagement::MountingPointAsset &data, DataModification modType);
|
||||
void onMainStructureElementChanged(const InfrastructureManagement::MainStructureElement &data, DataModification modType);
|
||||
|
||||
void onEffectOverrideChanged(int relayId, InfrastructureManagement::EffectOverride override);
|
||||
|
||||
private:
|
||||
Ui::EgcuInfoDialog *m_ui = nullptr;
|
||||
InfrastructureManagement::InstrumentationAsset m_instrumentationAsset;
|
||||
InfrastructureManagement::StructureElement m_structureElement;
|
||||
std::shared_ptr<InfrastructureManagement::Interface::Ftc> m_ftc;
|
||||
LtsUtils::RequestHelper *m_requestHelper;
|
||||
std::shared_ptr<AssetManagement::Interface::Dtc> m_asmDtc;
|
||||
QHash <int, RelayInfoWidget *> m_relayInfoWidgets;
|
||||
QVBoxLayout *m_relayLayout;
|
||||
int m_assetId = 0;
|
||||
};
|
||||
} // namespace Buildings
|
||||
+191
@@ -0,0 +1,191 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>EgcuInfoDialog</class>
|
||||
<widget class="QWidget" name="EgcuInfoDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>341</width>
|
||||
<height>701</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>257</width>
|
||||
<height>320</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Segment Info</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="11" column="0" colspan="2">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="lbxAssetName">
|
||||
<property name="text">
|
||||
<string>Asset Name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="lbxFloor">
|
||||
<property name="text">
|
||||
<string>Floor:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLabel" name="lblFloor">
|
||||
<property name="text">
|
||||
<string notr="true"><FLOOR></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<widget class="QLabel" name="lblAssetId">
|
||||
<property name="text">
|
||||
<string notr="true"><ASSETID></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QLabel" name="lblRoom">
|
||||
<property name="text">
|
||||
<string notr="true"><ROOM></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="1">
|
||||
<widget class="QLabel" name="lblHostName">
|
||||
<property name="text">
|
||||
<string notr="true"><HOSTNAME></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="lblBuildingName">
|
||||
<property name="text">
|
||||
<string notr="true"><BUILDINGNAME></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="lbxAssetId">
|
||||
<property name="text">
|
||||
<string>Asset Id:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="QLabel" name="lblAssetName">
|
||||
<property name="text">
|
||||
<string notr="true"><ASSETNAME></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<widget class="QLabel" name="lbxHostname">
|
||||
<property name="text">
|
||||
<string>Hostname:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="lbxRoom">
|
||||
<property name="text">
|
||||
<string>Room:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lblIcon">
|
||||
<property name="text">
|
||||
<string notr="true"><ICON></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lbxBuildingName">
|
||||
<property name="text">
|
||||
<string>Building:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="0" colspan="2">
|
||||
<widget class="QWidget" name="widgetRelais" native="true">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="lbxSegment">
|
||||
<property name="text">
|
||||
<string>Segment:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QLabel" name="lblSegment">
|
||||
<property name="text">
|
||||
<string notr="true"><SEGMENT></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
+318
@@ -0,0 +1,318 @@
|
||||
/**
|
||||
*@RDE_HEADER@
|
||||
* GUI Plugin for Building - Info
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2017-04-05
|
||||
*/
|
||||
|
||||
#include "egcu_operational.h"
|
||||
#include "ui_egcu_operational.h"
|
||||
#include "bld_config_dialog.h"
|
||||
|
||||
// Lts
|
||||
#include <LtsWidgets/lts_wait_dialog.h>
|
||||
|
||||
// DDS
|
||||
#include <SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
#include <InfrastructureManagement/ism_dtc.h>
|
||||
|
||||
// Qt
|
||||
#include <QNetworkReply>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QEventLoop>
|
||||
#include <QTimer>
|
||||
|
||||
namespace Buildings
|
||||
{
|
||||
|
||||
EgcuOperationalDialog::EgcuOperationalDialog(int mountPointId, const QString &menuGroup, QWidget *parent)
|
||||
: InfoDialogBase(mountPointId, menuGroup, QStringLiteral("EgcuOperationalDialog"), LtsWidgets::ButtonCombination::OkApplyCancel, parent)
|
||||
, m_ui(new Ui::EgcuOperationalDialog)
|
||||
, m_mountPointId(mountPointId)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
m_ui->m_lblIcon->setPixmap(QPixmap(QStringLiteral(":/icons/svg/bgv_effect_generation_unit.svg")));
|
||||
|
||||
#ifndef LTS_DEBUG
|
||||
m_ui->lblAssetId->hide();
|
||||
m_ui->lbAssetId->hide();
|
||||
m_ui->lbStructElementId->hide();
|
||||
#endif
|
||||
|
||||
// Set default selection
|
||||
m_ui->r0->setChecked(false);
|
||||
|
||||
m_stateTimer = new QTimer(this);
|
||||
connect(m_stateTimer, &QTimer::timeout, this, &EgcuOperationalDialog::onUpdateState);
|
||||
m_stateTimer->start(1000);
|
||||
|
||||
} // end of ctor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
EgcuOperationalDialog::~EgcuOperationalDialog()
|
||||
{
|
||||
delete m_stateTimer;
|
||||
delete m_ui;
|
||||
} // end of dtor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void EgcuOperationalDialog::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("Effect Generation Unit"));
|
||||
|
||||
m_ui->lbStatus->setText(QStringLiteral("<font color='orange'>%1</font>").arg(tr("Connecting...")));
|
||||
}
|
||||
|
||||
bool EgcuOperationalDialog::init(LtsSession::LtsSession *session)
|
||||
{
|
||||
if (!InfoDialogBase::init(session))
|
||||
return false;
|
||||
showBuildingInfos();
|
||||
connect(m_ismDtc.get(), &InfrastructureManagement::Interface::Dtc::instrumentationAssetChanged,
|
||||
this, &EgcuOperationalDialog::onInstrumentationAssetChanged);
|
||||
|
||||
m_ismDtc->enableMountingPointAsset();
|
||||
|
||||
auto cbMountPoint = [this](const InfrastructureManagement::MountingPointAsset & c)
|
||||
{
|
||||
onMountPointAssetChanged(c, DataModification::eAdded);
|
||||
};
|
||||
m_ismDtc->mountingPointAssets(cbMountPoint);
|
||||
|
||||
m_ismDtc->enableInstrumentationAsset();
|
||||
|
||||
auto cbInstrumentationAsset = [this](const InfrastructureManagement::InstrumentationAsset & c)
|
||||
{
|
||||
onInstrumentationAssetChanged(c, DataModification::eAdded);
|
||||
};
|
||||
m_ismDtc->instrumentationAssets(cbInstrumentationAsset);
|
||||
|
||||
return true;
|
||||
} // end of init()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void EgcuOperationalDialog::showBuildingInfos()
|
||||
{
|
||||
Buildings::BuildingState bldState = m_dtc->buildingState(m_mseId);
|
||||
|
||||
m_ui->lblAssetId->setText(QString::number(bldState.assetId()));
|
||||
} // end of showBuildingInfos()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool EgcuOperationalDialog::apply()
|
||||
{
|
||||
int relay = 0;
|
||||
int state = 0;
|
||||
int pulse = 0;
|
||||
int repeat = 0;
|
||||
int delay = 0;
|
||||
if (m_ui->r0->isChecked())
|
||||
relay = 0;
|
||||
|
||||
if (m_ui->r0->isChecked())
|
||||
state = 1;
|
||||
|
||||
DEBUG_LOG(m_logger) << "Apply: relay = " << relay
|
||||
<< " state=" << state
|
||||
<< " pulse=" << pulse
|
||||
<< " repeat=" << repeat
|
||||
<< " delay=" << delay;
|
||||
|
||||
QUrl url;
|
||||
QString request;
|
||||
if (state == 3)
|
||||
{
|
||||
request = QStringLiteral("http://%1/relay.php?state=%3").arg(m_host).arg(3);
|
||||
}
|
||||
else
|
||||
{
|
||||
request = QStringLiteral("http://%1/relay.php?number=%2&state=%3&pulse=%4&repeat=%5&delay=%6")
|
||||
.arg(m_host)
|
||||
.arg(relay)
|
||||
.arg(state)
|
||||
.arg(pulse)
|
||||
.arg(repeat)
|
||||
.arg(delay);
|
||||
DEBUG_LOG(m_logger) << "startRequest" << request;
|
||||
}
|
||||
url.setUrl(request);
|
||||
url.setUserName(m_user);
|
||||
url.setPassword(m_passwd);
|
||||
DEBUG_LOG(m_logger) << "startRequest: " << url.toString();
|
||||
|
||||
QNetworkReply *reply = m_qnam.get(QNetworkRequest(url));
|
||||
{
|
||||
LtsWidgets::LtsWaitDialogContainer wait;
|
||||
QEventLoop loop;
|
||||
connect(reply, &QNetworkReply::finished,
|
||||
&loop, &QEventLoop::quit);
|
||||
loop.exec();
|
||||
}
|
||||
|
||||
bool result = (reply->error() == QNetworkReply::NetworkError::NoError);
|
||||
|
||||
if (!result)
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Cannot configure relays: %1").arg(reply->errorString()));
|
||||
|
||||
reply->deleteLater();
|
||||
return result;
|
||||
}
|
||||
|
||||
void EgcuOperationalDialog::startRequest(const QUrl &requestedUrl)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "startRequest:" << requestedUrl.toString();
|
||||
m_httpRequestAborted = false;
|
||||
|
||||
auto reply = m_qnam.get(QNetworkRequest(requestedUrl));
|
||||
connect(reply, &QNetworkReply::finished, this, &EgcuOperationalDialog::httpFinished);
|
||||
}
|
||||
|
||||
|
||||
void EgcuOperationalDialog::httpFinished()
|
||||
{
|
||||
auto reply = qobject_cast<QNetworkReply*>(sender());
|
||||
if (!reply)
|
||||
return;
|
||||
|
||||
int i = 0;
|
||||
if (m_httpRequestAborted)
|
||||
{
|
||||
m_ui->groupBoxSelectRelay->setEnabled(false);
|
||||
ERROR_LOG(m_logger) << "httpRequestAborted";
|
||||
reply->deleteLater();
|
||||
return;
|
||||
}
|
||||
|
||||
if (reply->error())
|
||||
{
|
||||
m_ui->groupBoxSelectRelay->setEnabled(false);
|
||||
m_ui->lbStatus->setText(QStringLiteral("<font color='red'>%1</font>").arg(tr("Cannot connect to egcu: %1").arg(reply->errorString())));
|
||||
ERROR_LOG(m_logger) << "reply->error: " << reply->errorString();
|
||||
reply->deleteLater();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Sucess
|
||||
m_ui->groupBoxSelectRelay->setEnabled(true);
|
||||
m_ui->lbStatus->setText(QStringLiteral("<font color='green'>%1</font>").arg(tr("Connected to egcu")));
|
||||
|
||||
//parse the reply JSON and display result in the UI
|
||||
QJsonObject jsonObject = QJsonDocument::fromJson(reply->readAll()).object();
|
||||
QJsonDocument doc(jsonObject);
|
||||
DEBUG_LOG(m_logger) << doc.toJson(QJsonDocument::Indented);
|
||||
const QJsonArray jsonArray = jsonObject[QStringLiteral("State")].toArray();
|
||||
for (const QJsonValue &value : jsonArray)
|
||||
{
|
||||
QString valueString = value.toString();
|
||||
if (valueString == QStringLiteral("on"))
|
||||
valueString = QStringLiteral("<b>%1</b>").arg(tr("Actual State: on"));
|
||||
if (valueString == QStringLiteral("off"))
|
||||
valueString = QStringLiteral("<b>%1</b>").arg(tr("Actual State: off"));
|
||||
if (valueString == QStringLiteral("undefined"))
|
||||
valueString = QStringLiteral("<b>%1</b>").arg(tr("Actual State: undefined"));
|
||||
|
||||
switch (i)
|
||||
{
|
||||
case 0:
|
||||
m_ui->lbStateR0->setText(valueString);
|
||||
break;
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
case 8:
|
||||
case 9:
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
reply->deleteLater();
|
||||
}
|
||||
|
||||
void EgcuOperationalDialog::onUpdateState()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "onUpdateState";
|
||||
if (m_assetId == 0)
|
||||
return;
|
||||
QUrl url;
|
||||
QString request;
|
||||
request = QStringLiteral("http://%1/relay.php?state=3").arg(m_host);
|
||||
DEBUG_LOG(m_logger) << "startRequest:" << request;
|
||||
url.setUrl(request);
|
||||
url.setUserName(m_user);
|
||||
url.setPassword(m_passwd);
|
||||
startRequest(url);
|
||||
}
|
||||
|
||||
void EgcuOperationalDialog::onInstrumentationAssetChanged(
|
||||
const InfrastructureManagement::InstrumentationAsset &data, DataModification modType)
|
||||
{
|
||||
if (modType != DataModification::eAdded &&
|
||||
modType != DataModification::eModified)
|
||||
return;
|
||||
DEBUG_LOG(m_logger) << "onInstrumentationAssetChanged id:" << data.id();
|
||||
// Only EGCUs
|
||||
if (data.mountingPointTypeId() == InfrastructureManagement::MountingPointType_def::EffectGenerationControlUnit
|
||||
&& data.assetStateId() == InfrastructureManagement::InstrumentationAssetState_def::Mounted)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Insert instrumentation asset id=" << data.id();
|
||||
m_instrumentationAssets.insert(data.id(), data);
|
||||
if (data.id() == m_assetId)
|
||||
showEgcuInfos();
|
||||
}
|
||||
} // end of onInstrumentationAssetChanged()
|
||||
|
||||
void EgcuOperationalDialog::onMountPointAssetChanged(
|
||||
const InfrastructureManagement::MountingPointAsset &data, DataModification modType)
|
||||
{
|
||||
if (modType != DataModification::eAdded &&
|
||||
modType != DataModification::eModified)
|
||||
return;
|
||||
DEBUG_LOG(m_logger) << "onMountPointAssetChanged id:" << data.id();
|
||||
if (m_mountPointId == data.structureElementId())
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "FOUND m_assetId=" << m_assetId;
|
||||
m_assetId = data.assetId();
|
||||
if (m_instrumentationAssets.contains(m_assetId))
|
||||
showEgcuInfos();
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "NOT FOUND m_assetId=" << m_assetId;
|
||||
return;
|
||||
}
|
||||
} // end of onMountPointAssetChanged()
|
||||
|
||||
void EgcuOperationalDialog::showEgcuInfos()
|
||||
{
|
||||
InfrastructureManagement::InstrumentationAsset dataInst = m_instrumentationAssets.value(m_assetId);
|
||||
m_host = QString::fromStdString(dataInst.hostname());
|
||||
m_egcuName = QString::fromStdString(dataInst.name());
|
||||
|
||||
const QByteArray properties = QByteArray::fromRawData(dataInst.properties().c_str(),
|
||||
dataInst.properties().size());
|
||||
QJsonDocument propertyJsonDoc = QJsonDocument::fromJson(properties);
|
||||
QJsonObject propertyJsonObj = propertyJsonDoc.object();
|
||||
|
||||
m_user = propertyJsonObj[QStringLiteral("username")].toString();
|
||||
m_passwd = propertyJsonObj[QStringLiteral("password")].toString();
|
||||
|
||||
DEBUG_LOG(m_logger) << "onMountPointAssetChanged m_host:" << m_host
|
||||
<< " m_egcuName" << m_host
|
||||
<< " m_user" << m_user
|
||||
<< " m_passwd=" << m_passwd;
|
||||
m_ui->lblAssetName->setText(m_egcuName);
|
||||
m_ui->lblAssetId->setText(QString::number(m_assetId));
|
||||
m_ui->lblHostName->setText(m_host);
|
||||
}
|
||||
|
||||
} // namespace Buildings
|
||||
@@ -0,0 +1,75 @@
|
||||
/**
|
||||
*@RDE_HEADER@
|
||||
* GUI Plugin for Building- Info
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2017-04-05
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
// Buildings
|
||||
#include "info_dialog_base.h"
|
||||
|
||||
// DDS
|
||||
#include <InfrastructureManagement/ism.hpp>
|
||||
#include <LtsUtilsCore/data_modification_enum.h>
|
||||
|
||||
// HTTP Request
|
||||
#include <QNetworkAccessManager>
|
||||
|
||||
class QTimer;
|
||||
class QUrl;
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class EgcuOperationalDialog;
|
||||
}
|
||||
|
||||
namespace Buildings
|
||||
{
|
||||
|
||||
// --------------------------------------------------------
|
||||
// BuildingInfoDialog
|
||||
// --------------------------------------------------------
|
||||
class EgcuOperationalDialog : public InfoDialogBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit EgcuOperationalDialog(int mountPointId, const QString &menuGroup, QWidget *parent = nullptr);
|
||||
~EgcuOperationalDialog();
|
||||
|
||||
bool init(LtsSession::LtsSession *session) override;
|
||||
|
||||
QString egcuName() const { return m_egcuName; }
|
||||
QString buildingDisplayName() const override { return egcuName(); }
|
||||
|
||||
private:
|
||||
void retranslate() override;
|
||||
void showBuildingInfos() override;
|
||||
void startRequest(const QUrl &requestedUrl);
|
||||
void showEgcuInfos();
|
||||
|
||||
private slots:
|
||||
bool apply() override;
|
||||
void onUpdateState();
|
||||
void httpFinished();
|
||||
void onInstrumentationAssetChanged(const InfrastructureManagement::InstrumentationAsset &data, DataModification modType);
|
||||
void onMountPointAssetChanged(const InfrastructureManagement::MountingPointAsset &data, DataModification modType);
|
||||
|
||||
private:
|
||||
Ui::EgcuOperationalDialog *m_ui = nullptr;
|
||||
QHash <int, InfrastructureManagement::InstrumentationAsset> m_instrumentationAssets; // key = assetId
|
||||
int m_assetId = 0;
|
||||
int m_mountPointId = 0;
|
||||
QNetworkAccessManager m_qnam;
|
||||
bool m_httpRequestAborted = false;
|
||||
QString m_host;
|
||||
QString m_user;
|
||||
QString m_passwd;
|
||||
QString m_egcuName;
|
||||
QTimer *m_stateTimer = nullptr;
|
||||
};
|
||||
} // namespace Buildings
|
||||
+173
@@ -0,0 +1,173 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>EgcuOperationalDialog</class>
|
||||
<widget class="QWidget" name="EgcuOperationalDialog">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>257</width>
|
||||
<height>320</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Building Info</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="m_horizontalLayoutIcon">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="m_lblIcon">
|
||||
<property name="text">
|
||||
<string notr="true"><ICON></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lbStructElementId">
|
||||
<property name="text">
|
||||
<string>Asset Name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="lblAssetName">
|
||||
<property name="text">
|
||||
<string notr="true"><ASSETNAME></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lbAssetId">
|
||||
<property name="text">
|
||||
<string>Asset Id:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="lblAssetId">
|
||||
<property name="text">
|
||||
<string notr="true"><ASSETID></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lbBldName">
|
||||
<property name="text">
|
||||
<string>Hostname:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLabel" name="lblHostName">
|
||||
<property name="text">
|
||||
<string notr="true"><HOSTNAME></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Status:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLabel" name="lbStatus">
|
||||
<property name="text">
|
||||
<string notr="true"><STATUS></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBoxSelectRelay">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>200</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Select Relay:</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout_2">
|
||||
<item row="1" column="0">
|
||||
<widget class="QRadioButton" name="r0">
|
||||
<property name="text">
|
||||
<string>Ready to operate fog &machine</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lbStateR0">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
+121
@@ -0,0 +1,121 @@
|
||||
/**
|
||||
*@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
|
||||
@@ -0,0 +1,81 @@
|
||||
/**
|
||||
*@RDE_HEADER@
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Philipp Last, SLSE, 2018-03-06
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
//Lts
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
|
||||
//Buildings
|
||||
#include <Buildings/logger.h>
|
||||
#include <memory>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class BldInfoDialog;
|
||||
}
|
||||
namespace InfrastructureManagement
|
||||
{
|
||||
namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
namespace LtsSession {
|
||||
class LtsSession;
|
||||
}
|
||||
namespace BuildingViewer
|
||||
{
|
||||
class ForeignGuiInterface;
|
||||
}
|
||||
namespace ServiceMonitor
|
||||
{
|
||||
class ForeignGuiInterface;
|
||||
}
|
||||
|
||||
namespace Buildings
|
||||
{
|
||||
namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
|
||||
class InfoDialogBase : public LtsWidgets::LtsDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit InfoDialogBase(int bldEntityId, const QString &menuGroup, const QString &strLogger, LtsWidgets::ButtonCombination bc, QWidget *parent = nullptr);
|
||||
|
||||
virtual bool init(LtsSession::LtsSession *session);
|
||||
|
||||
|
||||
protected slots:
|
||||
void onFindOnMap();
|
||||
void onShowDetails();
|
||||
void onShowBuildingViewer();
|
||||
void onShowEgcuMonitor();
|
||||
|
||||
protected:
|
||||
virtual void showBuildingInfos() = 0;
|
||||
virtual QString buildingDisplayName() const = 0;
|
||||
|
||||
protected:
|
||||
int m_mseId = -1;
|
||||
QString m_menuGroup;
|
||||
int m_exerciseId;
|
||||
LtsSession::LtsSession *m_session = nullptr;
|
||||
|
||||
std::shared_ptr<Buildings::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<InfrastructureManagement::Interface::Dtc> m_ismDtc;
|
||||
std::shared_ptr<BuildingViewer::ForeignGuiInterface> m_bdvGuiIfc;
|
||||
std::shared_ptr<ServiceMonitor::ForeignGuiInterface> m_smoGuiIfc;
|
||||
|
||||
LOGGER_T m_logger;
|
||||
};
|
||||
} // namespace Buildings
|
||||
+137
@@ -0,0 +1,137 @@
|
||||
/**
|
||||
*@RDE_HEADER@
|
||||
* Ui for displaying Relay Infos
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Malte Diers, SLTE, 2021-04-27
|
||||
*/
|
||||
|
||||
#include "relay_info.h"
|
||||
#include "ui_relay_info.h"
|
||||
#include <LtsWidgets/lts_led_widget.h>
|
||||
#include <ngltools/ngltools_dtg.h>
|
||||
|
||||
namespace Buildings
|
||||
{
|
||||
|
||||
RelayInfoWidget::RelayInfoWidget(int id, QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, m_id(id)
|
||||
, m_state(false)
|
||||
, m_ui(new Ui::RelayInfoWidget)
|
||||
, m_logger(getLogger("RelayInfoWidget"))
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "RelayInfoWidget";
|
||||
m_ui->setupUi(this);
|
||||
// setPulseVisible(false);
|
||||
m_ui->ledStatus->setAspectHint(LtsWidgets::LtsLedWidget::AspectHint::WidthIsHeight);
|
||||
m_ui->ledStatus->setContentsMargins(5,5,5,5);
|
||||
setOfflineColor();
|
||||
connect(m_ui->tbOn, &QToolButton::clicked, this, &RelayInfoWidget::onButtonClicked);
|
||||
connect(m_ui->tbOff, &QToolButton::clicked, this, &RelayInfoWidget::onButtonClicked);
|
||||
connect(m_ui->tbAuto, &QToolButton::clicked, this, &RelayInfoWidget::onButtonClicked);
|
||||
}
|
||||
|
||||
RelayInfoWidget::~RelayInfoWidget()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
QString RelayInfoWidget::name() const
|
||||
{
|
||||
return m_ui->lblName->text();
|
||||
}
|
||||
|
||||
bool RelayInfoWidget::state() const
|
||||
{
|
||||
return m_state;
|
||||
}
|
||||
|
||||
int RelayInfoWidget::id() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
void RelayInfoWidget::setName(const QString &name)
|
||||
{
|
||||
m_ui->lblName->setText(name);
|
||||
}
|
||||
|
||||
void RelayInfoWidget::setState(bool state, qint64 stateTime, qint64 offlineTime)
|
||||
{
|
||||
if ( stateTime > offlineTime)
|
||||
{
|
||||
m_state = state;
|
||||
m_ui->ledStatus->setOnColor(state ? Qt::green : Qt::red);
|
||||
m_ui->ledStatus->setToolTip(QStringLiteral("%1 - %2").arg(tr("Values from")).arg(DTG::toStringMSec(stateTime)));
|
||||
m_ui->ledStatus->setStatus(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
setOfflineColor();
|
||||
m_ui->ledStatus->setToolTip(QStringLiteral("%1 - %2,\nEGCU offline since: %3").arg(tr("Values from")).arg(DTG::toStringMSec(stateTime)).arg(DTG::toStringMSec(offlineTime)));
|
||||
m_ui->ledStatus->setStatus(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void RelayInfoWidget::setEffectOverride(InfrastructureManagement::EffectOverride override)
|
||||
{
|
||||
switch(override.underlying())
|
||||
{
|
||||
case InfrastructureManagement::EffectOverride_def::Automatic:
|
||||
m_ui->tbAuto->setChecked(true);
|
||||
break;
|
||||
case InfrastructureManagement::EffectOverride_def::PermanentOn:
|
||||
m_ui->tbOn->setChecked(true);
|
||||
break;
|
||||
case InfrastructureManagement::EffectOverride_def::PermanentOff:
|
||||
m_ui->tbOff->setChecked(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void RelayInfoWidget::setEffectOverrideEnabled(InfrastructureManagement::EffectOverride override, bool enable)
|
||||
{
|
||||
switch(override.underlying())
|
||||
{
|
||||
case InfrastructureManagement::EffectOverride_def::Automatic:
|
||||
m_ui->tbAuto->setEnabled(enable);
|
||||
break;
|
||||
case InfrastructureManagement::EffectOverride_def::PermanentOn:
|
||||
m_ui->tbOn->setEnabled(enable);
|
||||
break;
|
||||
case InfrastructureManagement::EffectOverride_def::PermanentOff:
|
||||
m_ui->tbOff->setEnabled(enable);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void RelayInfoWidget::setLedVisible(bool enable)
|
||||
{
|
||||
m_ui->ledStatus->setVisible(enable);
|
||||
}
|
||||
|
||||
void RelayInfoWidget::onButtonClicked()
|
||||
{
|
||||
QAbstractButton *ab = qobject_cast<QAbstractButton*>(sender());
|
||||
if (!ab)
|
||||
return;
|
||||
InfrastructureManagement::EffectOverride eo = InfrastructureManagement::EffectOverride_def::Automatic;
|
||||
if (ab == m_ui->tbOff)
|
||||
eo = InfrastructureManagement::EffectOverride_def::PermanentOff;
|
||||
else if (ab == m_ui->tbOn)
|
||||
eo = InfrastructureManagement::EffectOverride_def::PermanentOn;
|
||||
|
||||
emit effectOverrideChanged(m_id, eo);
|
||||
}
|
||||
|
||||
void RelayInfoWidget::setOfflineColor()
|
||||
{
|
||||
QColor offlineColor;
|
||||
offlineColor.setRgb(120,92,37);
|
||||
m_ui->ledStatus->setOnColor(offlineColor);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
/**
|
||||
*@RDE_HEADER@
|
||||
* Ui for displaying Relay Infos
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Malte Diers, SLTE, 2021-04-27
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
#include <Buildings/bld_enums.hpp>
|
||||
#include <InfrastructureManagement/ism_enums.hpp>
|
||||
#include <QDateTime>
|
||||
#include <Buildings/logger.h>
|
||||
|
||||
namespace Ui {
|
||||
class RelayInfoWidget;
|
||||
}
|
||||
|
||||
|
||||
namespace Buildings
|
||||
{
|
||||
|
||||
class RelayInfoWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit RelayInfoWidget(int id, QWidget *parent = nullptr);
|
||||
~RelayInfoWidget();
|
||||
|
||||
QString name() const;
|
||||
bool state() const;
|
||||
int id() const;
|
||||
|
||||
signals:
|
||||
void effectOverrideChanged(int relayId, InfrastructureManagement::EffectOverride override);
|
||||
|
||||
public slots:
|
||||
void setName(const QString &name);
|
||||
void setState(bool state, qint64 stateTime, qint64 offlineTime);
|
||||
void setEffectOverride(InfrastructureManagement::EffectOverride override);
|
||||
void setEffectOverrideEnabled(InfrastructureManagement::EffectOverride override, bool enable = true);
|
||||
void setLedVisible(bool enable = true);
|
||||
void setOfflineColor();
|
||||
|
||||
private slots:
|
||||
void onButtonClicked();
|
||||
|
||||
private:
|
||||
int m_id;
|
||||
bool m_state;
|
||||
Ui::RelayInfoWidget *m_ui;
|
||||
LOGGER_T m_logger;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
+119
@@ -0,0 +1,119 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>RelayInfoWidget</class>
|
||||
<widget class="QWidget" name="RelayInfoWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>298</width>
|
||||
<height>36</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="lblName">
|
||||
<property name="text">
|
||||
<string><NAME></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="LtsWidgets::LtsLedWidget" name="ledStatus" native="true">
|
||||
<property name="toolTip">
|
||||
<string>EGCU offline</string>
|
||||
</property>
|
||||
<property name="oncolor" stdset="0">
|
||||
<color>
|
||||
<red>255</red>
|
||||
<green>170</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</property>
|
||||
<property name="status" stdset="0">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="tbOn">
|
||||
<property name="text">
|
||||
<string>ON</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="autoExclusive">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="tbAuto">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>AUTO</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="autoExclusive">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="tbOff">
|
||||
<property name="text">
|
||||
<string>OFF</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="autoExclusive">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LtsWidgets::LtsLedWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>LtsWidgets/lts_led_widget.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Reference in new issue
Block a user