207 lines
7.8 KiB
C++
Executable File
207 lines
7.8 KiB
C++
Executable File
/**
|
|
* @RDE_HEADER@
|
|
* GUI Plugin for ParticipantsMoveDialog
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
* Created by Gerlinde Rudolphus, SLSE, 2018-01-02
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
//Lts
|
|
#include <LtsWidgets/lts_dialog.h>
|
|
#include <LtsWidgets/lts_frameless_dialog.h>
|
|
#include <LtsSession/lts_session.h>
|
|
#include "participant_move_dialog.h"
|
|
#include <Plugins/SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
|
|
|
#include "participants_move_model.h"
|
|
|
|
//DDS
|
|
#include <PluginInterfaces/gui_plugin_interface.h>
|
|
#include <ParticipantManagement/ppm_dtc.h>
|
|
#include <ParticipantManagement/ppm_ftc.h>
|
|
#include <CentralEffectSimulation/ces_dtc.h>
|
|
#include <AreaEffectSimulation/aes_dtc.h>
|
|
#include <AssetManagement/asm_ftc.h>
|
|
#include <Plugins/ParticipantManagement/ppm_gui_combobox_plugin_interface.h>
|
|
#include <Plugins/CentralEffectSimulation/ces_gui_plugin_interface.h>
|
|
#include <Plugins/ParticipantManagement/ppm_participants_gui_plugin_interface.h>
|
|
|
|
#include "logger.h"
|
|
//Qt
|
|
|
|
#include <QJsonDocument>
|
|
#include <QJsonObject>
|
|
#include <QVariantMap>
|
|
|
|
namespace Ui
|
|
{
|
|
class ParticipantMoveDialog;
|
|
}
|
|
|
|
|
|
namespace CentralEffectSimulation
|
|
{
|
|
// --------------------------------------------------------
|
|
// ParticipantMoveDialog
|
|
// --------------------------------------------------------
|
|
class ParticipantsMoveDialog : public LtsWidgets::LtsDialog
|
|
, protected CentralEffectSimulation::Interface::Ftc::SimulatedMovementRemoveByParticipantIdReplyHandler
|
|
, protected ParticipantManagement::Interface::Ftc::SetSimulatedPositionReplyHandler
|
|
, protected ParticipantManagement::Interface::Ftc::SetSimulatedPositionRelativeReplyHandler
|
|
, protected ParticipantManagement::Interface::Ftc::SetSimulatedParticipantFormationReplyHandler
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit ParticipantsMoveDialog(const QString &menuGroup, QWidget *parent = nullptr);
|
|
~ParticipantsMoveDialog();
|
|
|
|
bool init(LtsSession::LtsSession *session,
|
|
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
|
const std::shared_ptr<CentralEffectSimulation::Interface::Dtc> &cesDtc,
|
|
const std::shared_ptr<ParticipantManagement::Interface::Ftc> &ppmFtc);
|
|
|
|
void onSimulatedMovementRemoveByParticipantIdReply(const Core::FunctionReplyObject &replyObject) override;
|
|
void onSetSimulatedPositionReply(const Core::FunctionReplyObject &replyObject) override;
|
|
void onSetSimulatedPositionRelativeReply(const Core::FunctionReplyObject &replyObject) override;
|
|
void onSetSimulatedParticipantFormationReply(const Core::FunctionReplyObject &replyObject) override;
|
|
|
|
enum class FormationGeometrieType : int
|
|
{
|
|
AimPoint,
|
|
Radial,
|
|
Area,
|
|
Line,
|
|
Point
|
|
};
|
|
|
|
public slots:
|
|
void onGetCoordinate(QPointF coordinate);
|
|
|
|
private:
|
|
bool getUnitPosition(int32_t participantId, Core::GeoPosition &unitPositionOut);
|
|
void doSetSimulatedPositionRequest(const ParticipantManagement::ParticipantData &participantData, const QPointF &coordinate);
|
|
void doSetSimulatedPositionRelativeRequest(const ParticipantManagement::ParticipantData &participantData, const QPointF &coordinate);
|
|
void doSetSimulatedParticipantFormationRequest(const ParticipantManagement::ParticipantData &participantData, const QPointF &coordinate, const QString &formationData);
|
|
private slots:
|
|
void closeDialogReceived(int32_t participantId);
|
|
void onModelChanged();
|
|
|
|
private:
|
|
void retranslate() override;
|
|
void onClicked();
|
|
void onRemove();
|
|
void onSetSimulatedMGRSPosition();
|
|
bool participantInUse4ExplosionCluster(const QModelIndex &participantIndex);
|
|
void changeParty();
|
|
void onSelectionChanged();
|
|
void onDoubleClicked();
|
|
void onSetPosition();
|
|
void setDialogEnable(bool enable);
|
|
bool isParticipantInUseForExplosionCluster(int id);
|
|
void tableColumnOrganiserSetting() override;
|
|
|
|
struct ParticipantTypePropertyStruct
|
|
{
|
|
QString m_propertiesStr;
|
|
bool isArtillery = false;
|
|
QString geometry = QStringLiteral("line");
|
|
double distance = -1;
|
|
double angle = -1;
|
|
QVariantMap distanceSets;
|
|
QJsonObject distanceSetsObj;
|
|
|
|
ParticipantTypePropertyStruct() {}
|
|
explicit ParticipantTypePropertyStruct(const QString &properties) : m_propertiesStr(properties)
|
|
{
|
|
setFormation(properties);
|
|
}
|
|
void setDefaultValue()
|
|
{
|
|
isArtillery = false;
|
|
geometry = QStringLiteral("line");
|
|
distance = -1;
|
|
angle = -1;
|
|
distanceSets.clear();
|
|
}
|
|
|
|
void setFormation(const QString &jsData)
|
|
{
|
|
setDefaultValue();
|
|
const QJsonObject typObj = QJsonDocument::fromJson(QByteArray::fromStdString(jsData.toStdString())).object();
|
|
if (typObj.isEmpty())
|
|
return;
|
|
isArtillery = typObj[isArtilleryStr].toBool(false);
|
|
// Formation data Object
|
|
const QJsonObject &formationObj = typObj[formationStr].toObject();
|
|
if (formationObj.isEmpty())
|
|
{
|
|
setDefaultValue();
|
|
return;
|
|
}
|
|
geometry = formationObj[geometryStr].toString(QStringLiteral("line"));
|
|
angle = formationObj[angleStr].toDouble(-1);
|
|
distance = formationObj[distanceStr].toDouble(-1);
|
|
distanceSetsObj = formationObj[distanceSetsStr].toObject();
|
|
distanceSets = distanceSetsObj.toVariantMap();
|
|
}
|
|
|
|
bool hasFormationData() const
|
|
{
|
|
if (isArtillery == false)
|
|
return true; // no need to continue artillery must be set for formation data to be changed
|
|
else
|
|
return (angle != -1) && (distance != -1);
|
|
}
|
|
QString getFormationDataObjectString() const
|
|
{
|
|
QJsonObject obj {{geometryStr, geometry},
|
|
{angleStr, angle},
|
|
{distanceStr, distance},
|
|
{distanceSetsStr, distanceSetsObj} // doesnt change. use in combobox for selection. selection used by distance
|
|
};
|
|
return QString::fromStdString(QJsonDocument(obj).toJson(QJsonDocument::Compact).toStdString());
|
|
}
|
|
|
|
const QString isArtilleryStr = QStringLiteral("isArtillery");
|
|
const QString formationStr = QStringLiteral("formation");
|
|
const QString geometryStr = QStringLiteral("geometry");
|
|
const QString angleStr = QStringLiteral("angle");
|
|
const QString distanceStr = QStringLiteral("distance");
|
|
const QString distanceSetsStr = QStringLiteral("distanceSets");
|
|
};
|
|
|
|
void setFormationAndPositioningUi(const ParticipantManagement::ParticipantData &participantData, QPointF &mgrsCoordinate, const bool &unitWithFormation);
|
|
|
|
bool removeFtc(int32_t participantId);
|
|
ParticipantManagement::ParticipantData participantFromIndex(const QModelIndex &idx) const;
|
|
|
|
private:
|
|
|
|
ParticipantMoveModel *m_participantModel{nullptr};
|
|
|
|
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
|
std::shared_ptr<ParticipantManagement::Interface::Ftc> m_ppmFtc;
|
|
std::shared_ptr<AreaEffectSimulation::Interface::Dtc> m_aesDtc;
|
|
|
|
std::shared_ptr<CentralEffectSimulation::Interface::Dtc> m_cesDtc;
|
|
std::shared_ptr<ParticipantManagement::ForeignGuiComboboxInterface> m_ppmCbxIfc;
|
|
std::shared_ptr<Interface::Ftc> m_ftc;
|
|
|
|
Ui::ParticipantMoveDialog *m_ui{nullptr};
|
|
LtsSession::LtsSession *m_session{nullptr};
|
|
QString m_menuGroup;
|
|
QMap<int, ParticipantMoveDialog *> m_participantDialogMap;
|
|
LtsUtils::RequestHelper *m_requestHelper{nullptr};
|
|
std::shared_ptr<SituationMap::ForeignGuiInterface> m_sitMapGuiIfc;
|
|
bool m_shiftModifierWhileOnSetPosition{false};
|
|
bool m_mgrsPosEditCoordinateActive{false};
|
|
LOGGER_T m_logger;
|
|
QRectF m_trainingAreaRect;
|
|
ParticipantTypePropertyStruct m_formationProps;
|
|
};
|
|
} // namespace CentralEffectSimulation
|