Initial commit

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

No files matched your search

@@ -0,0 +1,92 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Configure_Single_Url</class>
<widget class="QWidget" name="Configure_Single_Url">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1099</width>
<height>134</height>
</rect>
</property>
<property name="windowTitle">
<string notr="true">Layer Control</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Url:</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Name:</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QLabel" name="label_3">
<property name="toolTip">
<string>Min. zoom in limit</string>
</property>
<property name="text">
<string>Min Scale:</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLineEdit" name="le_minScale">
<property name="text">
<string notr="true">-1</string>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QLabel" name="label_4">
<property name="toolTip">
<string>Max. zoom in limit</string>
</property>
<property name="text">
<string>Max Scale:</string>
</property>
</widget>
</item>
<item row="2" column="4">
<widget class="QLineEdit" name="le_maxScale">
<property name="text">
<string notr="true">-1</string>
</property>
</widget>
</item>
<item row="3" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>17</width>
<height>13</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="2" colspan="3">
<widget class="QLineEdit" name="le_name"/>
</item>
<item row="0" column="2" colspan="3">
<widget class="QLineEdit" name="le_url"/>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
@@ -0,0 +1,106 @@
/**
* @RDE_HEADER@
* SituationMap - ConfigureMapUrlsDialog
* $Id$
* $HeadURL$
* $Author$
* Created by Norbert Thoden, SLSE, 2018-09-19
*/
#include "sitmap_configure_url_model.h"
//ASM
#include <AssetManagement/asm_data_plugin_interface.h>
// Qt
namespace SituationMap
{
ConfigureMapUrlModel::ConfigureMapUrlModel(QObject *parent)
: BaseClass( {tr("Name"), tr("Url"), tr("Map Type"), tr("Min Scale"), tr("Max Scale")}, parent)
{
}
ConfigureMapUrlModel::~ConfigureMapUrlModel()
{
}
void ConfigureMapUrlModel::addData(const DATA_T &entry)
{
for (const auto &r : qAsConst(m_vecData))
{
if (r == entry)
return;
}
beginInsertRows(QModelIndex(), m_vecData.size(), m_vecData.size());
m_vecData += entry;
endInsertRows();
}
QModelIndex ConfigureMapUrlModel::moveRow(const QModelIndex &sourceIndex, int destinationRow)
{
if (destinationRow >= m_vecData.size() || destinationRow < 0)
return sourceIndex;
std::swap(m_vecData[destinationRow], m_vecData[sourceIndex.row()]);
// only works as expected when destinationRow is +/-1 from sourceRow
QModelIndex idx = index(destinationRow, 0);
emit dataChanged(index(sourceIndex.row(), 0), index(sourceIndex.row(), columnCount(QModelIndex()) - 1));
emit dataChanged(idx, index(destinationRow, columnCount(QModelIndex()) - 1));
return idx;
}
QVector<ConfigureMapUrlModel::DATA_T> ConfigureMapUrlModel::allData() const
{
return m_vecData;
}
QVariant ConfigureMapUrlModel::data(const QModelIndex &index, int role) const
{
if ((role != Qt::DisplayRole &&
role != Qt::EditRole &&
role != Qt::UserRole) || !index.isValid() || index.row() >= m_vecData.size())
return QVariant();
const DATA_T &md = m_vecData.at(index.row());
switch (index.column())
{
case Columns::Url:
return QString::fromStdString(md.url());
case Columns::Name:
return QString::fromStdString(md.name());
case Columns::MapType:
{
switch (md.mapTypeId().underlying())
{
case AssetManagement::MapType_def::Aerial:
return tr("Aerial");
case AssetManagement::MapType_def::Topographic:
return tr("Topographic");
case AssetManagement::MapType_def::Unknown:
case AssetManagement::MapType_def::Feature:
case AssetManagement::MapType_def::Elevation:
case AssetManagement::MapType_def::SceneObjects:
break;
//empty
}
return tr("Unknown");
}
case Columns::MinScale:
return md.minScale();
case Columns::MaxScale:
return md.maxScale();
}
return QVariant();
}
} //namespace SituationMap
@@ -0,0 +1,56 @@
/**
* @RDE_HEADER@
* SituationMap - ConfigureMapUrlsDialog
* $Id$
* $HeadURL$
* $Author$
* Created by Norbert Thoden, SLSE, 2018-09-19
*/
#pragma once
#include <LtsWidgets/lts_abstract_table_model.h>
//Qt
namespace AssetManagement
{
class MapDescription;
}
namespace SituationMap
{
// --------------------------------------------------------
// ConfigureMapUrlModel
// --------------------------------------------------------
class ConfigureMapUrlModel : public LtsWidgets::LtsAbstractTableModel<AssetManagement::MapDescription>
{
Q_OBJECT
using BaseClass = LtsWidgets::LtsAbstractTableModel<AssetManagement::MapDescription>;
using DATA_T = AssetManagement::MapDescription;
public:
enum Columns
{
Name,
Url,
MapType,
MinScale,
MaxScale,
};
explicit ConfigureMapUrlModel(QObject *parent = nullptr);
~ConfigureMapUrlModel();
QVariant data(const QModelIndex &index, int role) const override;
void addData(const DATA_T &entry);
QModelIndex moveRow(const QModelIndex &sourceIndex, int destinationRow);
QVector<ConfigureMapUrlModel::DATA_T> allData() const;
};
}// namespace SituationMap
@@ -0,0 +1,232 @@
/**
* @RDE_HEADER@
* SituationMap - ConfigureMapUrlsWidgetDialog
* $Id$
* $HeadURL$
* $Author$
* Created by Norbert Thoden, SLSE, 2018-09-19
*/
#include "sitmap_configure_url_widget.h"
#include "ui_sitmap_configure_url_widget.h"
#include "ui_sitmap_configure_single_url.h"
#include "sitmap_configure_url_model.h"
//ASM
#include <AssetManagement/asm_data_plugin_interface.h>
constexpr int MIN_SCALE = -1;
constexpr int MAX_SCALE = 9999999;
namespace SituationMap
{
//------------------------------------------------------------------------------
ConfigureSingleMapUrl::ConfigureSingleMapUrl(QWidget *parent)
: BaseClass(parent/*, LtsWidgets::ButtonCombination::OkApplyCancel*/)
, m_ui(new Ui::Configure_Single_Url)
, m_buttonBox(new LtsWidgets::LtsDialogButtonBox(this))
{
setAttribute(Qt::WA_DeleteOnClose);
m_ui->setupUi(this);
layout()->addWidget(m_buttonBox);
connect(m_buttonBox->getButton(LtsWidgets::DialogButton::Ok), &QPushButton::clicked, this, &ConfigureSingleMapUrl::onOk);
connect(m_buttonBox->getButton(LtsWidgets::DialogButton::Close), &QPushButton::clicked, this, &ConfigureSingleMapUrl::onClose);
m_ui->le_url->setPlaceholderText(QStringLiteral("http://HOSTNAME/arcgis/rest/services/XXXX/MapServer"));
m_ui->le_name->setPlaceholderText(tr("Displayname"));
// minScale to limit zoom out
m_ui->le_minScale->setPlaceholderText(tr("limit zoom out, '-1' for invalid, '0' for infinite"));
m_ui->le_minScale->setValidator(new QIntValidator(MIN_SCALE, MAX_SCALE, this));
m_ui->le_minScale->setToolTip(m_ui->le_minScale->placeholderText());
// maxScale to limit zoom in
m_ui->le_maxScale->setPlaceholderText(tr("limit zoom in, '-1' for invalid"));
m_ui->le_maxScale->setValidator(new QIntValidator(MIN_SCALE, MAX_SCALE, this));
m_ui->le_maxScale->setToolTip(m_ui->le_maxScale->placeholderText());
}
ConfigureSingleMapUrl::~ConfigureSingleMapUrl()
{
}
void ConfigureSingleMapUrl::setPlaceholderTextForFile()
{
m_ui->le_url->setPlaceholderText(QStringLiteral("file:filename.ext"));
}
void ConfigureSingleMapUrl::setData(const ConfigureSingleMapUrl::DATA_T &data)
{
m_ui->le_url->setText(QString::fromStdString(data.url()));
m_ui->le_name->setText(QString::fromStdString(data.name()));
m_ui->le_minScale->setText(QString::number(data.minScale()));
m_ui->le_maxScale->setText(QString::number(data.maxScale()));
}
ConfigureSingleMapUrl::DATA_T ConfigureSingleMapUrl::data()
{
ConfigureSingleMapUrl::DATA_T data;
data.url(m_ui->le_url->text().trimmed().toStdString());
data.name(m_ui->le_name->text().trimmed().toStdString());
data.minScale(m_ui->le_minScale->text().toDouble());
data.maxScale(m_ui->le_maxScale->text().toDouble());
return data;
}
void ConfigureSingleMapUrl::onOk()
{
emit signalApply();
this->close();
}
void ConfigureSingleMapUrl::onClose()
{
this->close();
}
//------------------------------------------------------------------------------
ConfigureMapUrlsWidget::ConfigureMapUrlsWidget(QWidget *parent)
: QWidget(parent)
, m_ui(new Ui::Configure_Urls_Widget)
, m_logger(getLogger("ConfigureMapUrlsWidget"))
{
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
m_ui->setupUi(this);
connect(m_ui->pbUp, &QPushButton::clicked, this, &ConfigureMapUrlsWidget::onUpClicked);
connect(m_ui->pbDown, &QPushButton::clicked, this, &ConfigureMapUrlsWidget::onDownClicked);
connect(m_ui->pbAdd, &QPushButton::clicked, this, &ConfigureMapUrlsWidget::onAddClicked);
connect(m_ui->pbModify, &QPushButton::clicked, this, &ConfigureMapUrlsWidget::onModfiyClicked);
connect(m_ui->pbRemove, &QPushButton::clicked, this, &ConfigureMapUrlsWidget::onRemoveClicked);
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
}
ConfigureMapUrlsWidget::~ConfigureMapUrlsWidget()
{
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
delete m_ui;
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
}
void ConfigureMapUrlsWidget::setModel(ConfigureMapUrlModel *model)
{
if (!m_ui->tvLayer || !model)
return;
m_ui->tvLayer->setModel(model);
m_ui->tvLayer->hideColumn(ConfigureMapUrlModel::Columns::MapType);
m_configureMapUrlModel = model;
}
ConfigureMapUrlModel *ConfigureMapUrlsWidget::model() const
{
return m_configureMapUrlModel;
}
QTableView *ConfigureMapUrlsWidget::tableView()
{
return m_ui->tvLayer;
}
void ConfigureMapUrlsWidget::onUpClicked()
{
if (!m_configureMapUrlModel)
return;
int currentRow = m_ui->tvLayer->currentIndex().row();
if (currentRow - 1 < 0)
return;
QModelIndex idx = m_configureMapUrlModel->moveRow(m_ui->tvLayer->currentIndex(), currentRow - 1);
m_ui->tvLayer->setCurrentIndex(idx);
emit hasChanges();
}
void ConfigureMapUrlsWidget::onDownClicked()
{
if (!m_configureMapUrlModel)
return;
int currentRow = m_ui->tvLayer->currentIndex().row();
QModelIndex idx = m_configureMapUrlModel->moveRow(m_ui->tvLayer->currentIndex(), currentRow + 1);
m_ui->tvLayer->setCurrentIndex(idx);
emit hasChanges();
}
void ConfigureMapUrlsWidget::onAddClicked()
{
delete m_currentConfigureSingleUrl;
m_currentConfigureSingleUrl = new ConfigureSingleMapUrl(this);
m_currentConfigureSingleUrl->setWindowTitle(tr("Add Url"));
if (m_placeholderTextFile)
m_currentConfigureSingleUrl->setPlaceholderTextForFile();
connect(m_currentConfigureSingleUrl.data(), &ConfigureSingleMapUrl::signalApply,
this, &ConfigureMapUrlsWidget::addSingleUrl);
m_currentConfigureSingleUrl->show();
}
void ConfigureMapUrlsWidget::addSingleUrl()
{
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
if (!m_configureMapUrlModel)
return;
const ConfigureSingleMapUrl::DATA_T &data = m_currentConfigureSingleUrl->data();
m_configureMapUrlModel->addData(data);
emit hasChanges();
}
void ConfigureMapUrlsWidget::onModfiyClicked()
{
delete m_currentConfigureSingleUrl;
m_currentConfigureSingleUrl = new ConfigureSingleMapUrl(this);
m_currentConfigureSingleUrl->setWindowTitle(tr("Modify Url"));
if (m_placeholderTextFile)
m_currentConfigureSingleUrl->setPlaceholderTextForFile();
connect(m_currentConfigureSingleUrl.data(), &ConfigureSingleMapUrl::signalApply,
this, &ConfigureMapUrlsWidget::modifySingleUrl);
int currentRow = m_ui->tvLayer->currentIndex().row();
m_currentConfigureSingleUrl->setData(m_configureMapUrlModel->getRowData(currentRow));
m_currentConfigureSingleUrl->show();
}
void ConfigureMapUrlsWidget::modifySingleUrl()
{
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
if (!m_configureMapUrlModel)
return;
int currentRow = m_ui->tvLayer->currentIndex().row();
const ConfigureSingleMapUrl::DATA_T &data = m_currentConfigureSingleUrl->data();
m_configureMapUrlModel->setRowData(currentRow, data);
emit hasChanges();
}
void ConfigureMapUrlsWidget::onRemoveClicked()
{
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
int currentRow = m_ui->tvLayer->currentIndex().row();
m_configureMapUrlModel->removeRow(currentRow);
emit hasChanges();
}
} //namespace SituationMap
@@ -0,0 +1,117 @@
/**
* @RDE_HEADER@
* SituationMap - ConfigureMapUrlsDialog
* $Id$
* $HeadURL$
* $Author$
* Created by Norbert Thoden, SLSE, 2018-09-19
*/
#pragma once
//Map
#include <Common/situation_map_logging.h>
//Lts
#include <LtsWidgets/lts_dialog.h>
//Qt
#include <QTableView>
class QToolButton;
namespace Ui
{
class Configure_Urls_Widget;
class Configure_Single_Url;
}
namespace AssetManagement
{
class MapDescription;
}
namespace SituationMap
{
class ConfigureMapUrlModel;
// --------------------------------------------------------
// ConfigureSingleMapUrl
// --------------------------------------------------------
class ConfigureSingleMapUrl final : public LtsWidgets::LtsFramelessDialog
{
Q_OBJECT
public:
using BaseClass = LtsWidgets::LtsFramelessDialog;
using DATA_T = AssetManagement::MapDescription;
explicit ConfigureSingleMapUrl(QWidget *parent = nullptr);
~ConfigureSingleMapUrl();
void setPlaceholderTextForFile();
void setData(const DATA_T &data);
DATA_T data();
Q_SIGNALS:
void signalApply();
protected Q_SLOTS:
void onOk();
void onClose();
private:
Ui::Configure_Single_Url *m_ui;
LtsWidgets::LtsDialogButtonBox *m_buttonBox;
};
// --------------------------------------------------------
// ConfigureMapUrlsWidget
// --------------------------------------------------------
class ConfigureMapUrlsWidget : public QWidget
{
Q_OBJECT
public:
explicit ConfigureMapUrlsWidget(QWidget *parent = nullptr);
~ConfigureMapUrlsWidget();
void setPlaceholderTextForFile() { m_placeholderTextFile = true; }
void setModel(ConfigureMapUrlModel *model);
ConfigureMapUrlModel *model() const;
QTableView *tableView();
Q_SIGNALS:
void hasChanges();
protected Q_SLOTS:
void onUpClicked();
void onDownClicked();
void onAddClicked();
void onModfiyClicked();
void onRemoveClicked();
void addSingleUrl();
void modifySingleUrl();
private:
// void retranslate() override;
QPointer<ConfigureSingleMapUrl> m_currentConfigureSingleUrl;
Ui::Configure_Urls_Widget *m_ui;
ConfigureMapUrlModel *m_configureMapUrlModel = nullptr;
bool m_placeholderTextFile = false;
LOGGER_T m_logger;
};
}// namespace SituationMap
@@ -0,0 +1,133 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Configure_Urls_Widget</class>
<widget class="QWidget" name="Configure_Urls_Widget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>811</width>
<height>441</height>
</rect>
</property>
<property name="windowTitle">
<string notr="true">Layer Control</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QTableView" name="tvLayer">
<property name="minimumSize">
<size>
<width>500</width>
<height>200</height>
</size>
</property>
<property name="editTriggers">
<set>QAbstractItemView::AnyKeyPressed|QAbstractItemView::CurrentChanged|QAbstractItemView::EditKeyPressed|QAbstractItemView::SelectedClicked</set>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
</widget>
</item>
<item row="0" column="1">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pbUp">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../../../../Z/src/nglwidgets/nglresources.qrc">
<normaloff>:/icons/png/camera_arrow_up.png</normaloff>:/icons/png/camera_arrow_up.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbDown">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../../../../Z/src/nglwidgets/nglresources.qrc">
<normaloff>:/icons/png/camera_arrow_down.png</normaloff>:/icons/png/camera_arrow_down.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbAdd">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../../../../Z/src/nglwidgets/nglresources.qrc">
<normaloff>:/icons/png/add.png</normaloff>:/icons/png/add.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbModify">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../../../../Z/src/nglwidgets/nglresources.qrc">
<normaloff>:/icons/png/edith_graphic_eass.png</normaloff>:/icons/png/edith_graphic_eass.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbRemove">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../../../../Z/src/nglwidgets/nglresources.qrc">
<normaloff>:/icons/png/remove.png</normaloff>:/icons/png/remove.png</iconset>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
<resources>
<include location="../../../../../Z/src/nglwidgets/nglresources.qrc"/>
</resources>
<connections/>
</ui>
@@ -0,0 +1,383 @@
/**
* @RDE_HEADER@
* SituationMap - ConfigureMapUrlsDialog
* $Id$
* $HeadURL$
* $Author$
* Created by Norbert Thoden, SLSE, 2018-09-19
*/
#include "sitmap_configure_urls.h"
#include "ui_sitmap_configure_urls.h"
#include "sitmap_configure_url_model.h"
#include "sitmap_configure_url_widget.h"
#include <Map/map_initializer.h> // MapSettingJson
#include "AdapterDds/plugin_provider.h"
#include <LtsUtils/LtsUtilsCore/dds_vector.h>
namespace SituationMap
{
ConfigureMapUrls::ConfigureMapUrls(QWidget *parent)
: LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel)
, m_pluginProvider(nullptr)
, m_requestHelper(new LtsUtils::RequestHelper(this))
, m_ui(new Ui::Configure_Urls)
, m_logger(getLogger("ConfigureMapUrls"))
{
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
m_ui->setupUi(this);
ConfigureMapUrlsWidget *w;
// clear, we use our own widgets:
m_ui->tabWidget->removeTab(0);
w = new ConfigureMapUrlsWidget();
w->setModel(new ConfigureMapUrlModel(this));
m_ui->tabWidget->addTab(w, tr("Map"));
connect(w, &ConfigureMapUrlsWidget::hasChanges, this, &ConfigureMapUrls::slotChangesMade);
w = new ConfigureMapUrlsWidget();
w->setModel(new ConfigureMapUrlModel(this));
m_ui->tabWidget->addTab(w, tr("Scene"));
connect(w, &ConfigureMapUrlsWidget::hasChanges, this, &ConfigureMapUrls::slotChangesMade);
w = new ConfigureMapUrlsWidget();
w->setModel(new ConfigureMapUrlModel(this));
w->setPlaceholderTextForFile();
m_ui->tabWidget->addTab(w, tr("Elevation"));
connect(w, &ConfigureMapUrlsWidget::hasChanges, this, &ConfigureMapUrls::slotChangesMade);
w = new ConfigureMapUrlsWidget();
w->setModel(new ConfigureMapUrlModel(this));
w->setPlaceholderTextForFile();
m_ui->tabWidget->addTab(w, tr("SceneObject"));
connect(w, &ConfigureMapUrlsWidget::hasChanges, this, &ConfigureMapUrls::slotChangesMade);
//NLDEVCTRL-1727
setOnlineHelpFilename(QStringLiteral("Configuration_of_Modells_SLPKs")); // former: Situation-Configure_Map_Urls
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
}
ConfigureMapUrls::~ConfigureMapUrls()
{
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
delete m_ui;
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
}
bool ConfigureMapUrls::init(PluginProvider *pluginProvider)
{
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
m_pluginProvider = pluginProvider;
if (!m_pluginProvider)
{
ERROR_LOG(m_logger) << LOGFUNCTION << " no pluginProvider";
return false;
}
bool bRet = true;
m_asmDtc = m_pluginProvider->asmDtc();
if (!m_asmDtc)
{
ERROR_LOG(m_logger) << LOGFUNCTION << " Can not retrieve AssetManagement::DTC";
bRet = false;
}
m_asmFtc = m_pluginProvider->asmFtc();
if (!m_asmFtc)
{
ERROR_LOG(m_logger) << LOGFUNCTION << " Can not retrieve AssetManagement::FTC";
bRet = false;
}
connect(m_ui->cbTrainingArea, &LtsWidgets::LtsComboBox::currentTextChanged,
this, &ConfigureMapUrls::onSelectedTrainingAreaChanged);
m_ui->tabWidget->setCurrentIndex(0);
fillTrainingAreaCbx();
syncTaToGui();
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
return bRet;
}
void ConfigureMapUrls::fillTrainingAreaCbx()
{
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
if (!m_asmDtc)
{
ERROR_LOG(m_logger) << LOGFUNCTION << " no dtc";
return;
}
{
QSignalBlocker blocker(m_ui->cbTrainingArea);
// training areas
int curIdxTa = m_ui->cbTrainingArea->currentIndex();
m_ui->cbTrainingArea->clear();
auto cb = [this](const AssetManagement::TrainingArea & ta)
{
m_ui->cbTrainingArea->addItem(QString::fromStdString(ta.name()), QVariant(ta.id()));
};
m_asmDtc->trainingAreas(cb);
m_ui->cbTrainingArea->model()->sort(0);
if (curIdxTa >= 0)
m_ui->cbTrainingArea->setCurrentIndex(curIdxTa);
}
if (m_ui->cbTrainingArea->model()->rowCount() > 0)
{
const int newTrainingAreaId = m_ui->cbTrainingArea->currentData().toInt();
if (!retrieveTaOfService(newTrainingAreaId))
{
ERROR_LOG(m_logger) << LOGFUNCTION << " retrieveTrainingAreaOfService failed";
return;
}
}
// resetChanges();
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
}
void ConfigureMapUrls::onSelectedTrainingAreaChanged(const QString & /*dummy*/)
{
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
const int newTrainingAreaId = m_ui->cbTrainingArea->currentData().toInt();
if (m_trainingArea.id() == newTrainingAreaId)
return;
if (hasUnsavedChanges())
{
switch (LtsWidgets::LtsMessageDialog::askApplyDiscardCancel(this))
{
case LtsWidgets::Button::Apply:
apply();
if (!retrieveTaOfService(newTrainingAreaId))
{
ERROR_LOG(m_logger) << LOGFUNCTION << " retrieveTrainingAreaOfService failed";
return;
}
break;
case LtsWidgets::Button::Cancel:
INFO_LOG(m_logger) << LOGFUNCTION << " set back to m_trainingArea.id() = " << m_trainingArea.id();
m_ui->cbTrainingArea->setCurrentIndex(m_ui->cbTrainingArea->findData(QVariant(m_trainingArea.id()), Qt::UserRole));
break;
case LtsWidgets::Button::Discard:
if (!retrieveTaOfService(newTrainingAreaId))
{
ERROR_LOG(m_logger) << LOGFUNCTION << " retrieveTrainingAreaOfService failed";
return;
}
break;
default:
ERROR_LOG(m_logger) << LOGFUNCTION << " got unexpected!!!";
break;
}
}
else
{
if (!retrieveTaOfService(newTrainingAreaId))
{
ERROR_LOG(m_logger) << LOGFUNCTION << " retrieveTrainingAreaOfService failed";
return;
}
}
syncTaToGui();
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
}
bool ConfigureMapUrls::retrieveTaOfService(int trainingAreaId)
{
TRACE_LOG(m_logger) << LOGFUNCTION << " START, trainingAreaId=" << trainingAreaId;
if (!m_asmDtc)
{
ERROR_LOG(m_logger) << LOGFUNCTION << " no dtc";
return false;
}
// clear gui:
m_trainingArea = AssetManagement::TrainingArea();
syncTaToGui();
AssetManagement::TrainingArea ta = m_asmDtc->trainingArea(trainingAreaId);
if (ta.id() != trainingAreaId)
{
ERROR_LOG(m_logger) << LOGFUNCTION << " switch to m_trainingArea failed (taId=" << trainingAreaId << ")";
return false;
}
m_trainingArea = ta;
INFO_LOG(m_logger) << LOGFUNCTION << " switch to m_trainingArea " << m_trainingArea.id()
<< ", ta" << ta;
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
return true;
}
static inline std::vector<AssetManagement::MapDescription> vecToVec(const QVector<AssetManagement::MapDescription> &vec)
{
return LtsUtils::convert<std::vector<AssetManagement::MapDescription>>(vec);
}
static inline QVector<AssetManagement::MapDescription> vecToVec(const std::vector<AssetManagement::MapDescription> &vec)
{
return LtsUtils::convert<QVector<AssetManagement::MapDescription>>(vec);
}
void basicConfig(ConfigureMapUrlsWidget *tv, bool showTypeMinMax = true)
{
if (!tv)
return;
tv->tableView()->resizeColumnsToContents();
tv->tableView()->setColumnWidth(1, 100);
tv->tableView()->setColumnWidth(2, 100);
tv->tableView()->setColumnWidth(3, 100);
tv->tableView()->setColumnWidth(4, 100);
if (!showTypeMinMax)
{
tv->tableView()->hideColumn(ConfigureMapUrlModel::Columns::MapType);
tv->tableView()->hideColumn(ConfigureMapUrlModel::Columns::MinScale);
tv->tableView()->hideColumn(ConfigureMapUrlModel::Columns::MaxScale);
}
}
void ConfigureMapUrls::syncTaToGui()
{
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
ConfigureMapUrlsWidget *w;
w = static_cast<ConfigureMapUrlsWidget *>(m_ui->tabWidget->widget(0));
if (w && w->model())
{
w->model()->setData(vecToVec(m_trainingArea.map2D()));
TRACE_LOG(m_logger) << LOGFUNCTION << " model->rowCount()" << w->model()->rowCount();
}
basicConfig(w);
if (w && w->model())
connect(w->model(), &ConfigureMapUrlModel::dataChanged, this, []()
{
qCritical() << " Changed!!!";
});
w = static_cast<ConfigureMapUrlsWidget *>(m_ui->tabWidget->widget(1));
if (w && w->model())
{
w->model()->setData(vecToVec(m_trainingArea.scene3D()));
TRACE_LOG(m_logger) << LOGFUNCTION << " model->rowCount()" << w->model()->rowCount();
}
basicConfig(w);
w = static_cast<ConfigureMapUrlsWidget *>(m_ui->tabWidget->widget(2));
if (w && w->model())
w->model()->setData(vecToVec(m_trainingArea.elevation()));
basicConfig(w, false);
w = static_cast<ConfigureMapUrlsWidget *>(m_ui->tabWidget->widget(3));
if (w && w->model())
w->model()->setData(vecToVec(m_trainingArea.sceneObjects()));
basicConfig(w, false);
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
}
void ConfigureMapUrls::syncGuiToTa()
{
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
ConfigureMapUrlsWidget *w;
w = static_cast<ConfigureMapUrlsWidget *>(m_ui->tabWidget->widget(0));
if (w && w->model())
m_trainingArea.map2D(vecToVec(w->model()->allData()));
w = static_cast<ConfigureMapUrlsWidget *>(m_ui->tabWidget->widget(1));
if (w && w->model())
m_trainingArea.scene3D(vecToVec(w->model()->allData()));
w = static_cast<ConfigureMapUrlsWidget *>(m_ui->tabWidget->widget(2));
if (w && w->model())
m_trainingArea.elevation(vecToVec(w->model()->allData()));
w = static_cast<ConfigureMapUrlsWidget *>(m_ui->tabWidget->widget(3));
if (w && w->model())
m_trainingArea.sceneObjects(vecToVec(w->model()->allData()));
// The model does not know it`s mapDescriptionTypeId.
// So set them here:
for (auto &item : m_trainingArea.map2D())
item.mapDescriptionTypeId(AssetManagement::MapDescriptionType_def::Map2D);
for (auto &item : m_trainingArea.scene3D())
item.mapDescriptionTypeId(AssetManagement::MapDescriptionType_def::Scene3D);
for (auto &item : m_trainingArea.elevation())
item.mapDescriptionTypeId(AssetManagement::MapDescriptionType_def::Elevation);
for (auto &item : m_trainingArea.sceneObjects())
item.mapDescriptionTypeId(AssetManagement::MapDescriptionType_def::SceneObj);
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
}
void ConfigureMapUrls::retranslate()
{
translate(m_ui, tr("Configure Map Urls"));
// reBuildUi();
}
bool ConfigureMapUrls::apply()
{
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
if (!m_asmFtc)
{
ERROR_LOG(m_logger) << LOGFUNCTION << " Can not retrieve AssetManagement::FTC";
return false;
}
this->syncGuiToTa();
bool success = m_requestHelper->startSingleRequest([this]()
{
return m_asmFtc->trainingAreaModifyRequest(m_trainingArea, this);
});
TRACE_LOG(m_logger) << LOGFUNCTION << " END, scucess=" << success;
return success;
}
void ConfigureMapUrls::onTrainingAreaModifyReply(const Core::FunctionReplyObject &reply)
{
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
if (reply.error())
{
ERROR_LOG(m_logger) << LOGFUNCTION << "Got onTrainingAreaModifyReply error: " << reply();
return;
}
INFO_LOG(m_logger) << LOGFUNCTION << " Got onTrainingAreaModifyReply with id " << reply.id();
m_requestHelper->requestReply(reply);
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
}
} //namespace SituationMap
@@ -0,0 +1,85 @@
/**
* @RDE_HEADER@
* SituationMap - ConfigureMapUrlsDialog
* $Id$
* $HeadURL$
* $Author$
* Created by Norbert Thoden, SLSE, 2018-09-19
*/
#pragma once
//Map
#include <Common/situation_map_logging.h>
//ASM
#include <AssetManagement/asm_data_plugin_interface.h>
//Lts
#include <LtsWidgets/lts_dialog.h>
//DDS
#include <LtsUtilsGuiDds/request_helper.h>
//Qt
namespace Ui
{
class Configure_Urls;
}
namespace SituationMap
{
class PluginProvider;
// --------------------------------------------------------
// ConfigureMapUrlsDialog
// --------------------------------------------------------
class ConfigureMapUrls : public LtsWidgets::LtsDialog
, protected AssetManagement::Interface::Ftc::TrainingAreaModifyReplyHandler
{
Q_OBJECT
public:
explicit ConfigureMapUrls(QWidget *parent = nullptr);
~ConfigureMapUrls();
bool init(PluginProvider *pluginProvider);
protected:
void fillTrainingAreaCbx();
bool retrieveTaOfService(int trainingAreaId);
void syncTaToGui();
void syncGuiToTa();
void onTrainingAreaModifyReply(const Core::FunctionReplyObject &reply) override;
protected Q_SLOTS:
void onSelectedTrainingAreaChanged(const QString &dummy = QString());
private:
void retranslate() override;
bool apply() override final;
protected:
private:
SituationMap::PluginProvider *m_pluginProvider;
std::shared_ptr<AssetManagement::Interface::Dtc> m_asmDtc;
std::shared_ptr<AssetManagement::Interface::Ftc> m_asmFtc;
LtsUtils::RequestHelper *m_requestHelper;
AssetManagement::TrainingArea m_trainingArea;
Ui::Configure_Urls *m_ui;
LOGGER_T m_logger;
};
}// namespace SituationMap
@@ -0,0 +1,75 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Configure_Urls</class>
<widget class="QWidget" name="Configure_Urls">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>667</width>
<height>368</height>
</rect>
</property>
<property name="windowTitle">
<string notr="true"/>
</property>
<layout class="QGridLayout" name="gridLayout_7">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="lblTrainingArea">
<property name="text">
<string>Training Area:</string>
</property>
</widget>
</item>
<item>
<widget class="LtsWidgets::LtsComboBox" name="cbTrainingArea">
<property name="const" stdset="0">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="map">
<attribute name="title">
<string>Map</string>
</attribute>
</widget>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>LtsWidgets::LtsComboBox</class>
<extends>QComboBox</extends>
<header>LtsWidgets/lts_combo_box.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>