Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
@@ -0,0 +1,51 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
#
|
||||
# Created by Mike Wille, SLSE, 2016-09-26
|
||||
#
|
||||
|
||||
ADD_INTERFACE_LIBRARY(
|
||||
AesMineAreaGuiPluginInterface
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/aes_mine_area_gui_plugin_interface.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/..
|
||||
)
|
||||
|
||||
SET(aes_mine_area_gui_SRCS
|
||||
aes_mine_area_gui_plugin.cpp
|
||||
aes_mine_area_gui_plugin.h
|
||||
aes_mine_area_edit.cpp
|
||||
aes_mine_area_edit.h
|
||||
aes_mine_area_list.cpp
|
||||
aes_mine_area_list.h
|
||||
aes_mine_areas_model.cpp
|
||||
aes_mine_areas_model.h
|
||||
CustomView/aes_mine_area.h
|
||||
CustomView/aes_mine_area.cpp
|
||||
)
|
||||
|
||||
NGL_WRAP_UI(aes_mine_area_gui_SRCS
|
||||
aes_mine_area_edit.ui
|
||||
CustomView/aes_mine_area.ui
|
||||
)
|
||||
|
||||
NGL_ADD_LIBRARY(WS AesMineAreaGuiPlugin MODULE ${aes_mine_area_gui_SRCS})
|
||||
NGL_TARGET_LINK_LIBRARIES(AesMineAreaGuiPlugin
|
||||
AesBaseGui
|
||||
NGLLogger
|
||||
svcAesCommon
|
||||
LtsSessionData
|
||||
AesDataPluginInterface
|
||||
AesMineAreaGuiPluginInterface
|
||||
PdmGuiPluginInterface
|
||||
SituationMapGuiPluginInterface
|
||||
Qt5::Widgets
|
||||
LtsWidgets
|
||||
LtsUtilsGuiDds
|
||||
LtsDataView
|
||||
ngltools
|
||||
LtsUtilsSettings
|
||||
)
|
||||
|
||||
NGL_INSTALL_TARGET(AesMineAreaGuiPlugin)
|
||||
@@ -0,0 +1,83 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* CustomView for AES MineArea
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Mike Wille, SLSE, 2016-09-26
|
||||
*/
|
||||
|
||||
#include "aes_mine_area.h"
|
||||
#include "ui_aes_mine_area.h"
|
||||
|
||||
#include "aes_mine_areas_model.h"
|
||||
#include <Services/AreaEffectSimulation/Utils/polygons.h>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
CustomViewMineArea::CustomViewMineArea(QWidget *parent)
|
||||
: AbstractDisplayWidget(parent)
|
||||
, m_ui(new Ui::CustomViewMineArea)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
}
|
||||
|
||||
CustomViewMineArea::~CustomViewMineArea()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
bool CustomViewMineArea::init(const QModelIndex &idx)
|
||||
{
|
||||
if (!idx.isValid())
|
||||
return false;
|
||||
|
||||
m_ui->lbName->setText(rowData(idx, AreaEffectSimulation::MineAreasModel::BcName).toString());
|
||||
m_ui->lbChargeType->setText(rowData(idx, AreaEffectSimulation::MineAreasModel::BcChargeType).toString());
|
||||
m_ui->lbParty->setText(rowData(idx, AreaEffectSimulation::MineAreasModel::BcParty).toString());
|
||||
m_ui->lbWidth->setText(rowData(idx, AreaEffectSimulation::MineAreasModel::ColWidth).toString());
|
||||
m_ui->lbEffectStart->setText(rowData(idx, AreaEffectSimulation::MineAreasModel::BcEffectStart).toString());
|
||||
m_ui->lbEffectDuration->setText(rowData(idx, AreaEffectSimulation::MineAreasModel::BcEffectDuration).toString());
|
||||
m_ui->lbEffectState->setText(rowData(idx, AreaEffectSimulation::MineAreasModel::BcEffectState).toString());
|
||||
m_ui->lblIcon->clear();
|
||||
m_ui->lblIcon->setAutoFillBackground(true);
|
||||
|
||||
const AesItemSortFilterProxyModel *sfpm = qobject_cast<const AesItemSortFilterProxyModel *>(idx.model());
|
||||
if (!sfpm)
|
||||
return false;
|
||||
const MineAreasModel *aesModel = qobject_cast<const MineAreasModel *>(sfpm->sourceModel());
|
||||
if (!aesModel)
|
||||
return false;
|
||||
const auto srcIdx = sfpm->mapToSource(idx);
|
||||
MineArea mineArea = aesModel->getRowData(srcIdx.row());
|
||||
calculateIcon(mineArea, sfpm->partyColor(idx.row()));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CustomViewMineArea::calculateIcon(const MineArea &area, const QColor &color)
|
||||
{
|
||||
if (area.segments().size() == 0)
|
||||
return false;
|
||||
|
||||
QVector<Database::AesMineAreaSegment> segments;
|
||||
segments.reserve(area.segments().size());
|
||||
for (AreaEffectSimulation::MineSegment segmentIn : area.segments())
|
||||
{
|
||||
Database::AesMineAreaSegment segmentOut;
|
||||
segmentOut.startPosition = QPointF(segmentIn.positionStart().lon(),
|
||||
segmentIn.positionStart().lat());
|
||||
segmentOut.endPosition = QPointF(segmentIn.positionEnd().lon(),
|
||||
segmentIn.positionEnd().lat());
|
||||
segments.append(segmentOut);
|
||||
}
|
||||
|
||||
QPolygonF poly = AreaEffectSimulation::Polygons::mineArea(segments, area.width(), area.density(), area.isCenterLine());
|
||||
Qt::BrushStyle bStyle = PixmapLabel::checkForBrushStyle(area.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,35 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* CustomView for AES MineArea
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Mike Wille, SLSE, 2016-09-26
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <Viewer/LtsDataView/abstract_display_widget.h>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class CustomViewMineArea;
|
||||
}
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
class MineArea;
|
||||
class CustomViewMineArea : public LtsDataView::AbstractDisplayWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CustomViewMineArea(QWidget *parent = nullptr);
|
||||
~CustomViewMineArea();
|
||||
bool init(const QModelIndex &idx) override final;
|
||||
|
||||
private:
|
||||
bool calculateIcon(const AreaEffectSimulation::MineArea &area, const QColor &color);
|
||||
|
||||
Ui::CustomViewMineArea *m_ui;
|
||||
};
|
||||
} // namespace AreaEffectSimulation
|
||||
@@ -0,0 +1,297 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CustomViewMineArea</class>
|
||||
<widget class="QWidget" name="CustomViewMineArea">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>480</width>
|
||||
<height>220</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">
|
||||
<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>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
|
||||
</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>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Charge Type:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbChargeType">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">%CHARGE_TYPE%</string>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_11">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Party:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbParty">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">%PARTY%</string>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</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>
|
||||
<widget class="Line" name="line_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_15">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Width:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbWidth">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">%WIDTH%</string>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Start:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbEffectStart">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">%START%</string>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Duration:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbEffectDuration">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">%DURATION%</string>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>State:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbEffectState">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">%STATE%</string>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
|
||||
</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>
|
||||
</layout>
|
||||
</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,532 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* AreaEffectSimulation - MineArea Edit Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Mike Wille, SLSE, 2016-09-26
|
||||
*/
|
||||
|
||||
|
||||
#include "aes_mine_area_edit.h"
|
||||
#include "ui_aes_mine_area_edit.h"
|
||||
|
||||
#include <Plugins/AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
#include <Plugins/ProjectDataManagement/pdm_gui_plugin_interface.h>
|
||||
#include <Plugins/SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
|
||||
#include <AreaEffectSimulation/aes_operator_rights.h>
|
||||
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||
#include <LtsCoordTrans/lts_coord_widget.h>
|
||||
#include <LtsUtilsSettings/settings.h>
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
static int s_lastChargeType = 5005; // PzAbwVMiV as default
|
||||
static int s_DM72ChargeTypeId = 395;
|
||||
|
||||
MineAreaEdit::MineAreaEdit(const QString &menuGroup, QWidget *parent)
|
||||
: BaseEdit(menuGroup, QLatin1String("MineAreaEdit"), parent)
|
||||
, m_ui(new Ui::MineAreaEdit)
|
||||
, m_segments(5)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
m_ui->cbMineAreaInputMode->addItem(tr("Front line"), false);
|
||||
m_ui->cbMineAreaInputMode->addItem(tr("Center line"), true);
|
||||
|
||||
// Todo: Constraints from wherever
|
||||
m_ui->cbDurationHours->setValidator(new QIntValidator(1, s_maxDurationHours, this));
|
||||
m_ui->sbDensity->setDecimals(1);
|
||||
m_ui->sbDensity->setSingleStep(s_stepDensity);
|
||||
m_ui->sbDensity->setMinimum(s_minDensity);
|
||||
m_ui->sbDensity->setMaximum(s_maxDensity);
|
||||
m_ui->sbWidth->setDecimals(2);
|
||||
m_ui->sbWidth->setSingleStep(s_stepWidth);
|
||||
m_ui->sbWidth->setMinimum(s_minWidth);
|
||||
m_ui->sbWidth->setMaximum(s_maxWidth);
|
||||
m_ui->stackedWidget->addWidget(m_ui->sbDensity);
|
||||
m_ui->stackedWidget->addWidget(m_ui->cbxDensity);
|
||||
|
||||
m_uiRequirements->addRequirement({m_ui->lbIdentifier, [this]() { return (!m_ui->leIdentifier->text().isEmpty()); }});
|
||||
m_uiRequirements->addRequirement({m_ui->lbChargeType, [this]() { return (m_ui->cbChargeType->currentData().toInt() > 0); }});
|
||||
m_uiRequirements->addRequirement({m_ui->lbEffectStart, [this]() { return hasValidEffectStart(m_ui->dteEffectStart); }});
|
||||
m_uiRequirements->addRequirement({m_ui->lbParty, [this]() { return (m_ui->cbParty->currentData().toInt() > 0); }});
|
||||
m_uiRequirements->addRequirement({m_ui->lbLayingMethod, [this]() { return (m_ui->cbLayingProcedure->currentData().toInt() > 0); }});
|
||||
//m_uiRequirements->addRequirement({m_ui->lbGeometry, [this]() { return (!(m_ui->posEdit1->pos().isNull() || (m_ui->posEdit3->pos().isNull() && !m_ui->posEdit4->pos().isNull()) || (m_ui->posEdit4->pos().isNull() && !m_ui->posEdit5->pos().isNull()) || (m_ui->posEdit5->pos().isNull() && !m_ui->posEdit6->pos().isNull()))); }});
|
||||
|
||||
connect(m_ui->sbWidth, &QDoubleSpinBox::editingFinished, this, &MineAreaEdit::correctSpinBoxValue);
|
||||
connect(m_ui->sbDensity, &QDoubleSpinBox::editingFinished, this, &MineAreaEdit::correctSpinBoxValue);
|
||||
|
||||
connect(m_ui->cbLayingProcedure, QOverload<int>::of(&LtsWidgets::LtsComboBox::activated), this, &MineAreaEdit::onLayingProcedureChanged);
|
||||
|
||||
connect(m_ui->pbClear, &QPushButton::clicked, this, &MineAreaEdit::clearCoordinates);
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Add_Mine_Area"));
|
||||
|
||||
enaDisa();
|
||||
}
|
||||
|
||||
MineAreaEdit::~MineAreaEdit()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
std::vector<LtsCoordWidget::LtsCoordWidget *> MineAreaEdit::coordWidgets() const
|
||||
{
|
||||
return {m_coordMap.begin(), m_coordMap.end()};
|
||||
}
|
||||
|
||||
void MineAreaEdit::retranslate()
|
||||
{
|
||||
translate(m_ui, m_aesItem, tr("Mine Area"));
|
||||
bool isReactivatable = m_dtc->mineArea(m_aesItem.id()).isReactivatable();
|
||||
m_ui->pbResetDusMines->setText(isReactivatable ? tr("Reset DUS Mines") : tr("Hide DUS Mines"));
|
||||
m_ui->pbResetDusMines->setToolTip(isReactivatable ? tr("Reset all DUS Mines matched to this Minearea") : tr("Hide all DUS Mines matched to this Minearea"));
|
||||
}
|
||||
|
||||
void MineAreaEdit::enableUiElements(bool enable)
|
||||
{
|
||||
|
||||
m_ui->leIdentifier->setMaxLength(30);
|
||||
|
||||
m_ui->cbChargeType->setEnabled(enable);
|
||||
m_ui->cbDurationHours->setEnabled(enable);
|
||||
m_ui->cbLayingProcedure->setEnabled(enable);
|
||||
m_ui->cbLayingMethod->setEnabled(enable);
|
||||
m_ui->cbParty->setEnabled(enable);
|
||||
m_ui->pbClear->setEnabled(enable);
|
||||
setEffectStartEnabled(m_ui->dteEffectStart, enable);
|
||||
m_ui->pbPosition->setEnabled(m_sitMapGuiIfc && enable);
|
||||
enabledCoordinates(enable);
|
||||
m_ui->sbDensity->setEnabled(enable);
|
||||
m_ui->cbxDensity->setEnabled(enable);
|
||||
m_ui->sbWidth->setEnabled(enable);
|
||||
m_ui->leIdentifier->setEnabled(enable || isOnlyNameModifiable());
|
||||
|
||||
const MineArea &ma = m_dtc->mineArea(m_aesItem.id());
|
||||
if (m_aesItem.id() > 0 &&
|
||||
(ma.isDus() || ma.isConcrete()) &&
|
||||
// m_dtc->mineArea(m_aesItem.id()).isReactivatable() && // Always show button!
|
||||
LtsSessionData::hasOperatorRight(OperatorRights::MineAreasResetDusMines))
|
||||
m_ui->pbResetDusMines->setEnabled(isOnlyNameModifiable());
|
||||
else
|
||||
m_ui->pbResetDusMines->hide();
|
||||
|
||||
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->mineArea(m_aesItem.id());
|
||||
setData(baseData, false);
|
||||
__unchange__();
|
||||
if (name != m_ui->leIdentifier->text())
|
||||
m_ui->leIdentifier->setText(name);
|
||||
}
|
||||
}
|
||||
|
||||
bool MineAreaEdit::init(int aesItemId, bool copy,
|
||||
LtsSession::LtsSession *session)
|
||||
{
|
||||
if (!BaseEdit::init(aesItemId, session))
|
||||
return false;
|
||||
|
||||
bool isCenterLine = true; //default is true on OC
|
||||
if (m_session->app() != LtsAppDescriptor::App::OC)
|
||||
isCenterLine = LtsUtils::OperatorSettings::getInstance()->value(QStringLiteral("MineAeraInputMode"), QStringLiteral("CenterLine"), false).toBool();
|
||||
m_ui->cbMineAreaInputMode->setCurrentIndex(m_ui->cbMineAreaInputMode->findData(isCenterLine));
|
||||
|
||||
bool editable = LtsSessionData::LtsSessionData::getInstance()->hasOperatorRight(OperatorRights::MineAreasEdit) ||
|
||||
m_session->app() == LtsAppDescriptor::App::OC;
|
||||
bool readable = LtsSessionData::LtsSessionData::getInstance()->hasOperatorRight(OperatorRights::MineAreasShow);
|
||||
|
||||
if (!readable && !editable)
|
||||
return false;
|
||||
|
||||
if (!m_session->getForeignGuiInterface<ProjectDataManagement::ForeignGuiInterface>(m_pdmGuiIfc))
|
||||
{
|
||||
ERROR_LOG(m_logger)<<"Couldn't get pdmGuifc";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_session->getDtc<ProjectDataManagement::DataInterface>(m_pdmDtc))
|
||||
{
|
||||
ERROR_LOG(m_logger)<<"Couldn't get pdmDtc";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_session->getDtc<AreaEffectSimulation::DataInterface>(m_aesDtc))
|
||||
{
|
||||
ERROR_LOG(m_logger)<<"Couldn't get aesDtc";
|
||||
return false;
|
||||
}
|
||||
|
||||
m_ui->dteEffectStart->setChecked(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, &MineAreaEdit::getPosition);
|
||||
else
|
||||
m_ui->pbPosition->setEnabled(false);
|
||||
|
||||
m_pdmGuiIfc->fillMineFieldComboBox(m_ui->cbChargeType);
|
||||
|
||||
#ifndef TABLET_MODE
|
||||
// since the following call crashes on the ABT and i can not figure out why and we don't need
|
||||
// the functionality of the call on the ABT, it it configured out
|
||||
m_pdmGuiIfc->setChargeTypePropertyFilter(m_ui->cbChargeType, QStringLiteral("canBeCreated"), true);
|
||||
#endif
|
||||
|
||||
connect(m_ui->cbChargeType, QOverload<int>::of(&LtsWidgets::LtsComboBox::currentIndexChanged), this, &MineAreaEdit::onChargeTypeChanged);
|
||||
|
||||
setCombobxToValueIfPossible(m_ui->cbChargeType, s_lastChargeType);
|
||||
|
||||
// Todo: get Values from Whereever
|
||||
for (int duration : {1, 3, 6, 12, 24, 48, 96})
|
||||
m_ui->cbDurationHours->addItem(QString::number(duration), duration);
|
||||
m_ui->cbDurationHours->setCurrentIndex(m_ui->cbDurationHours->findData(96));
|
||||
|
||||
if (strcmp(PROJECTBUILD, "guez") == 0)
|
||||
m_ui->cbLayingProcedure->addItem(tr("Artillery"), AesMaLayingProcedureType_def::LptArtillery);
|
||||
|
||||
m_ui->cbLayingProcedure->addItem(tr("Pioneer"), AesMaLayingProcedureType_def::LptPioneer);
|
||||
m_ui->cbLayingProcedure->setCurrentIndex(m_ui->cbLayingProcedure->findData(AesMaLayingProcedureType_def::LptPioneer)); // Pioneer
|
||||
|
||||
m_ui->cbLayingMethod->addItem(tr("Open"), 0);
|
||||
m_ui->cbLayingMethod->addItem(tr("Covered"), 1);
|
||||
|
||||
m_ui->sbDensity->setValue(0.5);
|
||||
|
||||
for (double density : {5.0, 7.5, 15.0})
|
||||
m_ui->cbxDensity->addItem(QString::number(density), density);
|
||||
|
||||
onChargeTypeChanged(m_ui->cbChargeType->currentData().toInt());
|
||||
|
||||
m_ppmGuiCbxIfc->fillPartyComboBox(m_ui->cbParty);
|
||||
|
||||
LtsUtils::ProjectSettings *ps = LtsUtils::ProjectSettings::getInstance();
|
||||
const bool enableGuezDusMines = ps->value(QStringLiteral("aes"),
|
||||
QStringLiteral("enableGuezDusMines")).toBool();
|
||||
if (enableGuezDusMines)
|
||||
connect(m_ui->pbResetDusMines, &QPushButton::clicked, this, &MineAreaEdit::onResetDusMines);
|
||||
|
||||
|
||||
const bool enableEffectShowManagement = ps->value(QStringLiteral("esm"),
|
||||
QStringLiteral("enableEffectShowManagement")).toBool();
|
||||
|
||||
m_ui->cbEffectMarkingInTa->setVisible(enableEffectShowManagement &&
|
||||
((m_session->app() == LtsAppDescriptor::App::Situation ||
|
||||
m_session->app() == LtsAppDescriptor::App::SituationTablet) &&
|
||||
(!m_session->isReplayPartition())));
|
||||
|
||||
if (aesItemId > 0)
|
||||
{
|
||||
auto baseData = m_dtc->mineArea(aesItemId);
|
||||
setData(baseData, copy);
|
||||
}
|
||||
onLayingProcedureChanged();
|
||||
|
||||
enableUiElements(editable && isModifiable() && !isOnlyNameModifiable());
|
||||
|
||||
connect(m_dtc.get(), &AreaEffectSimulation::Interface::Dtc::mineAreaChanged,
|
||||
this, &BaseEdit::onAreaChanged);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void MineAreaEdit::setData(const MineArea &data, bool copy)
|
||||
{
|
||||
m_aesItem = data;
|
||||
if (copy)
|
||||
{
|
||||
m_aesItem.id(0);
|
||||
m_aesItem.effectStateId(AreaEffectSimulation::AesEffectState_def::get_default());
|
||||
}
|
||||
m_ui->leIdentifier->setText(QString::fromUtf8(data.name().c_str()));
|
||||
m_ui->cbChargeType->setCurrentIndex(m_ui->cbChargeType->findData(data.chargeStruct().chargeTypeId()));
|
||||
m_ui->sbDensity->setValue(data.density());
|
||||
|
||||
double distance = qRound(1.0 / data.density());
|
||||
if (distance == 8.0)
|
||||
distance = 7.5;
|
||||
const int densityIndex = m_ui->cbxDensity->findData(distance);
|
||||
if (densityIndex != -1)
|
||||
m_ui->cbxDensity->setCurrentIndex(densityIndex);
|
||||
else
|
||||
WARNING_LOG(m_logger) << "Got invalid density = " << data.density() << " / distance = " << distance;
|
||||
|
||||
//-- start -- hide Density for DM72 munition // Anbindung ADLER III E01562-458
|
||||
const QJsonObject &propObj = QJsonDocument::fromJson(data.properties().c_str()).object();
|
||||
const int refAesItemId = propObj.value(QStringLiteral("referencedAesItemId")).toInt(-1);
|
||||
int effectClusterChargeTypeId = 0;
|
||||
if (refAesItemId > 0)
|
||||
{
|
||||
const auto &effectCluster = m_aesDtc->effectCluster(refAesItemId);
|
||||
effectClusterChargeTypeId = (effectCluster.id() > 0) ? effectCluster.chargeStruct().chargeTypeId() : 0 ;
|
||||
}
|
||||
|
||||
const bool showDensity = (effectClusterChargeTypeId != s_DM72ChargeTypeId);
|
||||
m_ui->lbDensity->setVisible(showDensity);
|
||||
m_ui->sbDensity->setVisible(showDensity);
|
||||
|
||||
//--- ende -- hide Density for DM72 munition // Anbindung ADLER III E01562-458
|
||||
|
||||
|
||||
m_ui->sbWidth->setDecimals(0);
|
||||
m_ui->sbWidth->setValue(qRound(data.width()));
|
||||
m_ui->cbEffectMarkingInTa->setChecked(data.effectMarkingInTa());
|
||||
if (m_session->app() != LtsAppDescriptor::App::OC)
|
||||
m_ui->cbMineAreaInputMode->setCurrentIndex(m_ui->cbMineAreaInputMode->findData(data.isCenterLine()));
|
||||
|
||||
QVector<QPointF> coords;
|
||||
MineSegment seg;
|
||||
coords.reserve(data.segments().size());
|
||||
for (const MineSegment &ms : data.segments())
|
||||
{
|
||||
coords << QPointF(ms.positionStart().lon(), ms.positionStart().lat());
|
||||
seg = ms;
|
||||
}
|
||||
|
||||
if (coords.size() > 0) // Need at least one segment.
|
||||
coords << QPointF(seg.positionEnd().lon(), seg.positionEnd().lat());
|
||||
|
||||
for (int i = 0; i < coords.size(); ++i)
|
||||
{
|
||||
LtsCoordWidget::LtsCoordWidget *w = m_coordMap.value(i);
|
||||
if (!w)
|
||||
break;
|
||||
w->setCoordinate(coords[i]);
|
||||
}
|
||||
|
||||
m_ui->dteEffectStart->setMsecsSinceEpoch(data.effectStart().is_set() ? data.effectStart().get() : 0);
|
||||
|
||||
double duration = data.effectDuration() / (1000 * 60 * 60); // ms -> h
|
||||
m_ui->cbDurationHours->setCurrentText(QString::number(duration));
|
||||
m_ui->cbParty->setCurrentIndex(m_ui->cbParty->findData(data.partyId().is_set() ? data.partyId().get() : 0));
|
||||
m_ui->cbLayingProcedure->setCurrentIndex(m_ui->cbLayingProcedure->findData(static_cast<int>(data.layingProcedureType().underlying())));
|
||||
m_ui->cbLayingMethod->setCurrentIndex(m_ui->cbLayingMethod->findData(data.isLaidHidden() ? 1 : 0));
|
||||
}
|
||||
|
||||
//slots
|
||||
|
||||
void MineAreaEdit::getPosition()
|
||||
{
|
||||
if (!has2DMap())
|
||||
return;
|
||||
|
||||
double width = m_ui->sbWidth->value();
|
||||
|
||||
int maxSegments = m_segments;
|
||||
if (m_ui->cbLayingProcedure->currentData().toInt() == AesMaLayingProcedureType_def::LptArtillery)
|
||||
maxSegments = 1;
|
||||
|
||||
// NOTE: igniterType/IgniterFunciton = 0 as long as MineAr Dialog does not contain values
|
||||
if (m_pdmDtc->isLine(m_ui->cbChargeType->currentData().toInt(),0,0))
|
||||
{
|
||||
m_sitMapGuiIfc->getPolyline(this,
|
||||
SLOT(onPolygonData(QPolygonF)),
|
||||
nullptr, 1, m_segments + 1, 0.0, 0.0,
|
||||
getCoordinatesQPointF()
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_sitMapGuiIfc->getCorridor(this,
|
||||
SLOT(onMapRecData(double,QVector<QPointF>,QPolygonF)),
|
||||
nullptr,
|
||||
s_minWidth,
|
||||
s_maxWidth,
|
||||
s_maxLength,
|
||||
maxSegments,
|
||||
m_ui->cbMineAreaInputMode->currentData().toBool(), // true == centerline, otherwise frontline
|
||||
getCoordinatesQPointF(),
|
||||
width);
|
||||
}
|
||||
}
|
||||
|
||||
void MineAreaEdit::onMapRecData(const double width, const QVector<QPointF> &polygon, const QPolygonF &bufferOutlinePolygon)
|
||||
{
|
||||
m_ui->sbWidth->setValue(std::abs(width));
|
||||
// Reverse Coordinates only if Frontline
|
||||
setCoordinates(polygon, width < 0 && !m_ui->cbMineAreaInputMode->currentData().toBool());
|
||||
m_previewPolygon = bufferOutlinePolygon;
|
||||
showPreviewObject();
|
||||
}
|
||||
|
||||
void MineAreaEdit::onPolygonData(const QPolygonF &polygon)
|
||||
{
|
||||
setCoordinates(polygon, false);
|
||||
m_previewPolygon = polygon;
|
||||
showPreviewObject();
|
||||
}
|
||||
|
||||
bool MineAreaEdit::onResetDusMines()
|
||||
{
|
||||
return m_requestHelper->startSingleRequest([this]()
|
||||
{
|
||||
return m_ftc->mineResetRequest(MineResetRequest(m_aesItem.id(), dds::core::optional<int32_t>()), this);
|
||||
});
|
||||
}
|
||||
|
||||
bool MineAreaEdit::apply()
|
||||
{
|
||||
qint64 effectStart = m_ui->dteEffectStart->msecsSinceEpoch();
|
||||
std::string name = m_ui->leIdentifier->text().toStdString();
|
||||
int chargeTypeId = m_ui->cbChargeType->currentData().toInt();
|
||||
s_lastChargeType = chargeTypeId;
|
||||
AesMaLayingProcedureType layingProcedureType = static_cast<AesMaLayingProcedureType_def::type>(m_ui->cbLayingProcedure->currentData().toInt());
|
||||
bool isLaidHidden = m_ui->cbLayingMethod->currentData().toInt() != 0;
|
||||
int partyId = m_ui->cbParty->currentData().toInt();
|
||||
int playerId = 0;
|
||||
qint64 effectDuration = m_ui->cbDurationHours->currentText().toInt() * 60 * 60 * 1000L; // h --> msecs
|
||||
double density = 0.0;
|
||||
double width = 0.0;
|
||||
if (m_ui->stackedWidget->currentWidget() == m_ui->sbDensity)
|
||||
{
|
||||
density = m_ui->sbDensity->value();
|
||||
width = m_ui->sbWidth->value();
|
||||
}
|
||||
else
|
||||
{
|
||||
density = 1.0 / m_ui->cbxDensity->currentData().toInt();
|
||||
width = 0.0;
|
||||
}
|
||||
|
||||
if (!checkSegementLengths(this))
|
||||
return false;
|
||||
|
||||
const double distance = 500.0;
|
||||
const MineAreaModifyRequest req(m_aesItem.id(), name,
|
||||
LtsUtils::toOptional(effectStart),
|
||||
effectDuration,
|
||||
m_aesItem.effectSourceId(),
|
||||
density,
|
||||
width,
|
||||
{chargeTypeId,0,0},
|
||||
getCoordinates(),
|
||||
LtsUtils::toOptional(partyId),
|
||||
LtsUtils::toOptional(playerId),
|
||||
layingProcedureType,
|
||||
isLaidHidden,
|
||||
m_ui->cbEffectMarkingInTa->isChecked(),
|
||||
m_ui->cbMineAreaInputMode->currentData().toBool(),
|
||||
distance,
|
||||
LtsUtils::toOptional(0LL),
|
||||
true // sort Mine with algorithm
|
||||
);
|
||||
|
||||
return m_requestHelper->startSingleRequest([this, req]()
|
||||
{
|
||||
return m_ftc->mineAreaModifyRequest(req, this);
|
||||
});
|
||||
}
|
||||
|
||||
void MineAreaEdit::onLayingProcedureChanged()
|
||||
{
|
||||
const bool islptArtillery = m_ui->cbLayingProcedure->currentData().toInt() == AesMaLayingProcedureType_def::LptArtillery;
|
||||
if (islptArtillery)
|
||||
m_pdmGuiIfc->setChargeTypePropertyFilter(m_ui->cbChargeType, QStringLiteral("canBeThrown"), true);
|
||||
else
|
||||
m_pdmGuiIfc->setChargeTypePropertyFilter(m_ui->cbChargeType, QStringLiteral("canBeCreated"), true);
|
||||
|
||||
if (m_ui->cbChargeType->currentIndex() < 0)
|
||||
m_ui->cbChargeType->setCurrentIndex(0);
|
||||
m_ui->cbChargeType->setEnabled(m_ui->cbChargeType->count() > 1);
|
||||
|
||||
|
||||
// adjust posEdits:
|
||||
// LptArtillery -> one segment ; LptPioneer -> 5 segments
|
||||
if (islptArtillery)
|
||||
{
|
||||
for (int i = 2; i < m_coordMap.size(); i++)
|
||||
{
|
||||
LtsCoordWidget::LtsCoordWidget *w = m_coordMap.value(i);
|
||||
w->clear();
|
||||
w->setVisible(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
onChargeTypeChanged(m_ui->cbChargeType->currentData().toInt());
|
||||
|
||||
}
|
||||
|
||||
void MineAreaEdit::onChargeTypeChanged(int index)
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
int chargeTypeId = m_ui->cbChargeType->currentData().toInt();
|
||||
DEBUG_LOG(m_logger) << "chargeType: " << chargeTypeId;
|
||||
|
||||
// NOTE: igniterType/IgniterFunciton = 0 as long as MineAr Dialog does not contain values
|
||||
m_segments = m_pdmDtc->segments(chargeTypeId,0,0);
|
||||
DEBUG_LOG(m_logger) << "segments count: " << m_segments;
|
||||
|
||||
if (m_pdmDtc->isLine(chargeTypeId,0,0))
|
||||
{
|
||||
m_ui->stackedWidget->setCurrentWidget(m_ui->cbxDensity);
|
||||
m_ui->lbDensity->setText(tr("Distance [m]"));
|
||||
m_ui->lbWidth->setVisible(false);
|
||||
m_ui->sbWidth->setVisible(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ui->stackedWidget->setCurrentWidget(m_ui->sbDensity);
|
||||
m_ui->lbDensity->setText(tr("Density"));
|
||||
m_ui->lbWidth->setVisible(true);
|
||||
m_ui->sbWidth->setVisible(true);
|
||||
}
|
||||
|
||||
DEBUG_LOG(m_logger) << "before remove: m_coordMap.size(): " << m_coordMap.size();
|
||||
int size = m_coordMap.size();
|
||||
|
||||
for (int i = m_coordMap.size(); i <= size && i > m_segments; --i)
|
||||
{
|
||||
if (m_coordMap.size() == 0)
|
||||
break;
|
||||
|
||||
LtsCoordWidget::LtsCoordWidget *w = m_coordMap.value(i - 1);
|
||||
m_ui->vLayoutCoord->removeWidget(w);
|
||||
delete w;
|
||||
m_coordMap.remove(i - 1);
|
||||
}
|
||||
|
||||
for (int i = 0; i <= m_segments; i++)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "segment: " << i;
|
||||
LtsCoordWidget::LtsCoordWidget *w;
|
||||
if (!m_coordMap.contains(i))
|
||||
w = new LtsCoordWidget::LtsCoordWidget();
|
||||
else
|
||||
w = m_coordMap.value(i);
|
||||
m_ui->vLayoutCoord->addWidget(w);
|
||||
w->setVisible(true);
|
||||
m_coordMap.insert(i, w);
|
||||
}
|
||||
DEBUG_LOG(m_logger) << "m_coordMap.size(): " << m_coordMap.size();
|
||||
}
|
||||
|
||||
void MineAreaEdit::showPreviewObject()
|
||||
{
|
||||
if (!m_sitMapGuiIfc)
|
||||
return;
|
||||
|
||||
if (m_previewPolygon.isEmpty())
|
||||
return;
|
||||
|
||||
// NOTE: igniterType/IgniterFunciton = 0 as long as MieAreaEdit does not contain values
|
||||
m_sitMapGuiIfc->displayPreviewObject(this, m_previewPolygon, !m_pdmDtc->isLine(m_ui->cbChargeType->currentData().toInt(),0,0));
|
||||
}
|
||||
|
||||
} // namespace AreaEffectSimulation
|
||||
@@ -0,0 +1,83 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* AreaEffectSimulation - MineArea Edit Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Mike Wille, SLSE, 2016-09-26
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Plugins/AreaEffectSimulation/Gui/Base/aes_base_edit.h>
|
||||
#include <Plugins/ProjectDataManagement/pdm_gui_plugin_interface.h>
|
||||
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class MineAreaEdit;
|
||||
}
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
class MineAreaEdit final
|
||||
: public BaseEdit
|
||||
, protected AreaEffectSimulation::Interface::Ftc::MineAreaModifyReplyHandler
|
||||
, protected AreaEffectSimulation::Interface::Ftc::MineResetReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MineAreaEdit(const QString &menuGroup, QWidget *parent = nullptr);
|
||||
~MineAreaEdit();
|
||||
|
||||
QString dialogIdentifier() const override
|
||||
{
|
||||
return m_aesItem.id() <= 0 ? QStringLiteral("AddMineArea") : QStringLiteral("EditMineArea%1").arg(m_aesItem.id());
|
||||
}
|
||||
bool init(int aesItemId, bool copy, LtsSession::LtsSession *session);
|
||||
|
||||
void onMineAreaModifyReply(const Core::FunctionReplyObject &replyObject) override final { onAesItemModifyReply(replyObject); }
|
||||
void onMineResetReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
|
||||
|
||||
private:
|
||||
std::vector<LtsCoordWidget::LtsCoordWidget *> coordWidgets() const override;
|
||||
void retranslate() override;
|
||||
|
||||
static constexpr double s_minWidth = 1;
|
||||
static constexpr double s_maxWidth = 250;
|
||||
static constexpr double s_stepWidth = 1;
|
||||
static constexpr double s_minDensity = 0.1;
|
||||
static constexpr double s_maxDensity = 0.9;
|
||||
static constexpr double s_stepDensity = 0.1;
|
||||
static constexpr double s_maxLength = 2500;
|
||||
static constexpr int s_maxSegments = 10;
|
||||
static constexpr int s_maxDurationHours = 96;
|
||||
|
||||
void setData(const MineArea &data, bool copy);
|
||||
void enableUiElements(bool enable) override;
|
||||
|
||||
double getMaxLength() const override { return s_maxLength; }
|
||||
|
||||
private slots:
|
||||
void getPosition();
|
||||
void onMapRecData(const double width, const QVector<QPointF> &polygon, const QPolygonF &bufferOutlinePolygon);
|
||||
void onPolygonData(const QPolygonF &polygon);
|
||||
bool onResetDusMines();
|
||||
bool apply() override final;
|
||||
void onLayingProcedureChanged();
|
||||
void showPreviewObject() override;
|
||||
void onChargeTypeChanged(int index);
|
||||
private:
|
||||
std::shared_ptr<ProjectDataManagement::ForeignGuiInterface> m_pdmGuiIfc;
|
||||
std::shared_ptr<ProjectDataManagement::Interface::Dtc> m_pdmDtc;
|
||||
std::shared_ptr<AreaEffectSimulation::Interface::Dtc> m_aesDtc;
|
||||
Ui::MineAreaEdit *m_ui;
|
||||
QMap<int, LtsCoordWidget::LtsCoordWidget*> m_coordMap;
|
||||
QPolygonF m_previewPolygon;
|
||||
int m_segments;
|
||||
};
|
||||
|
||||
} //namespace AreaEffectSimulation
|
||||
@@ -0,0 +1,431 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MineAreaEdit</class>
|
||||
<widget class="QWidget" name="MineAreaEdit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>915</width>
|
||||
<height>619</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Aes Mine Area Edit</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lbIdentifier">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Identifier:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lbChargeType">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Charge Type:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lbDensity">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="lbWidth">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Depth [m]:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="lbEffectStart">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Start:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1" colspan="2">
|
||||
<widget class="LtsWidgets::LtsDateTimeEdit" name="dteEffectStart" native="true">
|
||||
<property name="checkable" stdset="0">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="lbDuration">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Duration [h]:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="lbParty">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Party:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="LtsWidgets::LtsComboBox" name="cbParty">
|
||||
<property name="currentText">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="lbLayingMethod">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Laying Method:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<widget class="LtsWidgets::LtsComboBox" name="cbLayingProcedure">
|
||||
<property name="currentText">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="2">
|
||||
<widget class="LtsWidgets::LtsComboBox" name="cbLayingMethod">
|
||||
<property name="currentText">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::MinimumExpanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>13</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="leIdentifier">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="2">
|
||||
<widget class="LtsWidgets::LtsComboBox" name="cbChargeType">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="currentText">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" colspan="2">
|
||||
<widget class="QStackedWidget" name="stackedWidget">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="page">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QDoubleSpinBox" name="sbDensity">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="page_2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QComboBox" name="cbxDensity">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1" colspan="2">
|
||||
<widget class="QDoubleSpinBox" name="sbWidth">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1" colspan="2">
|
||||
<widget class="QComboBox" name="cbDurationHours">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="currentText">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Input Mode:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="cbMineAreaInputMode"/>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>133</width>
|
||||
<height>33</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lbGeometry">
|
||||
<property name="text">
|
||||
<string>Geometry:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QPushButton" name="pbPosition">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/style/position.svg</normaloff>:/style/position.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<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>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<spacer name="verticalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QCheckBox" name="cbEffectMarkingInTa">
|
||||
<property name="text">
|
||||
<string>Fire marker</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" rowspan="5" colspan="2">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="vLayoutCoord"/>
|
||||
</item>
|
||||
<item>
|
||||
<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>
|
||||
<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="QPushButton" name="pbResetDusMines">
|
||||
<property name="toolTip">
|
||||
<string>Reset all DUS Mines matched to this Minearea</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Reset DUS Mines</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LtsWidgets::LtsComboBox</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header>LtsWidgets/lts_combo_box.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>leIdentifier</tabstop>
|
||||
<tabstop>cbChargeType</tabstop>
|
||||
<tabstop>dteEffectStart</tabstop>
|
||||
<tabstop>cbDurationHours</tabstop>
|
||||
<tabstop>cbParty</tabstop>
|
||||
<tabstop>cbLayingProcedure</tabstop>
|
||||
<tabstop>cbLayingMethod</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,95 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Gui Plugin for AreaEffectSimuation - MineAreas
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Mike Wille, SLSE, 2016-09-26
|
||||
*/
|
||||
|
||||
#include "aes_mine_area_gui_plugin.h"
|
||||
#include "aes_mine_area_list.h"
|
||||
#include "aes_mine_area_edit.h"
|
||||
|
||||
#include <AreaEffectSimulation/aes_operator_rights.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsUtilsSettings/settings.h>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
std::shared_ptr<GuiPluginBase::Interface> GuiPlugin::createGuiInterface(LtsSession::LtsSession *session)
|
||||
{
|
||||
return std::make_shared<InterfaceImpl>(session);
|
||||
}
|
||||
|
||||
InterfaceImpl::InterfaceImpl(LtsSession::LtsSession *session)
|
||||
: AesBaseInterface(session, getLogger("Plugins.Gui.MineArea"))
|
||||
, ForeignGuiInterface()
|
||||
{}
|
||||
|
||||
QVector<LtsWidgets::PluginData> InterfaceImpl::getActions()
|
||||
{
|
||||
QVector<LtsWidgets::PluginData> ret;
|
||||
|
||||
LtsUtils::ProjectSettings *ps = LtsUtils::ProjectSettings::getInstance();
|
||||
const bool enableMineAreas = ps->value(QStringLiteral("aes"),
|
||||
QStringLiteral("enableMineAreas")).toBool();
|
||||
|
||||
if (enableMineAreas)
|
||||
{
|
||||
// Mine-Area
|
||||
ret.append(LtsWidgets::PluginData(menuGroup(),
|
||||
tr("Mine Areas"),
|
||||
QLatin1String("ListMineAreas"),
|
||||
QIcon(QLatin1String("icon:mine_barriers.svg")),
|
||||
[this](QWidget *parent) { return onShowMineAreaListDialog(parent);},
|
||||
OperatorRights::MineAreasShow,
|
||||
LtsWidgets::ExercisePart::eExecution));
|
||||
|
||||
|
||||
if (m_session->isExercisePartition() && appId() != LtsAppDescriptor::App::OC)
|
||||
ret.append(LtsWidgets::PluginData(menuGroup(),
|
||||
tr("Add Mine Area"),
|
||||
QLatin1String("AddMineArea"),
|
||||
QIcon(QLatin1String("icon:mine_barriers_add.svg")),
|
||||
[this](QWidget *parent) { return onShowAddMineAreaDialog(parent);},
|
||||
OperatorRights::MineAreasEdit,
|
||||
LtsWidgets::ExercisePart::eExecution,
|
||||
LtsWidgets::ExerciseState::eCreated | LtsWidgets::ExerciseState::eStarted | LtsWidgets::ExerciseState::ePaused));
|
||||
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
AreaEffectSimulation::BaseEdit *InterfaceImpl::showEditWindow(int aesEntityId, QWidget *parent)
|
||||
{
|
||||
MineAreaEdit *editWidget = new MineAreaEdit(menuGroup(), parent);
|
||||
if (editWidget->init(aesEntityId, false, m_session))
|
||||
return editWidget;
|
||||
|
||||
delete editWidget;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
LtsWidgets::LtsDialog *InterfaceImpl::onShowAddMineAreaDialog(QWidget *parent)
|
||||
{
|
||||
MineAreaEdit *editWidget = new MineAreaEdit(menuGroup(), parent);
|
||||
if (editWidget->init(0, false, m_session))
|
||||
return editWidget;
|
||||
|
||||
delete editWidget;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
LtsWidgets::LtsDialog *InterfaceImpl::onShowMineAreaListDialog(QWidget *parent)
|
||||
{
|
||||
MineAreaList *listWidget = new MineAreaList(menuGroup(), parent);
|
||||
if (listWidget->init(m_session))
|
||||
return listWidget;
|
||||
|
||||
delete listWidget;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} // namespace AreaEffectSimulation
|
||||
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Gui Plugin for AreaEffectSimuation - MineAreas
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Mike Wille, SLSE, 2016-09-26
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Plugins/AreaEffectSimulation/Gui/Base/aes_base_gui_plugin.h>
|
||||
#include "aes_mine_area_gui_plugin_interface.h"
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
class GuiPlugin final : public AesBaseGuiPlugin
|
||||
{
|
||||
Q_PLUGIN_METADATA(IID "gui:3:aes.mineareas")
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GuiPlugin() = default;
|
||||
~GuiPlugin() = default;
|
||||
|
||||
QString pluginName() override { return QStringLiteral("AreaEffectSimuationMineAreaGui"); }
|
||||
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 AesMineArea::ForeignGuiInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit InterfaceImpl(LtsSession::LtsSession *session);
|
||||
QString menuGroup() const override final { return tr("Area Effect Simulation Mines"); } //We are now in a different Menugroup!
|
||||
|
||||
QVector<LtsWidgets::PluginData> getActions() override;
|
||||
|
||||
AreaEffectSimulation::BaseEdit *showEditWindow(int aesEntityId, QWidget *parent) override;
|
||||
private:
|
||||
LtsWidgets::LtsDialog *onShowAddMineAreaDialog(QWidget *parent);
|
||||
LtsWidgets::LtsDialog *onShowMineAreaListDialog(QWidget *parent);
|
||||
|
||||
};
|
||||
|
||||
} // namespace AreaEffectSimulation
|
||||
+29
@@ -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 AesMineArea
|
||||
{
|
||||
class ForeignGuiInterface
|
||||
{
|
||||
public:
|
||||
ForeignGuiInterface() = default;
|
||||
virtual ~ForeignGuiInterface() = default;
|
||||
|
||||
virtual AreaEffectSimulation::BaseEdit *showEditWindow(int aesEntityId, QWidget *parent) = 0;
|
||||
};
|
||||
} // namespace AesMineArea
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* AreaEffectSimulation - MineArea Overview Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Mike Wille, SLSE, 2016-09-26
|
||||
*/
|
||||
|
||||
#include "aes_mine_area_list.h"
|
||||
#include "aes_mine_areas_model.h"
|
||||
#include "aes_mine_area_edit.h"
|
||||
#include "CustomView/aes_mine_area.h"
|
||||
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <LtsUtilsSettings/settings.h>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
bool MineAreaList::init(LtsSession::LtsSession *session)
|
||||
{
|
||||
if (!AesItemList::init(session))
|
||||
return false;
|
||||
|
||||
m_bHasAddEditOperatorRights = LtsSessionData::LtsSessionData::getInstance()->hasOperatorRight(OperatorRights::MineAreasEdit);
|
||||
|
||||
setDataViewModel(m_model, [this]() { return new CustomViewMineArea(this); });
|
||||
|
||||
#ifndef LTS_DEBUG
|
||||
hideColumn(MineAreasModel::BcId);
|
||||
#endif
|
||||
hideColumn(MineAreasModel::BcParticipant);
|
||||
|
||||
setSortIndicator(MineAreasModel::BcName);
|
||||
|
||||
enaDisa();
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Mine_Areas"));
|
||||
|
||||
LtsUtils::ProjectSettings *ps = LtsUtils::ProjectSettings::getInstance();
|
||||
const bool enableGuezDusMines = ps->value(QStringLiteral("aes"),
|
||||
QStringLiteral("enableGuezDusMines")).toBool();
|
||||
if (enableGuezDusMines &&
|
||||
LtsSessionData::LtsSessionData::getInstance()->hasOperatorRight(OperatorRights::MineAreasResetDusMines))
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Import, this, &MineAreaList::slotReactivate);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MineAreaList::slotReactivate()
|
||||
{
|
||||
return m_requestHelper->startSingleRequest([this]() {
|
||||
const int aesItemId = 0;
|
||||
return m_ftc->mineResetRequest(MineResetRequest(aesItemId, dds::core::optional<int32_t>()), this);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
void MineAreaList::createModel()
|
||||
{
|
||||
m_model = new AesItemSortFilterProxyModelTmpl<MineArea>(m_session, this);
|
||||
|
||||
MineAreasModel *sourceModel = new MineAreasModel(this);
|
||||
m_model->setSourceModel(sourceModel);
|
||||
sourceModel->initModel(m_session);
|
||||
}
|
||||
|
||||
void MineAreaList::onAddAesItem()
|
||||
{
|
||||
MineAreaEdit *dialog = new MineAreaEdit(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 MineAreaList::onEditAesItem()
|
||||
{
|
||||
const int aesItemId = model()->aesId(currentRow());
|
||||
|
||||
if (aesItemId <= 0)
|
||||
return;
|
||||
|
||||
DEBUG_LOG(m_logger) << "current Aes Item Id: " << aesItemId;
|
||||
|
||||
MineAreaEdit *dialog = new MineAreaEdit(m_menuGroup, this);
|
||||
if (dialog->init(aesItemId, false, m_session))
|
||||
addDialog(dialog, m_menuGroup, dialog->dialogIdentifier(), LtsWidgets::LayoutArea::eDialogTab);
|
||||
else
|
||||
delete dialog;
|
||||
}
|
||||
|
||||
void MineAreaList::onRemoveAesItem()
|
||||
{
|
||||
const int aesItemId = model()->aesId(currentRow());
|
||||
Core::RemoveElementRequest req(aesItemId);
|
||||
m_requestHelper->startSingleRequest([req, this]()
|
||||
{
|
||||
return m_ftc->mineAreaRemoveRequest(req, this);
|
||||
});
|
||||
}
|
||||
|
||||
void MineAreaList::retranslate()
|
||||
{
|
||||
translateBase(tr("Mine Areas"));
|
||||
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Import)->setText(tr("Reactivate / hide all DUS mines"));
|
||||
}
|
||||
|
||||
void MineAreaList::onMineAreaRemoveReply(const Core::FunctionReplyObject &replyObject)
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
} // namespace AreaEffectSimulation
|
||||
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* AreaEffectSimulation - MineArea Overview Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Mike Wille, SLSE, 2016-09-26
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Plugins/AreaEffectSimulation/Gui/Base/aes_itemlist.h>
|
||||
#include <Plugins/AreaEffectSimulation/Gui/Base/aes_base_model.h>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
class MineAreaList final : public AesItemListTmpl<MineArea>
|
||||
, protected AreaEffectSimulation::Interface::Ftc::MineAreaRemoveReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
using AesItemListTmpl<MineArea>::AesItemListTmpl;
|
||||
|
||||
bool init(LtsSession::LtsSession *session) override;
|
||||
|
||||
private slots:
|
||||
void onAddAesItem() override;
|
||||
void onEditAesItem() override;
|
||||
void onRemoveAesItem() override;
|
||||
bool slotReactivate();
|
||||
|
||||
private:
|
||||
void createModel() override;
|
||||
void retranslate() override;
|
||||
void onMineAreaRemoveReply(const Core::FunctionReplyObject &replyObject) override;
|
||||
};
|
||||
} // namespace AreaEffectSimulation
|
||||
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* AreaEffectManangement - MineArea Overview Dialog Model
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Mike Wille, SLSE, 2016-09-26
|
||||
*/
|
||||
|
||||
#include "aes_mine_areas_model.h"
|
||||
#include <QLocale>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
|
||||
MineAreasModel::MineAreasModel(QObject *parent)
|
||||
: AesGuiBaseModel<MineArea>(parent, {tr("Depth")})
|
||||
{}
|
||||
|
||||
bool MineAreasModel::initModel(LtsSession::LtsSession *session)
|
||||
{
|
||||
if (!AesGuiBaseModel::initModel(session))
|
||||
return false;
|
||||
|
||||
connect(m_aesDtc.get(), &Interface::Dtc::mineAreaChanged,
|
||||
this, &MineAreasModel::onDataChanged);
|
||||
m_aesDtc->mineAreas([this](const MineArea &item) { insertRow(item);});
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
QVariant MineAreasModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!indexIsValid(index))
|
||||
return QVariant();
|
||||
|
||||
const MineArea &mine = getRowData(index.row());
|
||||
|
||||
if (index.column() < cntBaseColumns())
|
||||
return AesGuiBaseModel::data(mine, index.column(), role);
|
||||
|
||||
if (role != Qt::DisplayRole)
|
||||
return QVariant();
|
||||
|
||||
switch (index.column())
|
||||
{
|
||||
case ColWidth:
|
||||
return QLocale().toString(mine.width(), 'f', 2);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
} // namespace AreaEffectSimulation
|
||||
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* AreaEffectManangement - MineArea Overview Dialog Model
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Mike Wille, SLSE, 2016-09-26
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Plugins/AreaEffectSimulation/Gui/Base/aes_base_model.h>
|
||||
|
||||
namespace LtsSession
|
||||
{
|
||||
class LtsSession;
|
||||
}
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
class MineAreasModel : public AesGuiBaseModel<MineArea>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum AdditionalColumns {ColWidth = BcCount};
|
||||
explicit MineAreasModel(QObject *parent = nullptr);
|
||||
|
||||
bool initModel(LtsSession::LtsSession *session) override;
|
||||
|
||||
QVariant data(const QModelIndex &, int) const override final;
|
||||
};
|
||||
|
||||
} //namespace AreaEffectSimulation
|
||||
Reference in new issue
Block a user