Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+174
@@ -0,0 +1,174 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* TargetManagement - Target Edit Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Norbert Thoden, NLE, 2020-05-29
|
||||
*/
|
||||
|
||||
#include "tgt_area_edit.h"
|
||||
#include "tgt_area_model.h"
|
||||
#include "ui_tgt_area_edit.h"
|
||||
|
||||
#include <LtsUtilsSettings/settings.h>
|
||||
|
||||
|
||||
namespace TargetManagement
|
||||
{
|
||||
|
||||
AreaEdit::AreaEdit(QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_ui(new Ui::AreaEdit)
|
||||
, m_logger(getLogger("AreaEdit"))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
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);
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
AreaEdit::~AreaEdit()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void AreaEdit::retranslate()
|
||||
{
|
||||
translate(m_ui, m_area, tr("ShootbackArea"));
|
||||
}
|
||||
|
||||
bool AreaEdit::init(const std::shared_ptr<TargetManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<TargetManagement::Interface::Ftc> &ftc,
|
||||
const std::shared_ptr<SituationMap::ForeignGuiInterface> &sitMapGuiIfc,
|
||||
AreaModel *areaModel,
|
||||
const ShootbackArea &area)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "AreaEdit::init()";
|
||||
|
||||
if (!dtc || !ftc || !sitMapGuiIfc)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "AreaEdit::init() Invalid shared_ptr!";
|
||||
return false;
|
||||
}
|
||||
|
||||
m_dtc = dtc;
|
||||
m_ftc = ftc;
|
||||
m_sitMapGuiIfc = sitMapGuiIfc;
|
||||
m_areaModel = areaModel;
|
||||
setData(area);
|
||||
|
||||
if (m_sitMapGuiIfc)
|
||||
connect(m_ui->pbPosition, &QPushButton::clicked, this, &AreaEdit::getPosition);
|
||||
else
|
||||
m_ui->pbPosition->setEnabled(false);
|
||||
|
||||
connect(m_ui->pbClear, &QPushButton::clicked,
|
||||
m_ui->positionEdit, &LtsCoordWidget::LtsCoordWidget::clear);
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Targets"));
|
||||
|
||||
// if (m_area.id() <= 0)
|
||||
// slotChangesMade();
|
||||
|
||||
enaDisa();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void AreaEdit::enaDisa()
|
||||
{
|
||||
m_ui->pbPosition->setEnabled(m_sitMapGuiIfc.get());
|
||||
}
|
||||
|
||||
//slots
|
||||
|
||||
bool AreaEdit::apply()
|
||||
{
|
||||
m_area.name(m_ui->leName->text().toStdString());
|
||||
const QPointF &coord = m_ui->positionEdit->coordinate();
|
||||
m_area.position({coord.x(), coord.y()});
|
||||
m_area.width(m_ui->sbWidth->value());
|
||||
m_area.height(m_ui->sbHeight->value());
|
||||
|
||||
m_requestHelper->addRequest([this]()
|
||||
{
|
||||
return m_ftc->shootbackAreaModifyRequest(m_area, this);
|
||||
});
|
||||
|
||||
return m_requestHelper->startRequests();
|
||||
}
|
||||
|
||||
void AreaEdit::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 AreaEdit::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();
|
||||
}
|
||||
|
||||
|
||||
//private
|
||||
bool AreaEdit::has2DMap()
|
||||
{
|
||||
if (!m_sitMapGuiIfc)
|
||||
return false;
|
||||
if (m_sitMapGuiIfc->mapMode() != SituationMap::MapMode::MapMode_2D)
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Only available in 2D mode"));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void AreaEdit::showPreviewObject()
|
||||
{
|
||||
if (!m_sitMapGuiIfc)
|
||||
return;
|
||||
if (m_previewPolygon.isEmpty())
|
||||
return;
|
||||
m_sitMapGuiIfc->displayPreviewObject(this, m_previewPolygon, true);
|
||||
}
|
||||
|
||||
|
||||
void AreaEdit::setData(const ShootbackArea &area)
|
||||
{
|
||||
m_area = area;
|
||||
|
||||
if (m_area.id() > 0)
|
||||
{
|
||||
m_ui->leName->setText(QString::fromStdString(m_area.name()));
|
||||
m_ui->positionEdit->setCoordinate(m_area.position().lon(), m_area.position().lat());
|
||||
m_ui->sbWidth->setValue(m_area.width());
|
||||
m_ui->sbHeight->setValue(m_area.height());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user