386 lines
16 KiB
C++
Executable File
386 lines
16 KiB
C++
Executable File
/**
|
|
* @RDE_HEADER@
|
|
* GUI Plugin for AreaEffectSimulation - Explosions
|
|
* $Id: aes_explosion_gui_plugin.cpp 64799 2025-04-02 12:19:43Z kemayou_s $
|
|
* $HeadURL: svn://slssvn/TDS/branches/product/features/24_adler/Lts/Plugins/AreaEffectSimulation/Gui/Explosion/aes_explosion_gui_plugin.cpp $
|
|
* $Author: kemayou_s $
|
|
* Created by Patric Karwat, SLSE, 2016-07-05
|
|
*/
|
|
|
|
#include "aes_explosion_gui_plugin.h"
|
|
#include "aes_explosion_edit.h"
|
|
#include "aes_explosion_list.h"
|
|
#include "aes_explosions_edit.h"
|
|
#include "aes_explosions_edit_adler.h"
|
|
#include "aes_explosions_edit_adler_standalone.h"
|
|
#include <QApplication>
|
|
#include <AreaEffectSimulation/aes_operator_rights.h>
|
|
#include <LtsSession/lts_session.h>
|
|
#include <LtsUtilsSettings/settings.h>
|
|
#include <LtsWidgets/lts_base_layout_widget.h>
|
|
#include <LtsWidgets/lts_events.h>
|
|
#include <ProjectDataManagement/pdm_enums.hpp>
|
|
|
|
namespace AreaEffectSimulation
|
|
{
|
|
const QString InterfaceImpl::s_ExplosionGuiScheme = QStringLiteral("ExplosionGui");
|
|
|
|
std::shared_ptr<GuiPluginBase::Interface> GuiPlugin::createGuiInterface(LtsSession::LtsSession *session) { return std::make_shared<InterfaceImpl>(session); }
|
|
|
|
InterfaceImpl::InterfaceImpl(LtsSession::LtsSession *session)
|
|
: AesBaseInterface(session, getLogger("Plugins.Gui.Explosion"))
|
|
, ForeignGuiInterface()
|
|
{
|
|
qApp->installEventFilter(this); // for link events
|
|
}
|
|
|
|
QVector<LtsWidgets::PluginData> InterfaceImpl::getActions()
|
|
{
|
|
QVector<LtsWidgets::PluginData> ret;
|
|
|
|
LtsUtils::ProjectSettings *ps = LtsUtils::ProjectSettings::getInstance();
|
|
const bool enableSingleExplosionArtillery = ps->value(QStringLiteral("aes"), QStringLiteral("enableSingleExplosionArtillery")).toBool();
|
|
|
|
const bool enableCentralExplosionArtillery = ps->value(QStringLiteral("aes"), QStringLiteral("enableCentralExplosionArtillery")).toBool();
|
|
|
|
if (enableSingleExplosionArtillery)
|
|
{
|
|
// Single Explosion Artillery
|
|
ret.append(LtsWidgets::PluginData(
|
|
menuGroup(),
|
|
tr("Single Artillery"),
|
|
QLatin1String("ShowExplosionSingleArtillery"),
|
|
QIcon(QLatin1String("icon:arti_ammunition_firings_single.svg")),
|
|
[this](QWidget *parent) { return onShowExplosionListDialog(true, false, ProjectDataManagement::GearClass::Artillery, parent); },
|
|
OperatorRights::SingleExplosionsShowArtillery,
|
|
LtsWidgets::ExercisePart::eExecution));
|
|
|
|
if (m_session->isExercisePartition() && appId() != LtsAppDescriptor::App::OC)
|
|
ret.append(LtsWidgets::PluginData(
|
|
menuGroup(),
|
|
tr("Add Single Artillery"),
|
|
QLatin1String("AddExplosionSingleArtillery"),
|
|
QIcon(QLatin1String("icon:arti_ammunition_firings_single_add.svg")),
|
|
[this](QWidget *parent) { return onShowAddExplosionDialog(true, false, ProjectDataManagement::GearClass::Artillery, parent); },
|
|
OperatorRights::SingleExplosionsShowArtillery,
|
|
LtsWidgets::ExercisePart::eExecution,
|
|
LtsWidgets::ExerciseState::eCreated | LtsWidgets::ExerciseState::eStarted | LtsWidgets::ExerciseState::ePaused));
|
|
|
|
// Single Explosion Central Artillery
|
|
if (enableCentralExplosionArtillery)
|
|
{
|
|
ret.append(LtsWidgets::PluginData(
|
|
menuGroup(),
|
|
tr("Single Artillery Central"),
|
|
QLatin1String("ShowExplosionSingleCentralArtillery"),
|
|
QIcon(QLatin1String("icon:arti_ammunition_firings_single.svg")),
|
|
[this](QWidget *parent) { return onShowExplosionListDialog(true, true, ProjectDataManagement::GearClass::Artillery, parent); },
|
|
// OperatorRights::SingleExplosionsCentralShowArtillery,
|
|
OperatorRights::SingleExplosionsShowArtillery,
|
|
LtsWidgets::ExercisePart::eExecution));
|
|
|
|
if (m_session->isExercisePartition() && appId() != LtsAppDescriptor::App::OC)
|
|
ret.append(LtsWidgets::PluginData(
|
|
menuGroup(),
|
|
tr("Add Single Artillery Central"),
|
|
QLatin1String("AddExplosionSingleCentralArtillery"),
|
|
QIcon(QLatin1String("icon:arti_ammunition_firings_single_add.svg")),
|
|
[this](QWidget *parent) { return onShowAddExplosionDialog(true, true, ProjectDataManagement::GearClass::Artillery, parent); },
|
|
// OperatorRights::SingleExplosionsCentralShowArtillery,
|
|
OperatorRights::SingleExplosionsShowArtillery,
|
|
LtsWidgets::ExercisePart::eExecution,
|
|
LtsWidgets::ExerciseState::eCreated | LtsWidgets::ExerciseState::eStarted | LtsWidgets::ExerciseState::ePaused));
|
|
}
|
|
}
|
|
|
|
const bool enableSingleExplosionMortar = ps->value(QStringLiteral("aes"), QStringLiteral("enableSingleExplosionMortar")).toBool();
|
|
|
|
if (enableSingleExplosionMortar)
|
|
{
|
|
// Single Explosion Mortar
|
|
ret.append(LtsWidgets::PluginData(
|
|
menuGroup(),
|
|
tr("Single Mortar"),
|
|
QLatin1String("ShowExplosionSingleMortar"),
|
|
QIcon(QLatin1String("icon:mortar_ammunition_firings.svg")),
|
|
[this](QWidget *parent) { return onShowExplosionListDialog(true, false, ProjectDataManagement::GearClass::Mortar, parent); },
|
|
OperatorRights::SingleExplosionsShowMortar,
|
|
LtsWidgets::ExercisePart::eExecution));
|
|
|
|
if (m_session->isExercisePartition() && appId() != LtsAppDescriptor::App::OC)
|
|
ret.append(LtsWidgets::PluginData(
|
|
menuGroup(),
|
|
tr("Add Single Mortar"),
|
|
QLatin1String("AddExplosionSingleMortar"),
|
|
QIcon(QLatin1String("icon:add_mortar_ammunition_firings_single.svg")),
|
|
[this](QWidget *parent) { return onShowAddExplosionDialog(true, false, ProjectDataManagement::GearClass::Mortar, parent); },
|
|
OperatorRights::SingleExplosionsEditMortar,
|
|
LtsWidgets::ExercisePart::eExecution,
|
|
LtsWidgets::ExerciseState::eCreated | LtsWidgets::ExerciseState::eStarted | LtsWidgets::ExerciseState::ePaused));
|
|
}
|
|
|
|
// Air Support single fire (for GUEZ Nasat)
|
|
if (m_logger.isDebugEnabled())
|
|
{
|
|
ret.append(LtsWidgets::PluginData(
|
|
menuGroup(),
|
|
tr("Single NASAT Impacts"),
|
|
QLatin1String("ShowExplosionSingleAerial"),
|
|
QIcon(QLatin1String("icon:mortar_ammunition_firings.svg")),
|
|
[this](QWidget *parent) { return onShowExplosionListDialog(true, false, ProjectDataManagement::GearClass::AirSupport, parent); },
|
|
OperatorRights::AirSupportShow,
|
|
LtsWidgets::ExercisePart::eExecution));
|
|
}
|
|
|
|
const bool enableAreaExplosionArtillery = ps->value(QStringLiteral("aes"), QStringLiteral("enableAreaExplosionArtillery")).toBool();
|
|
|
|
if (enableAreaExplosionArtillery)
|
|
{
|
|
// Area Explosion Artillery
|
|
ret.append(LtsWidgets::PluginData(
|
|
menuGroup(),
|
|
tr("Area Artillery"),
|
|
QLatin1String("ShowExplosionAreaArtillery"),
|
|
QIcon(QLatin1String("icon:arti_ammunition_firings.svg")),
|
|
[this](QWidget *parent) { return onShowExplosionListDialog(false, false, ProjectDataManagement::GearClass::Artillery, parent); },
|
|
OperatorRights::AreaExplosionsShowArtillery,
|
|
LtsWidgets::ExercisePart::eExecution));
|
|
|
|
if (m_session->isExercisePartition() && appId() != LtsAppDescriptor::App::OC)
|
|
ret.append(LtsWidgets::PluginData(
|
|
menuGroup(),
|
|
tr("Add Area Artillery"),
|
|
QLatin1String("AddExplosionAreaArtillery"),
|
|
QIcon(QLatin1String("icon:arti_ammunition_firings_add.svg")),
|
|
[this](QWidget *parent) { return onShowAddExplosionDialog(false, false, ProjectDataManagement::GearClass::Artillery, parent); },
|
|
OperatorRights::AreaExplosionsEditArtillery,
|
|
LtsWidgets::ExercisePart::eExecution,
|
|
LtsWidgets::ExerciseState::eCreated | LtsWidgets::ExerciseState::eStarted | LtsWidgets::ExerciseState::ePaused));
|
|
}
|
|
|
|
const bool enableAreaExplosionMortar = ps->value(QStringLiteral("aes"), QStringLiteral("enableAreaExplosionMortar")).toBool();
|
|
|
|
if (enableAreaExplosionMortar)
|
|
{
|
|
ret.append(LtsWidgets::PluginData(
|
|
menuGroup(),
|
|
tr("Area Mortar"),
|
|
QLatin1String("ShowExplosionAreaMortar"),
|
|
QIcon(QLatin1String("icon:mortar_ammunition_firings.svg")),
|
|
[this](QWidget *parent) { return onShowExplosionListDialog(false, false, ProjectDataManagement::GearClass::Mortar, parent); },
|
|
OperatorRights::AreaExplosionsShowMortar,
|
|
LtsWidgets::ExercisePart::eExecution));
|
|
|
|
if (m_session->isExercisePartition() && appId() != LtsAppDescriptor::App::OC)
|
|
ret.append(LtsWidgets::PluginData(
|
|
menuGroup(),
|
|
tr("Add Area Mortar"),
|
|
QLatin1String("AddExplosionAreaMortar"),
|
|
QIcon(QLatin1String("icon:add_mortar_ammunition_firings.svg")),
|
|
[this](QWidget *parent) { return onShowAddExplosionDialog(false, false, ProjectDataManagement::GearClass::Mortar, parent); },
|
|
OperatorRights::AreaExplosionsEditMortar,
|
|
LtsWidgets::ExercisePart::eExecution,
|
|
LtsWidgets::ExerciseState::eCreated | LtsWidgets::ExerciseState::eStarted | LtsWidgets::ExerciseState::ePaused));
|
|
}
|
|
|
|
const bool enableExplosionCluster = ps->value(QStringLiteral("aes"), QStringLiteral("enableExplosionCluster")).toBool();
|
|
if (enableExplosionCluster)
|
|
{
|
|
DEBUG_LOG(m_logger) << "ShowExplosionClusterArtillery";
|
|
// Explosions / ExplosionCluster
|
|
// ListView:
|
|
ret.append(LtsWidgets::PluginData(
|
|
menuGroup(),
|
|
tr("Artillery"),
|
|
QStringLiteral("ShowExplosionClusterArtillery"),
|
|
QIcon(QStringLiteral("icon:mortar_ammunition_firings.svg")),
|
|
[this](QWidget *parent) { return onShowExplosionClusterListDialog(parent); },
|
|
OperatorRights::ExplosionShowCluster,
|
|
LtsWidgets::ExercisePart::eExecution));
|
|
|
|
if (m_session->isExercisePartition() && appId() != LtsAppDescriptor::App::OC)
|
|
{
|
|
DEBUG_LOG(m_logger) << "onShowAddExplosionClusterDialog";
|
|
ret.append(LtsWidgets::PluginData(
|
|
menuGroup(),
|
|
tr("Add Artillery"),
|
|
QStringLiteral("AddExplosionClusterArtillery"),
|
|
QIcon(QStringLiteral("icon:arti_ammunition_firings_add.svg")),
|
|
[this](QWidget *parent) { return onShowAddExplosionClusterDialog(parent); },
|
|
OperatorRights::ExplosionEditCluster,
|
|
LtsWidgets::ExercisePart::eExecution,
|
|
LtsWidgets::ExerciseState::eCreated | LtsWidgets::ExerciseState::eStarted | LtsWidgets::ExerciseState::ePaused));
|
|
DEBUG_LOG(m_logger) << "onShowAddExplosionAdlerDialog";
|
|
ret.append(LtsWidgets::PluginData(
|
|
menuGroup(),
|
|
tr("Add ADLER Artillery"),
|
|
QStringLiteral("AddAdlerArtillery"),
|
|
QIcon(QStringLiteral("icon:arti_ammunition_firings_add.svg")),
|
|
[this](QWidget *parent) { return onShowAddExplosionAdlerStandAloneDialog(parent); },
|
|
OperatorRights::AdlerExplosionClusterEdit,
|
|
LtsWidgets::ExercisePart::eExecution,
|
|
LtsWidgets::ExerciseState::eCreated | LtsWidgets::ExerciseState::eStarted | LtsWidgets::ExerciseState::ePaused));
|
|
}
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
AreaEffectSimulation::BaseEdit *InterfaceImpl::showEditWindow(int aesEntityId, bool isSingle, bool isCentral, ProjectDataManagement::GearClass gc, QWidget *parent)
|
|
{
|
|
ExplosionEdit *editWidget
|
|
= new ExplosionEdit(menuGroup(), isSingle ? (isCentral ? ExplosionEdit::etSingleCentral : ExplosionEdit::etSingle) : ExplosionEdit::etArea, gc, parent);
|
|
if (editWidget->init(aesEntityId, false, m_session))
|
|
return editWidget;
|
|
|
|
delete editWidget;
|
|
return nullptr;
|
|
}
|
|
|
|
BaseEdit *InterfaceImpl::showEditWindow(int aesEntityId, ProjectDataManagement::EffectSource effectSource, QWidget *parent)
|
|
{
|
|
switch (effectSource.underlying())
|
|
{
|
|
case ProjectDataManagement::EffectSource::ES_ADLER_STANDALONE:
|
|
{
|
|
ExplosionsEditAdlerStandAlone *editWidget = new ExplosionsEditAdlerStandAlone(menuGroup(), parent);
|
|
if (editWidget->init(aesEntityId, false, m_session))
|
|
return editWidget;
|
|
|
|
delete editWidget;
|
|
return nullptr;
|
|
break;
|
|
}
|
|
case ProjectDataManagement::EffectSource::ES_ADLER:
|
|
{
|
|
ExplosionsEditAdler *editWidget = new ExplosionsEditAdler(menuGroup(), parent);
|
|
if (editWidget->init(aesEntityId, false, m_session))
|
|
return editWidget;
|
|
|
|
delete editWidget;
|
|
return nullptr;
|
|
break;
|
|
}
|
|
case ProjectDataManagement::EffectSource::ES_Internal:
|
|
case ProjectDataManagement::EffectSource::ES_HLA:
|
|
{
|
|
ExplosionsEdit *editWidget = new ExplosionsEdit(menuGroup(), parent);
|
|
if (editWidget->init(aesEntityId, false, m_session))
|
|
return editWidget;
|
|
|
|
delete editWidget;
|
|
return nullptr;
|
|
break;
|
|
}
|
|
case ProjectDataManagement::EffectSource::ES_Unknown:
|
|
{
|
|
ERROR_LOG(m_logger) << "Unknow EffectSource";
|
|
break;
|
|
}
|
|
}
|
|
return nullptr;
|
|
}
|
|
|
|
LtsWidgets::LtsDialog *InterfaceImpl::onShowAddExplosionDialog(bool isSingle, bool isCentral, ProjectDataManagement::GearClass gc, QWidget *parent)
|
|
{
|
|
ExplosionEdit *editWidget
|
|
= new ExplosionEdit(menuGroup(), isSingle ? (isCentral ? ExplosionEdit::etSingleCentral : ExplosionEdit::etSingle) : ExplosionEdit::etArea, gc, parent);
|
|
if (editWidget->init(0, false, m_session))
|
|
return editWidget;
|
|
|
|
delete editWidget;
|
|
return nullptr;
|
|
}
|
|
|
|
LtsWidgets::LtsDialog *InterfaceImpl::onShowExplosionListDialog(bool isSingle, bool /*isCentral*/, ProjectDataManagement::GearClass gc, QWidget *parent)
|
|
{
|
|
ExplosionList *listWidget;
|
|
if (isSingle)
|
|
listWidget = new ExplosionSingleList(menuGroup(), gc, parent);
|
|
else
|
|
listWidget = new ExplosionAreaList(menuGroup(), gc, parent);
|
|
|
|
if (listWidget->init(m_session))
|
|
return listWidget;
|
|
|
|
delete listWidget;
|
|
return nullptr;
|
|
}
|
|
|
|
LtsWidgets::LtsDialog *InterfaceImpl::onShowAddExplosionClusterDialog(QWidget *parent)
|
|
{
|
|
ExplosionsEdit *editWidget = new ExplosionsEdit(menuGroup(), parent);
|
|
if (editWidget->init(0, false, m_session))
|
|
return editWidget;
|
|
|
|
delete editWidget;
|
|
return nullptr;
|
|
}
|
|
|
|
LtsWidgets::LtsDialog *InterfaceImpl::onShowAddExplosionAdlerStandAloneDialog(QWidget *parent)
|
|
{
|
|
DEBUG_LOG(m_logger) << "onShowAddExplosionAdlerStandAloneDialog";
|
|
ExplosionsEditAdlerStandAlone *editWidget = new ExplosionsEditAdlerStandAlone(menuGroup(), parent);
|
|
if (editWidget->init(0, false, m_session))
|
|
return editWidget;
|
|
|
|
delete editWidget;
|
|
return nullptr;
|
|
}
|
|
|
|
LtsWidgets::LtsDialog *InterfaceImpl::onShowExplosionClusterListDialog(QWidget *parent)
|
|
{
|
|
ExplosionList *listWidget;
|
|
|
|
listWidget = new ExplosionClusterList(menuGroup(),
|
|
{ProjectDataManagement::GearClass_def::Artillery,
|
|
ProjectDataManagement::GearClass_def::Mortar,
|
|
ProjectDataManagement::GearClass_def::Rocket},
|
|
parent);
|
|
|
|
if (listWidget->init(m_session))
|
|
return listWidget;
|
|
|
|
delete listWidget;
|
|
return nullptr;
|
|
}
|
|
|
|
bool InterfaceImpl::eventFilter(QObject *obj, QEvent *event) // show dialogs dialog on clicked link
|
|
{
|
|
if (obj == qApp && !event->isAccepted() && event->type() == LtsWidgets::LtsLinkEvent::eventTypeId())
|
|
{
|
|
auto ev = static_cast<LtsWidgets::LtsLinkEvent *>(event);
|
|
|
|
const auto isChildOfSession = [this](QWidget *w)
|
|
{
|
|
if (!w)
|
|
return true;
|
|
auto baseLayout = m_session->baseLayout();
|
|
return baseLayout->isAncestorOf(w);
|
|
};
|
|
if (isChildOfSession(ev->sourceBaseLayoutWidget()) && ev->url().host() == s_ExplosionGuiScheme.toLower())
|
|
{
|
|
bool ok = false;
|
|
ERROR_LOG(m_logger) << ev->url().path();
|
|
const QStringList params = ev->url().path().split(QStringLiteral("/"));
|
|
if (params.size() < 2)
|
|
return QObject::eventFilter(obj, event);
|
|
ERROR_LOG(m_logger) << "DIalog Name " << params.at(1) << " aesId " << params.at(2);
|
|
QString dialogName = params.at(1);
|
|
int aesId = params.at(2).toInt(&ok);
|
|
if (ok)
|
|
{
|
|
ExplosionsEditAdler *dlg = new ExplosionsEditAdler(menuGroup(), m_session->baseLayout());
|
|
if (dlg->init(aesId, false, m_session))
|
|
m_session->addWidget(dlg, menuGroup(), dlg->dialogIdentifier(), LtsWidgets::LayoutArea::eDialogTab);
|
|
|
|
event->accept();
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
|
|
return QObject::eventFilter(obj, event);
|
|
}
|
|
|
|
} // namespace AreaEffectSimulation
|