Initial commit

This commit is contained in:
torsten committed 2026-08-13 18:33:10 +02:00
commit b7d90b9afe
16245 files changed
+3396666

No files matched your search

@@ -0,0 +1,52 @@
#
# $Id$
# $HeadURL$
# $Author$
# Created by Malte Diers, SLSE, 2017-04-06
#
ADD_INTERFACE_LIBRARY(
AesFunctionalAreaGuiPluginInterface
${CMAKE_CURRENT_SOURCE_DIR}/aes_functional_area_gui_plugin_interface.h
${CMAKE_CURRENT_SOURCE_DIR}/..
)
SET(aes_functional_area_gui_SRCS
aes_functional_area_gui_plugin.cpp
aes_functional_area_gui_plugin.h
aes_functional_area_edit.cpp
aes_functional_area_edit.h
aes_functional_area_list.cpp
aes_functional_area_list.h
aes_functional_areas_model.cpp
aes_functional_areas_model.h
CustomView/aes_functional_area.cpp
CustomView/aes_functional_area.h
)
NGL_WRAP_UI(aes_functional_area_gui_SRCS
aes_functional_area_edit.ui
CustomView/aes_functional_area.ui
)
NGL_ADD_LIBRARY(WS AesFunctionalAreaGuiPlugin MODULE ${aes_functional_area_gui_SRCS})
NGL_TARGET_LINK_LIBRARIES(AesFunctionalAreaGuiPlugin
AesBaseGui
AesFunctionalAreaGuiPluginInterface
ngltools
NGLLogger
LtsSessionData
AesDataPluginInterface
PpmGuiComboboxPluginInterface
PpmDataPluginInterface
PpmParticipantSelectionGui
Qt5::Widgets
LtsWidgets
AsbDataPluginInterface
advancedSymbologyGui
LtsUtilsSettings
)
NGL_INSTALL_TARGET(AesFunctionalAreaGuiPlugin)
@@ -0,0 +1,87 @@
/**
* @RDE_HEADER@
* CustomView for Functional Area
* $Id$
* $HeadURL$
* $Author$
* Created by Malte Diers, SLSE, 2017-04-06
*/
#include "aes_functional_area.h"
#include "ui_aes_functional_area.h"
#include "aes_functional_areas_model.h"
#include <Services/AreaEffectSimulation/Utils/polygons.h>
#include <LtsUtilsSettings/settings.h>
namespace AreaEffectSimulation
{
CustomViewFunctionalArea::CustomViewFunctionalArea(QWidget *parent)
: AbstractDisplayWidget(parent)
, m_ui(new Ui::CustomViewFunctionalArea)
{
m_ui->setupUi(this);
}
CustomViewFunctionalArea::~CustomViewFunctionalArea()
{
delete m_ui;
}
bool CustomViewFunctionalArea::init(const QModelIndex &idx)
{
if (!idx.isValid())
return false;
m_ui->lbName->setText(rowData(idx, AreaEffectSimulation::FunctionalAreasModel::BcName).toString());
m_ui->lbType->setText(rowData(idx, AreaEffectSimulation::FunctionalAreasModel::ColType).toString());
const bool showPvSan = LtsUtils::ProjectSettings::isFunctionEnabled(QStringLiteral("ParticipantInformation"),
QStringLiteral("HasPvSan"));
if (!showPvSan)
m_ui->lbType->hide();
m_ui->lbState->setText(rowData(idx, AreaEffectSimulation::FunctionalAreasModel::BcEffectState).toString());
m_ui->lbTime->setText(rowData(idx, AreaEffectSimulation::FunctionalAreasModel::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 FunctionalAreasModel *aesModel = qobject_cast<const FunctionalAreasModel*>(sfpm->sourceModel());
if (!aesModel)
return false;
const auto srcIdx = sfpm->mapToSource(idx);
FunctionalArea funcArea = aesModel->getRowData(srcIdx.row());
calculateIcon(funcArea, sfpm->partyColor(idx.row()));
qint64 durationMSecs = rowData(idx, AreaEffectSimulation::FunctionalAreasModel::BcEffectDuration).toInt();
if (durationMSecs > 0)
{
m_ui->lbDuration->setText(QString::number(durationMSecs / (1000 * 60), 'f', 0));
}
else
{
m_ui->label_4->hide();
m_ui->lbDuration->hide();
m_ui->label_6->hide();
}
return true;
}
bool CustomViewFunctionalArea::calculateIcon(const FunctionalArea &funcArea, const QColor &color)
{
Database::AesFunctionalArea funcOut;
funcOut.width = funcArea.area().width();
funcOut.length = funcArea.area().height();
funcOut.position = QPointF(funcArea.area().cornerBottomLeft().lon(),
funcArea.area().cornerBottomLeft().lat());
QPolygonF poly = AreaEffectSimulation::Polygons::functionalArea(funcOut);
Qt::BrushStyle bStyle = PixmapLabel::checkForBrushStyle(funcArea.effectStateId());
const auto pix = Polygons::pixmapFromPolygon(PixmapLabel::geographic2Utm(poly), color, ICON_RESOLUTION, bStyle);
m_ui->lblIcon->setPixmap(pix);
return true;
}
} // namespace AreaEffectSimulation
@@ -0,0 +1,34 @@
/**
* @RDE_HEADER@
* CustomView for Functional Area
* $Id$
* $HeadURL$
* $Author$
* Created by Malte Diers, SLSE, 2017-04-06
*/
#pragma once
#include <Viewer/LtsDataView/abstract_display_widget.h>
namespace Ui
{
class CustomViewFunctionalArea;
}
namespace AreaEffectSimulation
{
class FunctionalArea;
class CustomViewFunctionalArea final : public LtsDataView::AbstractDisplayWidget
{
Q_OBJECT
public:
explicit CustomViewFunctionalArea(QWidget *parent = nullptr);
~CustomViewFunctionalArea();
bool init(const QModelIndex &idx) override final;
private:
bool calculateIcon(const AreaEffectSimulation::FunctionalArea &funcArea, const QColor &color);
Ui::CustomViewFunctionalArea *m_ui;
};
} // namespace AreaEffectSimulation
@@ -0,0 +1,173 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CustomViewFunctionalArea</class>
<widget class="QWidget" name="CustomViewFunctionalArea">
<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>
<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 notr="true"/>
</property>
<property name="text">
<string notr="true">State</string>
</property>
</widget>
</item>
</layout>
</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>
<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="text">
<string notr="true">Time</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_4">
<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>minutes</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>
@@ -0,0 +1,841 @@
/**
* @RDE_HEADER@
* AreaEffectSimulation - Functional Area Edit Dialog
* $Id$
* $HeadURL$
* $Author$
* Created by Malte Diers, SLSE, 2017-04-06
*/
#include "aes_functional_area_edit.h"
#include "ui_aes_functional_area_edit.h"
#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 "../AesInfo/aes_danger_area_aes_item_info.h"
#include <Plugins/ParticipantManagement/ppm_data_plugin_interface.h>
#include <Plugins/ParticipantManagement/Gui/ParticipantSelection/participant_selection.h>
#include <Symbology/sidc_codec.h>
#include <SymbologyGui/base_symbol_lookup_dialog.h>
#include <SymbologyGui/symbol_modification_dialog.h>
#include <AreaEffectSimulation/Utils/polygons.h>
#include <AreaEffectSimulation/aes_translation.h>
// #include <QDebug>
namespace AreaEffectSimulation
{
double FunctionalAreaEdit::s_minWidth;
double FunctionalAreaEdit::s_maxWidth;
double FunctionalAreaEdit::s_stepWidth;
double FunctionalAreaEdit::s_minHeight;
double FunctionalAreaEdit::s_maxHeight;
double FunctionalAreaEdit::s_stepHeight;
int FunctionalAreaEdit::s_minDurationMinutes;
int FunctionalAreaEdit::s_maxDurationMinutes;
int FunctionalAreaEdit::s_stepDurationMinutes;
int FunctionalAreaEdit::s_minEffectMinutes;
int FunctionalAreaEdit::s_maxEffectMinutes;
int FunctionalAreaEdit::s_stepEffectMinutes;
int FunctionalAreaEdit::s_stepSupplyMinutes;
// Todo: Höhe und Radius in Abhängigkeit der Munitionsart berechnen
FunctionalAreaEdit::FunctionalAreaEdit(const QString &menuGroup, QWidget *parent)
: BaseEdit(menuGroup, QLatin1String("FunctionalAreaEdit"), parent)
, m_symbolConfig(nullptr)
, m_symbolWatcher(nullptr)
, m_ui(new Ui::FunctionalAreaEdit)
{
m_ui->setupUi(this);
s_minWidth = 5;
s_maxWidth = 1275;
s_stepWidth = 5;
s_minHeight = 5;
s_maxHeight = 1275;
s_stepHeight = 5;
s_minDurationMinutes = 1;
s_maxDurationMinutes = 14400;
s_stepDurationMinutes = 1;
s_minEffectMinutes = 0;
s_maxEffectMinutes = 2550;
s_stepEffectMinutes = 10;
s_stepSupplyMinutes = 1;
m_ui->sbWidth->setMinimum(s_minWidth);
m_ui->sbWidth->setMaximum(s_maxWidth);
m_ui->sbWidth->setSingleStep(s_stepWidth);
m_ui->sbHeight->setMinimum(s_minHeight);
m_ui->sbHeight->setMaximum(s_maxHeight);
m_ui->sbHeight->setSingleStep(s_stepHeight);
m_ui->sbDurationMinutes->setMinimum(s_minDurationMinutes);
m_ui->sbDurationMinutes->setMaximum(s_maxDurationMinutes);
m_ui->sbDurationMinutes->setSingleStep(s_stepDurationMinutes);
m_ui->sbDecontaminationMinutes->setMinimum(s_minEffectMinutes);
m_ui->sbDecontaminationMinutes->setMaximum(s_maxEffectMinutes);
m_ui->sbDecontaminationMinutes->setSingleStep(s_stepEffectMinutes);
m_ui->sbMaintanenceMinutes->setMinimum(s_minEffectMinutes);
m_ui->sbMaintanenceMinutes->setMaximum(s_maxEffectMinutes);
m_ui->sbMaintanenceMinutes->setSingleStep(s_stepEffectMinutes);
m_ui->sbMedicalMinutes->setMinimum(s_minEffectMinutes);
m_ui->sbMedicalMinutes->setMaximum(s_maxEffectMinutes);
m_ui->sbMedicalMinutes->setSingleStep(s_stepEffectMinutes);
m_ui->sbSupplyMinutes->setMinimum(s_minEffectMinutes);
m_ui->sbSupplyMinutes->setMaximum(s_maxEffectMinutes);
m_ui->sbSupplyMinutes->setSingleStep(s_stepSupplyMinutes);
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->lblParticipant, [this]() { return (!m_ui->lblHierarchy->text().isEmpty()); }});
// m_uiRequirements->addRequirement({m_ui->chbDecon, [this]() { return (m_ui->chbDecon->isChecked() || m_ui->chbMaint->isChecked() || m_ui->chbMedic->isChecked()); }});
// party is (currently) not user-visible
// m_ui->lblParty->setVisible(false);
// m_ui->cbParty->setVisible(false);
connect(m_ui->cbDecontamination, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &FunctionalAreaEdit::onCbxIdxDeconChanged);
connect(m_ui->cbMaintenance, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &FunctionalAreaEdit::onCbxIdxMaintChanged);
connect(m_ui->cbMedical, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &FunctionalAreaEdit::onCbxIdxMedicChanged);
connect(m_ui->cbSupply, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &FunctionalAreaEdit::onCbxIdxSupplyChanged);
connect(m_ui->sbDecontaminationMinutes, &QSpinBox::editingFinished, this, &FunctionalAreaEdit::correctSpinBoxValue);
connect(m_ui->sbMaintanenceMinutes, &QSpinBox::editingFinished, this, &FunctionalAreaEdit::correctSpinBoxValue);
connect(m_ui->sbMedicalMinutes, &QSpinBox::editingFinished, this, &FunctionalAreaEdit::correctSpinBoxValue);
connect(m_ui->sbSupplyMinutes, &QSpinBox::editingFinished, this, &FunctionalAreaEdit::correctSpinBoxValue);
connect(m_ui->sbWidth, &QSpinBox::editingFinished, this, &FunctionalAreaEdit::correctSpinBoxValue);
connect(m_ui->sbHeight, &QSpinBox::editingFinished, this, &FunctionalAreaEdit::correctSpinBoxValue);
connect(m_ui->sbDurationMinutes, &QSpinBox::editingFinished, this, &FunctionalAreaEdit::correctSpinBoxValue);
connect(m_ui->pbClear, &QPushButton::clicked, m_ui->positionEdit, &LtsCoordWidget::LtsCoordWidget::clear);
connect(m_ui->pbParticipant, &QPushButton::clicked, this, &FunctionalAreaEdit::onParticipantClicked);
m_ui->sbDecontaminationMinutes->setEnabled(false);
m_ui->sbMaintanenceMinutes->setEnabled(false);
m_ui->sbMedicalMinutes->setEnabled(false);
m_ui->sbSupplyMinutes->setEnabled(false);
// Symbol:
m_symbolWatcher = new AdvancedSymbology::SymbolResultWatcherQWidget<QToolButton>(m_ui->pbIcon);
connect(m_ui->pbIcon, &QToolButton::clicked, this, &FunctionalAreaEdit::onSymbolSelection);
connect(m_ui->pbSymbolConfig, &QToolButton::clicked, this, &FunctionalAreaEdit::onSymbolConfig);
connect(m_ui->pbClearPointSymbol, &QPushButton::clicked, this, &FunctionalAreaEdit::onClearPointSymbol);
m_ui->cbFunctionalAreaType->setCurrentIndex(m_ui->cbFunctionalAreaType->findData(0)); // 0 is always functional area general
connect(m_ui->cbFunctionalAreaType, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &FunctionalAreaEdit::onCbxIdxFunctionalAreaTypeChanged);
// Initially do it:
const bool showPvSan = LtsUtils::ProjectSettings::isFunctionEnabled(QStringLiteral("ParticipantInformation"),
QStringLiteral("HasPvSan"));
m_ui->cbFunctionalAreaType->setVisible(showPvSan);
m_ui->lblType->setVisible(showPvSan);
setOnlineHelpFilename(QStringLiteral("Situation-Add_Functional_Area"));
enaDisa();
}
FunctionalAreaEdit::~FunctionalAreaEdit()
{
delete m_ui;
}
void FunctionalAreaEdit::retranslate()
{
translate(m_ui, m_aesItem, tr("Functional Area"));
}
void FunctionalAreaEdit::enableUiElements(bool enable)
{
m_ui->leIdentifier->setMaxLength(30);
const FunctionalAreaType type = m_functionalAreaTypes.value(m_ui->cbFunctionalAreaType->currentData().toInt());
//if (type.id() == 7) Supply Truck
if (type.supplyMode() == AesOperatingMode_def::OmWaitingTime)
{
DEBUG_LOG(m_logger) << "SUPPLY-MODE";
m_ui->sbDecontaminationMinutes->setEnabled(false);
m_ui->cbDecontamination->setEnabled(false);
m_ui->sbMaintanenceMinutes->setEnabled(false);
m_ui->cbMaintenance->setEnabled(false);
m_ui->sbMedicalMinutes->setEnabled(false);
m_ui->cbMedical->setEnabled(false);
m_ui->sbSupplyMinutes->setEnabled(true);
m_ui->cbSupply->setEnabled(true);
m_ui->pbParticipant->setEnabled(true);
m_ui->cbParty->setEnabled(false);
m_ui->sbDecontaminationMinutes->setValue(0);
m_ui->cbDecontamination->setCurrentIndex(0);
m_ui->sbMaintanenceMinutes->setValue(0);
m_ui->cbMaintenance->setCurrentIndex(0);
m_ui->sbMedicalMinutes->setValue(0);
m_ui->cbMedical->setCurrentIndex(0);
setVisableFaButtons();
}
else
{
m_ui->sbDecontaminationMinutes->setEnabled(true);
m_ui->cbDecontamination->setEnabled(true);
m_ui->sbMaintanenceMinutes->setEnabled(true);
m_ui->cbMaintenance->setEnabled(true);
m_ui->sbMedicalMinutes->setEnabled(true);
m_ui->cbMedical->setEnabled(true);
m_ui->sbSupplyMinutes->setEnabled(false);
m_ui->cbSupply->setEnabled(false);
m_ui->sbDurationMinutes->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->sbHeight->setEnabled(enable);
m_ui->sbWidth->setEnabled(enable);
const bool deconAvailable = type.deconMode() != AesOperatingMode_def::OmNotAvailable;
const bool maintAvailable = type.maintMode() != AesOperatingMode_def::OmNotAvailable;
const bool medicAvailable = type.medicMode() != AesOperatingMode_def::OmNotAvailable;
m_ui->cbDecontamination->setEnabled(enable && deconAvailable);
m_ui->cbMaintenance->setEnabled(enable && maintAvailable);
m_ui->cbMedical->setEnabled(enable && medicAvailable);
m_ui->sbDecontaminationMinutes->setEnabled((m_ui->cbDecontamination->currentIndex() == AesOperatingMode_def::OmWaitingTime) && enable && deconAvailable);
m_ui->sbMaintanenceMinutes->setEnabled((m_ui->cbMaintenance->currentIndex() == AesOperatingMode_def::OmWaitingTime) && enable && maintAvailable);
m_ui->sbMedicalMinutes->setEnabled((m_ui->cbMedical->currentIndex() == AesOperatingMode_def::OmWaitingTime) && enable && medicAvailable);
m_ui->sbSupplyMinutes->setEnabled(false);
m_ui->sbSupplyMinutes->setValue(0);
m_ui->cbSupply->setCurrentIndex(0);
setVisableFaButtons();
}
const bool isGenericFunctionalArea = type.id() == 0;
const bool symbolAvailable = type.pointSymbol().empty();
m_ui->pbClear->setEnabled(enable);
m_ui->leIdentifier->setEnabled(enable || isOnlyNameModifiable());
m_ui->pbIcon->setEnabled(enable && isGenericFunctionalArea);
if (AdvancedSymbology::SidcCodec::isEncoded(m_sidc))
{
//was is mit ETS Symbolen?
const QString rawSidc = AdvancedSymbology::SidcCodec::decodeRawSidc(m_sidc);
m_ui->pbSymbolConfig->setEnabled(rawSidc.size() && !AdvancedSymbology::SidcCodec::isCivil(m_sidc) && enable && symbolAvailable && isGenericFunctionalArea);
}
else
m_ui->pbSymbolConfig->setEnabled(false);
m_ui->pbClearPointSymbol->setEnabled(isGenericFunctionalArea);
if (m_aesItem.effectStateId() == AesEffectState_def::EsExpired)
{
m_ui->leIdentifier->setText(QString::fromStdString(m_aesItem.name()));
__unchange__();
DEBUG_LOG(m_logger) << "setUnchangeable()";
setUnchangeable();
disableButtons(true);
}
if (m_aesItem.effectStateId() == AesEffectState_def::EsActivated)
{
QString name = m_ui->leIdentifier->text();
auto baseData = m_dtc->functionalArea(m_aesItem.id());
DEBUG_LOG(m_logger) << "init: setData";
setData(baseData, false);
__unchange__();
if (name != m_ui->leIdentifier->text())
m_ui->leIdentifier->setText(name);
DEBUG_LOG(m_logger) << "setUnchangeable()";
setUnchangeable();
disableButtons(true);
}
}
bool FunctionalAreaEdit::init(int areaId, bool copy,
LtsSession::LtsSession *session)
{
if (!BaseEdit::init(areaId, session))
return false;
if (!session->getDtc<ParticipantManagement::DataInterface>(m_ppmDtc))
return false;
m_ui->cbFunctionalAreaType->clear();
m_functionalAreaTypes = m_dtc->functionalAreaTypes();
for (const auto &type : qAsConst(m_functionalAreaTypes))
m_ui->cbFunctionalAreaType->addItem(AreaEffectSimulation::trFunctionalAreaTypeName(type.name()), type.id());
bool editable = LtsSessionData::LtsSessionData::getInstance()->hasOperatorRight(OperatorRights::FunctionalAreasEdit) ||
m_session->app() == LtsAppDescriptor::App::OC;
bool readable = LtsSessionData::LtsSessionData::getInstance()->hasOperatorRight(OperatorRights::FunctionalAreasShow);
if (!readable && !editable)
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, &FunctionalAreaEdit::getPosition);
else
m_ui->pbPosition->setEnabled(false);
// get access to AdvancedSymbology::SymbolDictionary:
m_session->getForeignDataInterface<AdvancedSymbology::DataInterface>(m_asbfc);
fillCbx();
if (areaId > 0)
{
auto baseData = m_dtc->functionalArea(areaId);
DEBUG_LOG(m_logger) << "init: setData";
setData(baseData, copy);
}
connect(m_ui->cbParty, QOverload<int>::of(&LtsWidgets::LtsComboBox::currentIndexChanged), this, [this]()
{
onChangeSymbol(m_sidc);
});
enableUiElements(editable && isModifiable() && !isOnlyNameModifiable());
connect(m_dtc.get(), &AreaEffectSimulation::Interface::Dtc::functionalAreaChanged,
this, &BaseEdit::onAreaChanged);
return true;
}
void FunctionalAreaEdit::setData(const FunctionalArea &area, bool copy)
{
m_aesItem = area;
if (copy)
{
m_aesItem.id(0);
m_aesItem.effectStateId(AreaEffectSimulation::AesEffectState_def::get_default());
}
m_ui->leIdentifier->setText(QString::fromStdString(area.name()));
m_ui->dteEffectStart->setMsecsSinceEpoch(area.effectStart().is_set() ? area.effectStart().get() : 0);
m_ui->sbDurationMinutes->setValue(area.effectDuration() / 1000 / 60); // msecs -> mins
m_ui->sbWidth->setValue(area.area().width());
m_ui->sbHeight->setValue(area.area().height());
m_ui->cbParty->setCurrentIndex(m_ui->cbParty->findData(area.partyId().is_set() ? area.partyId().get() : 0));
const QPointF bottomLeft(area.area().cornerBottomLeft().lon(), area.area().cornerBottomLeft().lat());
const QPointF centerpoint = Polygons::bottomLeft2CenterPoint(bottomLeft, area.area().width(), area.area().height(), 0.0);
if (!bottomLeft.isNull())
m_ui->positionEdit->setCoordinate(centerpoint);
m_ui->cbDecontamination->setCurrentIndex(m_ui->cbDecontamination->findData(area.deconMode().underlying()));
m_ui->cbMaintenance->setCurrentIndex(m_ui->cbMaintenance->findData(area.maintMode().underlying()));
m_ui->cbMedical->setCurrentIndex(m_ui->cbMedical->findData(area.medicMode().underlying()));
m_ui->sbDecontaminationMinutes->setValue(area.deconTime() / (1000 * 60));
m_ui->sbMaintanenceMinutes->setValue(area.maintTime() / (1000 * 60));
m_ui->sbMedicalMinutes->setValue(area.medicTime() / (1000 * 60));
m_ui->sbSupplyMinutes->setValue(area.supplyTime() / (1000 * 60));
m_ui->cbFunctionalAreaType->setCurrentIndex(m_ui->cbFunctionalAreaType->findData(area.functionalAreaTypeId()));
if (m_aesItem.participantId().is_set())
{
int participantId = m_aesItem.participantId().get();
DEBUG_LOG(m_logger) << "ParticipantId = " << participantId;
QVector<int> participants;
participants.append(participantId);
onParticipant(participants);
}
// Symbol:
if (area.pointSymbol().is_set())
{
m_sidc = QString::fromStdString(area.pointSymbol().get());
onChangeSymbol(m_sidc);
}
if ((m_aesItem.effectStateId() == AesEffectState::EsActivated)
|| (m_aesItem.effectStateId() == AesEffectState::EsExpired))
{
DEBUG_LOG(m_logger) << "setUnchangeable";
disableButtons(true);
setUnchangeable();
}
}
void FunctionalAreaEdit::fillCbx()
{
int curIdxDeconCbx = m_ui->cbDecontamination->currentIndex();
int curIdxMaintCbx = m_ui->cbMaintenance->currentIndex();
int curIdxMedicCbx = m_ui->cbMedical->currentIndex();
// clear cbx
m_ui->cbDecontamination->clear();
m_ui->cbMaintenance->clear();
m_ui->cbMedical->clear();
m_ui->cbSupply->clear();
// fill with text
QString unused = tr("unused");
QString byOperator = tr("by operator");
QString bytimeout = tr("by wait time");
m_ui->cbDecontamination->addItem(unused, AesOperatingMode_def::OmNotUsed);
m_ui->cbDecontamination->addItem(byOperator, AesOperatingMode_def::OmObserver);
m_ui->cbDecontamination->addItem(bytimeout, AesOperatingMode_def::OmWaitingTime);
m_ui->cbMaintenance->addItem(unused, AesOperatingMode_def::OmNotUsed);
m_ui->cbMaintenance->addItem(byOperator, AesOperatingMode_def::OmObserver);
m_ui->cbMaintenance->addItem(bytimeout, AesOperatingMode_def::OmWaitingTime);
m_ui->cbMedical->addItem(unused, AesOperatingMode_def::OmNotUsed);
m_ui->cbMedical->addItem(byOperator, AesOperatingMode_def::OmObserver);
m_ui->cbMedical->addItem(bytimeout, AesOperatingMode_def::OmWaitingTime);
m_ui->cbSupply->addItem(bytimeout, AesOperatingMode_def::OmWaitingTime);
// reset Idx
if (curIdxDeconCbx >= 0)
m_ui->cbDecontamination->setCurrentIndex(curIdxDeconCbx);
if (curIdxMaintCbx >= 0)
m_ui->cbDecontamination->setCurrentIndex(curIdxMaintCbx);
if (curIdxMedicCbx >= 0)
m_ui->cbDecontamination->setCurrentIndex(curIdxMedicCbx);
m_ui->cbSupply->setCurrentIndex(0);
m_ppmGuiCbxIfc->fillPartyComboBox(m_ui->cbParty);
}
void FunctionalAreaEdit::getPosition()
{
if (!has2DMap())
return;
m_sitMapGuiIfc->getRectangleNorth(this,
SLOT(onRectData(QPointF,double,double,QPolygonF)),
nullptr,
s_minWidth,
s_maxWidth,
s_minHeight,
s_maxHeight,
m_ui->positionEdit->coordinate(),
m_ui->sbWidth->value(),
m_ui->sbHeight->value());
}
void FunctionalAreaEdit::onRectData(const QPointF &centerPoint, double width, double height, const QPolygonF &coordinates)
{
m_previewPolygon = coordinates;
m_ui->positionEdit->setCoordinate(centerPoint);
m_ui->sbWidth->setValue(width);
m_ui->sbHeight->setValue(height);
DEBUG_LOG(m_logger) << "Pos X: " << centerPoint.x() << " Y: " << centerPoint.y() << " W: " << width << " H: " << height;
showPreviewObject();
}
void FunctionalAreaEdit::onCbxIdxDeconChanged()
{
m_ui->sbDecontaminationMinutes->setEnabled(AesOperatingMode_def::OmWaitingTime == m_ui->cbDecontamination->currentData().toInt());
}
void FunctionalAreaEdit::onCbxIdxMaintChanged()
{
m_ui->sbMaintanenceMinutes->setEnabled(AesOperatingMode_def::OmWaitingTime == m_ui->cbMaintenance->currentData().toInt());
}
void FunctionalAreaEdit::onCbxIdxMedicChanged()
{
m_ui->sbMedicalMinutes->setEnabled(AesOperatingMode_def::OmWaitingTime == m_ui->cbMedical->currentData().toInt());
}
void FunctionalAreaEdit::onCbxIdxSupplyChanged()
{
m_ui->sbSupplyMinutes->setEnabled(AesOperatingMode_def::OmWaitingTime == m_ui->cbSupply->currentData().toInt());
}
void FunctionalAreaEdit::onCbxIdxFunctionalAreaTypeChanged()
{
const FunctionalAreaType type = m_functionalAreaTypes.value(m_ui->cbFunctionalAreaType->currentData().toInt());
DEBUG_LOG(m_logger) << "onCbxIdxFunctionalAreaTypeChanged"
<< " type.id=" << type.id()
<< " name=" << type.name();
if (type.id() != 0)
{
if (type.id() == 7)
{
m_ui->sbSupplyMinutes->setValue(type.supplyTime());
m_ui->cbSupply->setCurrentIndex(0);
}
else
{
m_sidc = QString::fromStdString(type.pointSymbol());
onChangeSymbol(m_sidc);
m_ui->sbDecontaminationMinutes->setValue(type.deconTime());
m_ui->sbMaintanenceMinutes->setValue(type.maintTime());
m_ui->sbMedicalMinutes->setValue(type.medicTime());
m_ui->cbDecontamination->setCurrentIndex(m_ui->cbDecontamination->findData(type.deconMode() == AesOperatingMode_def::OmNotAvailable ? AesOperatingMode_def::OmNotUsed : type.deconMode().underlying()));
m_ui->cbMaintenance->setCurrentIndex(m_ui->cbMaintenance->findData(type.maintMode() == AesOperatingMode_def::OmNotAvailable ? AesOperatingMode_def::OmNotUsed : type.maintMode().underlying()));
m_ui->cbMedical->setCurrentIndex(m_ui->cbMedical->findData(type.medicMode() == AesOperatingMode_def::OmNotAvailable ? AesOperatingMode_def::OmNotUsed : type.medicMode().underlying()));
}
}
enableUiElements(true);
}
void FunctionalAreaEdit::onSymbolSelection()
{
if (!m_asbfc)
{
ERROR_LOG(m_logger) << " m_asbfc";
return;
}
AdvancedSymbology::Gui::BaseSymbolLookupDialog *bslDlg =
AdvancedSymbology::Gui::BaseSymbolLookupDialog::showInstance();
connect(bslDlg, &AdvancedSymbology::Gui::BaseSymbolLookupDialog::finished, this, [this, bslDlg]()
{
// qCritical() << " finished";
bslDlg->disconnect(this); // !!! disconnect my slots from bslDlg !!!
});
connect(bslDlg, &AdvancedSymbology::Gui::BaseSymbolLookupDialog::lookupAppliedCompleteSidc, this, &FunctionalAreaEdit::onChangeSymbol);
bslDlg->setParticipantMode(false);
bslDlg->setCurrentSidc(m_sidc);
bslDlg->show();
}
void FunctionalAreaEdit::onSymbolConfig()
{
if (!m_asbfc)
{
ERROR_LOG(m_logger) << " no m_asbfc";
return;
}
AdvancedSymbology::SymbologyType symbologyType = AdvancedSymbology::SymbolDictionary::defaultSymbologyType();
m_symbolConfig = new AdvancedSymbology::Gui::SymbolModificationDialogFrameless(m_asbfc->getSymbolDictionary(symbologyType), false /* isParticipant */, this);
m_symbolConfig->setSidc(m_sidc);
connect(m_symbolConfig, &AdvancedSymbology::Gui::SymbolModificationDialogFrameless::sidcOnClose, this, &FunctionalAreaEdit::onChangeSymbol);
connect(m_symbolConfig, &AdvancedSymbology::Gui::SymbolModificationDialogFrameless::rejected, this, [this]()
{
m_symbolConfig->deleteLater();
m_symbolConfig = nullptr;
});
m_symbolConfig->show();
}
void FunctionalAreaEdit::onChangeSymbol(const QString &sidc)
{
TRACE_LOG(m_logger) << "Changing symbol to " << sidc;
if (m_sidc != sidc)
this->slotChangesMade();
m_sidc = sidc;
if (m_sidc.isEmpty())
{
m_ui->pbIcon->setIcon(QIcon()); // clear
return;
}
if (!m_asbfc)
{
ERROR_LOG(m_logger) << " no m_asbfc";
return;
}
AdvancedSymbology::SymbolDataToRender symDataToRender(sidc);
symDataToRender.fillColor = AdvancedSymbology::SymbolDataToRender::unknownColor();
symDataToRender.fillColorReplace = true;
int partyId = m_ui->cbParty->currentData().toInt();
if (partyId >= 0)
{
std::shared_ptr<ParticipantManagement::Interface::Dtc> ppmDtc;
m_session->getDtc<ParticipantManagement::DataInterface>(ppmDtc);
if (ppmDtc)
symDataToRender.fillColor = ppmDtc->party(partyId).color();
else
WARNING_LOG(m_logger) << "no ppmDtc";
}
m_symbolWatcher->setSymbolResult(m_asbfc->findImage(symDataToRender));
if (AdvancedSymbology::SidcCodec::isEncoded(m_sidc))
{
const bool isGenericFunctionalArea = m_ui->cbFunctionalAreaType->currentData().toInt() == 0;
const QString rawSidc = AdvancedSymbology::SidcCodec::decodeRawSidc(m_sidc);
m_ui->pbSymbolConfig->setEnabled(rawSidc.size() && (!AdvancedSymbology::SidcCodec::isCivil(m_sidc)) && isGenericFunctionalArea);
}
else
{
ERROR_LOG(m_logger) << LOGFUNCTION << " sidc is not encoded, sidc = '" << sidc << "'";
m_ui->pbSymbolConfig->setEnabled(false);
}
if (m_symbolConfig)
{
m_symbolConfig->deleteLater();
m_symbolConfig = nullptr;
}
DEBUG_LOG(m_logger) << "Changing symbol to " << sidc << " is in progress";
}
void FunctionalAreaEdit::onClearPointSymbol()
{
onChangeSymbol(QString());
}
bool FunctionalAreaEdit::apply()
{
DEBUG_LOG(m_logger) << "Apply";
std::string name = m_ui->leIdentifier->text().toStdString();
qint64 effectStart = m_ui->dteEffectStart->msecsSinceEpoch();
int duration = m_ui->sbDurationMinutes->value() * 60 * 1000; // mins -> msecs
int chargeType = 411; // Dummy Med area charge id Uleis
int partyId = m_ui->cbParty->currentData().toInt();
int functionalAreaType = m_ui->cbFunctionalAreaType->currentData().toInt();
int playerId = 0;
const auto pointSymbol = m_sidc.toStdString();
AesOperatingMode deconMode = static_cast<AesOperatingMode_def::type>(m_ui->cbDecontamination->currentData().toInt());
int deconTime = (AesOperatingMode_def::OmWaitingTime == m_ui->cbDecontamination->currentData().toInt()) ? 1000 * 60 * m_ui->sbDecontaminationMinutes->value() : 0;
AesOperatingMode maintMode = static_cast<AesOperatingMode_def::type>(m_ui->cbMaintenance->currentData().toInt());
int maintTime = (AesOperatingMode_def::OmWaitingTime == m_ui->cbMaintenance->currentData().toInt()) ? 1000 * 60 * m_ui->sbMaintanenceMinutes->value() : 0;
AesOperatingMode medicMode = static_cast<AesOperatingMode_def::type>(m_ui->cbMedical->currentData().toInt());
int medicTime = (AesOperatingMode_def::OmWaitingTime == m_ui->cbMedical->currentData().toInt()) ? 1000 * 60 * m_ui->sbMedicalMinutes->value() : 0;
AesOperatingMode supplyMode = static_cast<AesOperatingMode_def::type>(m_ui->cbSupply->currentData().toInt());
if ( functionalAreaType != 7 )
supplyMode = AesOperatingMode_def::OmNotUsed;
int supplyTime = (AesOperatingMode_def::OmWaitingTime == m_ui->cbSupply->currentData().toInt()) ? 1000 * 60 * m_ui->sbSupplyMinutes->value() : 0;
AesOperatingMode notfightMode = static_cast<AesOperatingMode_def::type>(m_ui->cbMedical->currentData().toInt());
int notfightTime = (AesOperatingMode_def::OmWaitingTime == m_ui->cbMedical->currentData().toInt()) ? 1000 * 60 * m_ui->sbMedicalMinutes->value() : 0;
if ( functionalAreaType == 7 )
{
deconMode = AesOperatingMode_def::OmNotUsed;
maintMode = AesOperatingMode_def::OmNotUsed;
medicMode = AesOperatingMode_def::OmNotUsed;
notfightMode = AesOperatingMode_def::OmNotUsed;
}
if ( functionalAreaType == 8 )
{
deconMode = AesOperatingMode_def::OmNotUsed;
maintMode = AesOperatingMode_def::OmNotUsed;
medicMode = AesOperatingMode_def::OmNotUsed;
supplyMode = AesOperatingMode_def::OmNotUsed;
notfightMode = AesOperatingMode_def::OmObserver;
}
QPointF bottomLeft(Polygons::centerPoint2BottomLeft(m_ui->positionEdit->coordinate(),
m_ui->sbWidth->value(),
m_ui->sbHeight->value(),
0.0));
const Core::GeoPosition2D bottomLeftGeo(bottomLeft.x(), bottomLeft.y());
const Area area(bottomLeftGeo, m_ui->sbWidth->value(), m_ui->sbHeight->value(), 0.0);
const ::dds::core::optional< int32_t > participantIdOpt = LtsUtils::toOptional(playerId);
if (supplyMode == AesOperatingMode_def::OmWaitingTime)
{
partyId = 0;
playerId = m_participant.id();
}
FunctionalAreaModifyRequest req(m_aesItem.id(),
name,
LtsUtils::toOptional(effectStart),
duration,
chargeType,
area,
LtsUtils::toOptional(partyId),
LtsUtils::toOptional(playerId),
LtsUtils::toOptional(pointSymbol),
functionalAreaType, // Todo: Get from UI
deconMode,
deconTime,
maintMode,
maintTime,
medicMode,
medicTime,
supplyMode,
supplyTime,
notfightMode,
notfightTime
);
m_requestHelper->addRequest([this, req, functionalAreaType]()
{
DEBUG_LOG(m_logger) << "addRequest m_aesItem.id()=" << m_aesItem.id()
<< " functionalAreaType=" << functionalAreaType
<< " area=" << req;
return m_ftc->functionalAreaModifyRequest(req, this);
});
DEBUG_LOG(m_logger) << "startRequest";
return m_requestHelper->startRequests();
}
void FunctionalAreaEdit::showPreviewObject()
{
if (!m_sitMapGuiIfc)
return;
if (m_previewPolygon.isEmpty())
return;
m_sitMapGuiIfc->displayPreviewObject(this, m_previewPolygon, true);
}
void FunctionalAreaEdit::disableButtons(bool state)
{
m_ui->leIdentifier->setDisabled(state);
m_ui->sbDurationMinutes->setDisabled(state);
m_ui->positionEdit->setDisabled(state);
m_ui->pbPosition->setDisabled(state);
m_ui->pbClear->setDisabled(state);
m_ui->sbWidth->setDisabled(state);
m_ui->sbHeight->setDisabled(state);
m_ui->cbFunctionalAreaType->setDisabled(state);
m_ui->cbDecontamination->setDisabled(state);
m_ui->cbMaintenance->setDisabled(state);
m_ui->cbMedical->setDisabled(state);
m_ui->cbSupply->setDisabled(state);
m_ui->sbDecontaminationMinutes->setDisabled(state);
m_ui->sbMaintanenceMinutes->setDisabled(state);
m_ui->sbMedicalMinutes->setDisabled(state);
m_ui->sbSupplyMinutes->setDisabled(state);
m_ui->pbIcon->setDisabled(state);
m_ui->pbSymbolConfig->setDisabled(state);
m_ui->pbClear->setDisabled(state);
m_ui->pbClearPointSymbol->setDisabled(state);
m_ui->cbParty->setDisabled(state);
m_ui->dteEffectStart->setDisabled(state);
m_ui->pbParticipant->setDisabled(state);
m_ui->pbParticipant->setDisabled(state);
}
void FunctionalAreaEdit::setVisableFaButtons()
{
int functionalAreaType = m_ui->cbFunctionalAreaType->currentData().toInt();
DEBUG_LOG(m_logger) << "setVisableFaButtons!!!!!!!!!!!!!!!!!!!!!!!! Type=" << functionalAreaType;
const QList<QWidget *> children = findChildren<QWidget *>();
for (QWidget *w : qAsConst(children))
{
//qWarning() << "MWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMW";
const QVariant type(w->property("type"));
//qWarning() << "widget" << w->objectName() << "- type is:" << type;
if (type.isNull())
continue;
auto x1 = type.toStringList();
//qWarning() << "x1" << x1;
auto x2 = QString::number(functionalAreaType);
//qWarning() << "x2" << x2;
auto x3 = x1.contains(x2);
//qWarning() << "x3" << x3;
w->setVisible(x3);
//qWarning() << "visible now?" << w->isVisible() << "parent?" << w->parentWidget();
}
}
QStringList FunctionalAreaEdit::toStringList(const QList<QByteArray> &list)
{
QStringList stringList;
stringList.reserve(list.size());
for (const QByteArray &ba : qAsConst(list))
stringList.append(QString::fromLocal8Bit(ba)); // Assuming local 8-bit.
return stringList;
}
void FunctionalAreaEdit::onParticipantClicked()
{
ParticipantManagement::ParticipantSelection *ps = new ParticipantManagement::ParticipantSelection(m_session, this);
ps->init();
ps->setParticipantSelected(m_participant.partyId(), m_participant.id());
connect(ps, &ParticipantManagement::ParticipantSelection::selectedParticipants, this, &FunctionalAreaEdit::onParticipant);
ps->exec();
}
void FunctionalAreaEdit::onParticipant(const QVector<int> &participants)
{
DEBUG_LOG(m_logger) << "onParticipant"
<< " participants.size=" << participants.size();
if (participants.isEmpty())
return;
// if (participants[0] == m_participant.id())
// return;
m_participant = m_ppmDtc->participant(participants[0]);
QString lblHierarchy = m_ppmDtc->hierarchyFromParticipant(m_participant.id());
QString lblParticipantType = ParticipantManagement::trTypeName(m_ppmDtc->type(m_participant.typeId()).name());
int functionalAreaType = m_ui->cbFunctionalAreaType->currentData().toInt();
DEBUG_LOG(m_logger) << "m_participant.id=" << m_participant.id()
<< " designator=" << m_participant.designator()
<< " tacticalIdentifier=" << m_participant.tacticalIdentifier()
<< " lblHierarchy=" << lblHierarchy
<< " lblHierarchy.isVisable=" << m_ui->lblHierarchy->isVisible()
<< " lblParticipantType=" << lblParticipantType
<< " lblParticipantType.isVisable=" << m_ui->lblParticipantType->isVisible()
<< " functionalAreaType=" << functionalAreaType;
QList<QByteArray> dynamicProperties = m_ui->lblHierarchy->dynamicPropertyNames();
const QStringList propertyStrHierarchie = toStringList(dynamicProperties);
DEBUG_LOG(m_logger) << "lblHierarchy.property=" << dynamicProperties.size()
<< " property=" << propertyStrHierarchie.join(QStringLiteral("|"));
QList<QByteArray> dynamicPropertiesType = m_ui->cbFunctionalAreaType->dynamicPropertyNames();
const QStringList propertyStrType = toStringList(dynamicPropertiesType);
DEBUG_LOG(m_logger) << "cbFunctionalAreaType.property=" << dynamicProperties.size()
<< " property=" << propertyStrType.join(QStringLiteral("|"));
m_ui->lblHierarchy->show();
m_ui->lblHierarchy->setText(m_ppmDtc->hierarchyFromParticipant(m_participant.id()));
m_ui->lblParticipantType->show();
m_ui->lblParticipantType->setText(ParticipantManagement::trTypeName(m_ppmDtc->type(m_participant.typeId()).name()));
m_ui->lblEquipmentNumber->show();
dds::core::optional<int32_t> eqId = m_participant.equipmentNumber();
if (eqId.is_set())
{
QString id = QString::number(eqId.get());
m_ui->lblEquipmentNumber->setText(id);
}
else
m_ui->lblEquipmentNumber->setText(QStringLiteral("-"));
}
} // namespace AreaEffectSimulation
@@ -0,0 +1,106 @@
/**
* @RDE_HEADER@
* AreaEffectSimulation - Functional Area Edit Dialog
* $Id$
* $HeadURL$
* $Author$
* Created by Malte Diers, SLSE, 2017-04-06
*/
#pragma once
#include <Plugins/AreaEffectSimulation/Gui/Base/aes_base_edit.h>
#include <AreaEffectSimulation/aes_ftc.h>
#include <Plugins/AdvancedSymbology/asb_data_plugin_interface.h>
#include <Plugins/ParticipantManagement/ppm_data_plugin_interface.h>
#include <QPolygonF>
namespace Ui
{
class FunctionalAreaEdit;
}
namespace AdvancedSymbology
{
namespace Gui
{
class SymbolModificationDialogFrameless;
}
}
namespace AreaEffectSimulation
{
class FunctionalAreaEdit final
: public BaseEdit
, protected AreaEffectSimulation::Interface::Ftc::FunctionalAreaModifyReplyHandler
{
Q_OBJECT
public:
explicit FunctionalAreaEdit(const QString &menuGroup, QWidget *parent = nullptr);
~FunctionalAreaEdit();
QString dialogIdentifier() const override
{
return m_aesItem.id() <= 0 ? QStringLiteral("AddFunctionalArea") : QStringLiteral("EditFunctionalArea%1").arg(m_aesItem.id());
}
bool init(int areaId, bool copy, LtsSession::LtsSession *session);
void onFunctionalAreaModifyReply(const Core::FunctionReplyObject &replyObject) override final { onAesItemModifyReply(replyObject); }
private:
void retranslate() override;
static double s_minWidth;
static double s_maxWidth;
static double s_stepWidth;
static double s_minHeight;
static double s_maxHeight;
static double s_stepHeight;
static int s_minDurationMinutes;
static int s_maxDurationMinutes;
static int s_stepDurationMinutes;
static int s_minEffectMinutes;
static int s_maxEffectMinutes;
static int s_stepEffectMinutes;
static int s_stepSupplyMinutes;
void setData(const FunctionalArea &area, bool copy);
void fillCbx();
void enableUiElements(bool enable) override;
void disableButtons(bool state);
void setVisableFaButtons();
QStringList toStringList(const QList<QByteArray> &list);
private Q_SLOTS:
void getPosition();
void onRectData(const QPointF &centerPoint, double width, double height, const QPolygonF &coordinates);
void onCbxIdxDeconChanged();
void onCbxIdxMaintChanged();
void onCbxIdxMedicChanged();
void onCbxIdxSupplyChanged();
void onCbxIdxFunctionalAreaTypeChanged();
void onSymbolSelection();
void onSymbolConfig();
void onChangeSymbol(const QString &sidc);
void onClearPointSymbol();
bool apply() override;
void showPreviewObject() override;
void onParticipantClicked();
void onParticipant(const QVector<int> &participants);
private:
std::shared_ptr<AdvancedSymbology::ForeignDataInterface> m_asbfc;
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
AdvancedSymbology::Gui::SymbolModificationDialogFrameless *m_symbolConfig;
QString m_sidc;
AdvancedSymbology::SymbolResultWatcherQWidgetBase *m_symbolWatcher;
QPolygonF m_previewPolygon;
Ui::FunctionalAreaEdit *m_ui;
QMap<qint32, AreaEffectSimulation::FunctionalAreaType> m_functionalAreaTypes;
ParticipantManagement::Participant m_participant;
};
} //namespace AreaEffectSimulation
@@ -0,0 +1,816 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>FunctionalAreaEdit</class>
<widget class="QWidget" name="FunctionalAreaEdit">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>632</width>
<height>475</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string notr="true">Aes Functional Area Edit</string>
</property>
<property name="toolTip">
<string notr="true"/>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="spacing">
<number>6</number>
</property>
<item>
<layout class="QFormLayout" name="formLayout">
<property name="sizeConstraint">
<enum>QLayout::SetMaximumSize</enum>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>30</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="lblDuration">
<property name="toolTip">
<string/>
</property>
<property name="text">
<string>Duration [min]:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="sbDurationMinutes">
<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>240</number>
</property>
<property name="singleStep">
<number>10</number>
</property>
<property name="value">
<number>60</number>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lblIdentifier">
<property name="toolTip">
<string/>
</property>
<property name="text">
<string>Identifier:</string>
</property>
</widget>
</item>
<item row="1" 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>
<property name="text">
<string notr="true"/>
</property>
</widget>
</item>
<item row="2" 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="1">
<widget class="LtsWidgets::LtsDateTimeEdit" name="dteEffectStart" native="true">
<property name="minimumSize">
<size>
<width>0</width>
<height>10</height>
</size>
</property>
<property name="toolTip">
<string/>
</property>
<property name="withButtons" stdset="0">
<bool>false</bool>
</property>
<property name="withSlider" stdset="0">
<bool>false</bool>
</property>
<property name="checkable" stdset="0">
<bool>true</bool>
</property>
<property name="withReset" stdset="0">
<bool>false</bool>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="lblType">
<property name="text">
<string>Type:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="cbFunctionalAreaType"/>
</item>
</layout>
</item>
<item>
<layout class="QFormLayout" name="formLayout_2">
<property name="sizeConstraint">
<enum>QLayout::SetMaximumSize</enum>
</property>
<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>
<item row="0" column="0">
<widget class="QLabel" name="lblPosition">
<property name="toolTip">
<string/>
</property>
<property name="text">
<string>Center Point:</string>
</property>
<property name="type" stdset="0">
<stringlist notr="true">
<string>0</string>
<string>1</string>
<string>2</string>
<string>3</string>
<string>4</string>
<string>5</string>
<string>6</string>
<string>8</string>
</stringlist>
</property>
</widget>
</item>
<item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="LtsCoordWidget::LtsCoordWidget" name="positionEdit" native="true">
<property name="toolTip">
<string notr="true"/>
</property>
<property name="type" stdset="0">
<stringlist notr="true">
<string>0</string>
<string>1</string>
<string>2</string>
<string>3</string>
<string>4</string>
<string>5</string>
<string>6</string>
<string>8</string>
</stringlist>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbPosition">
<property name="toolTip">
<string notr="true"/>
</property>
<property name="text">
<string notr="true"/>
</property>
<property name="icon">
<iconset>
<normaloff>:/style/position.svg</normaloff>:/style/position.svg</iconset>
</property>
<property name="type" stdset="0">
<stringlist notr="true">
<string>0</string>
<string>1</string>
<string>2</string>
<string>3</string>
<string>4</string>
<string>5</string>
<string>6</string>
<string>8</string>
</stringlist>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbClear">
<property name="text">
<string notr="true"/>
</property>
<property name="icon">
<iconset>
<normaloff>:/style/remove.svg</normaloff>:/style/remove.svg</iconset>
</property>
<property name="type" stdset="0">
<stringlist notr="true">
<string>0</string>
<string>1</string>
<string>2</string>
<string>3</string>
<string>4</string>
<string>5</string>
<string>6</string>
<string>8</string>
</stringlist>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lblDimensions">
<property name="toolTip">
<string/>
</property>
<property name="text">
<string>Dimensions [m]:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="LtsWidgets::LtsSpinBox" name="sbWidth"/>
</item>
<item>
<widget class="LtsWidgets::LtsSpinBox" name="sbHeight"/>
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QLabel" name="lblDecontamination">
<property name="toolTip">
<string/>
</property>
<property name="text">
<string>Decontamination:</string>
</property>
<property name="type" stdset="0">
<stringlist notr="true">
<string>0</string>
<string>5</string>
<string>6</string>
</stringlist>
</property>
</widget>
</item>
<item row="2" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<property name="rightMargin">
<number>0</number>
</property>
<item>
<widget class="QComboBox" name="cbDecontamination">
<property name="toolTip">
<string/>
</property>
<property name="type" stdset="0">
<stringlist notr="true">
<string>0</string>
<string>5</string>
<string>6</string>
</stringlist>
</property>
</widget>
</item>
<item>
<widget class="LtsWidgets::LtsSpinBox" name="sbDecontaminationMinutes">
<property name="type" stdset="0">
<stringlist notr="true">
<string>0</string>
<string>5</string>
<string>6</string>
</stringlist>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lblTimeUnitDecontamination">
<property name="toolTip">
<string/>
</property>
<property name="text">
<string>[min]</string>
</property>
<property name="type" stdset="0">
<stringlist notr="true">
<string>0</string>
<string>5</string>
<string>6</string>
</stringlist>
</property>
</widget>
</item>
</layout>
</item>
<item row="3" column="0">
<widget class="QLabel" name="lblMaintenance">
<property name="toolTip">
<string/>
</property>
<property name="text">
<string>Maintenance:</string>
</property>
<property name="type" stdset="0">
<stringlist notr="true">
<string>6</string>
<string>0</string>
</stringlist>
</property>
</widget>
</item>
<item row="3" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<property name="rightMargin">
<number>0</number>
</property>
<item>
<widget class="QComboBox" name="cbMaintenance">
<property name="toolTip">
<string/>
</property>
<property name="type" stdset="0">
<stringlist notr="true">
<string>6</string>
<string>0</string>
</stringlist>
</property>
</widget>
</item>
<item>
<widget class="LtsWidgets::LtsSpinBox" name="sbMaintanenceMinutes">
<property name="type" stdset="0">
<stringlist notr="true">
<string>6</string>
<string>0</string>
</stringlist>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lblTimeUnitMaintenance">
<property name="text">
<string>[min]</string>
</property>
<property name="type" stdset="0">
<stringlist notr="true">
<string>6</string>
<string>0</string>
</stringlist>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="0">
<widget class="QLabel" name="lblMedical">
<property name="toolTip">
<string/>
</property>
<property name="text">
<string>Medical:</string>
</property>
<property name="type" stdset="0">
<stringlist notr="true">
<string>0</string>
<string>1</string>
<string>2</string>
<string>3</string>
<string>4</string>
<string>5</string>
</stringlist>
</property>
</widget>
</item>
<item row="4" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_6">
<property name="rightMargin">
<number>0</number>
</property>
<item>
<widget class="QComboBox" name="cbMedical">
<property name="toolTip">
<string/>
</property>
<property name="type" stdset="0">
<stringlist notr="true">
<string>0</string>
<string>1</string>
<string>2</string>
<string>3</string>
<string>4</string>
<string>5</string>
</stringlist>
</property>
</widget>
</item>
<item>
<widget class="LtsWidgets::LtsSpinBox" name="sbMedicalMinutes">
<property name="type" stdset="0">
<stringlist notr="true">
<string>0</string>
<string>1</string>
<string>2</string>
<string>3</string>
<string>4</string>
<string>5</string>
</stringlist>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lblTimeUnitMedical">
<property name="toolTip">
<string/>
</property>
<property name="text">
<string>[min]</string>
</property>
<property name="type" stdset="0">
<stringlist notr="true">
<string>0</string>
<string>1</string>
<string>2</string>
<string>3</string>
<string>4</string>
<string>5</string>
</stringlist>
</property>
</widget>
</item>
</layout>
</item>
<item row="5" column="0">
<widget class="QLabel" name="lblSupply">
<property name="text">
<string>Resupply</string>
</property>
<property name="type" stdset="0">
<stringlist notr="true">
<string>7</string>
</stringlist>
</property>
</widget>
</item>
<item row="5" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QComboBox" name="cbSupply">
<property name="type" stdset="0">
<stringlist notr="true">
<string>7</string>
</stringlist>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="sbSupplyMinutes">
<property name="type" stdset="0">
<stringlist notr="true">
<string>7</string>
</stringlist>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lblTimeUnitSupply">
<property name="text">
<string>[min]</string>
</property>
<property name="type" stdset="0">
<stringlist notr="true">
<string>7</string>
</stringlist>
</property>
</widget>
</item>
</layout>
</item>
<item row="6" column="0">
<widget class="QLabel" name="lblSymbol">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Symbol:</string>
</property>
<property name="type" stdset="0">
<stringlist notr="true">
<string>0</string>
<string>1</string>
<string>2</string>
<string>3</string>
<string>4</string>
<string>5</string>
<string>6</string>
</stringlist>
</property>
</widget>
</item>
<item row="6" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<widget class="QToolButton" name="pbIcon">
<property name="minimumSize">
<size>
<width>60</width>
<height>60</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>60</width>
<height>60</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="iconSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="type" stdset="0">
<stringlist notr="true">
<string>0</string>
<string>1</string>
<string>2</string>
<string>3</string>
<string>4</string>
<string>5</string>
<string>6</string>
</stringlist>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="pbSymbolConfig">
<property name="text">
<string>Config</string>
</property>
<property name="type" stdset="0">
<stringlist notr="true">
<string>0</string>
<string>1</string>
<string>2</string>
<string>3</string>
<string>4</string>
<string>5</string>
<string>6</string>
</stringlist>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbClearPointSymbol">
<property name="text">
<string notr="true"/>
</property>
<property name="icon">
<iconset>
<normaloff>:/style/remove.svg</normaloff>:/style/remove.svg</iconset>
</property>
<property name="type" stdset="0">
<stringlist notr="true">
<string>0</string>
<string>1</string>
<string>2</string>
<string>3</string>
<string>4</string>
<string>5</string>
<string>6</string>
</stringlist>
</property>
</widget>
</item>
</layout>
</item>
<item row="7" column="0">
<widget class="QLabel" name="lblParty">
<property name="toolTip">
<string/>
</property>
<property name="text">
<string>Party:</string>
</property>
<property name="type" stdset="0">
<stringlist notr="true">
<string>0</string>
<string>1</string>
<string>2</string>
<string>3</string>
<string>4</string>
<string>5</string>
<string>6</string>
<string>8</string>
</stringlist>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="LtsWidgets::LtsComboBox" name="cbParty">
<property name="toolTip">
<string/>
</property>
<property name="type" stdset="0">
<stringlist notr="true">
<string>0</string>
<string>1</string>
<string>2</string>
<string>3</string>
<string>4</string>
<string>5</string>
<string>6</string>
<string>8</string>
</stringlist>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="lblParticipant">
<property name="text">
<string>Participant</string>
</property>
<property name="type" stdset="0">
<stringlist notr="true">
<string>7</string>
</stringlist>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QPushButton" name="pbParticipant">
<property name="text">
<string>Select Participant</string>
</property>
<property name="type" stdset="0">
<stringlist notr="true">
<string>7</string>
</stringlist>
</property>
</widget>
</item>
<item row="9" column="1">
<layout class="QFormLayout" name="formLayout_3">
<item row="0" column="0">
<widget class="QLabel" name="lblHierarchyName">
<property name="text">
<string>Hierarchie:</string>
</property>
<property name="type" stdset="0">
<stringlist notr="true">
<string>7</string>
</stringlist>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="lblHierarchy">
<property name="text">
<string notr="true"/>
</property>
<property name="type" stdset="0">
<stringlist notr="true">
<string>7</string>
</stringlist>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lblTypeName">
<property name="text">
<string>Type:</string>
</property>
<property name="type" stdset="0">
<stringlist notr="true">
<string>7</string>
</stringlist>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="lblParticipantType">
<property name="text">
<string notr="true"/>
</property>
<property name="type" stdset="0">
<stringlist notr="true">
<string>7</string>
</stringlist>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="lblEquipmentNumberName">
<property name="text">
<string>Equipment Number:</string>
</property>
<property name="type" stdset="0">
<stringlist notr="true">
<string>7</string>
</stringlist>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="lblEquipmentNumber">
<property name="text">
<string notr="true"/>
</property>
<property name="type" stdset="0">
<stringlist notr="true">
<string>7</string>
</stringlist>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</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>
<customwidget>
<class>LtsWidgets::LtsSpinBox</class>
<extends>QSpinBox</extends>
<header>LtsWidgets/lts_spinbox.h</header>
</customwidget>
<customwidget>
<class>LtsWidgets::LtsDateTimeEdit</class>
<extends>QWidget</extends>
<header>LtsWidgets/lts_date_time_edit.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>positionEdit</tabstop>
<tabstop>pbPosition</tabstop>
<tabstop>pbClear</tabstop>
<tabstop>sbWidth</tabstop>
<tabstop>sbHeight</tabstop>
<tabstop>pbClearPointSymbol</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>
@@ -0,0 +1,93 @@
/**
* @RDE_HEADER@
* GUI Plugin for AreaEffectSimulation - Functional Area
* $Id$
* $HeadURL$
* $Author$
* Created by Malte Diers, SLSE, 2017-04-06
*/
#include "aes_functional_area_gui_plugin.h"
#include "aes_functional_area_edit.h"
#include "aes_functional_area_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);
}
InterfaceImpl::InterfaceImpl(LtsSession::LtsSession *session)
: AesBaseInterface(session, getLogger("Plugins.Gui.FunctionalArea"))
, ForeignGuiInterface()
{}
QVector<LtsWidgets::PluginData> InterfaceImpl::getActions()
{
QVector<LtsWidgets::PluginData> ret;
LtsUtils::ProjectSettings *ps = LtsUtils::ProjectSettings::getInstance();
const bool enableFunctionalAreas = ps->value(QStringLiteral("aes"),
QStringLiteral("enableFunctionalAreas")).toBool();
if (enableFunctionalAreas)
{
// Functional Area
ret.append(LtsWidgets::PluginData(menuGroup(),
tr("Functional Areas"),
QLatin1String("ListFunctionalAreas"),
QIcon(QLatin1String("icon:functional_area.svg")),
[this](QWidget *parent) { return onShowFunctionalAreaListDialog(parent);},
OperatorRights::FunctionalAreasShow,
LtsWidgets::ExercisePart::eExecution));
if (m_session->isExercisePartition() && appId() != LtsAppDescriptor::App::OC)
ret.append(LtsWidgets::PluginData(menuGroup(),
tr("Add Functional Area"),
QLatin1String("AddFunctionalArea"),
QIcon(QLatin1String("icon:functional_area_add.svg")),
[this](QWidget *parent) { return onShowAddFunctionalAreaDialog(parent);},
OperatorRights::FunctionalAreasEdit,
LtsWidgets::ExercisePart::eExecution,
LtsWidgets::ExerciseState::eCreated | LtsWidgets::ExerciseState::eStarted | LtsWidgets::ExerciseState::ePaused));
}
return ret;
}
AreaEffectSimulation::BaseEdit *InterfaceImpl::showEditWindow(int aesEntityId, QWidget *parent)
{
FunctionalAreaEdit *editWidget = new FunctionalAreaEdit(menuGroup(), parent);
if (editWidget->init(aesEntityId, false, m_session))
return editWidget;
delete editWidget;
return nullptr;
}
LtsWidgets::LtsDialog *InterfaceImpl::onShowAddFunctionalAreaDialog(QWidget *parent)
{
FunctionalAreaEdit *editWidget = new FunctionalAreaEdit(menuGroup(), parent);
if (editWidget->init(0, false, m_session))
return editWidget;
delete editWidget;
return nullptr;
}
LtsWidgets::LtsDialog *InterfaceImpl::onShowFunctionalAreaListDialog(QWidget *parent)
{
FunctionalAreaList *listWidget = new FunctionalAreaList(menuGroup(), parent);
if (listWidget->init(m_session))
return listWidget;
delete listWidget;
return nullptr;
}
} // namespace AreaEffectSimulation
@@ -0,0 +1,51 @@
/**
* @RDE_HEADER@
* Gui Plugin for AreaEffectSimulation - Functional Area
* $Id$
* $HeadURL$
* $Author$
* Created by Malte Diers, SLSE, 2017-04-06
*/
#pragma once
#include <Plugins/AreaEffectSimulation/Gui/Base/aes_base_gui_plugin.h>
#include "aes_functional_area_gui_plugin_interface.h"
namespace AreaEffectSimulation
{
class GuiPlugin final : public AesBaseGuiPlugin
{
Q_PLUGIN_METADATA(IID "gui:3:aes.functional_areas")
Q_OBJECT
public:
GuiPlugin() = default;
~GuiPlugin() = default;
QString pluginName() override { return QStringLiteral("AreaEffectSimuationFunctionalAreaGui"); }
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 AesFunctionalArea::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 *onShowAddFunctionalAreaDialog(QWidget *parent);
LtsWidgets::LtsDialog *onShowFunctionalAreaListDialog(QWidget *parent);
};
} // namespace AreaEffectSimulation
@@ -0,0 +1,29 @@
/**
* @RDE_HEADER@
* HMI Plugin for AreaEffectSimulation / Functional Area (Interface for access from other Plugins)
* $Id$
* $HeadURL$
* $Author$
* Created by Malte Diers, SLSE, 2017-04-06
*/
#pragma once
class QWidget;
namespace AreaEffectSimulation
{
class BaseEdit;
}
namespace AesFunctionalArea
{
class ForeignGuiInterface
{
public:
ForeignGuiInterface() = default;
virtual ~ForeignGuiInterface() = default;
virtual AreaEffectSimulation::BaseEdit *showEditWindow(int aesEntityId, QWidget *parent) = 0;
};
} // namespace AesFunctionalArea
@@ -0,0 +1,106 @@
/**
* @RDE_HEADER@
* AreaEffectSimulation - Functional Area Overview Dialog
* $Id$
* $HeadURL$
* $Author$
* Created by Malte Diers, SLSE, 2017-04-06
*/
#include "aes_functional_area_list.h"
#include "aes_functional_areas_model.h"
#include "aes_functional_area_edit.h"
#include "CustomView/aes_functional_area.h"
#include <LtsSession/lts_session_data.h>
#include <LtsUtilsSettings/settings.h>
namespace AreaEffectSimulation
{
bool FunctionalAreaList::init(LtsSession::LtsSession *session)
{
if (!AesItemList::init(session))
return false;
m_bHasAddEditOperatorRights = LtsSessionData::LtsSessionData::getInstance()->hasOperatorRight(OperatorRights::FunctionalAreasEdit);
setDataViewModel(m_model, [this]() { return new CustomViewFunctionalArea(this); });
enaDisa();
#ifndef LTS_DEBUG
hideColumn(FunctionalAreasModel::BcId);
#endif
hideColumn(FunctionalAreasModel::BcChargeType);
hideColumn(FunctionalAreasModel::BcParticipant);
hideColumn(FunctionalAreasModel::BcEffectSource);
const bool showPvSan = LtsUtils::ProjectSettings::isFunctionEnabled(QStringLiteral("ParticipantInformation"),
QStringLiteral("HasPvSan"));
if (!showPvSan)
hideColumn(FunctionalAreasModel::ColType);
setSortIndicator(FunctionalAreasModel::BcName);
setOnlineHelpFilename(QStringLiteral("Situation-Functional_Areas"));
return true;
}
void FunctionalAreaList::createModel()
{
m_model = new AesItemSortFilterProxyModelTmpl<FunctionalArea>(m_session, this);
FunctionalAreasModel *sourceModel = new FunctionalAreasModel(this);
sourceModel->initModel(m_session);
m_model->setSourceModel(sourceModel);
}
void FunctionalAreaList::onAddAesItem()
{
FunctionalAreaEdit *dialog = new FunctionalAreaEdit(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;
}
void FunctionalAreaList::onEditAesItem()
{
const int aesItemId = model()->aesId(currentRow());
if (aesItemId <= 0)
return;
DEBUG_LOG(m_logger) << "current AreaId: " << aesItemId;
FunctionalAreaEdit *dialog = new FunctionalAreaEdit(m_menuGroup, this);
if (dialog->init(aesItemId, false, m_session))
addDialog(dialog, m_menuGroup, dialog->dialogIdentifier(), LtsWidgets::LayoutArea::eDialogTab);
else
delete dialog;
}
void FunctionalAreaList::onRemoveAesItem()
{
const int aesItemId = model()->aesId(currentRow());
Core::RemoveElementRequest req(aesItemId);
m_requestHelper->startSingleRequest([req, this]()
{
return m_ftc->functionalAreaRemoveRequest(req, this);
});
}
void FunctionalAreaList::retranslate()
{
translateBase(tr("Functional Areas"));
}
void FunctionalAreaList::onFunctionalAreaRemoveReply(const Core::FunctionReplyObject &replyObject)
{
m_requestHelper->requestReply(replyObject);
}
} // namespace AreaEffectSimulation
@@ -0,0 +1,37 @@
/**
* @RDE_HEADER@
* AreaEffectSimulation - Functional Area Overview Dialog
* $Id$
* $HeadURL$
* $Author$
* Created by Malte Diers, SLSE, 2017-04-06
*/
#pragma once
#include <Plugins/AreaEffectSimulation/Gui/Base/aes_itemlist.h>
#include <Plugins/AreaEffectSimulation/Gui/Base/aes_base_model.h>
namespace AreaEffectSimulation
{
class FunctionalAreaList final : public AesItemListTmpl<FunctionalArea>
, protected AreaEffectSimulation::Interface::Ftc::FunctionalAreaRemoveReplyHandler
{
Q_OBJECT
public:
using AesItemListTmpl<FunctionalArea>::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;
void onFunctionalAreaRemoveReply(const Core::FunctionReplyObject &replyObject) override;
};
}
@@ -0,0 +1,56 @@
/**
* @RDE_HEADER@
* AreaEffectManangement - Functional Area Overview Dialog Model
* $Id$
* $HeadURL$
* $Author$
*
* Created by Malte Diers, SLSE, 2017-04-06
*/
#include "aes_functional_areas_model.h"
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
#include <QLocale>
#include <QSet>
#include <AreaEffectSimulation/aes_translation.h>
namespace AreaEffectSimulation
{
bool FunctionalAreasModel::initModel(LtsSession::LtsSession *session)
{
if (!AesGuiBaseModel::initModel(session))
return false;
connect(m_aesDtc.get(), &Interface::Dtc::functionalAreaChanged,
this, &FunctionalAreasModel::onDataChanged);
m_aesDtc->functionalAreas([this](const FunctionalArea &item) { insertRow(item); });
return true;
}
QVariant FunctionalAreasModel::data(const QModelIndex &index, int role) const
{
if (!indexIsValid(index))
return QVariant();
const FunctionalArea &functionalArea = getRowData(index.row());
if (index.column() < cntBaseColumns())
return AesGuiBaseModel::data(functionalArea, index.column(), role);
if (role != Qt::DisplayRole)
return QVariant();
switch (index.column())
{
case ColType:
{
auto fat = m_aesDtc->functionalAreaType(functionalArea.functionalAreaTypeId());
return trFunctionalAreaTypeName(fat.name());
}
default:
break;
}
return QVariant();
}
} // namespace AreaEffectSimulation
@@ -0,0 +1,48 @@
/**
* @RDE_HEADER@
* HMI Plugin for AreaEffectSimulation - Functional Area Overview Dialog Model
* $Id$
* $HeadURL$
* $Author$
*
* Created by Malte Diers, SLSE, 2017-04-06
*/
#pragma once
#include <Plugins/AreaEffectSimulation/Gui/Base/aes_base_model.h>
namespace LtsSession
{
class LtsSession;
}
namespace AreaEffectSimulation
{
class FunctionalAreasModel : public AesGuiBaseModel<FunctionalArea>
{
Q_OBJECT
public:
enum AdditionalColumns {ColType = BcCount};
explicit FunctionalAreasModel(QObject *parent = nullptr)
: AesGuiBaseModel<FunctionalArea>(parent, {tr("Type")})
, m_gearClass(ProjectDataManagement::GearClass::FunctionalArea)
{}
bool initModel(LtsSession::LtsSession *session) override;
ProjectDataManagement::GearClass gearClass() const { return m_gearClass; }
QVariant data(const QModelIndex &, int) const override final;
protected:
ProjectDataManagement::GearClass m_gearClass;
};
} //namespace AreaEffectSimulation