Apply clang-format to Lts/Common and DTC/enum headers
- Formatted all CodeGen module files (9 files) - Formatted LtsAppDescriptor module files - Formatted LtsAppManager/AppChooser files - Applied clang-format to all DTC and enum headers across modules - Removed coordTransTests from CommonUnitTestsPlaceholder (moved to tests/) Cosmetic changes only, no functional modifications. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
848 files changed
+89305
-100020
No files matched your search
Executable → Regular
+328
-391
@@ -1,526 +1,463 @@
|
||||
|
||||
|
||||
|
||||
#include "participant_move_dialog.h"
|
||||
#include "ui_participant_move_dialog.h"
|
||||
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
|
||||
#include <LtsWidgets/lts_message_dialog.h>
|
||||
#include <Common/LtsCoordTrans/lts_coord_widget.h>
|
||||
#include <Plugins/ProjectDataManagement/pdm_gui_plugin_interface.h>
|
||||
#include <ParticipantManagement/ppm_gui_combobox_plugin_interface.h>
|
||||
#include <Plugins/CentralEffectSimulation/ces_data_plugin_interface.h>
|
||||
|
||||
#include "logger.h"
|
||||
#include <ParticipantManagement/ppm_translation.h>
|
||||
#include <ParticipantManagement/ppm.hpp>
|
||||
#include <FileManagement/flm_translation.h>
|
||||
#include "ui_participant_move_dialog.h"
|
||||
|
||||
#include <Common/LtsCoordTrans/lts_coord_widget.h>
|
||||
#include <FileManagement/flm_translation.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <LtsWidgets/lts_message_dialog.h>
|
||||
#include <ParticipantManagement/ppm.hpp>
|
||||
#include <ParticipantManagement/ppm_gui_combobox_plugin_interface.h>
|
||||
#include <ParticipantManagement/ppm_translation.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <Plugins/CentralEffectSimulation/ces_data_plugin_interface.h>
|
||||
#include <Plugins/ProjectDataManagement/pdm_gui_plugin_interface.h>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
|
||||
namespace CentralEffectSimulation
|
||||
{
|
||||
static constexpr double s_msConversion = 3.6;
|
||||
static constexpr int s_timeMilliConversion = 1000;
|
||||
static constexpr double s_msConversion = 3.6;
|
||||
static constexpr int s_timeMilliConversion = 1000;
|
||||
|
||||
ParticipantMoveDialog::ParticipantMoveDialog(QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel)
|
||||
, m_ftc(nullptr)
|
||||
, m_sitMapGuiIfc(nullptr)
|
||||
, m_ui(new Ui::WaypointsEdit)
|
||||
, m_id(0)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_polyline(QPolygonF())
|
||||
ParticipantMoveDialog::ParticipantMoveDialog(QWidget* parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel), m_ftc(nullptr),
|
||||
m_sitMapGuiIfc(nullptr), m_ui(new Ui::WaypointsEdit), m_id(0), m_requestHelper(new LtsUtils::RequestHelper(this)),
|
||||
m_polyline(QPolygonF())
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_ui->cbJump->hide();
|
||||
m_ui->label_5->hide();
|
||||
m_ui->spSpeed->setValue(30);
|
||||
m_ui->lePrefix->setText(tr("Waypoint"));
|
||||
m_uiRequirements->addRequirement({m_ui->lblMoveStart, [this]() { return hasValidEffectStart(m_ui->dteStartTime); }, tr("Begin time is smaller than current time")});
|
||||
connect (this, &ParticipantMoveDialog::signalFocused, this, &ParticipantMoveDialog::onFocus);
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Move_Participant_0"));
|
||||
}
|
||||
|
||||
m_ui->setupUi(this);
|
||||
m_ui->cbJump->hide();
|
||||
m_ui->label_5->hide();
|
||||
m_ui->spSpeed->setValue(30);
|
||||
m_ui->lePrefix->setText(tr("Waypoint"));
|
||||
m_uiRequirements->addRequirement({m_ui->lblMoveStart, [this]() { return hasValidEffectStart(m_ui->dteStartTime); },
|
||||
tr("Begin time is smaller than current time")});
|
||||
connect(this, &ParticipantMoveDialog::signalFocused, this, &ParticipantMoveDialog::onFocus);
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Move_Participant_0"));
|
||||
}
|
||||
|
||||
ParticipantMoveDialog::~ParticipantMoveDialog()
|
||||
{
|
||||
m_sitMapGuiIfc = nullptr;
|
||||
delete m_ui;
|
||||
emit closeDialog(m_participantData.id());
|
||||
}
|
||||
|
||||
m_sitMapGuiIfc = nullptr;
|
||||
delete m_ui;
|
||||
emit closeDialog(m_participantData.id());
|
||||
}
|
||||
|
||||
void ParticipantMoveDialog::enableUiElements(bool enable)
|
||||
{
|
||||
m_ui->pbPosition->setEnabled(enable);
|
||||
m_ui->pbClear->setEnabled(enable);
|
||||
}
|
||||
m_ui->pbPosition->setEnabled(enable);
|
||||
m_ui->pbClear->setEnabled(enable);
|
||||
}
|
||||
|
||||
|
||||
bool ParticipantMoveDialog::init(LtsSession::LtsSessionDataDds *session,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
const std::shared_ptr<CentralEffectSimulation::Interface::Dtc> &cesDtc,
|
||||
const ParticipantManagement::ParticipantData &data)
|
||||
bool ParticipantMoveDialog::init(LtsSession::LtsSessionDataDds* session,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc>& ppmDtc,
|
||||
const std::shared_ptr<CentralEffectSimulation::Interface::Dtc>& cesDtc,
|
||||
const ParticipantManagement::ParticipantData& data)
|
||||
{
|
||||
m_session = session;
|
||||
m_participantData = data;
|
||||
m_cesDtc = cesDtc;
|
||||
m_session = session;
|
||||
m_participantData = data;
|
||||
m_cesDtc = cesDtc;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (!m_session->getFtc<CentralEffectSimulation::DataInterface>(m_ftc))
|
||||
return false;
|
||||
|
||||
if (!m_session->getFtc<CentralEffectSimulation::DataInterface>(m_ftc))
|
||||
return false;
|
||||
m_session->getForeignGuiInterface<SituationMap::ForeignGuiInterface>(m_sitMapGuiIfc);
|
||||
|
||||
m_session->getForeignGuiInterface<SituationMap::ForeignGuiInterface>(m_sitMapGuiIfc);
|
||||
|
||||
if (m_sitMapGuiIfc)
|
||||
{
|
||||
connect(m_ui->pbPosition, &QPushButton::clicked, this, &ParticipantMoveDialog::onGetPolyline);
|
||||
connect(m_ui->pbClear, &QPushButton::clicked, this, &ParticipantMoveDialog::clearCoordinates);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ui->pbPosition->setEnabled(false);
|
||||
m_ui->pbClear->setEnabled(false);
|
||||
}
|
||||
|
||||
m_ui->dteStartTime->setMinimumTimeMSec(m_session->partitionTime());
|
||||
m_ui->dteStartTime->setRetrieveCurrentTimeCallback([this]() { return m_session->partitionTime(); });
|
||||
m_ui->lbIdentifier->setText(QString::fromStdString(data.tacticalIdentifier()));
|
||||
QString partyStr = ParticipantManagement::trPartyName(ppmDtc->party(m_participantData.partyId()).name());
|
||||
m_ui->lbParty->setText(partyStr);
|
||||
QString typeStr = ParticipantManagement::trTypeName(ppmDtc->type(m_participantData.typeId()).name());
|
||||
m_ui->lbType->setText(typeStr);
|
||||
|
||||
|
||||
enableUiElements(true);
|
||||
|
||||
initTableHeader();
|
||||
|
||||
connect(cesDtc.get(), &CentralEffectSimulation::Interface::Dtc::simulatedMovementChanged,
|
||||
this, &ParticipantMoveDialog::onSimulatedMovementChanged);
|
||||
|
||||
|
||||
{
|
||||
auto sm = [this](const CentralEffectSimulation::SimulatedMovement & sme)
|
||||
if (m_sitMapGuiIfc)
|
||||
{
|
||||
onSimulatedMovementChanged(sme, DataModification::eAdded);
|
||||
};
|
||||
if (!m_cesDtc->simulatedMovements(sm))
|
||||
return false;
|
||||
}
|
||||
connect(m_ui->pbPosition, &QPushButton::clicked, this, &ParticipantMoveDialog::onGetPolyline);
|
||||
connect(m_ui->pbClear, &QPushButton::clicked, this, &ParticipantMoveDialog::clearCoordinates);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ui->pbPosition->setEnabled(false);
|
||||
m_ui->pbClear->setEnabled(false);
|
||||
}
|
||||
|
||||
|
||||
m_buttonBox->connectLibraryButton(this,
|
||||
&ParticipantMoveDialog::onImportButtonClicked,
|
||||
&ParticipantMoveDialog::onExportButtonClicked);
|
||||
m_ui->dteStartTime->setMinimumTimeMSec(m_session->partitionTime());
|
||||
m_ui->dteStartTime->setRetrieveCurrentTimeCallback([this]() { return m_session->partitionTime(); });
|
||||
m_ui->lbIdentifier->setText(QString::fromStdString(data.tacticalIdentifier()));
|
||||
QString partyStr = ParticipantManagement::trPartyName(ppmDtc->party(m_participantData.partyId()).name());
|
||||
m_ui->lbParty->setText(partyStr);
|
||||
QString typeStr = ParticipantManagement::trTypeName(ppmDtc->type(m_participantData.typeId()).name());
|
||||
m_ui->lbType->setText(typeStr);
|
||||
|
||||
if (!m_session->getForeignGuiInterface<FileManagement::ForeignGuiInterface>(m_flmGui))
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Library, false);
|
||||
enableUiElements(true);
|
||||
|
||||
return true;
|
||||
initTableHeader();
|
||||
|
||||
}
|
||||
connect(cesDtc.get(), &CentralEffectSimulation::Interface::Dtc::simulatedMovementChanged, this,
|
||||
&ParticipantMoveDialog::onSimulatedMovementChanged);
|
||||
|
||||
void ParticipantMoveDialog::onSimulatedMovementChanged(const CentralEffectSimulation::SimulatedMovement &data, DataModification modType)
|
||||
{
|
||||
auto sm = [this](const CentralEffectSimulation::SimulatedMovement& sme) {
|
||||
onSimulatedMovementChanged(sme, DataModification::eAdded);
|
||||
};
|
||||
if (!m_cesDtc->simulatedMovements(sm))
|
||||
return false;
|
||||
}
|
||||
|
||||
m_buttonBox->connectLibraryButton(this, &ParticipantMoveDialog::onImportButtonClicked,
|
||||
&ParticipantMoveDialog::onExportButtonClicked);
|
||||
|
||||
if (!m_session->getForeignGuiInterface<FileManagement::ForeignGuiInterface>(m_flmGui))
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Library, false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ParticipantMoveDialog::onSimulatedMovementChanged(const CentralEffectSimulation::SimulatedMovement& data,
|
||||
DataModification modType)
|
||||
{
|
||||
if (modType == DataModification::eRemoved || m_participantData.id() != data.participantId())
|
||||
return;
|
||||
if (modType == DataModification::eRemoved || m_participantData.id() != data.participantId())
|
||||
return;
|
||||
INFO_LOG(m_logger) << "onSimulatedMovementChanged";
|
||||
|
||||
|
||||
clearContent();
|
||||
|
||||
m_id = data.id();
|
||||
m_ui->lePrefix->setText(QString::fromStdString(data.name()));
|
||||
m_ui->cbRepeat->setChecked(data.repeat());
|
||||
m_ui->cbJump->setChecked(data.jumpToStart());
|
||||
m_ui->dteStartTime->setMsecsSinceEpoch(data.startTime());
|
||||
m_polyline.clear();
|
||||
|
||||
for (const SimulatedMovementSegment &segment : data.segments())
|
||||
{
|
||||
const Core::GeoPosition2D &pointDds = segment.position();
|
||||
insertPos(pointDds.lon(), pointDds.lat(), QString::fromStdString(segment.name()), segment.delay(), segment.speed());
|
||||
m_polyline.push_back(QPointF(pointDds.lon(), pointDds.lat()));
|
||||
}
|
||||
|
||||
if (this->amIFocused())
|
||||
m_sitMapGuiIfc->displayPreviewObject(this, m_polyline, false);
|
||||
clearContent();
|
||||
|
||||
m_id = data.id();
|
||||
m_ui->lePrefix->setText(QString::fromStdString(data.name()));
|
||||
m_ui->cbRepeat->setChecked(data.repeat());
|
||||
m_ui->cbJump->setChecked(data.jumpToStart());
|
||||
m_ui->dteStartTime->setMsecsSinceEpoch(data.startTime());
|
||||
m_polyline.clear();
|
||||
|
||||
for (const SimulatedMovementSegment& segment : data.segments())
|
||||
{
|
||||
const Core::GeoPosition2D& pointDds = segment.position();
|
||||
insertPos(pointDds.lon(), pointDds.lat(), QString::fromStdString(segment.name()), segment.delay(),
|
||||
segment.speed());
|
||||
m_polyline.push_back(QPointF(pointDds.lon(), pointDds.lat()));
|
||||
}
|
||||
|
||||
if (this->amIFocused())
|
||||
m_sitMapGuiIfc->displayPreviewObject(this, m_polyline, false);
|
||||
}
|
||||
|
||||
void ParticipantMoveDialog::showPreview(bool show)
|
||||
{
|
||||
if (m_sitMapGuiIfc)
|
||||
{
|
||||
if (show)
|
||||
m_sitMapGuiIfc->displayPreviewObject(this, m_polyline, false);
|
||||
else
|
||||
m_sitMapGuiIfc->removePreviewObject();
|
||||
}
|
||||
if (m_sitMapGuiIfc)
|
||||
{
|
||||
if (show)
|
||||
m_sitMapGuiIfc->displayPreviewObject(this, m_polyline, false);
|
||||
else
|
||||
m_sitMapGuiIfc->removePreviewObject();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ParticipantMoveDialog::onSimulatedMovementRemoveReply(const Core::FunctionReplyObject &replyObject)
|
||||
void ParticipantMoveDialog::onSimulatedMovementRemoveReply(const Core::FunctionReplyObject& replyObject)
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
if (!replyObject.error())
|
||||
{
|
||||
m_sitMapGuiIfc->cancelActiveRubberbands();
|
||||
m_sitMapGuiIfc->removePreviewObject();
|
||||
}
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
if (!replyObject.error())
|
||||
{
|
||||
m_sitMapGuiIfc->cancelActiveRubberbands();
|
||||
m_sitMapGuiIfc->removePreviewObject();
|
||||
}
|
||||
}
|
||||
|
||||
void ParticipantMoveDialog::onSimulatedMovementModifyReply(const Core::FunctionReplyObject &replyObject)
|
||||
void ParticipantMoveDialog::onSimulatedMovementModifyReply(const Core::FunctionReplyObject& replyObject)
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
if (!replyObject.error())
|
||||
m_sitMapGuiIfc->removePreviewObject();
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
if (!replyObject.error())
|
||||
m_sitMapGuiIfc->removePreviewObject();
|
||||
}
|
||||
|
||||
void ParticipantMoveDialog::retranslate()
|
||||
{
|
||||
translate(m_ui, QString::fromStdString(m_participantData.tacticalIdentifier()), false, tr("Waypoints"));
|
||||
DEBUG_LOG(m_logger) << "retranslate";
|
||||
translate(m_ui, QString::fromStdString(m_participantData.tacticalIdentifier()), false, tr("Waypoints"));
|
||||
DEBUG_LOG(m_logger) << "retranslate";
|
||||
}
|
||||
|
||||
void ParticipantMoveDialog::initTableHeader()
|
||||
{
|
||||
QStringList headers;
|
||||
headers << tr("Identifier") << tr("Idle Time [s]") << tr("Speed [km/h]") << tr("Position");
|
||||
m_ui->tableWidget->setHorizontalHeaderLabels(headers);
|
||||
m_ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
||||
QStringList headers;
|
||||
headers << tr("Identifier") << tr("Idle Time [s]") << tr("Speed [km/h]") << tr("Position");
|
||||
m_ui->tableWidget->setHorizontalHeaderLabels(headers);
|
||||
m_ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
||||
}
|
||||
|
||||
|
||||
void ParticipantMoveDialog::insertPos(const double lon, const double lat, const QString &identifier, const int idleTime, const double speed)
|
||||
void ParticipantMoveDialog::insertPos(const double lon, const double lat, const QString& identifier, const int idleTime,
|
||||
const double speed)
|
||||
{
|
||||
QLineEdit *le = new QLineEdit;
|
||||
QSpinBox *sbDelay = new QSpinBox;
|
||||
QSpinBox *sbSpeed = new QSpinBox;
|
||||
sbDelay->setMinimum(m_ui->spIdleTime->minimum());
|
||||
sbDelay->setMaximum(m_ui->spIdleTime->maximum());
|
||||
sbSpeed->setMinimum(m_ui->spSpeed->minimum());
|
||||
sbSpeed->setMaximum(m_ui->spSpeed->maximum());
|
||||
int rowCount = m_ui->tableWidget->rowCount();
|
||||
QLineEdit* le = new QLineEdit;
|
||||
QSpinBox* sbDelay = new QSpinBox;
|
||||
QSpinBox* sbSpeed = new QSpinBox;
|
||||
sbDelay->setMinimum(m_ui->spIdleTime->minimum());
|
||||
sbDelay->setMaximum(m_ui->spIdleTime->maximum());
|
||||
sbSpeed->setMinimum(m_ui->spSpeed->minimum());
|
||||
sbSpeed->setMaximum(m_ui->spSpeed->maximum());
|
||||
int rowCount = m_ui->tableWidget->rowCount();
|
||||
|
||||
LtsCoordWidget::LtsCoordWidget *wdg = new LtsCoordWidget::LtsCoordWidget();
|
||||
|
||||
wdg->setCoordinate(lon, lat);
|
||||
wdg->setObjectName(QStringLiteral("positionEdit_") + QString::number(rowCount));
|
||||
m_ui->tableWidget->insertRow(rowCount);
|
||||
le->setText(identifier);
|
||||
m_ui->tableWidget->setCellWidget(rowCount, Name, le);
|
||||
sbDelay->setValue(idleTime / s_timeMilliConversion);
|
||||
m_ui->tableWidget->setCellWidget(rowCount, IdleTime, sbDelay);
|
||||
sbSpeed->setValue(speed * s_msConversion);
|
||||
m_ui->tableWidget->setCellWidget(rowCount, Speed, sbSpeed);
|
||||
m_ui->tableWidget->setCellWidget(rowCount, Position, wdg);
|
||||
wdg->setDisplayType(LtsCoordWidget::LtsCoordWidget::DisplayType::MGRS);
|
||||
LtsCoordWidget::LtsCoordWidget* wdg = new LtsCoordWidget::LtsCoordWidget();
|
||||
|
||||
wdg->setCoordinate(lon, lat);
|
||||
wdg->setObjectName(QStringLiteral("positionEdit_") + QString::number(rowCount));
|
||||
m_ui->tableWidget->insertRow(rowCount);
|
||||
le->setText(identifier);
|
||||
m_ui->tableWidget->setCellWidget(rowCount, Name, le);
|
||||
sbDelay->setValue(idleTime / s_timeMilliConversion);
|
||||
m_ui->tableWidget->setCellWidget(rowCount, IdleTime, sbDelay);
|
||||
sbSpeed->setValue(speed * s_msConversion);
|
||||
m_ui->tableWidget->setCellWidget(rowCount, Speed, sbSpeed);
|
||||
m_ui->tableWidget->setCellWidget(rowCount, Position, wdg);
|
||||
wdg->setDisplayType(LtsCoordWidget::LtsCoordWidget::DisplayType::MGRS);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void ParticipantMoveDialog::clearContent()
|
||||
{
|
||||
m_ui->lePrefix->clear();
|
||||
m_ui->cbRepeat->setChecked(false);
|
||||
m_ui->cbJump->setChecked(false);
|
||||
m_ui->lePrefix->clear();
|
||||
m_ui->cbRepeat->setChecked(false);
|
||||
m_ui->cbJump->setChecked(false);
|
||||
|
||||
clearCoordinates();
|
||||
clearCoordinates();
|
||||
}
|
||||
|
||||
void ParticipantMoveDialog::clearCoordinates()
|
||||
{
|
||||
if (m_ui)
|
||||
{
|
||||
m_ui->tableWidget->clearContents();
|
||||
m_ui->tableWidget->setRowCount(0);
|
||||
}
|
||||
|
||||
if ( m_sitMapGuiIfc && this->amIFocused())
|
||||
m_sitMapGuiIfc->removePreviewObject();
|
||||
if (m_ui)
|
||||
{
|
||||
m_ui->tableWidget->clearContents();
|
||||
m_ui->tableWidget->setRowCount(0);
|
||||
}
|
||||
|
||||
if (m_sitMapGuiIfc && this->amIFocused())
|
||||
m_sitMapGuiIfc->removePreviewObject();
|
||||
}
|
||||
|
||||
void ParticipantMoveDialog::onFocus()
|
||||
{
|
||||
showPreview(true);
|
||||
m_sitMapGuiIfc->displayPreviewObject(this, m_polyline, false);
|
||||
showPreview(true);
|
||||
m_sitMapGuiIfc->displayPreviewObject(this, m_polyline, false);
|
||||
}
|
||||
|
||||
void ParticipantMoveDialog::onGetPolyline()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO;
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO;
|
||||
|
||||
if (!m_sitMapGuiIfc)
|
||||
return;
|
||||
if (!m_sitMapGuiIfc)
|
||||
return;
|
||||
|
||||
if (m_sitMapGuiIfc->mapMode() != SituationMap::MapMode::MapMode_2D)
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Only available in 2D mode"));
|
||||
return;
|
||||
}
|
||||
if (m_sitMapGuiIfc->mapMode() != SituationMap::MapMode::MapMode_2D)
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Only available in 2D mode"));
|
||||
return;
|
||||
}
|
||||
|
||||
QPolygonF coordinates;
|
||||
int i = 0;
|
||||
while (true)
|
||||
{
|
||||
LtsCoordWidget::LtsCoordWidget *w = findChild<LtsCoordWidget::LtsCoordWidget *>(QStringLiteral("positionEdit_%1").arg(i));
|
||||
if (!w)
|
||||
break;
|
||||
if (!w->coordinate().isNull())
|
||||
coordinates << w->coordinate();
|
||||
++i;
|
||||
}
|
||||
QPolygonF coordinates;
|
||||
int i = 0;
|
||||
while (true)
|
||||
{
|
||||
LtsCoordWidget::LtsCoordWidget* w =
|
||||
findChild<LtsCoordWidget::LtsCoordWidget*>(QStringLiteral("positionEdit_%1").arg(i));
|
||||
if (!w)
|
||||
break;
|
||||
if (!w->coordinate().isNull())
|
||||
coordinates << w->coordinate();
|
||||
++i;
|
||||
}
|
||||
|
||||
m_sitMapGuiIfc->getPolyline(this,
|
||||
SLOT(onPolylineData(QPolygonF)),
|
||||
nullptr,
|
||||
2,
|
||||
11,
|
||||
-1,
|
||||
-1,
|
||||
coordinates);
|
||||
m_sitMapGuiIfc->getPolyline(this, SLOT(onPolylineData(QPolygonF)), nullptr, 2, 11, -1, -1, coordinates);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void ParticipantMoveDialog::onPolylineData(const QPolygonF &polyline)
|
||||
void ParticipantMoveDialog::onPolylineData(const QPolygonF& polyline)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " numberOfPoints: " << polyline.size();
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " numberOfPoints: " << polyline.size();
|
||||
|
||||
if (polyline.size() < 2)
|
||||
return;
|
||||
if (polyline.size() < 2)
|
||||
return;
|
||||
|
||||
m_polyline = polyline;
|
||||
m_polyline = polyline;
|
||||
|
||||
clearCoordinates();
|
||||
for (int i = 0; i < polyline.size(); i++)
|
||||
insertPos(polyline.at(i).x(), polyline.at(i).y(),
|
||||
m_ui->lePrefix->text() + QLatin1Char('_') + QString::number(i + 1),
|
||||
m_ui->spIdleTime->value() * s_timeMilliConversion,
|
||||
m_ui->spSpeed->value() / s_msConversion);
|
||||
clearCoordinates();
|
||||
for (int i = 0; i < polyline.size(); i++)
|
||||
insertPos(polyline.at(i).x(), polyline.at(i).y(),
|
||||
m_ui->lePrefix->text() + QLatin1Char('_') + QString::number(i + 1),
|
||||
m_ui->spIdleTime->value() * s_timeMilliConversion, m_ui->spSpeed->value() / s_msConversion);
|
||||
|
||||
|
||||
m_sitMapGuiIfc->displayPreviewObject(this, polyline, false);
|
||||
m_sitMapGuiIfc->displayPreviewObject(this, polyline, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool ParticipantMoveDialog::hasValidEffectStart(LtsWidgets::LtsDateTimeEdit *dte) const
|
||||
bool ParticipantMoveDialog::hasValidEffectStart(LtsWidgets::LtsDateTimeEdit* dte) const
|
||||
{
|
||||
|
||||
const bool bEmptyAllowed = dte->isCheckable();
|
||||
const auto ms = dte->msecsSinceEpoch();
|
||||
|
||||
if (bEmptyAllowed && ms == 0)
|
||||
return true;
|
||||
return ms > m_session->partitionTime();
|
||||
|
||||
const bool bEmptyAllowed = dte->isCheckable();
|
||||
const auto ms = dte->msecsSinceEpoch();
|
||||
|
||||
if (bEmptyAllowed && ms == 0)
|
||||
return true;
|
||||
return ms > m_session->partitionTime();
|
||||
}
|
||||
|
||||
SimulatedMovement ParticipantMoveDialog::requestContent() const
|
||||
{
|
||||
std::string name = m_ui->lePrefix->text().toStdString();
|
||||
int32_t repeat = m_ui->cbRepeat->isChecked();
|
||||
|
||||
int32_t jumpToStart = true;
|
||||
rti::core::int64 startTime = m_ui->dteStartTime->msecsSinceEpoch();
|
||||
int32_t participantId = m_participantData.id();
|
||||
int32_t nextPoint = 0;
|
||||
std::string name = m_ui->lePrefix->text().toStdString();
|
||||
int32_t repeat = m_ui->cbRepeat->isChecked();
|
||||
|
||||
int cntSegments = m_ui->tableWidget->rowCount();
|
||||
std::vector<CentralEffectSimulation::SimulatedMovementSegment> segments;
|
||||
segments.resize(cntSegments);
|
||||
for (int i = 0; i < cntSegments; i++)
|
||||
{
|
||||
QWidget *widget = m_ui->tableWidget->cellWidget(i, Name);
|
||||
const QString nameSeg = static_cast<QLineEdit *>(widget)->text();
|
||||
segments[i].name(nameSeg.toStdString());
|
||||
int32_t jumpToStart = true;
|
||||
rti::core::int64 startTime = m_ui->dteStartTime->msecsSinceEpoch();
|
||||
int32_t participantId = m_participantData.id();
|
||||
int32_t nextPoint = 0;
|
||||
|
||||
widget = m_ui->tableWidget->cellWidget(i, IdleTime);
|
||||
const int idleTime = static_cast<QSpinBox *>(widget)->value() * s_timeMilliConversion;
|
||||
segments[i].delay(idleTime);
|
||||
int cntSegments = m_ui->tableWidget->rowCount();
|
||||
std::vector<CentralEffectSimulation::SimulatedMovementSegment> segments;
|
||||
segments.resize(cntSegments);
|
||||
for (int i = 0; i < cntSegments; i++)
|
||||
{
|
||||
QWidget* widget = m_ui->tableWidget->cellWidget(i, Name);
|
||||
const QString nameSeg = static_cast<QLineEdit*>(widget)->text();
|
||||
segments[i].name(nameSeg.toStdString());
|
||||
|
||||
widget = m_ui->tableWidget->cellWidget(i, Speed);
|
||||
const double speed = static_cast<QSpinBox *>(widget)->value() / s_msConversion;
|
||||
widget = m_ui->tableWidget->cellWidget(i, IdleTime);
|
||||
const int idleTime = static_cast<QSpinBox*>(widget)->value() * s_timeMilliConversion;
|
||||
segments[i].delay(idleTime);
|
||||
|
||||
segments[i].speed(speed);
|
||||
widget = m_ui->tableWidget->cellWidget(i, Speed);
|
||||
const double speed = static_cast<QSpinBox*>(widget)->value() / s_msConversion;
|
||||
|
||||
widget = m_ui->tableWidget->cellWidget(i, Position);
|
||||
const QPointF point = static_cast<LtsCoordWidget::LtsCoordWidget *>(widget)->coordinate();
|
||||
const Core::GeoPosition2D pos(Core::GeoPosition2D(point.x(), point.y()));
|
||||
segments[i].position(pos);
|
||||
}
|
||||
segments[i].speed(speed);
|
||||
|
||||
return SimulatedMovement(m_id,
|
||||
name,
|
||||
startTime,
|
||||
participantId,
|
||||
segments,
|
||||
repeat,
|
||||
jumpToStart,
|
||||
nextPoint
|
||||
);
|
||||
widget = m_ui->tableWidget->cellWidget(i, Position);
|
||||
const QPointF point = static_cast<LtsCoordWidget::LtsCoordWidget*>(widget)->coordinate();
|
||||
const Core::GeoPosition2D pos(Core::GeoPosition2D(point.x(), point.y()));
|
||||
segments[i].position(pos);
|
||||
}
|
||||
|
||||
return SimulatedMovement(m_id, name, startTime, participantId, segments, repeat, jumpToStart, nextPoint);
|
||||
}
|
||||
|
||||
bool ParticipantMoveDialog::apply()
|
||||
{
|
||||
int cntSegments = m_ui->tableWidget->rowCount();
|
||||
if (cntSegments > 0)
|
||||
{
|
||||
const SimulatedMovement req = requestContent();
|
||||
|
||||
INFO_LOG(m_logger) << "--- onApplyMessage() ";
|
||||
|
||||
m_requestHelper->addRequest([this, req]()
|
||||
int cntSegments = m_ui->tableWidget->rowCount();
|
||||
if (cntSegments > 0)
|
||||
{
|
||||
return m_ftc->simulatedMovementModifyRequest(req, this);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_id > 0)
|
||||
{
|
||||
Core::RemoveElementRequest req(m_id);
|
||||
m_id = 0;
|
||||
const SimulatedMovement req = requestContent();
|
||||
|
||||
INFO_LOG(m_logger) << "--- onApplyMessage() ";
|
||||
INFO_LOG(m_logger) << "--- onApplyMessage() ";
|
||||
|
||||
m_requestHelper->addRequest([req, this]()
|
||||
{
|
||||
return m_ftc->simulatedMovementRemoveRequest(req, this);
|
||||
});
|
||||
m_requestHelper->addRequest([this, req]() { return m_ftc->simulatedMovementModifyRequest(req, this); });
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_id > 0)
|
||||
{
|
||||
Core::RemoveElementRequest req(m_id);
|
||||
m_id = 0;
|
||||
|
||||
return m_requestHelper->startRequests();
|
||||
INFO_LOG(m_logger) << "--- onApplyMessage() ";
|
||||
|
||||
m_requestHelper->addRequest([req, this]() { return m_ftc->simulatedMovementRemoveRequest(req, this); });
|
||||
}
|
||||
}
|
||||
|
||||
return m_requestHelper->startRequests();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
QByteArray ParticipantMoveDialog::simulatedMovementToJson() const
|
||||
{
|
||||
const SimulatedMovement req = requestContent();
|
||||
QJsonObject obj;
|
||||
obj[QStringLiteral("XmlType")] = FileManagement::toString(FileManagement::XmlType::CESParticipantMove);
|
||||
const SimulatedMovement req = requestContent();
|
||||
QJsonObject obj;
|
||||
obj[QStringLiteral("XmlType")] = FileManagement::toString(FileManagement::XmlType::CESParticipantMove);
|
||||
|
||||
obj[QStringLiteral("id")] = req.id();
|
||||
obj[QStringLiteral("jumpToStart")] = req.jumpToStart();
|
||||
obj[QStringLiteral("name")] = QString::fromStdString(req.name());
|
||||
obj[QStringLiteral("nextPoint")] = req.nextPoint();
|
||||
obj[QStringLiteral("participantId")] = req.participantId();
|
||||
obj[QStringLiteral("repeat")] = req.repeat();
|
||||
obj[QStringLiteral("startTime")] = req.startTime();
|
||||
obj[QStringLiteral("id")] = req.id();
|
||||
obj[QStringLiteral("jumpToStart")] = req.jumpToStart();
|
||||
obj[QStringLiteral("name")] = QString::fromStdString(req.name());
|
||||
obj[QStringLiteral("nextPoint")] = req.nextPoint();
|
||||
obj[QStringLiteral("participantId")] = req.participantId();
|
||||
obj[QStringLiteral("repeat")] = req.repeat();
|
||||
obj[QStringLiteral("startTime")] = req.startTime();
|
||||
|
||||
QJsonArray arr;
|
||||
for (auto it = req.segments().begin(); it != req.segments().end(); ++it)
|
||||
{
|
||||
QJsonObject inner;
|
||||
inner[QStringLiteral("delay")] = it->delay();
|
||||
inner[QStringLiteral("name")] = QString::fromStdString(it->name());
|
||||
inner[QStringLiteral("speed")] = it->speed();
|
||||
inner[QStringLiteral("lat")] = it->position().lat();
|
||||
inner[QStringLiteral("lon")] = it->position().lon();
|
||||
arr += inner;
|
||||
}
|
||||
obj[QStringLiteral("segments")] = arr;
|
||||
QJsonArray arr;
|
||||
for (auto it = req.segments().begin(); it != req.segments().end(); ++it)
|
||||
{
|
||||
QJsonObject inner;
|
||||
inner[QStringLiteral("delay")] = it->delay();
|
||||
inner[QStringLiteral("name")] = QString::fromStdString(it->name());
|
||||
inner[QStringLiteral("speed")] = it->speed();
|
||||
inner[QStringLiteral("lat")] = it->position().lat();
|
||||
inner[QStringLiteral("lon")] = it->position().lon();
|
||||
arr += inner;
|
||||
}
|
||||
obj[QStringLiteral("segments")] = arr;
|
||||
|
||||
QJsonDocument doc(obj);
|
||||
return doc.toJson(QJsonDocument::Compact);
|
||||
QJsonDocument doc(obj);
|
||||
return doc.toJson(QJsonDocument::Compact);
|
||||
}
|
||||
|
||||
SimulatedMovement ParticipantMoveDialog::jsonToSimulatedMovement(const QByteArray &content) const
|
||||
SimulatedMovement ParticipantMoveDialog::jsonToSimulatedMovement(const QByteArray& content) const
|
||||
{
|
||||
|
||||
CentralEffectSimulation::SimulatedMovement result;
|
||||
const QJsonDocument doc(QJsonDocument::fromJson(content));
|
||||
const QJsonObject obj(doc.object());
|
||||
|
||||
result.id(obj[QStringLiteral("id")].toInt());
|
||||
result.jumpToStart(obj[QStringLiteral("jumpToStart")].toInt());
|
||||
result.name(obj[QStringLiteral("name")].toString().toStdString());
|
||||
result.nextPoint(obj[QStringLiteral("nextPoint")].toInt());
|
||||
result.participantId(m_participantData.id());
|
||||
result.repeat(obj[QStringLiteral("repeat")].toInt());
|
||||
result.startTime(obj[QStringLiteral("startTime")].toDouble());
|
||||
CentralEffectSimulation::SimulatedMovement result;
|
||||
const QJsonDocument doc(QJsonDocument::fromJson(content));
|
||||
const QJsonObject obj(doc.object());
|
||||
|
||||
const QJsonArray arr(obj.value(QStringLiteral("segments")).toArray());
|
||||
auto &segments = result.segments();
|
||||
segments.resize(arr.size());
|
||||
for (int i = 0; i < arr.size(); ++i)
|
||||
{
|
||||
CentralEffectSimulation::SimulatedMovementSegment &segment = segments[i];
|
||||
const QJsonObject objArr(arr.at(i).toObject());
|
||||
segment.delay(objArr[QStringLiteral("delay")].toDouble());
|
||||
segment.name(objArr[QStringLiteral("name")].toString().toStdString());
|
||||
result.id(obj[QStringLiteral("id")].toInt());
|
||||
result.jumpToStart(obj[QStringLiteral("jumpToStart")].toInt());
|
||||
result.name(obj[QStringLiteral("name")].toString().toStdString());
|
||||
result.nextPoint(obj[QStringLiteral("nextPoint")].toInt());
|
||||
result.participantId(m_participantData.id());
|
||||
result.repeat(obj[QStringLiteral("repeat")].toInt());
|
||||
result.startTime(obj[QStringLiteral("startTime")].toDouble());
|
||||
|
||||
const QJsonArray arr(obj.value(QStringLiteral("segments")).toArray());
|
||||
auto& segments = result.segments();
|
||||
segments.resize(arr.size());
|
||||
for (int i = 0; i < arr.size(); ++i)
|
||||
{
|
||||
CentralEffectSimulation::SimulatedMovementSegment& segment = segments[i];
|
||||
const QJsonObject objArr(arr.at(i).toObject());
|
||||
segment.delay(objArr[QStringLiteral("delay")].toDouble());
|
||||
segment.name(objArr[QStringLiteral("name")].toString().toStdString());
|
||||
|
||||
segment.position().lat(objArr[QStringLiteral("lat")].toDouble());
|
||||
segment.position().lon(objArr[QStringLiteral("lon")].toDouble());
|
||||
segment.speed(objArr[QStringLiteral("speed")].toDouble());
|
||||
}
|
||||
return result;
|
||||
segment.position().lat(objArr[QStringLiteral("lat")].toDouble());
|
||||
segment.position().lon(objArr[QStringLiteral("lon")].toDouble());
|
||||
segment.speed(objArr[QStringLiteral("speed")].toDouble());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void ParticipantMoveDialog::onExportButtonClicked()
|
||||
{
|
||||
QJsonObject saveObject;
|
||||
saveObject[QStringLiteral("content")] = QString();
|
||||
QJsonObject saveObject;
|
||||
saveObject[QStringLiteral("content")] = QString();
|
||||
|
||||
const QByteArray byteArray = simulatedMovementToJson();
|
||||
const QByteArray byteArray = simulatedMovementToJson();
|
||||
|
||||
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 ";
|
||||
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 ParticipantMoveDialog::onImportButtonClicked()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << " 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::CESParticipantMove));
|
||||
if (fileId > 0)
|
||||
{
|
||||
if (!m_flmGui->isXmlType(content, FileManagement::toString(FileManagement::XmlType::CESParticipantMove)))
|
||||
QByteArray content;
|
||||
int fileId = m_flmGui->loadFileContent(this, content, {FileManagement::FileType::Xml}, m_session->exerciseId(),
|
||||
FileManagement::toString(FileManagement::XmlType::CESParticipantMove));
|
||||
if (fileId > 0)
|
||||
{
|
||||
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
|
||||
{
|
||||
SimulatedMovement req = jsonToSimulatedMovement(content);
|
||||
if (!m_flmGui->isXmlType(content, FileManagement::toString(FileManagement::XmlType::CESParticipantMove)))
|
||||
{
|
||||
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
|
||||
{
|
||||
SimulatedMovement req = jsonToSimulatedMovement(content);
|
||||
|
||||
INFO_LOG(m_logger) << "--- onImportButtonClicked() ";
|
||||
INFO_LOG(m_logger) << "--- onImportButtonClicked() ";
|
||||
|
||||
m_requestHelper->addRequest([this, req]()
|
||||
{
|
||||
return m_ftc->simulatedMovementModifyRequest(req, this);
|
||||
});
|
||||
m_requestHelper->startRequests();
|
||||
m_requestHelper->addRequest([this, req]() { return m_ftc->simulatedMovementModifyRequest(req, this); });
|
||||
m_requestHelper->startRequests();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
} // namespace CentralEffectSimulation
|
||||
Executable → Regular
+618
-667
File diff suppressed because it is too large.
Load diff
Executable → Regular
+40
-45
@@ -1,73 +1,68 @@
|
||||
|
||||
|
||||
|
||||
#include "participants_move_model.h"
|
||||
|
||||
#include <ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
|
||||
|
||||
namespace CentralEffectSimulation
|
||||
{
|
||||
|
||||
ParticipantMoveModel::ParticipantMoveModel(QObject *parent,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
const std::shared_ptr<AdvancedSymbology::ForeignDataInterface> &asbIfc)
|
||||
: ParticipantManagement::ParticipantEditModel(parent, ppmDtc, asbIfc)
|
||||
ParticipantMoveModel::ParticipantMoveModel(QObject* parent,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc>& ppmDtc,
|
||||
const std::shared_ptr<AdvancedSymbology::ForeignDataInterface>& asbIfc)
|
||||
: ParticipantManagement::ParticipantEditModel(parent, ppmDtc, asbIfc)
|
||||
{
|
||||
m_titles += tr("Simulated");
|
||||
m_titles += tr("Simulated");
|
||||
|
||||
connect(m_dtc.get(), &ParticipantManagement::Interface::Dtc::participantChanged,
|
||||
this, &ParticipantMoveModel::onParticipantChanged);
|
||||
connect(m_dtc.get(), &ParticipantManagement::Interface::Dtc::participantChanged, this,
|
||||
&ParticipantMoveModel::onParticipantChanged);
|
||||
|
||||
DEBUG_LOG(m_logger) << "ParticipantMoveModel::ParticipantMoveModel";
|
||||
DEBUG_LOG(m_logger) << "ParticipantMoveModel::ParticipantMoveModel";
|
||||
}
|
||||
|
||||
|
||||
QVariant ParticipantMoveModel::data(const QModelIndex &index, int role) const
|
||||
QVariant ParticipantMoveModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
|
||||
if (role == Qt::DisplayRole && index.column() == columnCount() - 1)
|
||||
{
|
||||
bool bIsSimulated = false;
|
||||
if (!isSelectableBySimulation(index, &bIsSimulated))
|
||||
return QVariant();
|
||||
return bIsSimulated ? tr("Yes") : tr("No");
|
||||
}
|
||||
|
||||
return ParticipantManagement::ParticipantEditModel::data(index, role);
|
||||
if (role == Qt::DisplayRole && index.column() == columnCount() - 1)
|
||||
{
|
||||
bool bIsSimulated = false;
|
||||
if (!isSelectableBySimulation(index, &bIsSimulated))
|
||||
return QVariant();
|
||||
return bIsSimulated ? tr("Yes") : tr("No");
|
||||
}
|
||||
|
||||
return ParticipantManagement::ParticipantEditModel::data(index, role);
|
||||
}
|
||||
|
||||
void ParticipantMoveModel::onParticipantChanged(const ParticipantManagement::Participant &data, DataModification modType)
|
||||
void ParticipantMoveModel::onParticipantChanged(const ParticipantManagement::Participant& data,
|
||||
DataModification modType)
|
||||
{
|
||||
Q_UNUSED(modType)
|
||||
if (data.partyId() != m_partyId)
|
||||
return;
|
||||
INFO_LOG(m_logger) << "onParticipantChanged isSimulated=" << data.isSimulated();
|
||||
onReinitModel(partyId());
|
||||
emit newData();
|
||||
Q_UNUSED(modType)
|
||||
if (data.partyId() != m_partyId)
|
||||
return;
|
||||
INFO_LOG(m_logger) << "onParticipantChanged isSimulated=" << data.isSimulated();
|
||||
onReinitModel(partyId());
|
||||
emit newData();
|
||||
}
|
||||
|
||||
bool ParticipantMoveModel::isSelectableBySimulation(const QModelIndex &index, bool *bIsSimulated) const
|
||||
bool ParticipantMoveModel::isSelectableBySimulation(const QModelIndex& index, bool* bIsSimulated) const
|
||||
{
|
||||
bool isSimulatable = true;
|
||||
const ParticipantManagement::ParticipantData data(getParticipantData(index));
|
||||
bool isSimulatable = true;
|
||||
const ParticipantManagement::ParticipantData data(getParticipantData(index));
|
||||
|
||||
if ((data.equipmentNumber().is_set() && data.equipmentNumber().get() > 0) ||
|
||||
m_dtc->type(data.typeId()).typeClass() == ParticipantManagement::TypeClass_def::Unit)
|
||||
isSimulatable = false;
|
||||
if ((data.equipmentNumber().is_set() && data.equipmentNumber().get() > 0) ||
|
||||
m_dtc->type(data.typeId()).typeClass() == ParticipantManagement::TypeClass_def::Unit)
|
||||
isSimulatable = false;
|
||||
|
||||
DEBUG_LOG(m_logger) << "ParticipantId: " << data.id()
|
||||
<< " isSimulated:" << data.isSimulated()
|
||||
<< " equipmentNo:" << data.equipmentNumber()
|
||||
<< " typeId=" << data.typeId()
|
||||
<< " modId=" << data.modId()
|
||||
<< " typeClass=" << m_dtc->type(data.typeId()).typeClass()
|
||||
<< " isSimulatable=" << isSimulatable;
|
||||
DEBUG_LOG(m_logger) << "ParticipantId: " << data.id() << " isSimulated:" << data.isSimulated()
|
||||
<< " equipmentNo:" << data.equipmentNumber() << " typeId=" << data.typeId()
|
||||
<< " modId=" << data.modId() << " typeClass=" << m_dtc->type(data.typeId()).typeClass()
|
||||
<< " isSimulatable=" << isSimulatable;
|
||||
|
||||
if (bIsSimulated)
|
||||
*bIsSimulated = data.isSimulated();
|
||||
if (bIsSimulated)
|
||||
*bIsSimulated = data.isSimulated();
|
||||
|
||||
return isSimulatable;
|
||||
return isSimulatable;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace CentralEffectSimulation
|
||||
Executable → Regular
+17
-21
@@ -1,36 +1,32 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <nglwidgets/ngltreeitem.h>
|
||||
#include <ParticipantManagement/ppm_dtc.h>
|
||||
#include <QStringList>
|
||||
|
||||
#include "logger.h"
|
||||
|
||||
#include <ParticipantManagement/Gui/Common/participant_edit_model.h>
|
||||
#include "logger.h"
|
||||
#include <ParticipantManagement/ppm_dtc.h>
|
||||
#include <QObject>
|
||||
#include <QStringList>
|
||||
#include <nglwidgets/ngltreeitem.h>
|
||||
|
||||
namespace CentralEffectSimulation
|
||||
{
|
||||
class ParticipantMoveModel final : public ParticipantManagement::ParticipantEditModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ParticipantMoveModel(QObject *parent,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
const std::shared_ptr<AdvancedSymbology::ForeignDataInterface> &asbIfc);
|
||||
Q_OBJECT
|
||||
public:
|
||||
ParticipantMoveModel(QObject* parent, const std::shared_ptr<ParticipantManagement::Interface::Dtc>& ppmDtc,
|
||||
const std::shared_ptr<AdvancedSymbology::ForeignDataInterface>& asbIfc);
|
||||
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
|
||||
|
||||
signals:
|
||||
void newData();
|
||||
signals:
|
||||
void newData();
|
||||
|
||||
private:
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
void onParticipantChanged(const ParticipantManagement::Participant &data, DataModification modType);
|
||||
bool isSelectableBySimulation(const QModelIndex &index, bool *bIsSimulated = nullptr) const;
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
void onParticipantChanged(const ParticipantManagement::Participant& data, DataModification modType);
|
||||
bool isSelectableBySimulation(const QModelIndex& index, bool* bIsSimulated = nullptr) const;
|
||||
};
|
||||
}
|
||||
} // namespace CentralEffectSimulation
|
||||
Reference in new issue
Block a user