Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+244
@@ -0,0 +1,244 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* AreaEffectSimulation - Functional Area Edit Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Philipp Dassow, SLEA, 2017-06-09
|
||||
*/
|
||||
|
||||
|
||||
#include "aes_technical_area_edit.h"
|
||||
#include "ui_aes_technical_area_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 <AreaEffectSimulation/aes_translation.h>
|
||||
#include <AreaEffectSimulation/Utils/polygons.h>
|
||||
#include <LtsUtilsSettings/settings.h>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
double TechnicalAreaEdit::s_minWidth;
|
||||
double TechnicalAreaEdit::s_maxWidth;
|
||||
double TechnicalAreaEdit::s_stepWidth;
|
||||
double TechnicalAreaEdit::s_minHeight;
|
||||
double TechnicalAreaEdit::s_maxHeight;
|
||||
double TechnicalAreaEdit::s_stepHeight;
|
||||
|
||||
|
||||
// Todo: Höhe und Radius in Abhängigkeit der Munitionsart berechnen
|
||||
|
||||
TechnicalAreaEdit::TechnicalAreaEdit(const QString &menuGroup, QWidget *parent)
|
||||
: BaseEdit(menuGroup, QLatin1String("TechnicalAreaEdit"), parent)
|
||||
, m_ui(new Ui::TechnicalAreaEdit)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
s_minWidth = 5;
|
||||
s_maxWidth = 1275;
|
||||
s_stepWidth = 5;
|
||||
s_minHeight = 5;
|
||||
s_maxHeight = 1275;
|
||||
s_stepHeight = 5;
|
||||
|
||||
m_ui->sbWidth->setMinimum(s_minWidth);
|
||||
m_ui->sbWidth->setMaximum(s_maxWidth);
|
||||
m_ui->sbWidth->setSingleStep(s_stepWidth);
|
||||
m_ui->sbHeight->setMinimum(s_minHeight);
|
||||
m_ui->sbHeight->setMaximum(s_maxHeight);
|
||||
m_ui->sbHeight->setSingleStep(s_stepHeight);
|
||||
|
||||
m_uiRequirements->addRequirement({m_ui->lblPosition, [this]() { return (!m_ui->positionEdit->coordinate().isNull()); }});
|
||||
m_uiRequirements->addRequirement({m_ui->lblIdentifier, [this]() { return (!m_ui->leIdentifier->text().isEmpty()); }});
|
||||
// m_uiRequirements->addRequirement({m_ui->chbDecon, [this]() { return (m_ui->chbDecon->isChecked() || m_ui->chbMaint->isChecked() || m_ui->chbMedic->isChecked()); }});
|
||||
|
||||
connect(m_ui->sbWidth, &QSpinBox::editingFinished, this, &TechnicalAreaEdit::correctSpinBoxValue);
|
||||
connect(m_ui->sbHeight, &QSpinBox::editingFinished, this, &TechnicalAreaEdit::correctSpinBoxValue);
|
||||
connect(m_ui->pbClear, &QPushButton::clicked, m_ui->positionEdit, &LtsCoordWidget::LtsCoordWidget::clear);
|
||||
|
||||
enaDisa();
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Add_Technical_Area"));
|
||||
}
|
||||
|
||||
TechnicalAreaEdit::~TechnicalAreaEdit()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void TechnicalAreaEdit::retranslate()
|
||||
{
|
||||
translate(m_ui, m_aesItem, tr("Technical Area"));
|
||||
}
|
||||
|
||||
void TechnicalAreaEdit::enableUiElements(bool enable)
|
||||
{
|
||||
|
||||
m_ui->leIdentifier->setMaxLength(30);
|
||||
|
||||
m_ui->pbPosition->setEnabled(m_sitMapGuiIfc && enable);
|
||||
m_ui->positionEdit->setEnabled(enable);
|
||||
m_ui->sbHeight->setEnabled(enable);
|
||||
m_ui->sbWidth->setEnabled(enable);
|
||||
m_ui->pbClear->setEnabled(enable);
|
||||
m_ui->leIdentifier->setEnabled(enable || isOnlyNameModifiable());
|
||||
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->technicalArea(m_aesItem.id());
|
||||
setData(baseData, false);
|
||||
__unchange__();
|
||||
if (name != m_ui->leIdentifier->text())
|
||||
m_ui->leIdentifier->setText(name);
|
||||
}
|
||||
}
|
||||
|
||||
bool TechnicalAreaEdit::init(int areaId, bool copy,
|
||||
LtsSession::LtsSession *session)
|
||||
{
|
||||
if (!BaseEdit::init(areaId, session))
|
||||
return false;
|
||||
|
||||
bool editable = LtsSessionData::LtsSessionData::getInstance()->hasOperatorRight(OperatorRights::TechnicalAreasEdit) ||
|
||||
m_session->app() == LtsAppDescriptor::App::OC;
|
||||
bool readable = LtsSessionData::LtsSessionData::getInstance()->hasOperatorRight(OperatorRights::TechnicalAreasShow);
|
||||
|
||||
if (!readable && !editable)
|
||||
return false;
|
||||
|
||||
if (m_sitMapGuiIfc)
|
||||
connect(m_ui->pbPosition, &QPushButton::clicked, this, &TechnicalAreaEdit::getPosition);
|
||||
else
|
||||
m_ui->pbPosition->setEnabled(false);
|
||||
|
||||
fillCbx();
|
||||
|
||||
if (areaId > 0)
|
||||
{
|
||||
auto baseData = m_dtc->technicalArea(areaId);
|
||||
setData(baseData, copy);
|
||||
}
|
||||
|
||||
enableUiElements(editable);
|
||||
|
||||
connect(m_dtc.get(), &AreaEffectSimulation::Interface::Dtc::technicalAreaChanged,
|
||||
this, &BaseEdit::onAreaChanged);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void TechnicalAreaEdit::setData(const TechnicalArea &area, bool copy)
|
||||
{
|
||||
m_aesItem = area;
|
||||
if (copy)
|
||||
{
|
||||
m_aesItem.id(0);
|
||||
m_aesItem.effectStateId(AreaEffectSimulation::AesEffectState_def::get_default());
|
||||
}
|
||||
m_ui->leIdentifier->setText(QString::fromStdString(area.name()));
|
||||
m_ui->sbWidth->setValue(area.area().width());
|
||||
m_ui->sbHeight->setValue(area.area().height());
|
||||
|
||||
QPointF bottomLeft(area.area().cornerBottomLeft().lon(), area.area().cornerBottomLeft().lat());
|
||||
QPointF centerpoint = Polygons::bottomLeft2CenterPoint(bottomLeft, area.area().width(), area.area().height(), 0.0);
|
||||
if (!centerpoint.isNull())
|
||||
m_ui->positionEdit->setCoordinate(centerpoint);
|
||||
|
||||
m_ui->cbType->setCurrentIndex(m_ui->cbType->findData(area.type().underlying()));
|
||||
}
|
||||
|
||||
inline void TechnicalAreaEdit::fillCbx()
|
||||
{
|
||||
int curIdxType = m_ui->cbType->currentIndex();
|
||||
LtsUtils::ProjectSettings *ps = LtsUtils::ProjectSettings::getInstance();
|
||||
|
||||
const bool enableSoundZones = ps->value(QStringLiteral("bld"),
|
||||
QStringLiteral("enableSoundZones")).toBool();
|
||||
|
||||
|
||||
m_ui->cbType->clear();
|
||||
m_ui->cbType->addItem(AreaEffectSimulation::toString(AesTechnicalAreaType_def::TatMout), AesTechnicalAreaType_def::TatMout);
|
||||
if ( enableSoundZones )
|
||||
m_ui->cbType->addItem(AreaEffectSimulation::toString(AesTechnicalAreaType_def::TatSoundZone), AesTechnicalAreaType_def::TatSoundZone);
|
||||
//m_ui->cbType->addItem(AreaEffectSimulation::toString(AesTechnicalAreaType_def::TatRestingAreaPersonnel), AesTechnicalAreaType_def::TatRestingAreaPersonnel);
|
||||
//m_ui->cbType->addItem(AreaEffectSimulation::toString(AesTechnicalAreaType_def::TatRestingAreaVehicle), AesTechnicalAreaType_def::TatRestingAreaVehicle);
|
||||
//m_ui->cbType->addItem(AreaEffectSimulation::toString(AesTechnicalAreaType_def::TatRestingAreaPersonnelAndVehicle), AesTechnicalAreaType_def::TatRestingAreaPersonnelAndVehicle);
|
||||
|
||||
if (curIdxType >= 0)
|
||||
m_ui->cbType->setCurrentIndex(curIdxType);
|
||||
}
|
||||
|
||||
void TechnicalAreaEdit::getPosition()
|
||||
{
|
||||
if (!has2DMap())
|
||||
return;
|
||||
|
||||
m_sitMapGuiIfc->getRectangleNorth(this,
|
||||
SLOT(onRectData(QPointF, double, double, QPolygonF)),
|
||||
nullptr,
|
||||
s_minWidth,
|
||||
s_maxWidth,
|
||||
s_minHeight,
|
||||
s_maxHeight,
|
||||
m_ui->positionEdit->coordinate(),
|
||||
m_ui->sbWidth->value(),
|
||||
m_ui->sbHeight->value()
|
||||
);
|
||||
}
|
||||
|
||||
void TechnicalAreaEdit::onRectData(const QPointF ¢erPoint, double width, double height, const QPolygonF &coordinates)
|
||||
{
|
||||
m_previewPolygon = coordinates;
|
||||
m_ui->positionEdit->setCoordinate(centerPoint);
|
||||
m_ui->sbWidth->setValue(width);
|
||||
m_ui->sbHeight->setValue(height);
|
||||
DEBUG_LOG(m_logger) << "Pos X: " << centerPoint.x() << " Y: " << centerPoint.y() << " W: " << width << " H: " << height;
|
||||
|
||||
showPreviewObject();
|
||||
}
|
||||
|
||||
bool TechnicalAreaEdit::apply()
|
||||
{
|
||||
std::string name = m_ui->leIdentifier->text().toStdString();
|
||||
AesTechnicalAreaType type = static_cast<AesTechnicalAreaType::inner_enum>(m_ui->cbType->currentData().toInt());
|
||||
QPointF bottomLeft(Polygons::centerPoint2BottomLeft(m_ui->positionEdit->coordinate(),
|
||||
m_ui->sbWidth->value(),
|
||||
m_ui->sbHeight->value(),
|
||||
0.0));
|
||||
const Core::GeoPosition2D bottomLeftGeo(bottomLeft.x(), bottomLeft.y());
|
||||
const Area area(bottomLeftGeo, m_ui->sbWidth->value(), m_ui->sbHeight->value(), 0.0);
|
||||
const TechnicalAreaModifyRequest req(m_aesItem.id(),
|
||||
name,
|
||||
area,
|
||||
type);
|
||||
|
||||
m_requestHelper->addRequest([this, req]()
|
||||
{
|
||||
return m_ftc->technicalAreaModifyRequest(req, this);
|
||||
});
|
||||
|
||||
return m_requestHelper->startRequests();
|
||||
}
|
||||
|
||||
void TechnicalAreaEdit::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