Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
@@ -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
|
||||
Reference in new issue
Block a user