Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+29
@@ -0,0 +1,29 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
# Created by Christian Ehrlicher, SLSE, 2016-03-01
|
||||
#
|
||||
|
||||
ADD_SUBDIRECTORY(Data)
|
||||
ADD_SUBDIRECTORY(Gui)
|
||||
|
||||
#
|
||||
# Gui Plugin Interface
|
||||
#
|
||||
ADD_INTERFACE_LIBRARY(AesInfoGuiPluginInterface
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/aes_info_gui_plugin_interface.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../
|
||||
GuiPluginInterface
|
||||
svcAesCommon
|
||||
)
|
||||
|
||||
#
|
||||
# Data Plugin Interface
|
||||
#
|
||||
ADD_INTERFACE_LIBRARY(AesDataPluginInterface
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/aes_data_plugin_interface.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../
|
||||
DataPluginInterface
|
||||
svcAesCommon
|
||||
)
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
# Created by Mike Wille, SLSE, 2016-09-06
|
||||
#
|
||||
|
||||
#
|
||||
# Data Plugin
|
||||
#
|
||||
NGL_ADD_LIBRARY(WS AesDataPlugin MODULE aes_data_plugin.cpp aes_data_plugin.h)
|
||||
NGL_TARGET_LINK_LIBRARIES(AesDataPlugin
|
||||
Qt5::Core
|
||||
AesDataPluginInterface
|
||||
svcAesClient
|
||||
NGLLogger
|
||||
LtsSessionDataDds
|
||||
)
|
||||
NGL_INSTALL_TARGET(AesDataPlugin)
|
||||
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Data Plugin for AreaEffectSimulation
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
*/
|
||||
|
||||
#include "aes_data_plugin.h"
|
||||
|
||||
#include <DDS/DDSConnector/dds_connector.h>
|
||||
#include <LtsSession/lts_session_data_dds.h>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
std::shared_ptr<DataPluginBase::Interface> DataPlugin::createDataInterface(LtsSession::LtsSessionDataDds *session)
|
||||
{
|
||||
std::shared_ptr<AreaEffectSimulation::Interface::Dtc> dtc;
|
||||
std::shared_ptr<AreaEffectSimulation::Interface::Ftc> ftc;
|
||||
if (!session->createTopicClient(dtc, ftc))
|
||||
return std::shared_ptr<DataPluginBase::Interface>();
|
||||
|
||||
return std::make_shared<DataInterfaceImpl>(dtc, ftc);
|
||||
}
|
||||
|
||||
DataInterfaceImpl::DataInterfaceImpl(const std::shared_ptr<AreaEffectSimulation::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<AreaEffectSimulation::Interface::Ftc> &ftc)
|
||||
: DataInterface()
|
||||
, m_dtc(dtc)
|
||||
, m_ftc(ftc)
|
||||
{}
|
||||
|
||||
} // namespace AreaEffectSimulation
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Data Plugin for AreaEffectSimulation
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <PluginInterfaces/data_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
class DataPlugin final : public QObject, public DataPluginBase::Plugin
|
||||
{
|
||||
Q_PLUGIN_METADATA(IID "data:3:aes")
|
||||
Q_INTERFACES(DataPluginBase::Plugin)
|
||||
|
||||
Q_OBJECT
|
||||
public:
|
||||
DataPlugin() = default;
|
||||
~DataPlugin() = default;
|
||||
|
||||
QString pluginName() const override { return QStringLiteral("AreaEffectSimulation"); }
|
||||
std::shared_ptr<DataPluginBase::Interface> createDataInterface(LtsSession::LtsSessionDataDds *session) override;
|
||||
bool availableInPartition(IDL::PartitionType partition) const override
|
||||
{
|
||||
return partition == IDL::PartitionType::Exercise ||
|
||||
partition == IDL::PartitionType::Replay ||
|
||||
partition == IDL::PartitionType::Global;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class DataInterfaceImpl final : public DataInterface
|
||||
{
|
||||
public:
|
||||
DataInterfaceImpl(const std::shared_ptr<AreaEffectSimulation::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<AreaEffectSimulation::Interface::Ftc> &ftc);
|
||||
|
||||
std::shared_ptr<AreaEffectSimulation::Interface::Dtc> getDtc() override { return m_dtc; }
|
||||
std::shared_ptr<AreaEffectSimulation::Interface::Ftc> getFtc() override { return m_ftc; }
|
||||
|
||||
private:
|
||||
std::shared_ptr<AreaEffectSimulation::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<AreaEffectSimulation::Interface::Ftc> m_ftc;
|
||||
};
|
||||
|
||||
} // namespace AreaEffectSimulation
|
||||
@@ -0,0 +1,48 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
# Created by hjl, SLSE, 2017-03-22
|
||||
#
|
||||
SET(aes_info_gui_SRCS
|
||||
aes_info_gui_plugin.h
|
||||
aes_info_gui_plugin.cpp
|
||||
aes_info_dialog.h
|
||||
aes_info_dialog.cpp
|
||||
aes_danger_area_aes_item_info.cpp
|
||||
aes_danger_area_aes_item_info.h
|
||||
aes_charge_effect_item_info.cpp
|
||||
aes_charge_effect_item_info.h
|
||||
)
|
||||
|
||||
NGL_WRAP_UI(aes_info_gui_SRCS
|
||||
aes_info_dialog.ui
|
||||
aes_danger_area_aes_item_info.ui
|
||||
aes_charge_effect_item_info.ui
|
||||
)
|
||||
|
||||
NGL_ADD_LIBRARY(WS AesInfoGuiPlugin MODULE ${aes_info_gui_SRCS})
|
||||
NGL_TARGET_LINK_LIBRARIES(AesInfoGuiPlugin
|
||||
AesInfoGuiPluginInterface
|
||||
NGLLogger
|
||||
PdmDataPluginInterface
|
||||
AesChargeEffectGuiPluginInterface
|
||||
svcAesCommon
|
||||
AesBaseGui
|
||||
AesBCContaminationGuiPluginInterface
|
||||
AesNContaminationGuiPluginInterface
|
||||
AesExplosionGuiPluginInterface
|
||||
AesMineAreaGuiPluginInterface
|
||||
AesDangerAreaGuiPluginInterface
|
||||
SituationMapGuiPluginInterface
|
||||
Qt5::Widgets
|
||||
LtsWidgets
|
||||
LtsSession
|
||||
LtsSessionData
|
||||
LtsUtilsGuiDds
|
||||
LtsUtilsSettings
|
||||
LtsCoordTrans
|
||||
ngltools
|
||||
)
|
||||
|
||||
NGL_INSTALL_TARGET(AesInfoGuiPlugin)
|
||||
+348
@@ -0,0 +1,348 @@
|
||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||
#include <Plugins/SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
#include <ngltools/ngltools_dtg.h>
|
||||
#include <AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
|
||||
#include <ChargeEffect/aes_charge_effect_edit.h>
|
||||
#include <ChargeEffect/aes_charge_effect_gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/Gui/BCContamination/aes_bccontamination_gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/Gui/NContamination/aes_ncontamination_gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/Gui/Explosion/aes_explosion_gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/Gui/MineArea/aes_mine_area_gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/Gui/MineCorridor/aes_mine_corridor_gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/Gui/GasPipe/aes_gas_pipe_gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/Gui/DangerArea/aes_danger_area_gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/Gui/Borderline/aes_borderline_gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/Gui/FunctionalArea/aes_functional_area_gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/Gui/MineSingleVirtual/aes_mine_single_virtual_gui_plugin_interface.h>
|
||||
|
||||
#include "aes_translation.h"
|
||||
#include "aes_charge_effect_item_info.h"
|
||||
#include "ui_aes_charge_effect_item_info.h"
|
||||
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
AesChargeEffectItemInfo::AesChargeEffectItemInfo(int chargeEffectId, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_logger(getLogger("AesChargeEffectItemInfo"))
|
||||
, m_session(nullptr)
|
||||
, m_ChargeEffectId(chargeEffectId)
|
||||
, m_ui(new Ui::AesChargeEffectItemInfo)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
m_ui->lblChargeEffectId->setText(QString::number(m_ChargeEffectId));
|
||||
|
||||
connect(m_ui->pbFindOnMap, &QToolButton::clicked, this, &AesChargeEffectItemInfo::onFindOnMap);
|
||||
connect(m_ui->pbDetails, &QToolButton::clicked, this, &AesChargeEffectItemInfo::onShowDetails);
|
||||
|
||||
}
|
||||
|
||||
AesChargeEffectItemInfo::~AesChargeEffectItemInfo()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
bool AesChargeEffectItemInfo::init(LtsSession::LtsSession *session)
|
||||
{
|
||||
m_session = session;
|
||||
|
||||
if (!session->getDtc<ProjectDataManagement::DataInterface>(m_pdmDtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << " failed to get pdmDtc";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!session->getDtc<AreaEffectSimulation::DataInterface>(m_aesDtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << " failed to get aesDtc";
|
||||
return false;
|
||||
}
|
||||
if (!m_aesDtc->isAesItemViewEnabled())
|
||||
m_aesDtc->enableAesItemView();
|
||||
|
||||
if (!m_pdmDtc->isChargeTypeEnabled())
|
||||
m_pdmDtc->enableChargeType();
|
||||
|
||||
const ChargeEffect data = m_aesDtc->chargeEffect(m_ChargeEffectId);
|
||||
//hide first:
|
||||
m_ui->lblPosition->hide();
|
||||
// Debug Infos
|
||||
#ifndef LTS_DEBUG
|
||||
m_ui->lbxChargeEffectId->hide();
|
||||
m_ui->lblChargeEffectId->hide();
|
||||
m_ui->lbxChargeTypeId->hide();
|
||||
m_ui->lblChargeTypeId->hide();
|
||||
m_ui->lbxOriginatorId->hide();
|
||||
m_ui->lblOriginatorId->hide();
|
||||
m_ui->lbxOriginatorType->hide();
|
||||
m_ui->lblOriginatorType->hide();
|
||||
#endif
|
||||
|
||||
m_ui->lblOriginatorId->setText(QString::number(data.originatorId()));
|
||||
m_ui->lblOriginatorType->setText(QString::number(data.originatorTypeId().underlying()));
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Info_Dialog-Charge_Effect"));
|
||||
|
||||
|
||||
connect(m_aesDtc.get(), &AreaEffectSimulation::Interface::Dtc::chargeEffectChanged,
|
||||
this, &AesChargeEffectItemInfo::onChargeEffectChanged);
|
||||
|
||||
handleChargeEffect(data);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void AesChargeEffectItemInfo::retranslate()
|
||||
{
|
||||
const ChargeEffect item = m_aesDtc->chargeEffect(m_ChargeEffectId);
|
||||
translate(m_ui, tr("ChargeEffect: \"%1\"").arg(QString::fromStdString(item.name()), 1, QLatin1Char('?')));
|
||||
}
|
||||
|
||||
void AesChargeEffectItemInfo::onFindOnMap() const
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "onFindOnMap() aesId: "<<m_ChargeEffectId;
|
||||
std::shared_ptr<SituationMap::ForeignGuiInterface> ifc;
|
||||
if (m_session->getForeignGuiInterface<SituationMap::ForeignGuiInterface>(ifc))
|
||||
ifc->centerMapToChargeEffectObject(m_ChargeEffectId);
|
||||
else
|
||||
WARNING_LOG(m_logger) << LOGFUNCTION << "getForeignGuiInterface<SituationMap::ForeignGuiInterface> failed!";
|
||||
}
|
||||
|
||||
template <typename InterfaceType>
|
||||
bool AesChargeEffectItemInfo::tryShowStandardEditDialog(const AesItemView& aiv)
|
||||
{
|
||||
std::shared_ptr<InterfaceType> ifc;
|
||||
if (m_session->getForeignGuiInterface<InterfaceType>(ifc))
|
||||
{
|
||||
AreaEffectSimulation::BaseEdit* dialog = ifc->showEditWindow(aiv.aesItemId(), this);
|
||||
if (dialog)
|
||||
{
|
||||
addDialog(dialog, dialog->menuGroup(), dialog->dialogIdentifier(), LtsWidgets::LayoutArea::eDialogTab);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
WARNING_LOG(m_logger) << LOGFUNCTION << " getForeignGuiInterface failed for specific AES interface!";
|
||||
return false;
|
||||
}
|
||||
|
||||
void AesChargeEffectItemInfo::onShowDetails()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION;
|
||||
|
||||
const ChargeEffect item = m_aesDtc->chargeEffect(m_ChargeEffectId);
|
||||
|
||||
if (item.originatorTypeId() == ProjectDataManagement::StateChangeOriginator::AreaEffectSimulation)
|
||||
{
|
||||
AesItemView aiv;
|
||||
m_aesDtc->aesItemViewFromEntityId(item.originatorId(), AreaEffectSimulation::AesType::AtUnknown, aiv);
|
||||
DEBUG_LOG(m_logger) << "aiv.id():" << aiv.id() << ", aesType: " << aiv.aesTypeId();
|
||||
|
||||
// Lambda für die Standard-Dialogregistrierung (spart Schreibarbeit bei Sonderfällen)
|
||||
auto registerDialog = [this](AreaEffectSimulation::BaseEdit* dialog) {
|
||||
if (dialog) {
|
||||
addDialog(dialog, dialog->menuGroup(), dialog->dialogIdentifier(), LtsWidgets::LayoutArea::eDialogTab);
|
||||
}
|
||||
};
|
||||
|
||||
switch(aiv.aesTypeId().underlying())
|
||||
{
|
||||
case AreaEffectSimulation::AesType::AtNContamination:
|
||||
{
|
||||
tryShowStandardEditDialog<AesNContamination::ForeignGuiInterface>(aiv);
|
||||
break;
|
||||
}
|
||||
case AreaEffectSimulation::AesType::AtMineArea:
|
||||
{
|
||||
tryShowStandardEditDialog<AesMineArea::ForeignGuiInterface>(aiv);
|
||||
break;
|
||||
}
|
||||
|
||||
case AreaEffectSimulation::AesType::AtMineCorridor:
|
||||
{
|
||||
tryShowStandardEditDialog<AesMineCorridor::ForeignGuiInterface>(aiv);
|
||||
break;
|
||||
}
|
||||
|
||||
case AreaEffectSimulation::AesType::AtGasPipe:
|
||||
{
|
||||
tryShowStandardEditDialog<AesGasPipe::ForeignGuiInterface>(aiv);
|
||||
break;
|
||||
}
|
||||
case AreaEffectSimulation::AesType::AtDangerArea:
|
||||
{
|
||||
tryShowStandardEditDialog<AesDangerArea::ForeignGuiInterface>(aiv);
|
||||
break;
|
||||
}
|
||||
case AreaEffectSimulation::AesType::AtBorderline:
|
||||
{
|
||||
tryShowStandardEditDialog<AesBorderline::ForeignGuiInterface>(aiv);
|
||||
break;
|
||||
}
|
||||
case AreaEffectSimulation::AesType::AtFunctionalArea:
|
||||
{
|
||||
tryShowStandardEditDialog<AesFunctionalArea::ForeignGuiInterface>(aiv);
|
||||
break;
|
||||
}
|
||||
|
||||
case AreaEffectSimulation::AesType::AtBCContamination:
|
||||
{
|
||||
std::shared_ptr<AesBCContamination::ForeignGuiInterface> ifc;
|
||||
if (m_session->getForeignGuiInterface<AesBCContamination::ForeignGuiInterface>(ifc))
|
||||
{
|
||||
const auto gearClass = m_pdmDtc->gearClassFromChargeTypeId(aiv.chargeStruct().chargeTypeId());
|
||||
if (gearClass == ProjectDataManagement::GearClass_def::Biological)
|
||||
registerDialog(ifc->showEditWindow(aiv.aesItemId(), false, this));
|
||||
else if (gearClass == ProjectDataManagement::GearClass_def::Chemical)
|
||||
registerDialog(ifc->showEditWindow(aiv.aesItemId(), true, this));
|
||||
}
|
||||
else
|
||||
WARNING_LOG(m_logger) << LOGFUNCTION << " getForeignGuiInterface<AesBCContamination::ForeignGuiInterface> failed!";
|
||||
break;
|
||||
}
|
||||
case AreaEffectSimulation::AesType::AtBoobyTrap:
|
||||
case AreaEffectSimulation::AesType::AtBoobyTrapSecondary:
|
||||
{
|
||||
std::shared_ptr<AesMineSingleVirtual::ForeignGuiInterface> ifc;
|
||||
if (m_session->getForeignGuiInterface<AesMineSingleVirtual::ForeignGuiInterface>(ifc))
|
||||
registerDialog(ifc->showBoobyTrapEditWindow(aiv.aesItemId(), this));
|
||||
else
|
||||
WARNING_LOG(m_logger) << LOGFUNCTION << " getForeignGuiInterface<AesMineSingleVirtual::ForeignGuiInterface> failed!";
|
||||
break;
|
||||
}
|
||||
case AreaEffectSimulation::AesType::AtOffRouteMine:
|
||||
case AreaEffectSimulation::AesType::AtOffRouteMineSecondary:
|
||||
{
|
||||
std::shared_ptr<AesMineSingleVirtual::ForeignGuiInterface> ifc;
|
||||
if (m_session->getForeignGuiInterface<AesMineSingleVirtual::ForeignGuiInterface>(ifc))
|
||||
registerDialog(ifc->showOffRouteMineEditWindow(aiv.aesItemId(), this));
|
||||
else
|
||||
WARNING_LOG(m_logger) << LOGFUNCTION << " getForeignGuiInterface<AesMineSingleVirtual::ForeignGuiInterface> failed!";
|
||||
break;
|
||||
}
|
||||
case AreaEffectSimulation::AesType::AtExplosionSingle:
|
||||
case AreaEffectSimulation::AesType::AtExplosionArea:
|
||||
{
|
||||
std::shared_ptr<AesExplosion::ForeignGuiInterface> ifc;
|
||||
if (m_session->getForeignGuiInterface<AesExplosion::ForeignGuiInterface>(ifc))
|
||||
{
|
||||
const bool isExplosionSingle = (aiv.aesTypeId().underlying() == AreaEffectSimulation::AesType::AtExplosionSingle);
|
||||
const auto gearClass = m_pdmDtc->gearClassFromChargeTypeId(aiv.chargeStruct().chargeTypeId());
|
||||
|
||||
for (auto gc : { ProjectDataManagement::GearClass::Artillery, ProjectDataManagement::GearClass::Mortar, ProjectDataManagement::GearClass::AirSupport })
|
||||
{
|
||||
if (gc == ProjectDataManagement::GearClass::AirSupport && !isExplosionSingle) continue; // ExplosionArea -> No AirSupport
|
||||
|
||||
if (gearClass == gc)
|
||||
{
|
||||
registerDialog(ifc->showEditWindow(aiv.aesItemId(), isExplosionSingle, false, gc, this));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
WARNING_LOG(m_logger) << LOGFUNCTION << " getForeignGuiInterface<AesExplosion::ForeignGuiInterface> failed!";
|
||||
break;
|
||||
}
|
||||
|
||||
case AreaEffectSimulation::AesType::AtExplosionCluster:
|
||||
case AreaEffectSimulation::AesType::AtEffectCluster:
|
||||
{
|
||||
std::shared_ptr<AesExplosion::ForeignGuiInterface> ifc;
|
||||
if (m_session->getForeignGuiInterface<AesExplosion::ForeignGuiInterface>(ifc))
|
||||
{
|
||||
// EffectSource is not set in aiv, get aesItem
|
||||
AesItem ai;
|
||||
m_aesDtc->aesItemFromId(aiv.aesItemId(), ai);
|
||||
registerDialog(ifc->showEditWindow(aiv.aesItemId(), ai.effectSourceId(), this));
|
||||
}
|
||||
else
|
||||
WARNING_LOG(m_logger) << LOGFUNCTION << " getForeignGuiInterface<AesExplosion::ForeignGuiInterface> failed!";
|
||||
break;
|
||||
}
|
||||
|
||||
case AreaEffectSimulation::AesType::AtAirSupportImpact:
|
||||
case AreaEffectSimulation::AesType::AtDusSingleMine:
|
||||
case AreaEffectSimulation::AesType::AtExplosionAreaSingleExplosions:
|
||||
case AreaEffectSimulation::AesType::AtMineAreaSingleMines:
|
||||
case AreaEffectSimulation::AesType::AtReconArea:
|
||||
case AreaEffectSimulation::AesType::AtTechnicalArea:
|
||||
case AreaEffectSimulation::AesType::AtExplosionSingleCentral:
|
||||
case AreaEffectSimulation::AesType::AtExplosionSingleCentralTrajectory:
|
||||
case AreaEffectSimulation::AesType::AtExplosionClusterSingleExplosions:
|
||||
case AreaEffectSimulation::AesType::AtExplosionClusterSingleTrajectory:
|
||||
case AreaEffectSimulation::AesType::AtExplosionClusterGunToTargetLine:
|
||||
case AreaEffectSimulation::AesType::AtEffectClusterGunToTargetLine:
|
||||
case AreaEffectSimulation::AesType::AtEffectClusterSingleExplosions:
|
||||
case AreaEffectSimulation::AesType::AtEffectClusterSingleTrajectory:
|
||||
// empty
|
||||
m_ui->pbDetails->hide();
|
||||
break;
|
||||
case AreaEffectSimulation::AesType::AtUnknown:
|
||||
Q_ASSERT(false);
|
||||
WARNING_LOG(m_logger) << "Unknown AesType found for aesEntityId: " << aiv.aesTypeId();
|
||||
break;
|
||||
default:
|
||||
DEBUG_LOG(m_logger) << "Couldn't find AesItem to ChargeEffect (any more). Hiding the button";
|
||||
m_ui->pbDetails->hide();
|
||||
break;
|
||||
} // switch
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
std::shared_ptr<AesChargeEffect::ForeignGuiInterface> ifc;
|
||||
if (m_session->getForeignGuiInterface<AesChargeEffect::ForeignGuiInterface>(ifc))
|
||||
{
|
||||
AreaEffectSimulation::BaseEdit* dialog = ifc->showEditWindow(m_ChargeEffectId, this);
|
||||
if (dialog)
|
||||
addDialog(dialog, dialog->menuGroup(), dialog->dialogIdentifier(), LtsWidgets::LayoutArea::eDialogTab);
|
||||
}
|
||||
else
|
||||
WARNING_LOG(m_logger) << LOGFUNCTION << " getForeignGuiInterface ChargeEffect failed!";
|
||||
}
|
||||
}
|
||||
|
||||
void AesChargeEffectItemInfo::onChargeEffectChanged(const ChargeEffect &data, DataModification modType)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << " [onChargeEffectChanged] id: " << data.id();
|
||||
if (data.id() == m_ChargeEffectId && modType != DataModification::eRemoved)
|
||||
handleChargeEffect(data);
|
||||
}
|
||||
|
||||
void AesChargeEffectItemInfo::handleChargeEffect(const ChargeEffect &data)
|
||||
{
|
||||
// Name
|
||||
m_ui->lblChargeEffectName->setText(QString::fromStdString(data.name()));
|
||||
|
||||
// Start
|
||||
m_ui->lblEffectStart->setText(DTG::toStringMSec(data.effectStart()));
|
||||
// Duration
|
||||
|
||||
m_ui->lblEffectDuration->setVisible(data.effectDuration() > 0);
|
||||
m_ui->lbxEffectDuration->setVisible(data.effectDuration() > 0);
|
||||
|
||||
m_ui->lblEffectDuration->setText(LtsWidgets::readableDuration(data.effectDuration()));
|
||||
|
||||
// Effect State
|
||||
AreaEffectSimulation::AesEffectState st = data.state();
|
||||
m_ui->lblStatus->setText(AreaEffectSimulation::toString(st));
|
||||
|
||||
// Charge Type Id
|
||||
m_ui->lblChargeTypeId->setText(QString::number(data.chargeTypeId()));
|
||||
|
||||
// Charge Type
|
||||
m_ui->lblChargeType->setText(m_pdmDtc->trChargeTypeShortName(data.chargeTypeId()));
|
||||
m_ui->lblChargeType->setToolTip(m_pdmDtc->trChargeTypeName(data.chargeTypeId()));
|
||||
|
||||
// Position
|
||||
m_ui->lblPosition->show();
|
||||
QString mgrs = LtsCoordTrans::mgrsFromGeographic(data.position().lon(), data.position().lat());
|
||||
m_ui->lblPosition->setText(tr("Position: %1").arg(mgrs));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Info dialog for the items covered by a charge effect
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by kemayou_s, ESZS, 2017-03-27
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AreaEffectSimulation/logger.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <AreaEffectSimulation/aes.hpp>
|
||||
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui {
|
||||
class AesChargeEffectItemInfo;
|
||||
}
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
|
||||
namespace Interface
|
||||
{
|
||||
class Ftc;
|
||||
class Dtc;
|
||||
}
|
||||
|
||||
class AesChargeEffectItemInfo : public LtsWidgets::LtsDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AesChargeEffectItemInfo(int aesId, QWidget *parent = nullptr);
|
||||
~AesChargeEffectItemInfo();
|
||||
|
||||
bool init(LtsSession::LtsSession *session);
|
||||
|
||||
private:
|
||||
void retranslate() override;
|
||||
template <typename InterfaceType>
|
||||
bool tryShowStandardEditDialog(const AesItemView& aiv);
|
||||
|
||||
private Q_SLOTS:
|
||||
void onFindOnMap() const;
|
||||
void onShowDetails();
|
||||
void onChargeEffectChanged(const AreaEffectSimulation::ChargeEffect &data, DataModification modType);
|
||||
void handleChargeEffect(const AreaEffectSimulation::ChargeEffect &data);
|
||||
private:
|
||||
std::shared_ptr<ProjectDataManagement::Interface::Dtc> m_pdmDtc;
|
||||
std::shared_ptr<AreaEffectSimulation::Interface::Dtc> m_aesDtc;
|
||||
LOGGER_T m_logger;
|
||||
LtsSession::LtsSession *m_session;
|
||||
int m_ChargeEffectId{-1};
|
||||
Ui::AesChargeEffectItemInfo *m_ui;
|
||||
};
|
||||
|
||||
} // namespace AreaEffectSimulation
|
||||
+343
@@ -0,0 +1,343 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>AesChargeEffectItemInfo</class>
|
||||
<widget class="QWidget" name="AesChargeEffectItemInfo">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>275</width>
|
||||
<height>479</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lblIcon">
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="LtsWidgets::LtsElidedLabel" name="lbxChargeEffectId">
|
||||
<property name="text">
|
||||
<string>Charge Effect Id:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="lblChargeEffectId">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"><EFFECTID></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="LtsWidgets::LtsElidedLabel" name="lbxEffectName">
|
||||
<property name="text">
|
||||
<string>Charge Effect Name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLabel" name="lblChargeEffectName">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"><EFFECTNAME></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="LtsWidgets::LtsElidedLabel" name="lbxOriginatorId">
|
||||
<property name="text">
|
||||
<string>Originator Id:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLabel" name="lblOriginatorId">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"><ORIGINATORID></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="LtsWidgets::LtsElidedLabel" name="lbxOriginatorType">
|
||||
<property name="text">
|
||||
<string>Originator Type:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QLabel" name="lblOriginatorType">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"><ORIGINATORTYPE></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="LtsWidgets::LtsElidedLabel" name="lbxEffectStart">
|
||||
<property name="text">
|
||||
<string>Effect Start:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QLabel" name="lblEffectStart">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"><EFFECTSTART></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="LtsWidgets::LtsElidedLabel" name="lbxEffectDuration">
|
||||
<property name="text">
|
||||
<string>Effect Duration:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="QLabel" name="lblEffectDuration">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"><EFFECTDURATION></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="LtsWidgets::LtsElidedLabel" name="lbxStatus">
|
||||
<property name="text">
|
||||
<string>Status:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<widget class="QLabel" name="lblStatus">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"><STATUS></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<widget class="LtsWidgets::LtsElidedLabel" name="lbxChargeTypeId">
|
||||
<property name="text">
|
||||
<string>Charge Type Id:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="1">
|
||||
<widget class="QLabel" name="lblChargeTypeId">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"><CHARGETYPEID></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="0">
|
||||
<widget class="LtsWidgets::LtsElidedLabel" name="lbxChargeType">
|
||||
<property name="text">
|
||||
<string>Charge Type:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="1">
|
||||
<widget class="QLabel" name="lblChargeType">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"><CHARGETYPE></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="0">
|
||||
<widget class="QLabel" name="lblPosition">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"><POSITION></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="11" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QToolButton" name="pbFindOnMap">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Find on map</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/style/center_to_object.svg</normaloff>:/style/center_to_object.svg</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="pbDetails">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Show details</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/style/pi_tact_status_history.svg</normaloff>:/style/pi_tact_status_history.svg</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="autoRepeatInterval">
|
||||
<number>100</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>17</width>
|
||||
<height>17</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="12" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LtsWidgets::LtsElidedLabel</class>
|
||||
<extends>QLabel</extends>
|
||||
<header>LtsWidgets/lts_elided_label.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
+166
@@ -0,0 +1,166 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Info dialog for the items covered by a danger area
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by diers, SLSE, 2017-03-27
|
||||
*/
|
||||
|
||||
#include "aes_danger_area_aes_item_info.h"
|
||||
#include "ui_aes_danger_area_aes_item_info.h"
|
||||
#include <Plugins/AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
#include <BCContamination/aes_bccontamination_gui_plugin_interface.h>
|
||||
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
|
||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
|
||||
#include <QDateTime>
|
||||
|
||||
#include <memory>
|
||||
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
|
||||
DangerAreaAesItemInfo::DangerAreaAesItemInfo(QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_dtc(nullptr)
|
||||
, m_logger(getLogger("DangerArea.AesItemInfo"))
|
||||
, m_session(nullptr)
|
||||
, m_ui(new Ui::DangerAreaAesItemInfo)
|
||||
, m_aesItemId(-1)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
}
|
||||
|
||||
DangerAreaAesItemInfo::~DangerAreaAesItemInfo()
|
||||
{
|
||||
for (const auto &item : qAsConst(m_aesItems))
|
||||
delete item.item;
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void DangerAreaAesItemInfo::retranslate()
|
||||
{
|
||||
|
||||
std::unique_ptr<AesItem> item(new BCContamination(m_dtc->bCContamination(m_aesItemId)));
|
||||
if (item->id() > 0)
|
||||
{
|
||||
translate(m_ui, m_dtc->bCContamination(m_aesItemId), tr("B/C-Contamination"));
|
||||
return;
|
||||
}
|
||||
|
||||
item.reset(new NContamination(m_dtc->nContamination(m_aesItemId)));
|
||||
if (item->id() > 0)
|
||||
{
|
||||
translate(m_ui, m_dtc->nContamination(m_aesItemId), tr("N-Contamination"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
item.reset(new ExplosionArea(m_dtc->explosionArea(m_aesItemId)));
|
||||
if (item->id() > 0)
|
||||
{
|
||||
translate(m_ui, m_dtc->explosionArea(m_aesItemId), tr("Explosion Area"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
item.reset(new ExplosionSingle(m_dtc->explosionSingle(m_aesItemId)));
|
||||
if (item->id() > 0)
|
||||
{
|
||||
translate(m_ui, m_dtc->explosionSingle(m_aesItemId), tr("Single Explosion"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
item.reset(new MineArea(m_dtc->mineArea(m_aesItemId)));
|
||||
if (item->id() > 0)
|
||||
{
|
||||
translate(m_ui, m_dtc->mineArea(m_aesItemId), tr("Mine Area"));
|
||||
return;
|
||||
}
|
||||
|
||||
translate(m_ui, tr("Unknown Aes Type"));
|
||||
}
|
||||
|
||||
bool DangerAreaAesItemInfo::init(const QSet<int> &dangerAreaIds, const QSet<int> &aesItemIds, LtsSession::LtsSession *session)
|
||||
{
|
||||
if (!init(session))
|
||||
return false;
|
||||
|
||||
for (int dangerAreaId : dangerAreaIds)
|
||||
m_dangerAreas.insert(dangerAreaId, m_dtc->dangerArea(dangerAreaId));
|
||||
for (int aesItemId : aesItemIds)
|
||||
insertAesItem(aesItemId);
|
||||
|
||||
m_aesItemId = aesItemIds.empty() ? -1 : *aesItemIds.begin();
|
||||
setText();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DangerAreaAesItemInfo::init(LtsSession::LtsSession *session)
|
||||
{
|
||||
if (m_session && session)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "double init()!";
|
||||
return false;
|
||||
}
|
||||
if (!m_session && !session)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "No Session available!";
|
||||
return false;
|
||||
}
|
||||
if (!m_session)
|
||||
m_session = session;
|
||||
|
||||
if(!m_dtc.get())
|
||||
if (!m_session->getDtc<AreaEffectSimulation::DataInterface>(m_dtc))
|
||||
return false;
|
||||
|
||||
setText();
|
||||
return true;
|
||||
}
|
||||
|
||||
void DangerAreaAesItemInfo::insertAesItem(int aesItemId)
|
||||
{
|
||||
AesItem *item;
|
||||
item = new BCContamination(m_dtc->bCContamination(aesItemId));
|
||||
if (item->id() > 0)
|
||||
{
|
||||
m_aesItems.insert(aesItemId, AesStruct(AesType::AtBCContamination, item));
|
||||
return;
|
||||
}
|
||||
delete item;
|
||||
|
||||
WARNING_LOG(m_logger) << "AesItem with id " << aesItemId << " is not of any known type!";
|
||||
}
|
||||
|
||||
void DangerAreaAesItemInfo::setText()
|
||||
{
|
||||
for (const DangerArea &dangerArea : qAsConst(m_dangerAreas))
|
||||
aesItemInfo(&dangerArea);
|
||||
|
||||
|
||||
for(const AesStruct &aesStruct : qAsConst(m_aesItems))
|
||||
{
|
||||
if(aesStruct.item->effectStateId() == AreaEffectSimulation::AesEffectState::EsActivated)
|
||||
aesItemInfo(aesStruct.item);
|
||||
}
|
||||
}
|
||||
|
||||
void DangerAreaAesItemInfo::aesItemInfo(const AesItem *item)
|
||||
{
|
||||
// Todo: Use This, not the HTML!
|
||||
std::shared_ptr<AesBCContamination::ForeignGuiInterface> guiInterface;
|
||||
if (!m_session->getForeignGuiInterface<AesBCContamination::ForeignGuiInterface>(guiInterface) || !guiInterface)
|
||||
return;
|
||||
|
||||
LtsWidgets::LtsDialog *info = guiInterface->showInfoWindow(item);
|
||||
m_ui->mainLayout->addWidget(info);
|
||||
// End Use This
|
||||
}
|
||||
|
||||
} // namespace AreaEffectSimulation
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Info dialog for the items covered by a danger area
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by diers, SLSE, 2017-03-27
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AreaEffectSimulation/logger.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <AreaEffectSimulation/aes.hpp>
|
||||
|
||||
namespace Ui {
|
||||
class DangerAreaAesItemInfo;
|
||||
}
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
namespace Interface
|
||||
{
|
||||
class Ftc;
|
||||
class Dtc;
|
||||
}
|
||||
|
||||
class DangerAreaAesItemInfo : public LtsWidgets::LtsDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DangerAreaAesItemInfo(QWidget *parent = nullptr);
|
||||
~DangerAreaAesItemInfo();
|
||||
|
||||
bool init(const QSet<int> &dangerAreaIds, const QSet<int> &aesItemIds, LtsSession::LtsSession *session = nullptr);
|
||||
|
||||
private:
|
||||
void retranslate() override;
|
||||
void setText();
|
||||
void aesItemInfo(const AesItem *item);
|
||||
|
||||
bool init(LtsSession::LtsSession *session);
|
||||
void insertAesItem(int aesItemId);
|
||||
|
||||
struct AesStruct
|
||||
{
|
||||
AesType type = AesType::AtUnknown;
|
||||
AesItem *item = nullptr;
|
||||
AesStruct(AesType _type, AesItem *_item) : type(_type), item(_item) {}
|
||||
};
|
||||
|
||||
std::shared_ptr<Interface::Dtc> m_dtc;
|
||||
LOGGER_T m_logger;
|
||||
LtsSession::LtsSession *m_session;
|
||||
QMap<int, DangerArea> m_dangerAreas;
|
||||
QMap<int, AesStruct> m_aesItems;
|
||||
Ui::DangerAreaAesItemInfo *m_ui;
|
||||
int m_aesItemId;
|
||||
};
|
||||
|
||||
} // namespace AreaEffectSimulation
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>DangerAreaAesItemInfo</class>
|
||||
<widget class="QWidget" name="DangerAreaAesItemInfo">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Aes Danger Area Info</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="mainLayout"/>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,136 @@
|
||||
/**
|
||||
*@RDE_HEADER@
|
||||
* GUI Plugin for AreaEffectSimulation - Info
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2017-03-23
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
//Lts
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsUtilsGuiDds/request_helper.h>
|
||||
|
||||
//AreaEffectSimulation
|
||||
#include <AreaEffectSimulation/logger.h>
|
||||
|
||||
|
||||
//DDS
|
||||
#include <Plugins/AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class AesInfoDialog;
|
||||
}
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
// --------------------------------------------------------
|
||||
// AESInfoDialog
|
||||
// --------------------------------------------------------
|
||||
class AesInfoDialog : public LtsWidgets::LtsDialog
|
||||
, protected AreaEffectSimulation::Interface::Ftc::MineResetReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AesInfoDialog(int aesEntityId, AreaEffectSimulation::AesType aesType, QWidget *parent = nullptr);
|
||||
~AesInfoDialog();
|
||||
|
||||
bool init(LtsSession::LtsSession *session,
|
||||
const std::shared_ptr<Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<Interface::Ftc> &ftc,
|
||||
const std::shared_ptr<ProjectDataManagement::Interface::Dtc> &pdmDtc);
|
||||
|
||||
void onMineResetReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
|
||||
|
||||
private:
|
||||
void retranslate() override;
|
||||
|
||||
void handleNContamination(const AesItemView &aesItemView);
|
||||
void handleNContamination(const AreaEffectSimulation::NContamination &data);
|
||||
void handleBCContamination(const AesItemView &aesItemView);
|
||||
void handleBCContamination(const AreaEffectSimulation::BCContamination &data);
|
||||
void handleExplosionArea(const AesItemView &aesItemView);
|
||||
void handleExplosionArea(const AreaEffectSimulation::ExplosionArea &data);
|
||||
void handleExplosionSingle(const AesItemView &aesItemView);
|
||||
void handleExplosionSingle(const AreaEffectSimulation::ExplosionSingle &data);
|
||||
void handleMineArea(const AesItemView &aesItemView);
|
||||
void handleMineArea(const AreaEffectSimulation::MineArea &data);
|
||||
void handleMineCorridor(const AesItemView &aesItemView);
|
||||
void handleMineCorridor(const AreaEffectSimulation::MineCorridor &data);
|
||||
void handleBoobyTrap(const AesItemView &aesItemView);
|
||||
void handleBoobyTrap(const AreaEffectSimulation::BoobyTrap &data);
|
||||
void handleOffRouteMine(const AesItemView &aesItemView);
|
||||
void handleOffRouteMine(const AreaEffectSimulation::OffRouteMine &data);
|
||||
void handleGasPipe(const AesItemView &aesItemView);
|
||||
void handleGasPipe(const AreaEffectSimulation::GasPipe &data);
|
||||
void handleDangerArea(const AesItemView &aesItemView);
|
||||
void handleDangerArea(const AreaEffectSimulation::DangerArea &data);
|
||||
void handleBorderline(const AesItemView &aesItemView);
|
||||
void handleBorderline(const AreaEffectSimulation::Borderline &data);
|
||||
void handleFunctionalArea(const AesItemView &aesItemView);
|
||||
void handleFunctionalArea(const AreaEffectSimulation::FunctionalArea &data);
|
||||
void handleAirSupportImpact(const AesItemView &aesItemView);
|
||||
void handleAirSupportImpact(const AreaEffectSimulation::AirSupportImpact &data);
|
||||
void handleMineAraeSingleMine();
|
||||
void handleMineAraeSingleMine(const Core::GeoPosition2D &position, const DusMine &mine);
|
||||
void handleSingleDusMine();
|
||||
void handleExplosionCluster(const AesItemView &aesItemView);
|
||||
void handleExplosionCluster(const AreaEffectSimulation::ExplosionCluster &data);
|
||||
void handleEffectCluster(const AesItemView &aesItemView);
|
||||
void handleEffectCluster(const AreaEffectSimulation::EffectCluster &data);
|
||||
|
||||
bool cbFunc(const AesItemView &aesItemView);
|
||||
|
||||
void handleAesItem(const AesItem &aesData, AesType aesTypeId);
|
||||
|
||||
private Q_SLOTS:
|
||||
void onFindOnMap();
|
||||
void onShowDetails();
|
||||
bool onResetDusMines();
|
||||
|
||||
void onNContaminationChanged(const AreaEffectSimulation::NContamination &data, DataModification modType);
|
||||
void onBCContaminationChanged(const AreaEffectSimulation::BCContamination &data, DataModification modType);
|
||||
void onBoobyTrapChanged(const AreaEffectSimulation::BoobyTrap &data, DataModification modType);
|
||||
void onOffRouteMineChanged(const AreaEffectSimulation::OffRouteMine &data, DataModification modType);
|
||||
void onExplosionAreaChanged(const AreaEffectSimulation::ExplosionArea &data, DataModification modType);
|
||||
void onExplosionSingleChanged(const AreaEffectSimulation::ExplosionSingle &data, DataModification modType);
|
||||
void onMineAreaChanged(const AreaEffectSimulation::MineArea &data, DataModification modType);
|
||||
void onMineCorridorChanged(const AreaEffectSimulation::MineCorridor &data, DataModification modType);
|
||||
void onGasPipeChanged(const GasPipe &data, DataModification modType);
|
||||
void onDangerAreaChanged(const AreaEffectSimulation::DangerArea &data, DataModification modType);
|
||||
void onBorderlineChanged(const AreaEffectSimulation::Borderline &data, DataModification modType);
|
||||
void onFunctionalAreaChanged(const AreaEffectSimulation::FunctionalArea &data, DataModification modType);
|
||||
void onAirSupportImpactChanged(const AirSupportImpact &data, DataModification modType);
|
||||
void onDusMineStateChanged(const DusMineState &data, DataModification modType);
|
||||
void onDusSingleMineChanged(const DusSingleMine &data, DataModification modType);
|
||||
void onExplosionClusterChanged(const ExplosionCluster &data, DataModification modType);
|
||||
void onEffectClusterChanged(const EffectCluster &data, DataModification modType);
|
||||
|
||||
private:
|
||||
int m_aesEntityId;
|
||||
QString m_aesEntityName;
|
||||
AreaEffectSimulation::AesType m_aesType;
|
||||
ProjectDataManagement::EffectSource m_aesEffectSource;
|
||||
int m_bcChargeTypeId;
|
||||
int m_singleExpChargeTypeId;
|
||||
int m_areaExpChargeTypeId;
|
||||
bool m_mineIsReactivatable;
|
||||
|
||||
LtsSession::LtsSession *m_session;
|
||||
std::shared_ptr<Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<Interface::Ftc> m_ftc;
|
||||
std::shared_ptr<ProjectDataManagement::Interface::Dtc> m_pdmDtc;
|
||||
|
||||
|
||||
Ui::AesInfoDialog* m_ui;
|
||||
LtsUtils::RequestHelper *m_requestHelper;
|
||||
LOGGER_T m_logger;
|
||||
};
|
||||
} // namespace AreaEffectSimulation
|
||||
@@ -0,0 +1,408 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>AesInfoDialog</class>
|
||||
<widget class="QWidget" name="AesInfoDialog">
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Aes Info</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="6" column="0">
|
||||
<widget class="LtsWidgets::LtsElidedLabel" name="lbAesStart">
|
||||
<property name="text">
|
||||
<string>AES Start:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="LtsWidgets::LtsElidedLabel" name="lbAesType">
|
||||
<property name="text">
|
||||
<string>AES Type:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="LtsWidgets::LtsElidedLabel" name="lbAesName">
|
||||
<property name="text">
|
||||
<string>AES Name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="1">
|
||||
<widget class="QLabel" name="lblChargeTypeId">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"><CHARGETYPEID></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<widget class="QLabel" name="lblAesDuration">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"><AESDURATION></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="LtsWidgets::LtsElidedLabel" name="lbAesTypeId">
|
||||
<property name="text">
|
||||
<string>AES Type Id:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLabel" name="lblAesItemId">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"><AESITEMID></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="QLabel" name="lblAesStart">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"><AESSTART></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="12" column="0" colspan="2">
|
||||
<widget class="QLabel" name="lblPosition">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"><POSITION></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<widget class="LtsWidgets::LtsElidedLabel" name="lbFlightTime">
|
||||
<property name="text">
|
||||
<string>Flight Time:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="0">
|
||||
<widget class="LtsWidgets::LtsElidedLabel" name="lbStatus">
|
||||
<property name="text">
|
||||
<string>Status:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLabel" name="lblAesTypeId">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"><AESTYPEID></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="1">
|
||||
<widget class="QLabel" name="lblStatus">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"><STATUS></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="0">
|
||||
<widget class="LtsWidgets::LtsElidedLabel" name="lbChargeTypeId">
|
||||
<property name="text">
|
||||
<string>Charge Type Id:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="13" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QToolButton" name="pbFindOnMap">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Find on map</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../Styles/Light/resources/rme_light_style.qrc">
|
||||
<normaloff>:/style/center_to_object.svg</normaloff>:/style/center_to_object.svg</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="pbDetails">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Show details</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../Styles/Light/resources/rme_light_style.qrc">
|
||||
<normaloff>:/style/pi_tact_status_history.svg</normaloff>:/style/pi_tact_status_history.svg</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="autoRepeatInterval">
|
||||
<number>100</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="pbResetDusMines">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Reset DUS Mines matched to this Minearea</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../Styles/Light/resources/rme_light_style.qrc">
|
||||
<normaloff>:/style/mine_barriers.svg</normaloff>:/style/mine_barriers.svg</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="14" column="1">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QLabel" name="lblAesType">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"><AESTYPE></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="LtsWidgets::LtsElidedLabel" name="lbAesDuration">
|
||||
<property name="text">
|
||||
<string>AES Duration:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="11" column="1">
|
||||
<widget class="QLabel" name="lblChargeType">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"><CHARGETYPE></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="1">
|
||||
<widget class="QLabel" name="lblFlightTime">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"><FLIGHTTIME></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lblIcon">
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="LtsWidgets::LtsElidedLabel" name="lbAesItemId">
|
||||
<property name="text">
|
||||
<string>AES Item Id:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QLabel" name="lblAesName">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"><AESNAME></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="LtsWidgets::LtsElidedLabel" name="lbAesId">
|
||||
<property name="text">
|
||||
<string notr="true">AES Id:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="lblAesId">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"><AESID></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="11" column="0">
|
||||
<widget class="LtsWidgets::LtsElidedLabel" name="lbChargeType">
|
||||
<property name="text">
|
||||
<string>Charge Type:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LtsWidgets::LtsElidedLabel</class>
|
||||
<extends>QLabel</extends>
|
||||
<header>LtsWidgets/lts_elided_label.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>pbResetDusMines</tabstop>
|
||||
<tabstop>pbFindOnMap</tabstop>
|
||||
<tabstop>pbDetails</tabstop>
|
||||
</tabstops>
|
||||
<resources>
|
||||
<include location="../../../Styles/Light/resources/rme_light_style.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,109 @@
|
||||
/**
|
||||
*@RDE_HEADER@
|
||||
* Gui Plugin for AreaEffectSimulation - Info
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2017-03-22
|
||||
*/
|
||||
|
||||
#include "aes_info_gui_plugin.h"
|
||||
#include "aes_info_dialog.h"
|
||||
#include "aes_danger_area_aes_item_info.h"
|
||||
#include "aes_charge_effect_item_info.h"
|
||||
|
||||
#include <LtsSession/lts_session.h>
|
||||
|
||||
#include <AreaEffectSimulation/logger.h>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
std::shared_ptr<GuiPluginBase::Interface> GuiPlugin::createGuiInterface(LtsSession::LtsSession *session)
|
||||
{
|
||||
return std::make_shared<InterfaceImpl>(session);
|
||||
} // end of createGuiInterface()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
InterfaceImpl::InterfaceImpl(LtsSession::LtsSession *session)
|
||||
: GuiPluginBase::Interface(session, getLogger("AESInfo"))
|
||||
, m_dtc(nullptr)
|
||||
, m_pdmDtc(nullptr)
|
||||
{} // end of ctor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool InterfaceImpl::fetchInterfaces()
|
||||
{
|
||||
if (!m_session->getDtc<AreaEffectSimulation::DataInterface>(m_dtc))
|
||||
return false;
|
||||
if (!m_session->getFtc<AreaEffectSimulation::DataInterface>(m_ftc))
|
||||
return false;
|
||||
if (!m_session->getDtc<ProjectDataManagement::DataInterface>(m_pdmDtc))
|
||||
return false;
|
||||
return true;
|
||||
} // end of fetchInterfaces()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void InterfaceImpl::clearInterfaces()
|
||||
{
|
||||
m_pdmDtc = nullptr;
|
||||
m_dtc = nullptr;
|
||||
m_ftc = nullptr;
|
||||
} // end of clearInterfaces()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
QString InterfaceImpl::menuGroup() const
|
||||
{
|
||||
return QStringLiteral("AES Info");
|
||||
} // end of menuGroup()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
QVector<LtsWidgets::PluginData> InterfaceImpl::getActions()
|
||||
{
|
||||
return {};
|
||||
} // end of getActions()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void InterfaceImpl::showInfoWindow(const QVector<int> &aesEntityIds, AreaEffectSimulation::AesType aesType)
|
||||
{
|
||||
for (auto id : aesEntityIds)
|
||||
this->showInfoWindow(id, aesType);
|
||||
}
|
||||
|
||||
void InterfaceImpl::showInfoWindow(int aesEntityId, AesType aesType)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "ShowInfoWindow() "
|
||||
<< " aesEntityId: " << aesEntityId;
|
||||
|
||||
AesInfoDialog *dialog = new AesInfoDialog(aesEntityId, aesType);
|
||||
if (!dialog->init(m_session, m_dtc, m_ftc, m_pdmDtc))
|
||||
{
|
||||
delete dialog;
|
||||
return;
|
||||
}
|
||||
|
||||
m_session->addWidget(dialog, menuGroup(), QStringLiteral("AesInfo%1").arg(aesEntityId), LtsWidgets::LayoutArea::eInfoTab);
|
||||
} // end of showInfoWindow()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
LtsWidgets::LtsDialog* InterfaceImpl::showDangerAreaAesItemInfo(const QSet<int> &dangerAreaIds, const QSet<int> &aesItemIds)
|
||||
{
|
||||
return LtsWidgets::initDialog(new DangerAreaAesItemInfo,
|
||||
dangerAreaIds, aesItemIds, m_session);
|
||||
}// end of showDangerAreaAesItemInfo()
|
||||
|
||||
void InterfaceImpl::showChargeEffectInfoWindow(int chargeEffectId)
|
||||
{
|
||||
AesChargeEffectItemInfo *dialog = new AesChargeEffectItemInfo(chargeEffectId);
|
||||
if (!dialog->init(m_session))
|
||||
{
|
||||
delete dialog;
|
||||
return;
|
||||
}
|
||||
m_session->addWidget(dialog, menuGroup(), QStringLiteral("AesInfo%1").arg(chargeEffectId), LtsWidgets::LayoutArea::eInfoTab);
|
||||
|
||||
} // end of showChargeEffectInfoWindow
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
} // namespace AreaEffectSimulation
|
||||
@@ -0,0 +1,70 @@
|
||||
/**
|
||||
*@RDE_HEADER@
|
||||
* Gui Plugin for AreaEffectSimulation - Info
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2017-03-22
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AreaEffectSimulation/logger.h>
|
||||
|
||||
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/aes_info_gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
|
||||
|
||||
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
class GuiPlugin final : public QObject, public GuiPluginBase::Plugin
|
||||
{
|
||||
Q_PLUGIN_METADATA(IID "gui:3:aes.info")
|
||||
Q_INTERFACES(GuiPluginBase::Plugin)
|
||||
|
||||
Q_OBJECT
|
||||
public:
|
||||
GuiPlugin() = default;
|
||||
~GuiPlugin() = default;
|
||||
|
||||
QString pluginName() override { return QLatin1String("AreaEffectSimulationInfoGui"); }
|
||||
std::shared_ptr<GuiPluginBase::Interface> createGuiInterface(LtsSession::LtsSession *session) override;
|
||||
bool availableInPartition(IDL::PartitionType partition) const override
|
||||
{
|
||||
return partition == IDL::PartitionType::Exercise ||
|
||||
partition == IDL::PartitionType::Replay;
|
||||
}
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class InterfaceImpl final : public QObject, public ForeignInfoGuiInterface, public GuiPluginBase::Interface
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit InterfaceImpl(LtsSession::LtsSession *session);
|
||||
|
||||
QVector<LtsWidgets::PluginData> getActions() override;
|
||||
bool fetchInterfaces() override;
|
||||
void clearInterfaces() override;
|
||||
QString menuGroup() const override;
|
||||
bool availableInPartition(IDL::PartitionType partition) const override { return partition == IDL::PartitionType::Exercise; }
|
||||
|
||||
// ForeignDataInterface
|
||||
void showInfoWindow(const QVector<int> &aesEntityIds, AreaEffectSimulation::AesType aesType) override;
|
||||
void showInfoWindow(int aesEntityId, AreaEffectSimulation::AesType aesType) override;
|
||||
LtsWidgets::LtsDialog* showDangerAreaAesItemInfo(const QSet<int> &dangerAreaIds, const QSet<int> &aesItemIds) override;
|
||||
virtual void showChargeEffectInfoWindow(int chargeEffectId) override;
|
||||
|
||||
private:
|
||||
std::shared_ptr<AreaEffectSimulation::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<AreaEffectSimulation::Interface::Ftc> m_ftc;
|
||||
std::shared_ptr<ProjectDataManagement::Interface::Dtc> m_pdmDtc;
|
||||
};
|
||||
|
||||
} // namespace AreaEffectSimulation
|
||||
@@ -0,0 +1,56 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
# Created by hjl, SLSE, 2017-06-06
|
||||
#
|
||||
|
||||
ADD_INTERFACE_LIBRARY(
|
||||
AesAirSupportGuiPluginInterface
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/aes_air_support_gui_plugin_interface.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/..
|
||||
)
|
||||
|
||||
|
||||
SET(aes_air_support_impact_gui_SRCS
|
||||
aes_air_support_gui_plugin.h
|
||||
aes_air_support_gui_plugin.cpp
|
||||
aes_air_support_9liner_list.h
|
||||
aes_air_support_9liner_list.cpp
|
||||
aes_air_support_9liner_model.h
|
||||
aes_air_support_9liner_model.cpp
|
||||
aes_air_support_impact_list.h
|
||||
aes_air_support_impact_list.cpp
|
||||
aes_air_support_impact_model.h
|
||||
aes_air_support_impact_model.cpp
|
||||
CustomView/aes_air_support_impact.h
|
||||
CustomView/aes_air_support_impact.cpp
|
||||
)
|
||||
|
||||
NGL_WRAP_UI(aes_air_support_impact_gui_SRCS
|
||||
aes_air_support_9liner_list.ui
|
||||
CustomView/aes_air_support_impact.ui
|
||||
)
|
||||
|
||||
NGL_ADD_LIBRARY(WS AesAirSupportGuiPlugin MODULE ${aes_air_support_impact_gui_SRCS})
|
||||
NGL_TARGET_LINK_LIBRARIES(AesAirSupportGuiPlugin
|
||||
AesBaseGui
|
||||
AesAirSupportGuiPluginInterface
|
||||
AesDataPluginInterface
|
||||
AesInfoGuiPluginInterface
|
||||
AesEffectClusterModel
|
||||
GnaDataPluginInterface
|
||||
LtsWidgets
|
||||
LtsSession
|
||||
LtsSessionData
|
||||
LtsDataView
|
||||
LtsUtilsGuiDds
|
||||
LtsUtilsSettings
|
||||
NGLLogger
|
||||
ngltools
|
||||
PpmDataPluginInterface
|
||||
SituationMapGuiPluginInterface
|
||||
Qt5::Widgets
|
||||
)
|
||||
|
||||
NGL_INSTALL_TARGET(AesAirSupportGuiPlugin)
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* CustomView for AES Explosion
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Mike Wille, SLSE, 2016-04-08
|
||||
*/
|
||||
|
||||
#include "aes_air_support_impact.h"
|
||||
#include "ui_aes_air_support_impact.h"
|
||||
|
||||
#include <Services/AreaEffectSimulation/Utils/polygons.h>
|
||||
#include <ProjectDataManagement/pdm_data_plugin_interface.h>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
CustomViewAirSupportImpact::CustomViewAirSupportImpact(LtsSession::LtsSession *session, QWidget *parent)
|
||||
: AbstractDisplayWidget(parent)
|
||||
, m_session(session)
|
||||
, m_ui(new Ui::CustomViewAirSupportImpact)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
}
|
||||
|
||||
CustomViewAirSupportImpact::~CustomViewAirSupportImpact()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
bool CustomViewAirSupportImpact::init(const QModelIndex &idx)
|
||||
{
|
||||
if (!idx.isValid())
|
||||
return false;
|
||||
|
||||
m_ui->lbName->setText(rowData(idx, AreaEffectSimulation::AirSupportImpactModel::BcName).toString());
|
||||
m_ui->lbEffectState->setText(rowData(idx, AreaEffectSimulation::AirSupportImpactModel::BcEffectState).toString());
|
||||
m_ui->lbEffectStart->setText(rowData(idx, AreaEffectSimulation::AirSupportImpactModel::BcEffectStart).toString());
|
||||
m_ui->lbChargeType->setText(rowData(idx, AreaEffectSimulation::AirSupportImpactModel::BcChargeType).toString());
|
||||
|
||||
QString durationString = rowData(idx, AreaEffectSimulation::AirSupportImpactModel::BcEffectDuration).toString();
|
||||
if (!durationString.isEmpty() && durationString != QLatin1String("0"))
|
||||
{
|
||||
m_ui->lbEffectDuration->setText(durationString);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ui->label_4->hide();
|
||||
m_ui->lbEffectDuration->hide();
|
||||
m_ui->label_6->hide();
|
||||
}
|
||||
m_ui->lblIcon->clear();
|
||||
m_ui->lblIcon->setAutoFillBackground(true);
|
||||
|
||||
const AesItemSortFilterProxyModel *sfpm = qobject_cast<const AesItemSortFilterProxyModel*>(idx.model());
|
||||
if (!sfpm)
|
||||
return false;
|
||||
const AirSupportImpactModel *aesModel = qobject_cast<const AirSupportImpactModel*>(sfpm->sourceModel());
|
||||
if (!aesModel)
|
||||
return false;
|
||||
const auto srcIdx = sfpm->mapToSource(idx);
|
||||
AirSupportImpact asi = aesModel->getRowData(srcIdx.row());
|
||||
calculateIcon(asi, sfpm->partyColor(idx.row()));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CustomViewAirSupportImpact::calculateIcon(const AirSupportImpact &asi, const QColor &color)
|
||||
{
|
||||
Database::AesAirSupportImpact dbAsi;
|
||||
dbAsi.impactPosition = QPointF(asi.impactPosition().lon(), asi.impactPosition().lat());
|
||||
|
||||
std::shared_ptr<ProjectDataManagement::Interface::Dtc> pdmDtc;
|
||||
if (!m_session->getDtc<ProjectDataManagement::DataInterface>(pdmDtc))
|
||||
return false;
|
||||
|
||||
double radius = pdmDtc->impactRadius(asi.chargeStruct().chargeTypeId(),
|
||||
asi.chargeStruct().igniterTypeId(),
|
||||
asi.chargeStruct().igniterFunctionId());
|
||||
QPolygonF poly = AreaEffectSimulation::Polygons::airSupportImpact(dbAsi, radius);
|
||||
Qt::BrushStyle bStyle = PixmapLabel::checkForBrushStyle(asi.effectStateId());
|
||||
const auto pix = Polygons::pixmapFromPolygon(PixmapLabel::geographic2Utm(poly), color, ICON_RESOLUTION, bStyle);
|
||||
m_ui->lblIcon->setPixmap(pix);
|
||||
|
||||
return true;
|
||||
}
|
||||
} // namespace AreaEffectSimulation
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* CustomView for AES Explosion
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Mike Wille, SLSE, 2016-04-08
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <Viewer/LtsDataView/abstract_display_widget.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
|
||||
#include "aes_air_support_impact_model.h"
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class CustomViewAirSupportImpact;
|
||||
}
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
class CustomViewAirSupportImpact final : public LtsDataView::AbstractDisplayWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CustomViewAirSupportImpact(LtsSession::LtsSession *session, QWidget *parent = nullptr);
|
||||
~CustomViewAirSupportImpact();
|
||||
bool init(const QModelIndex &idx) override final;
|
||||
|
||||
private:
|
||||
bool calculateIcon(const AreaEffectSimulation::AirSupportImpact &single, const QColor &color);
|
||||
|
||||
LtsSession::LtsSession *m_session;
|
||||
Ui::CustomViewAirSupportImpact *m_ui;
|
||||
|
||||
};
|
||||
} // namespace AreaEffectSimulation
|
||||
+178
@@ -0,0 +1,178 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CustomViewAirSupportImpact</class>
|
||||
<widget class="QWidget" name="CustomViewAirSupportImpact">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>350</width>
|
||||
<height>200</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"/>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="lbName">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">Name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbChargeType">
|
||||
<property name="font">
|
||||
<font>
|
||||
<italic>true</italic>
|
||||
</font>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">Type</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>State:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbEffectState">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">State</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="AreaEffectSimulation::PixmapLabel" name="lblIcon">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">icon</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="lbEffectStart">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">Time</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">for</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbEffectDuration">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">Duration</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>seconds</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>AreaEffectSimulation::PixmapLabel</class>
|
||||
<extends>QLabel</extends>
|
||||
<header>AreaEffectSimulation/Gui/Base/aes_pixmap_label.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for AreaEffectSimulation - AirSupportImpact Overview Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by ehrlicher, NLE, 2019-09-16
|
||||
*/
|
||||
|
||||
#include "aes_air_support_9liner_list.h"
|
||||
#include "aes_air_support_9liner_model.h"
|
||||
#include "ui_aes_air_support_9liner_list.h"
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
AirSupport9LinerList::AirSupport9LinerList(QWidget *parent)
|
||||
: LtsDialog(parent)
|
||||
, m_airSupport9LinerProxyModel(new AirSupport9LinerProxyModel(this))
|
||||
, m_airSupport9LinerModel(new AirSupport9LinerModel(this))
|
||||
, m_ui(new Ui::AirSupport9LinerList)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_airSupport9LinerProxyModel->setSourceModel(m_airSupport9LinerModel);
|
||||
m_ui->widget->setModel(m_airSupport9LinerProxyModel);
|
||||
|
||||
#ifndef LTS_DEBUG
|
||||
m_ui->widget->hideColumn(AirSupport9LinerModel::ParticipantId);
|
||||
#endif
|
||||
m_ui->widget->setSortIndicator(AirSupport9LinerModel::Participant, Qt::AscendingOrder);
|
||||
|
||||
QCheckBox *cbExpired = new QCheckBox(tr("Show expired"), m_ui->widget);
|
||||
cbExpired->setProperty("const", true);
|
||||
m_ui->widget->setCustomWidget(cbExpired);
|
||||
connect(cbExpired, &QCheckBox::toggled,
|
||||
m_airSupport9LinerProxyModel, &AirSupport9LinerProxyModel::setShowExpired);
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Aerial_Ordnance_9-Liner")); // since 2022-03-01: guez_online_help_de-1.1-11.noarch
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
AirSupport9LinerList::~AirSupport9LinerList()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool AirSupport9LinerList::init(LtsSession::LtsSession *session)
|
||||
{
|
||||
if (!m_airSupport9LinerModel->initModel(session))
|
||||
return false;
|
||||
if (m_airSupport9LinerProxyModel)
|
||||
m_airSupport9LinerProxyModel->setSession(session); // setSession to enable filtering (showExpired)
|
||||
return true;
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void AirSupport9LinerList::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("Air Support 9-Liner"));
|
||||
}
|
||||
|
||||
void AirSupport9LinerList::tableColumnOrganiserSetting()
|
||||
{
|
||||
//LtsColumnOrganiser
|
||||
m_ui->widget->setColumnsOrganiserEnabled(identifier(), true);
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
} // namespace AreaEffectSimulation
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for AreaEffectSimulation - AirSupportImpact Overview Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by ehrlicher, NLE, 2019-09-16
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Plugins/AreaEffectSimulation/Gui/Base/aes_itemlist.h>
|
||||
#include <Plugins/AreaEffectSimulation/Gui/Base/aes_base_model.h>
|
||||
#include "aes_air_support_9liner_model.h"
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class AirSupport9LinerList;
|
||||
}
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
class AirSupport9LinerList final : public LtsWidgets::LtsDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AirSupport9LinerList(QWidget *parent = nullptr);
|
||||
~AirSupport9LinerList();
|
||||
|
||||
bool init(LtsSession::LtsSession *session);
|
||||
|
||||
private:
|
||||
void retranslate() override;
|
||||
void tableColumnOrganiserSetting() override;
|
||||
private:
|
||||
AirSupport9LinerProxyModel *m_airSupport9LinerProxyModel = nullptr;
|
||||
AirSupport9LinerModel *m_airSupport9LinerModel = nullptr;
|
||||
Ui::AirSupport9LinerList *m_ui = nullptr;
|
||||
};
|
||||
}
|
||||
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>AirSupport9LinerList</class>
|
||||
<widget class="QWidget" name="AirSupport9LinerList">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>600</width>
|
||||
<height>500</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">AirSupport9LinerList</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="LtsDataView::LtsDataView" name="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>
|
||||
+183
@@ -0,0 +1,183 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for AreaEffectSimulation - AirSupportImpact Overview Dialog Model
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by ehrlicher, NLE, 2019-09-16
|
||||
*/
|
||||
|
||||
#include "aes_air_support_9liner_model.h"
|
||||
#include <GuezNasat/gna_data_plugin_interface.h>
|
||||
#include <ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
#include <ngltools/ngltools_dtg.h>
|
||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||
#include <LtsUtilsCore/variant_operators.h>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
AirSupport9LinerModel::AirSupport9LinerModel(QObject *parent)
|
||||
: LtsWidgets::LtsAbstractTableModel<GuezNasat::Nasat9Liner>({
|
||||
tr("ParticipantId"),
|
||||
tr("Participant"),
|
||||
tr("Timestamp"),
|
||||
tr("Attack Heading"),
|
||||
tr("Target Position")},
|
||||
parent)
|
||||
{
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool AirSupport9LinerModel::initModel(LtsSession::LtsSession *session)
|
||||
{
|
||||
if (!session->getDtc<GuezNasat::DataInterface>(m_gnaDtc))
|
||||
return false;
|
||||
|
||||
session->getDtc<ParticipantManagement::DataInterface>(m_ppmDtc);
|
||||
|
||||
connect(m_gnaDtc.get(), &GuezNasat::Interface::Dtc::nasat9LinerChanged,
|
||||
this, &AirSupport9LinerModel::onDataChanged);
|
||||
m_gnaDtc->nasat9Liners([this](const GuezNasat::Nasat9Liner &item) { insertRow(item); });
|
||||
|
||||
return true;
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
QVariant AirSupport9LinerModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (role != Qt::DisplayRole || !indexIsValid(index))
|
||||
return QVariant();
|
||||
|
||||
const GuezNasat::Nasat9Liner &item = m_vecData.at(index.row());
|
||||
|
||||
switch (index.column())
|
||||
{
|
||||
case ParticipantId:
|
||||
return item.participantId();
|
||||
case Participant:
|
||||
{
|
||||
if (!m_ppmDtc)
|
||||
return QString();
|
||||
return m_ppmDtc->hierarchyFromParticipant(item.participantId());
|
||||
}
|
||||
case Timestamp:
|
||||
return QDateTime::fromMSecsSinceEpoch(item.sampleTime());
|
||||
case AttackHeading:
|
||||
{
|
||||
if (item.finalAttackHeading() < 0)
|
||||
return QVariant();
|
||||
if (item.finalAttackHeadingHigh() < 0)
|
||||
return tr("%1 degree")
|
||||
.arg(item.finalAttackHeading());
|
||||
return tr("%1 degree (low: %2 degree, high: %3 degreee)", "degree as symbol!")
|
||||
.arg(item.finalAttackHeading())
|
||||
.arg(item.finalAttackHeadingLow())
|
||||
.arg(item.finalAttackHeadingHigh());
|
||||
}
|
||||
case TargetPosition:
|
||||
{
|
||||
if (std::isnan(item.targetPosition().lat()))
|
||||
return tr("---");
|
||||
LtsCoordTrans::UtmCoordinate coord(LtsCoordTrans::UtmCoordinate::fromGeographic(item.targetPosition().lon(),
|
||||
item.targetPosition().lat()));
|
||||
QString ret = coord.mgrs();
|
||||
if (item.targetPosition().z() > 0)
|
||||
ret += QLatin1Char(' ') + QString::number(qRound(item.targetPosition().z()));
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//
|
||||
// AirSupport9LinerProxyModel
|
||||
//
|
||||
void AirSupport9LinerProxyModel::setSession(LtsSession::LtsSession *session)
|
||||
{
|
||||
m_session = session;
|
||||
invalidateFilter();
|
||||
}
|
||||
|
||||
void AirSupport9LinerProxyModel::setShowExpired(bool bShow)
|
||||
{
|
||||
if (bShow == m_showExpired)
|
||||
return;
|
||||
m_showExpired = bShow;
|
||||
invalidateFilter();
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void AirSupport9LinerProxyModel::setSourceModel(QAbstractItemModel *model)
|
||||
{
|
||||
m_model = qobject_cast<AirSupport9LinerModel*>(model);
|
||||
LtsWidgets::LtsColumnFilterProxyModel::setSourceModel(model);
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool AirSupport9LinerProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
|
||||
{
|
||||
if (!m_model || source_parent.isValid() || source_row < 0 || source_row >= m_model->m_vecData.size())
|
||||
return LtsWidgets::LtsColumnFilterProxyModel::filterAcceptsRow(source_row, source_parent);
|
||||
|
||||
if (m_showExpired)
|
||||
return true;
|
||||
const auto &data = m_model->m_vecData.at(source_row);
|
||||
|
||||
// GUEZE-1676: Nineliner sollen zeitlich wie Trefferlinien angezeigt werden
|
||||
// isCurrent(); is outdated
|
||||
// return data.isCurrent();
|
||||
|
||||
// Expired. Show only if younger than m_offset
|
||||
if (!m_session)
|
||||
return true;
|
||||
|
||||
const qint64 m_offset = 5 * 60 * 1000; // default: 5 minutes, same as default at AES (AesItemSortFilterProxyModel at aes_base_model.cpp)
|
||||
if ((data.sampleTime() + m_offset) > m_session->partitionTime())
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool AirSupport9LinerProxyModel::lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const
|
||||
{
|
||||
if (!m_model || source_left.parent() != source_right.parent() || source_left.column() != source_right.column())
|
||||
return LtsWidgets::LtsColumnFilterProxyModel::lessThan(source_left, source_right);
|
||||
if (source_left.row() < 0 || source_left.row() >= m_model->m_vecData.size() ||
|
||||
source_right.row() < 0 || source_right.row() >= m_model->m_vecData.size())
|
||||
return LtsWidgets::LtsColumnFilterProxyModel::lessThan(source_left, source_right);
|
||||
|
||||
const auto &left = m_model->m_vecData.at(source_left.row());
|
||||
const auto &right = m_model->m_vecData.at(source_right.row());
|
||||
switch (source_left.column())
|
||||
{
|
||||
case AirSupport9LinerModel::ParticipantId:
|
||||
if (left.participantId() != right.participantId())
|
||||
return left.participantId() < right.participantId();
|
||||
return left.sampleTime() < right.sampleTime();
|
||||
case AirSupport9LinerModel::Participant:
|
||||
{
|
||||
const auto l = source_left.data();
|
||||
const auto r = source_right.data();
|
||||
if (l != r)
|
||||
return LtsUtils::lessThan(l, r);
|
||||
return left.sampleTime() < right.sampleTime();
|
||||
}
|
||||
case AirSupport9LinerModel::Timestamp:
|
||||
return left.sampleTime() < right.sampleTime();
|
||||
case AirSupport9LinerModel::AttackHeading:
|
||||
if (left.finalAttackHeading() != right.finalAttackHeading())
|
||||
return left.finalAttackHeading() < right.finalAttackHeading();
|
||||
if (left.finalAttackHeadingLow() != right.finalAttackHeadingLow())
|
||||
return left.finalAttackHeadingLow() < right.finalAttackHeadingLow();
|
||||
if (left.finalAttackHeadingHigh() != right.finalAttackHeadingHigh())
|
||||
return left.finalAttackHeadingHigh() < right.finalAttackHeadingHigh();
|
||||
return left.sampleTime() < right.sampleTime();
|
||||
}
|
||||
return LtsWidgets::LtsColumnFilterProxyModel::lessThan(source_left, source_right);
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
} // namespace AreaEffectSimulation
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for AreaEffectSimulation - AirSupportImpact Overview Dialog Model
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by ehrlicher, NLE, 2019-09-16
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
#include <LtsWidgets/lts_column_filter_proxy_model.h>
|
||||
#include <GuezNasat/gna_dtc.h>
|
||||
#include <ParticipantManagement/ppm_dtc.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <QSortFilterProxyModel>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
class AirSupport9LinerModel final : public LtsWidgets::LtsAbstractTableModel<GuezNasat::Nasat9Liner>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum Columns
|
||||
{
|
||||
ParticipantId,
|
||||
Participant,
|
||||
Timestamp,
|
||||
AttackHeading,
|
||||
TargetPosition,
|
||||
};
|
||||
explicit AirSupport9LinerModel(QObject *parent = nullptr);
|
||||
|
||||
bool initModel(LtsSession::LtsSession *session);
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
private:
|
||||
std::shared_ptr<GuezNasat::Interface::Dtc> m_gnaDtc;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
friend class AirSupport9LinerProxyModel;
|
||||
};
|
||||
|
||||
class AirSupport9LinerProxyModel final : public LtsWidgets::LtsColumnFilterProxyModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
using LtsWidgets::LtsColumnFilterProxyModel::LtsColumnFilterProxyModel;
|
||||
|
||||
void setSession(LtsSession::LtsSession *session);
|
||||
void setShowExpired(bool bShow);
|
||||
|
||||
void setSourceModel(QAbstractItemModel *model) override;
|
||||
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;
|
||||
bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const override;
|
||||
private:
|
||||
AirSupport9LinerModel *m_model{nullptr};
|
||||
LtsSession::LtsSession *m_session{nullptr};
|
||||
bool m_showExpired = false;
|
||||
};
|
||||
} //namespace AreaEffectSimulation
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Gui Plugin for AreaEffectSimulation - AirSupport
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by ehrlicher, NLE, 2019-09-16
|
||||
*/
|
||||
|
||||
#include "aes_air_support_gui_plugin.h"
|
||||
#include "aes_air_support_9liner_list.h"
|
||||
#include "aes_air_support_impact_list.h"
|
||||
//#include <Plugins/AreaEffectSimulation/Gui/Explosion/aes_explosion_list.h>
|
||||
|
||||
|
||||
#include <AreaEffectSimulation/aes_operator_rights.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsUtilsSettings/settings.h>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
std::shared_ptr<GuiPluginBase::Interface> GuiPlugin::createGuiInterface(LtsSession::LtsSession *session)
|
||||
{
|
||||
return std::make_shared<InterfaceImpl>(session);
|
||||
} // end of createGuiInterface()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
InterfaceImpl::InterfaceImpl(LtsSession::LtsSession *session)
|
||||
: AesBaseInterface(session, getLogger("Plugins.Gui.AirSupport"))
|
||||
, ForeignGuiInterface()
|
||||
{
|
||||
} // end of ctor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
QVector<LtsWidgets::PluginData> InterfaceImpl::getActions()
|
||||
{
|
||||
QVector<LtsWidgets::PluginData> ret;
|
||||
|
||||
LtsUtils::ProjectSettings *ps = LtsUtils::ProjectSettings::getInstance();
|
||||
const bool enableAirSupport = ps->value(QStringLiteral("aes"),
|
||||
QStringLiteral("enableAirSupport")).toBool();
|
||||
|
||||
if (!enableAirSupport)
|
||||
return ret;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
std::shared_ptr<GuezNasat::Interface::Dtc> gnaDtc;
|
||||
m_session->getDtc<GuezNasat::DataInterface>(gnaDtc);
|
||||
if (gnaDtc)
|
||||
{
|
||||
ret.append(LtsWidgets::PluginData(menuGroup(),
|
||||
tr("Air Support 9-Liner"),
|
||||
QStringLiteral("ListAirSupport9Liner"),
|
||||
QIcon(QStringLiteral("icon:nasat_nine_liner.svg")),
|
||||
[this](QWidget *parent) {
|
||||
return LtsWidgets::initDialog(new AirSupport9LinerList(parent), m_session);
|
||||
},
|
||||
OperatorRights::AirSupportShow,
|
||||
LtsWidgets::ExercisePart::eExecution));
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// old: AirSupportImpactList
|
||||
// ret.append(LtsWidgets::PluginData(menuGroup(),
|
||||
// tr("Air Support ImpactsOLD"),
|
||||
// QStringLiteral("ListAirSupportImpactsOLD"),
|
||||
// QIcon(QStringLiteral("icon:aes_airsupportimpacts.svg")),
|
||||
// [this](QWidget *parent) {
|
||||
// return LtsWidgets::initDialog(new AirSupportImpactList(menuGroup(), parent), m_session);
|
||||
// },
|
||||
// OperatorRights::AirSupportShow,
|
||||
// LtsWidgets::ExercisePart::eExecution));
|
||||
|
||||
// new : AirSupportExplosionClusterImpactList
|
||||
ret.append(LtsWidgets::PluginData(menuGroup(),
|
||||
tr("Air Support Impacts (ExCluster"),
|
||||
QStringLiteral("ListAirSupportImpactsNEW"),
|
||||
QIcon(QStringLiteral("icon:aes_airsupportimpacts.svg")),
|
||||
[this](QWidget *parent) {
|
||||
return LtsWidgets::initDialog(new AirSupportExplosionClusterImpactList(menuGroup(), parent), m_session);
|
||||
},
|
||||
OperatorRights::AirSupportShow,
|
||||
LtsWidgets::ExercisePart::eExecution));
|
||||
|
||||
return ret;
|
||||
} // end of getActions()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
} // namespace AreaEffectSimulation
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Gui Plugin for AreaEffectSimulation - AirSupport
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by ehrlicher, NLE, 2019-09-16
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Plugins/AreaEffectSimulation/Gui/Base/aes_base_gui_plugin.h>
|
||||
#include <GuezNasat/gna_data_plugin_interface.h>
|
||||
#include "aes_air_support_gui_plugin_interface.h"
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
class GuiPlugin final : public AesBaseGuiPlugin
|
||||
{
|
||||
Q_PLUGIN_METADATA(IID "gui:3:aes.airsupport")
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GuiPlugin() = default;
|
||||
~GuiPlugin() = default;
|
||||
QString pluginName() override { return QLatin1String("AreaEffectSimulationAirSupportGui"); }
|
||||
std::shared_ptr<GuiPluginBase::Interface> createGuiInterface(LtsSession::LtsSession *session) override;
|
||||
bool availableInPartition(IDL::PartitionType partition) const override
|
||||
{
|
||||
return partition == IDL::PartitionType::Exercise ||
|
||||
partition == IDL::PartitionType::Replay;
|
||||
}
|
||||
};
|
||||
|
||||
class InterfaceImpl final : public AesBaseInterface, public AesAirSupport::ForeignGuiInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit InterfaceImpl(LtsSession::LtsSession *session);
|
||||
|
||||
QVector<LtsWidgets::PluginData> getActions() override;
|
||||
};
|
||||
|
||||
} // namespace AreaEffectSimulation
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for AreaEffectSimulation AirSupport (Interface for access from other Plugins)
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by ehrlicher, NLE, 2019-09-16
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace AesAirSupport
|
||||
{
|
||||
class ForeignGuiInterface
|
||||
{
|
||||
public:
|
||||
ForeignGuiInterface() = default;
|
||||
virtual ~ForeignGuiInterface() = default;
|
||||
};
|
||||
|
||||
} //namespace AesAirSupport
|
||||
+129
@@ -0,0 +1,129 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for AreaEffectSimulation - AirSupportImpact Overview Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by ehrlicher, NLE, 2019-09-16
|
||||
*/
|
||||
|
||||
#include "aes_air_support_impact_list.h"
|
||||
#include "aes_air_support_impact_model.h"
|
||||
#include "CustomView/aes_air_support_impact.h"
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
//
|
||||
// class AirSupportImpactList
|
||||
//
|
||||
bool AirSupportImpactList::init(LtsSession::LtsSession *session)
|
||||
{
|
||||
if (!AesItemList::init(session))
|
||||
return false;
|
||||
|
||||
m_bHasAddEditOperatorRights = false;
|
||||
|
||||
setDataViewModel(m_model, [this]() { return new CustomViewAirSupportImpact(m_session, this); });
|
||||
|
||||
#ifndef LTS_DEBUG
|
||||
hideColumn(AirSupportImpactModel::BcId);
|
||||
#endif
|
||||
hideColumn(AirSupportImpactModel::BcEffectDuration);
|
||||
hideColumn(AirSupportImpactModel::BcEffectSource);
|
||||
|
||||
setSortIndicator(AirSupportImpactModel::BcName);
|
||||
|
||||
enaDisa();
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Aerial_Ordnances"));
|
||||
|
||||
return true;
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void AirSupportImpactList::createModel()
|
||||
{
|
||||
m_model = new AesItemSortFilterProxyModelTmpl<AirSupportImpact>(m_session, this);
|
||||
|
||||
m_airSupportImpactModel = new AirSupportImpactModel(this);
|
||||
m_airSupportImpactModel->initModel(m_session);
|
||||
m_model->setSourceModel(m_airSupportImpactModel);
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void AirSupportImpactList::retranslate()
|
||||
{
|
||||
translateBase(tr("Air Support Impacts"));
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//
|
||||
// class AirSupportExplosionClusterImpactList (successor of AirSupportImpactList)
|
||||
//
|
||||
bool AirSupportExplosionClusterImpactList::init(LtsSession::LtsSession *session)
|
||||
{
|
||||
if (!AesItemList::init(session))
|
||||
return false;
|
||||
|
||||
m_bHasAddEditOperatorRights = false;
|
||||
|
||||
setDataViewModel(m_model, [this]() { return new CustomViewAirSupportImpact(m_session, this); });
|
||||
|
||||
#ifndef LTS_DEBUG
|
||||
hideColumn(AirSupportImpactModel::BcId);
|
||||
#endif
|
||||
hideColumn(AirSupportImpactModel::BcEffectDuration);
|
||||
|
||||
hideColumn(EffectClusterModel::AdditionalColumns::ColGearType);
|
||||
hideColumn(EffectClusterModel::AdditionalColumns::ColIgniterType);
|
||||
hideColumn(EffectClusterModel::AdditionalColumns::ColFiringPosition);
|
||||
hideColumn(EffectClusterModel::AdditionalColumns::ColExplosionGeometry);
|
||||
hideColumn(EffectClusterModel::AdditionalColumns::ColTlaZog);
|
||||
hideColumn(EffectClusterModel::AdditionalColumns::ColMhPointCount);
|
||||
hideColumn(EffectClusterModel::AdditionalColumns::ColMhpRotationCount);
|
||||
hideColumn(EffectClusterModel::AdditionalColumns::ColImpactCount);
|
||||
hideColumn(EffectClusterModel::AdditionalColumns::ColZpElement);
|
||||
hideColumn(EffectClusterModel::AdditionalColumns::ColOriginalFlightDuration);
|
||||
hideColumn(EffectClusterModel::AdditionalColumns::ColOriginalPeakHeight);
|
||||
hideColumn(EffectClusterModel::AdditionalColumns::ColCalculatedFlightDuration);
|
||||
hideColumn(EffectClusterModel::AdditionalColumns::ColCalculatedPeakHeight);
|
||||
hideColumn(EffectClusterModel::AdditionalColumns::ColCalculatedFiringSpeed);
|
||||
hideColumn(EffectClusterModel::AdditionalColumns::ColLaunchVelocity);
|
||||
hideColumn(EffectClusterModel::AdditionalColumns::ColLaunchAngleDeg);
|
||||
hideColumn(EffectClusterModel::AdditionalColumns::ColDropAngle);
|
||||
hideColumn(EffectClusterModel::AdditionalColumns::ColTapTimepoint);
|
||||
hideColumn(EffectClusterModel::AdditionalColumns::ColLcAttack_Prf);
|
||||
hideColumn(EffectClusterModel::AdditionalColumns::ColLcTermination);
|
||||
hideColumn(EffectClusterModel::AdditionalColumns::ColCloudBase);
|
||||
|
||||
setSortIndicator(AirSupportImpactModel::BcName);
|
||||
|
||||
enaDisa();
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Aerial_Ordnances"));
|
||||
|
||||
return true;
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void AirSupportExplosionClusterImpactList::createModel()
|
||||
{
|
||||
m_model = new AesItemSortFilterProxyModelTmpl<EffectCluster>(m_session, this);
|
||||
|
||||
m_effectClusterModel = new EffectClusterModel({ProjectDataManagement::GearClass_def::AirSupport}, this);
|
||||
m_effectClusterModel->initModel(m_session);
|
||||
m_model->setSourceModel(m_effectClusterModel);
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void AirSupportExplosionClusterImpactList::retranslate()
|
||||
{
|
||||
translateBase(tr("Air Support Impacts"));
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
} // namespace AreaEffectSimulation
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for AreaEffectSimulation - AirSupportImpact Overview Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by ehrlicher, NLE, 2019-09-16
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Plugins/AreaEffectSimulation/Gui/Base/aes_itemlist.h>
|
||||
#include <Plugins/AreaEffectSimulation/Gui/Base/aes_base_model.h>
|
||||
#include <Plugins/AreaEffectSimulation/Gui/Explosion/aes_effect_cluster_model.h>
|
||||
#include "aes_air_support_impact_model.h"
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
class AirSupportImpactList final : public AesItemListTmpl<AirSupportImpact>
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
using AesItemListTmpl<AirSupportImpact>::AesItemListTmpl;
|
||||
|
||||
bool init(LtsSession::LtsSession *session) override;
|
||||
|
||||
private slots:
|
||||
void onAddAesItem() override {}
|
||||
void onEditAesItem() override {}
|
||||
void onRemoveAesItem() override {}
|
||||
|
||||
private:
|
||||
void createModel() override;
|
||||
void retranslate() override;
|
||||
AirSupportImpactModel *m_airSupportImpactModel{nullptr};
|
||||
};
|
||||
|
||||
class AirSupportExplosionClusterImpactList final : public AesItemListTmpl<EffectCluster>
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
using AesItemListTmpl<EffectCluster>::AesItemListTmpl;
|
||||
|
||||
bool init(LtsSession::LtsSession *session) override;
|
||||
|
||||
private slots:
|
||||
void onAddAesItem() override {}
|
||||
void onEditAesItem() override {}
|
||||
void onRemoveAesItem() override {}
|
||||
|
||||
private:
|
||||
void createModel() override;
|
||||
void retranslate() override;
|
||||
EffectClusterModel *m_effectClusterModel{nullptr};
|
||||
};
|
||||
|
||||
|
||||
// since
|
||||
|
||||
|
||||
}
|
||||
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for AreaEffectSimulation - AirSupportImpact Overview Dialog Model
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by ehrlicher, NLE, 2019-09-16
|
||||
*/
|
||||
|
||||
#include "aes_air_support_impact_model.h"
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
AirSupportImpactModel::AirSupportImpactModel(QObject *parent)
|
||||
: AesGuiBaseModel<AirSupportImpact>(parent, {})
|
||||
{
|
||||
} // end of ctor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool AirSupportImpactModel::initModel(LtsSession::LtsSession *session)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "--- Start AirSupportImpactModel::initModel()";
|
||||
|
||||
if (!AesGuiBaseModel::initModel(session))
|
||||
return false;
|
||||
|
||||
connect(m_aesDtc.get(), &AreaEffectSimulation::Interface::Dtc::airSupportImpactChanged,
|
||||
this, &AirSupportImpactModel::onDataChanged);
|
||||
m_aesDtc->airSupportImpacts([this](const AirSupportImpact &item) { insertRow(item); });
|
||||
|
||||
return true;
|
||||
} // end of initModel()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
QVariant AirSupportImpactModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!indexIsValid(index))
|
||||
return QVariant();
|
||||
|
||||
const AirSupportImpact &item = m_vecData.at(index.row());
|
||||
|
||||
if (index.column() < cntBaseColumns())
|
||||
return AesGuiBaseModel::data(item, index.column(), role);
|
||||
|
||||
if (role != Qt::DisplayRole)
|
||||
return QVariant();
|
||||
|
||||
return QVariant();
|
||||
} // end of data()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
} // namespace AreaEffectSimulation
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for AreaEffectSimulation - AirSupportImpact Overview Dialog Model
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by ehrlicher, NLE, 2019-09-16
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Plugins/AreaEffectSimulation/Gui/Base/aes_base_model.h>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
class AirSupportImpactModel final : public AesGuiBaseModel<AirSupportImpact>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AirSupportImpactModel(QObject *parent = nullptr);
|
||||
|
||||
bool initModel(LtsSession::LtsSession *session) override;
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
};
|
||||
} //namespace AreaEffectSimulation
|
||||
@@ -0,0 +1,52 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
# Created by Patric Karwat, SLSE, 2016-07-03
|
||||
#
|
||||
|
||||
ADD_INTERFACE_LIBRARY(
|
||||
AesBCContaminationGuiPluginInterface
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/aes_bccontamination_gui_plugin_interface.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/..
|
||||
)
|
||||
|
||||
SET(aes_bccontamination_gui_SRCS
|
||||
aes_bccontamination_gui_plugin.cpp
|
||||
aes_bccontamination_gui_plugin.h
|
||||
aes_bccontamination_edit.cpp
|
||||
aes_bccontamination_edit.h
|
||||
aes_bccontamination_list.cpp
|
||||
aes_bccontamination_list.h
|
||||
aes_bccontaminations_model.cpp
|
||||
aes_bccontaminations_model.h
|
||||
CustomView/aes_bccontamination.cpp
|
||||
CustomView/aes_bccontamination.h
|
||||
InfoView/aes_bccontamination_info.cpp
|
||||
InfoView/aes_bccontamination_info.h
|
||||
)
|
||||
|
||||
NGL_WRAP_UI(aes_bccontamination_gui_SRCS
|
||||
aes_bccontamination_edit.ui
|
||||
CustomView/aes_bccontamination.ui
|
||||
InfoView/aes_bccontamination_info.ui
|
||||
)
|
||||
|
||||
NGL_ADD_LIBRARY(WS AesBcContaminationGuiPlugin MODULE ${aes_bccontamination_gui_SRCS})
|
||||
NGL_TARGET_LINK_LIBRARIES(AesBcContaminationGuiPlugin
|
||||
AesBaseGui
|
||||
AesBCContaminationGuiPluginInterface
|
||||
ngltools
|
||||
LtsSessionData
|
||||
NGLLogger
|
||||
LtsSession
|
||||
AesDataPluginInterface
|
||||
AesInfoGuiPluginInterface
|
||||
Qt5::Widgets
|
||||
LtsWidgets
|
||||
LtsUtilsSettings
|
||||
)
|
||||
|
||||
NGL_INSTALL_TARGET(AesBcContaminationGuiPlugin)
|
||||
|
||||
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* CustomView for Contamination
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Mike Wille, SLSE, 2016-04-08
|
||||
*/
|
||||
|
||||
#include "aes_bccontamination.h"
|
||||
#include "ui_aes_bccontamination.h"
|
||||
|
||||
#include "aes_bccontaminations_model.h"
|
||||
#include <Services/AreaEffectSimulation/Utils/polygons.h>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
CustomViewBCContamination::CustomViewBCContamination(QWidget *parent)
|
||||
: AbstractDisplayWidget(parent)
|
||||
, m_ui(new Ui::CustomViewBCContamination)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
}
|
||||
|
||||
CustomViewBCContamination::~CustomViewBCContamination()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
bool CustomViewBCContamination::init(const QModelIndex &idx)
|
||||
{
|
||||
if (!idx.isValid())
|
||||
return false;
|
||||
|
||||
m_ui->lbName->setText(rowData(idx, AreaEffectSimulation::BCContaminationsModel::BcName).toString());
|
||||
m_ui->lbType->setText(rowData(idx, AreaEffectSimulation::BCContaminationsModel::BcChargeType).toString());
|
||||
m_ui->lbState->setText(rowData(idx, AreaEffectSimulation::BCContaminationsModel::BcEffectState).toString());
|
||||
m_ui->lbTime->setText(rowData(idx, AreaEffectSimulation::BCContaminationsModel::BcEffectStart).toString());
|
||||
m_ui->lblIcon->clear();
|
||||
m_ui->lblIcon->setAutoFillBackground(true);
|
||||
|
||||
const AesItemSortFilterProxyModel *sfpm = qobject_cast<const AesItemSortFilterProxyModel*>(idx.model());
|
||||
if (!sfpm)
|
||||
return false;
|
||||
const BCContaminationsModel *aesModel = qobject_cast<const BCContaminationsModel*>(sfpm->sourceModel());
|
||||
if (!aesModel)
|
||||
return false;
|
||||
const auto srcIdx = sfpm->mapToSource(idx);
|
||||
BCContamination bcContamin = aesModel->getRowData(srcIdx.row());
|
||||
calculateIcon(bcContamin, sfpm->partyColor(idx.row()));
|
||||
|
||||
qint64 durationMSecs = rowData(idx, AreaEffectSimulation::BCContaminationsModel::BcEffectDuration).toInt();
|
||||
if (durationMSecs > 0)
|
||||
{
|
||||
QString duration;
|
||||
if (durationMSecs % 1000 == 0 || durationMSecs > 60 * 1000)
|
||||
duration = QString::number(durationMSecs / 1000.0, 'f', 0);
|
||||
else
|
||||
duration = QString::number(durationMSecs / 1000.0, 'f', 3);
|
||||
|
||||
m_ui->lbDuration->setText(duration);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ui->label_4->hide();
|
||||
m_ui->lbDuration->hide();
|
||||
m_ui->label_6->hide();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CustomViewBCContamination::calculateIcon(const BCContamination &bcContamination, const QColor &color)
|
||||
{
|
||||
Database::AesBCContamination bcContaOut;
|
||||
bcContaOut.id = bcContamination.id();
|
||||
bcContaOut.chargeTypeId = bcContamination.chargeStruct().chargeTypeId();
|
||||
bcContaOut.effectStart = QDateTime::fromMSecsSinceEpoch(bcContamination.effectStart().is_set() ? bcContamination.effectStart().get() : 0);
|
||||
bcContaOut.impactPosition = QPointF(bcContamination.impactPosition().lon(), bcContamination.impactPosition().lat());
|
||||
bcContaOut.impactRadius = bcContamination.impactRadius();
|
||||
bcContaOut.propagationDirection = bcContamination.propagationDirection();
|
||||
|
||||
const QPolygonF poly = AreaEffectSimulation::Polygons::bcContamination(bcContaOut,
|
||||
ProjectDataManagement::VolatilityType_def::get_default(),
|
||||
bcContamination.impactRadius(),
|
||||
QDateTime::currentDateTime());
|
||||
|
||||
Qt::BrushStyle bStyle = PixmapLabel::checkForBrushStyle(bcContamination.effectStateId());
|
||||
const auto pix = Polygons::pixmapFromPolygon(PixmapLabel::geographic2Utm(poly), color, ICON_RESOLUTION, bStyle);
|
||||
m_ui->lblIcon->setPixmap(pix);
|
||||
|
||||
return true;
|
||||
}
|
||||
} // namespace AreaEffectSimulation
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* CustomView for AES Contamination
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Mike Wille, SLSE, 2016-04-08
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <Viewer/LtsDataView/abstract_display_widget.h>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class CustomViewBCContamination;
|
||||
}
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
class BCContamination;
|
||||
class CustomViewBCContamination final : public LtsDataView::AbstractDisplayWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CustomViewBCContamination(QWidget *parent = nullptr);
|
||||
~CustomViewBCContamination();
|
||||
bool init(const QModelIndex &idx) override final;
|
||||
|
||||
private:
|
||||
bool calculateIcon(const AreaEffectSimulation::BCContamination &bcContamination, const QColor &color);
|
||||
|
||||
Ui::CustomViewBCContamination *m_ui;
|
||||
|
||||
};
|
||||
} // namespace AreaEffectSimulation
|
||||
+179
@@ -0,0 +1,179 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CustomViewBCContamination</class>
|
||||
<widget class="QWidget" name="CustomViewBCContamination">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>350</width>
|
||||
<height>200</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"/>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="lbName">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">Name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbType">
|
||||
<property name="font">
|
||||
<font>
|
||||
<italic>true</italic>
|
||||
</font>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">Type</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>State:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbState">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">State</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="AreaEffectSimulation::PixmapLabel" name="lblIcon">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">icon</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="lbTime">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">Time</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">for</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbDuration">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">Duration</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>seconds</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>AreaEffectSimulation::PixmapLabel</class>
|
||||
<extends>QLabel</extends>
|
||||
<header>AreaEffectSimulation/Gui/Base/aes_pixmap_label.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Executable
+57
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Info Dialog for B/C Contamination
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by diers, NLE, 2017-03-30
|
||||
*/
|
||||
|
||||
#include "aes_bccontamination_info.h"
|
||||
#include "ui_aes_bccontamination_info.h"
|
||||
|
||||
#include <Plugins/AreaEffectSimulation/Gui/Base/InfoView/aes_base_info.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||
#include <QDateTime>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
BCContaminationInfo::BCContaminationInfo(QWidget *parent)
|
||||
: LtsDialog(parent)
|
||||
, m_ui(new Ui::BCContaminationInfo)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
}
|
||||
|
||||
BCContaminationInfo::~BCContaminationInfo()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void BCContaminationInfo::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("B/C-Contamination"));
|
||||
}
|
||||
|
||||
bool BCContaminationInfo::setData(const BCContamination *item)
|
||||
{
|
||||
m_ui->wBaseData->setData(item);
|
||||
|
||||
m_ui->lblImpactRadius->setText(QString::number(item->impactRadius()));
|
||||
m_ui->lblImpactPosition->setText(LtsCoordTrans::mgrsFromGeographic(item->impactPosition().lon(), item->impactPosition().lat()));
|
||||
m_ui->lblPropagationDirection->setText(tr("%1° = %2 mil").arg(item->propagationDirection(), 0, 'f', 2)
|
||||
.arg(item->propagationDirection() * 6400 / 360.0, 0, 'f', 0));
|
||||
m_ui->lblWindSpeed->setText(QString::number(item->windSpeed(), 'f', 2));
|
||||
m_ui->lblWeatherTimestamp->setText(QDateTime::fromMSecsSinceEpoch(item->weatherTimestamp()).toString());
|
||||
m_ui->lblWeatherPosition->setText(LtsCoordTrans::mgrsFromGeographic(item->weatherPosition().lon(), item->weatherPosition().lat()));
|
||||
return true;
|
||||
}
|
||||
|
||||
void BCContaminationInfo::init(LtsSession::LtsSession *session)
|
||||
{
|
||||
m_ui->wBaseData->init(session);
|
||||
}
|
||||
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Info Dialog for B/C Contamination
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by diers, NLE, 2017-03-30
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <Services/AreaEffectSimulation/aes.hpp>
|
||||
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class BCContaminationInfo;
|
||||
}
|
||||
|
||||
namespace LtsSession
|
||||
{
|
||||
class LtsSession;
|
||||
}
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
class BCContaminationInfo : public LtsWidgets::LtsDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit BCContaminationInfo(QWidget *parent = nullptr);
|
||||
~BCContaminationInfo();
|
||||
|
||||
bool setData(const BCContamination *item);
|
||||
void init(LtsSession::LtsSession *session);
|
||||
|
||||
private:
|
||||
void retranslate() override;
|
||||
|
||||
Ui::BCContaminationInfo *m_ui;
|
||||
};
|
||||
|
||||
}
|
||||
Executable
+171
@@ -0,0 +1,171 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>BCContaminationInfo</class>
|
||||
<widget class="QWidget" name="BCContaminationInfo">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>286</width>
|
||||
<height>172</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Aes B/C-Contamination Info</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLabel" name="lblPropagationDirection">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">90° = 1600'</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="lbxWindSpeed">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Wind Speed [m/s]:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lbxImpactPosition">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Impact Position:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="lbxWeatherTimestamp">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Weather Timestamp:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lbxImpactRadius">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Impact Radius [m]:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="lbxPropagationDirection">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Propagation Direction:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLabel" name="lblImpactPosition">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">32U MD 12345 67890</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="AreaEffectSimulation::BaseInfo" name="wBaseData" native="true"/>
|
||||
</item>
|
||||
<item row="7" column="0" colspan="2">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QLabel" name="lblWindSpeed">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">2.34</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="lblImpactRadius">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">0</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="lbxWeatherPosition">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Weather Position:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QLabel" name="lblWeatherTimestamp">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">12:34</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="QLabel" name="lblWeatherPosition">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">32U MD 23456 78901</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>AreaEffectSimulation::BaseInfo</class>
|
||||
<extends>QWidget</extends>
|
||||
<header location="global">Plugins/AreaEffectSimulation/Gui/Base/InfoView/aes_base_info.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
+397
@@ -0,0 +1,397 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* AreaEffectSimulation - Contamination Edit Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-07-07
|
||||
*/
|
||||
|
||||
|
||||
#include "aes_bccontamination_edit.h"
|
||||
#include "ui_aes_bccontamination_edit.h"
|
||||
#include "../AesInfo/aes_danger_area_aes_item_info.h"
|
||||
|
||||
#include <LtsWidgets/lts_message_dialog.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
#include <Plugins/SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/aes_info_gui_plugin_interface.h>
|
||||
|
||||
#include <AreaEffectSimulation/aes_translation.h>
|
||||
#include <LtsUtilsSettings/settings.h>
|
||||
#include <Services/AreaEffectSimulation/Utils/polygons.h>
|
||||
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
double BCContaminationEdit::s_minRadius;
|
||||
double BCContaminationEdit::s_maxRadius;
|
||||
double BCContaminationEdit::s_stepRadius;
|
||||
int BCContaminationEdit::s_minDurationHours;
|
||||
int BCContaminationEdit::s_maxDurationHours;
|
||||
double BCContaminationEdit::s_minAltitude;
|
||||
double BCContaminationEdit::s_maxAltitude;
|
||||
|
||||
static int s_lastChargeTypeB = 0;
|
||||
static int s_lastChargeTypeC = 0;
|
||||
|
||||
// Todo: Höhe und Radius in Abhängigkeit der Munitionsart berechnen
|
||||
|
||||
BCContaminationEdit::BCContaminationEdit(const QString &menuGroup, bool isChemical, QWidget *parent)
|
||||
: BaseEdit(menuGroup, QLatin1String("BCContaminationEdit"), parent)
|
||||
, m_isChemical(isChemical)
|
||||
, m_ui(new Ui::BCContaminationEdit)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
s_minRadius = 50;
|
||||
s_maxRadius = 2500;
|
||||
s_stepRadius = 5;
|
||||
s_minDurationHours = 1;
|
||||
s_maxDurationHours = 4;
|
||||
s_minAltitude = 2;
|
||||
s_maxAltitude = 50;
|
||||
|
||||
m_ui->sbRadius->setMinimum(s_minRadius);
|
||||
m_ui->sbRadius->setMaximum(s_maxRadius);
|
||||
m_ui->sbRadius->setSingleStep(s_stepRadius);
|
||||
m_ui->sbDurationHours->setMinimum(s_minDurationHours);
|
||||
m_ui->sbDurationHours->setMaximum(s_maxDurationHours);
|
||||
m_ui->sbAltitude->setMinimum(s_minAltitude);
|
||||
m_ui->sbAltitude->setMaximum(s_maxAltitude);
|
||||
|
||||
m_uiRequirements->addRequirement({m_ui->lblPosition, [this]() { return (!m_ui->positionEdit->coordinate().isNull()); }});
|
||||
m_uiRequirements->addRequirement({m_ui->lblIdentifier, [this]() { return (!m_ui->leIdentifier->text().isEmpty()); }});
|
||||
m_uiRequirements->addRequirement({m_ui->lblEffectStart, [this]() { return hasValidEffectStart(m_ui->dteEffectStart); }});
|
||||
m_uiRequirements->addRequirement({m_ui->lblChargeType, [this]() { return (m_ui->cbChargeType->currentData().toInt() > 0); }});
|
||||
|
||||
connect(m_ui->pbDangerArea, &QPushButton::clicked, this, &BCContaminationEdit::onPbDangerAreaClicked);
|
||||
connect(m_ui->pbClear, &QPushButton::clicked, m_ui->positionEdit, &LtsCoordWidget::LtsCoordWidget::clear);
|
||||
|
||||
connect(m_ui->sbRadius, &QSpinBox::editingFinished, this, &BCContaminationEdit::correctSpinBoxValue);
|
||||
|
||||
// [GUEZE-2833] Inkonsistenz - Wetter Einstellungen bei A und C Feldern
|
||||
// Order changed AwsDynamic = 0, AwsStatic = 1,
|
||||
m_ui->cbWeather->addItem(toString(AesWeatherSource::AwsDynamic), AesWeatherSource::AwsDynamic);
|
||||
m_ui->cbWeather->addItem(toString(AesWeatherSource::AwsStatic), AesWeatherSource::AwsStatic);
|
||||
|
||||
LtsUtils::ProjectSettings *ps = LtsUtils::ProjectSettings::getInstance();
|
||||
const bool enableShowMeteoDataStations = ps->value(QStringLiteral("mdm"),
|
||||
QStringLiteral("enableShowMeteoDataStations")).toBool();
|
||||
if (!enableShowMeteoDataStations)
|
||||
{
|
||||
m_ui->cbWeather->hide();
|
||||
m_ui->lblWeather->hide();
|
||||
// cbWeather per default auf AesWeatherSource::AwsStatic
|
||||
}
|
||||
m_ui->lblAltitude->show();
|
||||
m_ui->sbAltitude->show();
|
||||
// Not yet needed, as no step is defined:
|
||||
// connect(m_ui->sbAltitude, &QSpinBox::editingFinished, this, &BCContaminationEdit::correctSpinBoxValue);
|
||||
// connect(m_ui->sbDurationMinutes, &QSpinBox::editingFinished, this, &BCContaminationEdit::correctSpinBoxValue);
|
||||
|
||||
// party is (currently) not user-visible
|
||||
// m_ui->lblParty->setVisible(false);
|
||||
// m_ui->cbParty->setVisible(false);
|
||||
|
||||
enaDisa();
|
||||
|
||||
if (m_isChemical)
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Add_C-Contamination"));
|
||||
else
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Add_B-Contamination"));
|
||||
}
|
||||
|
||||
BCContaminationEdit::~BCContaminationEdit()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void BCContaminationEdit::retranslate()
|
||||
{
|
||||
translate(m_ui, m_aesItem, m_isChemical ? tr("C-Contamination") : tr("B-Contamination"));
|
||||
|
||||
if (m_isChemical)
|
||||
m_pdmGuiIfc->fillCComboBox(m_ui->cbChargeType);
|
||||
else
|
||||
m_pdmGuiIfc->fillBComboBox(m_ui->cbChargeType);
|
||||
setCombobxToValueIfPossible(m_ui->cbChargeType, m_isChemical ? s_lastChargeTypeC : s_lastChargeTypeB);
|
||||
}
|
||||
|
||||
void BCContaminationEdit::enableUiElements(bool enable)
|
||||
{
|
||||
m_ui->leIdentifier->setMaxLength(30);
|
||||
m_ui->cbChargeType->setEnabled(enable);
|
||||
m_ui->sbDurationHours->setEnabled(enable);
|
||||
m_ui->cbParty->setEnabled(enable);
|
||||
setEffectStartEnabled(m_ui->dteEffectStart, enable);
|
||||
|
||||
m_ui->pbPosition->setEnabled(m_sitMapGuiIfc && enable);
|
||||
m_ui->positionEdit->setEnabled(enable);
|
||||
m_ui->sbAltitude->setEnabled(enable);
|
||||
m_ui->cbLowerLimit->setEnabled(enable);
|
||||
m_ui->sbRadius->setEnabled(enable);
|
||||
m_ui->leIdentifier->setEnabled(enable || isOnlyNameModifiable());
|
||||
|
||||
m_ui->cbWeather->setEnabled(enable);
|
||||
m_ui->pbClear->setEnabled(enable);
|
||||
if (m_aesItem.effectStateId() == AesEffectState_def::EsExpired)
|
||||
{
|
||||
m_ui->leIdentifier->setText(QString::fromStdString(m_aesItem.name()));
|
||||
__unchange__();
|
||||
}
|
||||
if (m_aesItem.effectStateId() == AesEffectState_def::EsActivated)
|
||||
{
|
||||
QString name = m_ui->leIdentifier->text();
|
||||
auto baseData = m_dtc->bCContamination(m_aesItem.id());
|
||||
setData(baseData, false);
|
||||
__unchange__();
|
||||
if (name != m_ui->leIdentifier->text())
|
||||
m_ui->leIdentifier->setText(name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool BCContaminationEdit::init(int aesItemId, bool copy,
|
||||
LtsSession::LtsSession *session)
|
||||
{
|
||||
if (!BaseEdit::init(aesItemId, session))
|
||||
return false;
|
||||
|
||||
bool editable = (LtsSessionData::LtsSessionData::getInstance()->hasOperatorRight(OperatorRights::CContaminationsEdit) && m_isChemical) ||
|
||||
(LtsSessionData::LtsSessionData::getInstance()->hasOperatorRight(OperatorRights::BContaminationsEdit) && !m_isChemical) ||
|
||||
m_session->app() == LtsAppDescriptor::App::OC;
|
||||
|
||||
bool readable = (LtsSessionData::LtsSessionData::getInstance()->hasOperatorRight(OperatorRights::CContaminationsShow) && m_isChemical) ||
|
||||
(LtsSessionData::LtsSessionData::getInstance()->hasOperatorRight(OperatorRights::BContaminationsShow) && !m_isChemical) ;
|
||||
|
||||
setPbDangerAreaText();
|
||||
if (!readable && !editable)
|
||||
return false;
|
||||
|
||||
// FIXME: in GUI plugin, nicht ausserhalb!
|
||||
if (!m_session->getForeignGuiInterface<ProjectDataManagement::ForeignGuiInterface>(m_pdmGuiIfc))
|
||||
return false;
|
||||
|
||||
m_ui->dteEffectStart->setMinimumTimeMSec(m_session->partitionTime());
|
||||
m_ui->dteEffectStart->setRetrieveCurrentTimeCallback([this]() { return m_session->partitionTime(); });
|
||||
|
||||
if (m_sitMapGuiIfc)
|
||||
connect(m_ui->pbPosition, &QPushButton::clicked, this, &BCContaminationEdit::getPosition);
|
||||
else
|
||||
m_ui->pbPosition->setEnabled(false);
|
||||
|
||||
if (m_isChemical)
|
||||
m_pdmGuiIfc->fillCComboBox(m_ui->cbChargeType);
|
||||
else
|
||||
m_pdmGuiIfc->fillBComboBox(m_ui->cbChargeType);
|
||||
|
||||
m_ppmGuiCbxIfc->fillPartyComboBox(m_ui->cbParty);
|
||||
|
||||
if (aesItemId > 0)
|
||||
{
|
||||
auto baseData = m_dtc->bCContamination(aesItemId);
|
||||
setData(baseData, copy);
|
||||
}
|
||||
|
||||
auto cb = [this](const DangerAreaCorrelatedAesItem &item)
|
||||
{
|
||||
if (item.aesItemId() == m_aesItem.id())
|
||||
m_dangerAreaIds << item.dangerAreaId();
|
||||
};
|
||||
m_dtc->dangerAreaCorrelatedAesItems(cb);
|
||||
setPbDangerAreaText();
|
||||
|
||||
enableUiElements(editable && isModifiable() && !isOnlyNameModifiable());
|
||||
|
||||
connect(m_dtc.get(), &AreaEffectSimulation::Interface::Dtc::dangerAreaCorrelatedAesItemChanged,
|
||||
this, &BCContaminationEdit::onDangerAreaChanged);
|
||||
|
||||
connect(m_dtc.get(), &AreaEffectSimulation::Interface::Dtc::bCContaminationChanged,
|
||||
this, &BaseEdit::onAreaChanged);
|
||||
|
||||
|
||||
|
||||
auto cbDangerArea = [this](const DangerArea &data)
|
||||
{
|
||||
if (data.effectStateId() != AesEffectState::EsRemoved && data.associatedAesId() == m_aesItem.id())
|
||||
m_associatedDangerId = data.id();
|
||||
};
|
||||
m_dtc->dangerAreas(cbDangerArea);
|
||||
if (m_associatedDangerId)
|
||||
{
|
||||
m_ui->chbDangerArea->setChecked(true);
|
||||
m_ui->chbDangerArea->setEnabled(false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void BCContaminationEdit::setPbDangerAreaText()
|
||||
{
|
||||
QStringList sl;
|
||||
sl.reserve(m_dangerAreaIds.size());
|
||||
for (int idx : qAsConst(m_dangerAreaIds))
|
||||
{
|
||||
sl << QString::fromStdString(m_dtc->dangerArea(idx).name());
|
||||
}
|
||||
m_ui->pbDangerArea->setEnabled(sl.size());
|
||||
m_ui->pbDangerArea->setText(sl.join(QStringLiteral(", ")));
|
||||
}
|
||||
|
||||
void BCContaminationEdit::onDangerAreaChanged(const DangerAreaCorrelatedAesItem &data, DataModification modType)
|
||||
{
|
||||
if (data.aesItemId() != m_aesItem.id())
|
||||
return;
|
||||
|
||||
if (modType == DataModification::eAdded)
|
||||
m_dangerAreaIds += data.dangerAreaId();
|
||||
|
||||
if (modType == DataModification::eRemoved)
|
||||
m_dangerAreaIds -= data.dangerAreaId();
|
||||
// Note: Modification cannot happen as the key is unique for the combination.
|
||||
|
||||
setPbDangerAreaText();
|
||||
}
|
||||
|
||||
void BCContaminationEdit::onPbDangerAreaClicked()
|
||||
{
|
||||
if (m_dangerAreaIds.isEmpty())
|
||||
return;
|
||||
|
||||
std::shared_ptr<ForeignInfoGuiInterface> infoGuiInterface;
|
||||
if (!m_session->getForeignGuiInterface<ForeignInfoGuiInterface>(infoGuiInterface))
|
||||
return;
|
||||
|
||||
LtsWidgets::LtsDialog *dialog = infoGuiInterface->showDangerAreaAesItemInfo(m_dangerAreaIds, {m_aesItem.id()});
|
||||
|
||||
addDialog(dialog, m_menuGroup, tr("Danger Areas for %1 %2").arg(m_isChemical ? tr("C-Contamination") : tr("B-Contamination"), m_ui->leIdentifier->text()), LtsWidgets::LayoutArea::eInfoTab);
|
||||
}
|
||||
|
||||
void BCContaminationEdit::setData(const BCContamination &contamination, bool copy)
|
||||
{
|
||||
m_aesItem = contamination;
|
||||
if (copy)
|
||||
{
|
||||
m_aesItem.id(0);
|
||||
m_aesItem.effectStateId(AreaEffectSimulation::AesEffectState_def::get_default());
|
||||
}
|
||||
m_ui->leIdentifier->setText(QString::fromStdString(contamination.name()));
|
||||
m_ui->dteEffectStart->setMsecsSinceEpoch(contamination.effectStart().is_set() ? contamination.effectStart().get() : 0);
|
||||
m_ui->cbChargeType->setCurrentIndex(m_ui->cbChargeType->findData(contamination.chargeStruct().chargeTypeId())); // not user-visible
|
||||
m_ui->sbDurationHours->setValue(contamination.effectDuration() / 1000 / 60/ 60); // msecs -> mins -> hours
|
||||
m_ui->sbRadius->setValue(contamination.impactRadius());
|
||||
m_ui->cbParty->setCurrentIndex(m_ui->cbParty->findData(contamination.partyId().is_set() ? contamination.partyId().get() : 0));
|
||||
m_ui->cbWeather->setCurrentIndex(contamination.weatherSource().underlying());
|
||||
|
||||
QPointF impactPosition(contamination.impactPosition().lon(), contamination.impactPosition().lat());
|
||||
if (!impactPosition.isNull())
|
||||
m_ui->positionEdit->setCoordinate(impactPosition);
|
||||
|
||||
m_ui->sbAltitude->setValue(contamination.upperOffset());
|
||||
m_ui->cbLowerLimit->setChecked(qFuzzyIsNull(contamination.lowerOffset()));
|
||||
|
||||
}
|
||||
|
||||
void BCContaminationEdit::getPosition()
|
||||
{
|
||||
if (!has2DMap())
|
||||
return;
|
||||
|
||||
m_sitMapGuiIfc->getCircle(this,
|
||||
SLOT(onCircleData(QPointF, double)),
|
||||
nullptr,
|
||||
s_minRadius,
|
||||
s_maxRadius,
|
||||
m_ui->positionEdit->coordinate(),
|
||||
m_ui->sbRadius->value()); //max
|
||||
}
|
||||
|
||||
void BCContaminationEdit::onCircleData(const QPointF &position, double radius)
|
||||
{
|
||||
m_previewCircleCenter = position;
|
||||
|
||||
// SB corrects value acc. singleStep
|
||||
m_ui->sbRadius->setValue(radius);
|
||||
m_previewCircleRadius = m_ui->sbRadius->value();
|
||||
|
||||
m_ui->positionEdit->setCoordinate(position);
|
||||
DEBUG_LOG(m_logger) << "Pos X: " << position.x() << " Y: " << position.y() << " R: " << radius;
|
||||
|
||||
showPreviewObject();
|
||||
}
|
||||
|
||||
bool BCContaminationEdit::apply()
|
||||
{
|
||||
std::string name = m_ui->leIdentifier->text().toStdString();
|
||||
qint64 effectStart = m_ui->dteEffectStart->msecsSinceEpoch();
|
||||
int duration = m_ui->sbDurationHours->value() * 60 * 1000 * 60; //hours -> mins -> msecs
|
||||
int chargeType = m_ui->cbChargeType->currentData().toInt();
|
||||
if (m_isChemical)
|
||||
s_lastChargeTypeC = chargeType;
|
||||
else
|
||||
s_lastChargeTypeB = chargeType;
|
||||
int partyId = m_ui->cbParty->currentData().toInt();
|
||||
int participantId = 0;
|
||||
int radius = m_ui->sbRadius->value();
|
||||
int weathersource = m_ui->cbWeather->currentData().toInt();
|
||||
double extrusionHeight = m_ui->sbAltitude->value();
|
||||
|
||||
double lowerOffset = 0.0;
|
||||
if (!m_ui->cbLowerLimit->isChecked())
|
||||
lowerOffset = -1000.0;
|
||||
|
||||
QPointF p(m_ui->positionEdit->coordinate());
|
||||
const Core::GeoPosition2D pos(p.x(), p.y());
|
||||
|
||||
|
||||
const BCContaminationModifyRequest req(m_aesItem.id(),
|
||||
name,
|
||||
LtsUtils::toOptional(effectStart),
|
||||
duration,
|
||||
chargeType,
|
||||
pos,
|
||||
radius,
|
||||
static_cast<AesWeatherSource::inner_enum>(weathersource),
|
||||
LtsUtils::toOptional(partyId),
|
||||
LtsUtils::toOptional(participantId),
|
||||
dds::core::optional<double>(),
|
||||
dds::core::optional<double>(),
|
||||
dds::core::optional<Core::GeoPosition2D>(),
|
||||
dds::core::optional<rti::core::int64>(),
|
||||
dds::core::optional<rti::core::int64>(),
|
||||
extrusionHeight,
|
||||
lowerOffset,
|
||||
m_ui->chbDangerArea->isChecked());
|
||||
|
||||
INFO_LOG(m_logger) << "apply "
|
||||
<< " extrusionHeight=" << extrusionHeight
|
||||
<< " req.upperOffset=" << req.upperOffset()
|
||||
<< " lowerOf"
|
||||
"fset=" << lowerOffset
|
||||
<< " req.lowerOffset=" << req.lowerOffset();
|
||||
|
||||
m_requestHelper->addRequest([this,req]()
|
||||
{
|
||||
return m_ftc->bCContaminationModifyRequest(req, this);
|
||||
});
|
||||
bool ret= m_requestHelper->startRequests();
|
||||
if (m_ui->chbDangerArea->isChecked() && ret)
|
||||
m_ui->chbDangerArea->setEnabled(false);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void BCContaminationEdit::showPreviewObject()
|
||||
{
|
||||
if (!m_sitMapGuiIfc)
|
||||
return;
|
||||
|
||||
if (m_previewCircleCenter.isNull())
|
||||
return;
|
||||
|
||||
m_sitMapGuiIfc->displayPreviewObject(this, m_previewCircleCenter, m_previewCircleRadius);
|
||||
}
|
||||
|
||||
} // namespace AreaEffectSimulation
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* AreaEffectSimulation - Explosion Edit Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-07-07
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Plugins/AreaEffectSimulation/Gui/Base/aes_base_edit.h>
|
||||
#include <Plugins/ProjectDataManagement/pdm_gui_plugin_interface.h>
|
||||
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class BCContaminationEdit;
|
||||
}
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
class BCContaminationEdit final
|
||||
: public BaseEdit
|
||||
, protected AreaEffectSimulation::Interface::Ftc::BCContaminationModifyReplyHandler
|
||||
, protected AreaEffectSimulation::Interface::Ftc::DangerAreaModifyReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit BCContaminationEdit(const QString &menuGroup, bool isChemical, QWidget *parent = nullptr);
|
||||
~BCContaminationEdit();
|
||||
|
||||
QString dialogIdentifier() const override
|
||||
{
|
||||
if (m_isChemical)
|
||||
return m_aesItem.id() <= 0 ? QStringLiteral("AddCContamination") : QStringLiteral("EditCContamination%1").arg(m_aesItem.id());
|
||||
return m_aesItem.id() <= 0 ? QStringLiteral("AddBContamination") : QStringLiteral("EditBContamination%1").arg(m_aesItem.id());
|
||||
}
|
||||
bool init(int aesItemId, bool copy, LtsSession::LtsSession *session);
|
||||
|
||||
void onBCContaminationModifyReply(const Core::FunctionReplyObject &replyObject) override final { onAesItemModifyReply(replyObject); }
|
||||
void onDangerAreaModifyReply(const Core::FunctionReplyObject &replyObject) override final { onAesItemModifyReply(replyObject); }
|
||||
private:
|
||||
static double s_minRadius;
|
||||
static double s_maxRadius;
|
||||
static double s_stepRadius;
|
||||
static int s_minDurationHours;
|
||||
static int s_maxDurationHours;
|
||||
static double s_minAltitude;
|
||||
static double s_maxAltitude;
|
||||
|
||||
void retranslate() override;
|
||||
void setData(const BCContamination &contamination, bool copy);
|
||||
void enableUiElements(bool enable) override;
|
||||
void setPbDangerAreaText();
|
||||
|
||||
private Q_SLOTS:
|
||||
void getPosition();
|
||||
void onCircleData(const QPointF &position, double radius);
|
||||
bool apply() override;
|
||||
void onDangerAreaChanged(const DangerAreaCorrelatedAesItem &data, DataModification modType);
|
||||
void onPbDangerAreaClicked();
|
||||
void showPreviewObject() override;
|
||||
|
||||
private:
|
||||
bool m_isChemical;
|
||||
int m_associatedDangerId{0};
|
||||
QSet<int> m_dangerAreaIds;
|
||||
QPointF m_previewCircleCenter;
|
||||
double m_previewCircleRadius;
|
||||
Ui::BCContaminationEdit *m_ui;
|
||||
std::shared_ptr<ProjectDataManagement::ForeignGuiInterface> m_pdmGuiIfc;
|
||||
};
|
||||
|
||||
} //namespace AreaEffectSimulation
|
||||
+359
@@ -0,0 +1,359 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>BCContaminationEdit</class>
|
||||
<widget class="QWidget" name="BCContaminationEdit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>640</width>
|
||||
<height>208</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Aes Contamination Edit</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="1">
|
||||
<widget class="LtsWidgets::LtsDateTimeEdit" name="dteEffectStart" native="true">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="checkable" stdset="0">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="withButtons" stdset="0">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="withSlider" stdset="0">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="withReset" stdset="0">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="5">
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>2</width>
|
||||
<height>31</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="lblDuration">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Duration [h]:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="4" column="4">
|
||||
<widget class="LtsWidgets::LtsComboBox" name="cbParty">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="currentText">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="4">
|
||||
<widget class="QPushButton" name="pbDangerArea">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lblEffectStart">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Effect Start:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="3">
|
||||
<widget class="QLabel" name="lblDangerArea">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Danger Area:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="3">
|
||||
<widget class="QLabel" name="lblWeather">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Weather:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="4">
|
||||
<widget class="QSpinBox" name="sbRadius">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>1000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="lblPosition">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Position:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="3">
|
||||
<widget class="QLabel" name="lblParty">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Firing Party:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QLabel" name="lblAltitude">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Altitude [m]:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lblIdentifier">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Identifier:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="4">
|
||||
<widget class="LtsWidgets::LtsComboBox" name="cbWeather">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="currentText">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lblChargeType">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Agent Type:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="4">
|
||||
<widget class="QSpinBox" name="sbAltitude">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>1000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QLabel" name="lblRadius">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Radius [m]:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QSpinBox" name="sbDurationHours">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>4</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="LtsCoordWidget::LtsCoordWidget" name="positionEdit" native="true">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="showToolTip" stdset="0">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pbPosition">
|
||||
<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="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/style/remove.svg</normaloff>:/style/remove.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="leIdentifier">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="LtsWidgets::LtsComboBox" name="cbChargeType">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="currentText">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="5">
|
||||
<widget class="QCheckBox" name="cbLowerLimit">
|
||||
<property name="text">
|
||||
<string>Lower Limit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="5">
|
||||
<widget class="QCheckBox" name="chbDangerArea">
|
||||
<property name="text">
|
||||
<string>With Danger Area</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LtsCoordWidget::LtsCoordWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>LtsCoordTrans/lts_coord_widget.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>LtsWidgets::LtsDateTimeEdit</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>LtsWidgets/lts_date_time_edit.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>LtsWidgets::LtsComboBox</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header>LtsWidgets/lts_combo_box.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>leIdentifier</tabstop>
|
||||
<tabstop>dteEffectStart</tabstop>
|
||||
<tabstop>cbChargeType</tabstop>
|
||||
<tabstop>sbDurationHours</tabstop>
|
||||
<tabstop>positionEdit</tabstop>
|
||||
<tabstop>pbPosition</tabstop>
|
||||
<tabstop>pbClear</tabstop>
|
||||
<tabstop>sbAltitude</tabstop>
|
||||
<tabstop>sbRadius</tabstop>
|
||||
<tabstop>pbDangerArea</tabstop>
|
||||
<tabstop>cbWeather</tabstop>
|
||||
<tabstop>cbParty</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
+154
@@ -0,0 +1,154 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* GUI Plugin for AreaEffectSimulation - Contamination
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-07-07
|
||||
*/
|
||||
|
||||
#include "aes_bccontamination_gui_plugin.h"
|
||||
#include "aes_bccontamination_edit.h"
|
||||
#include "aes_bccontamination_list.h"
|
||||
|
||||
#include "InfoView/aes_bccontamination_info.h"
|
||||
|
||||
#include <AreaEffectSimulation/aes_operator_rights.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsUtilsSettings/settings.h>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
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.BcContamination"))
|
||||
, ForeignGuiInterface()
|
||||
, m_enableB(false)
|
||||
, m_enableC(false)
|
||||
, m_enableN(false)
|
||||
{
|
||||
LtsUtils::ProjectSettings *ps = LtsUtils::ProjectSettings::getInstance();
|
||||
m_enableB = ps->value(QStringLiteral("aes"),
|
||||
QStringLiteral("enableBiologicalContamination")).toBool();
|
||||
m_enableC = ps->value(QStringLiteral("aes"),
|
||||
QStringLiteral("enableChemicalContamination")).toBool();
|
||||
m_enableN = ps->value(QStringLiteral("aes"),
|
||||
QStringLiteral("enableNuclearContaminations")).toBool();
|
||||
|
||||
}
|
||||
|
||||
QString InterfaceImpl::menuGroup() const
|
||||
{
|
||||
if (!m_enableB && !m_enableC && m_enableN)
|
||||
return tr("Area Effect Simulation N");
|
||||
else if (m_enableB && !m_enableC && m_enableN)
|
||||
return tr("Area Effect Simulation NB");
|
||||
else if (!m_enableB && m_enableC && m_enableN)
|
||||
return tr("Area Effect Simulation NC");
|
||||
else if (m_enableB && !m_enableC && !m_enableN)
|
||||
return tr("Area Effect Simulation B");
|
||||
else if (m_enableB && m_enableC && !m_enableN)
|
||||
return tr("Area Effect Simulation BC");
|
||||
else if (!m_enableB && m_enableC && !m_enableN)
|
||||
return tr("Area Effect Simulation C");
|
||||
else
|
||||
return tr("Area Effect Simulation NBC");
|
||||
}
|
||||
|
||||
QVector<LtsWidgets::PluginData> InterfaceImpl::getActions()
|
||||
{
|
||||
QVector<LtsWidgets::PluginData> ret;
|
||||
|
||||
|
||||
|
||||
|
||||
if (m_enableC)
|
||||
{
|
||||
ret.append(LtsWidgets::PluginData(menuGroup(),
|
||||
tr("C-Contaminations"),
|
||||
QLatin1String("ListCContaminations"),
|
||||
QIcon(QLatin1String("icon:chemical_agents.svg")),
|
||||
[this](QWidget *parent) { return onShowBCContaminationListDialog(true, parent);},
|
||||
OperatorRights::CContaminationsShow,
|
||||
LtsWidgets::ExercisePart::eExecution));
|
||||
|
||||
|
||||
if (m_session->isExercisePartition() && appId() != LtsAppDescriptor::App::OC)
|
||||
ret.append(LtsWidgets::PluginData(menuGroup(),
|
||||
tr("Add C-Contamination"),
|
||||
QLatin1String("AddCContamination"),
|
||||
QIcon(QLatin1String("icon:chemical_agents_add.svg")),
|
||||
[this](QWidget *parent) { return onShowAddBCContaminationDialog(true, parent);},
|
||||
OperatorRights::CContaminationsEdit,
|
||||
LtsWidgets::ExercisePart::eExecution,
|
||||
LtsWidgets::ExerciseState::eCreated | LtsWidgets::ExerciseState::eStarted | LtsWidgets::ExerciseState::ePaused));
|
||||
}
|
||||
|
||||
if (m_enableB)
|
||||
{
|
||||
ret.append(LtsWidgets::PluginData(menuGroup(),
|
||||
tr("B-Contaminations"),
|
||||
QLatin1String("ListBContaminations"),
|
||||
QIcon(QLatin1String("icon:bio_agent.svg")),
|
||||
[this](QWidget *parent) { return onShowBCContaminationListDialog(false, parent);},
|
||||
OperatorRights::BContaminationsShow,
|
||||
LtsWidgets::ExercisePart::eExecution));
|
||||
|
||||
|
||||
if (m_session->isExercisePartition() && appId() != LtsAppDescriptor::App::OC)
|
||||
ret.append(LtsWidgets::PluginData(menuGroup(),
|
||||
tr("Add B-Contamination"),
|
||||
QLatin1String("AddBContamination"),
|
||||
QIcon(QLatin1String("icon:bio_agent_add.svg")),
|
||||
[this](QWidget *parent) { return onShowAddBCContaminationDialog(false, parent);},
|
||||
OperatorRights::BContaminationsEdit,
|
||||
LtsWidgets::ExercisePart::eExecution,
|
||||
LtsWidgets::ExerciseState::eCreated | LtsWidgets::ExerciseState::eStarted | LtsWidgets::ExerciseState::ePaused));
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool InterfaceImpl::fetchInterfaces()
|
||||
{
|
||||
std::shared_ptr<ProjectDataManagement::ForeignGuiInterface> pdmGuiIfc;
|
||||
if (!m_session->getForeignGuiInterface<ProjectDataManagement::ForeignGuiInterface>(pdmGuiIfc))
|
||||
return false;
|
||||
|
||||
return AesBaseInterface::fetchInterfaces();
|
||||
}
|
||||
|
||||
LtsWidgets::LtsDialog *InterfaceImpl::showInfoWindow(const AesItem *item)
|
||||
{
|
||||
const BCContamination *bcc = static_cast<const BCContamination*>(item);
|
||||
|
||||
BCContaminationInfo *dialog = new BCContaminationInfo();
|
||||
dialog->init(m_session);
|
||||
dialog->setData(bcc);
|
||||
return dialog;
|
||||
}
|
||||
|
||||
|
||||
AreaEffectSimulation::BaseEdit *InterfaceImpl::showEditWindow(int aesEntityId, bool isChemical, QWidget *parent)
|
||||
{
|
||||
return LtsWidgets::initDialog(new BCContaminationEdit(menuGroup(), isChemical, parent),
|
||||
aesEntityId, false, m_session);
|
||||
}
|
||||
|
||||
LtsWidgets::LtsDialog *InterfaceImpl::onShowAddBCContaminationDialog(bool isChemical, QWidget *parent)
|
||||
{
|
||||
return showEditWindow(0, isChemical, parent);
|
||||
}
|
||||
|
||||
LtsWidgets::LtsDialog *InterfaceImpl::onShowBCContaminationListDialog(bool isChemical, QWidget *parent)
|
||||
{
|
||||
return LtsWidgets::initDialog(new BCContaminationList(menuGroup(), isChemical, parent),
|
||||
m_session);
|
||||
}
|
||||
|
||||
} // namespace AreaEffectSimulation
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Gui Plugin for AreaEffectSimulation - Contamination
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-07-07
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Plugins/AreaEffectSimulation/Gui/Base/aes_base_gui_plugin.h>
|
||||
#include "aes_bccontamination_gui_plugin_interface.h"
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
class GuiPlugin final : public AesBaseGuiPlugin
|
||||
{
|
||||
Q_PLUGIN_METADATA(IID "gui:3:aes.bccontaminations")
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GuiPlugin() = default;
|
||||
~GuiPlugin() = default;
|
||||
|
||||
QString pluginName() override { return QStringLiteral("AreaEffectSimuationBCContaminationGui"); }
|
||||
std::shared_ptr<GuiPluginBase::Interface> createGuiInterface(LtsSession::LtsSession *session) override;
|
||||
bool availableInPartition(IDL::PartitionType partition) const override
|
||||
{
|
||||
return partition == IDL::PartitionType::Exercise ||
|
||||
partition == IDL::PartitionType::Replay;
|
||||
}
|
||||
};
|
||||
|
||||
class InterfaceImpl final : public AesBaseInterface, public AesBCContamination::ForeignGuiInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit InterfaceImpl(LtsSession::LtsSession *session);
|
||||
|
||||
QString menuGroup() const override final;
|
||||
QVector<LtsWidgets::PluginData> getActions() override;
|
||||
LtsWidgets::LtsDialog *showInfoWindow(const AesItem *item) override;
|
||||
AreaEffectSimulation::BaseEdit *showEditWindow(int aesEntityId, bool isChemical, QWidget *parent) override;
|
||||
bool fetchInterfaces() override;
|
||||
|
||||
private:
|
||||
LtsWidgets::LtsDialog *onShowAddBCContaminationDialog(bool isChemical, QWidget *parent);
|
||||
LtsWidgets::LtsDialog *onShowBCContaminationListDialog(bool isChemical, QWidget *parent);
|
||||
bool m_enableB;
|
||||
bool m_enableC;
|
||||
bool m_enableN;
|
||||
|
||||
};
|
||||
|
||||
} // namespace AreaEffectSimulation
|
||||
Executable
+36
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for AreaEffectSimulation (Interface for access from other Plugins)
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-07-01
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
class QWidget;
|
||||
namespace LtsWidgets
|
||||
{
|
||||
class LtsDialog;
|
||||
}
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
class AesItem;
|
||||
class BaseEdit;
|
||||
}
|
||||
|
||||
namespace AesBCContamination
|
||||
{
|
||||
class ForeignGuiInterface
|
||||
{
|
||||
public:
|
||||
ForeignGuiInterface() = default;
|
||||
virtual ~ForeignGuiInterface() = default;
|
||||
|
||||
virtual LtsWidgets::LtsDialog *showInfoWindow(const AreaEffectSimulation::AesItem *item) = 0;
|
||||
virtual AreaEffectSimulation::BaseEdit *showEditWindow(int aesEntityId, bool isChemical, QWidget *parent) = 0;
|
||||
};
|
||||
} // namespace AesBCContamination
|
||||
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* ContaminationManangement - Contamination Overview Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-07-07
|
||||
*/
|
||||
|
||||
#include "aes_bccontamination_list.h"
|
||||
#include "aes_bccontaminations_model.h"
|
||||
#include "aes_bccontamination_edit.h"
|
||||
#include "CustomView/aes_bccontamination.h"
|
||||
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
BCContaminationList::BCContaminationList(const QString &menuGroup, bool isChemical, QWidget *parent)
|
||||
: AesItemListTmpl<BCContamination>(menuGroup, parent)
|
||||
, m_isChemical(isChemical)
|
||||
{
|
||||
}
|
||||
|
||||
bool BCContaminationList::init(LtsSession::LtsSession *session)
|
||||
{
|
||||
if (!AesItemList::init(session))
|
||||
return false;
|
||||
|
||||
bool editable = (LtsSessionData::LtsSessionData::getInstance()->hasOperatorRight(OperatorRights::CContaminationsEdit) && m_isChemical) ||
|
||||
(LtsSessionData::LtsSessionData::getInstance()->hasOperatorRight(OperatorRights::BContaminationsEdit) && !m_isChemical) ||
|
||||
m_session->app() == LtsAppDescriptor::App::OC;
|
||||
if (session->isReplayPartition())
|
||||
editable = false;
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, editable);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Add, editable);
|
||||
|
||||
QSortFilterProxyModel *m = m_model;
|
||||
setDataViewModel(m, [this]() { return new CustomViewBCContamination(this); });
|
||||
|
||||
#ifndef LTS_DEBUG
|
||||
hideColumn(CContaminationsModel::BcId);
|
||||
#endif
|
||||
hideColumn(CContaminationsModel::BcParticipant);
|
||||
hideColumn(CContaminationsModel::BcEffectSource);
|
||||
|
||||
setSortIndicator(CContaminationsModel::BcName);
|
||||
|
||||
enaDisa();
|
||||
|
||||
if (m_isChemical)
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-C-Contaminations"));
|
||||
else
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-B-Contaminations"));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void BCContaminationList::createModel()
|
||||
{
|
||||
m_model = new AesItemSortFilterProxyModelTmpl<BCContamination>(m_session, this);
|
||||
BCContaminationsModel *sourceModel;
|
||||
if (m_isChemical)
|
||||
sourceModel = new CContaminationsModel(this);
|
||||
else
|
||||
sourceModel = new BContaminationsModel(this);
|
||||
sourceModel->initModel(m_session);
|
||||
m_model->setSourceModel(sourceModel);
|
||||
}
|
||||
|
||||
void BCContaminationList::onAddAesItem()
|
||||
{
|
||||
BCContaminationEdit *dialog = new BCContaminationEdit(m_menuGroup, m_isChemical, this);
|
||||
|
||||
const int aesItemId = model()->aesId(currentRow());
|
||||
if (dialog->init(aesItemId, aesItemId > 0, m_session))
|
||||
addDialog(dialog, m_menuGroup, dialog->dialogIdentifier(), LtsWidgets::LayoutArea::eDialogTab);
|
||||
else
|
||||
delete dialog;
|
||||
}
|
||||
|
||||
void BCContaminationList::onEditAesItem()
|
||||
{
|
||||
const int aesItemId = model()->aesId(currentRow());
|
||||
|
||||
if (aesItemId <= 0)
|
||||
return;
|
||||
|
||||
DEBUG_LOG(m_logger) << "current ContaminationId: " << aesItemId;
|
||||
|
||||
BCContaminationEdit *dialog = new BCContaminationEdit(m_menuGroup, m_isChemical, this);
|
||||
if (dialog->init(aesItemId, false, m_session))
|
||||
addDialog(dialog, m_menuGroup, dialog->dialogIdentifier(), LtsWidgets::LayoutArea::eDialogTab);
|
||||
else
|
||||
delete dialog;
|
||||
}
|
||||
|
||||
void BCContaminationList::onRemoveAesItem()
|
||||
{
|
||||
const int aesItemId = model()->aesId(currentRow());
|
||||
Core::RemoveElementRequest req(aesItemId);
|
||||
m_requestHelper->startSingleRequest([req, this]()
|
||||
{
|
||||
return m_ftc->bCContaminationRemoveRequest(req, this);
|
||||
});
|
||||
}
|
||||
|
||||
void BCContaminationList::retranslate()
|
||||
{
|
||||
translateBase(m_isChemical ? tr("C-Contaminations") : tr("B-Contaminations"));
|
||||
}
|
||||
|
||||
void BCContaminationList::onBCContaminationRemoveReply(const Core::FunctionReplyObject &replyObject)
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
} // namespace AreaEffectSimulation
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* AreaEffectSimulation - Contamination Overview Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-07-07
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Plugins/AreaEffectSimulation/Gui/Base/aes_itemlist.h>
|
||||
#include <Plugins/AreaEffectSimulation/Gui/Base/aes_base_model.h>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
class BCContaminationList final : public AesItemListTmpl<BCContamination>
|
||||
, protected AreaEffectSimulation::Interface::Ftc::BCContaminationRemoveReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit BCContaminationList(const QString &menuGroup, bool isChemical, QWidget *parent = nullptr);
|
||||
|
||||
bool init(LtsSession::LtsSession *session) override;
|
||||
|
||||
private slots:
|
||||
void onAddAesItem() override;
|
||||
void onEditAesItem() override;
|
||||
void onRemoveAesItem() override;
|
||||
|
||||
private:
|
||||
void createModel() override;
|
||||
void retranslate() override;
|
||||
void onBCContaminationRemoveReply(const Core::FunctionReplyObject &replyObject) override;
|
||||
|
||||
bool m_isChemical;
|
||||
};
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* AreaEffectManangement - BcContamination Overview Dialog Model
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Mike Wille, SLSE, 2016-09-26
|
||||
*/
|
||||
|
||||
#include "aes_bccontaminations_model.h"
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
bool BCContaminationsModel::initModel(LtsSession::LtsSession *session)
|
||||
{
|
||||
if (!AesGuiBaseModel::initModel(session))
|
||||
return false;
|
||||
|
||||
connect(m_aesDtc.get(), &Interface::Dtc::bCContaminationChanged,
|
||||
this, &BCContaminationsModel::onDataChanged);
|
||||
|
||||
fillAvailableChargeIds(m_gearClass);
|
||||
|
||||
m_aesDtc->bCContaminations([this](const BCContamination &item) { insertRow(item); });
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace AreaEffectSimulation
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for AreaEffectSimulation - Contaminations Overview Dialog Model
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Malte Diers, SLSE, 2017-02-20
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QSet>
|
||||
#include <Plugins/AreaEffectSimulation/Gui/Base/aes_base_model.h>
|
||||
#include <ProjectDataManagement/pdm_enums.hpp>
|
||||
|
||||
namespace LtsSession
|
||||
{
|
||||
class LtsSession;
|
||||
}
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
|
||||
/************ Abstract Class for B AND C Contamination ***************/
|
||||
class BCContaminationsModel : public AesGuiBaseModel<BCContamination>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
bool initModel(LtsSession::LtsSession *session);
|
||||
|
||||
ProjectDataManagement::GearClass gearClass() const { return m_gearClass; }
|
||||
|
||||
protected:
|
||||
explicit BCContaminationsModel(ProjectDataManagement::GearClass gc, QObject *parent = nullptr)
|
||||
: AesGuiBaseModel<BCContamination>(parent)
|
||||
, m_gearClass(gc)
|
||||
{}
|
||||
|
||||
ProjectDataManagement::GearClass m_gearClass;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/******************** Class for Biological Contamination ***************/
|
||||
/************ Use "BCContaminationsModel *ptr" nevertheless! ***********/
|
||||
|
||||
class BContaminationsModel final : public BCContaminationsModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit BContaminationsModel(QObject *parent)
|
||||
: BCContaminationsModel(ProjectDataManagement::GearClass::Biological, parent)
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
/******************** Class for Chemical Contamination *****************/
|
||||
/************ Use "BCContaminationsModel *ptr" nevertheless! ***********/
|
||||
|
||||
class CContaminationsModel final : public BCContaminationsModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CContaminationsModel(QObject *parent)
|
||||
: BCContaminationsModel(ProjectDataManagement::GearClass::Chemical, parent)
|
||||
{}
|
||||
};
|
||||
} //namespace AreaEffectSimulation
|
||||
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
#
|
||||
# Created by Malte Diers, SLSE, 2017-02-13
|
||||
#
|
||||
|
||||
SET(aes_base_gui_SRCS
|
||||
aes_base_edit.cpp
|
||||
aes_base_edit.h
|
||||
aes_base_gui_plugin.cpp
|
||||
aes_base_gui_plugin.h
|
||||
aes_base_model.cpp
|
||||
aes_base_model.h
|
||||
aes_base_exports.h
|
||||
aes_itemlist.cpp
|
||||
aes_itemlist.h
|
||||
aes_pixmap_label.cpp
|
||||
aes_pixmap_label.h
|
||||
InfoView/aes_base_info.cpp
|
||||
InfoView/aes_base_info.h
|
||||
)
|
||||
|
||||
NGL_WRAP_UI(aes_base_gui_SRCS
|
||||
aes_itemlist.ui
|
||||
InfoView/aes_base_info.ui
|
||||
)
|
||||
|
||||
NGL_ADD_LIBRARY(WS AesBaseGui SHARED ${aes_base_gui_SRCS})
|
||||
NGL_TARGET_LINK_LIBRARIES(AesBaseGui
|
||||
PRIVATE
|
||||
ExmDataPluginInterface
|
||||
LtsPrinting
|
||||
ngltools
|
||||
PpmGuiComboboxPluginInterface
|
||||
SituationMapGuiPluginInterface
|
||||
svcAesCommon
|
||||
PUBLIC
|
||||
PdmDataPluginInterface
|
||||
PdmGuiPluginInterface
|
||||
LtsCoordTrans # because it's used by every lib which links against AesBaseGui
|
||||
ltsCoordWidget # because it's used by every lib which links against AesBaseGui
|
||||
LtsDataView # because it's used by every lib which links against AesBaseGui
|
||||
LtsSession
|
||||
LtsSessionData
|
||||
LtsUtilsGuiDds
|
||||
LtsWidgets
|
||||
Qt5::Widgets
|
||||
)
|
||||
|
||||
NGL_INSTALL_TARGET(AesBaseGui)
|
||||
@@ -0,0 +1,122 @@
|
||||
#include "aes_base_info.h"
|
||||
#include "ui_aes_base_info.h"
|
||||
|
||||
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
|
||||
#include <Plugins/ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <QDateTime>
|
||||
#include <AreaEffectSimulation/aes_translation.h>
|
||||
#include <ParticipantManagement/ppm_translation.h>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
BaseInfo::BaseInfo(QWidget *parent)
|
||||
: LtsDialog(parent)
|
||||
, m_session(nullptr)
|
||||
, m_ui(new Ui::BaseInfo)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
}
|
||||
|
||||
BaseInfo::~BaseInfo()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void BaseInfo::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("AES Info"));
|
||||
}
|
||||
|
||||
void BaseInfo::setEffectStart(qint64 effectStart)
|
||||
{
|
||||
if (effectStart > 0)
|
||||
{
|
||||
m_ui->lblEffectStart->show();
|
||||
m_ui->lbxEffectStart->show();
|
||||
m_ui->lblEffectStart->setText(QDateTime::fromMSecsSinceEpoch(effectStart).toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ui->lblEffectStart->hide();
|
||||
m_ui->lbxEffectStart->hide();
|
||||
}
|
||||
}
|
||||
|
||||
void BaseInfo::setEffectDuration(int32_t effectDuration)
|
||||
{
|
||||
if (effectDuration > 0)
|
||||
{
|
||||
m_ui->lblEffectDuration->show();
|
||||
m_ui->lbxEffectDuration->show();
|
||||
m_ui->lblEffectDuration->setText(LtsWidgets::readableDuration(effectDuration, false));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ui->lblEffectDuration->hide();
|
||||
m_ui->lbxEffectDuration->hide();
|
||||
}
|
||||
}
|
||||
|
||||
bool BaseInfo::setData(const AesItem *item)
|
||||
{
|
||||
if (!m_session)
|
||||
return false;
|
||||
|
||||
std::shared_ptr<ProjectDataManagement::Interface::Dtc> pdmDtc = nullptr;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> ppmDtc = nullptr;
|
||||
m_session->getDtc<ParticipantManagement::DataInterface>(ppmDtc);
|
||||
|
||||
if (!m_session->getDtc<ProjectDataManagement::DataInterface>(pdmDtc) || !pdmDtc )
|
||||
return false;
|
||||
|
||||
setEffectDuration(item->effectDuration());
|
||||
m_ui->lblIdentifier->setText(QString::fromStdString(item->name().c_str()));
|
||||
m_ui->lblChargeType->setText(pdmDtc->trChargeTypeShortName(item->chargeStruct().chargeTypeId(), true));
|
||||
m_ui->lblChargeType->setToolTip(pdmDtc->trChargeTypeName(item->chargeStruct().chargeTypeId(), true));
|
||||
m_ui->lblEffectState->setText(AreaEffectSimulation::toString(item->effectStateId()));
|
||||
|
||||
|
||||
setEffectStart(item->effectStart().is_set() ? item->effectStart().get() : 0);
|
||||
|
||||
if (item->participantId().is_set())
|
||||
{
|
||||
if (!ppmDtc)
|
||||
m_ui->lblParticipant->setText(tr("ID: %1").arg(item->participantId().get()));
|
||||
else
|
||||
{
|
||||
ParticipantManagement::Participant participant = ppmDtc->participant(item->partyId().get());
|
||||
m_ui->lblParticipant->setText(QString::fromStdString(participant.name()));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ui->lblParticipant->hide();
|
||||
m_ui->lbxParticipant->hide();
|
||||
}
|
||||
|
||||
if (item->partyId().is_set())
|
||||
{
|
||||
if (!ppmDtc)
|
||||
m_ui->lblParty->setText(tr("ID: %1").arg(item->partyId().get()));
|
||||
else
|
||||
{
|
||||
ParticipantManagement::Party party = ppmDtc->party(item->partyId().get());
|
||||
m_ui->lblParty->setText(ParticipantManagement::trPartyName(party.name()));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ui->lblParty->hide();
|
||||
m_ui->lblParty->hide();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void BaseInfo::init(LtsSession::LtsSessionDataDds *session)
|
||||
{
|
||||
m_session = session;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
#pragma once
|
||||
|
||||
#include "../aes_base_exports.h"
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <Services/AreaEffectSimulation/aes.hpp>
|
||||
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class BaseInfo;
|
||||
}
|
||||
|
||||
namespace LtsSession
|
||||
{
|
||||
class LtsSessionDataDds;
|
||||
}
|
||||
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
class AESBASEGUI_EXPORT BaseInfo : public LtsWidgets::LtsDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit BaseInfo(QWidget *parent = nullptr);
|
||||
~BaseInfo();
|
||||
|
||||
bool setData(const AesItem *item);
|
||||
void init(LtsSession::LtsSessionDataDds *session);
|
||||
|
||||
void setEffectStart(qint64 effectStart);
|
||||
void setEffectDuration(int32_t effectDuration);
|
||||
|
||||
private:
|
||||
void retranslate() override;
|
||||
|
||||
LtsSession::LtsSessionDataDds *m_session;
|
||||
Ui::BaseInfo *m_ui;
|
||||
};
|
||||
|
||||
}
|
||||
@@ -0,0 +1,179 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>BaseInfo</class>
|
||||
<widget class="QWidget" name="BaseInfo">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>139</width>
|
||||
<height>162</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Aes Info</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="lbxEffectState">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Effect State:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="lblEffectStart">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">today</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QLabel" name="lblEffectState">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">Active</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lbxEffectDuration">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Effect Duration:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLabel" name="lblEffectDuration">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">1m</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lbxIdentifier">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Identifier:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="lblIdentifier">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="lbxParty">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Party:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QLabel" name="lblParty">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">RED</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lbxEffectStart">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Effect Start:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="lbxChargeTye">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Charge Type:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLabel" name="lblChargeType">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">Mun</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="lbxParticipant">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Participant:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="QLabel" name="lblParticipant">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">Bla</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
+357
@@ -0,0 +1,357 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* AreaEffectSimulation - Contamination Edit Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-07-07
|
||||
*/
|
||||
|
||||
|
||||
#include "aes_base_edit.h"
|
||||
|
||||
#include <Plugins/AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
#include <Plugins/SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
#include <Plugins/ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
#include <Plugins/ExerciseManagement/exm_data_plugin_interface.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <LtsWidgets/lts_date_time_edit.h>
|
||||
#include <LtsCoordTrans/lts_coord_widget.h>
|
||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||
#include <QSpinBox>
|
||||
#include <QJsonDocument>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
BaseEdit::BaseEdit(const QString &menuGroup, const QString &loggerName, QWidget *parent, LtsWidgets::ButtonCombination buttonCombination)
|
||||
: LtsWidgets::LtsDialog(parent, buttonCombination)
|
||||
, m_aesItem()
|
||||
, m_dtc(nullptr)
|
||||
, m_ftc(nullptr)
|
||||
, m_sitMapGuiIfc(nullptr)
|
||||
, m_ppmGuiCbxIfc(nullptr)
|
||||
, m_session(nullptr)
|
||||
, m_menuGroup(menuGroup)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_logger(getLogger(loggerName))
|
||||
{
|
||||
m_aesItem.id(0);
|
||||
connect(this, &BaseEdit::visibilityChanged, this, &BaseEdit::onVisibilityChanged);
|
||||
}
|
||||
|
||||
void BaseEdit::setCombobxToValueIfPossible(QComboBox *cbx, int val)
|
||||
{
|
||||
int idx = cbx->findData(val);
|
||||
if (idx >= 0)
|
||||
cbx->setCurrentIndex(idx);
|
||||
}
|
||||
|
||||
void BaseEdit::onAesItemCreateReply(const Core::FunctionReplyObject &replyObject)
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
if (!replyObject.error() && m_sitMapGuiIfc)
|
||||
m_sitMapGuiIfc->removePreviewObject();
|
||||
}
|
||||
|
||||
void BaseEdit::onAesItemModifyReply(const Core::FunctionReplyObject &replyObject)
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
|
||||
if (!replyObject.error() && m_sitMapGuiIfc )
|
||||
m_sitMapGuiIfc->removePreviewObject();
|
||||
}
|
||||
|
||||
bool BaseEdit::isModifiable() const
|
||||
{
|
||||
AesEffectState effectState = m_aesItem.effectStateId();
|
||||
return (effectState == AreaEffectSimulation::AesEffectState_def::EsPaused ||
|
||||
effectState == AreaEffectSimulation::AesEffectState_def::EsActivated ||
|
||||
effectState == AreaEffectSimulation::AesEffectState_def::EsPrepared ||
|
||||
effectState == AreaEffectSimulation::AesEffectState_def::EsCreated ||
|
||||
effectState == AreaEffectSimulation::AesEffectState_def::EsUnknown ||
|
||||
effectState == AreaEffectSimulation::AesEffectState_def::EsReceived) &&
|
||||
(!m_session->isReplayPartition()) &&
|
||||
(m_session->app() != LtsAppDescriptor::App::OC); // not OC-App
|
||||
}
|
||||
|
||||
bool BaseEdit::isOnlyNameModifiable() const
|
||||
{
|
||||
AesEffectState effectState = m_aesItem.effectStateId();
|
||||
return (effectState == AreaEffectSimulation::AesEffectState_def::EsPaused ||
|
||||
effectState == AreaEffectSimulation::AesEffectState_def::EsActivated) &&
|
||||
(!m_session->isReplayPartition()) &&
|
||||
(m_session->app() != LtsAppDescriptor::App::OC); // not OC-App
|
||||
}
|
||||
|
||||
void BaseEdit::correctSpinBoxValue()
|
||||
{
|
||||
QSpinBox *sb = qobject_cast<QSpinBox*>(sender());
|
||||
if (sb)
|
||||
return correctSpinBoxValueInternal(sb);
|
||||
|
||||
QDoubleSpinBox *dsb = qobject_cast<QDoubleSpinBox*>(sender());
|
||||
if (dsb)
|
||||
return correctSpinBoxValueInternal(dsb);
|
||||
}
|
||||
|
||||
void BaseEdit::onVisibilityChanged(bool visible)
|
||||
{
|
||||
if (!m_sitMapGuiIfc)
|
||||
return;
|
||||
|
||||
if (!visible)
|
||||
m_sitMapGuiIfc->removePreviewObject();
|
||||
else
|
||||
showPreviewObject();
|
||||
}
|
||||
|
||||
void BaseEdit::correctSpinBoxValueInternal(QSpinBox *sb)
|
||||
{
|
||||
if (!sb)
|
||||
return;
|
||||
|
||||
int step = sb->singleStep();
|
||||
if (step == 1)
|
||||
return;
|
||||
|
||||
int value = sb->value();
|
||||
int remainder = (value - sb->minimum()) % step;
|
||||
if (remainder == 0)
|
||||
return;
|
||||
|
||||
if (2 * remainder > step)
|
||||
value += (step - remainder);
|
||||
else
|
||||
value -= remainder;
|
||||
|
||||
if (value > sb->maximum())
|
||||
value -= step;
|
||||
|
||||
if(value < sb->minimum())
|
||||
value = sb->minimum();
|
||||
|
||||
sb->setValue(value);
|
||||
}
|
||||
|
||||
void BaseEdit::correctSpinBoxValueInternal(QDoubleSpinBox *sb)
|
||||
{
|
||||
if (!sb)
|
||||
return;
|
||||
|
||||
double step = sb->singleStep();
|
||||
if (qFuzzyCompare(step, pow(10, sb->decimals())))
|
||||
return;
|
||||
|
||||
double value = sb->value();
|
||||
double remainder = fmod(value - sb->minimum(), step);
|
||||
if (qFuzzyCompare(remainder, 0))
|
||||
return;
|
||||
|
||||
if (2 * remainder > step)
|
||||
value += (step - remainder);
|
||||
else
|
||||
value -= remainder;
|
||||
|
||||
if (value > sb->maximum())
|
||||
value -= step;
|
||||
|
||||
if (value < sb->minimum())
|
||||
value = sb->minimum();
|
||||
|
||||
sb->setValue(value);
|
||||
}
|
||||
|
||||
bool BaseEdit::hasValidEffectStart(LtsWidgets::LtsDateTimeEdit *dte) const
|
||||
{
|
||||
if (isOnlyNameModifiable())
|
||||
return true;
|
||||
// if there is visible a enabled/disable checkbox -> also allow 0 as effect start
|
||||
if (dte->isCheckable() && !dte->isChecked())
|
||||
return true;
|
||||
const auto ms = dte->msecsSinceEpoch();
|
||||
return ms > m_session->partitionTime();
|
||||
}
|
||||
|
||||
void BaseEdit::setEffectStartEnabled(LtsWidgets::LtsDateTimeEdit *dte, bool enable)
|
||||
{
|
||||
if (enable)
|
||||
{
|
||||
int exerciseId = m_session->exerciseId();
|
||||
std::shared_ptr<ExerciseManagement::Interface::Dtc> exmDtc;
|
||||
m_session->getDtc<ExerciseManagement::DataInterface>(exmDtc);
|
||||
ExerciseManagement::Exercise exercise = exmDtc->exercise(exerciseId);
|
||||
|
||||
// Enablen der gesamten Checkbox nur, wenn Übung läuft:
|
||||
enable = (exercise.state() == ExerciseManagement::ExerciseState_def::Started ||
|
||||
exercise.state() == ExerciseManagement::ExerciseState_def::Paused);
|
||||
|
||||
// In Übungsvorbereitung keine Eingabe einer Zeit möglich:
|
||||
if (exercise.state() == ExerciseManagement::ExerciseState_def::Created)
|
||||
dte->setChecked(false);
|
||||
else // Ansonsten Status gemäß eingetragener Zeit.
|
||||
dte->setChecked(dte->msecsSinceEpoch() > 0);
|
||||
}
|
||||
else // Ansonsten Status gemäß eingetragener Zeit.
|
||||
dte->setChecked(dte->msecsSinceEpoch() > 0);
|
||||
// Gesamtstatus übernehmen.
|
||||
dte->setEnabled(enable);
|
||||
}
|
||||
|
||||
bool BaseEdit::has2DMap(bool showMsgBoxIfNot2D)
|
||||
{
|
||||
if (!m_sitMapGuiIfc)
|
||||
return false;
|
||||
if (m_sitMapGuiIfc->mapMode() != SituationMap::MapMode::MapMode_2D)
|
||||
{
|
||||
if (showMsgBoxIfNot2D)
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Only available in 2D mode"));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void BaseEdit::setCoordinates(const QVector<QPointF> &coords, bool reverse)
|
||||
{
|
||||
// Reverse if Frontline is chosen and width is taken to the right (like drawing an L)
|
||||
clearCoordinates();
|
||||
const auto cWidgets(coordWidgets());
|
||||
if (!reverse)
|
||||
{
|
||||
for (size_t i = 0; i < cWidgets.size() && i < static_cast<size_t>(coords.size()); ++i)
|
||||
cWidgets.at(i)->setCoordinate(coords.at(i));
|
||||
}
|
||||
else
|
||||
{
|
||||
auto copy(coords);
|
||||
std::reverse(std::begin(copy), std::end(copy));
|
||||
for (size_t i = 0; i < cWidgets.size() && i < static_cast<size_t>(copy.size()); ++i)
|
||||
cWidgets.at(i)->setCoordinate(copy.at(i));
|
||||
}
|
||||
}
|
||||
|
||||
void BaseEdit::setCoordinates(const std::vector<Core::GeoPosition2D> &coords)
|
||||
{
|
||||
clearCoordinates();
|
||||
const auto cWidgets(coordWidgets());
|
||||
for (size_t i = 0; i < cWidgets.size() && i < static_cast<size_t>(coords.size()); ++i)
|
||||
cWidgets.at(i)->setCoordinate(coords.at(i).lon(), coords.at(i).lat());
|
||||
}
|
||||
|
||||
std::vector<Core::GeoPosition2D> BaseEdit::getCoordinates() const
|
||||
{
|
||||
std::vector<Core::GeoPosition2D> segments;
|
||||
const auto cWidgets(coordWidgets());
|
||||
segments.reserve(cWidgets.size());
|
||||
for (const auto cw : cWidgets)
|
||||
{
|
||||
const QPointF coord = cw->coordinate();
|
||||
if (coord.isNull())
|
||||
break;
|
||||
segments.emplace_back(Core::GeoPosition2D(coord.x(), coord.y()));
|
||||
}
|
||||
return segments;
|
||||
}
|
||||
|
||||
QVector<QPointF> BaseEdit::getCoordinatesQPointF() const
|
||||
{
|
||||
QVector<QPointF> segments;
|
||||
const auto cWidgets(coordWidgets());
|
||||
segments.reserve(cWidgets.size());
|
||||
for (const auto *cw : cWidgets)
|
||||
{
|
||||
const QPointF coord = cw->coordinate();
|
||||
if (coord.isNull())
|
||||
break;
|
||||
segments.push_back(coord);
|
||||
}
|
||||
return segments;
|
||||
}
|
||||
|
||||
void BaseEdit::clearCoordinates()
|
||||
{
|
||||
for (auto *cw : coordWidgets())
|
||||
cw->clear();
|
||||
}
|
||||
|
||||
void BaseEdit::enabledCoordinates(bool enable)
|
||||
{
|
||||
for (auto *cw : coordWidgets())
|
||||
cw->setEnabled(enable);
|
||||
}
|
||||
|
||||
|
||||
void BaseEdit::onAreaChanged(const AesItem &data, DataModification modType)
|
||||
{
|
||||
// No, we don't update the UI elements (yet). If we wanted to, we had to
|
||||
// implement a virtual method such as enableUiElements...
|
||||
if (data.id() != m_aesItem.id())
|
||||
return;
|
||||
|
||||
if (modType == DataModification::eRemoved || data.effectStateId() == AesEffectState_def::EsRemoved)
|
||||
{
|
||||
// As a simple 'close()' does not work:
|
||||
__unchange__();
|
||||
closeRequest();
|
||||
return;
|
||||
}
|
||||
m_aesItem = data;
|
||||
enableUiElements(isModifiable() && !isOnlyNameModifiable());
|
||||
}
|
||||
|
||||
bool BaseEdit::init(int aesItemId, LtsSession::LtsSession *session)
|
||||
{
|
||||
if (m_session)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "double init()!";
|
||||
return false;
|
||||
}
|
||||
m_session = session;
|
||||
m_aesItem.id(aesItemId);
|
||||
|
||||
if (!m_session->getDtc<AreaEffectSimulation::DataInterface>(m_dtc))
|
||||
return false;
|
||||
if (!m_session->getFtc<AreaEffectSimulation::DataInterface>(m_ftc))
|
||||
return false;
|
||||
m_session->getForeignGuiInterface<SituationMap::ForeignGuiInterface>(m_sitMapGuiIfc);
|
||||
if (!m_session->getForeignGuiInterface<ParticipantManagement::ForeignGuiComboboxInterface>(m_ppmGuiCbxIfc))
|
||||
return false;
|
||||
|
||||
if (m_session->isReplayPartition() || (LtsAppDescriptor::App::OC == m_session->app()))
|
||||
setUnchangeable();
|
||||
|
||||
if (aesItemId == 0)
|
||||
{
|
||||
m_aesItem.effectSourceId(ProjectDataManagement::EffectSource_def::ES_Internal);
|
||||
m_buttonBox->setText(LtsWidgets::DialogButton::Ok, tr("Add"));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
double BaseEdit::distance(const Core::GeoPosition2D &p1, const Core::GeoPosition2D &p2)
|
||||
{
|
||||
LtsCoordTrans::UtmCoordinate start = LtsCoordTrans::UtmCoordinate::fromGeographic(p1.lon(), p1.lat());
|
||||
LtsCoordTrans::UtmCoordinate end = LtsCoordTrans::UtmCoordinate::fromGeographic(p2.lon(), p2.lat(), start.zone);
|
||||
double dx = start.x - end.x;
|
||||
double dy = start.y - end.y;
|
||||
return std::sqrt(dx*dx + dy*dy);
|
||||
}
|
||||
|
||||
bool BaseEdit::checkSegementLengths(QWidget *parent) const
|
||||
{
|
||||
auto segments = getCoordinates();
|
||||
for (auto i=0; i<((int) segments.size() - 1); ++i)
|
||||
{
|
||||
double dis = distance(segments[i], segments[i+1]);
|
||||
if (getMaxLength() != 0 && dis > getMaxLength())
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(parent, tr("The distance between Coordinate %1 and %2 is too long.\nThe segment is %3m long, but the maximum segment length is %4m.")
|
||||
.arg(i+1).arg(i+2).arg(QString::number(dis,'d',2),QString::number(getMaxLength(),'d',2)));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace AreaEffectSimulation
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* AreaEffectSimulation - Explosion Edit Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-07-07
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "aes_base_exports.h"
|
||||
#include <AreaEffectSimulation/logger.h>
|
||||
#include <AreaEffectSimulation/aes.hpp>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsWidgets/ui_requirement.h>
|
||||
|
||||
// For not having to include in every derived class, we do it here:
|
||||
#include <LtsUtilsGuiDds/request_helper.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsUtilsCore/data_modification_enum.h>
|
||||
#include <AreaEffectSimulation/aes_ftc.h>
|
||||
#include <AreaEffectSimulation/aes_operator_rights.h>
|
||||
#include <Plugins/ParticipantManagement/ppm_gui_combobox_plugin_interface.h>
|
||||
|
||||
class QSpinBox;
|
||||
class QDoubleSpinBox;
|
||||
|
||||
namespace SituationMap
|
||||
{
|
||||
class ForeignGuiInterface;
|
||||
}
|
||||
|
||||
namespace LtsWidgets
|
||||
{
|
||||
class LtsDateTimeEdit;
|
||||
}
|
||||
namespace LtsCoordWidget
|
||||
{
|
||||
class LtsCoordWidget;
|
||||
}
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
namespace Interface
|
||||
{
|
||||
class Ftc;
|
||||
class Dtc;
|
||||
}
|
||||
|
||||
class AESBASEGUI_EXPORT BaseEdit : public LtsWidgets::LtsDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit BaseEdit(const QString &menuGroup,
|
||||
const QString &loggerName,
|
||||
QWidget *parent = nullptr,
|
||||
LtsWidgets::ButtonCombination buttonCombination = LtsWidgets::ButtonCombination::OkApplyCancel);
|
||||
|
||||
bool init(int aesItemId, LtsSession::LtsSession *session);
|
||||
|
||||
QString menuGroup() const { return m_menuGroup; }
|
||||
virtual QString dialogIdentifier() const = 0;
|
||||
|
||||
public Q_SLOTS:
|
||||
void onAreaChanged(const AesItem &data, DataModification modType);
|
||||
|
||||
protected Q_SLOTS:
|
||||
void enaDisa() {}
|
||||
void correctSpinBoxValue();
|
||||
void onVisibilityChanged(bool visible);
|
||||
virtual void showPreviewObject() = 0;
|
||||
|
||||
protected:
|
||||
|
||||
void setCombobxToValueIfPossible(QComboBox *cbx, int val);
|
||||
void onAesItemCreateReply(const Core::FunctionReplyObject &replyObject);
|
||||
void onAesItemModifyReply(const Core::FunctionReplyObject &replyObject);
|
||||
bool isModifiable() const;
|
||||
virtual bool isOnlyNameModifiable() const;
|
||||
virtual void enableUiElements(bool enable) = 0;
|
||||
void correctSpinBoxValueInternal(QSpinBox *sb);
|
||||
void correctSpinBoxValueInternal(QDoubleSpinBox *sb);
|
||||
bool hasValidEffectStart(LtsWidgets::LtsDateTimeEdit *dte) const;
|
||||
void setEffectStartEnabled(LtsWidgets::LtsDateTimeEdit *dte, bool enable = true);
|
||||
|
||||
virtual std::vector<LtsCoordWidget::LtsCoordWidget *> coordWidgets() const { return {}; }
|
||||
void setCoordinates(const QVector<QPointF> &coords, bool reverse);
|
||||
void setCoordinates(const std::vector<Core::GeoPosition2D> &coords);
|
||||
std::vector<Core::GeoPosition2D> getCoordinates() const;
|
||||
QVector<QPointF> getCoordinatesQPointF() const;
|
||||
void clearCoordinates();
|
||||
void enabledCoordinates(bool enable);
|
||||
bool has2DMap(bool showMsgBoxIfNot2D = true);
|
||||
|
||||
static double distance(const Core::GeoPosition2D &p1, const Core::GeoPosition2D &p2);
|
||||
static bool isInBounds(int value, const QPair<int, int>&minMax) { return (value >= minMax.first) && (value <= minMax.second); }
|
||||
|
||||
bool checkSegementLengths(QWidget *parent) const;
|
||||
virtual double getMaxLength() const { return 0; }
|
||||
|
||||
AesItem m_aesItem;
|
||||
|
||||
std::shared_ptr<Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<Interface::Ftc> m_ftc;
|
||||
std::shared_ptr<SituationMap::ForeignGuiInterface> m_sitMapGuiIfc;
|
||||
std::shared_ptr<ParticipantManagement::ForeignGuiComboboxInterface> m_ppmGuiCbxIfc;
|
||||
|
||||
LtsSession::LtsSession *m_session;
|
||||
QString m_menuGroup;
|
||||
LtsUtils::RequestHelper *m_requestHelper;
|
||||
LOGGER_T m_logger;
|
||||
};
|
||||
|
||||
} //namespace AreaEffectSimulation
|
||||
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* Export definitions
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
#ifndef AESBASEGUI_EXPORT
|
||||
# ifdef BUILD_STATIC_LIBRARIES
|
||||
# define AESBASEGUI_EXPORT
|
||||
# else
|
||||
# if defined(MAKE_AESBASEGUI_LIB)
|
||||
# define AESBASEGUI_EXPORT Q_DECL_EXPORT
|
||||
# else
|
||||
# define AESBASEGUI_EXPORT Q_DECL_IMPORT
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
@@ -0,0 +1,60 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* GUI Plugin for AreaEffectSimulation - Contamination
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-07-07
|
||||
*/
|
||||
|
||||
#include "aes_base_gui_plugin.h"
|
||||
|
||||
#include <Plugins/AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
|
||||
#include <Plugins/ProjectDataManagement/pdm_gui_plugin_interface.h>
|
||||
#include <Plugins/SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <AreaEffectSimulation/aes_operator_rights.h>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
AesBaseInterface::AesBaseInterface(LtsSession::LtsSession *session, NGL::INGLLogger &logger)
|
||||
: GuiPluginBase::Interface(session, logger)
|
||||
, m_dtc(nullptr)
|
||||
, m_ftc(nullptr)
|
||||
, m_pdmDtc(nullptr)
|
||||
, m_pdmGuiIfc(nullptr)
|
||||
, m_sitmapGuIfc(nullptr)
|
||||
{}
|
||||
|
||||
|
||||
bool AesBaseInterface::fetchInterfaces()
|
||||
{
|
||||
if (!m_session->getDtc<AreaEffectSimulation::DataInterface>(m_dtc))
|
||||
return false;
|
||||
if (!m_session->getFtc<AreaEffectSimulation::DataInterface>(m_ftc))
|
||||
return false;
|
||||
if (!m_session->getDtc<ProjectDataManagement::DataInterface>(m_pdmDtc))
|
||||
return false;
|
||||
if (!m_session->getForeignGuiInterface<ProjectDataManagement::ForeignGuiInterface>(m_pdmGuiIfc))
|
||||
return false;
|
||||
if (!m_session->getForeignGuiInterface<ParticipantManagement::ForeignGuiComboboxInterface>(m_ppmGuiCbxIfc))
|
||||
return false;
|
||||
|
||||
m_session->getForeignGuiInterface<SituationMap::ForeignGuiInterface>(m_sitmapGuIfc); // optional
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void AesBaseInterface::clearInterfaces()
|
||||
{
|
||||
m_ppmGuiCbxIfc = nullptr;
|
||||
m_sitmapGuIfc = nullptr;
|
||||
m_pdmGuiIfc = nullptr;
|
||||
m_pdmDtc = nullptr;
|
||||
m_ftc = nullptr;
|
||||
m_dtc = nullptr;
|
||||
}
|
||||
|
||||
} // namespace AreaEffectSimulation
|
||||
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Gui Plugin for AreaEffectSimulation - Contamination
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-07-07
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "aes_base_exports.h"
|
||||
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
|
||||
#include <Plugins/ProjectDataManagement/pdm_gui_plugin_interface.h>
|
||||
#include <Plugins/SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
#include <Plugins/ParticipantManagement/ppm_gui_combobox_plugin_interface.h>
|
||||
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
class AESBASEGUI_EXPORT AesBaseGuiPlugin : public QObject, public GuiPluginBase::Plugin
|
||||
{
|
||||
Q_INTERFACES(GuiPluginBase::Plugin)
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AesBaseGuiPlugin() = default;
|
||||
~AesBaseGuiPlugin() = default;
|
||||
};
|
||||
|
||||
class AESBASEGUI_EXPORT AesBaseInterface : public QObject, public GuiPluginBase::Interface
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QString menuGroup() const override { return tr("Area Effect Simulation"); }
|
||||
bool fetchInterfaces() override;
|
||||
void clearInterfaces() override;
|
||||
bool availableInPartition(IDL::PartitionType partition) const override
|
||||
{
|
||||
return partition == IDL::PartitionType::Exercise ||
|
||||
partition == IDL::PartitionType::Replay;
|
||||
}
|
||||
|
||||
protected:
|
||||
explicit AesBaseInterface(LtsSession::LtsSession *session, NGL::INGLLogger &logger);
|
||||
|
||||
private:
|
||||
std::shared_ptr<AreaEffectSimulation::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<AreaEffectSimulation::Interface::Ftc> m_ftc;
|
||||
std::shared_ptr<ProjectDataManagement::Interface::Dtc> m_pdmDtc;
|
||||
std::shared_ptr<ProjectDataManagement::ForeignGuiInterface> m_pdmGuiIfc;
|
||||
std::shared_ptr<SituationMap::ForeignGuiInterface> m_sitmapGuIfc;
|
||||
std::shared_ptr<ParticipantManagement::ForeignGuiComboboxInterface> m_ppmGuiCbxIfc;
|
||||
};
|
||||
|
||||
} // namespace AreaEffectSimulation
|
||||
@@ -0,0 +1,356 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* AreaEffectManangement - Aes Item Overview Dialog Model Base Class to be inherited by the Area Types
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Malte Diers, SLSE, 2016-09-26
|
||||
*/
|
||||
|
||||
#include "aes_base_model.h"
|
||||
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
|
||||
#include <Plugins/ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
#include <Plugins/ParticipantManagement/ppm_gui_combobox_plugin_interface.h>
|
||||
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
|
||||
#include <ParticipantManagement/ppm_translation.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
|
||||
#include <QLocale>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
//
|
||||
// AesGuiBasHelpers
|
||||
//
|
||||
AesGuiBasHelpers::AesGuiBasHelpers()
|
||||
: m_aesDtc(nullptr)
|
||||
, m_pdmDtc(nullptr)
|
||||
, m_ppmDtc(nullptr)
|
||||
, m_logger(getLogger("AesGuiBase"))
|
||||
{}
|
||||
|
||||
bool AesGuiBasHelpers::initModel(LtsSession::LtsSession *session)
|
||||
{
|
||||
if (m_aesDtc)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "double init()!";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!session->getDtc<AreaEffectSimulation::DataInterface>(m_aesDtc))
|
||||
return false;
|
||||
if (!session->getDtc<ProjectDataManagement::DataInterface>(m_pdmDtc))
|
||||
return false;
|
||||
if (!session->getDtc<ParticipantManagement::DataInterface>(m_ppmDtc))
|
||||
return false;
|
||||
session->getForeignGuiInterface<ParticipantManagement::ForeignGuiComboboxInterface>(m_ppmGuiCbxIfc);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QVariant AesGuiBasHelpers::stringFromPartyId(const dds::core::optional<int> &id) const
|
||||
{
|
||||
if (!id.is_set())
|
||||
return QObject::tr("---");
|
||||
auto it = m_partyNames.find(id.get());
|
||||
if (it != m_partyNames.end())
|
||||
return it.value();
|
||||
const QString name = ParticipantManagement::trPartyName(m_ppmDtc->party(id.get()).name());
|
||||
m_partyNames.insert(id.get(), name);
|
||||
return name;
|
||||
}
|
||||
|
||||
QIcon AesGuiBasHelpers::iconFromPartyId(const dds::core::optional<int> &id) const
|
||||
{
|
||||
if (!id.is_set() || !m_ppmGuiCbxIfc)
|
||||
return QIcon();
|
||||
auto it = m_partyIcons.find(id.get());
|
||||
if (it != m_partyIcons.end())
|
||||
return it.value();
|
||||
const QRgb col = QRgb(m_ppmDtc->party(id.get()).color());
|
||||
const QIcon icon = m_ppmGuiCbxIfc->pixmapFromParty(col);
|
||||
m_partyIcons.insert(id.get(), icon);
|
||||
return icon;
|
||||
}
|
||||
|
||||
QVariant AesGuiBasHelpers::hierarchyFromParticipantId(const dds::core::optional<int> &id) const
|
||||
{
|
||||
if (!id.is_set())
|
||||
return QObject::tr("---");
|
||||
auto it = m_participantHierarchy.find(id.get());
|
||||
if (it != m_participantHierarchy.end())
|
||||
return it.value();
|
||||
const QString name = m_ppmDtc->hierarchyFromParticipant(id.get());
|
||||
m_participantHierarchy.insert(id.get(), name);
|
||||
return name;
|
||||
}
|
||||
|
||||
QVariant AesGuiBasHelpers::chargeTypeName(int chargeTypeId, bool shortName) const
|
||||
{
|
||||
if (shortName)
|
||||
{
|
||||
auto it = m_chargeTypeShortNames.find(chargeTypeId);
|
||||
if (it != m_chargeTypeShortNames.end())
|
||||
return it.value();
|
||||
const QString name = m_pdmDtc->trChargeTypeShortName(chargeTypeId, true);
|
||||
m_chargeTypeShortNames.insert(chargeTypeId, name);
|
||||
return name;
|
||||
}
|
||||
|
||||
auto it = m_chargeTypeNames.find(chargeTypeId);
|
||||
if (it != m_chargeTypeNames.end())
|
||||
return it.value();
|
||||
const QString name = m_pdmDtc->trChargeTypeName(chargeTypeId, true);
|
||||
m_chargeTypeNames.insert(chargeTypeId, name);
|
||||
return name;
|
||||
|
||||
}
|
||||
|
||||
QString AesGuiBasHelpers::simulationTypeText(bool isCentral)
|
||||
{
|
||||
return isCentral ? QObject::tr("central") : QObject::tr("peripheral");
|
||||
}
|
||||
|
||||
void AesGuiBasHelpers::updateEffectStateComboboxFilterData(bool bWithPause)
|
||||
{
|
||||
LtsWidgets::ComboboxFilterContent cfc;
|
||||
LtsWidgets::ComboboxFilterData cfd;
|
||||
const auto effectStates = {
|
||||
AesEffectState::EsExpired,
|
||||
AesEffectState::EsCreated,
|
||||
AesEffectState::EsPrepared,
|
||||
AesEffectState::EsActivated,
|
||||
AesEffectState::EsPaused,
|
||||
AesEffectState::EsFired,
|
||||
AesEffectState::EsReceived
|
||||
};
|
||||
for (const auto es : effectStates) {
|
||||
if (!bWithPause && es == AesEffectState::EsPaused)
|
||||
continue;
|
||||
cfd.data = es;
|
||||
cfd.text = AreaEffectSimulation::toString(es);
|
||||
cfc.data.push_back(cfd);
|
||||
}
|
||||
cfc.sortItems = false;
|
||||
m_cbxFilterEffectState = cfc.toVariant();
|
||||
}
|
||||
|
||||
void AesGuiBasHelpers::updateComboboxFilterData(const QSet<int> &availablePartyIds,
|
||||
const QSet<int> &availabelChargeIds)
|
||||
{
|
||||
LtsWidgets::ComboboxFilterContent cfc;
|
||||
LtsWidgets::ComboboxFilterData cfd;
|
||||
for (const int i : qAsConst(availabelChargeIds))
|
||||
{
|
||||
cfd.data = i;
|
||||
cfd.text = chargeTypeName(i).toString();
|
||||
cfc.data.push_back(cfd);
|
||||
}
|
||||
cfc.sortItems = true;
|
||||
m_cbxFilterChargeType = cfc.toVariant();
|
||||
|
||||
cfc.data.clear();
|
||||
for (const int i : qAsConst(availablePartyIds))
|
||||
{
|
||||
cfd.data = i;
|
||||
cfd.text = ParticipantManagement::trPartyName(m_ppmDtc->party(i).name());
|
||||
cfd.icon = iconFromPartyId(i);
|
||||
cfc.data.push_back(cfd);
|
||||
}
|
||||
cfc.sortItems = false;
|
||||
m_cbxFilterParty = cfc.toVariant();
|
||||
}
|
||||
|
||||
void AreaEffectSimulation::AesGuiBasHelpers::updateSimulationTypeComboboxFilterData()
|
||||
{
|
||||
LtsWidgets::ComboboxFilterContent cfc;
|
||||
LtsWidgets::ComboboxFilterData cfd;
|
||||
|
||||
cfd.text = simulationTypeText(true);
|
||||
cfd.data = cfd.text;
|
||||
cfc.data.push_back(cfd);
|
||||
|
||||
cfd.text = simulationTypeText(false);
|
||||
cfd.data = cfd.text;
|
||||
cfc.data.push_back(cfd);
|
||||
|
||||
cfc.sortItems = false;
|
||||
m_cbxFilterSimulationType = cfc.toVariant();
|
||||
}
|
||||
|
||||
void AesGuiBasHelpers::fillAvailableChargeIds(ProjectDataManagement::GearClass gc)
|
||||
{
|
||||
m_availableChargeIds.clear();
|
||||
const QVector<ProjectDataManagement::ChargeType> availableCharges = m_pdmDtc->chargesForGearClass(gc);
|
||||
for (const auto &charge : availableCharges)
|
||||
m_availableChargeIds += charge.id();
|
||||
// enable filter although no charges for this type are available
|
||||
if (m_availableChargeIds.isEmpty())
|
||||
m_availableChargeIds += 0;
|
||||
}
|
||||
|
||||
void AesGuiBasHelpers::fillAvailableChargeIds(const QVector<ProjectDataManagement::GearClass> &gcs)
|
||||
{
|
||||
m_availableChargeIds.clear();
|
||||
|
||||
for (auto gc : qAsConst(gcs))
|
||||
{
|
||||
const QVector<ProjectDataManagement::ChargeType> &availableCharges = m_pdmDtc->chargesForGearClass(gc);
|
||||
for (const auto &charge : qAsConst(availableCharges))
|
||||
m_availableChargeIds += charge.id();
|
||||
}
|
||||
// enable filter although no charges for this type are available
|
||||
if (m_availableChargeIds.isEmpty())
|
||||
m_availableChargeIds += 0;
|
||||
}
|
||||
|
||||
//
|
||||
// AesItemSortFilterProxyModel
|
||||
//
|
||||
AesItemSortFilterProxyModel::AesItemSortFilterProxyModel(LtsSession::LtsSession *session, QObject *parent)
|
||||
: LtsWidgets::LtsColumnFilterProxyModel(parent)
|
||||
, m_session(session)
|
||||
, m_showExpired(false)
|
||||
, m_offset(5 * 60 * 1000) // default: 5 minutes
|
||||
{
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> ppmDtc;
|
||||
if (m_session->getDtc<ParticipantManagement::DataInterface>(ppmDtc))
|
||||
{
|
||||
auto cb = [this](const ParticipantManagement::Party &party)
|
||||
{
|
||||
m_partyColors[party.id()] = QColor::fromRgb(QRgb(party.color()));
|
||||
};
|
||||
ppmDtc->partys(cb);
|
||||
}
|
||||
}
|
||||
|
||||
void AesItemSortFilterProxyModel::setShowExpired(bool showExpired)
|
||||
{
|
||||
if (m_showExpired == showExpired)
|
||||
return;
|
||||
|
||||
m_showExpired = showExpired;
|
||||
invalidateFilter();
|
||||
}
|
||||
|
||||
void AesItemSortFilterProxyModel::setOffset(int offsetMsecs)
|
||||
{
|
||||
if (m_offset == offsetMsecs)
|
||||
return;
|
||||
|
||||
m_offset = offsetMsecs;
|
||||
invalidateFilter();
|
||||
}
|
||||
|
||||
bool AesItemSortFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
|
||||
{
|
||||
bool bRet = checkFilter(source_row);
|
||||
if (!bRet)
|
||||
return false;
|
||||
return LtsWidgets::LtsColumnFilterProxyModel::filterAcceptsRow(source_row, source_parent);
|
||||
}
|
||||
|
||||
bool AesItemSortFilterProxyModel::lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const
|
||||
{
|
||||
if (source_left.column() != source_right.column())
|
||||
return LtsWidgets::LtsColumnFilterProxyModel::lessThan(source_left, source_right);
|
||||
|
||||
switch (source_left.column())
|
||||
{
|
||||
case AesGuiBasHelpers::BcEffectStart:
|
||||
{
|
||||
const auto effectStartLeft = aesEffectStart(source_left.row());
|
||||
const auto effectStartRight = aesEffectStart(source_right.row());
|
||||
if (effectStartLeft.is_set() && effectStartRight.is_set())
|
||||
return effectStartLeft.get() < effectStartRight.get();
|
||||
if (effectStartRight.is_set())
|
||||
return true;
|
||||
if (effectStartLeft.is_set())
|
||||
return false;
|
||||
return aesId(source_left.row()) < aesId(source_right.row());
|
||||
}
|
||||
case AesGuiBasHelpers::BcEffectDuration:
|
||||
{
|
||||
const auto effectDurationLeft = aesEffectDuration(source_left.row());
|
||||
const auto effectDurationRight = aesEffectDuration(source_right.row());
|
||||
if (effectDurationLeft == effectDurationRight)
|
||||
return aesId(source_left.row()) < aesId(source_right.row());
|
||||
return effectDurationLeft < effectDurationRight;
|
||||
}
|
||||
case AesGuiBasHelpers::BcEffectState:
|
||||
{
|
||||
const auto effectStateLeft = aesEffectStateId(source_left.row());
|
||||
const auto effectStateRight = aesEffectStateId(source_right.row());
|
||||
if (effectStateLeft == effectStateRight)
|
||||
return aesId(source_left.row()) < aesId(source_right.row());
|
||||
return effectStateLeft < effectStateRight;
|
||||
}
|
||||
case AesGuiBasHelpers::BcEffectSource:
|
||||
{
|
||||
const auto effectSourceLeft = aesEffectSourceId(source_left.row());
|
||||
const auto effectSourceRight = aesEffectSourceId(source_right.row());
|
||||
if (effectSourceLeft == effectSourceRight)
|
||||
return aesId(source_left.row()) < aesId(source_right.row());
|
||||
return effectSourceLeft < effectSourceRight;
|
||||
}
|
||||
case AesGuiBasHelpers::BcParty:
|
||||
{
|
||||
const auto partyIdLeft = partyId(source_left.row());
|
||||
const auto partyIdRight = partyId(source_right.row());
|
||||
if (partyIdLeft == partyIdRight)
|
||||
return aesId(source_left.row()) < aesId(source_right.row());
|
||||
return partyIdLeft < partyIdRight;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return LtsWidgets::LtsColumnFilterProxyModel::lessThan(source_left, source_right);
|
||||
}
|
||||
|
||||
|
||||
bool AesItemSortFilterProxyModel::checkFilter(int source_row) const
|
||||
{
|
||||
int32_t party = partyId(source_row);
|
||||
if (party != -1 && !LtsSessionData::LtsSessionData::getInstance()->isVisibleParty(m_session->exerciseId(), party))
|
||||
return false;
|
||||
|
||||
const auto effectStateId = aesEffectStateId(source_row);
|
||||
if (effectStateId == AesEffectState_def::EsRemoved)
|
||||
return false;
|
||||
|
||||
// If showExpired: Show all
|
||||
if (showExpired())
|
||||
return true;
|
||||
|
||||
const int id = aesId(source_row);
|
||||
if (id <= 0)
|
||||
return false;
|
||||
|
||||
// If MA is not in state expired: Show
|
||||
if (effectStateId != AreaEffectSimulation::AesEffectState::EsExpired && effectStateId != AreaEffectSimulation::AesEffectState::EsRemoved)
|
||||
return true;
|
||||
|
||||
if (!m_session)
|
||||
{
|
||||
// Todo: Log
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto effectStart = aesEffectStart(source_row);
|
||||
qint64 effectEnd = 0;
|
||||
if (effectStart.is_set())
|
||||
effectEnd = effectStart.get() + aesEffectDuration(source_row);
|
||||
|
||||
// Expired. Show only if younger than m_offset
|
||||
if (effectStart.is_set() &&
|
||||
effectEnd + m_offset > m_session->partitionTime())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
} // namespace AreaEffectSimulation
|
||||
+375
@@ -0,0 +1,375 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* AreaEffectManangement - Overview Dialog Model Base
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Mike Wille, SLSE, 2016-09-26
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "aes_base_exports.h"
|
||||
|
||||
|
||||
#include <AreaEffectSimulation/aes.hpp>
|
||||
#include <AreaEffectSimulation/aes_translation.h>
|
||||
#include <AreaEffectSimulation/aes_dtc.h>
|
||||
#include <AreaEffectSimulation/logger.h>
|
||||
#include <ProjectDataManagement/pdm_translation.h>
|
||||
|
||||
#include <QSet>
|
||||
#include <QVector>
|
||||
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
#include <LtsWidgets/lts_column_filter_proxy_model.h>
|
||||
#include <ngltools/ngltools_dtg.h>
|
||||
#include <Plugins/AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
#include <ProjectDataManagement/pdm_enums.hpp>
|
||||
|
||||
const static int DEFAULT_EFFECT_DURATION = 777777;
|
||||
|
||||
namespace LtsSession
|
||||
{
|
||||
class LtsSession;
|
||||
}
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
class ForeignGuiComboboxInterface;
|
||||
}
|
||||
namespace ProjectDataManagement
|
||||
{
|
||||
namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
class AESBASEGUI_EXPORT AesGuiBasHelpers
|
||||
{
|
||||
public:
|
||||
enum BaseColumns
|
||||
{
|
||||
BcId,
|
||||
BcName,
|
||||
BcChargeType,
|
||||
BcEffectDuration,
|
||||
BcEffectStart,
|
||||
BcEffectState,
|
||||
BcParty,
|
||||
BcParticipant,
|
||||
BcIsCentral,
|
||||
BcEffectSource,
|
||||
BcCount
|
||||
};
|
||||
|
||||
protected:
|
||||
AesGuiBasHelpers();
|
||||
|
||||
virtual ~AesGuiBasHelpers() = default;
|
||||
|
||||
virtual bool initModel(LtsSession::LtsSession *session);
|
||||
|
||||
QVariant stringFromPartyId(const dds::core::optional<int> &id) const;
|
||||
QIcon iconFromPartyId(const dds::core::optional<int> &id) const;
|
||||
QVariant hierarchyFromParticipantId(const dds::core::optional<int> &id) const;
|
||||
QVariant chargeTypeName(int chargeTypeId, bool shortName = true) const;
|
||||
static QString simulationTypeText(bool isCentral);
|
||||
|
||||
void updateEffectStateComboboxFilterData(bool bWithPause);
|
||||
void updateComboboxFilterData(const QSet<int> &availablePartyIds,
|
||||
const QSet<int> &availabelChargeIds);
|
||||
void updateSimulationTypeComboboxFilterData();
|
||||
void fillAvailableChargeIds(ProjectDataManagement::GearClass gc);
|
||||
void fillAvailableChargeIds(const QVector<ProjectDataManagement::GearClass> &gcs);
|
||||
|
||||
protected:
|
||||
std::shared_ptr<AreaEffectSimulation::Interface::Dtc> m_aesDtc;
|
||||
std::shared_ptr<ProjectDataManagement::Interface::Dtc> m_pdmDtc;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
std::shared_ptr<ParticipantManagement::ForeignGuiComboboxInterface> m_ppmGuiCbxIfc;
|
||||
|
||||
QVariant m_cbxFilterChargeType;
|
||||
QVariant m_cbxFilterEffectState;
|
||||
QVariant m_cbxFilterParty;
|
||||
QVariant m_cbxFilterSimulationType;
|
||||
|
||||
QSet<int> m_availableChargeIds;
|
||||
LOGGER_T m_logger;
|
||||
|
||||
private:
|
||||
mutable QHash<int, QVariant> m_partyNames;
|
||||
mutable QHash<int, QIcon> m_partyIcons;
|
||||
mutable QHash<int, QVariant> m_participantHierarchy;
|
||||
mutable QHash<int, QVariant> m_chargeTypeNames;
|
||||
mutable QHash<int, QVariant> m_chargeTypeShortNames;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
class AesGuiBaseModel : public LtsWidgets::LtsAbstractTableModel<T>, public AesGuiBasHelpers
|
||||
{
|
||||
protected:
|
||||
explicit AesGuiBaseModel(QObject *parent = nullptr, const QVector<QString> &vecAdditionalColumns = QVector<QString>())
|
||||
: LtsWidgets::LtsAbstractTableModel<T>({QObject::tr("Id"),
|
||||
QObject::tr("Name"),
|
||||
QObject::tr("Charge Type"),
|
||||
QObject::tr("Effect Duration"),
|
||||
QObject::tr("Effect Start"),
|
||||
QObject::tr("Effect State"),
|
||||
QObject::tr("Party"),
|
||||
QObject::tr("Participant"),
|
||||
QObject::tr("SimulationType"),
|
||||
QObject::tr("EffectSource")},
|
||||
parent)
|
||||
{
|
||||
LtsWidgets::LtsAbstractTableModel<T>::m_vecColumns.append(vecAdditionalColumns);
|
||||
QObject::connect(this, &AesGuiBaseModel::rowsInserted,
|
||||
this, &AesGuiBaseModel::onUpdateComboboxFilterData);
|
||||
QObject::connect(this, &AesGuiBaseModel::rowsRemoved,
|
||||
this, &AesGuiBaseModel::onUpdateComboboxFilterData);
|
||||
QObject::connect(this, &AesGuiBaseModel::modelReset,
|
||||
this, &AesGuiBaseModel::onUpdateComboboxFilterData);
|
||||
updateEffectStateComboboxFilterData(false);
|
||||
updateSimulationTypeComboboxFilterData();
|
||||
onUpdateComboboxFilterData();
|
||||
}
|
||||
|
||||
void onUpdateComboboxFilterData()
|
||||
{
|
||||
QSet<int> availabelChargeIds;
|
||||
QSet<int> availablePartyIds;
|
||||
for (const T &data : qAsConst(AesGuiBaseModel::m_vecData))
|
||||
{
|
||||
availabelChargeIds.insert(data.chargeStruct().chargeTypeId());
|
||||
if (data.partyId().is_set())
|
||||
availablePartyIds.insert(data.partyId().get());
|
||||
}
|
||||
updateComboboxFilterData(availablePartyIds, availabelChargeIds);
|
||||
}
|
||||
|
||||
int cntBaseColumns() const
|
||||
{
|
||||
return BcCount;
|
||||
}
|
||||
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role) const override
|
||||
{
|
||||
if (orientation == Qt::Horizontal && role == LtsWidgets::LtsColumnFilterProxyModel::ComboboxFilterRole)
|
||||
{
|
||||
switch (section)
|
||||
{
|
||||
case BcParty:
|
||||
return m_cbxFilterParty;
|
||||
case BcChargeType:
|
||||
return m_cbxFilterChargeType;
|
||||
case BcEffectState:
|
||||
return m_cbxFilterEffectState;
|
||||
case BcIsCentral:
|
||||
return m_cbxFilterSimulationType;
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
}
|
||||
return LtsWidgets::LtsAbstractTableModel<T>::headerData(section, orientation, role);
|
||||
}
|
||||
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override
|
||||
{
|
||||
if (!LtsWidgets::LtsAbstractTableModel<T>::indexIsValid(index))
|
||||
return QVariant();
|
||||
const T &item = LtsWidgets::LtsAbstractTableModel<T>::m_vecData.at(index.row());
|
||||
return data(item, index.column(), role);
|
||||
}
|
||||
|
||||
|
||||
QVariant data(const T &item, int column, int role = Qt::DisplayRole) const
|
||||
{
|
||||
if (role == Qt::ToolTipRole)
|
||||
{
|
||||
switch (column)
|
||||
{
|
||||
case BcId:
|
||||
case BcName:
|
||||
case BcEffectStart:
|
||||
case BcIsCentral:
|
||||
return QVariant();
|
||||
case BcChargeType:
|
||||
return QObject::tr("Id: %1").arg(item.chargeStruct().chargeTypeId());
|
||||
case BcEffectDuration:
|
||||
{
|
||||
if (item.effectDuration() == DEFAULT_EFFECT_DURATION)
|
||||
return QStringLiteral("---");
|
||||
else
|
||||
return QObject::tr("%1 secs").arg(QString::number(item.effectDuration() / 1000.0, 'f', 3));
|
||||
}
|
||||
case BcEffectState:
|
||||
return QObject::tr("Id: %1").arg(item.effectStateId().underlying());
|
||||
case BcEffectSource:
|
||||
return QObject::tr("Id: %1").arg(item.effectSourceId().underlying());
|
||||
case BcParty:
|
||||
return QObject::tr("Id: %1").arg(item.partyId().is_set() ? item.partyId().get() : -1);
|
||||
case BcParticipant:
|
||||
return QObject::tr("Id: %1").arg(item.participantId().is_set() ? item.participantId().get() : -1);
|
||||
}
|
||||
}
|
||||
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
switch (column)
|
||||
{
|
||||
case BcId:
|
||||
return item.id();
|
||||
case BcName:
|
||||
return QString::fromUtf8(item.name().c_str());
|
||||
case BcChargeType:
|
||||
return chargeTypeName(item.chargeStruct().chargeTypeId());
|
||||
case BcEffectDuration:
|
||||
if (item.effectDuration() == DEFAULT_EFFECT_DURATION)
|
||||
return QStringLiteral("---");
|
||||
else
|
||||
return LtsWidgets::readableDuration(item.effectDuration());
|
||||
case BcEffectStart:
|
||||
return item.effectStart().is_set() ? DTG::toStringMSec(item.effectStart().get()) : QObject::tr("---");
|
||||
case BcEffectState:
|
||||
return AreaEffectSimulation::toString(item.effectStateId());
|
||||
case BcEffectSource:
|
||||
return ProjectDataManagement::toString(item.effectSourceId());
|
||||
case BcParty:
|
||||
return stringFromPartyId(item.partyId());
|
||||
case BcParticipant:
|
||||
return hierarchyFromParticipantId(item.participantId());
|
||||
case BcIsCentral:
|
||||
return simulationTypeText(item.isCentral());
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
if (role == Qt::DecorationRole)
|
||||
{
|
||||
switch (column)
|
||||
{
|
||||
case BcParty:
|
||||
return iconFromPartyId(item.partyId());
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
if (role == LtsWidgets::LtsColumnFilterProxyModel::ComboboxFilterRole)
|
||||
{
|
||||
switch (column)
|
||||
{
|
||||
case BcChargeType:
|
||||
return item.chargeStruct().chargeTypeId();
|
||||
case BcEffectState:
|
||||
return item.effectStateId().underlying();
|
||||
case BcParty:
|
||||
return item.partyId().is_set() ? item.partyId().get() : -1;
|
||||
case BcIsCentral:
|
||||
return simulationTypeText(item.isCentral());
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
public:
|
||||
T aesItem(int row) const { return LtsWidgets::LtsAbstractTableModel<T>::getRowData(row); }
|
||||
|
||||
protected:
|
||||
bool isFiltered(const T &data, DataModification modType) const override
|
||||
{
|
||||
if (!m_availableChargeIds.isEmpty() && !m_availableChargeIds.contains(data.chargeStruct().chargeTypeId()))
|
||||
return true;
|
||||
return LtsWidgets::LtsAbstractTableModel<T>::isFiltered(data, modType);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class AESBASEGUI_EXPORT AesItemSortFilterProxyModel : public LtsWidgets::LtsColumnFilterProxyModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AesItemSortFilterProxyModel(LtsSession::LtsSession *session, QObject *parent = nullptr);
|
||||
~AesItemSortFilterProxyModel() = default;
|
||||
|
||||
bool showExpired() const { return m_showExpired; }
|
||||
int offset() const { return m_offset; }
|
||||
|
||||
virtual int aesId(int row) const = 0;
|
||||
virtual bool isExpired(int row) const = 0;
|
||||
virtual bool isExternal(int row) const = 0;
|
||||
virtual AesEffectState aesEffectStateId(int row) const = 0;
|
||||
virtual ProjectDataManagement::EffectSource aesEffectSourceId(int row) const = 0;
|
||||
virtual dds::core::optional<rti::core::int64> aesEffectStart(int row) const = 0;
|
||||
virtual int32_t aesEffectDuration(int row) const = 0;
|
||||
virtual int32_t partyId(int row) const = 0;
|
||||
QColor partyColor(int row) const { return m_partyColors.value(partyId(row), Qt::black); }
|
||||
|
||||
public slots:
|
||||
void setOffset(int offsetMsecs);
|
||||
void setShowExpired(bool showExpired);
|
||||
|
||||
protected:
|
||||
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override final;
|
||||
bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const override final;
|
||||
|
||||
private:
|
||||
bool checkFilter(int source_row) const;
|
||||
private:
|
||||
LtsSession::LtsSession *m_session;
|
||||
bool m_showExpired;
|
||||
int m_offset;
|
||||
QMap<int, QColor> m_partyColors;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class AesItemSortFilterProxyModelTmpl : public AesItemSortFilterProxyModel
|
||||
{
|
||||
public:
|
||||
using AesItemSortFilterProxyModel::AesItemSortFilterProxyModel;
|
||||
|
||||
void setSourceModel(QAbstractItemModel *sm) override
|
||||
{
|
||||
m_sourceModel = dynamic_cast<AesGuiBaseModel<T>*>(sm);
|
||||
Q_ASSERT(m_sourceModel);
|
||||
AesItemSortFilterProxyModel::setSourceModel(sm);
|
||||
}
|
||||
T aesItem(int row) const { return m_sourceModel->aesItem(row); }
|
||||
|
||||
int aesId(int row) const override { return aesItem(row).id(); }
|
||||
bool isExpired(int row) const override
|
||||
{
|
||||
const auto es = aesItem(row).effectStateId();
|
||||
// alles andere wird als expired angesehen -> also nicht löschbar
|
||||
return es != AreaEffectSimulation::AesEffectState_def::EsCreated &&
|
||||
es != AreaEffectSimulation::AesEffectState_def::EsPrepared &&
|
||||
es != AreaEffectSimulation::AesEffectState_def::EsActivated &&
|
||||
es != AreaEffectSimulation::AesEffectState_def::EsPaused &&
|
||||
es != AreaEffectSimulation::AesEffectState_def::EsReceived;
|
||||
}
|
||||
bool isExternal(int row) const override
|
||||
{
|
||||
return aesItem(row).externalId() > 0;
|
||||
}
|
||||
protected:
|
||||
AesEffectState aesEffectStateId(int row) const override { return aesItem(row).effectStateId(); }
|
||||
ProjectDataManagement::EffectSource aesEffectSourceId(int row) const override { return aesItem(row).effectSourceId(); }
|
||||
dds::core::optional<rti::core::int64> aesEffectStart(int row) const override { return aesItem(row).effectStart(); }
|
||||
int32_t aesEffectDuration(int row) const override { return aesItem(row).effectDuration(); }
|
||||
virtual int32_t partyId(int row) const override { return aesItem(row).partyId().is_set()?aesItem(row).partyId().get():-1; }
|
||||
|
||||
AesGuiBaseModel<T> *m_sourceModel = nullptr;
|
||||
};
|
||||
} //namespace AreaEffectSimulation
|
||||
+307
@@ -0,0 +1,307 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* ContaminationManangement - Contamination Overview Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-07-07
|
||||
*/
|
||||
|
||||
#include "aes_itemlist.h"
|
||||
#include "aes_base_model.h"
|
||||
#include "ui_aes_itemlist.h"
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QKeyEvent>
|
||||
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsUtilsGuiDds/request_helper.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
#include <Plugins/SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
#include <Viewer/LtsDataView/lts_data_view.h>
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QTreeView>
|
||||
#include <LtsPrinting/printing.h>
|
||||
|
||||
static const auto ADLER_BTN = LtsWidgets::DialogButton::Export;
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
AesItemList::AesItemList(const QString &menuGroup, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_ftc(nullptr)
|
||||
, m_dtc(nullptr)
|
||||
, m_menuGroup(menuGroup)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_showExpired(false)
|
||||
, m_bHasAddEditOperatorRights(true)
|
||||
, m_bHasAddAdlerOperatorRights(false)
|
||||
, m_session(nullptr)
|
||||
, m_ui(new Ui::AesItemList)
|
||||
, m_logger(getLogger("AesItemList"))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
QCheckBox *cbExpired = new QCheckBox(tr("Show expired"), m_ui->widget);
|
||||
cbExpired->setProperty("const", true);
|
||||
m_ui->widget->setCustomWidget(cbExpired);
|
||||
connect(cbExpired, &QCheckBox::toggled, this, &AesItemList::setShowExpired);
|
||||
}
|
||||
|
||||
AesItemList::~AesItemList() { delete m_ui; }
|
||||
|
||||
bool AesItemList::init(LtsSession::LtsSession *session)
|
||||
{
|
||||
if (m_session)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "double init()!";
|
||||
return false;
|
||||
}
|
||||
m_session = session;
|
||||
|
||||
if (!m_session->getFtc<AreaEffectSimulation::DataInterface>(m_ftc))
|
||||
return false;
|
||||
if (!m_session->getDtc<AreaEffectSimulation::DataInterface>(m_dtc))
|
||||
return false;
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &AesItemList::onPrint);
|
||||
if (m_session->app() != LtsAppDescriptor::App::OC)
|
||||
{
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Add, this, &AesItemList::onAddAesItem);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Remove, this, &AesItemList::onRemoveAesItem);
|
||||
}
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &AesItemList::onEditAesItem);
|
||||
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Save)->setText(tr("Center on Map"));
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Save)->setIcon(QIcon(QStringLiteral("icon:center_to_object.svg")));
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Save, this, &AesItemList::onCenterAesItem);
|
||||
m_buttonBox->getButton(ADLER_BTN)->hide();
|
||||
m_buttonBox->connectButton(ADLER_BTN, this, &AesItemList::onAdlerBtn);
|
||||
|
||||
QCheckBox *cb = qobject_cast<QCheckBox *>(m_ui->widget->customWidget());
|
||||
bool showExpired = (!cb || cb->isChecked());
|
||||
|
||||
createModel();
|
||||
model()->setShowExpired(showExpired);
|
||||
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalSelectionChanged, this, &AesItemList::enaDisa);
|
||||
connect(m_session, &LtsSession::LtsSession::signalExerciseDataChanged, this, &AesItemList::enaDisa);
|
||||
connect(m_dtc.get(), &AreaEffectSimulation::Interface::Dtc::explosionClusterChanged, this, &AesItemList::onHandleAdler);
|
||||
connect(m_dtc.get(), &AreaEffectSimulation::Interface::Dtc::effectClusterChanged, this, &AesItemList::onHandleAdler);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void AesItemList::enaDisa()
|
||||
{
|
||||
const int curSelRow = currentRow();
|
||||
onHandleAdler();
|
||||
LtsWidgets::ExerciseStates allowedStates = LtsWidgets::ExerciseState::eCreated | LtsWidgets::ExerciseState::eStarted | LtsWidgets::ExerciseState::ePaused;
|
||||
bool bEnableEditRemove = false;
|
||||
bool bIsAllowedInState = allowedStates.testFlag(m_session->exerciseState());
|
||||
bool isOc = (m_session->app() == LtsAppDescriptor::App::OC);
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Save, !model()->isExpired(curSelRow));
|
||||
|
||||
if (curSelRow >= 0)
|
||||
bEnableEditRemove = !model()->isExpired(curSelRow) && !model()->isExternal(curSelRow);
|
||||
if (!m_bHasAddEditOperatorRights)
|
||||
{
|
||||
bEnableEditRemove = false;
|
||||
bIsAllowedInState = false;
|
||||
}
|
||||
|
||||
if (!m_session->isReplayPartition())
|
||||
{
|
||||
if (!model()->isExternal(curSelRow))
|
||||
{
|
||||
m_buttonBox->setText(LtsWidgets::DialogButton::Edit, tr("Edit"));
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, bEnableEditRemove && bIsAllowedInState);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_buttonBox->setText(LtsWidgets::DialogButton::Edit, tr("Show Details"));
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, bIsAllowedInState);
|
||||
}
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, bEnableEditRemove && bIsAllowedInState);
|
||||
|
||||
// Adler Add Button
|
||||
bool isEsAdler = false;
|
||||
if (curSelRow >= 0)
|
||||
{
|
||||
const ProjectDataManagement::EffectSource &es = model()->aesEffectSourceId(curSelRow);
|
||||
|
||||
if (es == ProjectDataManagement::EffectSource::ES_ADLER || es == ProjectDataManagement::EffectSource::ES_ADLER_STANDALONE)
|
||||
isEsAdler = true;
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Add, bIsAllowedInState && !isEsAdler);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Load, m_bHasAddAdlerOperatorRights && isEsAdler);
|
||||
m_buttonBox->setButtonVisible(LtsWidgets::DialogButton::Load, !isOc);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Add, bIsAllowedInState);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Load, m_bHasAddAdlerOperatorRights);
|
||||
m_buttonBox->setButtonVisible(LtsWidgets::DialogButton::Load, !isOc);
|
||||
}
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Load)->setText(tr("Add ADLER"));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_buttonBox->setButtonVisible(LtsWidgets::DialogButton::Add, false);
|
||||
m_buttonBox->setButtonVisible(LtsWidgets::DialogButton::Remove, false);
|
||||
|
||||
m_buttonBox->setText(LtsWidgets::DialogButton::Edit, tr("Show Details"));
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, bEnableEditRemove);
|
||||
}
|
||||
|
||||
if (bEnableEditRemove && bIsAllowedInState)
|
||||
{
|
||||
m_doubleClickConnection = connect(m_ui->widget, &LtsDataView::LtsDataView::signalDoubleClicked, this, &AesItemList::onEditAesItem, Qt::UniqueConnection);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_doubleClickConnection)
|
||||
disconnect(m_doubleClickConnection);
|
||||
}
|
||||
}
|
||||
|
||||
void AesItemList::onPrint() { LtsPrinting::printView(m_session, this, m_ui->widget->treeView()); }
|
||||
|
||||
void AesItemList::onAdlerBtn()
|
||||
{
|
||||
AesEffectState aesEffectState = model()->aesEffectStateId(currentRow());
|
||||
ProjectDataManagement::EffectSource effectSource = model()->aesEffectSourceId(currentRow());
|
||||
|
||||
DEBUG_LOG(m_logger) << "onAdlerBtn aesEffectState=" << aesEffectState;
|
||||
|
||||
switch (aesEffectState.underlying())
|
||||
{
|
||||
case AreaEffectSimulation::AesEffectState::EsReceived:
|
||||
{
|
||||
switch (effectSource.underlying())
|
||||
{
|
||||
case ProjectDataManagement::EffectSource::ES_ADLER:
|
||||
{
|
||||
AcknowledgeExternalAesItemRequest req;
|
||||
int aesId = model()->aesId(currentRow());
|
||||
req.aesId(aesId);
|
||||
m_requestHelper->startSingleRequest([req, this]() { return m_ftc->acknowledgeExternalAesItemRequest(req, this); });
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
ExplosionClusterReleaseReceivedRequest req;
|
||||
int aesId = model()->aesId(currentRow());
|
||||
req.id(aesId);
|
||||
m_requestHelper->startSingleRequest([req, this]() { return m_ftc->explosionClusterReleaseReceivedRequest(req, this); });
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case AreaEffectSimulation::AesEffectState::EsCreated:
|
||||
case AreaEffectSimulation::AesEffectState::EsPrepared:
|
||||
{
|
||||
if (effectSource == ProjectDataManagement::EffectSource::ES_ADLER ||
|
||||
effectSource == ProjectDataManagement::EffectSource::ES_ADLER_STANDALONE)
|
||||
{
|
||||
AreaEffectSimulation::SetAesItemEffectorStateRequest req;
|
||||
req.aesId(model()->aesId(currentRow()));
|
||||
req.newEffectorState(AesEffectorState::EsReadyToFire);
|
||||
DEBUG_LOG(m_logger) << "Send setAesItemEffectorStateRequest with aesId: " << req.aesId() << ", AesEffectorState: " << req.newEffectorState();
|
||||
|
||||
m_requestHelper->startSingleRequest([req, this]() { return m_ftc->setAesItemEffectorStateRequest(req, this); });
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
m_buttonBox->getButton(ADLER_BTN)->hide();
|
||||
}
|
||||
}
|
||||
|
||||
// enable Adler-Btn
|
||||
void AesItemList::onHandleAdler()
|
||||
{
|
||||
AesEffectState aesEffectState = model()->aesEffectStateId(currentRow());
|
||||
DEBUG_LOG(m_logger) << "onHandleAdler aesEffectState=" << aesEffectState;
|
||||
auto *adlerBtn = m_buttonBox->getButton(ADLER_BTN);
|
||||
|
||||
switch (aesEffectState.underlying())
|
||||
{
|
||||
case AreaEffectSimulation::AesEffectState::EsReceived:
|
||||
{
|
||||
adlerBtn->setText(tr("Mark received"));
|
||||
adlerBtn->setIcon(QIcon(QStringLiteral("icon:mortar_ammunition_administration.svg")));
|
||||
adlerBtn->show();
|
||||
break;
|
||||
}
|
||||
case AreaEffectSimulation::AesEffectState::EsCreated:
|
||||
case AreaEffectSimulation::AesEffectState::EsPrepared:
|
||||
{
|
||||
ProjectDataManagement::EffectSource effectSource = model()->aesEffectSourceId(currentRow());
|
||||
if (effectSource.underlying() == ProjectDataManagement::EffectSource::ES_ADLER ||
|
||||
effectSource.underlying() == ProjectDataManagement::EffectSource::ES_ADLER_STANDALONE)
|
||||
{
|
||||
const EffectCluster &ecData = m_dtc->effectCluster(model()->aesId(currentRow()));
|
||||
if (ecData.effectorState() == AreaEffectSimulation::AesEffectorState::EsNotReadyToFire)
|
||||
{
|
||||
adlerBtn->setText(tr("Ready To Fire"));
|
||||
adlerBtn->show();
|
||||
}
|
||||
else
|
||||
adlerBtn->hide();
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
adlerBtn->hide();
|
||||
}
|
||||
}
|
||||
|
||||
void AesItemList::onCenterAesItem()
|
||||
{
|
||||
int aesId = model()->aesId(currentRow());
|
||||
std::shared_ptr<SituationMap::ForeignGuiInterface> ifc;
|
||||
if (m_session->getForeignGuiInterface<SituationMap::ForeignGuiInterface>(ifc))
|
||||
ifc->centerMapToAesObject(aesId);
|
||||
}
|
||||
|
||||
void AesItemList::hideColumn(int col) { m_ui->widget->hideColumn(col); }
|
||||
|
||||
void AesItemList::showColumn(int col) { m_ui->widget->showColumn(col); }
|
||||
|
||||
int AesItemList::currentRow() const
|
||||
{
|
||||
const auto selRows = m_ui->widget->selectedRows();
|
||||
if (selRows.count() != 1)
|
||||
return -1;
|
||||
return selRows.first().row();
|
||||
}
|
||||
|
||||
void AesItemList::setDataViewModel(QAbstractItemModel *model, const std::function<LtsDataView::AbstractDisplayWidget *()> &customDisplayWidgetCreator)
|
||||
{
|
||||
m_ui->widget->setModel(model, customDisplayWidgetCreator);
|
||||
}
|
||||
|
||||
void AesItemList::setDataViewModel(QAbstractItemModel *model) { m_ui->widget->setModel(model); }
|
||||
|
||||
void AesItemList::setShowExpired(bool show) { model()->setShowExpired(show); }
|
||||
|
||||
void AesItemList::setSortIndicator(int col) { m_ui->widget->setSortIndicator(col, Qt::AscendingOrder); }
|
||||
|
||||
void AesItemList::translateBase(const QString &windowTitle) { translate(m_ui, windowTitle); }
|
||||
|
||||
void AesItemList::tableColumnOrganiserSetting()
|
||||
{
|
||||
// LtsColumnOrganiser
|
||||
m_ui->widget->setColumnsOrganiserEnabled(identifier(), true);
|
||||
}
|
||||
|
||||
} // namespace AreaEffectSimulation
|
||||
+111
@@ -0,0 +1,111 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* AreaEffectSimulation - Contamination Overview Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-07-07
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "aes_base_exports.h"
|
||||
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <AreaEffectSimulation/aes_ftc.h>
|
||||
#include <AreaEffectSimulation/aes_dtc.h>
|
||||
#include <LtsUtilsGuiDds/request_helper.h>
|
||||
|
||||
|
||||
#include <AreaEffectSimulation/logger.h>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class AesItemList;
|
||||
}
|
||||
namespace LtsSession
|
||||
{
|
||||
class LtsSession;
|
||||
}
|
||||
class QAbstractItemModel;
|
||||
namespace LtsDataView
|
||||
{
|
||||
class AbstractDisplayWidget;
|
||||
}
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
class AesItemSortFilterProxyModel;
|
||||
template<typename T>
|
||||
class AesItemSortFilterProxyModelTmpl;
|
||||
|
||||
class AESBASEGUI_EXPORT AesItemList : public LtsWidgets::LtsDialog
|
||||
, protected AreaEffectSimulation::Interface::Ftc::MineResetReplyHandler
|
||||
, protected AreaEffectSimulation::Interface::Ftc::ExplosionClusterReleaseReceivedReplyHandler
|
||||
, protected AreaEffectSimulation::Interface::Ftc::AcknowledgeExternalAesItemReplyHandler
|
||||
, protected AreaEffectSimulation::Interface::Ftc::SetAesItemEffectorStateReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AesItemList(const QString &menuGroup, QWidget *parent = nullptr);
|
||||
~AesItemList();
|
||||
|
||||
virtual bool init(LtsSession::LtsSession *session);
|
||||
bool isShowExpired() const { return m_showExpired; }
|
||||
void onMineResetReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
|
||||
void onExplosionClusterReleaseReceivedReply (const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
|
||||
void onSetAesItemEffectorStateReply (const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
|
||||
void onAcknowledgeExternalAesItemReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
|
||||
|
||||
public slots:
|
||||
void setShowExpired(bool show);
|
||||
|
||||
protected slots:
|
||||
void enaDisa();
|
||||
virtual void onPrint();
|
||||
virtual void onAddAesItem() = 0;
|
||||
virtual void onEditAesItem() = 0;
|
||||
virtual void onRemoveAesItem() = 0;
|
||||
virtual void onHandleAdler();
|
||||
void onAdlerBtn();
|
||||
void onCenterAesItem();
|
||||
void hideColumn(int col);
|
||||
void showColumn(int col);
|
||||
|
||||
protected:
|
||||
virtual void createModel() = 0;
|
||||
virtual AesItemSortFilterProxyModel *model() = 0;
|
||||
virtual const AesItemSortFilterProxyModel *model() const = 0;
|
||||
int currentRow() const; // the currently selected row (not current index!)
|
||||
void setDataViewModel(QAbstractItemModel *model, const std::function<LtsDataView::AbstractDisplayWidget*()> &customDisplayWidgetCreator);
|
||||
void setDataViewModel(QAbstractItemModel *model);
|
||||
void setSortIndicator(int col);
|
||||
void translateBase(const QString &windowTitle);
|
||||
void tableColumnOrganiserSetting() override;
|
||||
|
||||
std::shared_ptr<AreaEffectSimulation::Interface::Ftc> m_ftc;
|
||||
std::shared_ptr<AreaEffectSimulation::Interface::Dtc> m_dtc;
|
||||
QString m_menuGroup;
|
||||
LtsUtils::RequestHelper *m_requestHelper;
|
||||
bool m_showExpired;
|
||||
bool m_bHasAddEditOperatorRights;
|
||||
bool m_bHasAddAdlerOperatorRights;
|
||||
LtsSession::LtsSession *m_session;
|
||||
Ui::AesItemList *m_ui;
|
||||
QMetaObject::Connection m_doubleClickConnection;
|
||||
LOGGER_T m_logger;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
class AesItemListTmpl : public AesItemList
|
||||
{
|
||||
public:
|
||||
using AesItemList::AesItemList;
|
||||
protected:
|
||||
AesItemSortFilterProxyModel *model() override { return m_model; }
|
||||
const AesItemSortFilterProxyModel *model() const override { return m_model; }
|
||||
|
||||
AesItemSortFilterProxyModelTmpl<T> *m_model = nullptr;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>AesItemList</class>
|
||||
<widget class="QWidget" name="AesItemList">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>600</width>
|
||||
<height>500</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Aes Item List</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="LtsDataView::LtsDataView" name="widget">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</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>
|
||||
@@ -0,0 +1,94 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* AreaEffectSimulation - PixmapLabel
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Malte Schroeder, NLSE, 2018-05-09
|
||||
*/
|
||||
|
||||
#include "aes_pixmap_label.h"
|
||||
|
||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
PixmapLabel::PixmapLabel(QWidget *parent)
|
||||
: QLabel(parent)
|
||||
, m_pixmap()
|
||||
{
|
||||
setMinimumSize(1, 1);
|
||||
setScaledContents(false);
|
||||
}
|
||||
|
||||
int PixmapLabel::heightForWidth(int width) const
|
||||
{
|
||||
return m_pixmap.isNull() ? this->height() : qRound(double(m_pixmap.height() * width)) / m_pixmap.width();
|
||||
}
|
||||
|
||||
QSize PixmapLabel::sizeHint() const
|
||||
{
|
||||
int w = this->width();
|
||||
return QSize(w, heightForWidth(w));
|
||||
}
|
||||
|
||||
QPixmap PixmapLabel::scaledPixmap(const QSize &size, const Qt::AspectRatioMode &aspectRatioMode, const Qt::TransformationMode &transformationMode) const
|
||||
{
|
||||
return m_pixmap.scaled(size, aspectRatioMode, transformationMode);
|
||||
}
|
||||
|
||||
Qt::BrushStyle PixmapLabel::checkForBrushStyle(const AesEffectState &state)
|
||||
{
|
||||
switch(state.underlying()) // Todo: change to correct BrushStyle?
|
||||
{
|
||||
case AesEffectState_def::EsUnknown:
|
||||
return Qt::BrushStyle::NoBrush;
|
||||
case AesEffectState_def::EsPrepared:
|
||||
case AesEffectState_def::EsFired:
|
||||
return Qt::BrushStyle::BDiagPattern;
|
||||
case AesEffectState_def::EsCreated:
|
||||
case AesEffectState_def::EsReceived:
|
||||
return Qt::BrushStyle::VerPattern;
|
||||
case AesEffectState_def::EsActivated:
|
||||
return Qt::BrushStyle::CrossPattern;
|
||||
case AesEffectState_def::EsRemoved:
|
||||
return Qt::BrushStyle::NoBrush;
|
||||
case AesEffectState_def::EsPaused:
|
||||
case AesEffectState_def::EsExpired:
|
||||
case AesEffectState_def::EsError:
|
||||
return Qt::BrushStyle::SolidPattern;
|
||||
}
|
||||
return Qt::BrushStyle::NoBrush;
|
||||
}
|
||||
|
||||
void PixmapLabel::setPixmap(const QPixmap &pixmap)
|
||||
{
|
||||
m_pixmap = pixmap;
|
||||
QLabel::setPixmap(scaledPixmap(this->size()));
|
||||
}
|
||||
|
||||
void PixmapLabel::resizeEvent(QResizeEvent *e)
|
||||
{
|
||||
QLabel::resizeEvent(e);
|
||||
|
||||
if(m_pixmap.isNull())
|
||||
return;
|
||||
QLabel::setPixmap(scaledPixmap(this->size()));
|
||||
}
|
||||
|
||||
QPolygonF PixmapLabel::geographic2Utm(const QPolygonF &poly)
|
||||
{
|
||||
if(poly.isEmpty())
|
||||
return QPolygonF();
|
||||
|
||||
QPolygonF polyOut;
|
||||
polyOut.reserve(poly.size());
|
||||
LtsCoordTrans::UtmCoordinate utmPos = LtsCoordTrans::UtmCoordinate::fromGeographic(poly.at(0));
|
||||
for(const QPointF &p : poly)
|
||||
{
|
||||
LtsCoordTrans::UtmCoordinate coord = LtsCoordTrans::UtmCoordinate::fromGeographic(p.x(), p.y(), utmPos.zone);
|
||||
polyOut.append(QPointF(coord.x, coord.y));
|
||||
}
|
||||
return polyOut;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* AreaEffectSimulation - PixmapLabel
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Malte Schroeder, NLSE, 2018-05-09
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QLabel>
|
||||
#include <QPolygonF>
|
||||
#include "aes_base_exports.h"
|
||||
#include <AreaEffectSimulation/aes_enums.hpp>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
constexpr int ICON_RESOLUTION = 256;
|
||||
|
||||
class AESBASEGUI_EXPORT PixmapLabel : public QLabel
|
||||
{
|
||||
public:
|
||||
explicit PixmapLabel(QWidget *parent = nullptr);
|
||||
|
||||
int heightForWidth(int width) const override;
|
||||
QSize sizeHint() const override;
|
||||
QPixmap scaledPixmap(const QSize &size,
|
||||
const Qt::AspectRatioMode &ratioMode = Qt::KeepAspectRatio,
|
||||
const Qt::TransformationMode &transformationMode = Qt::SmoothTransformation) const;
|
||||
|
||||
static Qt::BrushStyle checkForBrushStyle(const AreaEffectSimulation::AesEffectState &state);
|
||||
static QPolygonF geographic2Utm(const QPolygonF &poly);
|
||||
|
||||
public slots:
|
||||
void setPixmap(const QPixmap &pixmap);
|
||||
void resizeEvent(QResizeEvent *e) override;
|
||||
|
||||
private:
|
||||
QPixmap m_pixmap;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
# Created by hjl, SLSE, 2017-06-06
|
||||
#
|
||||
|
||||
ADD_INTERFACE_LIBRARY(
|
||||
AesBorderlineGuiPluginInterface
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/aes_borderline_gui_plugin_interface.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/..
|
||||
)
|
||||
|
||||
|
||||
SET(aes_borderline_gui_SRCS
|
||||
aes_borderline_gui_plugin.h
|
||||
aes_borderline_gui_plugin.cpp
|
||||
aes_borderline_list.h
|
||||
aes_borderline_list.cpp
|
||||
aes_borderlines_model.h
|
||||
aes_borderlines_model.cpp
|
||||
aes_borderline_edit.h
|
||||
aes_borderline_edit.cpp
|
||||
CustomView/aes_borderline.h
|
||||
CustomView/aes_borderline.cpp
|
||||
)
|
||||
|
||||
NGL_WRAP_UI(aes_borderline_gui_SRCS
|
||||
aes_borderline_edit.ui
|
||||
CustomView/aes_borderline.ui
|
||||
)
|
||||
|
||||
NGL_ADD_LIBRARY(WS AesBorderlineGuiPlugin MODULE ${aes_borderline_gui_SRCS})
|
||||
NGL_TARGET_LINK_LIBRARIES(AesBorderlineGuiPlugin
|
||||
AesBaseGui
|
||||
AesBorderlineGuiPluginInterface
|
||||
ngltools
|
||||
AesDataPluginInterface
|
||||
PdmGuiPluginInterface
|
||||
AesInfoGuiPluginInterface
|
||||
FlmDataPluginInterface
|
||||
NGLLogger
|
||||
Qt5::Widgets
|
||||
LtsWidgets
|
||||
LtsSession
|
||||
LtsSessionData
|
||||
LtsDataView
|
||||
SituationMapGuiPluginInterface
|
||||
LtsUtilsGuiDds
|
||||
LtsUtilsSettings
|
||||
)
|
||||
|
||||
NGL_INSTALL_TARGET(AesBorderlineGuiPlugin)
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* CustomView for AES Borderline
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2017-06-20
|
||||
*/
|
||||
|
||||
#include "aes_borderline.h"
|
||||
#include "ui_aes_borderline.h"
|
||||
|
||||
#include "aes_borderlines_model.h"
|
||||
#include <Services/AreaEffectSimulation/Utils/polygons.h>
|
||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
CustomViewBorderline::CustomViewBorderline(QWidget *parent)
|
||||
: AbstractDisplayWidget(parent)
|
||||
, m_ui(new Ui::CustomViewBorderline)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
}
|
||||
|
||||
CustomViewBorderline::~CustomViewBorderline()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
bool CustomViewBorderline::init(const QModelIndex &idx)
|
||||
{
|
||||
if (idx.isValid())
|
||||
return false;
|
||||
|
||||
m_ui->lblName->setText(rowData(idx, AreaEffectSimulation::BorderlinesModel::BcName).toString());
|
||||
m_ui->lblIcon->clear();
|
||||
m_ui->lblIcon->setAutoFillBackground(true);
|
||||
|
||||
const AesItemSortFilterProxyModel *sfpm = qobject_cast<const AesItemSortFilterProxyModel*>(idx.model());
|
||||
if (!sfpm)
|
||||
return false;
|
||||
const BorderlinesModel *aesModel = qobject_cast<const BorderlinesModel*>(sfpm->sourceModel());
|
||||
if (!aesModel)
|
||||
return false;
|
||||
const auto srcIdx = sfpm->mapToSource(idx);
|
||||
Borderline bLine = aesModel->getRowData(srcIdx.row());
|
||||
calculateIcon(bLine, sfpm->partyColor(idx.row()));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CustomViewBorderline::calculateIcon(const AreaEffectSimulation::Borderline &line, const QColor &color)
|
||||
{
|
||||
if (line.segments().size() == 0)
|
||||
return false;
|
||||
|
||||
QVector<QPointF> segments;
|
||||
segments.reserve(line.segments().size());
|
||||
int setZone = -1;
|
||||
for (const Core::GeoPosition2D &s : line.segments())
|
||||
{
|
||||
const LtsCoordTrans::UtmCoordinate coord(LtsCoordTrans::UtmCoordinate::fromGeographic(s.lon(), s.lat(), setZone));
|
||||
if (setZone < 0)
|
||||
setZone = coord.zone;
|
||||
segments.append(QPointF(coord.x, coord.y));
|
||||
}
|
||||
|
||||
QPolygonF poly = AreaEffectSimulation::Polygons::borderline(segments);
|
||||
Qt::BrushStyle bStyle = Qt::BrushStyle::NoBrush;
|
||||
const auto pix = Polygons::pixmapFromPolygon(poly, color, ICON_RESOLUTION, bStyle, true);
|
||||
m_ui->lblIcon->setPixmap(pix);
|
||||
|
||||
return true;
|
||||
}
|
||||
} // namespace AreaEffectSimulation
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* CustomView for AES Borderline
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2017-06-20
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <Viewer/LtsDataView/abstract_display_widget.h>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class CustomViewBorderline;
|
||||
}
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
class Borderline;
|
||||
class CustomViewBorderline final : public LtsDataView::AbstractDisplayWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CustomViewBorderline(QWidget *parent = nullptr);
|
||||
~CustomViewBorderline();
|
||||
bool init(const QModelIndex &idx) override final;
|
||||
|
||||
private:
|
||||
bool calculateIcon(const AreaEffectSimulation::Borderline &line, const QColor &color);
|
||||
|
||||
Ui::CustomViewBorderline *m_ui;
|
||||
|
||||
};
|
||||
} // namespace AreaEffectSimulation
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CustomViewBorderline</class>
|
||||
<widget class="QWidget" name="CustomViewBorderline">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>350</width>
|
||||
<height>200</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"/>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="lblName">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">Name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="AreaEffectSimulation::PixmapLabel" name="lblIcon">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">icon</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>AreaEffectSimulation::PixmapLabel</class>
|
||||
<extends>QLabel</extends>
|
||||
<header>AreaEffectSimulation/Gui/Base/aes_pixmap_label.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,364 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for AreaEffectSimulation - Borderline Add/Edit Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2017-06-20
|
||||
*/
|
||||
|
||||
#include "aes_borderline_edit.h"
|
||||
#include "ui_aes_borderline_edit.h"
|
||||
|
||||
#include <Plugins/AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
#include <Plugins/SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
|
||||
#include <LtsWidgets/lts_message_dialog.h>
|
||||
#include <FileManagement/flm_translation.h>
|
||||
|
||||
#include <QJsonObject>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonArray>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
BorderlineEdit::BorderlineEdit(const QString &menuGroup, QWidget *parent)
|
||||
: BaseEdit(menuGroup, QLatin1String("BorderlineEdit"), parent)
|
||||
, m_ui(new Ui::BorderlineEdit)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
// ???
|
||||
m_uiRequirements->addRequirement({m_ui->lblGeometry, [this]() { return (!m_ui->positionEdit_1->coordinate().isNull() &&
|
||||
!m_ui->positionEdit_2->coordinate().isNull()
|
||||
); }});
|
||||
m_uiRequirements->addRequirement({m_ui->lblIdentifier, [this]() { return (!m_ui->leIdentifier->text().isEmpty()); }});
|
||||
|
||||
connect(m_ui->pbClear, &QPushButton::clicked, this, &BorderlineEdit::clearCoordinates);
|
||||
|
||||
#ifndef LTS_DEBUG
|
||||
m_ui->lblBorderlineId->hide();
|
||||
m_ui->lbBorderlineId->hide();
|
||||
#endif
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Add_Borderline"));
|
||||
|
||||
enaDisa(); // does nothing
|
||||
} // end of ctor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
BorderlineEdit::~BorderlineEdit()
|
||||
{
|
||||
delete m_ui;
|
||||
} // end of dtor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
std::vector<LtsCoordWidget::LtsCoordWidget *> BorderlineEdit::coordWidgets() const
|
||||
{
|
||||
return {m_ui->positionEdit_1,
|
||||
m_ui->positionEdit_2,
|
||||
m_ui->positionEdit_3,
|
||||
m_ui->positionEdit_4,
|
||||
m_ui->positionEdit_5,
|
||||
m_ui->positionEdit_6,
|
||||
m_ui->positionEdit_7,
|
||||
m_ui->positionEdit_8,
|
||||
m_ui->positionEdit_9,
|
||||
m_ui->positionEdit_10,
|
||||
m_ui->positionEdit_11};
|
||||
} // end of retranslate()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void BorderlineEdit::retranslate()
|
||||
{
|
||||
translate(m_ui, m_aesItem, tr("Borderline"));
|
||||
} // end of retranslate()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void BorderlineEdit::enableUiElements(bool enable)
|
||||
{
|
||||
|
||||
m_ui->leIdentifier->setMaxLength(30);
|
||||
m_ui->pbPosition->setEnabled(m_sitMapGuiIfc && enable);
|
||||
enabledCoordinates(enable);
|
||||
m_ui->cbParty->setEnabled(enable);
|
||||
m_ui->pbClear->setEnabled(enable);
|
||||
|
||||
|
||||
m_ui->leIdentifier->setEnabled(enable || isOnlyNameModifiable());
|
||||
if (m_aesItem.effectStateId() == AesEffectState_def::EsExpired)
|
||||
{
|
||||
m_ui->leIdentifier->setText(QString::fromStdString(m_aesItem.name()));
|
||||
__unchange__();
|
||||
}
|
||||
if (m_aesItem.effectStateId() == AesEffectState_def::EsActivated)
|
||||
{
|
||||
QString name = m_ui->leIdentifier->text();
|
||||
auto baseData = m_dtc->borderline(m_aesItem.id());
|
||||
setData(baseData, false);
|
||||
__unchange__();
|
||||
if (name != m_ui->leIdentifier->text())
|
||||
m_ui->leIdentifier->setText(name);
|
||||
}
|
||||
|
||||
|
||||
} // end of enableUiElements()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool BorderlineEdit::init(int aesItemId, bool copy, LtsSession::LtsSession *session)
|
||||
{
|
||||
if (!BaseEdit::init(aesItemId, session))
|
||||
return false;
|
||||
|
||||
bool editable = LtsSessionData::LtsSessionData::getInstance()->hasOperatorRight(OperatorRights::BorderlinesEdit) ||
|
||||
m_session->app() == LtsAppDescriptor::App::OC;
|
||||
bool readable = LtsSessionData::LtsSessionData::getInstance()->hasOperatorRight(OperatorRights::BorderlinesShow);
|
||||
|
||||
|
||||
if (!readable && !editable)
|
||||
return false;
|
||||
|
||||
if (m_sitMapGuiIfc)
|
||||
connect(m_ui->pbPosition, &QPushButton::clicked, this, &BorderlineEdit::onGetPolyline);
|
||||
else
|
||||
m_ui->pbPosition->setEnabled(false);
|
||||
|
||||
m_ppmGuiCbxIfc->fillPartyComboBox(m_ui->cbParty);
|
||||
|
||||
if (aesItemId > 0)
|
||||
{
|
||||
auto baseData = m_dtc->borderline(aesItemId);
|
||||
setData(baseData, copy);
|
||||
}
|
||||
|
||||
enableUiElements(editable && isModifiable() && !isOnlyNameModifiable());
|
||||
|
||||
connect(m_dtc.get(), &AreaEffectSimulation::Interface::Dtc::borderlineChanged,
|
||||
this, &BaseEdit::onAreaChanged);
|
||||
|
||||
// Save/Load from Library Button
|
||||
m_buttonBox->connectLibraryButton(this,
|
||||
&BorderlineEdit::onImportButtonClicked,
|
||||
&BorderlineEdit::onExportButtonClicked);
|
||||
|
||||
if (!session->getForeignGuiInterface<FileManagement::ForeignGuiInterface>(m_flmGui))
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Library, false);
|
||||
|
||||
return true;
|
||||
|
||||
} // end of init()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void BorderlineEdit::setData(const Borderline &borderline, bool copy)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION << "borderlineId: " << borderline.id()
|
||||
<< " operatorId: " << borderline.operatorId();
|
||||
|
||||
m_aesItem = borderline;
|
||||
if (copy)
|
||||
{
|
||||
m_aesItem.id(0);
|
||||
m_aesItem.effectStateId(AreaEffectSimulation::AesEffectState_def::get_default());
|
||||
}
|
||||
m_ui->leIdentifier->setText(QString::fromStdString(borderline.name()));
|
||||
if ( borderline.partyId().is_set())
|
||||
m_ui->cbParty->setCurrentIndex(m_ui->cbParty->findData(borderline.partyId().get()));
|
||||
m_ui->lbBorderlineId->setText(QString::number(borderline.id()));
|
||||
|
||||
if (borderline.operatorId() > 0)
|
||||
m_ui->cbLocalBorderline->setChecked(true);
|
||||
else
|
||||
m_ui->cbLocalBorderline->setChecked(false);
|
||||
|
||||
setCoordinates(borderline.segments());
|
||||
} // end of setData()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void BorderlineEdit::onGetPolyline()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION;
|
||||
|
||||
if (!has2DMap())
|
||||
return;
|
||||
|
||||
QPolygonF coordinates = getCoordinatesQPointF();
|
||||
|
||||
m_sitMapGuiIfc->getPolyline(this,
|
||||
SLOT(onPolylineData(QPolygonF)),
|
||||
nullptr,
|
||||
2,
|
||||
11,
|
||||
-1,
|
||||
-1,
|
||||
coordinates);
|
||||
|
||||
} // end of onGetPolyline()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void BorderlineEdit::onPolylineData(const QPolygonF &polyline)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION << " numberOfPoints: " << polyline.size();
|
||||
|
||||
if (polyline.size() < 2)
|
||||
return;
|
||||
|
||||
m_previewPolygon = polyline;
|
||||
|
||||
// Don't reverse Polyline
|
||||
setCoordinates(polyline, false);
|
||||
|
||||
showPreviewObject();
|
||||
|
||||
}// end of onPolylineData()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void BorderlineEdit::showPreviewObject()
|
||||
{
|
||||
if (!m_sitMapGuiIfc)
|
||||
return;
|
||||
|
||||
if (m_previewPolygon.isEmpty())
|
||||
return;
|
||||
|
||||
m_sitMapGuiIfc->displayPreviewObject(this, m_previewPolygon, false);
|
||||
}
|
||||
|
||||
bool BorderlineEdit::apply()
|
||||
{
|
||||
const int operatorId = (m_ui->cbLocalBorderline->isChecked() ?
|
||||
LtsSessionData::LtsSessionData::getInstance()->getOperatorId() :
|
||||
0);
|
||||
|
||||
const BorderlineModifyRequest req(m_aesItem.id(),
|
||||
operatorId,
|
||||
m_ui->cbParty->currentData().toInt(),
|
||||
m_ui->leIdentifier->text().toStdString(),
|
||||
getCoordinates());
|
||||
DEBUG_LOG(m_logger) << "modifyBorderline: " << req;
|
||||
|
||||
m_requestHelper->addRequest([this, req]()
|
||||
{
|
||||
return m_ftc->borderlineModifyRequest(req, this);
|
||||
});
|
||||
|
||||
return m_requestHelper->startRequests();
|
||||
|
||||
} // end of apply()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
QByteArray BorderlineEdit::borderlineToJson()
|
||||
{
|
||||
QJsonArray arrSeg;
|
||||
const int operatorId = (m_ui->cbLocalBorderline->isChecked() ?
|
||||
LtsSessionData::LtsSessionData::getInstance()->getOperatorId() :
|
||||
0);
|
||||
|
||||
QJsonObject obj;
|
||||
obj[QStringLiteral("XmlType")] = FileManagement::toString(FileManagement::XmlType::AESBorderlineEdit);
|
||||
obj[QStringLiteral("id")] = m_aesItem.id();
|
||||
obj[QStringLiteral("operatorId")] = operatorId;
|
||||
obj[QStringLiteral("cbParty")] = m_ui->cbParty->currentData().toInt();
|
||||
obj[QStringLiteral("leIdentifier")] = m_ui->leIdentifier->text();
|
||||
|
||||
arrSeg = {};
|
||||
const auto segments = getCoordinates();
|
||||
for (const Core::GeoPosition2D &segment : segments)
|
||||
{
|
||||
QJsonObject innerSeg;
|
||||
innerSeg[QStringLiteral("lat")] = segment.lat();
|
||||
innerSeg[QStringLiteral("lon")] = segment.lon();
|
||||
|
||||
arrSeg += innerSeg;
|
||||
}
|
||||
obj[QStringLiteral("segments")] = arrSeg;
|
||||
QJsonDocument doc(obj);
|
||||
return doc.toJson(QJsonDocument::Compact);
|
||||
|
||||
}
|
||||
|
||||
Borderline BorderlineEdit::jsonToBorderline(const QByteArray &content)
|
||||
{
|
||||
Borderline borderline;
|
||||
// already checked that content is not empty, is parseable and contains the proper XmlType (AESBorderlineEdit)
|
||||
const QJsonDocument doc(QJsonDocument::fromJson(content));
|
||||
const QJsonObject obj(doc.object());
|
||||
|
||||
borderline.chargeStruct().chargeTypeId(obj[QStringLiteral("chargeTypeId")].toInt());
|
||||
borderline.effectDuration(obj[QStringLiteral("effectDuration")].toDouble());
|
||||
borderline.effectMarkingInTa(obj[QStringLiteral("effectMarkingInTa")].toInt());
|
||||
borderline.effectStart(obj[QStringLiteral("effectStart")].toDouble());
|
||||
int effectStateId = obj[QStringLiteral("effectStateId")].toInt();
|
||||
borderline.effectStateId(static_cast<AreaEffectSimulation::AesEffectState::inner_enum>(effectStateId));
|
||||
borderline.operatorId(obj[QStringLiteral("operatorId")].toInt());
|
||||
borderline.id(0);
|
||||
borderline.name(obj[QStringLiteral("leIdentifier")].toString().toStdString());
|
||||
if (obj.contains(QStringLiteral("participantId")) )
|
||||
borderline.participantId(obj[QStringLiteral("participantId")].toDouble());
|
||||
if (obj.contains(QStringLiteral("partyId")) )
|
||||
borderline.partyId(obj[QStringLiteral("partyId")].toDouble());
|
||||
borderline.sampleTime(obj[QStringLiteral("sampleTime")].toDouble());
|
||||
|
||||
//Start segments
|
||||
const QJsonArray arrSeg = (obj.value(QStringLiteral("segments")).toArray());
|
||||
borderline.segments().reserve(arrSeg.size());
|
||||
for (const auto &ele : arrSeg)
|
||||
{
|
||||
const QJsonObject objSeg(ele.toObject());
|
||||
Core::GeoPosition2D segment;
|
||||
segment.lat(objSeg[QStringLiteral("lat")].toDouble());
|
||||
segment.lon(objSeg[QStringLiteral("lon")].toDouble());
|
||||
borderline.segments().push_back(std::move(segment));
|
||||
}
|
||||
//End segments
|
||||
|
||||
return borderline;
|
||||
}
|
||||
|
||||
void BorderlineEdit::onExportButtonClicked()
|
||||
{
|
||||
QByteArray byteArray = borderlineToJson();
|
||||
int fileId = m_flmGui->saveFileContent(this, FileManagement::FileType::Xml, m_session->exerciseId(), byteArray);
|
||||
if (fileId > 0)
|
||||
DEBUG_LOG(m_logger) << "Saved file with id = " << fileId;
|
||||
else
|
||||
ERROR_LOG(m_logger) << "Could not save file in library ";
|
||||
}
|
||||
|
||||
void BorderlineEdit::onImportButtonClicked()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << " onImportButtonClicked() ";
|
||||
|
||||
QByteArray content;
|
||||
int fileId = m_flmGui->loadFileContent(this, content, {FileManagement::FileType::Xml}, m_session->exerciseId(), FileManagement::toString(FileManagement::XmlType::AESBorderlineEdit));
|
||||
if (fileId > 0)
|
||||
{
|
||||
if (!m_flmGui->isXmlType(content, FileManagement::toString(FileManagement::XmlType::AESBorderlineEdit)))
|
||||
{
|
||||
QHash<LtsWidgets::Button, QString> texts({{LtsWidgets::Button::Yes, tr("Ok")}});
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this,
|
||||
tr("Invalid xml file content"),
|
||||
windowTitle(),
|
||||
LtsWidgets::Behaviour::Modal,
|
||||
LtsWidgets::Button::Yes,
|
||||
texts);
|
||||
}
|
||||
else
|
||||
{
|
||||
Borderline borderline = jsonToBorderline(content);
|
||||
setData( borderline, true);
|
||||
setCoordinates(borderline.segments());
|
||||
QPolygonF coordinates = getCoordinatesQPointF();
|
||||
|
||||
onPolylineData(coordinates);
|
||||
showPreviewObject();
|
||||
INFO_LOG(m_logger) << "--- onImportButtonClicked() ";
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
} // namespace AreaEffectSimulation
|
||||
@@ -0,0 +1,82 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for AreaEffectSimulation - Borderline Add/Edit Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2017-06-20
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Plugins/AreaEffectSimulation/Gui/Base/aes_base_edit.h>
|
||||
#include <AreaEffectSimulation/aes_ftc.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <Plugins/FileManagement/flm_explorer_gui_plugin_interface.h>
|
||||
|
||||
//#include <LtsWidgets/lts_dialog.h>
|
||||
//#include <LtsSession/lts_session.h>
|
||||
//#include <LtsUtilsGuiDds/request_helper.h>
|
||||
|
||||
//#include <AreaEffectSimulation/aes_dtc.h>
|
||||
//#include <AreaEffectSimulation/aes_ftc.h>
|
||||
//#include <AreaEffectSimulation/logger.h>
|
||||
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class BorderlineEdit;
|
||||
}
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
class BorderlineEdit final
|
||||
: public BaseEdit
|
||||
, protected AreaEffectSimulation::Interface::Ftc::BorderlineModifyReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit BorderlineEdit(const QString &menuGroup, QWidget *parent = nullptr);
|
||||
~BorderlineEdit();
|
||||
|
||||
QString dialogIdentifier() const override
|
||||
{
|
||||
return m_aesItem.id() <= 0 ? QStringLiteral("AddBorderline") : QStringLiteral("EditBorderline%1").arg(m_aesItem.id());
|
||||
}
|
||||
bool init(int aesItemId, bool copy, LtsSession::LtsSession *session);
|
||||
|
||||
|
||||
//virtual functions from ExerciseEventManagement::Interface::Ftc
|
||||
void onBorderlineModifyReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
|
||||
|
||||
|
||||
private:
|
||||
std::vector<LtsCoordWidget::LtsCoordWidget *> coordWidgets() const override;
|
||||
void retranslate() override;
|
||||
void enableUiElements(bool enable) override;
|
||||
|
||||
void setData(const Borderline &borderline, bool copy);
|
||||
QByteArray borderlineToJson();
|
||||
Borderline jsonToBorderline(const QByteArray &content);
|
||||
|
||||
private slots:
|
||||
void onGetPolyline();
|
||||
void onPolylineData(const QPolygonF &polyline); // callback for onGetPolyline()
|
||||
void onExportButtonClicked();
|
||||
void onImportButtonClicked();
|
||||
|
||||
/**
|
||||
* Override the accept function from LtsDialog to save a modified edit dialog when the widget is closed.
|
||||
*/
|
||||
bool apply() override;
|
||||
void showPreviewObject() override;
|
||||
|
||||
private:
|
||||
Ui::BorderlineEdit *m_ui;
|
||||
QPolygonF m_previewPolygon;
|
||||
std::shared_ptr<FileManagement::ForeignGuiInterface> m_flmGui;
|
||||
};
|
||||
|
||||
} // namespace AreaEffectSimulation
|
||||
@@ -0,0 +1,266 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>BorderlineEdit</class>
|
||||
<widget class="QWidget" name="BorderlineEdit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1128</width>
|
||||
<height>224</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Aes Danger Area Edit</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="2" colspan="2">
|
||||
<widget class="QLabel" name="lblGeometry">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Geometry:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLabel" name="lbBorderlineId">
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="LtsWidgets::LtsComboBox" name="cbParty">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="currentText">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="3">
|
||||
<widget class="QPushButton" name="pbClear">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../Styles/Light/resources/rde_light_style.qrc">
|
||||
<normaloff>:/style/remove.svg</normaloff>:/style/remove.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lblParty">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Party:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QCheckBox" name="cbLocalBorderline">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Local Borderline</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="lblBorderlineId">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Borderline Id:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="3">
|
||||
<widget class="QPushButton" name="pbPosition">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../Styles/Light/resources/rde_light_style.qrc">
|
||||
<normaloff>:/style/position.svg</normaloff>:/style/position.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="leIdentifier">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lblIdentifier">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Identifier:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="4">
|
||||
<widget class="LtsCoordWidget::LtsCoordWidget" name="positionEdit_1">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="5">
|
||||
<widget class="LtsCoordWidget::LtsCoordWidget" name="positionEdit_7">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="5">
|
||||
<widget class="LtsCoordWidget::LtsCoordWidget" name="positionEdit_8">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="5">
|
||||
<widget class="LtsCoordWidget::LtsCoordWidget" name="positionEdit_9">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="5">
|
||||
<widget class="LtsCoordWidget::LtsCoordWidget" name="positionEdit_10">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="5">
|
||||
<widget class="LtsCoordWidget::LtsCoordWidget" name="positionEdit_11">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="4">
|
||||
<widget class="LtsCoordWidget::LtsCoordWidget" name="positionEdit_2">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="4">
|
||||
<widget class="LtsCoordWidget::LtsCoordWidget" name="positionEdit_3">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="4">
|
||||
<widget class="LtsCoordWidget::LtsCoordWidget" name="positionEdit_4">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="4">
|
||||
<widget class="LtsCoordWidget::LtsCoordWidget" name="positionEdit_5">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="4">
|
||||
<widget class="LtsCoordWidget::LtsCoordWidget" name="positionEdit_6">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>0</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::LtsComboBox</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header>LtsWidgets/lts_combo_box.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../../../Styles/Light/resources/rde_light_style.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
+98
@@ -0,0 +1,98 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Gui Plugin for AreaEffectSimulation - Borderlines
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2017-06-06
|
||||
*/
|
||||
|
||||
#include "aes_borderline_gui_plugin.h"
|
||||
#include "aes_borderline_list.h"
|
||||
#include "aes_borderline_edit.h"
|
||||
|
||||
#include <AreaEffectSimulation/aes_operator_rights.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsUtilsSettings/settings.h>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
std::shared_ptr<GuiPluginBase::Interface> GuiPlugin::createGuiInterface(LtsSession::LtsSession *session)
|
||||
{
|
||||
return std::make_shared<InterfaceImpl>(session);
|
||||
} // end of createGuiInterface()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
InterfaceImpl::InterfaceImpl(LtsSession::LtsSession *session)
|
||||
: AesBaseInterface(session, getLogger("Plugins.Gui.Borderline"))
|
||||
// : GuiPluginBase::Interface(session, getLogger("Plugins.Gui.BorderlineImpl"))
|
||||
, ForeignGuiInterface()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << " --------Start InterfaceImpl Gui plugin borderline";
|
||||
} // end of ctor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
QVector<LtsWidgets::PluginData> InterfaceImpl::getActions()
|
||||
{
|
||||
QVector<LtsWidgets::PluginData> ret;
|
||||
|
||||
LtsUtils::ProjectSettings *ps = LtsUtils::ProjectSettings::getInstance();
|
||||
const bool enableBorderlines = ps->value(QStringLiteral("aes"),
|
||||
QStringLiteral("enableBorderlines")).toBool();
|
||||
|
||||
if (enableBorderlines && m_session->app() != LtsAppDescriptor::App::OC)
|
||||
{
|
||||
// Action 'Show Borderlines' anlegen
|
||||
ret.append(LtsWidgets::PluginData( tr("Alarm Management"),
|
||||
tr("Borderlines"),
|
||||
QLatin1String("ListBorderlines"),
|
||||
QIcon(QLatin1String("icon:define_border_lines.svg")),
|
||||
[this](QWidget *parent) { return onShowBorderlineListDialog(parent);},
|
||||
OperatorRights::BorderlinesShow,
|
||||
LtsWidgets::ExercisePart::eExecution));
|
||||
|
||||
|
||||
|
||||
// Action 'New Borderline' anlegen
|
||||
if (m_session->isExercisePartition())
|
||||
ret.append(LtsWidgets::PluginData(tr("Alarm Management"),
|
||||
tr("Add Borderline"),
|
||||
QLatin1String("AddBorderline"),
|
||||
QIcon(QLatin1String("icon:define_border_lines_add.svg")),
|
||||
[this](QWidget *parent) { return onShowAddBorderlineDialog(parent);},
|
||||
OperatorRights::BorderlinesEdit,
|
||||
LtsWidgets::ExercisePart::eExecution,
|
||||
LtsWidgets::ExerciseState::eCreated | LtsWidgets::ExerciseState::eStarted | LtsWidgets::ExerciseState::ePaused));
|
||||
}
|
||||
return ret;
|
||||
} // end of getActions()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
AreaEffectSimulation::BaseEdit *InterfaceImpl::showEditWindow(int aesEntityId, QWidget *parent)
|
||||
{
|
||||
BorderlineEdit *dialog = new BorderlineEdit(menuGroup(), parent);
|
||||
dialog->init(aesEntityId, false, m_session);
|
||||
return dialog;
|
||||
} // end of showEditWindow()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
LtsWidgets::LtsDialog *InterfaceImpl::onShowBorderlineListDialog(QWidget *parent)
|
||||
{
|
||||
BorderlineList *dialog = new BorderlineList(menuGroup(), parent);
|
||||
dialog->init(m_session);
|
||||
return dialog;
|
||||
} // end of onShowBorderlineListDialog()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
LtsWidgets::LtsDialog *InterfaceImpl::onShowAddBorderlineDialog(QWidget *parent)
|
||||
{
|
||||
BorderlineEdit *dialog = new BorderlineEdit(menuGroup(), parent);
|
||||
dialog->init(0, false, m_session);
|
||||
return dialog;
|
||||
} // end of onShowAddBorderlineDialog()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
} // namespace AreaEffectSimulation
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Gui Plugin for AreaEffectSimulation Borderline
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2017-06-06
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Plugins/AreaEffectSimulation/Gui/Base/aes_base_gui_plugin.h>
|
||||
#include "aes_borderline_gui_plugin_interface.h"
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
class GuiPlugin final : public AesBaseGuiPlugin
|
||||
{
|
||||
Q_PLUGIN_METADATA(IID "gui:3:aes.borderlines")
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GuiPlugin() = default;
|
||||
~GuiPlugin() = default;
|
||||
QString pluginName() override { return QLatin1String("AreaEffectSimulationBorderlineGui"); }
|
||||
std::shared_ptr<GuiPluginBase::Interface> createGuiInterface(LtsSession::LtsSession *session) override;
|
||||
bool availableInPartition(IDL::PartitionType partition) const override
|
||||
{
|
||||
return partition == IDL::PartitionType::Exercise ||
|
||||
partition == IDL::PartitionType::Replay;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
class InterfaceImpl final : public AesBaseInterface, public AesBorderline::ForeignGuiInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit InterfaceImpl(LtsSession::LtsSession *session);
|
||||
|
||||
QVector<LtsWidgets::PluginData> getActions() override;
|
||||
AreaEffectSimulation::BaseEdit *showEditWindow(int aesEntityId, QWidget *parent) override;
|
||||
|
||||
private:
|
||||
LtsWidgets::LtsDialog *onShowBorderlineListDialog(QWidget *parent);
|
||||
LtsWidgets::LtsDialog *onShowAddBorderlineDialog(QWidget *parent);
|
||||
|
||||
};
|
||||
|
||||
} // namespace AreaEffectSimulation
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for AreaEffectSimulation Borderline (Interface for access from other Plugins)
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2017-06-06
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
class QWidget;
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
class BaseEdit;
|
||||
}
|
||||
|
||||
namespace AesBorderline
|
||||
{
|
||||
class ForeignGuiInterface
|
||||
{
|
||||
public:
|
||||
ForeignGuiInterface() = default;
|
||||
virtual ~ForeignGuiInterface() = default;
|
||||
|
||||
virtual AreaEffectSimulation::BaseEdit *showEditWindow(int aesEntityId, QWidget *parent) = 0;
|
||||
};
|
||||
|
||||
} //namespace AesBorderline
|
||||
@@ -0,0 +1,183 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for AreaEffectSimulation - Borderline Overview Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2017-06-19
|
||||
*/
|
||||
|
||||
#include "aes_borderline_list.h"
|
||||
#include "aes_borderline_edit.h"
|
||||
#include "aes_borderlines_model.h"
|
||||
#include "CustomView/aes_borderline.h"
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <FileManagement/flm_translation.h>
|
||||
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
bool BorderlineList::init(LtsSession::LtsSession *session)
|
||||
{
|
||||
if (!AesItemList::init(session))
|
||||
return false;
|
||||
|
||||
m_bHasAddEditOperatorRights = LtsSessionData::LtsSessionData::getInstance()->hasOperatorRight(OperatorRights::BorderlinesEdit);
|
||||
|
||||
setDataViewModel(m_model, [this]() { return new CustomViewBorderline(this); });
|
||||
|
||||
#ifndef LTS_DEBUG
|
||||
hideColumn(BorderlinesModel::BcId);
|
||||
#endif
|
||||
hideColumn(BorderlinesModel::BcChargeType);
|
||||
hideColumn(BorderlinesModel::BcEffectDuration);
|
||||
hideColumn(BorderlinesModel::BcEffectStart);
|
||||
hideColumn(BorderlinesModel::BcEffectState);
|
||||
hideColumn(BorderlinesModel::BcEffectSource);
|
||||
hideColumn(BorderlinesModel::BcParticipant);
|
||||
|
||||
setSortIndicator(BorderlinesModel::BcName);
|
||||
|
||||
enaDisa();
|
||||
|
||||
// Save/Load from Library Button
|
||||
m_buttonBox->connectLibraryButton(this,
|
||||
&BorderlineList::onImportButtonClicked,
|
||||
&BorderlineList::onExportButtonClicked);
|
||||
|
||||
if (!session->getForeignGuiInterface<FileManagement::ForeignGuiInterface>(m_flmGui))
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Library, false);
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Borderlines"));
|
||||
|
||||
return true;
|
||||
} // end of init()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void BorderlineList::createModel()
|
||||
{
|
||||
m_model = new AesItemSortFilterProxyModelTmpl<Borderline>(m_session, this);
|
||||
|
||||
m_borderlinesModel = new BorderlinesModel(this);
|
||||
m_borderlinesModel->initModel(m_session);
|
||||
m_model->setSourceModel(m_borderlinesModel);
|
||||
} // end of createModel()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void BorderlineList::onAddAesItem()
|
||||
{
|
||||
BorderlineEdit *dialog = new BorderlineEdit(m_menuGroup, this);
|
||||
|
||||
const int aesItemId = model()->aesId(currentRow());
|
||||
if (dialog->init(aesItemId, aesItemId > 0, m_session))
|
||||
addDialog(dialog, m_menuGroup, dialog->dialogIdentifier(), LtsWidgets::LayoutArea::eDialogTab);
|
||||
else
|
||||
delete dialog;
|
||||
} // end of onAddAesItem()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void BorderlineList::onEditAesItem()
|
||||
{
|
||||
const int aesItemId = model()->aesId(currentRow());
|
||||
|
||||
if (aesItemId < 0)
|
||||
return;
|
||||
|
||||
DEBUG_LOG(m_logger) << "current BorderlineId: " << aesItemId;
|
||||
|
||||
BorderlineEdit *dialog = new BorderlineEdit(m_menuGroup, this);
|
||||
if (dialog->init(aesItemId, false, m_session))
|
||||
addDialog(dialog, m_menuGroup, dialog->dialogIdentifier(), LtsWidgets::LayoutArea::eDialogTab);
|
||||
else
|
||||
delete dialog;
|
||||
} // end of onEditAesItem()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void BorderlineList::onRemoveAesItem()
|
||||
{
|
||||
const int aesItemId = model()->aesId(currentRow());
|
||||
Core::RemoveElementRequest req(aesItemId);
|
||||
m_requestHelper->startSingleRequest([req, this]()
|
||||
{
|
||||
return m_ftc->borderlineRemoveRequest(req, this);
|
||||
});
|
||||
} // end of onRemoveAesItem()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void BorderlineList::retranslate()
|
||||
{
|
||||
translateBase(tr("Borderlines"));
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void BorderlineList::onBorderlineModifyReply(const Core::FunctionReplyObject &replyObject)
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
} // end of onBorderlineRemoveReply()
|
||||
|
||||
void BorderlineList::onBorderlineRemoveReply(const Core::FunctionReplyObject &replyObject)
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
} // end of onBorderlineRemoveReply()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// library
|
||||
void BorderlineList::onExportButtonClicked()
|
||||
{
|
||||
QByteArray byteArray = m_borderlinesModel->borderlinesToJson();
|
||||
|
||||
int fileId = m_flmGui->saveFileContent(this, FileManagement::FileType::Xml, m_session->exerciseId(), byteArray);
|
||||
if (fileId > 0)
|
||||
DEBUG_LOG(m_logger) << "Saved file with id = " << fileId;
|
||||
else
|
||||
ERROR_LOG(m_logger) << "Could not save file in library ";
|
||||
|
||||
}
|
||||
|
||||
void BorderlineList::onImportButtonClicked()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << " onImportButtonClicked() ";
|
||||
|
||||
QByteArray content;
|
||||
int fileId = m_flmGui->loadFileContent(this, content, {FileManagement::FileType::Xml}, m_session->exerciseId(), FileManagement::toString(FileManagement::XmlType::AESBorderlineList));
|
||||
if (fileId > 0)
|
||||
{
|
||||
if (!m_flmGui->isXmlType(content, FileManagement::toString(FileManagement::XmlType::AESBorderlineList)))
|
||||
{
|
||||
QHash<LtsWidgets::Button, QString> texts({{LtsWidgets::Button::Yes, tr("Ok")}});
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this,
|
||||
tr("Invalid xml file content"),
|
||||
windowTitle(),
|
||||
LtsWidgets::Behaviour::Modal,
|
||||
LtsWidgets::Button::Yes,
|
||||
texts);
|
||||
}
|
||||
else
|
||||
{
|
||||
INFO_LOG(m_logger) << "--- onImportButtonClicked() ";
|
||||
const QVector<Borderline> requests = m_borderlinesModel->jsonToBorderlineVector(content);
|
||||
for(const auto &borderline : requests)
|
||||
{
|
||||
BorderlineModifyRequest request;
|
||||
request.id(0);
|
||||
request.name(borderline.name());
|
||||
request.operatorId(borderline.operatorId());
|
||||
if (borderline.partyId().is_set())
|
||||
request.partyId(borderline.partyId().get());
|
||||
request.name(borderline.name());
|
||||
request.segments(borderline.segments());
|
||||
m_requestHelper->startSingleRequest([this, request]()
|
||||
{
|
||||
return m_ftc->borderlineModifyRequest(request, this);
|
||||
});
|
||||
}
|
||||
INFO_LOG(m_logger) << "--- onImportButtonClicked() ";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // namespace AreaEffectSimulation
|
||||
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for AreaEffectSimulation - Borderline Overview Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2017-06-19
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Plugins/AreaEffectSimulation/Gui/Base/aes_itemlist.h>
|
||||
#include <Plugins/AreaEffectSimulation/Gui/Base/aes_base_model.h>
|
||||
#include <Plugins/FileManagement/flm_explorer_gui_plugin_interface.h>
|
||||
#include "aes_borderlines_model.h"
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
class BorderlineList final : public AesItemListTmpl<Borderline>
|
||||
, protected AreaEffectSimulation::Interface::Ftc::BorderlineModifyReplyHandler
|
||||
, protected AreaEffectSimulation::Interface::Ftc::BorderlineRemoveReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
using AesItemListTmpl<Borderline>::AesItemListTmpl;
|
||||
|
||||
bool init(LtsSession::LtsSession *session) override;
|
||||
|
||||
private slots:
|
||||
void onAddAesItem() override;
|
||||
void onEditAesItem() override;
|
||||
void onRemoveAesItem() override;
|
||||
void onExportButtonClicked();
|
||||
void onImportButtonClicked();
|
||||
|
||||
private:
|
||||
void createModel() override;
|
||||
void retranslate() override;
|
||||
void onBorderlineModifyReply(const Core::FunctionReplyObject &replyObject) override;
|
||||
void onBorderlineRemoveReply(const Core::FunctionReplyObject &replyObject) override;
|
||||
BorderlinesModel *m_borderlinesModel = nullptr;
|
||||
std::shared_ptr<FileManagement::ForeignGuiInterface> m_flmGui;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,181 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for AreaEffectSimulation - Borderline Overview Dialog Model
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2017-06-19
|
||||
*/
|
||||
|
||||
|
||||
#include "aes_borderlines_model.h"
|
||||
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <FileManagement/flm_translation.h>
|
||||
|
||||
#include <QJsonArray>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonDocument>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
BorderlinesModel::BorderlinesModel(QObject *parent)
|
||||
: AesGuiBaseModel<Borderline>(parent, {tr("Type")})
|
||||
// operatorId represents here the type of borderline. operatorId <=0 global, >0 local
|
||||
{
|
||||
} // end of ctor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
BorderlinesModel::~BorderlinesModel()
|
||||
{
|
||||
} // end of dtor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool BorderlinesModel::initModel(LtsSession::LtsSession *session)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "--- Start BorderlinesModel::initModel()";
|
||||
|
||||
if (!AesGuiBaseModel::initModel(session))
|
||||
return false;
|
||||
|
||||
connect(m_aesDtc.get(), &AreaEffectSimulation::Interface::Dtc::borderlineChanged,
|
||||
this, &BorderlinesModel::onDataChanged);
|
||||
m_aesDtc->borderlines([this](const Borderline &item) { insertRow(item); });
|
||||
|
||||
return true;
|
||||
} // end of initModel()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
QVariant BorderlinesModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!indexIsValid(index))
|
||||
return QVariant();
|
||||
|
||||
const Borderline &item = m_vecData.at(index.row());
|
||||
|
||||
if (index.column() < cntBaseColumns())
|
||||
return AesGuiBaseModel::data(item, index.column(), role);
|
||||
|
||||
if (role != Qt::DisplayRole)
|
||||
return QVariant();
|
||||
|
||||
// Spezielle Borderline columns
|
||||
switch (index.column())
|
||||
{
|
||||
case ColOperatorId:
|
||||
if (item.operatorId() == 0)
|
||||
return tr("Global");
|
||||
return tr("Local");
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return QVariant();
|
||||
} // end of data()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool BorderlinesModel::isFiltered(const Borderline &data, DataModification modType) const
|
||||
{
|
||||
// globale und nur lokale Borderlines des akt. operators eintragen
|
||||
if ((data.operatorId() != LtsSessionData::LtsSessionData::getInstance()->getOperatorId()) &&
|
||||
(data.operatorId() != 0))
|
||||
return true;
|
||||
return AesGuiBaseModel::isFiltered(data, modType);
|
||||
|
||||
} // end of isFiltered()
|
||||
//-----------------------------------------------------------------------------
|
||||
QByteArray BorderlinesModel::borderlinesToJson()
|
||||
{
|
||||
QJsonObject obj;
|
||||
QJsonArray arr;
|
||||
QJsonArray arrSeg;
|
||||
|
||||
obj[QStringLiteral("XmlType")] = FileManagement::toString(FileManagement::XmlType::AESBorderlineList);
|
||||
for (int row = 0; row <rowCount(); row++)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "row =" << ": " << row;
|
||||
QJsonObject inner;
|
||||
const Borderline &borderline = m_vecData.at(row);
|
||||
|
||||
inner[QStringLiteral("chargeTypeId")] = borderline.chargeStruct().chargeTypeId();
|
||||
inner[QStringLiteral("effectDuration")] = borderline.effectDuration();
|
||||
inner[QStringLiteral("effectMarkingInTa")] = borderline.effectMarkingInTa();
|
||||
//inner[QStringLiteral("effectStart")] = borderline.effectStart(); not for Borderlines
|
||||
inner[QStringLiteral("effectStateId")] = borderline.effectStateId().underlying();
|
||||
inner[QStringLiteral("id")] = borderline.id();
|
||||
inner[QStringLiteral("isDeleted")] = borderline.isDeleted();
|
||||
inner[QStringLiteral("isUsed")] = borderline.isUsed();
|
||||
inner[QStringLiteral("name")] = QString::fromStdString(borderline.name());
|
||||
inner[QStringLiteral("operatorId")] = borderline.operatorId();
|
||||
if ( borderline.participantId().is_set())
|
||||
inner[QStringLiteral("participantId")] = borderline.participantId().get();
|
||||
if ( borderline.partyId().is_set())
|
||||
inner[QStringLiteral("partyId")] = borderline.partyId().get();
|
||||
inner[QStringLiteral("sampleTime")] = borderline.sampleTime();
|
||||
|
||||
arrSeg = {};
|
||||
for (const Core::GeoPosition2D &segment : borderline.segments())
|
||||
{
|
||||
QJsonObject innerSeg;
|
||||
|
||||
innerSeg[QStringLiteral("lat")] = segment.lat();
|
||||
innerSeg[QStringLiteral("lon")] = segment.lon();
|
||||
|
||||
arrSeg += innerSeg;
|
||||
}
|
||||
inner[QStringLiteral("segments")] = arrSeg;
|
||||
arr += inner;
|
||||
}
|
||||
|
||||
obj[QStringLiteral("Borderlines")] = arr;
|
||||
QJsonDocument doc(obj);
|
||||
return doc.toJson(QJsonDocument::Compact);
|
||||
|
||||
}
|
||||
|
||||
QVector<Borderline> BorderlinesModel::jsonToBorderlineVector(const QByteArray &content)
|
||||
{
|
||||
QVector<Borderline> result;
|
||||
// already checked that content is not empty and parseable and containing the proper XmlType (AESBorderlineList)
|
||||
const QJsonDocument doc(QJsonDocument::fromJson(content));
|
||||
const QJsonObject obj(doc.object());
|
||||
const QJsonArray arr(obj.value(QStringLiteral("Borderlines")).toArray());
|
||||
for (const auto &ele : arr)
|
||||
{
|
||||
const QJsonObject objArr(ele.toObject());
|
||||
Borderline borderline;
|
||||
borderline.chargeStruct().chargeTypeId(objArr[QStringLiteral("chargeTypeId")].toInt());
|
||||
borderline.effectDuration(objArr[QStringLiteral("effectDuration")].toDouble());
|
||||
borderline.effectMarkingInTa(objArr[QStringLiteral("effectMarkingInTa")].toInt());
|
||||
borderline.effectStart(objArr[QStringLiteral("effectStart")].toDouble());
|
||||
int effectStateId = objArr[QStringLiteral("effectStateId")].toInt();
|
||||
borderline.effectStateId(static_cast<AreaEffectSimulation::AesEffectState::inner_enum>(effectStateId));
|
||||
borderline.operatorId(objArr[QStringLiteral("operatorId")].toInt());
|
||||
borderline.id(0);
|
||||
borderline.name(objArr[QStringLiteral("name")].toString().toStdString());
|
||||
if (objArr.contains(QStringLiteral("participantId")) )
|
||||
borderline.participantId(objArr[QStringLiteral("participantId")].toDouble());
|
||||
if (objArr.contains(QStringLiteral("partyId")) )
|
||||
borderline.partyId(objArr[QStringLiteral("partyId")].toDouble());
|
||||
borderline.sampleTime(objArr[QStringLiteral("sampleTime")].toDouble());
|
||||
|
||||
//Start segments
|
||||
const QJsonArray arrSeg = (objArr.value(QStringLiteral("segments")).toArray());
|
||||
borderline.segments().reserve(arrSeg.size());
|
||||
for (const auto &seg : arrSeg)
|
||||
{
|
||||
const QJsonObject objSeg(seg.toObject());
|
||||
Core::GeoPosition2D segment;
|
||||
segment.lat(objSeg[QStringLiteral("lat")].toDouble());
|
||||
segment.lon(objSeg[QStringLiteral("lon")].toDouble());
|
||||
borderline.segments().push_back(std::move(segment));
|
||||
}
|
||||
//End segments
|
||||
|
||||
result.append(std::move(borderline));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace AreaEffectSimulation
|
||||
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for AreaEffectSimulation - Borderline Overview Dialog Model
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2017-06-19
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Plugins/AreaEffectSimulation/Gui/Base/aes_base_model.h>
|
||||
|
||||
namespace LtsSession
|
||||
{
|
||||
class LtsSession;
|
||||
}
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
class BorderlinesModel final : public AesGuiBaseModel<Borderline>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum AdditionalColumns {ColOperatorId = BcCount};
|
||||
explicit BorderlinesModel(QObject *parent = nullptr);
|
||||
~BorderlinesModel();
|
||||
|
||||
bool initModel(LtsSession::LtsSession *session) override;
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
QByteArray borderlinesToJson();
|
||||
QVector<Borderline> jsonToBorderlineVector(const QByteArray &content);
|
||||
|
||||
protected:
|
||||
bool isFiltered(const Borderline &data, DataModification modType) const override;
|
||||
};
|
||||
} //namespace AreaEffectSimulation
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
# Created by Christian Ehrlicher, SLSE, 2016-03-01
|
||||
#
|
||||
|
||||
ADD_SUBDIRECTORY(AesInfo)
|
||||
ADD_SUBDIRECTORY(AirSupport)
|
||||
ADD_SUBDIRECTORY(Base)
|
||||
ADD_SUBDIRECTORY(BCContamination)
|
||||
ADD_SUBDIRECTORY(Borderline)
|
||||
ADD_SUBDIRECTORY(ChargeAdministration)
|
||||
ADD_SUBDIRECTORY(ChargeEffect)
|
||||
ADD_SUBDIRECTORY(DangerArea)
|
||||
ADD_SUBDIRECTORY(Explosion)
|
||||
ADD_SUBDIRECTORY(FunctionalArea)
|
||||
ADD_SUBDIRECTORY(GasPipe)
|
||||
ADD_SUBDIRECTORY(MineArea)
|
||||
ADD_SUBDIRECTORY(MineCorridor)
|
||||
ADD_SUBDIRECTORY(MineSingleVirtual)
|
||||
ADD_SUBDIRECTORY(NContamination)
|
||||
ADD_SUBDIRECTORY(TechnicalArea)
|
||||
@@ -0,0 +1,48 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
# Created by Malte Diers, SLSE, 2016-07-03
|
||||
#
|
||||
|
||||
SET(aes_charge_administration_gui_SRCS
|
||||
aes_charge_administration_gui_plugin.cpp
|
||||
aes_charge_administration_gui_plugin.h
|
||||
aes_charge_administration_list.cpp
|
||||
aes_charge_administration_list.h
|
||||
aes_charge_administration_model.cpp
|
||||
aes_charge_administration_model.h
|
||||
aes_charge_administration_adler_list.cpp
|
||||
aes_charge_administration_adler_list.h
|
||||
aes_charge_administration_adler_model.cpp
|
||||
aes_charge_administration_adler_model.h
|
||||
aes_charge_edit.h
|
||||
aes_charge_edit.cpp
|
||||
CustomView/aes_charge_administration.h
|
||||
CustomView/aes_charge_administration.cpp
|
||||
)
|
||||
|
||||
NGL_WRAP_UI(aes_charge_administration_gui_SRCS
|
||||
aes_charge_administration_list.ui
|
||||
aes_charge_edit.ui
|
||||
CustomView/aes_charge_administration.ui
|
||||
)
|
||||
|
||||
NGL_ADD_LIBRARY(WS AesChargeAdministrationGuiPlugin MODULE ${aes_charge_administration_gui_SRCS})
|
||||
NGL_TARGET_LINK_LIBRARIES(AesChargeAdministrationGuiPlugin
|
||||
LtsPrinting
|
||||
AesBaseGui
|
||||
LtsDataView
|
||||
NGLLogger
|
||||
ngltools
|
||||
LtsSession
|
||||
LtsSessionData
|
||||
AesDataPluginInterface
|
||||
PpmGuiComboboxPluginInterface
|
||||
svcPdmCommon
|
||||
Qt5::Widgets
|
||||
LtsWidgets
|
||||
LtsUtilsSettings
|
||||
)
|
||||
|
||||
NGL_INSTALL_TARGET(AesChargeAdministrationGuiPlugin)
|
||||
Executable
+42
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* CustomView for AES NContamination
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Mike Wille, SLSE, 2016-04-08
|
||||
*/
|
||||
|
||||
#include "aes_charge_administration.h"
|
||||
#include "ui_aes_charge_administration.h"
|
||||
|
||||
#include "aes_charge_administration_model.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
CustomViewChargeAdministration::CustomViewChargeAdministration(QWidget *parent)
|
||||
: AbstractDisplayWidget(parent)
|
||||
, m_ui(new Ui::CustomViewChargeAdministration)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
}
|
||||
|
||||
CustomViewChargeAdministration::~CustomViewChargeAdministration()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
bool CustomViewChargeAdministration::init(const QModelIndex &idx)
|
||||
{
|
||||
if (!idx.isValid())
|
||||
return false;
|
||||
|
||||
m_ui->lblChargeType->setText(rowData(idx, AreaEffectSimulation::ChargeAdministrationModel::ColTypeName).toString());
|
||||
m_ui->lblCount->setText(rowData(idx, AreaEffectSimulation::ChargeAdministrationModel::ColStock).toString());
|
||||
m_ui->lblPlanned->setText(rowData(idx, AreaEffectSimulation::ChargeAdministrationModel::ColPlanned).toString());
|
||||
return true;
|
||||
}
|
||||
} // namespace AreaEffectSimulation
|
||||
Executable
+35
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* CustomView for AES NContamination
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Mike Wille, SLSE, 2016-04-08
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include <Viewer/LtsDataView/abstract_display_widget.h>
|
||||
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class CustomViewChargeAdministration;
|
||||
}
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
class CustomViewChargeAdministration final : public LtsDataView::AbstractDisplayWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CustomViewChargeAdministration(QWidget *parent = nullptr);
|
||||
~CustomViewChargeAdministration();
|
||||
bool init(const QModelIndex &idx) override final;
|
||||
|
||||
private:
|
||||
Ui::CustomViewChargeAdministration* m_ui;
|
||||
|
||||
};
|
||||
} // namespace AreaEffectSimulation
|
||||
Executable
+120
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CustomViewChargeAdministration</class>
|
||||
<widget class="QWidget" name="CustomViewChargeAdministration">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>300</width>
|
||||
<height>70</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"/>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="lblChargeType">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">Name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Amount:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lblCount">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">0</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Already Planned:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lblPlanned">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">0</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Executable
+117
@@ -0,0 +1,117 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* AreaEffectManangement - Adler Charge Administration Overview Dialog Model
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Astrid Müller, ESZE, 2025-12-19
|
||||
*/
|
||||
|
||||
#include "aes_charge_administration_adler_list.h"
|
||||
#include "ui_aes_charge_administration_list.h"
|
||||
#include "aes_charge_administration_adler_model.h"
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsWidgets/lts_combo_box.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsUtilsGuiDds/request_helper.h>
|
||||
|
||||
#include <Plugins/ParticipantManagement/ppm_gui_combobox_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <QInputDialog>
|
||||
|
||||
#include <LtsPrinting/printing.h>
|
||||
#include <QTreeView>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
ChargeAdministrationAdlerList::ChargeAdministrationAdlerList(QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_model(nullptr)
|
||||
, m_sourceModel(nullptr)
|
||||
, m_session(nullptr)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_ui(new Ui::ChargeAdministrationList)
|
||||
, m_logger(getLogger("ChargeAdministrationAdlerList"))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
connect(m_ui->cbParty, static_cast<void (LtsWidgets::LtsComboBox::*)(int)>(&LtsWidgets::LtsComboBox::currentIndexChanged),
|
||||
this, &ChargeAdministrationAdlerList::onPartyChanged);
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Charge_Administration_Adler"));
|
||||
}
|
||||
|
||||
ChargeAdministrationAdlerList::~ChargeAdministrationAdlerList()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void ChargeAdministrationAdlerList::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("Charge Administration Adler"));
|
||||
}
|
||||
|
||||
void ChargeAdministrationAdlerList::tableColumnOrganiserSetting()
|
||||
{
|
||||
//LtsColumnOrganiser
|
||||
m_ui->widget->setColumnsOrganiserEnabled(identifier(), true);
|
||||
}
|
||||
|
||||
void ChargeAdministrationAdlerList::onPartyChanged()
|
||||
{
|
||||
m_model->setParty(m_ui->cbParty->currentData().toInt());
|
||||
}
|
||||
|
||||
bool ChargeAdministrationAdlerList::init(LtsSession::LtsSession *session)
|
||||
{
|
||||
if (m_session)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "double init()!";
|
||||
return false;
|
||||
}
|
||||
m_session = session;
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &ChargeAdministrationAdlerList::onPrint);
|
||||
|
||||
std::shared_ptr<ParticipantManagement::ForeignGuiComboboxInterface> ppmGuiCbxIfc;
|
||||
if (!m_session->getForeignGuiInterface<ParticipantManagement::ForeignGuiComboboxInterface>(ppmGuiCbxIfc))
|
||||
return false;
|
||||
|
||||
m_sourceModel = new ChargeAdministrationAdlerModel(this);
|
||||
|
||||
if (!m_sourceModel->initModel(m_session))
|
||||
return false;
|
||||
|
||||
m_model = new ChargeAdministrationAdlerSortFilterProxyModel(this);
|
||||
m_model->setSourceModel(m_sourceModel);
|
||||
m_ui->widget->setModel(m_model);
|
||||
m_ui->widget->hideColumn(ChargeAdministrationAdlerModel::ColId, true);
|
||||
|
||||
#ifndef LTS_DEBUG
|
||||
bool onlydebugMode =true;
|
||||
m_ui->widget->hideColumn(ChargeAdministrationAdlerModel::ColTypeId, onlydebugMode);
|
||||
m_ui->widget->hideColumn(ChargeAdministrationAdlerModel::ColChanged, onlydebugMode);
|
||||
#endif
|
||||
|
||||
m_ui->widget->setSortIndicator(ChargeAdministrationAdlerModel::ColTypeName, Qt::AscendingOrder);
|
||||
|
||||
ppmGuiCbxIfc->fillPartyComboBox(m_ui->cbParty);
|
||||
onPartyChanged();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ChargeAdministrationAdlerList::onPrint()
|
||||
{
|
||||
QString header;
|
||||
header += QStringLiteral("<p>");
|
||||
header += tr("Party: %1").arg(m_ui->cbParty->currentText());
|
||||
header += QStringLiteral("<br/>");
|
||||
header += QStringLiteral("</p>");
|
||||
|
||||
LtsPrinting::printView(m_session, this, m_ui->widget->treeView(), header );
|
||||
}
|
||||
|
||||
} // namespace AreaEffectSimulation
|
||||
Executable
+60
@@ -0,0 +1,60 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* AreaEffectManangement - Adler Charge Administration Overview Dialog Model
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Astrid Müller, ESZE, 2025-12-19
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
|
||||
|
||||
#include <AreaEffectSimulation/aes_ftc.h>
|
||||
#include <AreaEffectSimulation/logger.h>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class ChargeAdministrationList;
|
||||
}
|
||||
|
||||
namespace LtsSession
|
||||
{
|
||||
class LtsSession;
|
||||
}
|
||||
namespace LtsUtils
|
||||
{
|
||||
class RequestHelper;
|
||||
}
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
class ChargeAdministrationAdlerModel;
|
||||
class ChargeAdministrationAdlerSortFilterProxyModel;
|
||||
|
||||
class ChargeAdministrationAdlerList final : public LtsWidgets::LtsDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ChargeAdministrationAdlerList(QWidget *parent = nullptr);
|
||||
~ChargeAdministrationAdlerList();
|
||||
|
||||
bool init(LtsSession::LtsSession *session);
|
||||
|
||||
private slots:
|
||||
void onPrint();
|
||||
void onPartyChanged();
|
||||
|
||||
private:
|
||||
void retranslate() override;
|
||||
void tableColumnOrganiserSetting() override;
|
||||
ChargeAdministrationAdlerSortFilterProxyModel *m_model;
|
||||
ChargeAdministrationAdlerModel *m_sourceModel;
|
||||
LtsSession::LtsSession *m_session;
|
||||
LtsUtils::RequestHelper *m_requestHelper;
|
||||
Ui::ChargeAdministrationList *m_ui;
|
||||
LOGGER_T m_logger;
|
||||
};
|
||||
}
|
||||
Executable
+270
@@ -0,0 +1,270 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* AreaEffectManangement - Adler Charge Administration Overview Dialog Model
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Astrid Müller, ESZE, 2025-12-19
|
||||
*/
|
||||
|
||||
#include "aes_charge_administration_adler_model.h"
|
||||
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <LtsUtilsCore/json_object.h>
|
||||
#include <ngltools/ngltools_dtg.h>
|
||||
#include <ProjectDataManagement/pdm_translation.h>
|
||||
#include <LtsUtilsSettings/settings.h>
|
||||
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
//
|
||||
// ChargeAdministrationAdlerSortFilterProxyModel
|
||||
//
|
||||
void ChargeAdministrationAdlerSortFilterProxyModel::setSourceModel(QAbstractItemModel *model)
|
||||
{
|
||||
m_sourceModel = qobject_cast<ChargeAdministrationAdlerModel*>(model);
|
||||
LtsWidgets::LtsColumnFilterProxyModel::setSourceModel(model);
|
||||
}
|
||||
|
||||
bool ChargeAdministrationAdlerSortFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
|
||||
{
|
||||
if (!m_sourceModel || source_parent.isValid() || source_row < 0 || source_row >= m_sourceModel->rowCount())
|
||||
return LtsWidgets::LtsColumnFilterProxyModel::filterAcceptsRow(source_row, source_parent);
|
||||
|
||||
const ChargeAdministrationAdler &item = m_sourceModel->m_vecData.at(source_row);
|
||||
if (item.partyId != m_party)
|
||||
return false;
|
||||
return LtsWidgets::LtsColumnFilterProxyModel::filterAcceptsRow(source_row, source_parent);
|
||||
}
|
||||
|
||||
int ChargeAdministrationAdlerSortFilterProxyModel::party() const
|
||||
{
|
||||
return m_party;
|
||||
}
|
||||
|
||||
void ChargeAdministrationAdlerSortFilterProxyModel::setParty(int party)
|
||||
{
|
||||
m_party = party;
|
||||
invalidateFilter();
|
||||
}
|
||||
|
||||
//
|
||||
// ChargeAdministrationAdlerModel
|
||||
//
|
||||
ChargeAdministrationAdlerModel::ChargeAdministrationAdlerModel(QObject *parent)
|
||||
: LtsWidgets::LtsAbstractTableModel<ChargeAdministrationAdler>({tr("Id"),
|
||||
tr("Charge Type Id"),
|
||||
tr("Changed"),
|
||||
tr("Charge Type Name"),
|
||||
tr("Total Stock"),
|
||||
tr("Gear Class")},
|
||||
parent)
|
||||
, m_logger(getLogger("ChargeAdministration"))
|
||||
{}
|
||||
|
||||
bool ChargeAdministrationAdlerModel::initModel(LtsSession::LtsSession *session)
|
||||
{
|
||||
if (!session->getDtc<ProjectDataManagement::DataInterface>(m_pdmDtc))
|
||||
return false;
|
||||
|
||||
if (!session->getDtc<ParticipantManagement::DataInterface>(m_ppmDtc))
|
||||
return false;
|
||||
|
||||
m_DynamicParticipantDataMap = m_ppmDtc->dynamicParticipantDatas();
|
||||
QMapIterator<qint32, ParticipantManagement::DynamicParticipantData> iter(m_DynamicParticipantDataMap);
|
||||
while(iter.hasNext())
|
||||
{
|
||||
iter.next();
|
||||
updateParticipantChargeTypeMap(iter.value());
|
||||
}
|
||||
|
||||
QMap<qint32, ParticipantManagement::Party> parties;
|
||||
if (!m_ppmDtc->visibleParties(parties, LtsSessionData::LtsSessionData::getInstance()->getVisibleParties(session->exerciseId())))
|
||||
{
|
||||
DEBUG_LOG (m_logger) << "Could not retrieve visible Parties!";
|
||||
return false;
|
||||
}
|
||||
|
||||
// fill tableView;
|
||||
for (const ParticipantManagement::Party &p : qAsConst(parties))
|
||||
{
|
||||
updateItem(p.id());
|
||||
}
|
||||
|
||||
connect (m_ppmDtc.get(), &ParticipantManagement::Interface::Dtc::dynamicParticipantDataChanged,
|
||||
this, &ChargeAdministrationAdlerModel::onStateChanged);
|
||||
connect (m_ppmDtc.get(), &ParticipantManagement::Interface::Dtc::participantChanged,
|
||||
this, &ChargeAdministrationAdlerModel::onParticipantChanged);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ChargeAdministrationAdlerModel::onStateChanged(const ParticipantManagement::DynamicParticipantData &data, DataModification modType)
|
||||
{
|
||||
switch (modType)
|
||||
{
|
||||
case DataModification::eAdded:
|
||||
case DataModification::eModified:
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "+++++++++ DataModification --> " << modType;
|
||||
updateParticipantChargeTypeMap(data);
|
||||
// TableView update
|
||||
updateItem(m_ppmDtc->participant(data.participantId()).partyId());
|
||||
break;
|
||||
}
|
||||
case DataModification::eRemoved:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ChargeAdministrationAdlerModel::onParticipantChanged(const ParticipantManagement::Participant &data,
|
||||
DataModification modType)
|
||||
{
|
||||
Q_UNUSED(modType)
|
||||
qint32 typeId = data.typeId();
|
||||
qint32 participantId = data.id();
|
||||
|
||||
// Only inactive participants are of interest (isDeleted() == true)
|
||||
if (!data.isDeleted() || (!m_ppmDtc->isAdlerType(typeId) &&
|
||||
(m_ppmDtc->type(typeId).typeClass().underlying() != ParticipantManagement::TypeClass::Unit)))
|
||||
return;
|
||||
|
||||
if (m_participantChargeTypeMap.contains(participantId))
|
||||
{
|
||||
// remove chargeType from tableView
|
||||
QList<qint32> keys = m_participantChargeTypeMap.value(participantId).chargeTypeTotalStockMap.keys();
|
||||
for ( int key : keys)
|
||||
{
|
||||
int row = findRowForChargeTypeId(key, m_participantChargeTypeMap.value(participantId).partyId);
|
||||
if (row != -1)
|
||||
removeRow(row);
|
||||
}
|
||||
// remove Participant from Map
|
||||
m_participantChargeTypeMap.remove(participantId);
|
||||
}
|
||||
|
||||
// update tableView
|
||||
updateItem(data.partyId());
|
||||
}
|
||||
|
||||
void ChargeAdministrationAdlerModel::updateParticipantChargeTypeMap(const ParticipantManagement::DynamicParticipantData &data)
|
||||
{
|
||||
qint32 participantId = data.participantId();
|
||||
qint64 sampleTime = data.sampleTime();
|
||||
qint32 typeId = m_ppmDtc->participant(participantId).typeId();
|
||||
bool isDeleted = m_ppmDtc->participant(participantId).isDeleted();
|
||||
|
||||
if (isDeleted || (!m_ppmDtc->isAdlerType(typeId) &&
|
||||
(m_ppmDtc->type(typeId).typeClass().underlying() != ParticipantManagement::TypeClass::Unit)))
|
||||
return;
|
||||
|
||||
QMap<qint32, GearData> chargeTypeGearData;
|
||||
for (const ParticipantManagement::GearInformation &ct : data.gear())
|
||||
{
|
||||
if (m_pdmDtc->adlerChargeTypeName(ct.chargeTypeId()).isEmpty())
|
||||
continue;
|
||||
|
||||
GearData gearData;
|
||||
gearData.remain = ct.remain();
|
||||
gearData.lastUpdate = ct.lastUpdate();
|
||||
if (chargeTypeGearData.contains(ct.chargeTypeId()))
|
||||
{
|
||||
gearData.remain += chargeTypeGearData.value(ct.chargeTypeId()).remain;
|
||||
}
|
||||
chargeTypeGearData.insert(ct.chargeTypeId(), gearData);
|
||||
}
|
||||
m_participantChargeTypeMap.insert(participantId,
|
||||
ChargeStruct(participantId, m_ppmDtc->participant(participantId).partyId(),
|
||||
sampleTime, chargeTypeGearData));
|
||||
}
|
||||
|
||||
void ChargeAdministrationAdlerModel::updateItem(int partyId)
|
||||
{
|
||||
QMap<qint32, GearData> chargeTypeGearData;
|
||||
qint64 sampleTime=0;
|
||||
ChargeAdministrationAdler item;
|
||||
|
||||
for (const ChargeStruct &participantCharges : qAsConst(m_participantChargeTypeMap))
|
||||
{
|
||||
if (participantCharges.partyId != partyId)
|
||||
continue;
|
||||
DEBUG_LOG(m_logger) << "+++++++++ ParticipantId -> " << participantCharges.participantId << ", sampleTime ->" << sampleTime;
|
||||
for (auto it = participantCharges.chargeTypeTotalStockMap.cbegin(), end = participantCharges.chargeTypeTotalStockMap.cend(); it != end; ++it)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "+++++++++ chargeRemain ->" << it.key() << ": " << it.value().remain
|
||||
<< it.value().lastUpdate;
|
||||
GearData data;
|
||||
data.lastUpdate = it.value().lastUpdate;
|
||||
data.remain = it.value().remain;
|
||||
if (chargeTypeGearData.contains(it.key()))
|
||||
{
|
||||
data.remain += chargeTypeGearData.value(it.key()).remain;
|
||||
}
|
||||
if (chargeTypeGearData.contains(it.key()))
|
||||
if (chargeTypeGearData.value(it.key()).lastUpdate > data.lastUpdate)
|
||||
data.lastUpdate = chargeTypeGearData.value(it.key()).lastUpdate;
|
||||
|
||||
chargeTypeGearData.insert(it.key(), data);
|
||||
}
|
||||
}
|
||||
|
||||
item.partyId = partyId;
|
||||
for (auto gearData = chargeTypeGearData.cbegin(), end = chargeTypeGearData.cend(); gearData != end; ++gearData)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "### PartyId " << item.partyId << " insert item -> chargeTypeId: " << gearData.key() << ", amount: " << gearData.value().remain
|
||||
<< ", lastUpdate:" << gearData.value().lastUpdate;
|
||||
|
||||
item.chargeTypeId = gearData.key();
|
||||
item.sampleTime = gearData.value().lastUpdate;
|
||||
item.amount = gearData.value().remain;
|
||||
int row = findRowForChargeTypeId(item.chargeTypeId, item.partyId);
|
||||
if (row < 0)
|
||||
insertRow(item);
|
||||
else
|
||||
setRowData(row, item);
|
||||
}
|
||||
}
|
||||
|
||||
int ChargeAdministrationAdlerModel::findRowForChargeTypeId(qint32 typeId, qint32 partyId) const
|
||||
{
|
||||
for (int i = 0; i < m_vecData.size(); ++i)
|
||||
{
|
||||
if (m_vecData.at(i).chargeTypeId == typeId && m_vecData.at(i).partyId == partyId)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
QVariant ChargeAdministrationAdlerModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (role != Qt::DisplayRole || !indexIsValid(index))
|
||||
return QVariant();
|
||||
|
||||
const ChargeAdministrationAdler &item = m_vecData.at(index.row());
|
||||
|
||||
switch (index.column())
|
||||
{
|
||||
case ColId:
|
||||
return item.id;
|
||||
case ColTypeId:
|
||||
return item.chargeTypeId;
|
||||
case ColChanged:
|
||||
return QDateTime::fromMSecsSinceEpoch(item.sampleTime);
|
||||
case ColTypeName:
|
||||
return m_pdmDtc->trChargeTypeShortName(item.chargeTypeId, true);
|
||||
case ColStock:
|
||||
return item.amount;
|
||||
case ColGearClass:
|
||||
return ProjectDataManagement::toString(m_pdmDtc->gearClassFromChargeTypeId(item.chargeTypeId));
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
} // namespace AreaEffectSimulation
|
||||
Executable
+115
@@ -0,0 +1,115 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* AreaEffectManangement - Adler Charge Administration Overview Dialog Model
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Astrid Müller, ESZE, 2025-12-19
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
#include <LtsWidgets/lts_column_filter_proxy_model.h>
|
||||
#include <AreaEffectSimulation/aes_dtc.h>
|
||||
#include <AreaEffectSimulation/logger.h>
|
||||
#include <ProjectDataManagement/pdm.hpp>
|
||||
#include <Plugins/ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
|
||||
namespace LtsSession
|
||||
{
|
||||
class LtsSession;
|
||||
}
|
||||
|
||||
namespace ProjectDataManagement {
|
||||
namespace Interface {
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
struct ChargeAdministrationAdler
|
||||
{
|
||||
qint32 id;
|
||||
qint32 chargeTypeId;
|
||||
qint32 partyId;
|
||||
qint32 amount;
|
||||
qint64 sampleTime;
|
||||
};
|
||||
|
||||
class ChargeAdministrationAdlerModel : public LtsWidgets::LtsAbstractTableModel<ChargeAdministrationAdler>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum Columns
|
||||
{
|
||||
ColId,
|
||||
ColTypeId,
|
||||
ColChanged,
|
||||
ColTypeName,
|
||||
ColStock,
|
||||
ColGearClass
|
||||
};
|
||||
|
||||
explicit ChargeAdministrationAdlerModel(QObject *parent = nullptr);
|
||||
|
||||
bool initModel(LtsSession::LtsSession *session);
|
||||
QVariant data(const QModelIndex &, int role = Qt::DisplayRole) const override final;
|
||||
|
||||
private slots:
|
||||
void onStateChanged(const ParticipantManagement::DynamicParticipantData &data, DataModification modType);
|
||||
void onParticipantChanged(const ParticipantManagement::Participant &data, DataModification modType);
|
||||
|
||||
private:
|
||||
struct GearData {
|
||||
qint32 remain;
|
||||
qint64 lastUpdate;
|
||||
};
|
||||
struct ChargeStruct
|
||||
{
|
||||
qint32 participantId;
|
||||
qint32 partyId;
|
||||
qint64 sampleTime;
|
||||
QMap<qint32, GearData> chargeTypeTotalStockMap; // QMap<chargeTypeId, GearData>
|
||||
ChargeStruct() {};
|
||||
ChargeStruct(qint32 _participantId, qint32 _partyId, qint64 _sampleTime, QMap<qint32, GearData> _chargeTypeTotalStock)
|
||||
: participantId(_participantId), partyId(_partyId), sampleTime(_sampleTime), chargeTypeTotalStockMap(_chargeTypeTotalStock) {}
|
||||
};
|
||||
|
||||
void updateParticipantChargeTypeMap(const ParticipantManagement::DynamicParticipantData &data);
|
||||
void updateItem(int partyId);
|
||||
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
std::shared_ptr<ProjectDataManagement::Interface::Dtc> m_pdmDtc;
|
||||
QMap<qint32, ParticipantManagement::DynamicParticipantData> m_DynamicParticipantDataMap;
|
||||
QMap<qint32, ChargeStruct> m_participantChargeTypeMap;
|
||||
LOGGER_T m_logger;
|
||||
|
||||
friend class ChargeAdministrationAdlerSortFilterProxyModel;
|
||||
int findRowForChargeTypeId(qint32 typeId, qint32 partyId) const;
|
||||
};
|
||||
|
||||
class ChargeAdministrationAdlerSortFilterProxyModel final : public LtsWidgets::LtsColumnFilterProxyModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
using LtsWidgets::LtsColumnFilterProxyModel::LtsColumnFilterProxyModel;
|
||||
|
||||
void setSourceModel(QAbstractItemModel *model) override;
|
||||
int party() const;
|
||||
|
||||
public slots:
|
||||
void setParty(int party);
|
||||
|
||||
protected:
|
||||
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;
|
||||
|
||||
private:
|
||||
ChargeAdministrationAdlerModel *m_sourceModel = nullptr;
|
||||
int m_party = 0;
|
||||
};
|
||||
|
||||
} //namespace AreaEffectSimulation
|
||||
Executable
+74
@@ -0,0 +1,74 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* GUI Plugin for AreaEffectSimulation - NContaminations
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-07-07
|
||||
*/
|
||||
|
||||
#include "aes_charge_administration_gui_plugin.h"
|
||||
#include "aes_charge_administration_list.h"
|
||||
#include "aes_charge_administration_adler_list.h"
|
||||
|
||||
#include <AreaEffectSimulation/aes_operator_rights.h>
|
||||
#include <LtsUtilsSettings/settings.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
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.ChargeAdministration"))
|
||||
{}
|
||||
|
||||
QVector<LtsWidgets::PluginData> InterfaceImpl::getActions()
|
||||
{
|
||||
QVector<LtsWidgets::PluginData> ret;
|
||||
|
||||
LtsUtils::ProjectSettings *ps = LtsUtils::ProjectSettings::getInstance();
|
||||
const bool enableChargeAdministration = ps->value(QStringLiteral("aes"),
|
||||
QStringLiteral("enableChargeAdministration")).toBool();
|
||||
|
||||
if (enableChargeAdministration && m_session->app() != LtsAppDescriptor::App::OC)
|
||||
{
|
||||
// Charge Administration
|
||||
ret.append(LtsWidgets::PluginData(menuGroup(),
|
||||
tr("Charge Administration"),
|
||||
QLatin1String("aesShowChargeAdministration"),
|
||||
QIcon(QLatin1String("icon:mortar_ammunition_administration.svg")),
|
||||
[this](QWidget *parent) { return onShowChargeAdministrationListDialog(parent);},
|
||||
OperatorRights::ChargeAdministrationShow,
|
||||
LtsWidgets::ExercisePart::eExecution));
|
||||
// Charge Administration Adler
|
||||
ret.append(LtsWidgets::PluginData(menuGroup(),
|
||||
tr("Charge Administration Adler"),
|
||||
QLatin1String("aesShowChargeAdministrationAdler"),
|
||||
QIcon(QLatin1String("icon:mortar_ammunition_administration.svg")),
|
||||
[this](QWidget *parent) { return onShowChargeAdministrationAdlerListDialog(parent);},
|
||||
OperatorRights::ChargeAdministrationShow,
|
||||
LtsWidgets::ExercisePart::eExecution));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
LtsWidgets::LtsDialog *InterfaceImpl::onShowChargeAdministrationListDialog(QWidget *parent)
|
||||
{
|
||||
ChargeAdministrationList *dialog = new ChargeAdministrationList(parent);
|
||||
dialog->init(m_session);
|
||||
return dialog;
|
||||
}
|
||||
|
||||
LtsWidgets::LtsDialog *InterfaceImpl::onShowChargeAdministrationAdlerListDialog(QWidget *parent)
|
||||
{
|
||||
ChargeAdministrationAdlerList *dialog = new ChargeAdministrationAdlerList(parent);
|
||||
dialog->init(m_session);
|
||||
return dialog;
|
||||
}
|
||||
|
||||
} // namespace AreaEffectSimulation
|
||||
Executable
+49
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Gui Plugin for AreaEffectSimulation - NContamniations
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-07-07
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Plugins/AreaEffectSimulation/Gui/Base/aes_base_gui_plugin.h>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
class GuiPlugin final : public AesBaseGuiPlugin
|
||||
{
|
||||
Q_PLUGIN_METADATA(IID "gui:3:aes.chargeadministration")
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GuiPlugin() = default;
|
||||
~GuiPlugin() = default;
|
||||
|
||||
QString pluginName() override { return QStringLiteral("AreaEffectSimuationChargeAdministrationGui"); }
|
||||
std::shared_ptr<GuiPluginBase::Interface> createGuiInterface(LtsSession::LtsSession *session) override;
|
||||
bool availableInPartition(IDL::PartitionType partition) const override
|
||||
{
|
||||
return partition == IDL::PartitionType::Exercise;
|
||||
}
|
||||
};
|
||||
|
||||
class InterfaceImpl final : public AesBaseInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit InterfaceImpl(LtsSession::LtsSession *session);
|
||||
|
||||
QVector<LtsWidgets::PluginData> getActions() override;
|
||||
|
||||
private:
|
||||
LtsWidgets::LtsDialog *onShowChargeAdministrationListDialog(QWidget *parent);
|
||||
LtsWidgets::LtsDialog *onShowChargeAdministrationAdlerListDialog(QWidget *parent);
|
||||
|
||||
};
|
||||
|
||||
} // namespace AreaEffectSimulation
|
||||
Executable
+194
@@ -0,0 +1,194 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* ContaminationManangement - NContamination Overview Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-07-07
|
||||
*/
|
||||
|
||||
#include "aes_charge_administration_list.h"
|
||||
#include "CustomView/aes_charge_administration.h"
|
||||
#include "aes_charge_administration_model.h"
|
||||
#include "aes_charge_edit.h"
|
||||
#include "ui_aes_charge_administration_list.h"
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsUtilsGuiDds/request_helper.h>
|
||||
#include <LtsWidgets/lts_combo_box.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
|
||||
#include <QInputDialog>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <Plugins/AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
#include <Plugins/ParticipantManagement/ppm_gui_combobox_plugin_interface.h>
|
||||
|
||||
#include <QTreeView>
|
||||
#include <LtsPrinting/printing.h>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
ChargeAdministrationList::ChargeAdministrationList(QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_model(nullptr)
|
||||
, m_sourceModel(nullptr)
|
||||
, m_session(nullptr)
|
||||
, m_ftc(nullptr)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_ui(new Ui::ChargeAdministrationList)
|
||||
, m_logger(getLogger("ChargeAdministrationList"))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
connect(m_ui->cbParty,
|
||||
static_cast<void (LtsWidgets::LtsComboBox::*)(int)>(&LtsWidgets::LtsComboBox::currentIndexChanged),
|
||||
this,
|
||||
&ChargeAdministrationList::onPartyChanged);
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Charge_Administration"));
|
||||
}
|
||||
|
||||
ChargeAdministrationList::~ChargeAdministrationList() { delete m_ui; }
|
||||
|
||||
void ChargeAdministrationList::retranslate() { translate(m_ui, tr("Charge Administration")); }
|
||||
|
||||
void ChargeAdministrationList::enaDisa()
|
||||
{
|
||||
LtsWidgets::ExerciseStates allowedStates = LtsWidgets::ExerciseState::eCreated | LtsWidgets::ExerciseState::eStarted | LtsWidgets::ExerciseState::ePaused;
|
||||
bool bIsAllowedInState = allowedStates.testFlag(m_session->exerciseState());
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, bIsAllowedInState && m_ui->widget->selectedRows().count() > 0);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, bIsAllowedInState && m_ui->widget->selectedRows().count() > 0);
|
||||
}
|
||||
|
||||
void ChargeAdministrationList::onPartyChanged() { m_model->setParty(m_ui->cbParty->currentData().toInt()); }
|
||||
|
||||
void ChargeAdministrationList::onChargeAdministrationModifyReply(const Core::FunctionReplyObject &replyObject) { m_requestHelper->requestReply(replyObject); }
|
||||
|
||||
void ChargeAdministrationList::tableColumnOrganiserSetting()
|
||||
{
|
||||
// LtsColumnOrganiser
|
||||
m_ui->widget->setColumnsOrganiserEnabled(identifier(), true);
|
||||
}
|
||||
|
||||
bool ChargeAdministrationList::init(LtsSession::LtsSession *session)
|
||||
{
|
||||
if (m_session)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "double init()!";
|
||||
return false;
|
||||
}
|
||||
m_session = session;
|
||||
|
||||
if (m_session->app() != LtsAppDescriptor::App::OC)
|
||||
{
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &ChargeAdministrationList::onEditCharge);
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalDoubleClicked, this, &ChargeAdministrationList::onEditCharge);
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalEnterPressed, this, &ChargeAdministrationList::onEditCharge);
|
||||
}
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &ChargeAdministrationList::onPrint);
|
||||
|
||||
// FIXME: keine ifcs ausserhalb des GUI Plugins holen ...
|
||||
// std::shared_ptr<ParticipantManagement::ForeignGuiComboboxInterface> ppmGuiCbxIfc;
|
||||
|
||||
if (!m_session->getFtc<AreaEffectSimulation::DataInterface>(m_ftc))
|
||||
return false;
|
||||
|
||||
std::shared_ptr<ParticipantManagement::ForeignGuiComboboxInterface> ppmGuiCbxIfc;
|
||||
if (!m_session->getForeignGuiInterface<ParticipantManagement::ForeignGuiComboboxInterface>(ppmGuiCbxIfc))
|
||||
return false;
|
||||
|
||||
m_sourceModel = new ChargeAdministrationModel(this);
|
||||
|
||||
QVector<ChargeAdministrationModifyRequest> reqs;
|
||||
if (!m_sourceModel->initModel(m_session, reqs))
|
||||
return false;
|
||||
|
||||
if (!reqs.isEmpty())
|
||||
{
|
||||
for (const ChargeAdministrationModifyRequest &req : qAsConst(reqs))
|
||||
{
|
||||
m_requestHelper->addRequest([this, req]() { return m_ftc->chargeAdministrationModifyRequest(req, this); });
|
||||
}
|
||||
m_requestHelper->startRequests();
|
||||
}
|
||||
|
||||
m_model = new ChargeAdministrationSortFilterProxyModel(this);
|
||||
m_model->setSourceModel(m_sourceModel);
|
||||
m_ui->widget->setModel(m_model, [this]() { return new CustomViewChargeAdministration(this); });
|
||||
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalSelectionChanged, this, &ChargeAdministrationList::enaDisa);
|
||||
|
||||
#ifndef LTS_DEBUG
|
||||
bool onlydebugMode = true;
|
||||
m_ui->widget->hideColumn(ChargeAdministrationModel::ColId, onlydebugMode);
|
||||
m_ui->widget->hideColumn(ChargeAdministrationModel::ColTypeId, onlydebugMode);
|
||||
m_ui->widget->hideColumn(ChargeAdministrationModel::ColChanged, onlydebugMode);
|
||||
#endif
|
||||
|
||||
// Todo: setColumnHidden(MineAreasModel::BcColumns::ColPlayer);
|
||||
|
||||
m_ui->widget->setSortIndicator(ChargeAdministrationModel::ColTypeName, Qt::AscendingOrder);
|
||||
|
||||
enaDisa();
|
||||
|
||||
ppmGuiCbxIfc->fillPartyComboBox(m_ui->cbParty);
|
||||
onPartyChanged();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ChargeAdministrationList::onPrint()
|
||||
{
|
||||
QString header;
|
||||
header += QStringLiteral("<p>");
|
||||
header += tr("Party: %1").arg(m_ui->cbParty->currentText());
|
||||
header += QStringLiteral("<br/>");
|
||||
header += QStringLiteral("</p>");
|
||||
|
||||
LtsPrinting::printView(m_session, this, m_ui->widget->treeView(), header);
|
||||
}
|
||||
|
||||
void ChargeAdministrationList::onEditCharge()
|
||||
{
|
||||
ChargeAdministration item = m_sourceModel->getRowData(m_ui->widget->currentIndex().row());
|
||||
|
||||
if (item.id() < 0)
|
||||
return;
|
||||
|
||||
ProjectDataManagement::ChargeType ct = m_sourceModel->chargeType(item.chargeTypeId());
|
||||
|
||||
const QModelIndex temp = m_ui->widget->currentIndex();
|
||||
|
||||
const QModelIndex mi = temp.sibling(temp.row(), ChargeAdministrationModel::ColTypeName);
|
||||
auto ce = new ChargeEdit(ct.id(), m_sourceModel->data(mi).toString(), item.amount(), this);
|
||||
connect(ce, &ChargeEdit::newStock, this, &ChargeAdministrationList::onChargeEditFinished);
|
||||
connect(ce, &ChargeEdit::newStock, ce, &ChargeEdit::deleteLater);
|
||||
ce->show();
|
||||
}
|
||||
|
||||
void ChargeAdministrationList::onChargeEditFinished(int chargeId, int newStock)
|
||||
{
|
||||
ChargeAdministration item = m_sourceModel->getRowData(m_ui->widget->currentIndex().row());
|
||||
|
||||
if (item.chargeTypeId() != chargeId) // sanity
|
||||
return;
|
||||
|
||||
if (item.amount() == newStock)
|
||||
return;
|
||||
item.amount(newStock);
|
||||
|
||||
bool amountChangedByOperator = true;
|
||||
const ChargeAdministrationModifyRequest req(item.id(),
|
||||
item.chargeTypeId(),
|
||||
item.partyId(),
|
||||
item.effectSourceId(),
|
||||
item.amount(),
|
||||
amountChangedByOperator); // relativeAmount
|
||||
|
||||
m_requestHelper->addRequest([this, req]() { return m_ftc->chargeAdministrationModifyRequest(req, this); });
|
||||
m_requestHelper->startRequests();
|
||||
}
|
||||
|
||||
} // namespace AreaEffectSimulation
|
||||
Executable
+66
@@ -0,0 +1,66 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* AreaEffectSimulation - Contamination Overview Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-07-07
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
|
||||
|
||||
#include <AreaEffectSimulation/aes_ftc.h>
|
||||
#include <AreaEffectSimulation/logger.h>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class ChargeAdministrationList;
|
||||
}
|
||||
|
||||
namespace LtsSession
|
||||
{
|
||||
class LtsSession;
|
||||
}
|
||||
namespace LtsUtils {
|
||||
class RequestHelper;
|
||||
}
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
class ChargeAdministrationModel;
|
||||
class ChargeAdministrationSortFilterProxyModel;
|
||||
|
||||
class ChargeAdministrationList final : public LtsWidgets::LtsDialog
|
||||
, protected AreaEffectSimulation::Interface::Ftc::ChargeAdministrationModifyReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ChargeAdministrationList(QWidget *parent = nullptr);
|
||||
~ChargeAdministrationList();
|
||||
|
||||
bool init(LtsSession::LtsSession *session);
|
||||
private slots:
|
||||
void onPrint();
|
||||
void onEditCharge();
|
||||
void enaDisa();
|
||||
void onPartyChanged();
|
||||
void onChargeEditFinished(int chargeId, int newStock);
|
||||
|
||||
private:
|
||||
void retranslate() override;
|
||||
void onChargeAdministrationModifyReply(const Core::FunctionReplyObject &replyObject) override;
|
||||
void tableColumnOrganiserSetting() override;
|
||||
ChargeAdministrationSortFilterProxyModel *m_model;
|
||||
ChargeAdministrationModel *m_sourceModel;
|
||||
LtsSession::LtsSession *m_session;
|
||||
std::shared_ptr<AreaEffectSimulation::Interface::Ftc> m_ftc;
|
||||
LtsUtils::RequestHelper *m_requestHelper;
|
||||
Ui::ChargeAdministrationList *m_ui;
|
||||
LOGGER_T m_logger;
|
||||
// QVector<LtsWidgets::ColumnOrganiserInfo> m_columnOrganiserInfo;
|
||||
QMap<int, int> m_columnVisualOrder; // key: logicalindex, value: visualIndex
|
||||
};
|
||||
}
|
||||
Executable
+63
@@ -0,0 +1,63 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ChargeAdministrationList</class>
|
||||
<widget class="QWidget" name="ChargeAdministrationList">
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Charge Administration List</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Party:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="LtsWidgets::LtsComboBox" name="cbParty">
|
||||
<property name="const" stdset="0">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>278</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="3">
|
||||
<widget class="LtsDataView::LtsDataView" name="widget">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LtsWidgets::LtsComboBox</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header>LtsWidgets/lts_combo_box.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>LtsDataView::LtsDataView</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>LtsDataView/lts_data_view.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Executable
+179
@@ -0,0 +1,179 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* AreaEffectManangement - N Contamination Overview Dialog Model
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Malte Diers, SLSE, 2017-02-21
|
||||
*/
|
||||
|
||||
#include "aes_charge_administration_model.h"
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <LtsUtilsCore/json_object.h>
|
||||
#include <LtsUtilsSettings/settings.h>
|
||||
#include <Plugins/AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
#include <Plugins/ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
|
||||
#include <ProjectDataManagement/pdm_translation.h>
|
||||
#include <ngltools/ngltools_dtg.h>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
//
|
||||
// ChargeAdministrationSortFilterProxyModel
|
||||
//
|
||||
|
||||
void ChargeAdministrationSortFilterProxyModel::setSourceModel(QAbstractItemModel *model)
|
||||
{
|
||||
m_sourceModel = qobject_cast<ChargeAdministrationModel *>(model);
|
||||
LtsWidgets::LtsColumnFilterProxyModel::setSourceModel(model);
|
||||
}
|
||||
|
||||
bool ChargeAdministrationSortFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
|
||||
{
|
||||
if (!m_sourceModel || source_parent.isValid() || source_row < 0 || source_row >= m_sourceModel->rowCount())
|
||||
return LtsWidgets::LtsColumnFilterProxyModel::filterAcceptsRow(source_row, source_parent);
|
||||
|
||||
const ChargeAdministration &item = m_sourceModel->m_vecData.at(source_row);
|
||||
if (item.partyId() != m_party)
|
||||
return false;
|
||||
return LtsWidgets::LtsColumnFilterProxyModel::filterAcceptsRow(source_row, source_parent);
|
||||
}
|
||||
|
||||
int ChargeAdministrationSortFilterProxyModel::party() const { return m_party; }
|
||||
|
||||
void ChargeAdministrationSortFilterProxyModel::setParty(int party)
|
||||
{
|
||||
m_party = party;
|
||||
invalidateFilter();
|
||||
}
|
||||
|
||||
//
|
||||
// ChargeAdministrationModel
|
||||
//
|
||||
ChargeAdministrationModel::ChargeAdministrationModel(QObject *parent)
|
||||
: LtsWidgets::LtsAbstractTableModel<ChargeAdministration>({tr("Id"),
|
||||
tr("Charge Type Id"),
|
||||
tr("Changed"),
|
||||
tr("Charge Type Name"),
|
||||
tr("Total Stock"),
|
||||
tr("Planned"),
|
||||
tr("Available"),
|
||||
tr("Used"),
|
||||
tr("Gear Class")},
|
||||
parent)
|
||||
, m_logger(getLogger("ChargeAdministration"))
|
||||
{
|
||||
}
|
||||
|
||||
bool ChargeAdministrationModel::initModel(LtsSession::LtsSession *session, QVector<ChargeAdministrationModifyRequest> &reqs)
|
||||
{
|
||||
if (m_aesDtc)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "double init()!";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!session->getDtc<AreaEffectSimulation::DataInterface>(m_aesDtc))
|
||||
return false;
|
||||
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> ppmDtc;
|
||||
|
||||
if (!session->getDtc<ProjectDataManagement::DataInterface>(m_pdmDtc))
|
||||
return false;
|
||||
|
||||
if (!session->getDtc<ParticipantManagement::DataInterface>(ppmDtc))
|
||||
return false;
|
||||
|
||||
m_chargeTypeMap = m_pdmDtc->chargeTypes();
|
||||
|
||||
connect(m_aesDtc.get(), &Interface::Dtc::chargeAdministrationChanged, this, &ChargeAdministrationModel::onChargeAdministrationChanged);
|
||||
|
||||
QVector<QPair<int, int>> chargesInserted;
|
||||
auto cb = [this, &chargesInserted](const ChargeAdministration &item)
|
||||
{
|
||||
// skip ADLER charges
|
||||
const int chargeTypeId = item.chargeTypeId();
|
||||
if (m_pdmDtc->isAdlerChargeType(chargeTypeId))
|
||||
return;
|
||||
|
||||
insertRow(item);
|
||||
chargesInserted.append(qMakePair<int, int>(item.chargeTypeId(), item.partyId()));
|
||||
};
|
||||
m_aesDtc->chargeAdministrations(cb);
|
||||
|
||||
QMap<qint32, ParticipantManagement::Party> parties;
|
||||
if (!ppmDtc->visibleParties(parties, LtsSessionData::LtsSessionData::getInstance()->getVisibleParties(session->exerciseId())))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not retrieve visible Parties!";
|
||||
return false;
|
||||
}
|
||||
|
||||
QVector<ProjectDataManagement::ChargeType> chargesForGearClass
|
||||
= m_pdmDtc->chargesForGearClass(ProjectDataManagement::GearClass_def::Artillery) + m_pdmDtc->chargesForGearClass(ProjectDataManagement::GearClass_def::Mortar);
|
||||
|
||||
LtsUtils::ProjectSettings *ps = LtsUtils::ProjectSettings::getInstance();
|
||||
const bool enableRocket = ps->value(QStringLiteral("aes"), QStringLiteral("enableRocket"), false).toBool();
|
||||
if (enableRocket)
|
||||
chargesForGearClass += m_pdmDtc->chargesForGearClass(ProjectDataManagement::GearClass_def::Rocket);
|
||||
for (const ParticipantManagement::Party &p : qAsConst(parties))
|
||||
{
|
||||
for (const ProjectDataManagement::ChargeType &ct : qAsConst(chargesForGearClass))
|
||||
{
|
||||
if (chargesInserted.contains(qMakePair(ct.id(), p.id())) || isDummy(ct) || m_pdmDtc->isAdlerChargeType(ct.id()))
|
||||
continue;
|
||||
|
||||
reqs << ChargeAdministrationModifyRequest(0, ct.id(), p.id(), ProjectDataManagement::EffectSource::ES_Internal, 0, true); // amountChangedByOperator=true
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChargeAdministrationModel::isDummy(const ProjectDataManagement::ChargeType &ct)
|
||||
{
|
||||
return LtsUtils::JsonObject::fromJson(ct.properties()).valueOr<bool>("isDummy", false);
|
||||
}
|
||||
|
||||
QVariant ChargeAdministrationModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (role != Qt::DisplayRole || !indexIsValid(index))
|
||||
return QVariant();
|
||||
|
||||
const ChargeAdministration &item = m_vecData.at(index.row());
|
||||
|
||||
switch (index.column())
|
||||
{
|
||||
case ColId:
|
||||
return item.id();
|
||||
case ColTypeId:
|
||||
return item.chargeTypeId();
|
||||
case ColChanged:
|
||||
return QDateTime::fromMSecsSinceEpoch(item.sampleTime());
|
||||
case ColTypeName:
|
||||
return m_pdmDtc->trChargeTypeShortName(item.chargeTypeId(), true);
|
||||
case ColStock:
|
||||
return item.amount();
|
||||
case ColAvailable:
|
||||
return item.amount() - item.planned();
|
||||
case ColPlanned:
|
||||
return item.planned();
|
||||
case ColUsed:
|
||||
return item.used();
|
||||
case ColGearClass:
|
||||
return ProjectDataManagement::toString(m_pdmDtc->gearClassFromChargeTypeId(item.chargeTypeId()));
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
void ChargeAdministrationModel::onChargeAdministrationChanged(const ChargeAdministration &data, DataModification modType)
|
||||
{
|
||||
// skip ADLER charges
|
||||
if (m_pdmDtc->isAdlerChargeType(data.chargeTypeId()))
|
||||
return;
|
||||
onDataChanged(data, modType);
|
||||
}
|
||||
|
||||
} // namespace AreaEffectSimulation
|
||||
Executable
+94
@@ -0,0 +1,94 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for AreaEffectSimulation - Contaminations Overview Dialog Model
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Malte Diers, SLSE, 2017-02-20
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
#include <LtsWidgets/lts_column_filter_proxy_model.h>
|
||||
#include <AreaEffectSimulation/aes_dtc.h>
|
||||
#include <AreaEffectSimulation/logger.h>
|
||||
#include <ProjectDataManagement/pdm.hpp>
|
||||
|
||||
namespace LtsSession
|
||||
{
|
||||
class LtsSession;
|
||||
}
|
||||
|
||||
namespace ProjectDataManagement {
|
||||
namespace Interface {
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
class ChargeAdministrationModel : public LtsWidgets::LtsAbstractTableModel<ChargeAdministration>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum Columns
|
||||
{
|
||||
ColId,
|
||||
ColTypeId,
|
||||
ColChanged,
|
||||
ColTypeName,
|
||||
ColStock,
|
||||
ColPlanned,
|
||||
ColAvailable,
|
||||
ColUsed,
|
||||
ColGearClass
|
||||
};
|
||||
|
||||
explicit ChargeAdministrationModel(QObject *parent = nullptr);
|
||||
|
||||
bool initModel(LtsSession::LtsSession *session, QVector<ChargeAdministrationModifyRequest> &reqs);
|
||||
QVariant data(const QModelIndex &, int role = Qt::DisplayRole) const override final;
|
||||
|
||||
ProjectDataManagement::ChargeType chargeType(int id) const { return m_chargeTypeMap.value(id); }
|
||||
|
||||
private slots:
|
||||
void onChargeAdministrationChanged(const AreaEffectSimulation::ChargeAdministration &data, DataModification modType);
|
||||
|
||||
private:
|
||||
bool isDummy(const ProjectDataManagement::ChargeType &ct);
|
||||
|
||||
private:
|
||||
std::shared_ptr<AreaEffectSimulation::Interface::Dtc> m_aesDtc;
|
||||
std::shared_ptr<ProjectDataManagement::Interface::Dtc> m_pdmDtc;
|
||||
QMap<qint32, ProjectDataManagement::ChargeType> m_chargeTypeMap;
|
||||
LOGGER_T m_logger;
|
||||
|
||||
friend class ChargeAdministrationSortFilterProxyModel;
|
||||
};
|
||||
|
||||
class ChargeAdministrationSortFilterProxyModel final : public LtsWidgets::LtsColumnFilterProxyModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
using LtsWidgets::LtsColumnFilterProxyModel::LtsColumnFilterProxyModel;
|
||||
|
||||
void setSourceModel(QAbstractItemModel *model) override;
|
||||
int party() const;
|
||||
|
||||
public slots:
|
||||
void setParty(int party);
|
||||
|
||||
protected:
|
||||
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;
|
||||
|
||||
private:
|
||||
ChargeAdministrationModel *m_sourceModel = nullptr;
|
||||
int m_party = 0;
|
||||
};
|
||||
|
||||
|
||||
} //namespace AreaEffectSimulation
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* ContaminationManangement - ChargeEdit Dlg
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2019-05-17
|
||||
*/
|
||||
|
||||
#include "aes_charge_edit.h"
|
||||
#include "ui_aes_charge_edit.h"
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
ChargeEdit::ChargeEdit(int chargeId, const QString &charge, int oldStock, QWidget *parent)
|
||||
: LtsWidgets::LtsFramelessDialog(parent, LtsWidgets::Behaviour::Modal)
|
||||
, m_chargeId(chargeId)
|
||||
, m_oldStock(oldStock)
|
||||
, m_buttonBox(new LtsWidgets::LtsDialogButtonBox(this))
|
||||
, m_ui(new Ui::ChargeEdit)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_ui->verticalLayout->addWidget(m_buttonBox);
|
||||
|
||||
connect(m_buttonBox->getButton(LtsWidgets::DialogButton::Close), &QPushButton::clicked,
|
||||
this, &ChargeEdit::onSendStock);
|
||||
connect(m_buttonBox->getButton(LtsWidgets::DialogButton::Ok), &QPushButton::clicked,
|
||||
this, &ChargeEdit::onSendStock);
|
||||
m_ui->spStock->setValue(oldStock);
|
||||
m_ui->lblCharge->setText(charge);
|
||||
}
|
||||
|
||||
ChargeEdit::~ChargeEdit()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void ChargeEdit::onSendStock()
|
||||
{
|
||||
if (sender() == m_buttonBox->getButton(LtsWidgets::DialogButton::Close))
|
||||
emit newStock(m_chargeId, m_oldStock);
|
||||
else
|
||||
emit newStock(m_chargeId, m_ui->spStock->value());
|
||||
}
|
||||
|
||||
} // namespace AreaEffectSimulation
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* AreaEffectSimulation - ChargeEdit Dlg
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2019-05-17
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LtsWidgets/lts_frameless_dialog.h>
|
||||
#include <LtsWidgets/lts_dialog_button_box.h>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class ChargeEdit;
|
||||
}
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
class ChargeEdit : public LtsWidgets::LtsFramelessDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ChargeEdit(int chargeId, const QString &charge, int oldStock, QWidget *parent = nullptr);
|
||||
~ChargeEdit();
|
||||
|
||||
private slots:
|
||||
void onSendStock();
|
||||
|
||||
signals:
|
||||
void newStock(int chargeId, int newStock);
|
||||
private:
|
||||
int m_chargeId;
|
||||
int m_oldStock;
|
||||
LtsWidgets::LtsDialogButtonBox *m_buttonBox;
|
||||
Ui::ChargeEdit *m_ui;
|
||||
|
||||
};
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ChargeEdit</class>
|
||||
<widget class="QWidget" name="ChargeEdit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>193</width>
|
||||
<height>58</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Charge Administration List</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>New Stock for:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lblCharge">
|
||||
<property name="text">
|
||||
<string notr="true"><CHARGE></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spStock">
|
||||
<property name="maximum">
|
||||
<number>9999999</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,45 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
# Created by Malte Diers, SLSE, 2017-04-06
|
||||
#
|
||||
|
||||
ADD_INTERFACE_LIBRARY(
|
||||
AesChargeEffectGuiPluginInterface
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/aes_charge_effect_gui_plugin_interface.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/..
|
||||
)
|
||||
|
||||
SET(aes_charge_effect_gui_SRCS
|
||||
aes_charge_effect_gui_plugin.cpp
|
||||
aes_charge_effect_gui_plugin.h
|
||||
aes_charge_effect_edit.cpp
|
||||
aes_charge_effect_edit.h
|
||||
)
|
||||
|
||||
NGL_WRAP_UI(aes_charge_effect_gui_SRCS
|
||||
aes_charge_effect_edit.ui
|
||||
)
|
||||
|
||||
NGL_ADD_LIBRARY(WS AesChargeEffectGuiPlugin MODULE ${aes_charge_effect_gui_SRCS})
|
||||
NGL_TARGET_LINK_LIBRARIES(AesChargeEffectGuiPlugin
|
||||
AesBaseGui
|
||||
AesChargeEffectGuiPluginInterface
|
||||
ngltools
|
||||
NGLLogger
|
||||
LtsSessionData
|
||||
AesDataPluginInterface
|
||||
PpmGuiComboboxPluginInterface
|
||||
PpmDataPluginInterface
|
||||
PpmParticipantSelectionGui
|
||||
Qt5::Widgets
|
||||
LtsWidgets
|
||||
AsbDataPluginInterface
|
||||
advancedSymbologyGui
|
||||
LtsUtilsSettings
|
||||
)
|
||||
|
||||
NGL_INSTALL_TARGET(AesChargeEffectGuiPlugin)
|
||||
|
||||
|
||||
+312
@@ -0,0 +1,312 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* AreaEffectSimulation - Charge Effect Edit Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Astrid Müller, ESZE, 2025-08-19
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <LtsUtilsSettings/settings.h>
|
||||
#include <ParticipantManagement/ppm_translation.h>
|
||||
#include <Plugins/AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
#include <Plugins/SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
|
||||
#include <Plugins/ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
#include <Plugins/ParticipantManagement/Gui/ParticipantSelection/participant_selection.h>
|
||||
#include <Plugins/ParticipantManagement/Gui/Common/participant_edit_model.h>
|
||||
#include <AreaEffectSimulation/Utils/polygons.h>
|
||||
#include <AreaEffectSimulation/aes_translation.h>
|
||||
#include <SituationMap/Map/map.h>
|
||||
|
||||
|
||||
#include "aes_charge_effect_edit.h"
|
||||
#include "ui_aes_charge_effect_edit.h"
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
ChargeEffectEdit::ChargeEffectEdit(const QString &menuGroup, QWidget *parent)
|
||||
: BaseEdit(menuGroup, QLatin1String("ChargeEffectEdit"), parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_ui(new Ui::ChargeEffectEdit)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_ui->pbPosition->setEnabled(false);
|
||||
m_ui->lblFuze->setVisible(false);
|
||||
m_ui->cbFuze->setVisible(false);
|
||||
m_ui->lblWeapon->setVisible(false);
|
||||
m_ui->cbWeapon->setVisible(false);
|
||||
enaDisa();
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Add_Charge_Effect"));
|
||||
}
|
||||
|
||||
ChargeEffectEdit::~ChargeEffectEdit()
|
||||
{
|
||||
m_sitMapGuiIfc = nullptr;
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
bool ChargeEffectEdit::apply()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Apply";
|
||||
return true;
|
||||
}
|
||||
|
||||
void ChargeEffectEdit::showPreviewObject()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool ChargeEffectEdit::init(int areaId, bool copy,
|
||||
LtsSession::LtsSession *session)
|
||||
{
|
||||
Q_UNUSED(copy)
|
||||
|
||||
if (!BaseEdit::init(areaId, session)) //areaId is aesItemId
|
||||
return false;
|
||||
|
||||
if (!session->getForeignGuiInterface<SituationMap::ForeignGuiInterface>(m_sitMapGuiIfc))
|
||||
return false;
|
||||
|
||||
if (!session->getDtc<ParticipantManagement::DataInterface>(m_ppmDtc))
|
||||
return false;
|
||||
|
||||
// PDM
|
||||
if (!session->getDtc<ProjectDataManagement::DataInterface>(m_pdmDtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << " failed to get pdmDtc";
|
||||
return false;
|
||||
}
|
||||
m_pdmDtc->waitForHistoricalDataChargeType(1000);
|
||||
m_pdmDtc->waitForHistoricalDataGearType(1000);
|
||||
m_pdmDtc->waitForHistoricalDataGearTypeChargeType(1000);
|
||||
|
||||
connect(m_ui->cbPlayer, &QCheckBox::toggled, this, &ChargeEffectEdit::onChangeParty);
|
||||
|
||||
bool editable = LtsSessionData::LtsSessionData::getInstance()->hasOperatorRight(OperatorRights::ChargeEffectEdit) &&
|
||||
m_session->app() != LtsAppDescriptor::App::OC;
|
||||
|
||||
if (!editable)
|
||||
return false;
|
||||
|
||||
session->getForeignDataInterface<AdvancedSymbology::DataInterface>(m_asb);
|
||||
m_participantModel = new ParticipantManagement::ParticipantEditModel(this, m_ppmDtc, m_asb);
|
||||
m_participantModel->setUnitsSelectable(false);
|
||||
// only needed to set recursiveFilteringEnabled
|
||||
auto proxyModel = new ParticipantManagement::ParticipantTreeFilterProxyModel(this);
|
||||
proxyModel->setSourceModel(m_participantModel);
|
||||
proxyModel->setRecursiveFilteringEnabled(true);
|
||||
m_ui->dvParticipants->setModel(proxyModel);
|
||||
m_ui->dvParticipants->setToolButtonsVisible(false);
|
||||
#ifndef LTS_DEBUG
|
||||
m_ui->dvParticipants->hideColumn(ParticipantManagement::ParticipantEditModel::ColParticipantId);
|
||||
#endif
|
||||
m_ui->dvParticipants->setSortIndicator(0, Qt::AscendingOrder);
|
||||
|
||||
connect(m_ui->dvParticipants, &LtsDataView::LtsDataView::selectionChanged,
|
||||
this, &ChargeEffectEdit::onSelectionChanged);
|
||||
|
||||
connect(m_ui->cbParty,
|
||||
static_cast<void (LtsWidgets::LtsComboBox::*)(int)>(&LtsWidgets::LtsComboBox::currentIndexChanged),
|
||||
this, &ChargeEffectEdit::onChangeParty);
|
||||
|
||||
m_ppmGuiCbxIfc->fillPartyComboBox(m_ui->cbParty);
|
||||
onChangeParty();
|
||||
|
||||
fillCharges();
|
||||
if (m_ui->cbChargeType->count())
|
||||
m_ui->pbPosition->setEnabled(true);
|
||||
|
||||
// enableUiElements(editable && isModifiable() && !isOnlyNameModifiable());
|
||||
|
||||
m_ui->pbPosition->setIcon(QIcon(QStringLiteral("icon:position.svg")));
|
||||
|
||||
connect(m_ui->pbPosition, &QPushButton::toggled, this, &ChargeEffectEdit::onPositionButtonToggled);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ChargeEffectEdit::retranslate()
|
||||
{
|
||||
translate(m_ui, m_aesItem, tr("Charge Effect"));
|
||||
}
|
||||
|
||||
void ChargeEffectEdit::enableUiElements(bool enable)
|
||||
{
|
||||
Q_UNUSED(enable);
|
||||
}
|
||||
|
||||
void ChargeEffectEdit::onChangeParty()
|
||||
{
|
||||
if (m_ui->cbPlayer->isChecked())
|
||||
{
|
||||
m_ui->dvParticipants->setEnabled(true);
|
||||
m_participantModel->onReinitModel(m_ui->cbParty->currentData().toInt());
|
||||
m_ui->dvParticipants->expandAll();
|
||||
m_ui->pbPosition->setEnabled(false);
|
||||
cancelPositionTrigger();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ui->dvParticipants->setEnabled(false);
|
||||
m_participantModel->resetModel();
|
||||
if (m_ui->cbChargeType->count())
|
||||
m_ui->pbPosition->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
void ChargeEffectEdit::onSelectionChanged()
|
||||
{
|
||||
m_ui->pbPosition->setEnabled(false);
|
||||
|
||||
if (m_ui->dvParticipants->selectedRows().isEmpty())
|
||||
return;
|
||||
|
||||
const ParticipantManagement::ParticipantData data(m_participantModel->getParticipantData(m_ui->dvParticipants->selectedRows().first()));
|
||||
DEBUG_LOG(m_logger) << "ParticipantId: " << data.id();
|
||||
|
||||
if (m_ppmDtc->type(data.typeId()).typeClass() == ParticipantManagement::TypeClass_def::Unit)
|
||||
return;
|
||||
|
||||
DEBUG_LOG(m_logger) << "typeClass: " << m_ppmDtc->type(data.typeId()).typeClass()
|
||||
<< " eqNr.isSet(): " << data.equipmentNumber().is_set();
|
||||
|
||||
if (data.equipmentNumber().is_set())
|
||||
{
|
||||
if (m_ui->cbChargeType->count())
|
||||
m_ui->pbPosition->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
void ChargeEffectEdit::onPositionButtonToggled(bool isChecked)
|
||||
{
|
||||
if (isChecked)
|
||||
{
|
||||
m_ui->pbPosition->setStyleSheet(QStringLiteral("background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop: 0 rgb(254, 45, 102), stop: 1 rgb(255, 92, 61));"));
|
||||
getPosition();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ui->pbPosition->setStyleSheet(QStringLiteral(""));
|
||||
m_sitMapGuiIfc->cancelActiveRubberbands();
|
||||
}
|
||||
}
|
||||
|
||||
void ChargeEffectEdit::getPosition()
|
||||
{
|
||||
|
||||
if (!m_sitMapGuiIfc) //sanity
|
||||
return;
|
||||
|
||||
if (m_sitMapGuiIfc->mapMode() != SituationMap::MapMode::MapMode_2D)
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Only available in 2D mode"));
|
||||
return;
|
||||
}
|
||||
m_sitMapGuiIfc->getCoordinate(this, SLOT(onGetCoordinate(QPointF)), SLOT(onEscapePressed(QString)));
|
||||
}
|
||||
|
||||
void ChargeEffectEdit::onGetCoordinate(const QPointF &coordinate)
|
||||
{
|
||||
ParticipantManagement::ParticipantData participantData;
|
||||
const QModelIndexList indexList = m_ui->dvParticipants->selectedRows();
|
||||
int checked = m_ui->cbPlayer->isChecked();
|
||||
if (checked && indexList.size())
|
||||
participantData = m_participantModel->getParticipantData(indexList.first());
|
||||
|
||||
const int chargeTypeId = m_ui->cbChargeType->currentData().toInt();
|
||||
const int partyId = m_ui->cbParty->currentData().toInt();
|
||||
DEBUG_LOG(m_logger) << "ParticipantId=" << participantData.id()
|
||||
<< " EquipmentNr=" << participantData.equipmentNumber()
|
||||
<< " partyId=" << partyId
|
||||
<< " chargeType=" << chargeTypeId
|
||||
<< " onGetCoordinate x=" << coordinate.x() << " y=" << coordinate.y();
|
||||
|
||||
// Button zurücksetzen
|
||||
cancelPositionTrigger();
|
||||
int gearType = 0;
|
||||
for (const auto >c : m_pdmDtc->gearTypeChargeTypes())
|
||||
{
|
||||
if (gtc.chargeTypeId() == chargeTypeId)
|
||||
gearType = gtc.gearTypeId();
|
||||
}
|
||||
|
||||
const auto chargeType = m_pdmDtc->chargeType(chargeTypeId);
|
||||
|
||||
|
||||
|
||||
ChargeEffectModifyRequest request;
|
||||
int id;
|
||||
ProjectDataManagement::StateChangeOriginator originatorTypeId;
|
||||
if (m_ui->cbPlayer->isChecked())
|
||||
{
|
||||
id = participantData.id();
|
||||
originatorTypeId = ProjectDataManagement::StateChangeOriginator::Participant;
|
||||
}
|
||||
else
|
||||
{
|
||||
id = partyId;
|
||||
originatorTypeId = ProjectDataManagement::StateChangeOriginator::Party;
|
||||
}
|
||||
|
||||
|
||||
request.name(chargeType.shortName());
|
||||
request.chargeTypeId(chargeTypeId);
|
||||
request.igniterTypeId(0);//(m_pdmDtc->fuseTypes(chargeTypeId).first()); <-- check by inserting error
|
||||
request.gearTypeId(gearType);
|
||||
request.originatorId(id);
|
||||
request.originatorTypeId(originatorTypeId);
|
||||
request.effectDuration(1000);
|
||||
request.effectStart(m_session->partitionTime() + 6000);
|
||||
request.position(Core::GeoPosition(coordinate.x(), coordinate.y(), 0.0));
|
||||
|
||||
m_requestHelper->addRequest([this,request]()
|
||||
{
|
||||
return m_ftc->chargeEffectModifyRequest(request, this);
|
||||
});
|
||||
m_requestHelper->startRequests();
|
||||
}
|
||||
|
||||
void ChargeEffectEdit::onEscapePressed(const QString &value)
|
||||
{
|
||||
Q_UNUSED(value)
|
||||
DEBUG_LOG(m_logger) << "################## onEscapePressed";
|
||||
cancelPositionTrigger();
|
||||
}
|
||||
|
||||
void ChargeEffectEdit::fillCharges()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << " fillCharges";
|
||||
|
||||
m_ui->cbChargeType->clear();
|
||||
|
||||
if (!m_pdmDtc)
|
||||
{
|
||||
ERROR_LOG(m_logger) << " no m_pdmDtc";
|
||||
return;
|
||||
}
|
||||
|
||||
for (const auto &charge : m_pdmDtc->chargeTypes())
|
||||
{
|
||||
if(!m_pdmDtc->isVirtuallyFireable(charge.id()))
|
||||
continue;
|
||||
|
||||
m_ui->cbChargeType->addItem(QString::fromStdString(charge.name()), charge.id());
|
||||
}
|
||||
m_ui->cbChargeType->setEnabled(m_ui->cbChargeType->count() > 1);
|
||||
}
|
||||
|
||||
void ChargeEffectEdit::cancelPositionTrigger()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << " cancelPositionTrigger";
|
||||
m_ui->pbPosition->setChecked(false);
|
||||
onPositionButtonToggled(m_ui->pbPosition->isChecked());
|
||||
}
|
||||
|
||||
} // namespace AreaEffectSimulation
|
||||
Loaded 100 of 16245 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user