Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
@@ -0,0 +1,53 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
# Created by hjl, SLSE, 2017-06-06
|
||||
#
|
||||
|
||||
ADD_INTERFACE_LIBRARY(
|
||||
AesBorderlineGuiPluginInterface
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/aes_borderline_gui_plugin_interface.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/..
|
||||
)
|
||||
|
||||
|
||||
SET(aes_borderline_gui_SRCS
|
||||
aes_borderline_gui_plugin.h
|
||||
aes_borderline_gui_plugin.cpp
|
||||
aes_borderline_list.h
|
||||
aes_borderline_list.cpp
|
||||
aes_borderlines_model.h
|
||||
aes_borderlines_model.cpp
|
||||
aes_borderline_edit.h
|
||||
aes_borderline_edit.cpp
|
||||
CustomView/aes_borderline.h
|
||||
CustomView/aes_borderline.cpp
|
||||
)
|
||||
|
||||
NGL_WRAP_UI(aes_borderline_gui_SRCS
|
||||
aes_borderline_edit.ui
|
||||
CustomView/aes_borderline.ui
|
||||
)
|
||||
|
||||
NGL_ADD_LIBRARY(WS AesBorderlineGuiPlugin MODULE ${aes_borderline_gui_SRCS})
|
||||
NGL_TARGET_LINK_LIBRARIES(AesBorderlineGuiPlugin
|
||||
AesBaseGui
|
||||
AesBorderlineGuiPluginInterface
|
||||
ngltools
|
||||
AesDataPluginInterface
|
||||
PdmGuiPluginInterface
|
||||
AesInfoGuiPluginInterface
|
||||
FlmDataPluginInterface
|
||||
NGLLogger
|
||||
Qt5::Widgets
|
||||
LtsWidgets
|
||||
LtsSession
|
||||
LtsSessionData
|
||||
LtsDataView
|
||||
SituationMapGuiPluginInterface
|
||||
LtsUtilsGuiDds
|
||||
LtsUtilsSettings
|
||||
)
|
||||
|
||||
NGL_INSTALL_TARGET(AesBorderlineGuiPlugin)
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* CustomView for AES Borderline
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2017-06-20
|
||||
*/
|
||||
|
||||
#include "aes_borderline.h"
|
||||
#include "ui_aes_borderline.h"
|
||||
|
||||
#include "aes_borderlines_model.h"
|
||||
#include <Services/AreaEffectSimulation/Utils/polygons.h>
|
||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
CustomViewBorderline::CustomViewBorderline(QWidget *parent)
|
||||
: AbstractDisplayWidget(parent)
|
||||
, m_ui(new Ui::CustomViewBorderline)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
}
|
||||
|
||||
CustomViewBorderline::~CustomViewBorderline()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
bool CustomViewBorderline::init(const QModelIndex &idx)
|
||||
{
|
||||
if (idx.isValid())
|
||||
return false;
|
||||
|
||||
m_ui->lblName->setText(rowData(idx, AreaEffectSimulation::BorderlinesModel::BcName).toString());
|
||||
m_ui->lblIcon->clear();
|
||||
m_ui->lblIcon->setAutoFillBackground(true);
|
||||
|
||||
const AesItemSortFilterProxyModel *sfpm = qobject_cast<const AesItemSortFilterProxyModel*>(idx.model());
|
||||
if (!sfpm)
|
||||
return false;
|
||||
const BorderlinesModel *aesModel = qobject_cast<const BorderlinesModel*>(sfpm->sourceModel());
|
||||
if (!aesModel)
|
||||
return false;
|
||||
const auto srcIdx = sfpm->mapToSource(idx);
|
||||
Borderline bLine = aesModel->getRowData(srcIdx.row());
|
||||
calculateIcon(bLine, sfpm->partyColor(idx.row()));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CustomViewBorderline::calculateIcon(const AreaEffectSimulation::Borderline &line, const QColor &color)
|
||||
{
|
||||
if (line.segments().size() == 0)
|
||||
return false;
|
||||
|
||||
QVector<QPointF> segments;
|
||||
segments.reserve(line.segments().size());
|
||||
int setZone = -1;
|
||||
for (const Core::GeoPosition2D &s : line.segments())
|
||||
{
|
||||
const LtsCoordTrans::UtmCoordinate coord(LtsCoordTrans::UtmCoordinate::fromGeographic(s.lon(), s.lat(), setZone));
|
||||
if (setZone < 0)
|
||||
setZone = coord.zone;
|
||||
segments.append(QPointF(coord.x, coord.y));
|
||||
}
|
||||
|
||||
QPolygonF poly = AreaEffectSimulation::Polygons::borderline(segments);
|
||||
Qt::BrushStyle bStyle = Qt::BrushStyle::NoBrush;
|
||||
const auto pix = Polygons::pixmapFromPolygon(poly, color, ICON_RESOLUTION, bStyle, true);
|
||||
m_ui->lblIcon->setPixmap(pix);
|
||||
|
||||
return true;
|
||||
}
|
||||
} // namespace AreaEffectSimulation
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* CustomView for AES Borderline
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2017-06-20
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <Viewer/LtsDataView/abstract_display_widget.h>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class CustomViewBorderline;
|
||||
}
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
class Borderline;
|
||||
class CustomViewBorderline final : public LtsDataView::AbstractDisplayWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CustomViewBorderline(QWidget *parent = nullptr);
|
||||
~CustomViewBorderline();
|
||||
bool init(const QModelIndex &idx) override final;
|
||||
|
||||
private:
|
||||
bool calculateIcon(const AreaEffectSimulation::Borderline &line, const QColor &color);
|
||||
|
||||
Ui::CustomViewBorderline *m_ui;
|
||||
|
||||
};
|
||||
} // namespace AreaEffectSimulation
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CustomViewBorderline</class>
|
||||
<widget class="QWidget" name="CustomViewBorderline">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>350</width>
|
||||
<height>200</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="lblName">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">Name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="AreaEffectSimulation::PixmapLabel" name="lblIcon">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">icon</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>AreaEffectSimulation::PixmapLabel</class>
|
||||
<extends>QLabel</extends>
|
||||
<header>AreaEffectSimulation/Gui/Base/aes_pixmap_label.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,364 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for AreaEffectSimulation - Borderline Add/Edit Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2017-06-20
|
||||
*/
|
||||
|
||||
#include "aes_borderline_edit.h"
|
||||
#include "ui_aes_borderline_edit.h"
|
||||
|
||||
#include <Plugins/AreaEffectSimulation/aes_data_plugin_interface.h>
|
||||
#include <Plugins/SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
|
||||
#include <LtsWidgets/lts_message_dialog.h>
|
||||
#include <FileManagement/flm_translation.h>
|
||||
|
||||
#include <QJsonObject>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonArray>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
BorderlineEdit::BorderlineEdit(const QString &menuGroup, QWidget *parent)
|
||||
: BaseEdit(menuGroup, QLatin1String("BorderlineEdit"), parent)
|
||||
, m_ui(new Ui::BorderlineEdit)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
// ???
|
||||
m_uiRequirements->addRequirement({m_ui->lblGeometry, [this]() { return (!m_ui->positionEdit_1->coordinate().isNull() &&
|
||||
!m_ui->positionEdit_2->coordinate().isNull()
|
||||
); }});
|
||||
m_uiRequirements->addRequirement({m_ui->lblIdentifier, [this]() { return (!m_ui->leIdentifier->text().isEmpty()); }});
|
||||
|
||||
connect(m_ui->pbClear, &QPushButton::clicked, this, &BorderlineEdit::clearCoordinates);
|
||||
|
||||
#ifndef LTS_DEBUG
|
||||
m_ui->lblBorderlineId->hide();
|
||||
m_ui->lbBorderlineId->hide();
|
||||
#endif
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Add_Borderline"));
|
||||
|
||||
enaDisa(); // does nothing
|
||||
} // end of ctor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
BorderlineEdit::~BorderlineEdit()
|
||||
{
|
||||
delete m_ui;
|
||||
} // end of dtor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
std::vector<LtsCoordWidget::LtsCoordWidget *> BorderlineEdit::coordWidgets() const
|
||||
{
|
||||
return {m_ui->positionEdit_1,
|
||||
m_ui->positionEdit_2,
|
||||
m_ui->positionEdit_3,
|
||||
m_ui->positionEdit_4,
|
||||
m_ui->positionEdit_5,
|
||||
m_ui->positionEdit_6,
|
||||
m_ui->positionEdit_7,
|
||||
m_ui->positionEdit_8,
|
||||
m_ui->positionEdit_9,
|
||||
m_ui->positionEdit_10,
|
||||
m_ui->positionEdit_11};
|
||||
} // end of retranslate()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void BorderlineEdit::retranslate()
|
||||
{
|
||||
translate(m_ui, m_aesItem, tr("Borderline"));
|
||||
} // end of retranslate()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void BorderlineEdit::enableUiElements(bool enable)
|
||||
{
|
||||
|
||||
m_ui->leIdentifier->setMaxLength(30);
|
||||
m_ui->pbPosition->setEnabled(m_sitMapGuiIfc && enable);
|
||||
enabledCoordinates(enable);
|
||||
m_ui->cbParty->setEnabled(enable);
|
||||
m_ui->pbClear->setEnabled(enable);
|
||||
|
||||
|
||||
m_ui->leIdentifier->setEnabled(enable || isOnlyNameModifiable());
|
||||
if (m_aesItem.effectStateId() == AesEffectState_def::EsExpired)
|
||||
{
|
||||
m_ui->leIdentifier->setText(QString::fromStdString(m_aesItem.name()));
|
||||
__unchange__();
|
||||
}
|
||||
if (m_aesItem.effectStateId() == AesEffectState_def::EsActivated)
|
||||
{
|
||||
QString name = m_ui->leIdentifier->text();
|
||||
auto baseData = m_dtc->borderline(m_aesItem.id());
|
||||
setData(baseData, false);
|
||||
__unchange__();
|
||||
if (name != m_ui->leIdentifier->text())
|
||||
m_ui->leIdentifier->setText(name);
|
||||
}
|
||||
|
||||
|
||||
} // end of enableUiElements()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool BorderlineEdit::init(int aesItemId, bool copy, LtsSession::LtsSession *session)
|
||||
{
|
||||
if (!BaseEdit::init(aesItemId, session))
|
||||
return false;
|
||||
|
||||
bool editable = LtsSessionData::LtsSessionData::getInstance()->hasOperatorRight(OperatorRights::BorderlinesEdit) ||
|
||||
m_session->app() == LtsAppDescriptor::App::OC;
|
||||
bool readable = LtsSessionData::LtsSessionData::getInstance()->hasOperatorRight(OperatorRights::BorderlinesShow);
|
||||
|
||||
|
||||
if (!readable && !editable)
|
||||
return false;
|
||||
|
||||
if (m_sitMapGuiIfc)
|
||||
connect(m_ui->pbPosition, &QPushButton::clicked, this, &BorderlineEdit::onGetPolyline);
|
||||
else
|
||||
m_ui->pbPosition->setEnabled(false);
|
||||
|
||||
m_ppmGuiCbxIfc->fillPartyComboBox(m_ui->cbParty);
|
||||
|
||||
if (aesItemId > 0)
|
||||
{
|
||||
auto baseData = m_dtc->borderline(aesItemId);
|
||||
setData(baseData, copy);
|
||||
}
|
||||
|
||||
enableUiElements(editable && isModifiable() && !isOnlyNameModifiable());
|
||||
|
||||
connect(m_dtc.get(), &AreaEffectSimulation::Interface::Dtc::borderlineChanged,
|
||||
this, &BaseEdit::onAreaChanged);
|
||||
|
||||
// Save/Load from Library Button
|
||||
m_buttonBox->connectLibraryButton(this,
|
||||
&BorderlineEdit::onImportButtonClicked,
|
||||
&BorderlineEdit::onExportButtonClicked);
|
||||
|
||||
if (!session->getForeignGuiInterface<FileManagement::ForeignGuiInterface>(m_flmGui))
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Library, false);
|
||||
|
||||
return true;
|
||||
|
||||
} // end of init()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void BorderlineEdit::setData(const Borderline &borderline, bool copy)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION << "borderlineId: " << borderline.id()
|
||||
<< " operatorId: " << borderline.operatorId();
|
||||
|
||||
m_aesItem = borderline;
|
||||
if (copy)
|
||||
{
|
||||
m_aesItem.id(0);
|
||||
m_aesItem.effectStateId(AreaEffectSimulation::AesEffectState_def::get_default());
|
||||
}
|
||||
m_ui->leIdentifier->setText(QString::fromStdString(borderline.name()));
|
||||
if ( borderline.partyId().is_set())
|
||||
m_ui->cbParty->setCurrentIndex(m_ui->cbParty->findData(borderline.partyId().get()));
|
||||
m_ui->lbBorderlineId->setText(QString::number(borderline.id()));
|
||||
|
||||
if (borderline.operatorId() > 0)
|
||||
m_ui->cbLocalBorderline->setChecked(true);
|
||||
else
|
||||
m_ui->cbLocalBorderline->setChecked(false);
|
||||
|
||||
setCoordinates(borderline.segments());
|
||||
} // end of setData()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void BorderlineEdit::onGetPolyline()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION;
|
||||
|
||||
if (!has2DMap())
|
||||
return;
|
||||
|
||||
QPolygonF coordinates = getCoordinatesQPointF();
|
||||
|
||||
m_sitMapGuiIfc->getPolyline(this,
|
||||
SLOT(onPolylineData(QPolygonF)),
|
||||
nullptr,
|
||||
2,
|
||||
11,
|
||||
-1,
|
||||
-1,
|
||||
coordinates);
|
||||
|
||||
} // end of onGetPolyline()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void BorderlineEdit::onPolylineData(const QPolygonF &polyline)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION << " numberOfPoints: " << polyline.size();
|
||||
|
||||
if (polyline.size() < 2)
|
||||
return;
|
||||
|
||||
m_previewPolygon = polyline;
|
||||
|
||||
// Don't reverse Polyline
|
||||
setCoordinates(polyline, false);
|
||||
|
||||
showPreviewObject();
|
||||
|
||||
}// end of onPolylineData()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void BorderlineEdit::showPreviewObject()
|
||||
{
|
||||
if (!m_sitMapGuiIfc)
|
||||
return;
|
||||
|
||||
if (m_previewPolygon.isEmpty())
|
||||
return;
|
||||
|
||||
m_sitMapGuiIfc->displayPreviewObject(this, m_previewPolygon, false);
|
||||
}
|
||||
|
||||
bool BorderlineEdit::apply()
|
||||
{
|
||||
const int operatorId = (m_ui->cbLocalBorderline->isChecked() ?
|
||||
LtsSessionData::LtsSessionData::getInstance()->getOperatorId() :
|
||||
0);
|
||||
|
||||
const BorderlineModifyRequest req(m_aesItem.id(),
|
||||
operatorId,
|
||||
m_ui->cbParty->currentData().toInt(),
|
||||
m_ui->leIdentifier->text().toStdString(),
|
||||
getCoordinates());
|
||||
DEBUG_LOG(m_logger) << "modifyBorderline: " << req;
|
||||
|
||||
m_requestHelper->addRequest([this, req]()
|
||||
{
|
||||
return m_ftc->borderlineModifyRequest(req, this);
|
||||
});
|
||||
|
||||
return m_requestHelper->startRequests();
|
||||
|
||||
} // end of apply()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
QByteArray BorderlineEdit::borderlineToJson()
|
||||
{
|
||||
QJsonArray arrSeg;
|
||||
const int operatorId = (m_ui->cbLocalBorderline->isChecked() ?
|
||||
LtsSessionData::LtsSessionData::getInstance()->getOperatorId() :
|
||||
0);
|
||||
|
||||
QJsonObject obj;
|
||||
obj[QStringLiteral("XmlType")] = FileManagement::toString(FileManagement::XmlType::AESBorderlineEdit);
|
||||
obj[QStringLiteral("id")] = m_aesItem.id();
|
||||
obj[QStringLiteral("operatorId")] = operatorId;
|
||||
obj[QStringLiteral("cbParty")] = m_ui->cbParty->currentData().toInt();
|
||||
obj[QStringLiteral("leIdentifier")] = m_ui->leIdentifier->text();
|
||||
|
||||
arrSeg = {};
|
||||
const auto segments = getCoordinates();
|
||||
for (const Core::GeoPosition2D &segment : segments)
|
||||
{
|
||||
QJsonObject innerSeg;
|
||||
innerSeg[QStringLiteral("lat")] = segment.lat();
|
||||
innerSeg[QStringLiteral("lon")] = segment.lon();
|
||||
|
||||
arrSeg += innerSeg;
|
||||
}
|
||||
obj[QStringLiteral("segments")] = arrSeg;
|
||||
QJsonDocument doc(obj);
|
||||
return doc.toJson(QJsonDocument::Compact);
|
||||
|
||||
}
|
||||
|
||||
Borderline BorderlineEdit::jsonToBorderline(const QByteArray &content)
|
||||
{
|
||||
Borderline borderline;
|
||||
// already checked that content is not empty, is parseable and contains the proper XmlType (AESBorderlineEdit)
|
||||
const QJsonDocument doc(QJsonDocument::fromJson(content));
|
||||
const QJsonObject obj(doc.object());
|
||||
|
||||
borderline.chargeStruct().chargeTypeId(obj[QStringLiteral("chargeTypeId")].toInt());
|
||||
borderline.effectDuration(obj[QStringLiteral("effectDuration")].toDouble());
|
||||
borderline.effectMarkingInTa(obj[QStringLiteral("effectMarkingInTa")].toInt());
|
||||
borderline.effectStart(obj[QStringLiteral("effectStart")].toDouble());
|
||||
int effectStateId = obj[QStringLiteral("effectStateId")].toInt();
|
||||
borderline.effectStateId(static_cast<AreaEffectSimulation::AesEffectState::inner_enum>(effectStateId));
|
||||
borderline.operatorId(obj[QStringLiteral("operatorId")].toInt());
|
||||
borderline.id(0);
|
||||
borderline.name(obj[QStringLiteral("leIdentifier")].toString().toStdString());
|
||||
if (obj.contains(QStringLiteral("participantId")) )
|
||||
borderline.participantId(obj[QStringLiteral("participantId")].toDouble());
|
||||
if (obj.contains(QStringLiteral("partyId")) )
|
||||
borderline.partyId(obj[QStringLiteral("partyId")].toDouble());
|
||||
borderline.sampleTime(obj[QStringLiteral("sampleTime")].toDouble());
|
||||
|
||||
//Start segments
|
||||
const QJsonArray arrSeg = (obj.value(QStringLiteral("segments")).toArray());
|
||||
borderline.segments().reserve(arrSeg.size());
|
||||
for (const auto &ele : arrSeg)
|
||||
{
|
||||
const QJsonObject objSeg(ele.toObject());
|
||||
Core::GeoPosition2D segment;
|
||||
segment.lat(objSeg[QStringLiteral("lat")].toDouble());
|
||||
segment.lon(objSeg[QStringLiteral("lon")].toDouble());
|
||||
borderline.segments().push_back(std::move(segment));
|
||||
}
|
||||
//End segments
|
||||
|
||||
return borderline;
|
||||
}
|
||||
|
||||
void BorderlineEdit::onExportButtonClicked()
|
||||
{
|
||||
QByteArray byteArray = borderlineToJson();
|
||||
int fileId = m_flmGui->saveFileContent(this, FileManagement::FileType::Xml, m_session->exerciseId(), byteArray);
|
||||
if (fileId > 0)
|
||||
DEBUG_LOG(m_logger) << "Saved file with id = " << fileId;
|
||||
else
|
||||
ERROR_LOG(m_logger) << "Could not save file in library ";
|
||||
}
|
||||
|
||||
void BorderlineEdit::onImportButtonClicked()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << " onImportButtonClicked() ";
|
||||
|
||||
QByteArray content;
|
||||
int fileId = m_flmGui->loadFileContent(this, content, {FileManagement::FileType::Xml}, m_session->exerciseId(), FileManagement::toString(FileManagement::XmlType::AESBorderlineEdit));
|
||||
if (fileId > 0)
|
||||
{
|
||||
if (!m_flmGui->isXmlType(content, FileManagement::toString(FileManagement::XmlType::AESBorderlineEdit)))
|
||||
{
|
||||
QHash<LtsWidgets::Button, QString> texts({{LtsWidgets::Button::Yes, tr("Ok")}});
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this,
|
||||
tr("Invalid xml file content"),
|
||||
windowTitle(),
|
||||
LtsWidgets::Behaviour::Modal,
|
||||
LtsWidgets::Button::Yes,
|
||||
texts);
|
||||
}
|
||||
else
|
||||
{
|
||||
Borderline borderline = jsonToBorderline(content);
|
||||
setData( borderline, true);
|
||||
setCoordinates(borderline.segments());
|
||||
QPolygonF coordinates = getCoordinatesQPointF();
|
||||
|
||||
onPolylineData(coordinates);
|
||||
showPreviewObject();
|
||||
INFO_LOG(m_logger) << "--- onImportButtonClicked() ";
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
} // namespace AreaEffectSimulation
|
||||
@@ -0,0 +1,82 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for AreaEffectSimulation - Borderline Add/Edit Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2017-06-20
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Plugins/AreaEffectSimulation/Gui/Base/aes_base_edit.h>
|
||||
#include <AreaEffectSimulation/aes_ftc.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <Plugins/FileManagement/flm_explorer_gui_plugin_interface.h>
|
||||
|
||||
//#include <LtsWidgets/lts_dialog.h>
|
||||
//#include <LtsSession/lts_session.h>
|
||||
//#include <LtsUtilsGuiDds/request_helper.h>
|
||||
|
||||
//#include <AreaEffectSimulation/aes_dtc.h>
|
||||
//#include <AreaEffectSimulation/aes_ftc.h>
|
||||
//#include <AreaEffectSimulation/logger.h>
|
||||
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class BorderlineEdit;
|
||||
}
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
class BorderlineEdit final
|
||||
: public BaseEdit
|
||||
, protected AreaEffectSimulation::Interface::Ftc::BorderlineModifyReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit BorderlineEdit(const QString &menuGroup, QWidget *parent = nullptr);
|
||||
~BorderlineEdit();
|
||||
|
||||
QString dialogIdentifier() const override
|
||||
{
|
||||
return m_aesItem.id() <= 0 ? QStringLiteral("AddBorderline") : QStringLiteral("EditBorderline%1").arg(m_aesItem.id());
|
||||
}
|
||||
bool init(int aesItemId, bool copy, LtsSession::LtsSession *session);
|
||||
|
||||
|
||||
//virtual functions from ExerciseEventManagement::Interface::Ftc
|
||||
void onBorderlineModifyReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
|
||||
|
||||
|
||||
private:
|
||||
std::vector<LtsCoordWidget::LtsCoordWidget *> coordWidgets() const override;
|
||||
void retranslate() override;
|
||||
void enableUiElements(bool enable) override;
|
||||
|
||||
void setData(const Borderline &borderline, bool copy);
|
||||
QByteArray borderlineToJson();
|
||||
Borderline jsonToBorderline(const QByteArray &content);
|
||||
|
||||
private slots:
|
||||
void onGetPolyline();
|
||||
void onPolylineData(const QPolygonF &polyline); // callback for onGetPolyline()
|
||||
void onExportButtonClicked();
|
||||
void onImportButtonClicked();
|
||||
|
||||
/**
|
||||
* Override the accept function from LtsDialog to save a modified edit dialog when the widget is closed.
|
||||
*/
|
||||
bool apply() override;
|
||||
void showPreviewObject() override;
|
||||
|
||||
private:
|
||||
Ui::BorderlineEdit *m_ui;
|
||||
QPolygonF m_previewPolygon;
|
||||
std::shared_ptr<FileManagement::ForeignGuiInterface> m_flmGui;
|
||||
};
|
||||
|
||||
} // namespace AreaEffectSimulation
|
||||
@@ -0,0 +1,266 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>BorderlineEdit</class>
|
||||
<widget class="QWidget" name="BorderlineEdit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1128</width>
|
||||
<height>224</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Aes Danger Area Edit</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="2" colspan="2">
|
||||
<widget class="QLabel" name="lblGeometry">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Geometry:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLabel" name="lbBorderlineId">
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="LtsWidgets::LtsComboBox" name="cbParty">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="currentText">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="3">
|
||||
<widget class="QPushButton" name="pbClear">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../Styles/Light/resources/rde_light_style.qrc">
|
||||
<normaloff>:/style/remove.svg</normaloff>:/style/remove.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lblParty">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Party:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QCheckBox" name="cbLocalBorderline">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Local Borderline</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="lblBorderlineId">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Borderline Id:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="3">
|
||||
<widget class="QPushButton" name="pbPosition">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../Styles/Light/resources/rde_light_style.qrc">
|
||||
<normaloff>:/style/position.svg</normaloff>:/style/position.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="leIdentifier">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lblIdentifier">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Identifier:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="4">
|
||||
<widget class="LtsCoordWidget::LtsCoordWidget" name="positionEdit_1">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="5">
|
||||
<widget class="LtsCoordWidget::LtsCoordWidget" name="positionEdit_7">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="5">
|
||||
<widget class="LtsCoordWidget::LtsCoordWidget" name="positionEdit_8">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="5">
|
||||
<widget class="LtsCoordWidget::LtsCoordWidget" name="positionEdit_9">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="5">
|
||||
<widget class="LtsCoordWidget::LtsCoordWidget" name="positionEdit_10">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="5">
|
||||
<widget class="LtsCoordWidget::LtsCoordWidget" name="positionEdit_11">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="4">
|
||||
<widget class="LtsCoordWidget::LtsCoordWidget" name="positionEdit_2">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="4">
|
||||
<widget class="LtsCoordWidget::LtsCoordWidget" name="positionEdit_3">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="4">
|
||||
<widget class="LtsCoordWidget::LtsCoordWidget" name="positionEdit_4">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="4">
|
||||
<widget class="LtsCoordWidget::LtsCoordWidget" name="positionEdit_5">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="4">
|
||||
<widget class="LtsCoordWidget::LtsCoordWidget" name="positionEdit_6">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LtsCoordWidget::LtsCoordWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>LtsCoordTrans/lts_coord_widget.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>LtsWidgets::LtsComboBox</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header>LtsWidgets/lts_combo_box.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../../../Styles/Light/resources/rde_light_style.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
+98
@@ -0,0 +1,98 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Gui Plugin for AreaEffectSimulation - Borderlines
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2017-06-06
|
||||
*/
|
||||
|
||||
#include "aes_borderline_gui_plugin.h"
|
||||
#include "aes_borderline_list.h"
|
||||
#include "aes_borderline_edit.h"
|
||||
|
||||
#include <AreaEffectSimulation/aes_operator_rights.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsUtilsSettings/settings.h>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
std::shared_ptr<GuiPluginBase::Interface> GuiPlugin::createGuiInterface(LtsSession::LtsSession *session)
|
||||
{
|
||||
return std::make_shared<InterfaceImpl>(session);
|
||||
} // end of createGuiInterface()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
InterfaceImpl::InterfaceImpl(LtsSession::LtsSession *session)
|
||||
: AesBaseInterface(session, getLogger("Plugins.Gui.Borderline"))
|
||||
// : GuiPluginBase::Interface(session, getLogger("Plugins.Gui.BorderlineImpl"))
|
||||
, ForeignGuiInterface()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << " --------Start InterfaceImpl Gui plugin borderline";
|
||||
} // end of ctor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
QVector<LtsWidgets::PluginData> InterfaceImpl::getActions()
|
||||
{
|
||||
QVector<LtsWidgets::PluginData> ret;
|
||||
|
||||
LtsUtils::ProjectSettings *ps = LtsUtils::ProjectSettings::getInstance();
|
||||
const bool enableBorderlines = ps->value(QStringLiteral("aes"),
|
||||
QStringLiteral("enableBorderlines")).toBool();
|
||||
|
||||
if (enableBorderlines && m_session->app() != LtsAppDescriptor::App::OC)
|
||||
{
|
||||
// Action 'Show Borderlines' anlegen
|
||||
ret.append(LtsWidgets::PluginData( tr("Alarm Management"),
|
||||
tr("Borderlines"),
|
||||
QLatin1String("ListBorderlines"),
|
||||
QIcon(QLatin1String("icon:define_border_lines.svg")),
|
||||
[this](QWidget *parent) { return onShowBorderlineListDialog(parent);},
|
||||
OperatorRights::BorderlinesShow,
|
||||
LtsWidgets::ExercisePart::eExecution));
|
||||
|
||||
|
||||
|
||||
// Action 'New Borderline' anlegen
|
||||
if (m_session->isExercisePartition())
|
||||
ret.append(LtsWidgets::PluginData(tr("Alarm Management"),
|
||||
tr("Add Borderline"),
|
||||
QLatin1String("AddBorderline"),
|
||||
QIcon(QLatin1String("icon:define_border_lines_add.svg")),
|
||||
[this](QWidget *parent) { return onShowAddBorderlineDialog(parent);},
|
||||
OperatorRights::BorderlinesEdit,
|
||||
LtsWidgets::ExercisePart::eExecution,
|
||||
LtsWidgets::ExerciseState::eCreated | LtsWidgets::ExerciseState::eStarted | LtsWidgets::ExerciseState::ePaused));
|
||||
}
|
||||
return ret;
|
||||
} // end of getActions()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
AreaEffectSimulation::BaseEdit *InterfaceImpl::showEditWindow(int aesEntityId, QWidget *parent)
|
||||
{
|
||||
BorderlineEdit *dialog = new BorderlineEdit(menuGroup(), parent);
|
||||
dialog->init(aesEntityId, false, m_session);
|
||||
return dialog;
|
||||
} // end of showEditWindow()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
LtsWidgets::LtsDialog *InterfaceImpl::onShowBorderlineListDialog(QWidget *parent)
|
||||
{
|
||||
BorderlineList *dialog = new BorderlineList(menuGroup(), parent);
|
||||
dialog->init(m_session);
|
||||
return dialog;
|
||||
} // end of onShowBorderlineListDialog()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
LtsWidgets::LtsDialog *InterfaceImpl::onShowAddBorderlineDialog(QWidget *parent)
|
||||
{
|
||||
BorderlineEdit *dialog = new BorderlineEdit(menuGroup(), parent);
|
||||
dialog->init(0, false, m_session);
|
||||
return dialog;
|
||||
} // end of onShowAddBorderlineDialog()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
} // namespace AreaEffectSimulation
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Gui Plugin for AreaEffectSimulation Borderline
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2017-06-06
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Plugins/AreaEffectSimulation/Gui/Base/aes_base_gui_plugin.h>
|
||||
#include "aes_borderline_gui_plugin_interface.h"
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
class GuiPlugin final : public AesBaseGuiPlugin
|
||||
{
|
||||
Q_PLUGIN_METADATA(IID "gui:3:aes.borderlines")
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GuiPlugin() = default;
|
||||
~GuiPlugin() = default;
|
||||
QString pluginName() override { return QLatin1String("AreaEffectSimulationBorderlineGui"); }
|
||||
std::shared_ptr<GuiPluginBase::Interface> createGuiInterface(LtsSession::LtsSession *session) override;
|
||||
bool availableInPartition(IDL::PartitionType partition) const override
|
||||
{
|
||||
return partition == IDL::PartitionType::Exercise ||
|
||||
partition == IDL::PartitionType::Replay;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
class InterfaceImpl final : public AesBaseInterface, public AesBorderline::ForeignGuiInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit InterfaceImpl(LtsSession::LtsSession *session);
|
||||
|
||||
QVector<LtsWidgets::PluginData> getActions() override;
|
||||
AreaEffectSimulation::BaseEdit *showEditWindow(int aesEntityId, QWidget *parent) override;
|
||||
|
||||
private:
|
||||
LtsWidgets::LtsDialog *onShowBorderlineListDialog(QWidget *parent);
|
||||
LtsWidgets::LtsDialog *onShowAddBorderlineDialog(QWidget *parent);
|
||||
|
||||
};
|
||||
|
||||
} // namespace AreaEffectSimulation
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for AreaEffectSimulation Borderline (Interface for access from other Plugins)
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2017-06-06
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
class QWidget;
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
class BaseEdit;
|
||||
}
|
||||
|
||||
namespace AesBorderline
|
||||
{
|
||||
class ForeignGuiInterface
|
||||
{
|
||||
public:
|
||||
ForeignGuiInterface() = default;
|
||||
virtual ~ForeignGuiInterface() = default;
|
||||
|
||||
virtual AreaEffectSimulation::BaseEdit *showEditWindow(int aesEntityId, QWidget *parent) = 0;
|
||||
};
|
||||
|
||||
} //namespace AesBorderline
|
||||
@@ -0,0 +1,183 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for AreaEffectSimulation - Borderline Overview Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2017-06-19
|
||||
*/
|
||||
|
||||
#include "aes_borderline_list.h"
|
||||
#include "aes_borderline_edit.h"
|
||||
#include "aes_borderlines_model.h"
|
||||
#include "CustomView/aes_borderline.h"
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <FileManagement/flm_translation.h>
|
||||
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
bool BorderlineList::init(LtsSession::LtsSession *session)
|
||||
{
|
||||
if (!AesItemList::init(session))
|
||||
return false;
|
||||
|
||||
m_bHasAddEditOperatorRights = LtsSessionData::LtsSessionData::getInstance()->hasOperatorRight(OperatorRights::BorderlinesEdit);
|
||||
|
||||
setDataViewModel(m_model, [this]() { return new CustomViewBorderline(this); });
|
||||
|
||||
#ifndef LTS_DEBUG
|
||||
hideColumn(BorderlinesModel::BcId);
|
||||
#endif
|
||||
hideColumn(BorderlinesModel::BcChargeType);
|
||||
hideColumn(BorderlinesModel::BcEffectDuration);
|
||||
hideColumn(BorderlinesModel::BcEffectStart);
|
||||
hideColumn(BorderlinesModel::BcEffectState);
|
||||
hideColumn(BorderlinesModel::BcEffectSource);
|
||||
hideColumn(BorderlinesModel::BcParticipant);
|
||||
|
||||
setSortIndicator(BorderlinesModel::BcName);
|
||||
|
||||
enaDisa();
|
||||
|
||||
// Save/Load from Library Button
|
||||
m_buttonBox->connectLibraryButton(this,
|
||||
&BorderlineList::onImportButtonClicked,
|
||||
&BorderlineList::onExportButtonClicked);
|
||||
|
||||
if (!session->getForeignGuiInterface<FileManagement::ForeignGuiInterface>(m_flmGui))
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Library, false);
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Borderlines"));
|
||||
|
||||
return true;
|
||||
} // end of init()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void BorderlineList::createModel()
|
||||
{
|
||||
m_model = new AesItemSortFilterProxyModelTmpl<Borderline>(m_session, this);
|
||||
|
||||
m_borderlinesModel = new BorderlinesModel(this);
|
||||
m_borderlinesModel->initModel(m_session);
|
||||
m_model->setSourceModel(m_borderlinesModel);
|
||||
} // end of createModel()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void BorderlineList::onAddAesItem()
|
||||
{
|
||||
BorderlineEdit *dialog = new BorderlineEdit(m_menuGroup, this);
|
||||
|
||||
const int aesItemId = model()->aesId(currentRow());
|
||||
if (dialog->init(aesItemId, aesItemId > 0, m_session))
|
||||
addDialog(dialog, m_menuGroup, dialog->dialogIdentifier(), LtsWidgets::LayoutArea::eDialogTab);
|
||||
else
|
||||
delete dialog;
|
||||
} // end of onAddAesItem()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void BorderlineList::onEditAesItem()
|
||||
{
|
||||
const int aesItemId = model()->aesId(currentRow());
|
||||
|
||||
if (aesItemId < 0)
|
||||
return;
|
||||
|
||||
DEBUG_LOG(m_logger) << "current BorderlineId: " << aesItemId;
|
||||
|
||||
BorderlineEdit *dialog = new BorderlineEdit(m_menuGroup, this);
|
||||
if (dialog->init(aesItemId, false, m_session))
|
||||
addDialog(dialog, m_menuGroup, dialog->dialogIdentifier(), LtsWidgets::LayoutArea::eDialogTab);
|
||||
else
|
||||
delete dialog;
|
||||
} // end of onEditAesItem()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void BorderlineList::onRemoveAesItem()
|
||||
{
|
||||
const int aesItemId = model()->aesId(currentRow());
|
||||
Core::RemoveElementRequest req(aesItemId);
|
||||
m_requestHelper->startSingleRequest([req, this]()
|
||||
{
|
||||
return m_ftc->borderlineRemoveRequest(req, this);
|
||||
});
|
||||
} // end of onRemoveAesItem()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void BorderlineList::retranslate()
|
||||
{
|
||||
translateBase(tr("Borderlines"));
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void BorderlineList::onBorderlineModifyReply(const Core::FunctionReplyObject &replyObject)
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
} // end of onBorderlineRemoveReply()
|
||||
|
||||
void BorderlineList::onBorderlineRemoveReply(const Core::FunctionReplyObject &replyObject)
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
} // end of onBorderlineRemoveReply()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// library
|
||||
void BorderlineList::onExportButtonClicked()
|
||||
{
|
||||
QByteArray byteArray = m_borderlinesModel->borderlinesToJson();
|
||||
|
||||
int fileId = m_flmGui->saveFileContent(this, FileManagement::FileType::Xml, m_session->exerciseId(), byteArray);
|
||||
if (fileId > 0)
|
||||
DEBUG_LOG(m_logger) << "Saved file with id = " << fileId;
|
||||
else
|
||||
ERROR_LOG(m_logger) << "Could not save file in library ";
|
||||
|
||||
}
|
||||
|
||||
void BorderlineList::onImportButtonClicked()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << " onImportButtonClicked() ";
|
||||
|
||||
QByteArray content;
|
||||
int fileId = m_flmGui->loadFileContent(this, content, {FileManagement::FileType::Xml}, m_session->exerciseId(), FileManagement::toString(FileManagement::XmlType::AESBorderlineList));
|
||||
if (fileId > 0)
|
||||
{
|
||||
if (!m_flmGui->isXmlType(content, FileManagement::toString(FileManagement::XmlType::AESBorderlineList)))
|
||||
{
|
||||
QHash<LtsWidgets::Button, QString> texts({{LtsWidgets::Button::Yes, tr("Ok")}});
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this,
|
||||
tr("Invalid xml file content"),
|
||||
windowTitle(),
|
||||
LtsWidgets::Behaviour::Modal,
|
||||
LtsWidgets::Button::Yes,
|
||||
texts);
|
||||
}
|
||||
else
|
||||
{
|
||||
INFO_LOG(m_logger) << "--- onImportButtonClicked() ";
|
||||
const QVector<Borderline> requests = m_borderlinesModel->jsonToBorderlineVector(content);
|
||||
for(const auto &borderline : requests)
|
||||
{
|
||||
BorderlineModifyRequest request;
|
||||
request.id(0);
|
||||
request.name(borderline.name());
|
||||
request.operatorId(borderline.operatorId());
|
||||
if (borderline.partyId().is_set())
|
||||
request.partyId(borderline.partyId().get());
|
||||
request.name(borderline.name());
|
||||
request.segments(borderline.segments());
|
||||
m_requestHelper->startSingleRequest([this, request]()
|
||||
{
|
||||
return m_ftc->borderlineModifyRequest(request, this);
|
||||
});
|
||||
}
|
||||
INFO_LOG(m_logger) << "--- onImportButtonClicked() ";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // namespace AreaEffectSimulation
|
||||
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for AreaEffectSimulation - Borderline Overview Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2017-06-19
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Plugins/AreaEffectSimulation/Gui/Base/aes_itemlist.h>
|
||||
#include <Plugins/AreaEffectSimulation/Gui/Base/aes_base_model.h>
|
||||
#include <Plugins/FileManagement/flm_explorer_gui_plugin_interface.h>
|
||||
#include "aes_borderlines_model.h"
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
class BorderlineList final : public AesItemListTmpl<Borderline>
|
||||
, protected AreaEffectSimulation::Interface::Ftc::BorderlineModifyReplyHandler
|
||||
, protected AreaEffectSimulation::Interface::Ftc::BorderlineRemoveReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
using AesItemListTmpl<Borderline>::AesItemListTmpl;
|
||||
|
||||
bool init(LtsSession::LtsSession *session) override;
|
||||
|
||||
private slots:
|
||||
void onAddAesItem() override;
|
||||
void onEditAesItem() override;
|
||||
void onRemoveAesItem() override;
|
||||
void onExportButtonClicked();
|
||||
void onImportButtonClicked();
|
||||
|
||||
private:
|
||||
void createModel() override;
|
||||
void retranslate() override;
|
||||
void onBorderlineModifyReply(const Core::FunctionReplyObject &replyObject) override;
|
||||
void onBorderlineRemoveReply(const Core::FunctionReplyObject &replyObject) override;
|
||||
BorderlinesModel *m_borderlinesModel = nullptr;
|
||||
std::shared_ptr<FileManagement::ForeignGuiInterface> m_flmGui;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,181 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for AreaEffectSimulation - Borderline Overview Dialog Model
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2017-06-19
|
||||
*/
|
||||
|
||||
|
||||
#include "aes_borderlines_model.h"
|
||||
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <FileManagement/flm_translation.h>
|
||||
|
||||
#include <QJsonArray>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonDocument>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
BorderlinesModel::BorderlinesModel(QObject *parent)
|
||||
: AesGuiBaseModel<Borderline>(parent, {tr("Type")})
|
||||
// operatorId represents here the type of borderline. operatorId <=0 global, >0 local
|
||||
{
|
||||
} // end of ctor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
BorderlinesModel::~BorderlinesModel()
|
||||
{
|
||||
} // end of dtor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool BorderlinesModel::initModel(LtsSession::LtsSession *session)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "--- Start BorderlinesModel::initModel()";
|
||||
|
||||
if (!AesGuiBaseModel::initModel(session))
|
||||
return false;
|
||||
|
||||
connect(m_aesDtc.get(), &AreaEffectSimulation::Interface::Dtc::borderlineChanged,
|
||||
this, &BorderlinesModel::onDataChanged);
|
||||
m_aesDtc->borderlines([this](const Borderline &item) { insertRow(item); });
|
||||
|
||||
return true;
|
||||
} // end of initModel()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
QVariant BorderlinesModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!indexIsValid(index))
|
||||
return QVariant();
|
||||
|
||||
const Borderline &item = m_vecData.at(index.row());
|
||||
|
||||
if (index.column() < cntBaseColumns())
|
||||
return AesGuiBaseModel::data(item, index.column(), role);
|
||||
|
||||
if (role != Qt::DisplayRole)
|
||||
return QVariant();
|
||||
|
||||
// Spezielle Borderline columns
|
||||
switch (index.column())
|
||||
{
|
||||
case ColOperatorId:
|
||||
if (item.operatorId() == 0)
|
||||
return tr("Global");
|
||||
return tr("Local");
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return QVariant();
|
||||
} // end of data()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool BorderlinesModel::isFiltered(const Borderline &data, DataModification modType) const
|
||||
{
|
||||
// globale und nur lokale Borderlines des akt. operators eintragen
|
||||
if ((data.operatorId() != LtsSessionData::LtsSessionData::getInstance()->getOperatorId()) &&
|
||||
(data.operatorId() != 0))
|
||||
return true;
|
||||
return AesGuiBaseModel::isFiltered(data, modType);
|
||||
|
||||
} // end of isFiltered()
|
||||
//-----------------------------------------------------------------------------
|
||||
QByteArray BorderlinesModel::borderlinesToJson()
|
||||
{
|
||||
QJsonObject obj;
|
||||
QJsonArray arr;
|
||||
QJsonArray arrSeg;
|
||||
|
||||
obj[QStringLiteral("XmlType")] = FileManagement::toString(FileManagement::XmlType::AESBorderlineList);
|
||||
for (int row = 0; row <rowCount(); row++)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "row =" << ": " << row;
|
||||
QJsonObject inner;
|
||||
const Borderline &borderline = m_vecData.at(row);
|
||||
|
||||
inner[QStringLiteral("chargeTypeId")] = borderline.chargeStruct().chargeTypeId();
|
||||
inner[QStringLiteral("effectDuration")] = borderline.effectDuration();
|
||||
inner[QStringLiteral("effectMarkingInTa")] = borderline.effectMarkingInTa();
|
||||
//inner[QStringLiteral("effectStart")] = borderline.effectStart(); not for Borderlines
|
||||
inner[QStringLiteral("effectStateId")] = borderline.effectStateId().underlying();
|
||||
inner[QStringLiteral("id")] = borderline.id();
|
||||
inner[QStringLiteral("isDeleted")] = borderline.isDeleted();
|
||||
inner[QStringLiteral("isUsed")] = borderline.isUsed();
|
||||
inner[QStringLiteral("name")] = QString::fromStdString(borderline.name());
|
||||
inner[QStringLiteral("operatorId")] = borderline.operatorId();
|
||||
if ( borderline.participantId().is_set())
|
||||
inner[QStringLiteral("participantId")] = borderline.participantId().get();
|
||||
if ( borderline.partyId().is_set())
|
||||
inner[QStringLiteral("partyId")] = borderline.partyId().get();
|
||||
inner[QStringLiteral("sampleTime")] = borderline.sampleTime();
|
||||
|
||||
arrSeg = {};
|
||||
for (const Core::GeoPosition2D &segment : borderline.segments())
|
||||
{
|
||||
QJsonObject innerSeg;
|
||||
|
||||
innerSeg[QStringLiteral("lat")] = segment.lat();
|
||||
innerSeg[QStringLiteral("lon")] = segment.lon();
|
||||
|
||||
arrSeg += innerSeg;
|
||||
}
|
||||
inner[QStringLiteral("segments")] = arrSeg;
|
||||
arr += inner;
|
||||
}
|
||||
|
||||
obj[QStringLiteral("Borderlines")] = arr;
|
||||
QJsonDocument doc(obj);
|
||||
return doc.toJson(QJsonDocument::Compact);
|
||||
|
||||
}
|
||||
|
||||
QVector<Borderline> BorderlinesModel::jsonToBorderlineVector(const QByteArray &content)
|
||||
{
|
||||
QVector<Borderline> result;
|
||||
// already checked that content is not empty and parseable and containing the proper XmlType (AESBorderlineList)
|
||||
const QJsonDocument doc(QJsonDocument::fromJson(content));
|
||||
const QJsonObject obj(doc.object());
|
||||
const QJsonArray arr(obj.value(QStringLiteral("Borderlines")).toArray());
|
||||
for (const auto &ele : arr)
|
||||
{
|
||||
const QJsonObject objArr(ele.toObject());
|
||||
Borderline borderline;
|
||||
borderline.chargeStruct().chargeTypeId(objArr[QStringLiteral("chargeTypeId")].toInt());
|
||||
borderline.effectDuration(objArr[QStringLiteral("effectDuration")].toDouble());
|
||||
borderline.effectMarkingInTa(objArr[QStringLiteral("effectMarkingInTa")].toInt());
|
||||
borderline.effectStart(objArr[QStringLiteral("effectStart")].toDouble());
|
||||
int effectStateId = objArr[QStringLiteral("effectStateId")].toInt();
|
||||
borderline.effectStateId(static_cast<AreaEffectSimulation::AesEffectState::inner_enum>(effectStateId));
|
||||
borderline.operatorId(objArr[QStringLiteral("operatorId")].toInt());
|
||||
borderline.id(0);
|
||||
borderline.name(objArr[QStringLiteral("name")].toString().toStdString());
|
||||
if (objArr.contains(QStringLiteral("participantId")) )
|
||||
borderline.participantId(objArr[QStringLiteral("participantId")].toDouble());
|
||||
if (objArr.contains(QStringLiteral("partyId")) )
|
||||
borderline.partyId(objArr[QStringLiteral("partyId")].toDouble());
|
||||
borderline.sampleTime(objArr[QStringLiteral("sampleTime")].toDouble());
|
||||
|
||||
//Start segments
|
||||
const QJsonArray arrSeg = (objArr.value(QStringLiteral("segments")).toArray());
|
||||
borderline.segments().reserve(arrSeg.size());
|
||||
for (const auto &seg : arrSeg)
|
||||
{
|
||||
const QJsonObject objSeg(seg.toObject());
|
||||
Core::GeoPosition2D segment;
|
||||
segment.lat(objSeg[QStringLiteral("lat")].toDouble());
|
||||
segment.lon(objSeg[QStringLiteral("lon")].toDouble());
|
||||
borderline.segments().push_back(std::move(segment));
|
||||
}
|
||||
//End segments
|
||||
|
||||
result.append(std::move(borderline));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace AreaEffectSimulation
|
||||
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for AreaEffectSimulation - Borderline Overview Dialog Model
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2017-06-19
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Plugins/AreaEffectSimulation/Gui/Base/aes_base_model.h>
|
||||
|
||||
namespace LtsSession
|
||||
{
|
||||
class LtsSession;
|
||||
}
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
class BorderlinesModel final : public AesGuiBaseModel<Borderline>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum AdditionalColumns {ColOperatorId = BcCount};
|
||||
explicit BorderlinesModel(QObject *parent = nullptr);
|
||||
~BorderlinesModel();
|
||||
|
||||
bool initModel(LtsSession::LtsSession *session) override;
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
QByteArray borderlinesToJson();
|
||||
QVector<Borderline> jsonToBorderlineVector(const QByteArray &content);
|
||||
|
||||
protected:
|
||||
bool isFiltered(const Borderline &data, DataModification modType) const override;
|
||||
};
|
||||
} //namespace AreaEffectSimulation
|
||||
Reference in new issue
Block a user