Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
Executable
+28
@@ -0,0 +1,28 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
# Created by Christian Ehrlicher, SLSE, 2016-03-01
|
||||
#
|
||||
|
||||
ADD_SUBDIRECTORY(Data)
|
||||
ADD_SUBDIRECTORY(Gui)
|
||||
|
||||
#
|
||||
# Data Plugin Interface
|
||||
#
|
||||
ADD_INTERFACE_LIBRARY(AsmDataPluginInterface
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/asm_data_plugin_interface.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/..
|
||||
DataPluginInterface
|
||||
svcAsmCommon
|
||||
)
|
||||
#
|
||||
# Gui Plugin Interface
|
||||
#
|
||||
ADD_INTERFACE_LIBRARY(AsmGuiPluginInterface
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/asm_gui_plugin_interface.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/..
|
||||
GuiPluginInterface
|
||||
svcAsmCommon
|
||||
)
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
# Created by Mike Wille, SLSE; 2016-09-06
|
||||
#
|
||||
|
||||
#
|
||||
# Data Plugin
|
||||
#
|
||||
NGL_ADD_LIBRARY(WS AsmDataPlugin MODULE asm_data_plugin.cpp asm_data_plugin.h)
|
||||
NGL_TARGET_LINK_LIBRARIES(AsmDataPlugin
|
||||
Qt5::Core
|
||||
AsmDataPluginInterface
|
||||
svcAsmClient
|
||||
NGLLogger
|
||||
LtsSessionDataDds
|
||||
)
|
||||
NGL_INSTALL_TARGET(AsmDataPlugin)
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Data Plugin for ExerciseManangement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
*/
|
||||
|
||||
#include "asm_data_plugin.h"
|
||||
|
||||
#include <DDS/DDSConnector/dds_connector.h>
|
||||
#include <AssetManagement/logger.h>
|
||||
#include <LtsSession/lts_session_data_dds.h>
|
||||
|
||||
namespace AssetManagement
|
||||
{
|
||||
std::shared_ptr<DataPluginBase::Interface> DataPlugin::createDataInterface(LtsSession::LtsSessionDataDds *session)
|
||||
{
|
||||
std::shared_ptr<Interface::Dtc> dtc;
|
||||
std::shared_ptr<Interface::Ftc> ftc;
|
||||
if (!session->createTopicClient(dtc, ftc, false, true))
|
||||
return std::shared_ptr<DataPluginBase::Interface>();
|
||||
return std::make_shared<DataInterfaceImpl>(dtc, ftc);
|
||||
}
|
||||
|
||||
DataInterfaceImpl::DataInterfaceImpl(const std::shared_ptr<AssetManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<AssetManagement::Interface::Ftc> &ftc)
|
||||
: DataInterface()
|
||||
, m_dtc(dtc)
|
||||
, m_ftc(ftc)
|
||||
{}
|
||||
|
||||
} // namespace AssetManagement
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Data Plugin for AssetManagement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <PluginInterfaces/data_plugin_interface.h>
|
||||
#include <Plugins/AssetManagement/asm_data_plugin_interface.h>
|
||||
|
||||
|
||||
namespace AssetManagement
|
||||
{
|
||||
|
||||
class DataPlugin final : public QObject, public DataPluginBase::Plugin
|
||||
{
|
||||
Q_PLUGIN_METADATA(IID "data:3:asm")
|
||||
Q_INTERFACES(DataPluginBase::Plugin)
|
||||
|
||||
Q_OBJECT
|
||||
public:
|
||||
DataPlugin() = default;
|
||||
~DataPlugin() = default;
|
||||
|
||||
QString pluginName() const override { return QStringLiteral("AssetManagement"); }
|
||||
std::shared_ptr<DataPluginBase::Interface> createDataInterface(LtsSession::LtsSessionDataDds *session) override;
|
||||
bool availableInPartition(IDL::PartitionType partition) const override { return (partition == IDL::PartitionType::Global || partition == IDL::PartitionType::Exercise || partition == IDL::PartitionType::Replay ); }
|
||||
};
|
||||
|
||||
|
||||
class DataInterfaceImpl final : public DataInterface
|
||||
{
|
||||
public:
|
||||
explicit DataInterfaceImpl(const std::shared_ptr<AssetManagement::Interface::Dtc> &dtc, const std::shared_ptr<AssetManagement::Interface::Ftc> &ftc);
|
||||
|
||||
// DataInterface interface
|
||||
std::shared_ptr<AssetManagement::Interface::Ftc> getFtc() override { return m_ftc; }
|
||||
std::shared_ptr<AssetManagement::Interface::Dtc> getDtc() override { return m_dtc; }
|
||||
|
||||
private:
|
||||
std::shared_ptr<AssetManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<AssetManagement::Interface::Ftc> m_ftc;
|
||||
|
||||
};
|
||||
|
||||
} // namespace AssetManagement
|
||||
@@ -0,0 +1,48 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
# Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
#
|
||||
|
||||
SET(asm_gui_SRCS
|
||||
asm_training_area_dialog.cpp
|
||||
asm_training_area_dialog.h
|
||||
asm_edit_training_area_dialog.cpp
|
||||
asm_edit_training_area_dialog.h
|
||||
asm_training_area_model.cpp
|
||||
asm_training_area_model.h
|
||||
asm_training_area_gui_plugin.cpp
|
||||
asm_training_area_gui_plugin.h
|
||||
)
|
||||
|
||||
NGL_WRAP_UI(asm_gui_SRCS
|
||||
asm_training_area_dialog.ui
|
||||
asm_edit_training_area_dialog.ui
|
||||
)
|
||||
|
||||
NGL_ADD_LIBRARY(WS AsmGuiPlugin MODULE ${asm_gui_SRCS})
|
||||
NGL_TARGET_LINK_LIBRARIES(AsmGuiPlugin
|
||||
ngltools # dtg
|
||||
NGLLogger
|
||||
LtsSession
|
||||
PdmDataPluginInterface
|
||||
AsmDataPluginInterface
|
||||
OpmDataPluginInterface
|
||||
AsmGuiPluginInterface
|
||||
FlmDataPluginInterface
|
||||
Qt5::Widgets
|
||||
LtsCoordTrans
|
||||
ltsCoordWidget
|
||||
LtsWidgets
|
||||
LtsDataView
|
||||
LtsUtilsGuiDds
|
||||
LtsUtilsSettings
|
||||
LtsSessionData
|
||||
ProjectConfig
|
||||
LtsUtilsGuiConnectDialog
|
||||
)
|
||||
|
||||
NGL_INSTALL_TARGET(AsmGuiPlugin)
|
||||
|
||||
|
||||
+383
@@ -0,0 +1,383 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* ExerciseManangement - Exercise Edit Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
*/
|
||||
|
||||
|
||||
#include "asm_edit_training_area_dialog.h"
|
||||
#include "ui_asm_edit_training_area_dialog.h"
|
||||
|
||||
#include <LtsWidgets/lts_message_dialog.h>
|
||||
#include <LtsUtilsCore/dds_vector.h>
|
||||
#include <LtsUtilsCore/dds_vector_to_pixmap.h>
|
||||
#include <LtsUtilsSettings/settings.h>
|
||||
#include <LtsSession/lts_session_data.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_stepWidth {5};
|
||||
static constexpr double s_minHeight {10};
|
||||
static constexpr double s_maxHeight {50000};
|
||||
//static constexpr double s_stepHeight {5};
|
||||
|
||||
using namespace CombatNetRadio;
|
||||
namespace AssetManagement
|
||||
{
|
||||
Core::GeoPosition2D convert(const QPointF &coord)
|
||||
{
|
||||
return Core::GeoPosition2D(coord.x(), coord.y()); // lon/lat
|
||||
}
|
||||
|
||||
QPointF convert(const Core::GeoPosition2D &geoPos)
|
||||
{
|
||||
return QPointF(geoPos.lon(), geoPos.lat());
|
||||
}
|
||||
|
||||
|
||||
// --------------------------------------------------------
|
||||
// AsmEditTrainingAreaDialog
|
||||
// --------------------------------------------------------
|
||||
AsmEditTrainingAreaDialog::AsmEditTrainingAreaDialog(QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel)
|
||||
, m_ui(new Ui::AsmEditTrainingAreaDialog)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_menuGroup()
|
||||
, m_logger(getLogger("AssetManangementEditDialog"))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
}
|
||||
|
||||
|
||||
AsmEditTrainingAreaDialog::~AsmEditTrainingAreaDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
|
||||
void AsmEditTrainingAreaDialog::retranslate()
|
||||
{
|
||||
translate(m_ui, m_dialogTitle);
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
// m_asmFtc->enableMapDescriptionModify(true);
|
||||
// m_asmFtc->enableMapDescriptionRemove(true);
|
||||
|
||||
if (!sitMapGuiIfc)
|
||||
{
|
||||
ERROR_LOG(m_logger) << LOGFUNCTION << " Invalid shared_ptr sitMapGuiIfc!";
|
||||
return false;
|
||||
}
|
||||
|
||||
m_trainingArea = AssetManagement::TrainingArea();
|
||||
AssetManagement::TrainingArea ta = AssetManagement::TrainingArea();
|
||||
if(trainingAreaId == 0)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION << " 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) << LOGFUNCTION << " training area not valid id: "<< trainingAreaId;
|
||||
return false;
|
||||
}
|
||||
|
||||
m_dialogTitle = tr("Edit Training Area: %1").arg(QString::fromStdString(ta.name()));
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION << " edit training area " <<trainingAreaId;
|
||||
}
|
||||
|
||||
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()));
|
||||
|
||||
connect(m_ui->pbClear, &QPushButton::clicked,
|
||||
m_ui->positionEdit, &LtsCoordWidget::LtsCoordWidget::clear);
|
||||
|
||||
onEditClicked();
|
||||
//setOnlineHelpFilename(QStringLiteral("Administrator-Edit_Exercise"));
|
||||
|
||||
setData();
|
||||
enaDisa();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief AsmEditTrainingAreaDialog::enaDisa
|
||||
*/
|
||||
void AsmEditTrainingAreaDialog::enaDisa()
|
||||
{
|
||||
m_ui->pbPosition->setEnabled(m_sitMapGuiIfc.get());
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief AsmEditTrainingAreaDialog::has2DMap
|
||||
* \return
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief AsmEditTrainingAreaDialog::getPosition
|
||||
*/
|
||||
void AsmEditTrainingAreaDialog::getPosition()
|
||||
{
|
||||
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) << LOGFUNCTION << " ModeMode == Undefined ";
|
||||
break;
|
||||
} // switch
|
||||
|
||||
}
|
||||
|
||||
void AsmEditTrainingAreaDialog::onRectData(const QPointF ¢erPoint, 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));
|
||||
|
||||
m_previewPolygon = coordinates;
|
||||
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;
|
||||
|
||||
showPreviewObject();
|
||||
}
|
||||
|
||||
void AsmEditTrainingAreaDialog::onCoordinate(const QPointF ¢erPoint)
|
||||
{
|
||||
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));
|
||||
|
||||
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));
|
||||
|
||||
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);
|
||||
|
||||
DEBUG_LOG(m_logger) << "Pos X: " << centerPoint.x() << " Y: " << centerPoint.y() << " W: " << width << " H: " << height;
|
||||
|
||||
showPreviewObject();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AsmEditTrainingAreaDialog::onEditClicked()
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " 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());
|
||||
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END Edit";
|
||||
|
||||
onSelectionChanged();
|
||||
|
||||
}
|
||||
|
||||
void AsmEditTrainingAreaDialog::onSelectionChanged()
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
QPointF AsmEditTrainingAreaDialog::getCentPos(TrainingArea ta)
|
||||
{
|
||||
// bottom left
|
||||
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) << LOGFUNCTION << " 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());
|
||||
|
||||
if(!m_asmFtc)
|
||||
{
|
||||
ERROR_LOG(m_logger) << LOGFUNCTION << " 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;
|
||||
|
||||
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);
|
||||
});
|
||||
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " 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());
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
//Core::GeoPosition2D point;
|
||||
|
||||
// bottom left
|
||||
LtsCoordTrans::UtmCoordinate utmCoordinate = LtsCoordTrans::UtmCoordinate::fromGeographic(ddsTrainingArea.bottomLeft().lon(), ddsTrainingArea.bottomLeft().lat());
|
||||
polygonF.push_back(QPointF((ddsTrainingArea.bottomLeft().lon()),(ddsTrainingArea.bottomLeft().lat())));
|
||||
|
||||
// bottom right
|
||||
polygonF.push_back(utmCoordinate.geographic(ddsTrainingArea.width()));
|
||||
|
||||
// upper right
|
||||
polygonF.push_back(utmCoordinate.geographic(ddsTrainingArea.width(), ddsTrainingArea.height()));
|
||||
|
||||
// upper left
|
||||
polygonF.push_back(utmCoordinate.geographic(0, ddsTrainingArea.height()));
|
||||
|
||||
return polygonF;
|
||||
}
|
||||
|
||||
|
||||
} // namespace ExerciseManagement
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* ExerciseManangement - Exercise Edit Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AssetManagement/asm_dtc.h>
|
||||
#include <AssetManagement/asm_ftc.h>
|
||||
#include <AssetManagement/logger.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsUtilsGuiDds/request_helper.h>
|
||||
#include <LtsSession/lts_session_data_dds.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
|
||||
{
|
||||
class AsmEditTrainingAreaDialog;
|
||||
}
|
||||
|
||||
namespace AssetManagement
|
||||
{
|
||||
|
||||
|
||||
// --------------------------------------------------------
|
||||
// AsmEditTrainingAreaDialog
|
||||
// --------------------------------------------------------
|
||||
class AsmEditTrainingAreaDialog final : public LtsWidgets::LtsDialog
|
||||
, protected Interface::Ftc::TrainingAreaModifyReplyHandler
|
||||
, protected Interface::Ftc::TrainingAreaRemoveReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AsmEditTrainingAreaDialog(QWidget *parent = nullptr);
|
||||
|
||||
bool init(LtsSession::LtsSessionDataDds *session,
|
||||
const int &trainingAreaId, const std::shared_ptr<SituationMap::ForeignGuiInterface> &sitMapGuiIfc,
|
||||
const QString &menuGroup);
|
||||
|
||||
~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:
|
||||
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); }
|
||||
|
||||
bool has2DMap();
|
||||
void enaDisa();
|
||||
void showPreviewObject();
|
||||
QPointF getCentPos(AssetManagement::TrainingArea ta);
|
||||
bool apply() override;
|
||||
void setData();
|
||||
QPolygonF getTrainingArea(const AssetManagement::TrainingArea &ta);
|
||||
|
||||
Ui::AsmEditTrainingAreaDialog *m_ui{nullptr};
|
||||
LtsSession::LtsSessionDataDds *m_session{nullptr};
|
||||
//int m_taId{-1}; /// current training Area id
|
||||
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;
|
||||
LOGGER_T m_logger;
|
||||
QString m_trainingAreaName{};
|
||||
AssetManagement::TrainingArea m_trainingArea;
|
||||
std::shared_ptr<SituationMap::ForeignGuiInterface> m_sitMapGuiIfc;
|
||||
QPolygonF m_previewPolygon;
|
||||
bool m_taExist{false};
|
||||
|
||||
};
|
||||
}
|
||||
+176
@@ -0,0 +1,176 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>AsmEditTrainingAreaDialog</class>
|
||||
<widget class="QWidget" name="AsmEditTrainingAreaDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>788</width>
|
||||
<height>479</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Translated in Source</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="name_Lbl">
|
||||
<property name="text">
|
||||
<string>Name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QLineEdit" name="name_lineEdit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QLabel" name="lblPosition">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Center Point:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QPushButton" name="pbPosition">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>57</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/style/position.svg</normaloff>:/style/position.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pbClear">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>57</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/style/remove.svg</normaloff>:/style/remove.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="LtsCoordWidget::LtsCoordWidget" name="positionEdit" native="true"/>
|
||||
</item>
|
||||
<item row="2" column="3" rowspan="2">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>456</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2">
|
||||
<widget class="QLabel" name="lblDimensions">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Dimensions [m]:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="LtsWidgets::LtsSpinBox" name="sbWidth">
|
||||
<property name="maximum">
|
||||
<number>999999999</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="LtsWidgets::LtsSpinBox" name="sbHeight">
|
||||
<property name="maximum">
|
||||
<number>999999999</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="4" column="1" colspan="2">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>248</width>
|
||||
<height>342</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LtsCoordWidget::LtsCoordWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>LtsCoordTrans/lts_coord_widget.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>LtsWidgets::LtsSpinBox</class>
|
||||
<extends>QSpinBox</extends>
|
||||
<header>LtsWidgets/lts_spinbox.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
+311
@@ -0,0 +1,311 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* ExerciseManangement - Exercise Overview Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
*/
|
||||
|
||||
|
||||
#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 <LtsSession/lts_session_data.h>
|
||||
#include <LtsUtilsSettings/settings.h>
|
||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||
#include <Proxies/CombatNetRadio/helper.h>
|
||||
#include <AssetManagement/asm_ftc_types.h>
|
||||
|
||||
using namespace CombatNetRadio;
|
||||
namespace AssetManagement
|
||||
{
|
||||
//---------------------------------
|
||||
// AsmTrainingAreaDialog
|
||||
//---------------------------------
|
||||
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_logger(getLogger("AsmTrainingAreaDialog"))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
setOnlineHelpFilename(QStringLiteral("Asset_Management-Training_Area"));
|
||||
|
||||
// m_buttonBox->connectButton(LtsWidgets::DialogButton::Add, this, &AsmTrainingAreaDialog::onAddTrainingArea);
|
||||
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();
|
||||
}
|
||||
|
||||
AsmTrainingAreaDialog::~AsmTrainingAreaDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void AsmTrainingAreaDialog::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("Training Area Overview"));
|
||||
}
|
||||
|
||||
void AsmTrainingAreaDialog::tableColumnOrganiserSetting()
|
||||
{
|
||||
//LtsColumnOrganiser
|
||||
m_ui->trainingAreaView->setColumnsOrganiserEnabled(identifier(), true);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief AsmTrainingAreaDialog::init
|
||||
* \param session
|
||||
* \return
|
||||
*/
|
||||
bool AsmTrainingAreaDialog::init(LtsSession::LtsSessionDataDds *session, const std::shared_ptr<SituationMap::ForeignGuiInterface> &sitMapGuiIfc)
|
||||
{
|
||||
m_session = session;
|
||||
|
||||
if (!m_session->getDtc<AssetManagement::DataInterface>(m_asmDtc)) // TODO: not obli
|
||||
{
|
||||
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);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
// show all areas at the beginning
|
||||
showAllTrainingAreas();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void AsmTrainingAreaDialog::enaDisa()
|
||||
{
|
||||
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) );
|
||||
}
|
||||
|
||||
void AsmTrainingAreaDialog::onAddTrainingArea()
|
||||
{
|
||||
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))
|
||||
{
|
||||
delete dialog;
|
||||
return;
|
||||
}
|
||||
connect(this, &AsmTrainingAreaDialog::destroyed, dialog, &QObject::deleteLater);
|
||||
addDialog(dialog, m_menuGroup, identifier, LtsWidgets::LayoutArea::eDialogTab);
|
||||
}
|
||||
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " adding temp training Area ";
|
||||
}
|
||||
|
||||
void AsmTrainingAreaDialog::onRemoveTrainingArea()
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " 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) << LOGFUNCTION << " 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) << LOGFUNCTION << " success = " << success;
|
||||
}
|
||||
else
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Warning"),
|
||||
tr("Cannot remove currently edited Training Area"));
|
||||
}
|
||||
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " 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;
|
||||
}
|
||||
|
||||
const QString identifier = QStringLiteral("AsmEditTrainingArea_%1").arg(taItem.id());
|
||||
if(focusDialog(m_menuGroup,identifier, LtsWidgets::LayoutArea::eDialogTab))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
AsmEditTrainingAreaDialog *dialog = new AsmEditTrainingAreaDialog(this);
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
void AsmTrainingAreaDialog::onSelectionChanged()
|
||||
{
|
||||
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();
|
||||
|
||||
}
|
||||
|
||||
void AsmTrainingAreaDialog::clearSelection()
|
||||
{
|
||||
m_ui->trainingAreaView->clearSelection();
|
||||
if(m_sitMapGuiIfc)
|
||||
{
|
||||
m_sitMapGuiIfc->removePreviewObject();
|
||||
}
|
||||
}
|
||||
|
||||
QPolygonF AsmTrainingAreaDialog::getTrainingArea(int trainingAreaId)
|
||||
{
|
||||
if(!m_asmDtc)
|
||||
{
|
||||
ERROR_LOG(m_logger) << LOGFUNCTION << " m_asmDtc is not valid!";
|
||||
return {};
|
||||
}
|
||||
const AssetManagement::TrainingArea &ddsTrainingArea = m_asmDtc->trainingArea(trainingAreaId);
|
||||
if (ddsTrainingArea.id() != trainingAreaId)
|
||||
{
|
||||
ERROR_LOG(m_logger) << LOGFUNCTION << " TrainingArea not found, trainingAreaId = " << trainingAreaId;
|
||||
return {};
|
||||
}
|
||||
|
||||
return getTrainingArea(ddsTrainingArea);
|
||||
}
|
||||
|
||||
QPolygonF AsmTrainingAreaDialog::getTrainingArea(const TrainingArea &ddsTrainingArea)
|
||||
{
|
||||
QPolygonF polygonF;
|
||||
|
||||
// bottom left
|
||||
LtsCoordTrans::UtmCoordinate utmCoordinate = LtsCoordTrans::UtmCoordinate::fromGeographic(ddsTrainingArea.bottomLeft().lon(), ddsTrainingArea.bottomLeft().lat());
|
||||
polygonF.push_back(QPointF((ddsTrainingArea.bottomLeft().lon()),(ddsTrainingArea.bottomLeft().lat())));
|
||||
|
||||
// bottom right
|
||||
polygonF.push_back(utmCoordinate.geographic(ddsTrainingArea.width()));
|
||||
|
||||
// upper right
|
||||
polygonF.push_back(utmCoordinate.geographic(ddsTrainingArea.width(), ddsTrainingArea.height()));
|
||||
|
||||
// upper left
|
||||
polygonF.push_back(utmCoordinate.geographic(0, ddsTrainingArea.height()));
|
||||
|
||||
return polygonF;
|
||||
}
|
||||
|
||||
|
||||
void AsmTrainingAreaDialog::showAllTrainingAreas()
|
||||
{
|
||||
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);
|
||||
} // for
|
||||
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);
|
||||
}
|
||||
|
||||
} // namespace AssetManagement
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* ExerciseManangement - Exercise Overview Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsUtilsGuiDds/request_helper.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"
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class AsmTrainingAreaDialog;
|
||||
}
|
||||
namespace LtsUtils
|
||||
{
|
||||
class RequestHelper;
|
||||
}
|
||||
namespace AssetManagement
|
||||
{
|
||||
// --------------------------------------------------------
|
||||
// AsmTrainingAreaDialog
|
||||
// --------------------------------------------------------
|
||||
class AsmTrainingAreaDialog : public LtsWidgets::LtsDialog
|
||||
, protected Interface::Ftc::TrainingAreaModifyReplyHandler
|
||||
, protected Interface::Ftc::TrainingAreaRemoveReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
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();
|
||||
|
||||
private slots:
|
||||
void enaDisa();
|
||||
void onAddTrainingArea();
|
||||
void onEditTrainingArea();
|
||||
void onRemoveTrainingArea();
|
||||
void onSelectionChanged();
|
||||
|
||||
private:
|
||||
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;
|
||||
|
||||
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;
|
||||
LOGGER_T m_logger;
|
||||
QPolygonF m_previewPolygon;
|
||||
std::shared_ptr<SituationMap::ForeignGuiInterface> m_sitMapGuiIfc;
|
||||
QSet<int> m_viewedTaIds{};
|
||||
|
||||
};
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>AsmTrainingAreaDialog</class>
|
||||
<widget class="QWidget" name="AsmTrainingAreaDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>712</width>
|
||||
<height>410</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="LtsDataView::LtsDataView" name="trainingAreaView" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>50</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LtsDataView::LtsDataView</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>LtsDataView/lts_data_view.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* GUI Plugin for ExerciseManangement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
*/
|
||||
|
||||
#include "asm_training_area_gui_plugin.h"
|
||||
#include "asm_training_area_dialog.h"
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <AssetManagement/asm_operator_rights.h>
|
||||
|
||||
|
||||
namespace AssetManagement
|
||||
{
|
||||
|
||||
std::shared_ptr<GuiPluginBase::Interface> GuiPlugin::createGuiInterface(LtsSession::LtsSession *session)
|
||||
{
|
||||
return std::make_shared<InterfaceImpl>(session);
|
||||
}
|
||||
|
||||
|
||||
InterfaceImpl::InterfaceImpl(LtsSession::LtsSession *session)
|
||||
: GuiPluginBase::Interface(session, getLogger("Plugins.Gui.Asm"))
|
||||
, m_sitmapGuiIfc(nullptr)
|
||||
{}
|
||||
|
||||
|
||||
QVector<LtsWidgets::PluginData> InterfaceImpl::getActions()
|
||||
{
|
||||
QVector<LtsWidgets::PluginData> ret;
|
||||
|
||||
LtsWidgets::PluginData plData;
|
||||
plData.menuGroup = menuGroup();
|
||||
plData.menuText = tr("Edit Training Areas");
|
||||
plData.menuIcon = QIcon(QLatin1String("icon:draw_symbol.svg"));
|
||||
plData.identifier = QLatin1String("asmTrainingAreas");
|
||||
//plData.operatorRight = OperatorRights::Groups_AssetManagement;
|
||||
plData.exercisePart = LtsWidgets::ExercisePart::ePlanning;
|
||||
plData.createWidgetFunc = [this](QWidget *parent)
|
||||
{
|
||||
return onShowAssetManagementTrainingAreaEdit(parent);
|
||||
};
|
||||
ret.append(plData);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
bool InterfaceImpl::fetchInterfaces()
|
||||
{
|
||||
if (!m_session->getForeignGuiInterface<SituationMap::ForeignGuiInterface>(m_sitmapGuiIfc))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void InterfaceImpl::clearInterfaces()
|
||||
{
|
||||
// m_dtc = nullptr;
|
||||
m_sitmapGuiIfc = nullptr;
|
||||
}
|
||||
|
||||
LtsWidgets::LtsDialog *InterfaceImpl::onShowAssetManagementTrainingAreaEdit(QWidget *parent)
|
||||
{
|
||||
return LtsWidgets::initDialog(new AssetManagement::AsmTrainingAreaDialog(menuGroup(), parent),m_session, m_sitmapGuiIfc);
|
||||
}
|
||||
|
||||
} // namespace AssetManagement
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Gui Plugin for ExerciseManangement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AssetManagement/logger.h>
|
||||
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <Common/ProjectConfig/project_defines.h>
|
||||
#include <Plugins/AssetManagement/asm_data_plugin_interface.h>
|
||||
//#include <Plugins/AssetManagement/asm_gui_plugin_interface.h>
|
||||
#include <Plugins/SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
|
||||
|
||||
namespace AssetManagement
|
||||
{
|
||||
|
||||
class GuiPlugin final : public QObject, public GuiPluginBase::Plugin
|
||||
{
|
||||
Q_PLUGIN_METADATA(IID "gui:3:asm")
|
||||
Q_INTERFACES(GuiPluginBase::Plugin)
|
||||
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit GuiPlugin() = default;
|
||||
~GuiPlugin() = default;
|
||||
|
||||
QString pluginName() override { return QLatin1String("AssetManagementGuiPlugin"); }
|
||||
std::shared_ptr<GuiPluginBase::Interface> createGuiInterface(LtsSession::LtsSession *session) override;
|
||||
bool availableInPartition(IDL::PartitionType partition) const override
|
||||
{
|
||||
return partition == IDL::PartitionType::Global;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class InterfaceImpl final : public QObject, public GuiPluginBase::Interface
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit InterfaceImpl(LtsSession::LtsSession *session);
|
||||
|
||||
QVector<LtsWidgets::PluginData> getActions() override;
|
||||
QString menuGroup() const override { return tr("Exercises"); }
|
||||
bool fetchInterfaces() override;
|
||||
void clearInterfaces() override;
|
||||
bool availableInPartition(IDL::PartitionType partition) const override
|
||||
{
|
||||
return partition == IDL::PartitionType::Global;
|
||||
}
|
||||
|
||||
private:
|
||||
LtsWidgets::LtsDialog *onShowAssetManagementTrainingAreaEdit(QWidget *parent);
|
||||
std::shared_ptr<SituationMap::ForeignGuiInterface> m_sitmapGuiIfc;
|
||||
|
||||
// std::shared_ptr<AssetManagement::Interface::Dtc> m_dtc;
|
||||
};
|
||||
|
||||
} // namespace AssetManagement
|
||||
+76
@@ -0,0 +1,76 @@
|
||||
#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")},
|
||||
//tr("image")},
|
||||
parent)
|
||||
,m_asmDtc(nullptr)
|
||||
,m_logger(getLogger("AsmTrainingAreaDialogModel"))
|
||||
{}
|
||||
|
||||
AsmTrainingAreaDialogModel::~AsmTrainingAreaDialogModel()
|
||||
{}
|
||||
|
||||
bool AsmTrainingAreaDialogModel::initModel(const std::shared_ptr<Interface::Dtc> &dtc, bool hideRemoved)
|
||||
{
|
||||
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) << LOGFUNCTION << " no m_asmDtc";
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QVariant AsmTrainingAreaDialogModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!indexIsValid(index)) //role != Qt::DisplayRole ||
|
||||
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();
|
||||
// case Image:
|
||||
// return asmTrainingArea.image();
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
#include <AssetManagement/asm_dtc.h>
|
||||
#include <AssetManagement/logger.h>
|
||||
|
||||
|
||||
namespace AssetManagement
|
||||
{
|
||||
|
||||
class AsmTrainingAreaDialogModel
|
||||
: public LtsWidgets::LtsAbstractTableModel<AssetManagement::TrainingArea>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
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);
|
||||
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override final;
|
||||
|
||||
|
||||
private:
|
||||
bool m_hideRemoved;
|
||||
std::shared_ptr<Interface::Dtc> m_asmDtc;
|
||||
LOGGER_T m_logger;
|
||||
};
|
||||
|
||||
}// namespace AssetManagement
|
||||
|
||||
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
# Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
#
|
||||
ADD_SUBDIRECTORY(AsmTrainingAreaEdit)
|
||||
|
||||
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Data Plugin Interface for AssetManagement (Interface for access from other Plugins)
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AssetManagement/asm_dtc.h>
|
||||
#include <AssetManagement/asm_ftc.h>
|
||||
#include <PluginInterfaces/data_plugin_interface.h>
|
||||
|
||||
namespace AssetManagement
|
||||
{
|
||||
/**
|
||||
* @brief The DataInterface class provides the Topics Clients only for the GUI Plugins
|
||||
*/
|
||||
class DataInterface : public DataPluginBase::Interface
|
||||
{
|
||||
public:
|
||||
using DataPluginBase::Interface::Interface;
|
||||
|
||||
virtual std::shared_ptr<AssetManagement::Interface::Dtc> getDtc() = 0;
|
||||
virtual std::shared_ptr<AssetManagement::Interface::Ftc> getFtc() = 0;
|
||||
};
|
||||
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Data Plugin Interface for AssetManagement (Interface for access from other Plugins)
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AssetManagement/asm_dtc.h>
|
||||
#include <AssetManagement/asm_ftc.h>
|
||||
#include <PluginInterfaces/data_plugin_interface.h>
|
||||
#include <AssetManagement/Gui/AsmTrainingAreaEdit/asm_training_area_dialog.h>
|
||||
|
||||
namespace AssetManagement
|
||||
{
|
||||
/**
|
||||
* @brief The DataInterface class provides the Topics Clients only for the GUI Plugins
|
||||
*/
|
||||
class ForeignAsmManagementGui
|
||||
{
|
||||
public:
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user