Apply clang-format to Lts/Common and DTC/enum headers
- Formatted all CodeGen module files (9 files) - Formatted LtsAppDescriptor module files - Formatted LtsAppManager/AppChooser files - Applied clang-format to all DTC and enum headers across modules - Removed coordTransTests from CommonUnitTestsPlaceholder (moved to tests/) Cosmetic changes only, no functional modifications. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
848 files changed
+89305
-100020
No files matched your search
Executable → Regular
+207
-250
@@ -1,372 +1,329 @@
|
||||
|
||||
|
||||
|
||||
|
||||
#include "asm_edit_training_area_dialog.h"
|
||||
|
||||
#include "ui_asm_edit_training_area_dialog.h"
|
||||
|
||||
#include <LtsWidgets/lts_message_dialog.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <LtsUtilsCore/dds_vector.h>
|
||||
#include <LtsUtilsCore/dds_vector_to_pixmap.h>
|
||||
#include <LtsUtilsSettings/settings.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <LtsWidgets/lts_message_dialog.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <Proxies/CombatNetRadio/helper.h>
|
||||
|
||||
static constexpr double s_minWidth{10};
|
||||
static constexpr double s_maxWidth{50000};
|
||||
|
||||
|
||||
static constexpr double s_minWidth {10};
|
||||
static constexpr double s_maxWidth {50000};
|
||||
|
||||
static constexpr double s_minHeight {10};
|
||||
static constexpr double s_maxHeight {50000};
|
||||
|
||||
static constexpr double s_minHeight{10};
|
||||
static constexpr double s_maxHeight{50000};
|
||||
|
||||
using namespace CombatNetRadio;
|
||||
|
||||
namespace AssetManagement
|
||||
{
|
||||
Core::GeoPosition2D convert(const QPointF &coord)
|
||||
Core::GeoPosition2D convert(const QPointF& coord)
|
||||
{
|
||||
return Core::GeoPosition2D(coord.x(), coord.y());
|
||||
return Core::GeoPosition2D(coord.x(), coord.y());
|
||||
}
|
||||
|
||||
QPointF convert(const Core::GeoPosition2D &geoPos)
|
||||
QPointF convert(const Core::GeoPosition2D& geoPos)
|
||||
{
|
||||
return QPointF(geoPos.lon(), geoPos.lat());
|
||||
return QPointF(geoPos.lon(), geoPos.lat());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
AsmEditTrainingAreaDialog::AsmEditTrainingAreaDialog(QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel)
|
||||
, m_ui(new Ui::AsmEditTrainingAreaDialog)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_menuGroup()
|
||||
AsmEditTrainingAreaDialog::AsmEditTrainingAreaDialog(QWidget* parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel),
|
||||
m_ui(new Ui::AsmEditTrainingAreaDialog), m_requestHelper(new LtsUtils::RequestHelper(this)), m_menuGroup()
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_ui->setupUi(this);
|
||||
}
|
||||
|
||||
|
||||
AsmEditTrainingAreaDialog::~AsmEditTrainingAreaDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
|
||||
void AsmEditTrainingAreaDialog::retranslate()
|
||||
{
|
||||
translate(m_ui, m_dialogTitle);
|
||||
translate(m_ui, m_dialogTitle);
|
||||
}
|
||||
|
||||
|
||||
bool AsmEditTrainingAreaDialog::init(LtsSession::LtsSessionDataDds *session,
|
||||
const int &trainingAreaId,
|
||||
const std::shared_ptr<SituationMap::ForeignGuiInterface> &sitMapGuiIfc,
|
||||
const QString &menuGroup)
|
||||
bool AsmEditTrainingAreaDialog::init(LtsSession::LtsSessionDataDds* session, const int& trainingAreaId,
|
||||
const std::shared_ptr<SituationMap::ForeignGuiInterface>& sitMapGuiIfc,
|
||||
const QString& menuGroup)
|
||||
{
|
||||
m_menuGroup = menuGroup;
|
||||
m_session = session;
|
||||
if (!m_session->getDtc<AssetManagement::DataInterface>(m_asmDtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "AsmEditTrainingAreaDialog::init() Could not enable DTC from ASM";
|
||||
return false;
|
||||
}
|
||||
if(!m_session->getFtc<AssetManagement::DataInterface>(m_asmFtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "AsmEditTrainingAreaDialog::init() Could not enable FTC from ASM";
|
||||
return false;
|
||||
}
|
||||
m_asmFtc->enableTrainingAreaRemove(true);
|
||||
m_asmFtc->enableTrainingAreaModify(true);
|
||||
|
||||
|
||||
|
||||
if (!sitMapGuiIfc)
|
||||
{
|
||||
ERROR_LOG(m_logger) << Q_FUNC_INFO << " Invalid shared_ptr sitMapGuiIfc!";
|
||||
return false;
|
||||
}
|
||||
|
||||
m_trainingArea = AssetManagement::TrainingArea();
|
||||
AssetManagement::TrainingArea ta = AssetManagement::TrainingArea();
|
||||
if(trainingAreaId == 0)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " New training area ";
|
||||
ta.id() = 0;
|
||||
ta.name() = QStringLiteral("newArea").toStdString();
|
||||
ta.width() = 12800;
|
||||
ta.height() = 12800;
|
||||
m_dialogTitle = tr("New Training Area");
|
||||
}
|
||||
else
|
||||
{
|
||||
ta = m_asmDtc->trainingArea(trainingAreaId);
|
||||
if(ta.id()<= 0)
|
||||
m_menuGroup = menuGroup;
|
||||
m_session = session;
|
||||
if (!m_session->getDtc<AssetManagement::DataInterface>(m_asmDtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << Q_FUNC_INFO << " training area not valid id: "<< trainingAreaId;
|
||||
return false;
|
||||
ERROR_LOG(m_logger) << "AsmEditTrainingAreaDialog::init() Could not enable DTC from ASM";
|
||||
return false;
|
||||
}
|
||||
if (!m_session->getFtc<AssetManagement::DataInterface>(m_asmFtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "AsmEditTrainingAreaDialog::init() Could not enable FTC from ASM";
|
||||
return false;
|
||||
}
|
||||
m_asmFtc->enableTrainingAreaRemove(true);
|
||||
m_asmFtc->enableTrainingAreaModify(true);
|
||||
|
||||
if (!sitMapGuiIfc)
|
||||
{
|
||||
ERROR_LOG(m_logger) << Q_FUNC_INFO << " Invalid shared_ptr sitMapGuiIfc!";
|
||||
return false;
|
||||
}
|
||||
|
||||
m_dialogTitle = tr("Edit Training Area: %1").arg(QString::fromStdString(ta.name()));
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " edit training area " <<trainingAreaId;
|
||||
}
|
||||
m_trainingArea = AssetManagement::TrainingArea();
|
||||
AssetManagement::TrainingArea ta = AssetManagement::TrainingArea();
|
||||
if (trainingAreaId == 0)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " New training area ";
|
||||
ta.id() = 0;
|
||||
ta.name() = QStringLiteral("newArea").toStdString();
|
||||
ta.width() = 12800;
|
||||
ta.height() = 12800;
|
||||
m_dialogTitle = tr("New Training Area");
|
||||
}
|
||||
else
|
||||
{
|
||||
ta = m_asmDtc->trainingArea(trainingAreaId);
|
||||
if (ta.id() <= 0)
|
||||
{
|
||||
ERROR_LOG(m_logger) << Q_FUNC_INFO << " training area not valid id: " << trainingAreaId;
|
||||
return false;
|
||||
}
|
||||
|
||||
m_trainingArea = ta;
|
||||
m_sitMapGuiIfc = sitMapGuiIfc;
|
||||
if (m_sitMapGuiIfc)
|
||||
{
|
||||
connect(m_ui->pbPosition, &QPushButton::clicked, this, &AsmEditTrainingAreaDialog::getPosition);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ui->pbPosition->setEnabled(false);
|
||||
}
|
||||
m_ui->name_lineEdit->setText(QString::fromStdString(m_trainingArea.name()));
|
||||
m_dialogTitle = tr("Edit Training Area: %1").arg(QString::fromStdString(ta.name()));
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " edit training area " << trainingAreaId;
|
||||
}
|
||||
|
||||
connect(m_ui->pbClear, &QPushButton::clicked,
|
||||
m_ui->positionEdit, &LtsCoordWidget::LtsCoordWidget::clear);
|
||||
m_trainingArea = ta;
|
||||
m_sitMapGuiIfc = sitMapGuiIfc;
|
||||
if (m_sitMapGuiIfc)
|
||||
{
|
||||
connect(m_ui->pbPosition, &QPushButton::clicked, this, &AsmEditTrainingAreaDialog::getPosition);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ui->pbPosition->setEnabled(false);
|
||||
}
|
||||
m_ui->name_lineEdit->setText(QString::fromStdString(m_trainingArea.name()));
|
||||
|
||||
onEditClicked();
|
||||
|
||||
connect(m_ui->pbClear, &QPushButton::clicked, m_ui->positionEdit, &LtsCoordWidget::LtsCoordWidget::clear);
|
||||
|
||||
setData();
|
||||
enaDisa();
|
||||
onEditClicked();
|
||||
|
||||
return true;
|
||||
setData();
|
||||
enaDisa();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AsmEditTrainingAreaDialog::enaDisa()
|
||||
{
|
||||
m_ui->pbPosition->setEnabled(m_sitMapGuiIfc.get());
|
||||
m_ui->pbPosition->setEnabled(m_sitMapGuiIfc.get());
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool AsmEditTrainingAreaDialog::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;
|
||||
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 AsmEditTrainingAreaDialog::getPosition()
|
||||
{
|
||||
const SituationMap::MapMode mode = m_sitMapGuiIfc->mapMode();
|
||||
const SituationMap::MapMode mode = m_sitMapGuiIfc->mapMode();
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case SituationMap::MapMode::MapMode_2D:
|
||||
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());
|
||||
|
||||
break;
|
||||
case SituationMap::MapMode::MapMode_3D:
|
||||
m_sitMapGuiIfc->getCoordinate(this, SLOT(onCoordinate(QPointF)), nullptr);
|
||||
break;
|
||||
case SituationMap::MapMode::Undefined:
|
||||
ERROR_LOG(m_logger) << Q_FUNC_INFO << " ModeMode == Undefined ";
|
||||
break;
|
||||
}
|
||||
switch (mode)
|
||||
{
|
||||
case SituationMap::MapMode::MapMode_2D:
|
||||
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());
|
||||
|
||||
break;
|
||||
case SituationMap::MapMode::MapMode_3D:
|
||||
m_sitMapGuiIfc->getCoordinate(this, SLOT(onCoordinate(QPointF)), nullptr);
|
||||
break;
|
||||
case SituationMap::MapMode::Undefined:
|
||||
ERROR_LOG(m_logger) << Q_FUNC_INFO << " ModeMode == Undefined ";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void AsmEditTrainingAreaDialog::onRectData(const QPointF ¢erPoint, double width, double height, const QPolygonF &coordinates)
|
||||
void AsmEditTrainingAreaDialog::onRectData(const QPointF& centerPoint, double width, double height,
|
||||
const QPolygonF& coordinates)
|
||||
{
|
||||
LtsCoordTrans::UtmCoordinate utmCoordinate = LtsCoordTrans::UtmCoordinate::fromGeographic(centerPoint.x(), centerPoint.y());
|
||||
const QPointF &btmLeft = utmCoordinate.geographic(-1*(width/2.0), -1*(height/2.0));
|
||||
LtsCoordTrans::UtmCoordinate utmCoordinate =
|
||||
LtsCoordTrans::UtmCoordinate::fromGeographic(centerPoint.x(), centerPoint.y());
|
||||
const QPointF& btmLeft = utmCoordinate.geographic(-1 * (width / 2.0), -1 * (height / 2.0));
|
||||
|
||||
m_previewPolygon = coordinates;
|
||||
m_ui->positionEdit->setCoordinate(centerPoint.x(),centerPoint.y());
|
||||
m_ui->positionEdit->setCoordinate(centerPoint.x(), centerPoint.y());
|
||||
m_ui->sbWidth->setValue(width);
|
||||
m_ui->sbHeight->setValue(height);
|
||||
m_trainingArea.height() = height;
|
||||
m_trainingArea.width() = width;
|
||||
m_trainingArea.bottomLeft() = convert(btmLeft);
|
||||
|
||||
DEBUG_LOG(m_logger) << "Pos X: " << centerPoint.x() << " Y: " << centerPoint.y() << " W: " << width << " H: " << height;
|
||||
DEBUG_LOG(m_logger) << "Pos X: " << centerPoint.x() << " Y: " << centerPoint.y() << " W: " << width
|
||||
<< " H: " << height;
|
||||
|
||||
showPreviewObject();
|
||||
showPreviewObject();
|
||||
}
|
||||
|
||||
void AsmEditTrainingAreaDialog::onCoordinate(const QPointF ¢erPoint)
|
||||
void AsmEditTrainingAreaDialog::onCoordinate(const QPointF& centerPoint)
|
||||
{
|
||||
LtsCoordTrans::UtmCoordinate utmCoordinate = LtsCoordTrans::UtmCoordinate::fromGeographic(centerPoint.x(), centerPoint.y());
|
||||
LtsCoordTrans::UtmCoordinate utmCoordinate =
|
||||
LtsCoordTrans::UtmCoordinate::fromGeographic(centerPoint.x(), centerPoint.y());
|
||||
|
||||
const double height = m_ui->sbHeight->value();
|
||||
const double width = m_ui->sbWidth->value();
|
||||
const QPointF btmLeft = utmCoordinate.geographic(-1*(width/2.0), -1*(height/2.0));
|
||||
const double height = m_ui->sbHeight->value();
|
||||
const double width = m_ui->sbWidth->value();
|
||||
const QPointF btmLeft = utmCoordinate.geographic(-1 * (width / 2.0), -1 * (height / 2.0));
|
||||
|
||||
m_ui->positionEdit->setCoordinate(centerPoint.x(),centerPoint.y());
|
||||
m_ui->positionEdit->setCoordinate(centerPoint.x(), centerPoint.y());
|
||||
|
||||
{
|
||||
const QPointF topLeft = utmCoordinate.geographic(-1*(width/2.0), 1*(height/2.0));
|
||||
const QPointF topRight = utmCoordinate.geographic( 1*(width/2.0), 1*(height/2.0));
|
||||
const QPointF btmRight = utmCoordinate.geographic( 1*(width/2.0),-1*(height/2.0));
|
||||
{
|
||||
const QPointF topLeft = utmCoordinate.geographic(-1 * (width / 2.0), 1 * (height / 2.0));
|
||||
const QPointF topRight = utmCoordinate.geographic(1 * (width / 2.0), 1 * (height / 2.0));
|
||||
const QPointF btmRight = utmCoordinate.geographic(1 * (width / 2.0), -1 * (height / 2.0));
|
||||
|
||||
m_previewPolygon.clear();
|
||||
m_previewPolygon.append(btmLeft);
|
||||
m_previewPolygon.append(topLeft);
|
||||
m_previewPolygon.append(topRight);
|
||||
m_previewPolygon.append(btmRight);
|
||||
}
|
||||
m_previewPolygon.clear();
|
||||
m_previewPolygon.append(btmLeft);
|
||||
m_previewPolygon.append(topLeft);
|
||||
m_previewPolygon.append(topRight);
|
||||
m_previewPolygon.append(btmRight);
|
||||
}
|
||||
|
||||
m_ui->sbWidth->setValue(width);
|
||||
m_ui->sbHeight->setValue(height);
|
||||
m_trainingArea.height() = height;
|
||||
m_trainingArea.width() = width;
|
||||
m_trainingArea.bottomLeft() = convert(btmLeft);
|
||||
m_ui->sbWidth->setValue(width);
|
||||
m_ui->sbHeight->setValue(height);
|
||||
m_trainingArea.height() = height;
|
||||
m_trainingArea.width() = width;
|
||||
m_trainingArea.bottomLeft() = convert(btmLeft);
|
||||
|
||||
DEBUG_LOG(m_logger) << "Pos X: " << centerPoint.x() << " Y: " << centerPoint.y() << " W: " << width << " H: " << height;
|
||||
|
||||
showPreviewObject();
|
||||
DEBUG_LOG(m_logger) << "Pos X: " << centerPoint.x() << " Y: " << centerPoint.y() << " W: " << width
|
||||
<< " H: " << height;
|
||||
|
||||
showPreviewObject();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AsmEditTrainingAreaDialog::onEditClicked()
|
||||
{
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START Editing..";
|
||||
if (!m_sitMapGuiIfc || m_trainingArea.id() < 0)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "onEditClicked: sitMapGuiIfc or trainingArea_id: "<<m_trainingArea.id()<<" invalid! ";
|
||||
return;
|
||||
}
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START Editing..";
|
||||
if (!m_sitMapGuiIfc || m_trainingArea.id() < 0)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "onEditClicked: sitMapGuiIfc or trainingArea_id: " << m_trainingArea.id()
|
||||
<< " invalid! ";
|
||||
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());
|
||||
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());
|
||||
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END Edit";
|
||||
|
||||
onSelectionChanged();
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END Edit";
|
||||
|
||||
onSelectionChanged();
|
||||
}
|
||||
|
||||
void AsmEditTrainingAreaDialog::onSelectionChanged()
|
||||
{
|
||||
m_previewPolygon= getTrainingArea(m_trainingArea);
|
||||
showPreviewObject();
|
||||
m_previewPolygon = getTrainingArea(m_trainingArea);
|
||||
showPreviewObject();
|
||||
}
|
||||
|
||||
void AsmEditTrainingAreaDialog::showPreviewObject()
|
||||
{
|
||||
if (!m_sitMapGuiIfc || m_previewPolygon.size() == 0)
|
||||
{
|
||||
TRACE_LOG(m_logger) << " AsmEditTrainingAreaDialog::showPreviewObject(): m_sitMapGuiIfc invalid or polygon empty ";
|
||||
return;
|
||||
}
|
||||
m_sitMapGuiIfc->displayPreviewObject(this, m_previewPolygon, true);
|
||||
if (!m_sitMapGuiIfc || m_previewPolygon.size() == 0)
|
||||
{
|
||||
TRACE_LOG(m_logger)
|
||||
<< " AsmEditTrainingAreaDialog::showPreviewObject(): m_sitMapGuiIfc invalid or polygon empty ";
|
||||
return;
|
||||
}
|
||||
m_sitMapGuiIfc->displayPreviewObject(this, m_previewPolygon, true);
|
||||
}
|
||||
|
||||
QPointF AsmEditTrainingAreaDialog::getCentPos(TrainingArea ta)
|
||||
{
|
||||
|
||||
LtsCoordTrans::UtmCoordinate utmCoordinate = LtsCoordTrans::UtmCoordinate::fromGeographic(ta.bottomLeft().lon(),
|
||||
ta.bottomLeft().lat());
|
||||
|
||||
QPointF centerPoint = utmCoordinate.geographic((ta.width() / 2.0), ta.height() / 2.0);
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " coord: x: "<< centerPoint.x() <<" y: "<< centerPoint.y();
|
||||
LtsCoordTrans::UtmCoordinate utmCoordinate =
|
||||
LtsCoordTrans::UtmCoordinate::fromGeographic(ta.bottomLeft().lon(), ta.bottomLeft().lat());
|
||||
|
||||
return centerPoint;
|
||||
QPointF centerPoint = utmCoordinate.geographic((ta.width() / 2.0), ta.height() / 2.0);
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " coord: x: " << centerPoint.x() << " y: " << centerPoint.y();
|
||||
|
||||
return centerPoint;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool AsmEditTrainingAreaDialog::apply()
|
||||
{
|
||||
LtsCoordTrans::UtmCoordinate utmCoordinate = LtsCoordTrans::UtmCoordinate::fromGeographic(m_ui->positionEdit->coordinate().x(),
|
||||
m_ui->positionEdit->coordinate().y());
|
||||
LtsCoordTrans::UtmCoordinate utmCoordinate = LtsCoordTrans::UtmCoordinate::fromGeographic(
|
||||
m_ui->positionEdit->coordinate().x(), m_ui->positionEdit->coordinate().y());
|
||||
|
||||
if(!m_asmFtc)
|
||||
{
|
||||
ERROR_LOG(m_logger) << Q_FUNC_INFO << " Can not retrieve AssetManagement::FTC";
|
||||
return false;
|
||||
}
|
||||
double height = m_ui->sbHeight->value();
|
||||
double width = m_ui->sbWidth->value();
|
||||
const QPointF btmLeft = utmCoordinate.geographic(-1*(width/2.0), -1*(height/2.0));
|
||||
if (!m_asmFtc)
|
||||
{
|
||||
ERROR_LOG(m_logger) << Q_FUNC_INFO << " Can not retrieve AssetManagement::FTC";
|
||||
return false;
|
||||
}
|
||||
double height = m_ui->sbHeight->value();
|
||||
double width = m_ui->sbWidth->value();
|
||||
const QPointF btmLeft = utmCoordinate.geographic(-1 * (width / 2.0), -1 * (height / 2.0));
|
||||
|
||||
TrainingArea req = m_trainingArea;
|
||||
TrainingArea req = m_trainingArea;
|
||||
|
||||
req.name() = m_ui->name_lineEdit->text().toStdString();
|
||||
req.width() = m_ui->sbWidth->value();
|
||||
req.height() = m_ui->sbHeight->value();
|
||||
req.bottomLeft(convert(btmLeft));
|
||||
req.name() = m_ui->name_lineEdit->text().toStdString();
|
||||
req.width() = m_ui->sbWidth->value();
|
||||
req.height() = m_ui->sbHeight->value();
|
||||
req.bottomLeft(convert(btmLeft));
|
||||
|
||||
bool success = m_requestHelper->startSingleRequest([this, req]()
|
||||
{
|
||||
return m_asmFtc->trainingAreaModifyRequest(req, this);
|
||||
});
|
||||
bool success =
|
||||
m_requestHelper->startSingleRequest([this, req]() { return m_asmFtc->trainingAreaModifyRequest(req, this); });
|
||||
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " scucess=" << success;
|
||||
return success;
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " scucess=" << success;
|
||||
return success;
|
||||
}
|
||||
|
||||
void AsmEditTrainingAreaDialog::setData()
|
||||
{
|
||||
if(m_trainingArea.id() > 0)
|
||||
{
|
||||
m_ui->name_lineEdit->setText(QString::fromStdString(m_trainingArea.name()));
|
||||
QPointF coord = getCentPos(m_trainingArea);
|
||||
m_ui->positionEdit->setCoordinate(coord.x(), coord.y());
|
||||
m_ui->sbWidth->setValue(m_trainingArea.width());
|
||||
m_ui->sbHeight->setValue(m_trainingArea.height());
|
||||
}
|
||||
if (m_trainingArea.id() > 0)
|
||||
{
|
||||
m_ui->name_lineEdit->setText(QString::fromStdString(m_trainingArea.name()));
|
||||
QPointF coord = getCentPos(m_trainingArea);
|
||||
m_ui->positionEdit->setCoordinate(coord.x(), coord.y());
|
||||
m_ui->sbWidth->setValue(m_trainingArea.width());
|
||||
m_ui->sbHeight->setValue(m_trainingArea.height());
|
||||
}
|
||||
}
|
||||
|
||||
QPolygonF AsmEditTrainingAreaDialog::getTrainingArea(const TrainingArea &ta)
|
||||
QPolygonF AsmEditTrainingAreaDialog::getTrainingArea(const TrainingArea& ta)
|
||||
{
|
||||
QPolygonF polygonF;
|
||||
if(!m_asmDtc)
|
||||
{
|
||||
ERROR_LOG(m_logger) << " m_asmDtc is not valid!";
|
||||
return{};
|
||||
}
|
||||
AssetManagement::TrainingArea ddsTrainingArea = ta;
|
||||
|
||||
QPolygonF polygonF;
|
||||
if (!m_asmDtc)
|
||||
{
|
||||
ERROR_LOG(m_logger) << " m_asmDtc is not valid!";
|
||||
return {};
|
||||
}
|
||||
AssetManagement::TrainingArea ddsTrainingArea = ta;
|
||||
|
||||
|
||||
LtsCoordTrans::UtmCoordinate utmCoordinate = LtsCoordTrans::UtmCoordinate::fromGeographic(ddsTrainingArea.bottomLeft().lon(), ddsTrainingArea.bottomLeft().lat());
|
||||
polygonF.push_back(QPointF((ddsTrainingArea.bottomLeft().lon()),(ddsTrainingArea.bottomLeft().lat())));
|
||||
LtsCoordTrans::UtmCoordinate utmCoordinate = LtsCoordTrans::UtmCoordinate::fromGeographic(
|
||||
ddsTrainingArea.bottomLeft().lon(), ddsTrainingArea.bottomLeft().lat());
|
||||
polygonF.push_back(QPointF((ddsTrainingArea.bottomLeft().lon()), (ddsTrainingArea.bottomLeft().lat())));
|
||||
|
||||
|
||||
polygonF.push_back(utmCoordinate.geographic(ddsTrainingArea.width()));
|
||||
polygonF.push_back(utmCoordinate.geographic(ddsTrainingArea.width()));
|
||||
|
||||
|
||||
polygonF.push_back(utmCoordinate.geographic(ddsTrainingArea.width(), ddsTrainingArea.height()));
|
||||
polygonF.push_back(utmCoordinate.geographic(ddsTrainingArea.width(), ddsTrainingArea.height()));
|
||||
|
||||
|
||||
polygonF.push_back(utmCoordinate.geographic(0, ddsTrainingArea.height()));
|
||||
polygonF.push_back(utmCoordinate.geographic(0, ddsTrainingArea.height()));
|
||||
|
||||
return polygonF;
|
||||
return polygonF;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
} // namespace AssetManagement
|
||||
Executable → Regular
+53
-53
@@ -1,18 +1,16 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AssetManagement/asm_dtc.h>
|
||||
#include <AssetManagement/asm_ftc.h>
|
||||
#include <AssetManagement/logger.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||
#include <LtsSession/lts_session_data_dds.h>
|
||||
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <Plugins/AssetManagement/asm_data_plugin_interface.h>
|
||||
#include <Plugins/SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
@@ -22,64 +20,66 @@ class AsmEditTrainingAreaDialog;
|
||||
namespace AssetManagement
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class AsmEditTrainingAreaDialog final : public LtsWidgets::LtsDialog
|
||||
, protected Interface::Ftc::TrainingAreaModifyReplyHandler
|
||||
, protected Interface::Ftc::TrainingAreaRemoveReplyHandler
|
||||
class AsmEditTrainingAreaDialog final : public LtsWidgets::LtsDialog,
|
||||
protected Interface::Ftc::TrainingAreaModifyReplyHandler,
|
||||
protected Interface::Ftc::TrainingAreaRemoveReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AsmEditTrainingAreaDialog(QWidget *parent = nullptr);
|
||||
public:
|
||||
explicit AsmEditTrainingAreaDialog(QWidget* parent = nullptr);
|
||||
|
||||
bool init(LtsSession::LtsSessionDataDds *session,
|
||||
const int &trainingAreaId, const std::shared_ptr<SituationMap::ForeignGuiInterface> &sitMapGuiIfc,
|
||||
const QString &menuGroup);
|
||||
bool init(LtsSession::LtsSessionDataDds* session, const int& trainingAreaId,
|
||||
const std::shared_ptr<SituationMap::ForeignGuiInterface>& sitMapGuiIfc, const QString& menuGroup);
|
||||
|
||||
~AsmEditTrainingAreaDialog();
|
||||
~AsmEditTrainingAreaDialog();
|
||||
|
||||
private slots:
|
||||
void getPosition();
|
||||
void onRectData(const QPointF ¢erPoint, double width, double height, const QPolygonF &coordinates);
|
||||
void onCoordinate(const QPointF ¢erPoint);
|
||||
void onEditClicked();
|
||||
void onSelectionChanged();
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
void retranslate() override;
|
||||
void onTrainingAreaModifyReply(const Core::FunctionReplyObject &reply) override final { m_requestHelper->requestReply(reply); }
|
||||
void onTrainingAreaRemoveReply(const Core::FunctionReplyObject &reply) override final { m_requestHelper->requestReply(reply); }
|
||||
private slots:
|
||||
void getPosition();
|
||||
void onRectData(const QPointF& centerPoint, double width, double height, const QPolygonF& coordinates);
|
||||
void onCoordinate(const QPointF& centerPoint);
|
||||
void onEditClicked();
|
||||
void onSelectionChanged();
|
||||
|
||||
bool has2DMap();
|
||||
void enaDisa();
|
||||
void showPreviewObject();
|
||||
QPointF getCentPos(AssetManagement::TrainingArea ta);
|
||||
bool apply() override;
|
||||
void setData();
|
||||
QPolygonF getTrainingArea(const AssetManagement::TrainingArea &ta);
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
void retranslate() override;
|
||||
|
||||
Ui::AsmEditTrainingAreaDialog *m_ui{nullptr};
|
||||
LtsSession::LtsSessionDataDds *m_session{nullptr};
|
||||
|
||||
QPointF m_Coordinates;
|
||||
bool m_rubberbandEditMode{false};
|
||||
void onTrainingAreaModifyReply(const Core::FunctionReplyObject& reply) override final
|
||||
{
|
||||
m_requestHelper->requestReply(reply);
|
||||
}
|
||||
|
||||
std::shared_ptr<AssetManagement::Interface::Ftc> m_asmFtc;
|
||||
std::shared_ptr<AssetManagement::Interface::Dtc> m_asmDtc;
|
||||
void onTrainingAreaRemoveReply(const Core::FunctionReplyObject& reply) override final
|
||||
{
|
||||
m_requestHelper->requestReply(reply);
|
||||
}
|
||||
|
||||
bool has2DMap();
|
||||
void enaDisa();
|
||||
void showPreviewObject();
|
||||
QPointF getCentPos(AssetManagement::TrainingArea ta);
|
||||
bool apply() override;
|
||||
void setData();
|
||||
QPolygonF getTrainingArea(const AssetManagement::TrainingArea& ta);
|
||||
|
||||
LtsUtils::RequestHelper *m_requestHelper{nullptr};
|
||||
QString m_dialogTitle{};
|
||||
Ui::AsmEditTrainingAreaDialog* m_ui{nullptr};
|
||||
LtsSession::LtsSessionDataDds* m_session{nullptr};
|
||||
|
||||
QString m_menuGroup;
|
||||
QString m_trainingAreaName{};
|
||||
AssetManagement::TrainingArea m_trainingArea;
|
||||
std::shared_ptr<SituationMap::ForeignGuiInterface> m_sitMapGuiIfc;
|
||||
QPolygonF m_previewPolygon;
|
||||
bool m_taExist{false};
|
||||
QPointF m_Coordinates;
|
||||
bool m_rubberbandEditMode{false};
|
||||
|
||||
std::shared_ptr<AssetManagement::Interface::Ftc> m_asmFtc;
|
||||
std::shared_ptr<AssetManagement::Interface::Dtc> m_asmDtc;
|
||||
|
||||
LtsUtils::RequestHelper* m_requestHelper{nullptr};
|
||||
QString m_dialogTitle{};
|
||||
|
||||
QString m_menuGroup;
|
||||
QString m_trainingAreaName{};
|
||||
AssetManagement::TrainingArea m_trainingArea;
|
||||
std::shared_ptr<SituationMap::ForeignGuiInterface> m_sitMapGuiIfc;
|
||||
QPolygonF m_previewPolygon;
|
||||
bool m_taExist{false};
|
||||
};
|
||||
}
|
||||
} // namespace AssetManagement
|
||||
Executable → Regular
+185
-200
@@ -1,301 +1,286 @@
|
||||
|
||||
|
||||
|
||||
|
||||
#include "asm_training_area_dialog.h"
|
||||
#include "ui_asm_training_area_dialog.h"
|
||||
|
||||
#include "asm_edit_training_area_dialog.h"
|
||||
#include <Plugins/AssetManagement/asm_data_plugin_interface.h>
|
||||
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
|
||||
#include "ui_asm_training_area_dialog.h"
|
||||
|
||||
#include <AssetManagement/asm_ftc_types.h>
|
||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <LtsUtilsSettings/settings.h>
|
||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||
#include <Plugins/AssetManagement/asm_data_plugin_interface.h>
|
||||
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
|
||||
#include <Proxies/CombatNetRadio/helper.h>
|
||||
#include <AssetManagement/asm_ftc_types.h>
|
||||
|
||||
using namespace CombatNetRadio;
|
||||
|
||||
namespace AssetManagement
|
||||
{
|
||||
|
||||
|
||||
|
||||
AsmTrainingAreaDialog::AsmTrainingAreaDialog(const QString &menuGroup, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_ui(new Ui::AsmTrainingAreaDialog)
|
||||
, m_session(nullptr)
|
||||
, m_menuGroup(menuGroup)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
AsmTrainingAreaDialog::AsmTrainingAreaDialog(const QString& menuGroup, QWidget* parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly), m_ui(new Ui::AsmTrainingAreaDialog),
|
||||
m_session(nullptr), m_menuGroup(menuGroup), m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
setOnlineHelpFilename(QStringLiteral("Asset_Management-Training_Area"));
|
||||
m_ui->setupUi(this);
|
||||
setOnlineHelpFilename(QStringLiteral("Asset_Management-Training_Area"));
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Add, this, &AsmTrainingAreaDialog::onAddTrainingArea);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &AsmTrainingAreaDialog::onEditTrainingArea);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Remove, this, &AsmTrainingAreaDialog::onRemoveTrainingArea);
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Add, this, &AsmTrainingAreaDialog::onAddTrainingArea);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &AsmTrainingAreaDialog::onEditTrainingArea);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Remove, this, &AsmTrainingAreaDialog::onRemoveTrainingArea);
|
||||
|
||||
connect(m_ui->trainingAreaView, &LtsDataView::LtsDataView::signalSelectionChanged,
|
||||
this, &AsmTrainingAreaDialog::onSelectionChanged);
|
||||
enaDisa();
|
||||
connect(m_ui->trainingAreaView, &LtsDataView::LtsDataView::signalSelectionChanged, this,
|
||||
&AsmTrainingAreaDialog::onSelectionChanged);
|
||||
enaDisa();
|
||||
}
|
||||
|
||||
AsmTrainingAreaDialog::~AsmTrainingAreaDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void AsmTrainingAreaDialog::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("Training Area Overview"));
|
||||
translate(m_ui, tr("Training Area Overview"));
|
||||
}
|
||||
|
||||
void AsmTrainingAreaDialog::tableColumnOrganiserSetting()
|
||||
{
|
||||
|
||||
m_ui->trainingAreaView->setColumnsOrganiserEnabled(identifier(), true);
|
||||
|
||||
m_ui->trainingAreaView->setColumnsOrganiserEnabled(identifier(), true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool AsmTrainingAreaDialog::init(LtsSession::LtsSessionDataDds *session, const std::shared_ptr<SituationMap::ForeignGuiInterface> &sitMapGuiIfc)
|
||||
bool AsmTrainingAreaDialog::init(LtsSession::LtsSessionDataDds* session,
|
||||
const std::shared_ptr<SituationMap::ForeignGuiInterface>& sitMapGuiIfc)
|
||||
{
|
||||
m_session = session;
|
||||
m_session = session;
|
||||
|
||||
if (!m_session->getDtc<AssetManagement::DataInterface>(m_asmDtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not enable DTC from ASM";
|
||||
return false;
|
||||
}
|
||||
if(!m_session->getFtc<AssetManagement::DataInterface>(m_asmFtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not enable FTC from ASM";
|
||||
return false;
|
||||
}
|
||||
if (!m_session->getDtc<AssetManagement::DataInterface>(m_asmDtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not enable DTC from ASM";
|
||||
return false;
|
||||
}
|
||||
if (!m_session->getFtc<AssetManagement::DataInterface>(m_asmFtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not enable FTC from ASM";
|
||||
return false;
|
||||
}
|
||||
|
||||
m_sitMapGuiIfc = sitMapGuiIfc;
|
||||
if(!m_sitMapGuiIfc)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "m_sitMapGuiIfc is invalid ";
|
||||
return false;
|
||||
}
|
||||
bool bRet = true;
|
||||
bRet &= m_asmDtc->enableTrainingArea(true);
|
||||
m_sitMapGuiIfc = sitMapGuiIfc;
|
||||
if (!m_sitMapGuiIfc)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "m_sitMapGuiIfc is invalid ";
|
||||
return false;
|
||||
}
|
||||
bool bRet = true;
|
||||
bRet &= m_asmDtc->enableTrainingArea(true);
|
||||
|
||||
bRet &= m_asmFtc->enableTrainingAreaModify(true);
|
||||
bRet &= m_asmFtc->enableTrainingAreaRemove(true);
|
||||
bRet &= m_asmFtc->enableTrainingAreaModify(true);
|
||||
bRet &= m_asmFtc->enableTrainingAreaRemove(true);
|
||||
|
||||
if(!bRet)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not enable dtc or ftc from ASM";
|
||||
return false;
|
||||
}
|
||||
if (!bRet)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not enable dtc or ftc from ASM";
|
||||
return false;
|
||||
}
|
||||
|
||||
INFO_LOG(m_logger) << "Ftc && Dtc enabled from ASM";
|
||||
INFO_LOG(m_logger) << "Ftc && Dtc enabled from ASM";
|
||||
|
||||
delete m_model;
|
||||
m_model = new AsmTrainingAreaDialogModel(this);
|
||||
m_model->initModel(m_asmDtc, false);
|
||||
m_ui->trainingAreaView->setModel(m_model);
|
||||
connect(m_ui->trainingAreaView, &LtsDataView::LtsDataView::signalDoubleClicked, this, &AsmTrainingAreaDialog::onEditTrainingArea);
|
||||
delete m_model;
|
||||
m_model = new AsmTrainingAreaDialogModel(this);
|
||||
m_model->initModel(m_asmDtc, false);
|
||||
m_ui->trainingAreaView->setModel(m_model);
|
||||
connect(m_ui->trainingAreaView, &LtsDataView::LtsDataView::signalDoubleClicked, this,
|
||||
&AsmTrainingAreaDialog::onEditTrainingArea);
|
||||
|
||||
|
||||
showAllTrainingAreas();
|
||||
showAllTrainingAreas();
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void AsmTrainingAreaDialog::enaDisa()
|
||||
{
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, false);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, false);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, false);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, false);
|
||||
|
||||
QModelIndexList indexList = m_ui->trainingAreaView->selectedRows();
|
||||
if (indexList.size() == 0)
|
||||
return;
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, (indexList.size() == 1) );
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, (indexList.size() == 1) );
|
||||
QModelIndexList indexList = m_ui->trainingAreaView->selectedRows();
|
||||
if (indexList.size() == 0)
|
||||
return;
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, (indexList.size() == 1));
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, (indexList.size() == 1));
|
||||
}
|
||||
|
||||
void AsmTrainingAreaDialog::onAddTrainingArea()
|
||||
{
|
||||
const QString identifier = QStringLiteral("AsmAddTrainingArea");
|
||||
const QString identifier = QStringLiteral("AsmAddTrainingArea");
|
||||
|
||||
if(!focusDialog(m_menuGroup,identifier, LtsWidgets::LayoutArea::eDialogTab))
|
||||
{
|
||||
|
||||
AsmEditTrainingAreaDialog *dialog = new AsmEditTrainingAreaDialog(this);
|
||||
|
||||
if(!dialog->init(m_session,0,m_sitMapGuiIfc,m_menuGroup))
|
||||
if (!focusDialog(m_menuGroup, identifier, LtsWidgets::LayoutArea::eDialogTab))
|
||||
{
|
||||
delete dialog;
|
||||
return;
|
||||
}
|
||||
connect(this, &AsmTrainingAreaDialog::destroyed, dialog, &QObject::deleteLater);
|
||||
addDialog(dialog, m_menuGroup, identifier, LtsWidgets::LayoutArea::eDialogTab);
|
||||
}
|
||||
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " adding temp training Area ";
|
||||
AsmEditTrainingAreaDialog* dialog = new AsmEditTrainingAreaDialog(this);
|
||||
|
||||
if (!dialog->init(m_session, 0, m_sitMapGuiIfc, m_menuGroup))
|
||||
{
|
||||
delete dialog;
|
||||
return;
|
||||
}
|
||||
connect(this, &AsmTrainingAreaDialog::destroyed, dialog, &QObject::deleteLater);
|
||||
addDialog(dialog, m_menuGroup, identifier, LtsWidgets::LayoutArea::eDialogTab);
|
||||
}
|
||||
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " adding temp training Area ";
|
||||
}
|
||||
|
||||
void AsmTrainingAreaDialog::onRemoveTrainingArea()
|
||||
{
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START" ;
|
||||
QModelIndexList indexList = m_ui->trainingAreaView->selectedRows();
|
||||
if (indexList.size() == 0)
|
||||
return;
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START";
|
||||
QModelIndexList indexList = m_ui->trainingAreaView->selectedRows();
|
||||
if (indexList.size() == 0)
|
||||
return;
|
||||
|
||||
TrainingArea req = m_model->getRowData(indexList.front().row());
|
||||
if (req.id() < 0)
|
||||
{
|
||||
ERROR_LOG(m_logger) << Q_FUNC_INFO << " invalid id:bt"<< req.id();
|
||||
return;
|
||||
}
|
||||
if (!m_viewedTaIds.contains(req.id()))
|
||||
{
|
||||
bool success = m_requestHelper->startSingleRequest([this, req]()
|
||||
TrainingArea req = m_model->getRowData(indexList.front().row());
|
||||
if (req.id() < 0)
|
||||
{
|
||||
return m_asmFtc->trainingAreaRemoveRequest(TrainingAreaRemoveRequest(req.id()), this);
|
||||
});
|
||||
ERROR_LOG(m_logger) << Q_FUNC_INFO << " invalid id:bt" << req.id();
|
||||
return;
|
||||
}
|
||||
if (!m_viewedTaIds.contains(req.id()))
|
||||
{
|
||||
bool success = m_requestHelper->startSingleRequest(
|
||||
[this, req]() { return m_asmFtc->trainingAreaRemoveRequest(TrainingAreaRemoveRequest(req.id()), this); });
|
||||
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " success = " << success;
|
||||
}
|
||||
else
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Warning"),
|
||||
tr("Cannot remove currently edited Training Area"));
|
||||
}
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " success = " << success;
|
||||
}
|
||||
else
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Warning"),
|
||||
tr("Cannot remove currently edited Training Area"));
|
||||
}
|
||||
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END";
|
||||
}
|
||||
|
||||
void AsmTrainingAreaDialog::onEditTrainingArea()
|
||||
{
|
||||
QModelIndexList indexList = m_ui->trainingAreaView->selectedRows();
|
||||
if (indexList.size() == 0)
|
||||
return;
|
||||
TrainingArea taItem = m_model->getRowData(indexList.front().row());
|
||||
if (taItem.id() < 0)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "onEditTrainingArea invalid id = "<< taItem.id();
|
||||
return;
|
||||
}
|
||||
QModelIndexList indexList = m_ui->trainingAreaView->selectedRows();
|
||||
if (indexList.size() == 0)
|
||||
return;
|
||||
TrainingArea taItem = m_model->getRowData(indexList.front().row());
|
||||
if (taItem.id() < 0)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "onEditTrainingArea invalid id = " << taItem.id();
|
||||
return;
|
||||
}
|
||||
|
||||
const QString identifier = QStringLiteral("AsmEditTrainingArea_%1").arg(taItem.id());
|
||||
if(focusDialog(m_menuGroup,identifier, LtsWidgets::LayoutArea::eDialogTab))
|
||||
{
|
||||
return;
|
||||
}
|
||||
const QString identifier = QStringLiteral("AsmEditTrainingArea_%1").arg(taItem.id());
|
||||
if (focusDialog(m_menuGroup, identifier, LtsWidgets::LayoutArea::eDialogTab))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
AsmEditTrainingAreaDialog *dialog = new AsmEditTrainingAreaDialog(this);
|
||||
AsmEditTrainingAreaDialog* dialog = new AsmEditTrainingAreaDialog(this);
|
||||
|
||||
if(!dialog->init(m_session,taItem.id(),m_sitMapGuiIfc,m_menuGroup))
|
||||
{
|
||||
delete dialog;
|
||||
return;
|
||||
}
|
||||
if (!dialog->init(m_session, taItem.id(), m_sitMapGuiIfc, m_menuGroup))
|
||||
{
|
||||
delete dialog;
|
||||
return;
|
||||
}
|
||||
|
||||
connect(this, &AsmTrainingAreaDialog::destroyed, dialog, &QObject::deleteLater);
|
||||
|
||||
connect(dialog, &AsmEditTrainingAreaDialog::destroyed, this, [this](){
|
||||
clearSelection(); });
|
||||
addDialog(dialog, m_menuGroup, identifier, LtsWidgets::LayoutArea::eDialogTab);
|
||||
connect(this, &AsmTrainingAreaDialog::destroyed, dialog, &QObject::deleteLater);
|
||||
|
||||
connect(dialog, &AsmEditTrainingAreaDialog::destroyed, this, [this]() { clearSelection(); });
|
||||
addDialog(dialog, m_menuGroup, identifier, LtsWidgets::LayoutArea::eDialogTab);
|
||||
}
|
||||
|
||||
void AsmTrainingAreaDialog::onSelectionChanged()
|
||||
{
|
||||
enaDisa();
|
||||
DEBUG_LOG(m_logger) << "onSelectionChanged() called !";
|
||||
const QModelIndex curIdx = m_ui->trainingAreaView->currentIndex();
|
||||
if (!curIdx.isValid())
|
||||
return;
|
||||
enaDisa();
|
||||
DEBUG_LOG(m_logger) << "onSelectionChanged() called !";
|
||||
const QModelIndex curIdx = m_ui->trainingAreaView->currentIndex();
|
||||
if (!curIdx.isValid())
|
||||
return;
|
||||
|
||||
AssetManagement::TrainingArea taItem = m_model->getRowData(curIdx.row());
|
||||
DEBUG_LOG(m_logger) << "onSelectionChanged() selected training area id: "<<taItem.id();
|
||||
if(taItem.id() < 0)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "onEditTrainingArea invalid id"<< taItem.id();
|
||||
return;
|
||||
}
|
||||
|
||||
m_previewPolygon = getTrainingArea(taItem.id());
|
||||
showPreviewObject();
|
||||
AssetManagement::TrainingArea taItem = m_model->getRowData(curIdx.row());
|
||||
DEBUG_LOG(m_logger) << "onSelectionChanged() selected training area id: " << taItem.id();
|
||||
if (taItem.id() < 0)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "onEditTrainingArea invalid id" << taItem.id();
|
||||
return;
|
||||
}
|
||||
|
||||
m_previewPolygon = getTrainingArea(taItem.id());
|
||||
showPreviewObject();
|
||||
}
|
||||
|
||||
void AsmTrainingAreaDialog::clearSelection()
|
||||
{
|
||||
m_ui->trainingAreaView->clearSelection();
|
||||
if(m_sitMapGuiIfc)
|
||||
{
|
||||
m_sitMapGuiIfc->removePreviewObject();
|
||||
}
|
||||
m_ui->trainingAreaView->clearSelection();
|
||||
if (m_sitMapGuiIfc)
|
||||
{
|
||||
m_sitMapGuiIfc->removePreviewObject();
|
||||
}
|
||||
}
|
||||
|
||||
QPolygonF AsmTrainingAreaDialog::getTrainingArea(int trainingAreaId)
|
||||
{
|
||||
if(!m_asmDtc)
|
||||
{
|
||||
ERROR_LOG(m_logger) << Q_FUNC_INFO << " m_asmDtc is not valid!";
|
||||
return {};
|
||||
}
|
||||
const AssetManagement::TrainingArea &ddsTrainingArea = m_asmDtc->trainingArea(trainingAreaId);
|
||||
if (ddsTrainingArea.id() != trainingAreaId)
|
||||
{
|
||||
ERROR_LOG(m_logger) << Q_FUNC_INFO << " TrainingArea not found, trainingAreaId = " << trainingAreaId;
|
||||
return {};
|
||||
}
|
||||
if (!m_asmDtc)
|
||||
{
|
||||
ERROR_LOG(m_logger) << Q_FUNC_INFO << " m_asmDtc is not valid!";
|
||||
return {};
|
||||
}
|
||||
const AssetManagement::TrainingArea& ddsTrainingArea = m_asmDtc->trainingArea(trainingAreaId);
|
||||
if (ddsTrainingArea.id() != trainingAreaId)
|
||||
{
|
||||
ERROR_LOG(m_logger) << Q_FUNC_INFO << " TrainingArea not found, trainingAreaId = " << trainingAreaId;
|
||||
return {};
|
||||
}
|
||||
|
||||
return getTrainingArea(ddsTrainingArea);
|
||||
return getTrainingArea(ddsTrainingArea);
|
||||
}
|
||||
|
||||
QPolygonF AsmTrainingAreaDialog::getTrainingArea(const TrainingArea &ddsTrainingArea)
|
||||
QPolygonF AsmTrainingAreaDialog::getTrainingArea(const TrainingArea& ddsTrainingArea)
|
||||
{
|
||||
QPolygonF polygonF;
|
||||
QPolygonF polygonF;
|
||||
|
||||
|
||||
LtsCoordTrans::UtmCoordinate utmCoordinate = LtsCoordTrans::UtmCoordinate::fromGeographic(ddsTrainingArea.bottomLeft().lon(), ddsTrainingArea.bottomLeft().lat());
|
||||
polygonF.push_back(QPointF((ddsTrainingArea.bottomLeft().lon()),(ddsTrainingArea.bottomLeft().lat())));
|
||||
LtsCoordTrans::UtmCoordinate utmCoordinate = LtsCoordTrans::UtmCoordinate::fromGeographic(
|
||||
ddsTrainingArea.bottomLeft().lon(), ddsTrainingArea.bottomLeft().lat());
|
||||
polygonF.push_back(QPointF((ddsTrainingArea.bottomLeft().lon()), (ddsTrainingArea.bottomLeft().lat())));
|
||||
|
||||
|
||||
polygonF.push_back(utmCoordinate.geographic(ddsTrainingArea.width()));
|
||||
polygonF.push_back(utmCoordinate.geographic(ddsTrainingArea.width()));
|
||||
|
||||
|
||||
polygonF.push_back(utmCoordinate.geographic(ddsTrainingArea.width(), ddsTrainingArea.height()));
|
||||
polygonF.push_back(utmCoordinate.geographic(ddsTrainingArea.width(), ddsTrainingArea.height()));
|
||||
|
||||
|
||||
polygonF.push_back(utmCoordinate.geographic(0, ddsTrainingArea.height()));
|
||||
polygonF.push_back(utmCoordinate.geographic(0, ddsTrainingArea.height()));
|
||||
|
||||
return polygonF;
|
||||
return polygonF;
|
||||
}
|
||||
|
||||
|
||||
void AsmTrainingAreaDialog::showAllTrainingAreas()
|
||||
{
|
||||
if (!m_sitMapGuiIfc)
|
||||
return;
|
||||
if (!m_sitMapGuiIfc)
|
||||
return;
|
||||
|
||||
QVector<QPolygonF> polyVec;
|
||||
const int rowCount = m_model->rowCount();
|
||||
for (int row = 0; row < rowCount; ++row)
|
||||
{
|
||||
const TrainingArea ¤tArea = m_model->getRowData(row);
|
||||
INFO_LOG(m_logger) << " row = " << row << " ; currentArea = " << currentArea;
|
||||
const QPolygonF &poly = getTrainingArea(currentArea);
|
||||
polyVec.append(poly);
|
||||
}
|
||||
if (!polyVec.isEmpty())
|
||||
m_sitMapGuiIfc->displayPreviewObjects(this, polyVec, true);
|
||||
QVector<QPolygonF> polyVec;
|
||||
const int rowCount = m_model->rowCount();
|
||||
for (int row = 0; row < rowCount; ++row)
|
||||
{
|
||||
const TrainingArea& currentArea = m_model->getRowData(row);
|
||||
INFO_LOG(m_logger) << " row = " << row << " ; currentArea = " << currentArea;
|
||||
const QPolygonF& poly = getTrainingArea(currentArea);
|
||||
polyVec.append(poly);
|
||||
}
|
||||
if (!polyVec.isEmpty())
|
||||
m_sitMapGuiIfc->displayPreviewObjects(this, polyVec, true);
|
||||
}
|
||||
|
||||
void AsmTrainingAreaDialog::showPreviewObject()
|
||||
{
|
||||
if (!this->m_sitMapGuiIfc || m_previewPolygon.size() == 0)
|
||||
{
|
||||
TRACE_LOG(m_logger) << " showPreviewObject(): m_sitMapGuiIfc invalid or polygon empty ";
|
||||
return;
|
||||
}
|
||||
this->m_sitMapGuiIfc->displayPreviewObject(this, m_previewPolygon, true);
|
||||
if (!this->m_sitMapGuiIfc || m_previewPolygon.size() == 0)
|
||||
{
|
||||
TRACE_LOG(m_logger) << " showPreviewObject(): m_sitMapGuiIfc invalid or polygon empty ";
|
||||
return;
|
||||
}
|
||||
this->m_sitMapGuiIfc->displayPreviewObject(this, m_previewPolygon, true);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace AssetManagement
|
||||
Executable → Regular
+54
-47
@@ -1,74 +1,81 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
#include "asm_training_area_model.h"
|
||||
|
||||
#include <AssetManagement/asm_data_plugin_interface.h>
|
||||
#include <Plugins/SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <AssetManagement/logger.h>
|
||||
#include <AssetManagement/asm_dtc.h>
|
||||
#include <AssetManagement/asm_ftc.h>
|
||||
|
||||
#include "asm_training_area_model.h"
|
||||
#include <AssetManagement/logger.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <Plugins/SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class AsmTrainingAreaDialog;
|
||||
}
|
||||
|
||||
namespace LtsUtils
|
||||
{
|
||||
class RequestHelper;
|
||||
}
|
||||
|
||||
namespace AssetManagement
|
||||
{
|
||||
|
||||
|
||||
|
||||
class AsmTrainingAreaDialog : public LtsWidgets::LtsDialog
|
||||
, protected Interface::Ftc::TrainingAreaModifyReplyHandler
|
||||
, protected Interface::Ftc::TrainingAreaRemoveReplyHandler
|
||||
class AsmTrainingAreaDialog : public LtsWidgets::LtsDialog,
|
||||
protected Interface::Ftc::TrainingAreaModifyReplyHandler,
|
||||
protected Interface::Ftc::TrainingAreaRemoveReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AsmTrainingAreaDialog(const QString &menuGroup, QWidget *parent = nullptr);
|
||||
~AsmTrainingAreaDialog();
|
||||
public:
|
||||
explicit AsmTrainingAreaDialog(const QString& menuGroup, QWidget* parent = nullptr);
|
||||
~AsmTrainingAreaDialog();
|
||||
|
||||
bool init(LtsSession::LtsSessionDataDds *session,
|
||||
const std::shared_ptr<SituationMap::ForeignGuiInterface> &sitMapGuiIfc);
|
||||
QPolygonF getTrainingArea(int trainingAreaId);
|
||||
QPolygonF getTrainingArea(const TrainingArea &ddsTrainingArea);
|
||||
void showAllTrainingAreas();
|
||||
void showPreviewObject();
|
||||
void clearSelection();
|
||||
bool init(LtsSession::LtsSessionDataDds* session,
|
||||
const std::shared_ptr<SituationMap::ForeignGuiInterface>& sitMapGuiIfc);
|
||||
QPolygonF getTrainingArea(int trainingAreaId);
|
||||
QPolygonF getTrainingArea(const TrainingArea& ddsTrainingArea);
|
||||
void showAllTrainingAreas();
|
||||
void showPreviewObject();
|
||||
void clearSelection();
|
||||
|
||||
private slots:
|
||||
void enaDisa();
|
||||
void onAddTrainingArea();
|
||||
void onEditTrainingArea();
|
||||
void onRemoveTrainingArea();
|
||||
void onSelectionChanged();
|
||||
private slots:
|
||||
void enaDisa();
|
||||
void onAddTrainingArea();
|
||||
void onEditTrainingArea();
|
||||
void onRemoveTrainingArea();
|
||||
void onSelectionChanged();
|
||||
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
void retranslate() override;
|
||||
void onTrainingAreaModifyReply(const Core::FunctionReplyObject &reply) override final { m_requestHelper->requestReply(reply); }
|
||||
void onTrainingAreaRemoveReply(const Core::FunctionReplyObject &reply) override final { m_requestHelper->requestReply(reply); }
|
||||
void tableColumnOrganiserSetting() override;
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
void retranslate() override;
|
||||
|
||||
Ui::AsmTrainingAreaDialog *m_ui;
|
||||
AsmTrainingAreaDialogModel *m_model{nullptr};
|
||||
LtsSession::LtsSessionDataDds *m_session;
|
||||
QString m_menuGroup;
|
||||
std::shared_ptr<AssetManagement::Interface::Dtc> m_asmDtc;
|
||||
std::shared_ptr<AssetManagement::Interface::Ftc> m_asmFtc;
|
||||
LtsUtils::RequestHelper *m_requestHelper;
|
||||
QPolygonF m_previewPolygon;
|
||||
std::shared_ptr<SituationMap::ForeignGuiInterface> m_sitMapGuiIfc;
|
||||
QSet<int> m_viewedTaIds{};
|
||||
void onTrainingAreaModifyReply(const Core::FunctionReplyObject& reply) override final
|
||||
{
|
||||
m_requestHelper->requestReply(reply);
|
||||
}
|
||||
|
||||
void onTrainingAreaRemoveReply(const Core::FunctionReplyObject& reply) override final
|
||||
{
|
||||
m_requestHelper->requestReply(reply);
|
||||
}
|
||||
|
||||
void tableColumnOrganiserSetting() override;
|
||||
|
||||
Ui::AsmTrainingAreaDialog* m_ui;
|
||||
AsmTrainingAreaDialogModel* m_model{nullptr};
|
||||
LtsSession::LtsSessionDataDds* m_session;
|
||||
QString m_menuGroup;
|
||||
std::shared_ptr<AssetManagement::Interface::Dtc> m_asmDtc;
|
||||
std::shared_ptr<AssetManagement::Interface::Ftc> m_asmFtc;
|
||||
LtsUtils::RequestHelper* m_requestHelper;
|
||||
QPolygonF m_previewPolygon;
|
||||
std::shared_ptr<SituationMap::ForeignGuiInterface> m_sitMapGuiIfc;
|
||||
QSet<int> m_viewedTaIds{};
|
||||
};
|
||||
}
|
||||
} // namespace AssetManagement
|
||||
Executable → Regular
+48
-59
@@ -1,75 +1,64 @@
|
||||
#include "asm_training_area_model.h"
|
||||
|
||||
|
||||
namespace AssetManagement
|
||||
{
|
||||
|
||||
AsmTrainingAreaDialogModel::AsmTrainingAreaDialogModel(QObject *parent)
|
||||
: LtsWidgets::LtsAbstractTableModel<AssetManagement::TrainingArea>({tr("Id"),
|
||||
tr("Name"),
|
||||
tr("Botton Left x"),
|
||||
tr("Bottom Left y"),
|
||||
tr("Height"),
|
||||
tr("Width")},
|
||||
|
||||
parent)
|
||||
,m_asmDtc(nullptr)
|
||||
{}
|
||||
AsmTrainingAreaDialogModel::AsmTrainingAreaDialogModel(QObject* parent)
|
||||
: LtsWidgets::LtsAbstractTableModel<AssetManagement::TrainingArea>(
|
||||
{tr("Id"), tr("Name"), tr("Botton Left x"), tr("Bottom Left y"), tr("Height"), tr("Width")},
|
||||
|
||||
AsmTrainingAreaDialogModel::~AsmTrainingAreaDialogModel()
|
||||
{}
|
||||
|
||||
bool AsmTrainingAreaDialogModel::initModel(const std::shared_ptr<Interface::Dtc> &dtc, bool hideRemoved)
|
||||
parent),
|
||||
m_asmDtc(nullptr)
|
||||
{
|
||||
m_asmDtc = dtc;
|
||||
m_hideRemoved = hideRemoved;
|
||||
|
||||
if (m_asmDtc)
|
||||
{
|
||||
connect(m_asmDtc.get(), &Interface::Dtc::trainingAreaChanged, this, &AsmTrainingAreaDialogModel::onDataChanged);
|
||||
|
||||
m_asmDtc->trainingAreas([this](const AssetManagement::TrainingArea &data)
|
||||
{
|
||||
onDataChanged(data, DataModification::eAdded);
|
||||
});
|
||||
|
||||
} else {
|
||||
WARNING_LOG(m_logger) << Q_FUNC_INFO << " no m_asmDtc";
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QVariant AsmTrainingAreaDialogModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!indexIsValid(index))
|
||||
return QVariant();
|
||||
AsmTrainingAreaDialogModel::~AsmTrainingAreaDialogModel() {}
|
||||
|
||||
const AssetManagement::TrainingArea &asmTrainingArea = m_vecData.at(index.row());
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
switch (index.column())
|
||||
bool AsmTrainingAreaDialogModel::initModel(const std::shared_ptr<Interface::Dtc>& dtc, bool hideRemoved)
|
||||
{
|
||||
m_asmDtc = dtc;
|
||||
m_hideRemoved = hideRemoved;
|
||||
|
||||
if (m_asmDtc)
|
||||
{
|
||||
case Id:
|
||||
return asmTrainingArea.id();
|
||||
case Name:
|
||||
return QString::fromStdString(asmTrainingArea.name());
|
||||
case BottomLeft_x:
|
||||
return asmTrainingArea.bottomLeft().lon();
|
||||
case BottomLeft_y:
|
||||
return asmTrainingArea.bottomLeft().lat();
|
||||
case Height:
|
||||
return asmTrainingArea.height();
|
||||
case Width:
|
||||
return asmTrainingArea.width();
|
||||
|
||||
|
||||
connect(m_asmDtc.get(), &Interface::Dtc::trainingAreaChanged, this, &AsmTrainingAreaDialogModel::onDataChanged);
|
||||
|
||||
m_asmDtc->trainingAreas(
|
||||
[this](const AssetManagement::TrainingArea& data) { onDataChanged(data, DataModification::eAdded); });
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
else
|
||||
{
|
||||
WARNING_LOG(m_logger) << Q_FUNC_INFO << " no m_asmDtc";
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QVariant AsmTrainingAreaDialogModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
if (!indexIsValid(index))
|
||||
return QVariant();
|
||||
|
||||
|
||||
|
||||
const AssetManagement::TrainingArea& asmTrainingArea = m_vecData.at(index.row());
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
switch (index.column())
|
||||
{
|
||||
case Id:
|
||||
return asmTrainingArea.id();
|
||||
case Name:
|
||||
return QString::fromStdString(asmTrainingArea.name());
|
||||
case BottomLeft_x:
|
||||
return asmTrainingArea.bottomLeft().lon();
|
||||
case BottomLeft_y:
|
||||
return asmTrainingArea.bottomLeft().lat();
|
||||
case Height:
|
||||
return asmTrainingArea.height();
|
||||
case Width:
|
||||
return asmTrainingArea.width();
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
} // namespace AssetManagement
|
||||
Executable → Regular
+22
-31
@@ -1,47 +1,38 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
#include <AssetManagement/asm_dtc.h>
|
||||
#include <AssetManagement/logger.h>
|
||||
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
|
||||
namespace AssetManagement
|
||||
{
|
||||
|
||||
class AsmTrainingAreaDialogModel
|
||||
: public LtsWidgets::LtsAbstractTableModel<AssetManagement::TrainingArea>
|
||||
class AsmTrainingAreaDialogModel : public LtsWidgets::LtsAbstractTableModel<AssetManagement::TrainingArea>
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum Columns
|
||||
{
|
||||
Id,
|
||||
Name,
|
||||
BottomLeft_x,
|
||||
BottomLeft_y,
|
||||
Height,
|
||||
Width,
|
||||
Image,
|
||||
};
|
||||
public:
|
||||
enum Columns {
|
||||
Id,
|
||||
Name,
|
||||
BottomLeft_x,
|
||||
BottomLeft_y,
|
||||
Height,
|
||||
Width,
|
||||
Image,
|
||||
};
|
||||
|
||||
explicit AsmTrainingAreaDialogModel(QObject *parent = nullptr);
|
||||
~AsmTrainingAreaDialogModel();
|
||||
bool initModel(const std::shared_ptr<AssetManagement::Interface::Dtc> &asmDtc, bool hideRemoved);
|
||||
explicit AsmTrainingAreaDialogModel(QObject* parent = nullptr);
|
||||
~AsmTrainingAreaDialogModel();
|
||||
bool initModel(const std::shared_ptr<AssetManagement::Interface::Dtc>& asmDtc, bool hideRemoved);
|
||||
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override final;
|
||||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override final;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
bool m_hideRemoved;
|
||||
std::shared_ptr<Interface::Dtc> m_asmDtc;
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
bool m_hideRemoved;
|
||||
std::shared_ptr<Interface::Dtc> m_asmDtc;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace AssetManagement
|
||||
Reference in new issue
Block a user