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,49 @@
#
# $Id$
# $HeadURL$
# $Author$
# Created by Patric Karwat, SLSE, 2016-07-03
#
ADD_INTERFACE_LIBRARY(
AesDangerAreaGuiPluginInterface
${CMAKE_CURRENT_SOURCE_DIR}/aes_danger_area_gui_plugin_interface.h
${CMAKE_CURRENT_SOURCE_DIR}/..
)
SET(aes_danger_area_gui_SRCS
aes_danger_area_gui_plugin.cpp
aes_danger_area_gui_plugin.h
aes_danger_area_edit.cpp
aes_danger_area_edit.h
aes_danger_area_list.cpp
aes_danger_area_list.h
aes_danger_areas_model.cpp
aes_danger_areas_model.h
CustomView/aes_danger_area.h
CustomView/aes_danger_area.cpp
)
NGL_WRAP_UI(aes_danger_area_gui_SRCS
aes_danger_area_edit.ui
CustomView/aes_danger_area.ui
)
NGL_ADD_LIBRARY2(WS AesDangerAreaGuiPlugin MODULE ${aes_danger_area_gui_SRCS})
NGL_TARGET_LINK_LIBRARIES(AesDangerAreaGuiPlugin
AesBaseGui
ngltools # dtg
NGLLogger
LtsSessionData
AesDataPluginInterface
AesDangerAreaGuiPluginInterface
PdmGuiPluginInterface
AesInfoGuiPluginInterface
SituationMapGuiPluginInterface
Qt5::Widgets
LtsWidgets
LtsDataView
LtsUtilsGuiDds
LtsUtilsSettings
)
@@ -0,0 +1,77 @@
/**
* @RDE_HEADER@
* CustomView for AES NContamination
* $Id$
* $HeadURL$
* $Author$
* Created by Mike Wille, SLSE, 2016-04-08
*/
#include "aes_danger_area.h"
#include "ui_aes_danger_area.h"
#include "aes_danger_areas_model.h"
#include <Services/AreaEffectSimulation/Utils/polygons.h>
#include <LtsCoordTrans/lts_coord_trans.h>
namespace AreaEffectSimulation
{
CustomViewDangerArea::CustomViewDangerArea(QWidget *parent)
: AbstractDisplayWidget(parent)
, m_ui(new Ui::CustomViewDangerArea)
{
m_ui->setupUi(this);
}
CustomViewDangerArea::~CustomViewDangerArea()
{
delete m_ui;
}
bool CustomViewDangerArea::init(const QModelIndex &idx)
{
if (!idx.isValid())
return false;
m_ui->lblIdentifier->setText(rowData(idx, AreaEffectSimulation::DangerAreasModel::BcName).toString());
m_ui->lblEffectState->setText(rowData(idx, AreaEffectSimulation::DangerAreasModel::BcEffectState).toString());
m_ui->lblEffectStart->setText(rowData(idx, AreaEffectSimulation::DangerAreasModel::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 DangerAreasModel *aesModel = qobject_cast<const DangerAreasModel*>(sfpm->sourceModel());
if (!aesModel)
return false;
const auto srcIdx = sfpm->mapToSource(idx);
DangerArea dangerArea = aesModel->getRowData(srcIdx.row());
calculateIcon(dangerArea, sfpm->partyColor(idx.row()));
return true;
}
bool CustomViewDangerArea::calculateIcon(const AreaEffectSimulation::DangerArea &area, const QColor &color)
{
if (area.segments().size() == 0)
return false;
QVector<QPointF> segments;
segments.reserve(area.segments().size());
int setZone = -1;
for (const Core::GeoPosition2D &s : area.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::dangerArea(segments);
Qt::BrushStyle bStyle = PixmapLabel::checkForBrushStyle(area.effectStateId());
const auto pix = Polygons::pixmapFromPolygon(poly, color, ICON_RESOLUTION, bStyle);
m_ui->lblIcon->setPixmap(pix);
return true;
}
} // namespace AreaEffectSimulation
@@ -0,0 +1,34 @@
/**
* @RDE_HEADER@
* CustomView for AES NContamination
* $Id$
* $HeadURL$
* $Author$
* Created by Mike Wille, SLSE, 2016-04-08
*/
#pragma once
#include <Viewer/LtsDataView/abstract_display_widget.h>
namespace Ui
{
class CustomViewDangerArea;
}
namespace AreaEffectSimulation
{
class DangerArea;
class CustomViewDangerArea final : public LtsDataView::AbstractDisplayWidget
{
Q_OBJECT
public:
explicit CustomViewDangerArea(QWidget *parent = nullptr);
~CustomViewDangerArea();
bool init(const QModelIndex &idx) override final;
private:
bool calculateIcon(const AreaEffectSimulation::DangerArea &area, const QColor &color);
Ui::CustomViewDangerArea *m_ui;
};
} // namespace AreaEffectSimulation
@@ -0,0 +1,157 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CustomViewDangerArea</class>
<widget class="QWidget" name="CustomViewDangerArea">
<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="lblIdentifier">
<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="lblEffectState">
<property name="toolTip">
<string notr="true"/>
</property>
<property name="text">
<string notr="true">State</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<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>
<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>
<spacer name="horizontalSpacer_4">
<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>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="lblEffectStart">
<property name="text">
<string notr="true">Time</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,259 @@
/**
* @RDE_HEADER@
* AreaEffectSimulation - NContamination Edit Dialog
* $Id$
* $HeadURL$
* $Author$
* Created by Patric Karwat, SLSE, 2016-07-07
*/
#include "aes_danger_area_edit.h"
#include "ui_aes_danger_area_edit.h"
#include <LtsSession/lts_session_data.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 <PluginInterfaces/gui_plugin_interface.h>
#include <QDoubleSpinBox>
namespace AreaEffectSimulation
{
DangerAreaEdit::DangerAreaEdit(const QString &menuGroup, QWidget *parent)
: BaseEdit(menuGroup, QLatin1String("DangerAreaEdit"), parent)
, m_ui(new Ui::DangerAreaEdit)
{
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_ui->positionEdit_3->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); }});
connect(m_ui->pbAesItems, &QPushButton::clicked, this, &DangerAreaEdit::onPbAesItemsClicked);
connect(m_ui->pbClear, &QPushButton::clicked, this, &DangerAreaEdit::clearCoordinates);
enaDisa();
setOnlineHelpFilename(QStringLiteral("Situation-Add_Danger_Area"));
}
DangerAreaEdit::~DangerAreaEdit()
{
delete m_ui;
}
std::vector<LtsCoordWidget::LtsCoordWidget *> DangerAreaEdit::coordWidgets() const
{
return {m_ui->positionEdit_1,
m_ui->positionEdit_2,
m_ui->positionEdit_3,
m_ui->positionEdit_4,
m_ui->positionEdit_5};
}
void DangerAreaEdit::retranslate()
{
translate(m_ui, m_aesItem, tr("Danger Area"));
}
void DangerAreaEdit::enableUiElements(bool enable)
{
m_ui->leIdentifier->setMaxLength(30);
m_ui->pbPosition->setEnabled(m_sitMapGuiIfc && enable);
enabledCoordinates(enable);
m_ui->pbClear->setEnabled(enable);
m_ui->leIdentifier->setEnabled(enable || isOnlyNameModifiable());
setEffectStartEnabled(m_ui->dteEffectStart, 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->dangerArea(m_aesItem.id());
setData(baseData, false);
__unchange__();
if (name != m_ui->leIdentifier->text())
m_ui->leIdentifier->setText(name);
}
}
bool DangerAreaEdit::init(int aesItemId, bool copy,
LtsSession::LtsSession *session)
{
if (!BaseEdit::init(aesItemId, session))
return false;
bool editable = LtsSessionData::LtsSessionData::getInstance()->hasOperatorRight(OperatorRights::DangerAreasEdit) ||
m_session->app() == LtsAppDescriptor::App::OC;
bool readable = LtsSessionData::LtsSessionData::getInstance()->hasOperatorRight(OperatorRights::DangerAreasShow);
if (!readable && !editable)
return false;
// Todo: Older allowed?
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, &DangerAreaEdit::getPolygon);
else
m_ui->pbPosition->setEnabled(false);
if (aesItemId > 0)
{
auto baseData = m_dtc->dangerArea(aesItemId);
setData(baseData, copy);
}
auto cb = [this](const DangerAreaCorrelatedAesItem &item)
{
if (item.dangerAreaId() == m_aesItem.id()) // AesItemId === DangerAreaId
m_otherAesItemIds << item.aesItemId();
};
m_dtc->dangerAreaCorrelatedAesItems(cb);
setPbAesItemsText();
enableUiElements(editable && isModifiable() && !isOnlyNameModifiable());
connect(m_dtc.get(), &AreaEffectSimulation::Interface::Dtc::dangerAreaCorrelatedAesItemChanged,
this, &DangerAreaEdit::onCorrelatedItemsChanged);
connect(m_dtc.get(), &AreaEffectSimulation::Interface::Dtc::dangerAreaChanged,
this, &BaseEdit::onAreaChanged);
return true;
}
void DangerAreaEdit::setPbAesItemsText()
{
QStringList sl;
for (int idx : qAsConst(m_otherAesItemIds))
{
AesItem item;
m_dtc->aesItemFromId(idx, item);
if (item.id() <= 0)
continue;
// Todo: Correct?
if (item.effectStateId() != AesEffectState_def::EsActivated)
continue;
sl << QString::fromStdString(item.name().c_str());
}
m_ui->pbAesItems->setEnabled(sl.size());
m_ui->pbAesItems->setText(sl.join(QStringLiteral(", ")));
}
void DangerAreaEdit::setData(const DangerArea &aesItem, bool copy)
{
m_aesItem = aesItem;
if (copy)
{
m_aesItem.id(0);
m_aesItem.effectStateId(AreaEffectSimulation::AesEffectState_def::get_default());
}
m_ui->leIdentifier->setText(QString::fromStdString(aesItem.name()));
m_ui->dteEffectStart->setMsecsSinceEpoch(aesItem.effectStart().is_set() ? aesItem.effectStart().get() : 0);
setCoordinates(aesItem.segments());
}
void DangerAreaEdit::getPolygon()
{
if (!has2DMap())
return;
QPolygonF coordinates = getCoordinatesQPointF();
m_sitMapGuiIfc->getPolygon(this,
SLOT(onPolygonData(QPolygonF)),
nullptr,
3,
5,
-1,
-1,
coordinates);
}
void DangerAreaEdit::onPolygonData(const QPolygonF &poly)
{
if (poly.size() < 3)
return;
m_previewPolygon = poly;
// Don't reverse Polygon
setCoordinates(poly, false);
showPreviewObject();
}
bool DangerAreaEdit::apply()
{
std::string name = m_ui->leIdentifier->text().toStdString();
qint64 effectStart = m_ui->dteEffectStart->msecsSinceEpoch();
const DangerAreaModifyRequest req(m_aesItem.id(),
name,
0,
311, //danger area charge id Uleis
LtsUtils::toOptional(effectStart),
getCoordinates(),
dds::core::optional<int32_t>(),
dds::core::optional<int32_t>(),
dds::core::optional<int32_t>());
m_requestHelper->addRequest([this,req]()
{
return m_ftc->dangerAreaModifyRequest(req, this);
});
return m_requestHelper->startRequests();
}
void DangerAreaEdit::onCorrelatedItemsChanged(const DangerAreaCorrelatedAesItem &data, DataModification modType)
{
if (data.dangerAreaId() != m_aesItem.id())
return;
if (modType == DataModification::eAdded)
m_otherAesItemIds += data.aesItemId();
if (modType == DataModification::eRemoved)
m_otherAesItemIds -= data.aesItemId();
// Note: Modification cannot happen as the key is unique for the combination.
setPbAesItemsText();
}
void DangerAreaEdit::onPbAesItemsClicked()
{
if (m_otherAesItemIds.isEmpty())
return;
std::shared_ptr<ForeignInfoGuiInterface> infoGuiInterface;
if (!m_session->getForeignGuiInterface<ForeignInfoGuiInterface>(infoGuiInterface))
return;
LtsWidgets::LtsDialog *dialog = infoGuiInterface->showDangerAreaAesItemInfo({m_aesItem.id()}, m_otherAesItemIds);
addDialog(dialog, m_menuGroup, tr("Danger Areas for BC Contamination %1").arg(m_ui->leIdentifier->text()), LtsWidgets::LayoutArea::eInfoTab);
}
void DangerAreaEdit::showPreviewObject()
{
if (!m_sitMapGuiIfc)
return;
if (m_previewPolygon.isEmpty())
return;
m_sitMapGuiIfc->displayPreviewObject(this, m_previewPolygon, true);
}
} // namespace AreaEffectSimulation
@@ -0,0 +1,65 @@
/**
* @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 <AreaEffectSimulation/aes_ftc.h>
class QDoubleSpinBox;
namespace Ui
{
class DangerAreaEdit;
}
namespace AreaEffectSimulation
{
class DangerAreaEdit final
: public BaseEdit
, protected AreaEffectSimulation::Interface::Ftc::DangerAreaModifyReplyHandler
{
Q_OBJECT
public:
explicit DangerAreaEdit(const QString &menuGroup, QWidget *parent = nullptr);
~DangerAreaEdit();
QString dialogIdentifier() const override
{
return m_aesItem.id() <= 0 ? QStringLiteral("AddDangerArea") : QStringLiteral("EditDangerArea%1").arg(m_aesItem.id());
}
bool init(int aesItemId, bool copy, LtsSession::LtsSession *session);
void onDangerAreaModifyReply(const Core::FunctionReplyObject &replyObject) override final { onAesItemModifyReply(replyObject); }
private:
std::vector<LtsCoordWidget::LtsCoordWidget *> coordWidgets() const override;
void retranslate() override;
void setData(const DangerArea &aesItem, bool copy);
void enableUiElements(bool enable) override;
void setPbAesItemsText();
private Q_SLOTS:
void getPolygon();
void onPolygonData(const QPolygonF &poly);
bool apply() override;
void onCorrelatedItemsChanged(const DangerAreaCorrelatedAesItem &data, DataModification modType);
void onPbAesItemsClicked();
void showPreviewObject() override;
private:
QSet<int> m_otherAesItemIds;
QPolygonF m_previewPolygon;
Ui::DangerAreaEdit *m_ui;
};
} //namespace AreaEffectSimulation
@@ -0,0 +1,233 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DangerAreaEdit</class>
<widget class="QWidget" name="DangerAreaEdit">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>892</width>
<height>206</height>
</rect>
</property>
<property name="windowTitle">
<string notr="true">Aes Danger Area Edit</string>
</property>
<property name="toolTip">
<string notr="true"/>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="3" column="4">
<widget class="LtsCoordWidget::LtsCoordWidget" name="positionEdit_4" native="true">
<property name="toolTip">
<string/>
</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="0" column="4">
<widget class="LtsCoordWidget::LtsCoordWidget" name="positionEdit_1" native="true">
<property name="toolTip">
<string/>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="leIdentifier">
<property name="toolTip">
<string/>
</property>
</widget>
</item>
<item row="2" column="2">
<spacer name="horizontalSpacer_2">
<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="2" column="4">
<widget class="LtsCoordWidget::LtsCoordWidget" name="positionEdit_3" native="true">
<property name="toolTip">
<string/>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lblEffectStart">
<property name="toolTip">
<string notr="true"/>
</property>
<property name="text">
<string>Activation Time:</string>
</property>
</widget>
</item>
<item row="4" column="4">
<widget class="LtsCoordWidget::LtsCoordWidget" name="positionEdit_5" native="true">
<property name="toolTip">
<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="1" column="4">
<widget class="LtsCoordWidget::LtsCoordWidget" name="positionEdit_2" native="true">
<property name="toolTip">
<string/>
</property>
</widget>
</item>
<item row="1" column="6">
<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 row="0" column="3">
<widget class="QLabel" name="lblGeometry">
<property name="toolTip">
<string/>
</property>
<property name="text">
<string>Geometry:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="LtsWidgets::LtsDateTimeEdit" name="dteEffectStart" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<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>true</bool>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label">
<property name="toolTip">
<string/>
</property>
<property name="text">
<string>Area Effects:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QPushButton" name="pbAesItems">
<property name="toolTip">
<string/>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="3">
<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>
</widget>
</item>
<item row="2" column="3">
<widget class="QPushButton" name="pbClear">
<property name="toolTip">
<string notr="true"/>
</property>
<property name="text">
<string notr="true"/>
</property>
<property name="icon">
<iconset>
<normaloff>:/style/remove.svg</normaloff>:/style/remove.svg</iconset>
</property>
</widget>
</item>
</layout>
</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>
</customwidgets>
<tabstops>
<tabstop>dteEffectStart</tabstop>
<tabstop>leIdentifier</tabstop>
<tabstop>positionEdit_1</tabstop>
<tabstop>positionEdit_2</tabstop>
<tabstop>positionEdit_3</tabstop>
<tabstop>positionEdit_4</tabstop>
<tabstop>positionEdit_5</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>
@@ -0,0 +1,123 @@
/**
* @RDE_HEADER@
* GUI Plugin for AreaEffectSimulation - NContaminations
* $Id$
* $HeadURL$
* $Author$
* Created by Patric Karwat, SLSE, 2016-07-07
*/
#include "aes_danger_area_gui_plugin.h"
#include "aes_danger_area_edit.h"
#include "aes_danger_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.DangerArea"))
, ForeignGuiInterface()
, m_enableB(false)
, m_enableC(false)
, m_enableN(false)
, m_enableD(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();
m_enableD = ps->value(QStringLiteral("aes"),
QStringLiteral("enableDangerAreas")).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_enableD)
{
ret.append(LtsWidgets::PluginData(menuGroup(),
tr("Danger Areas"),
QLatin1String("ListDangerAreas"),
QIcon(QLatin1String("icon:danger_areas.svg")),
[this](QWidget *parent) { return onShowDangerAreaListDialog(parent);},
OperatorRights::DangerAreasShow,
LtsWidgets::ExercisePart::eExecution));
if (m_session->isExercisePartition() && appId() != LtsAppDescriptor::App::OC)
ret.append(LtsWidgets::PluginData(menuGroup(),
tr("Add Danger Area"),
QLatin1String("AddDangerArea"),
QIcon(QLatin1String("icon:danger_areas_add.svg")),
[this](QWidget *parent) { return onShowAddDangerAreaDialog(parent);},
OperatorRights::DangerAreasEdit,
LtsWidgets::ExercisePart::eExecution,
LtsWidgets::ExerciseState::eCreated | LtsWidgets::ExerciseState::eStarted | LtsWidgets::ExerciseState::ePaused));
}
return ret;
}
AreaEffectSimulation::BaseEdit *InterfaceImpl::showEditWindow(int aesEntityId, QWidget *parent)
{
DangerAreaEdit *editWidget = new DangerAreaEdit(menuGroup(), parent);
if (editWidget->init(aesEntityId, false, m_session))
return editWidget;
delete editWidget;
return nullptr;
}
LtsWidgets::LtsDialog *InterfaceImpl::onShowAddDangerAreaDialog(QWidget *parent)
{
DangerAreaEdit *editWidget = new DangerAreaEdit(menuGroup(), parent);
if (editWidget->init(0, false, m_session))
return editWidget;
delete editWidget;
return nullptr;
}
LtsWidgets::LtsDialog *InterfaceImpl::onShowDangerAreaListDialog(QWidget *parent)
{
DangerAreaList *listWidget = new DangerAreaList(menuGroup(), parent);
if (listWidget->init(m_session))
return listWidget;
delete listWidget;
return nullptr;
}
} // namespace AreaEffectSimulation
@@ -0,0 +1,55 @@
/**
* @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>
#include "aes_danger_area_gui_plugin_interface.h"
namespace AreaEffectSimulation
{
class GuiPlugin final : public AesBaseGuiPlugin
{
Q_PLUGIN_METADATA(IID "gui:3:aes.dangerareas")
Q_OBJECT
public:
GuiPlugin() = default;
~GuiPlugin() = default;
QString pluginName() override { return QStringLiteral("AreaEffectSimuationDangerAreaGui"); }
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 AesDangerArea::ForeignGuiInterface
{
Q_OBJECT
public:
explicit InterfaceImpl(LtsSession::LtsSession *session);
QVector<LtsWidgets::PluginData> getActions() override;
QString menuGroup() const override final;
AreaEffectSimulation::BaseEdit *showEditWindow(int aesEntityId, QWidget *parent) override;
private:
LtsWidgets::LtsDialog *onShowAddDangerAreaDialog(QWidget *parent);
LtsWidgets::LtsDialog *onShowDangerAreaListDialog(QWidget *parent);
bool m_enableB;
bool m_enableC;
bool m_enableN;
bool m_enableD;
};
} // namespace AreaEffectSimulation
@@ -0,0 +1,29 @@
/**
* @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 AreaEffectSimulation
{
class BaseEdit;
}
namespace AesDangerArea
{
class ForeignGuiInterface
{
public:
ForeignGuiInterface() = default;
virtual ~ForeignGuiInterface() = default;
virtual AreaEffectSimulation::BaseEdit *showEditWindow(int aesEntityId, QWidget *parent) = 0;
};
} // namespace AesDangerArea
@@ -0,0 +1,101 @@
/**
* @RDE_HEADER@
* ContaminationManangement - NContamination Overview Dialog
* $Id$
* $HeadURL$
* $Author$
* Created by Patric Karwat, SLSE, 2016-07-07
*/
#include "aes_danger_area_list.h"
#include "aes_danger_areas_model.h"
#include "aes_danger_area_edit.h"
#include "CustomView/aes_danger_area.h"
#include <LtsSession/lts_session_data.h>
namespace AreaEffectSimulation
{
bool DangerAreaList::init(LtsSession::LtsSession *session)
{
if (!AesItemList::init(session))
return false;
m_bHasAddEditOperatorRights = LtsSessionData::LtsSessionData::getInstance()->hasOperatorRight(OperatorRights::DangerAreasEdit);
setDataViewModel(m_model, [this]() { return new CustomViewDangerArea(this); });
#ifndef LTS_DEBUG
hideColumn(DangerAreasModel::BcId);
#endif
hideColumn(DangerAreasModel::BcParticipant);
hideColumn(DangerAreasModel::BcParty);
hideColumn(DangerAreasModel::BcChargeType);
hideColumn(DangerAreasModel::BcEffectDuration);
hideColumn(DangerAreasModel::BcEffectSource);
setSortIndicator(DangerAreasModel::BcName);
enaDisa();
setOnlineHelpFilename(QStringLiteral("Situation-Danger_Areas"));
return true;
}
void DangerAreaList::createModel()
{
m_model = new AesItemSortFilterProxyModelTmpl<DangerArea>(m_session, this);
DangerAreasModel *sourceModel = new DangerAreasModel(this);
sourceModel->initModel(m_session);
m_model->setSourceModel(sourceModel);
}
void DangerAreaList::onAddAesItem()
{
DangerAreaEdit *dialog = new DangerAreaEdit(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 DangerAreaList::onEditAesItem()
{
const int aesItemId = model()->aesId(currentRow());
if (aesItemId < 0)
return;
DEBUG_LOG(m_logger) << "current NContaminationId: " << aesItemId;
DangerAreaEdit *dialog = new DangerAreaEdit(m_menuGroup, this);
if (dialog->init(aesItemId, false, m_session))
addDialog(dialog, m_menuGroup, dialog->dialogIdentifier(), LtsWidgets::LayoutArea::eDialogTab);
else
delete dialog;
}
void DangerAreaList::onRemoveAesItem()
{
const int aesItemId = model()->aesId(currentRow());
Core::RemoveElementRequest req(aesItemId);
m_requestHelper->startSingleRequest([req, this]()
{
return m_ftc->dangerAreaRemoveRequest(req, this);
});
}
void DangerAreaList::retranslate()
{
translateBase(tr("Danger Areas"));
}
void DangerAreaList::onDangerAreaRemoveReply(const Core::FunctionReplyObject &replyObject)
{
m_requestHelper->requestReply(replyObject);
}
} // namespace AreaEffectSimulation
@@ -0,0 +1,37 @@
/**
* @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 DangerAreaList final : public AesItemListTmpl<DangerArea>
, protected AreaEffectSimulation::Interface::Ftc::DangerAreaRemoveReplyHandler
{
Q_OBJECT
public:
using AesItemListTmpl<DangerArea>::AesItemListTmpl;
bool init(LtsSession::LtsSession *session) override;
private slots:
void onAddAesItem() override;
void onEditAesItem() override;
void onRemoveAesItem() override;
protected:
void createModel() override;
void retranslate() override;
void onDangerAreaRemoveReply(const Core::FunctionReplyObject &replyObject) override;
};
}
@@ -0,0 +1,33 @@
/**
* @RDE_HEADER@
* AreaEffectManangement - N Contamination Overview Dialog Model
* $Id$
* $HeadURL$
* $Author$
*
* Created by Malte Diers, SLSE, 2017-02-21
*/
#include "aes_danger_areas_model.h"
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
#include <QLocale>
namespace AreaEffectSimulation
{
DangerAreasModel::DangerAreasModel(QObject *parent)
: AesGuiBaseModel<DangerArea>(parent)
{}
bool DangerAreasModel::initModel(LtsSession::LtsSession *session)
{
if (!AesGuiBaseModel::initModel(session))
return false;
connect(m_aesDtc.get(), &Interface::Dtc::dangerAreaChanged,
this, &DangerAreasModel::onDataChanged);
m_aesDtc->dangerAreas([this](const DangerArea &item) { insertRow(item); });
return true;
}
} // namespace AreaEffectSimulation
@@ -0,0 +1,32 @@
/**
* @RDE_HEADER@
* HMI Plugin for AreaEffectSimulation - Contaminations Overview Dialog Model
* $Id$
* $HeadURL$
* $Author$
*
* Created by Malte Diers, SLSE, 2017-02-20
*/
#pragma once
#include <Plugins/AreaEffectSimulation/Gui/Base/aes_base_model.h>
namespace LtsSession
{
class LtsSession;
}
namespace AreaEffectSimulation
{
class DangerAreasModel : public AesGuiBaseModel<DangerArea>
{
Q_OBJECT
public:
explicit DangerAreasModel(QObject *parent = nullptr);
bool initModel(LtsSession::LtsSession *session);
};
} //namespace AreaEffectSimulation