Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
@@ -0,0 +1,232 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* AreaEffectSimulation - NContamination Edit Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-07-07
|
||||
*/
|
||||
|
||||
|
||||
#include "aes_gas_pipe_edit.h"
|
||||
#include "ui_aes_gas_pipe_edit.h"
|
||||
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <Plugins/AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
#include <Plugins/SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
|
||||
#include <QDoubleSpinBox>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
GasPipeEdit::GasPipeEdit(const QString &menuGroup, QWidget *parent)
|
||||
: BaseEdit(menuGroup, QLatin1String("GasPipeEdit"), parent)
|
||||
, m_ui(new Ui::GasPipeEdit)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
m_ui->sbWidth->setMinimum(s_minWidth);
|
||||
m_ui->sbWidth->setMaximum(s_maxWidth);
|
||||
m_ui->sbWidth->setSingleStep(s_stepWidth);
|
||||
|
||||
m_uiRequirements->addRequirement({m_ui->lblGeometry, [this]() { return (!m_ui->positionEdit_1->coordinate().isNull() &&
|
||||
!m_ui->positionEdit_2->coordinate().isNull()
|
||||
); }});
|
||||
m_uiRequirements->addRequirement({m_ui->lblIdentifier, [this]() { return (!m_ui->leIdentifier->text().isEmpty()); }});
|
||||
m_uiRequirements->addRequirement({m_ui->lblEffectStart, [this]() { return hasValidEffectStart(m_ui->dteEffectStart); }});
|
||||
|
||||
enaDisa();
|
||||
connect(m_ui->sbWidth, &QSpinBox::editingFinished, this, &GasPipeEdit::correctSpinBoxValue);
|
||||
connect(m_ui->pbClear, &QPushButton::clicked, this, &GasPipeEdit::clearCoordinates);
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Add_Gas_Pipeline"));
|
||||
}
|
||||
|
||||
GasPipeEdit::~GasPipeEdit()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void GasPipeEdit::retranslate()
|
||||
{
|
||||
translate(m_ui, m_aesItem, tr("Gas Pipe"));
|
||||
}
|
||||
|
||||
std::vector<LtsCoordWidget::LtsCoordWidget *> GasPipeEdit::coordWidgets() const
|
||||
{
|
||||
return {m_ui->positionEdit_1,
|
||||
m_ui->positionEdit_2,
|
||||
m_ui->positionEdit_3,
|
||||
m_ui->positionEdit_4,
|
||||
m_ui->positionEdit_5,
|
||||
m_ui->positionEdit_6,
|
||||
m_ui->positionEdit_7,
|
||||
m_ui->positionEdit_8,
|
||||
m_ui->positionEdit_9,
|
||||
m_ui->positionEdit_10,
|
||||
m_ui->positionEdit_11};
|
||||
}
|
||||
|
||||
void GasPipeEdit::enableUiElements(bool enable)
|
||||
{
|
||||
|
||||
m_ui->leIdentifier->setMaxLength(30);
|
||||
|
||||
m_ui->pbPosition->setEnabled(m_sitMapGuiIfc && enable);
|
||||
setEffectStartEnabled(m_ui->dteEffectStart, enable);
|
||||
enabledCoordinates(enable);
|
||||
m_ui->sbWidth->setEnabled(enable);
|
||||
m_ui->pbClear->setEnabled(enable);
|
||||
m_ui->leIdentifier->setEnabled(enable || isOnlyNameModifiable());
|
||||
m_ui->cbParty->setEnabled(enable);
|
||||
|
||||
if (m_aesItem.effectStateId() == AesEffectState_def::EsExpired)
|
||||
{
|
||||
m_ui->leIdentifier->setText(QString::fromStdString(m_aesItem.name()));
|
||||
__unchange__();
|
||||
}
|
||||
if (m_aesItem.effectStateId() == AesEffectState_def::EsActivated)
|
||||
{
|
||||
QString name = m_ui->leIdentifier->text();
|
||||
auto baseData = m_dtc->gasPipe(m_aesItem.id());
|
||||
setData(baseData, false);
|
||||
__unchange__();
|
||||
if (name != m_ui->leIdentifier->text())
|
||||
m_ui->leIdentifier->setText(name);
|
||||
}
|
||||
}
|
||||
|
||||
bool GasPipeEdit::init(int aesItemId, bool copy,
|
||||
LtsSession::LtsSession *session)
|
||||
{
|
||||
if (!BaseEdit::init(aesItemId, session))
|
||||
return false;
|
||||
|
||||
bool editable = LtsSessionData::LtsSessionData::getInstance()->hasOperatorRight(OperatorRights::GasPipesEdit) ||
|
||||
m_session->app() == LtsAppDescriptor::App::OC;
|
||||
bool readable = LtsSessionData::LtsSessionData::getInstance()->hasOperatorRight(OperatorRights::GasPipesShow);
|
||||
|
||||
if (!readable && !editable)
|
||||
return false;
|
||||
|
||||
// Todo: Older allowed?
|
||||
m_ui->dteEffectStart->setMinimumTimeMSec(m_session->partitionTime());
|
||||
m_ui->dteEffectStart->setRetrieveCurrentTimeCallback([this]() { return m_session->partitionTime(); });
|
||||
|
||||
if (m_sitMapGuiIfc)
|
||||
connect(m_ui->pbPosition, &QPushButton::clicked, this, &GasPipeEdit::getPolygon);
|
||||
else
|
||||
m_ui->pbPosition->setEnabled(false);
|
||||
|
||||
m_ppmGuiCbxIfc->fillPartyComboBox(m_ui->cbParty);
|
||||
|
||||
if (aesItemId > 0)
|
||||
{
|
||||
auto baseData = m_dtc->gasPipe(aesItemId);
|
||||
setData(baseData, copy);
|
||||
}
|
||||
|
||||
enableUiElements(editable && isModifiable() && !isOnlyNameModifiable());
|
||||
|
||||
connect(m_dtc.get(), &AreaEffectSimulation::Interface::Dtc::gasPipeChanged,
|
||||
this, &BaseEdit::onAreaChanged);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void GasPipeEdit::setData(const GasPipe &aesItem, bool copy)
|
||||
{
|
||||
m_aesItem = aesItem;
|
||||
if (copy)
|
||||
{
|
||||
m_aesItem.id(0);
|
||||
m_aesItem.effectStateId(AreaEffectSimulation::AesEffectState_def::get_default());
|
||||
}
|
||||
m_ui->leIdentifier->setText(QString::fromStdString(aesItem.name()));
|
||||
m_ui->sbWidth->setValue(aesItem.width());
|
||||
m_ui->dteEffectStart->setMsecsSinceEpoch(aesItem.effectStart().is_set() ? aesItem.effectStart().get() : 0);
|
||||
if ( aesItem.partyId().is_set())
|
||||
m_ui->cbParty->setCurrentIndex(m_ui->cbParty->findData(aesItem.partyId().get()));
|
||||
|
||||
setCoordinates(aesItem.segments());
|
||||
}
|
||||
|
||||
void GasPipeEdit::getPolygon()
|
||||
{
|
||||
if (!has2DMap())
|
||||
return;
|
||||
|
||||
m_sitMapGuiIfc->getCorridor(this,
|
||||
SLOT(onPolygonData(double, QVector<QPointF>, QPolygonF)),
|
||||
nullptr,
|
||||
s_minWidth,
|
||||
s_maxWidth,
|
||||
s_maxLength,
|
||||
s_maxSegments,
|
||||
true,
|
||||
getCoordinatesQPointF(),
|
||||
50);
|
||||
}
|
||||
|
||||
|
||||
void GasPipeEdit::onPolygonData(const double width, const QVector<QPointF> &polygon, const QPolygonF &bufferOutlinePolygon)
|
||||
{
|
||||
if (polygon.size() < 2)
|
||||
return;
|
||||
|
||||
m_previewPolygon = bufferOutlinePolygon;
|
||||
|
||||
// Only Centerline allowed, no reverse polygon
|
||||
setCoordinates(polygon, false);
|
||||
m_ui->sbWidth->setValue(std::abs(width));
|
||||
|
||||
showPreviewObject();
|
||||
}
|
||||
|
||||
bool GasPipeEdit::apply()
|
||||
{
|
||||
std::string name = m_ui->leIdentifier->text().toStdString();
|
||||
double width = m_ui->sbWidth->value();
|
||||
qint64 effectStart = m_ui->dteEffectStart->msecsSinceEpoch();
|
||||
int partyId = m_ui->cbParty->currentData().toInt();
|
||||
int effectDuration = 10000; // 10 Seconds
|
||||
|
||||
if (!checkSegementLengths(this))
|
||||
return false;
|
||||
|
||||
const GasPipeModifyRequest req(m_aesItem.id(),
|
||||
LtsUtils::toOptional(effectStart),
|
||||
LtsUtils::toOptional(partyId),
|
||||
name,
|
||||
getCoordinates(),
|
||||
width,
|
||||
effectDuration);
|
||||
/*const GasPipeModifyRequest req(m_aesItem.id(),
|
||||
name,
|
||||
1 * 60 * 1000, // 1min
|
||||
width,
|
||||
getCoordinates(),
|
||||
LtsUtils::toOptional(effectStart),
|
||||
dds::core::optional<int32_t>(),
|
||||
dds::core::optional<int32_t>());*/
|
||||
|
||||
return m_requestHelper->startSingleRequest([this, req]()
|
||||
{
|
||||
return m_ftc->gasPipeModifyRequest(req, this);
|
||||
});
|
||||
}
|
||||
|
||||
void GasPipeEdit::showPreviewObject()
|
||||
{
|
||||
if (!m_sitMapGuiIfc)
|
||||
return;
|
||||
|
||||
if (m_previewPolygon.isEmpty())
|
||||
return;
|
||||
|
||||
m_sitMapGuiIfc->displayPreviewObject(this, m_previewPolygon, true);
|
||||
}
|
||||
|
||||
} // namespace AreaEffectSimulation
|
||||
Reference in new issue
Block a user