Compare commits

..
Author SHA1 Message Date
berrux-dev edd5e3ba81 Configure the Release 2 scope in the merged CMakeLists tree
- Lts/CMakeLists.txt: restore the cleanup scope (Tools, DDS, Common,
  Services, Proxies, Plugins) - the validation version configured only
  Lts/Common and TrainingAreaBase, silently dropping the GROUP1 DDS
  targets, the GROUP5 tools and the service libraries.
- 11 further scope CMakeLists from cleanup: the validation versions had
  removed the per-module unit-test subdirectories (ctest baseline
  targets), LtsUtilsGui, and used a stale GeographicLib link style.
- PrtCnv: keep the validation CMAKE_CURRENT_BINARY_DIR include
  (generated prtcnvlib_export.h).
- sPDM executable: guard on Lts/Common/LtsWebSocket (pruned, link
  orphan) like the sTAB executable.
2026-11-16 19:36:39 +01:00
berrux-dev 262fd226f9 Restore in-scope files missing from the merge and scope-aware CMakeLists
The merge from story/release-validation-scope only carried files that
existed at the common base or on that branch. In-scope files added on
story/release-2-cleanup after the base (per-module unit-test dirs, the
Release 2 driver and rpmbuild script) were missing, breaking
ADD_SUBDIRECTORY(unit-test) references.

- Restore the 33 missing in-scope files from story/release-2-cleanup.
- Lts/Common/CMakeLists.txt and LtsUtilsGui/CMakeLists.txt: take the
  story/release-2-cleanup versions (the validation versions still
  reference out-of-scope subdirectories: httq, LtsRestClient,
  LtsWebSocket, ConnectDialog, StyleManager).
2026-11-16 19:04:24 +01:00
berrux-dev cfe15c72c4 Merge story/release-validation-scope
Bring the validation-scope line (in-tree Jenkins CI copy, lcov coverage
wiring, step-by-step release-scope README, TetraIF unit tests, the
LogView runtime icon/resource fix, Dockerfile, rpmbuild and the
new_docker_build.sh driver with the DEB output path) on top of the
XmlPatterns branch pruned to the Release 2 scope.

Conflict policy:
- Out-of-scope targets/modules: keep the prune (deletion wins).
- In-scope files that validation had deleted: restored from
  story/release-2-cleanup (the Release 2 closure, with the
  pruned-module guards).
- In-scope sources carrying migration work: XmlPatterns versions
  (Qt XmlPatterns rework on QDomDocument, DDS member and logger
  fixes, first-build fixes).
- Scope-aware CMakeLists (top level, PluginInterfaces, LtsWidgets)
  and .envrc: story/release-2-cleanup / ours versions.
2026-11-16 18:49:14 +01:00
berrux-dev 70d4b892a9 Prune the tree to the Release 2 scope
Delete everything that is not part of the Release 2 build closure
defined by the story/release-2-cleanup README (46 targets,
GROUP1/3/5/6): out-of-scope Lts modules (Viewer, OSG/BuildingViewer
floor, Schusstafel, MSDL/SAAB import tools, ...), the include/ stub
surplus, tests/, specs/, translations/, the migration report files,
cmake/FindOpenSceneGraph.cmake, external/Schusstafel and the legacy
new_docker_build.sh driver.

In-scope files keep the XmlPatterns-branch versions (Qt XmlPatterns
rework on QDomDocument, BZip2 nglcompression, first-build fixes).
Tracked file count: 16140 -> 2166.
2026-11-16 18:08:56 +01:00
berrux-dev d327c66c46 Close bld/OSG floor: OSG 3.4.1 from source + port osgQt to Qt6 + wire BgViewer dtEntity
Migrate BuildingViewer (16 files: DDS members, m_logger inits, QOpenGLWidget); gui:3:bld.info + gui:3:bdv now load
2026-10-24 19:32:52 +02:00
berrux-dev 8e9594d25c Close ppm.msdl/ppm.saab floors: re-implement MSDL/SAAB import without Qt XmlPatterns
Qt6::Xml (QDomDocument) + xmllint schema check; MSDL links XercesC + xsdc++ tree classes; both moved into GROUP12
2026-10-24 19:31:04 +02:00
berrux-dev 3924b1e72b externel dependency 2026-10-23 16:28:08 +02:00
berrux-dev fb3e91ea4b Close Schusstafel + KDChart plugin floors: cesPluginGeoPairing/OreOnlineReportsGuiPlugin in GROUP12 (presence-gated), image bakes KDChart
DDS member fixes (GeoPairing, OnlineReports charts/dialogs); FindKDChart/FindSchusstafel find-module wiring
2026-10-22 13:16:23 +02:00
berrux-dev e067c21b0d Enable Codification/OHP/PlanEditor/OrgChart plugin groups (G12 225); harden new_docker_build.sh
First-build fixes (DDS members, Qt6 transitive WebChannel/PrintSupport drops, logger init, Qt5 guard); script: log_warn, BUILD_WLS default ON, Poppler image+APT, XmlPatterns 6.0 wording
2026-10-21 13:50:10 +02:00
berrux-dev 131a6714cf Restore BZip2 in nglcompression (legacy REQUIRED it)
Define HAVE_BZIP2 so the real impl compiles instead of the stub; link libbz2; nglcomp_test green
2026-10-21 10:18:32 +02:00
berrux-dev 598fc2560e Complete Qt6 migration: full clean build green across groups G1-G12 incl. runtime plugin set
new_docker_build.sh gains Group 12 (212 GUI/Data plugins); fixes LtsUtilsGuiDds visibility (LTO-stripped exports), LtsProjectionWorkstation unity name shadow, 6 unity-off dirs (dup file-scope statics, ddsftc INTERFACE sources) and reconfigures BUILD_FILTERMANAGEMENT/BUILD_PLUGINS_SERVICEMONITOR=ON
2026-10-20 09:36:57 +02:00
berrux-dev 2b957d1edb Port SymbologyImpl Esri processors to the ArcGIS 300 QFuture async API
TaskWatcher (searchSymbols/fetchSymbol/createSwatch + completion signals) -> QFuture (searchSymbolsAsync/fetchSymbolAsync/createSwatchAsync + QFutureWatcher finished/result getter); flat arcgis/ includes; arcgisversion.h shim (external SDK). advancedSymbology now builds+links vs 300 (0 errors); SymbologyXML CTest 6/6, 0 assertion failures. Migration-only vs legacy; one documented forced delta: 300 has no spec-only DictionarySymbolStyle. Summary: MIGRATION_SUMMARY_ARCGIS300_SYMBOLOGY.md.
2026-10-07 06:24:35 +02:00
361 changed files with 11339 additions and 9410 deletions

No files matched your search

+18
View File
@@ -9,3 +9,21 @@ fix_qt6_gui_deps.py
fix_rti_conditionals.py fix_rti_conditionals.py
fix_target_checks.py fix_target_checks.py
build build
__pycache__/
add_logger_bootstrap_include.py
aqtinstall.log
ces_fix.py
ces_pass2.py
fix_additem_enum.py
fix_broken_includes.py
fix_enum_as_int.py
fix_enums.py
fix_logger_init.py
fix_logger_remnant.py
fix_members.py
fix_mlogger.py
fix_pdm_combo.py
fix_sco.py
restore_underlying.py
../../restore_ppm_dtc.py
*.py
+2 -1
View File
@@ -1,4 +1,5 @@
# export MIGRATE_PIPELINE_ROOT="/home/torsten/sandbox/qt6-migration-pipeline" # export MIGRATE_PIPELINE_ROOT="/home/torsten/sandbox/qt6-migration-pipeline"
export MIGRATE_PIPELINE_ROOT="/home/torsten/sandbox/qt6-migration-pipeline" export MIGRATE_PIPELINE_ROOT="/home/nkana/repo/qt6-migration-pipeline"
export CLAUDE_CODE_MAX_OUTPUT_TOKENS=16000
export LANG=C.UTF-8 export LANG=C.UTF-8
export LC_ALL=C.UTF-8 export LC_ALL=C.UTF-8
+1 -2
View File
@@ -14,5 +14,4 @@ build/
build2/ build2/
.envrc .envrc
build4 build4
build4_* coverage-out/
deb_build_tmp
+3 -4
View File
@@ -1,9 +1,8 @@
# Prebuilt build image for the Release 2 branch # Prebuilt build image for the release validation-scope branch
# (Ubuntu 26.04 + Qt6 + all dependencies for the legatus release build). # (Ubuntu 26.04 + Qt6 + all dependencies for the legatus release build).
# #
# Build with (the APT package list mirrors the in-container install list of # Built by new_docker_build.sh --build-prebuilt-image, which passes the
# new_docker_build_release2.sh): # package list and Qt settings as build args (see build_prebuilt_image()).
# docker build --build-arg APT_PACKAGES="<space-separated packages>" -t <image> .
FROM ubuntu:26.04 FROM ubuntu:26.04
@@ -1,11 +1,4 @@
/**
* @RDE_HEADER@
* Wrapper-Objects for Grantlee engine
* $Id$
* $HeadURL$
* $Author$
* Created by Hanna E. Rathje, SLSE, 2015-08-04
*/
#include "GrantleeWrappers.h" #include "GrantleeWrappers.h"
@@ -1,11 +1,13 @@
// Stub GTest smoke test for coordTrans
#include <gtest/gtest.h> #include <gtest/gtest.h>
TEST(CoordTransSmokeTest, StubTest) { TEST(CoordTransSmokeTest, StubTest)
{
EXPECT_TRUE(true); EXPECT_TRUE(true);
} }
int main(int argc, char **argv) { int main(int argc, char **argv)
{
::testing::InitGoogleTest(&argc, argv); ::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS(); return RUN_ALL_TESTS();
} }
@@ -1,4 +1,4 @@
// Stub QtTest smoke test for coordTrans
#include <QTest> #include <QTest>
class CoordTransSmokeTest : public QObject class CoordTransSmokeTest : public QObject
@@ -6,9 +6,7 @@ class CoordTransSmokeTest : public QObject
Q_OBJECT Q_OBJECT
private slots: private slots:
void stubTest() { void stubTest() { QVERIFY(true); }
QVERIFY(true);
}
}; };
QTEST_APPLESS_MAIN(CoordTransSmokeTest) QTEST_APPLESS_MAIN(CoordTransSmokeTest)
@@ -1,5 +1,3 @@
// MockCoordTrans.h - Stub mock for CoordTrans functionality
// This is a placeholder to allow builds without full CoordTrans implementation
#ifndef MOCK_COORD_TRANS_H #ifndef MOCK_COORD_TRANS_H
#define MOCK_COORD_TRANS_H #define MOCK_COORD_TRANS_H
@@ -8,9 +6,11 @@
#include <QtCore/QPointF> #include <QtCore/QPointF>
// Minimal stub to satisfy linker requirements // Minimal stub to satisfy linker requirements
namespace LtsCoordTrans { namespace LtsCoordTrans
{
// Placeholder types // Placeholder types
struct UtmCoordinate { struct UtmCoordinate
{
static UtmCoordinate fromMgrs(const QString &) { return UtmCoordinate(); } static UtmCoordinate fromMgrs(const QString &) { return UtmCoordinate(); }
QPointF geographic() const { return QPointF(); } QPointF geographic() const { return QPointF(); }
}; };
@@ -28,8 +28,7 @@ int main(int argc, char* argv[])
if (!f.open(QFile::ReadOnly)) if (!f.open(QFile::ReadOnly))
{ {
printf("LtsAppDescriptorChecker: cannot open apps.json at %s: %s\n", appsJsonFilePath.toStdString().c_str(), printf("LtsAppDescriptorChecker: cannot open apps.json at %s: %s\n", appsJsonFilePath.toStdString().c_str(), f.errorString().toStdString().c_str());
f.errorString().toStdString().c_str());
return -2; return -2;
} }
@@ -38,12 +37,12 @@ int main(int argc, char* argv[])
QStringList lastErrors; QStringList lastErrors;
QStringList dummy1; QStringList dummy1;
QString dummy2; QString dummy2;
LtsAppDescriptor::AppDescriptionVector adv = LtsAppDescriptor::AppDescriptionVector adv = LtsAppDescriptor::LtsAppDescriptor::getAppDescriptionVector(f.readAll(), lastErrors, dummy1, dummy2);
LtsAppDescriptor::LtsAppDescriptor::getAppDescriptionVector(f.readAll(), lastErrors, dummy1, dummy2);
if (!lastErrors.isEmpty()) if (!lastErrors.isEmpty())
{ {
printf("LtsAppDescriptorChecker: apps.json at %s invalid:\n%s\n", appsJsonFilePath.toStdString().c_str(), printf("LtsAppDescriptorChecker: apps.json at %s invalid:\n%s\n",
appsJsonFilePath.toStdString().c_str(),
lastErrors.join(QStringLiteral("\r\n\r\n")).toStdString().c_str()); lastErrors.join(QStringLiteral("\r\n\r\n")).toStdString().c_str());
return 1; return 1;
} }
@@ -107,8 +106,7 @@ int main(int argc, char* argv[])
{ {
if (!guiPluginIIDs.contains(pi.iid)) if (!guiPluginIIDs.contains(pi.iid))
{ {
printf("LtsAppDescriptorChecker: apps.json at '%s' uses unknown IID '%s'\n", printf("LtsAppDescriptorChecker: apps.json at '%s' uses unknown IID '%s'\n", appsJsonFilePath.toStdString().c_str(), pi.iid.toStdString().c_str());
appsJsonFilePath.toStdString().c_str(), pi.iid.toStdString().c_str());
ok = false; ok = false;
} }
} }
@@ -1,12 +1,4 @@
/**
* @RDE_HEADER@
* App Descriptor - Class to modify App Descriptor JSON Documents
* $Id$
* $HeadURL$
* $Author$
*
* Created by Mike Wille, SLSE, 2016-10-24
*/
#include "lts_app_descriptor.h" #include "lts_app_descriptor.h"
@@ -42,9 +34,13 @@ static void addOptionToPlugin(QVector<PluginInfo>& pluginInfos, const PluginInfo
pluginInfos.append(pi); pluginInfos.append(pi);
} }
static bool addOptionsToPlugin(AppDescription& appDesc, const QString& optionIdentifier, static bool addOptionsToPlugin(AppDescription &appDesc,
const QStringList& ignoredPlugins, const QJsonObject& optionsObject, const QString &optionIdentifier,
const PluginInfo::Flag flag, QStringList& lastErrors, bool atLeastOnePluginNeeded) const QStringList &ignoredPlugins,
const QJsonObject &optionsObject,
const PluginInfo::Flag flag,
QStringList &lastErrors,
bool atLeastOnePluginNeeded)
{ {
bool hasPlugins = false; bool hasPlugins = false;
auto optionsObjectIt = optionsObject.constFind(optionIdentifier); auto optionsObjectIt = optionsObject.constFind(optionIdentifier);
@@ -65,8 +61,7 @@ static bool addOptionsToPlugin(AppDescription& appDesc, const QString& optionIde
if (atLeastOnePluginNeeded && !hasPlugins) if (atLeastOnePluginNeeded && !hasPlugins)
{ {
lastErrors.append(QCoreApplication::tr("No plugins specified for '%1' option for app '%2'") lastErrors.append(QCoreApplication::tr("No plugins specified for '%1' option for app '%2'").arg(optionIdentifier, appDesc.appName));
.arg(optionIdentifier, appDesc.appName));
return false; return false;
} }
@@ -104,7 +99,8 @@ App LtsAppDescriptor::appFromInteger(int i)
return App::Login; return App::Login;
} }
AppDescriptionVector LtsAppDescriptor::getAppDescriptionVector(const QByteArray& jsonDocument, QStringList& lastErrors, AppDescriptionVector LtsAppDescriptor::getAppDescriptionVector(const QByteArray &jsonDocument,
QStringList &lastErrors,
const QStringList &ignoredPlugins, const QStringList &ignoredPlugins,
QString &loginPluginIid) QString &loginPluginIid)
{ {
@@ -137,10 +133,7 @@ AppDescriptionVector LtsAppDescriptor::getAppDescriptionVector(const QByteArray&
} }
} }
lastErrors.append(QCoreApplication::tr("JSON: %1<br>Row: %2, Column: %3") lastErrors.append(QCoreApplication::tr("JSON: %1<br>Row: %2, Column: %3").arg(parseError.errorString()).arg(row + 1).arg(column + 1));
.arg(parseError.errorString())
.arg(row + 1)
.arg(column + 1));
return appDescriptions; return appDescriptions;
} }
@@ -174,9 +167,7 @@ AppDescriptionVector LtsAppDescriptor::getAppDescriptionVector(const QByteArray&
{ {
if (valueActive.type() != QJsonValue::Type::Bool) if (valueActive.type() != QJsonValue::Type::Bool)
{ {
lastErrors.append(QCoreApplication::tr("App '%1': value App.Active is not a bool (%2)") lastErrors.append(QCoreApplication::tr("App '%1': value App.Active is not a bool (%2)").arg(appDesc.appName).arg((int)valueActive.type()));
.arg(appDesc.appName)
.arg((int)valueActive.type()));
return appDescriptions; return appDescriptions;
} }
} }
@@ -185,9 +176,7 @@ AppDescriptionVector LtsAppDescriptor::getAppDescriptionVector(const QByteArray&
const QJsonValue valueVisible = appObject.value(QStringLiteral("Visible")); const QJsonValue valueVisible = appObject.value(QStringLiteral("Visible"));
if (!valueVisible.isUndefined() && valueVisible.type() != QJsonValue::Type::Bool) if (!valueVisible.isUndefined() && valueVisible.type() != QJsonValue::Type::Bool)
{ {
lastErrors.append(QCoreApplication::tr("App '%1': value App.Visible is not a bool (%2)") lastErrors.append(QCoreApplication::tr("App '%1': value App.Visible is not a bool (%2)").arg(appDesc.appName).arg((int)valueVisible.type()));
.arg(appDesc.appName)
.arg((int)valueVisible.type()));
return appDescriptions; return appDescriptions;
} }
appDesc.visible = valueVisible.toBool(true); appDesc.visible = valueVisible.toBool(true);
@@ -198,12 +187,9 @@ AppDescriptionVector LtsAppDescriptor::getAppDescriptionVector(const QByteArray&
const QJsonObject optionsObject(appObject.value(QStringLiteral("Options")).toObject()); const QJsonObject optionsObject(appObject.value(QStringLiteral("Options")).toObject());
addOptionsToPlugin(appDesc, QStringLiteral("Payloads"), ignoredPlugins, optionsObject, addOptionsToPlugin(appDesc, QStringLiteral("Payloads"), ignoredPlugins, optionsObject, PluginInfo::Flag::PAYLOAD, lastErrors, false);
PluginInfo::Flag::PAYLOAD, lastErrors, false); addOptionsToPlugin(appDesc, QStringLiteral("Actions"), ignoredPlugins, optionsObject, PluginInfo::Flag::ACTIONS, lastErrors, true);
addOptionsToPlugin(appDesc, QStringLiteral("Actions"), ignoredPlugins, optionsObject, PluginInfo::Flag::ACTIONS, addOptionsToPlugin(appDesc, QStringLiteral("Main"), ignoredPlugins, optionsObject, PluginInfo::Flag::MAIN, lastErrors, false);
lastErrors, true);
addOptionsToPlugin(appDesc, QStringLiteral("Main"), ignoredPlugins, optionsObject, PluginInfo::Flag::MAIN,
lastErrors, false);
appDescriptions.append(appDesc); appDescriptions.append(appDesc);
} }
@@ -97,8 +97,10 @@ typedef QVector<AppDescription> AppDescriptionVector;
namespace LtsAppDescriptor // TODO: make qobject class singleton - for tr namespace LtsAppDescriptor // TODO: make qobject class singleton - for tr
{ {
LTSAPPDESCRIPTOR_EXPORT App appFromInteger(int i); LTSAPPDESCRIPTOR_EXPORT App appFromInteger(int i);
LTSAPPDESCRIPTOR_EXPORT AppDescriptionVector getAppDescriptionVector(const QByteArray &jsonDocument, QStringList &lastErrors, LTSAPPDESCRIPTOR_EXPORT AppDescriptionVector getAppDescriptionVector(const QByteArray &jsonDocument,
const QStringList &ignoredPlugins, QString &loginPluginIid); QStringList &lastErrors,
const QStringList &ignoredPlugins,
QString &loginPluginIid);
} }
} // namespace LtsAppDescriptor } // namespace LtsAppDescriptor
@@ -13,7 +13,9 @@
#include <QtWidgets/QLineEdit> #include <QtWidgets/QLineEdit>
#include <QtWidgets/QPushButton> #include <QtWidgets/QPushButton>
LtsAppDescriptorEditor::LtsAppDescriptorEditor(QWidget* parent) : QWidget(parent), m_ui(new Ui_LtsAppDescriptionEditor) LtsAppDescriptorEditor::LtsAppDescriptorEditor(QWidget *parent)
: QWidget(parent)
, m_ui(new Ui_LtsAppDescriptionEditor)
{ {
m_ui->setupUi(this); m_ui->setupUi(this);
m_vector = LtsAppDescriptor::AppDescriptionVector(); m_vector = LtsAppDescriptor::AppDescriptionVector();
@@ -53,9 +55,8 @@ LtsAppDescriptorEditor::~LtsAppDescriptorEditor()
void LtsAppDescriptorEditor::getAppDescriptionVector() void LtsAppDescriptorEditor::getAppDescriptionVector()
{ {
m_fileName = QFileDialog::getOpenFileName( m_fileName =
this, tr("Open JSON"), QLatin1Literal("/shd/CTC/TOOLS/TDS/TDS-source/Lts/Projects/Legatus/resources/"), QFileDialog::getOpenFileName(this, tr("Open JSON"), QLatin1Literal("/shd/CTC/TOOLS/TDS/TDS-source/Lts/Projects/Legatus/resources/"), tr("JSON File (*.json)"));
tr("JSON File (*.json)"));
if (m_fileName.isEmpty()) if (m_fileName.isEmpty())
return; return;
@@ -111,8 +112,7 @@ void LtsAppDescriptorEditor::onAppsClicked(const QModelIndex& index)
if (optionalFlag) if (optionalFlag)
strFlags.append(QLatin1String("optional ")); strFlags.append(QLatin1String("optional "));
pluginList << QString(type + QLatin1String(": ") + reqPlugin.iid + QLatin1String(" [ ") + strFlags + pluginList << QString(type + QLatin1String(": ") + reqPlugin.iid + QLatin1String(" [ ") + strFlags + QLatin1String("]"));
QLatin1String("]"));
} }
} }
updatePluginModel(pluginList); updatePluginModel(pluginList);
@@ -189,8 +189,7 @@ void LtsAppDescriptorEditor::pluginTypeChanged()
} }
else else
{ {
QMessageBox msgBox(QMessageBox::Information, tr("Error"), QMessageBox msgBox(QMessageBox::Information, tr("Error"), tr("Plugin Type must either be \"gui\" or \"data\"."));
tr("Plugin Type must either be \"gui\" or \"data\"."));
msgBox.exec(); msgBox.exec();
m_ui->lePluginType->setText(QString()); m_ui->lePluginType->setText(QString());
} }
@@ -215,8 +214,7 @@ void LtsAppDescriptorEditor::onAppAddClicked()
if (appList.contains(m_ui->leAppName->text(), Qt::CaseInsensitive)) if (appList.contains(m_ui->leAppName->text(), Qt::CaseInsensitive))
{ {
QMessageBox msgBox(QMessageBox::Critical, tr("Error"), QMessageBox msgBox(QMessageBox::Critical, tr("Error"), tr("There already exists an app named \"%1\".").arg(m_ui->leAppName->text()));
tr("There already exists an app named \"%1\".").arg(m_ui->leAppName->text()));
msgBox.exec(); msgBox.exec();
return; return;
} }
@@ -254,8 +252,7 @@ void LtsAppDescriptorEditor::onPluginAddClicked()
if (pluginList.contains(m_ui->lePluginName->text(), Qt::CaseInsensitive)) if (pluginList.contains(m_ui->lePluginName->text(), Qt::CaseInsensitive))
{ {
QMessageBox msgBox(QMessageBox::Critical, tr("Error"), QMessageBox msgBox(QMessageBox::Critical, tr("Error"), tr("There already exists an plugin named \"%1\".").arg(m_ui->lePluginName->text()));
tr("There already exists an plugin named \"%1\".").arg(m_ui->lePluginName->text()));
msgBox.exec(); msgBox.exec();
return; return;
} }
@@ -293,8 +290,10 @@ void LtsAppDescriptorEditor::onAppDeleteClicked()
QMessageBox msgBox(tr("Warning"), QMessageBox msgBox(tr("Warning"),
tr("The App \n\"%1\" \nwill be removed. Continue?").arg(m_appIndex.data().toString()), tr("The App \n\"%1\" \nwill be removed. Continue?").arg(m_appIndex.data().toString()),
QMessageBox::Warning, QMessageBox::Yes | QMessageBox::Default, QMessageBox::Warning,
QMessageBox::No | QMessageBox::Escape, QMessageBox::NoButton); QMessageBox::Yes | QMessageBox::Default,
QMessageBox::No | QMessageBox::Escape,
QMessageBox::NoButton);
if (msgBox.exec() == QMessageBox::No) if (msgBox.exec() == QMessageBox::No)
return; return;
@@ -313,8 +312,10 @@ void LtsAppDescriptorEditor::onPluginDeletedClicked()
QMessageBox msgBox(tr("Warning"), QMessageBox msgBox(tr("Warning"),
tr("The Plugin \n\"%1\" \nwill be removed. Continue?").arg(m_pluginIndex.data().toString()), tr("The Plugin \n\"%1\" \nwill be removed. Continue?").arg(m_pluginIndex.data().toString()),
QMessageBox::Warning, QMessageBox::Yes | QMessageBox::Default, QMessageBox::Warning,
QMessageBox::No | QMessageBox::Escape, QMessageBox::NoButton); QMessageBox::Yes | QMessageBox::Default,
QMessageBox::No | QMessageBox::Escape,
QMessageBox::NoButton);
if (msgBox.exec() == QMessageBox::No) if (msgBox.exec() == QMessageBox::No)
return; return;
@@ -354,27 +355,20 @@ void LtsAppDescriptorEditor::onUpdateClicked()
m_vector[m_appIndex.row()].requiredPlugins[m_pluginIndex.row()].iid = m_ui->lePluginName->text(); m_vector[m_appIndex.row()].requiredPlugins[m_pluginIndex.row()].iid = m_ui->lePluginName->text();
if (m_ui->lePluginType->text() == QLatin1String("gui")) if (m_ui->lePluginType->text() == QLatin1String("gui"))
m_vector[m_appIndex.row()].requiredPlugins[m_pluginIndex.row()].type = m_vector[m_appIndex.row()].requiredPlugins[m_pluginIndex.row()].type = LtsAppDescriptor::PluginInfo::PluginType::GUI;
LtsAppDescriptor::PluginInfo::PluginType::GUI;
else if (m_ui->lePluginType->text() == QLatin1String("data")) else if (m_ui->lePluginType->text() == QLatin1String("data"))
m_vector[m_appIndex.row()].requiredPlugins[m_pluginIndex.row()].type = m_vector[m_appIndex.row()].requiredPlugins[m_pluginIndex.row()].type = LtsAppDescriptor::PluginInfo::PluginType::DATA;
LtsAppDescriptor::PluginInfo::PluginType::DATA;
else else
m_vector[m_appIndex.row()].requiredPlugins[m_pluginIndex.row()].type = m_vector[m_appIndex.row()].requiredPlugins[m_pluginIndex.row()].type = LtsAppDescriptor::PluginInfo::PluginType::UNKNOWN;
LtsAppDescriptor::PluginInfo::PluginType::UNKNOWN;
m_vector[m_appIndex.row()].requiredPlugins[m_pluginIndex.row()].flags = m_vector[m_appIndex.row()].requiredPlugins[m_pluginIndex.row()].flags = QFlags<LtsAppDescriptor::PluginInfo::Flag>();
QFlags<LtsAppDescriptor::PluginInfo::Flag>();
if (m_ui->chbActions->isChecked()) if (m_ui->chbActions->isChecked())
m_vector[m_appIndex.row()].requiredPlugins[m_pluginIndex.row()].flags |= m_vector[m_appIndex.row()].requiredPlugins[m_pluginIndex.row()].flags |= LtsAppDescriptor::PluginInfo::Flag::ACTIONS;
LtsAppDescriptor::PluginInfo::Flag::ACTIONS;
if (m_ui->chbMain->isChecked()) if (m_ui->chbMain->isChecked())
m_vector[m_appIndex.row()].requiredPlugins[m_pluginIndex.row()].flags |= m_vector[m_appIndex.row()].requiredPlugins[m_pluginIndex.row()].flags |= LtsAppDescriptor::PluginInfo::Flag::MAIN;
LtsAppDescriptor::PluginInfo::Flag::MAIN;
if (m_ui->chbPayload->isChecked()) if (m_ui->chbPayload->isChecked())
m_vector[m_appIndex.row()].requiredPlugins[m_pluginIndex.row()].flags |= m_vector[m_appIndex.row()].requiredPlugins[m_pluginIndex.row()].flags |= LtsAppDescriptor::PluginInfo::Flag::PAYLOAD;
LtsAppDescriptor::PluginInfo::Flag::PAYLOAD;
onAppsClicked(m_appIndex); onAppsClicked(m_appIndex);
onNewpluginClicked(); onNewpluginClicked();
@@ -454,9 +448,12 @@ void LtsAppDescriptorEditor::checkSave()
{ {
if (m_changed) if (m_changed)
{ {
QMessageBox msgBox(tr("Warning"), tr("The Data has been modified.\nDo you want to save your changes?"), QMessageBox msgBox(tr("Warning"),
QMessageBox::Warning, QMessageBox::Yes | QMessageBox::Default, tr("The Data has been modified.\nDo you want to save your changes?"),
QMessageBox::No | QMessageBox::Escape, QMessageBox::NoButton); QMessageBox::Warning,
QMessageBox::Yes | QMessageBox::Default,
QMessageBox::No | QMessageBox::Escape,
QMessageBox::NoButton);
if (msgBox.exec() == QMessageBox::Yes) if (msgBox.exec() == QMessageBox::Yes)
onSaveAsClicked(); onSaveAsClicked();
@@ -465,9 +462,8 @@ void LtsAppDescriptorEditor::checkSave()
void LtsAppDescriptorEditor::onSaveAsClicked() void LtsAppDescriptorEditor::onSaveAsClicked()
{ {
QString fileName = QFileDialog::getSaveFileName( QString fileName =
this, tr("Save JSON"), QLatin1Literal("/shd/CTC/TOOLS/TDS/TDS-source/Lts/Projects/Legatus/resources/"), QFileDialog::getSaveFileName(this, tr("Save JSON"), QLatin1Literal("/shd/CTC/TOOLS/TDS/TDS-source/Lts/Projects/Legatus/resources/"), tr("JSON File (*.json)"));
tr("JSON File (*.json)"));
if (fileName.isEmpty()) if (fileName.isEmpty())
return; return;
@@ -1,12 +1,4 @@
/**
* @RDE_HEADER@
* App Descriptor Editor
* $Id$
* $HeadURL$
* $Author$
*
* Created by Mike Wille, SLSE, 2016-10-24
*/
#include "lts_app_descriptor_editor.h" #include "lts_app_descriptor_editor.h"
@@ -19,3 +19,5 @@ NGL_TARGET_LINK_LIBRARIES(LtsCommandLineParser
PUBLIC PUBLIC
Qt6::Core Qt6::Core
) )
ADD_SUBDIRECTORY(unit-test)
@@ -1,9 +1,4 @@
/**
* @RDE_HEADER@
* $Id$
* $HeadURL$
* $Author$
*/
#include "LtsCommandLineParser.h" #include "LtsCommandLineParser.h"
@@ -18,7 +13,8 @@ namespace LtsCommandLineParser
static constexpr int s_maxDomainId = 232; static constexpr int s_maxDomainId = 232;
LtsCommandLineParser::LtsCommandLineParser(ProvideCommandLineParameterOptions opts) LtsCommandLineParser::LtsCommandLineParser(ProvideCommandLineParameterOptions opts)
: QCommandLineParser(), m_enabledOptions(opts) : QCommandLineParser()
, m_enabledOptions(opts)
{ {
if (NGL::isAppInBuildBasePath() || m_enabledOptions.testFlag(CreateDomainIdFromIp)) if (NGL::isAppInBuildBasePath() || m_enabledOptions.testFlag(CreateDomainIdFromIp))
{ {
@@ -50,18 +46,12 @@ LtsCommandLineParser::LtsCommandLineParser(ProvideCommandLineParameterOptions op
if (m_enabledOptions.testFlag(CustomConfigFile)) if (m_enabledOptions.testFlag(CustomConfigFile))
{ {
const QString cf(NGL::findProjectConfigFile()); const QString cf(NGL::findProjectConfigFile());
addOption({{QStringLiteral("i"), QStringLiteral("ini")}, addOption({{QStringLiteral("i"), QStringLiteral("ini")}, QStringLiteral("Default: ") + cf, QStringLiteral("filename"), cf});
QStringLiteral("Default: ") + cf,
QStringLiteral("filename"),
cf});
} }
if (m_enabledOptions.testFlag(TcpConnectionUrl)) if (m_enabledOptions.testFlag(TcpConnectionUrl))
{ {
const QString defaultTcpUrl(QStringLiteral("EXCTDS01:7400")); const QString defaultTcpUrl(QStringLiteral("EXCTDS01:7400"));
addOption({{QStringLiteral("t"), QStringLiteral("tcpurl")}, addOption({{QStringLiteral("t"), QStringLiteral("tcpurl")}, QStringLiteral("Default: ") + defaultTcpUrl, QStringLiteral("hostname:port"), defaultTcpUrl});
QStringLiteral("Default: ") + defaultTcpUrl,
QStringLiteral("hostname:port"),
defaultTcpUrl});
} }
addHelpOption(); addHelpOption();
@@ -1,9 +1,4 @@
/**
* @RDE_HEADER@
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once #pragma once
@@ -18,7 +13,8 @@ namespace LtsCommandLineParser
class LTSCOMMANDLINEPARSER_EXPORT LtsCommandLineParser : public QCommandLineParser class LTSCOMMANDLINEPARSER_EXPORT LtsCommandLineParser : public QCommandLineParser
{ {
public: public:
enum ProvideCommandLineParameterOptions { enum ProvideCommandLineParameterOptions
{
None = 0x0000, None = 0x0000,
CreateDomainIdFromIp = 0x0001, CreateDomainIdFromIp = 0x0001,
DomainId = 0x0002, DomainId = 0x0002,
@@ -28,21 +24,15 @@ class LTSCOMMANDLINEPARSER_EXPORT LtsCommandLineParser : public QCommandLinePars
NoVersion = 0x0020 NoVersion = 0x0020
}; };
explicit LtsCommandLineParser(ProvideCommandLineParameterOptions opts = ProvideCommandLineParameterOptions( explicit LtsCommandLineParser(ProvideCommandLineParameterOptions opts = ProvideCommandLineParameterOptions(CreateDomainIdFromIp | DomainId | ExerciseId |
CreateDomainIdFromIp | DomainId | ExerciseId | CustomConfigFile)); CustomConfigFile));
virtual ~LtsCommandLineParser() = default; virtual ~LtsCommandLineParser() = default;
int domainId() const; int domainId() const;
void setDomainId(int id); void setDomainId(int id);
int exerciseId() const int exerciseId() const { return m_exerciseId; }
{
return m_exerciseId;
}
QString iniFile() const QString iniFile() const { return m_iniFile; }
{
return m_iniFile;
}
bool iniFileSet() const; bool iniFileSet() const;
bool useTcpConnection() const; bool useTcpConnection() const;
@@ -53,10 +43,7 @@ class LTSCOMMANDLINEPARSER_EXPORT LtsCommandLineParser : public QCommandLinePars
bool domainIdProvided() const; bool domainIdProvided() const;
bool exerciseIdProvided() const; bool exerciseIdProvided() const;
void setUnitModuleTestMode(bool onOff) void setUnitModuleTestMode(bool onOff) { m_unitModuleTestMode = onOff; }
{
m_unitModuleTestMode = onOff;
}
protected: protected:
QString m_additionalHelpStr; QString m_additionalHelpStr;
@@ -0,0 +1,29 @@
#
# Unit tests for the LtsCommandLineParser module.
# One test executable per module, each registered with ctest.
#
if (NOT BUILD_TESTING)
return()
endif()
# --- LtsCommandLineParser: option registration, parsing, domain id handling
if (TARGET LtsCommandLineParser)
# probe helper: runs init() with a real command line (QtTest's main cannot
# forward CLI options); used by iniFileProvidesDomainId
ADD_EXECUTABLE(commandlineparser_ini_probe commandlineparser_ini_probe.cpp)
TARGET_LINK_LIBRARIES(commandlineparser_ini_probe
LtsCommandLineParser
Qt6::Core
)
ADD_EXECUTABLE(commandlineparser_unit_test commandlineparser_unit_test.cpp)
ADD_DEPENDENCIES(commandlineparser_unit_test commandlineparser_ini_probe)
TARGET_COMPILE_DEFINITIONS(commandlineparser_unit_test PRIVATE
INI_PROBE_EXE="$<TARGET_FILE:commandlineparser_ini_probe>")
TARGET_LINK_LIBRARIES(commandlineparser_unit_test
LtsCommandLineParser
Qt6::Core
Qt6::Test
)
ADD_TEST(NAME commandlineparser_unit_test COMMAND $<TARGET_FILE:commandlineparser_unit_test>)
endif()
@@ -0,0 +1,31 @@
/**
* @RDE_HEADER@
* Helper probe for the LtsCommandLineParser unit test: runs init() with the
* real command line (QTest's main cannot forward CLI options) and reports
* the resulting domain id.
* $Id$
* $HeadURL$
* $Author$
*/
#include <QtCore/QCoreApplication>
#include <LtsCommandLineParser/LtsCommandLineParser.h>
#include <cstdio>
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
LtsCommandLineParser::LtsCommandLineParser parser;
parser.setUnitModuleTestMode(true);
if (!parser.init(false))
{
std::printf("INIT_FAIL\n");
return 1;
}
std::printf("DOMAINID=%d\n", parser.domainId());
return 0;
}
@@ -0,0 +1,173 @@
/**
* @RDE_HEADER@
* Unittest
* $Id$
* $HeadURL$
* $Author$
*/
#include <QtTest/QTest>
#include <LtsCommandLineParser/LtsCommandLineParser.h>
#include <QtCore/QDir>
#include <QtCore/QProcess>
#include <QtCore/QSettings>
#include <QtCore/QTemporaryDir>
#include <QtCore/QUrl>
class commandlineparser_unit_test : public QObject
{
Q_OBJECT
private Q_SLOTS:
void optionDefaults();
void parseWithOptions();
void tcpConnectionUrl();
void setDomainIdOverridesGenerated();
void domainIdFallbackRange();
void initCleanRun();
void iniFileProvidesDomainId();
void unknownOptionBehaviour();
};
using Lcp = LtsCommandLineParser::LtsCommandLineParser;
void commandlineparser_unit_test::optionDefaults()
{
Lcp parser;
// nothing parsed yet
QVERIFY(!parser.domainIdProvided());
QVERIFY(!parser.exerciseIdProvided());
QVERIFY(!parser.iniFileSet());
QVERIFY(!parser.useTcpConnection());
QVERIFY(!parser.tcpConnectionUrl().isValid());
QCOMPARE(parser.exerciseId(), 0);
QCOMPARE(parser.iniFile(), QString());
}
void commandlineparser_unit_test::parseWithOptions()
{
Lcp parser(Lcp::ProvideCommandLineParameterOptions(
Lcp::DomainId | Lcp::ExerciseId | Lcp::CustomConfigFile | Lcp::TcpConnectionUrl));
const bool ok = parser.parse({
QStringLiteral("prog"),
QStringLiteral("-d"), QStringLiteral("42"),
QStringLiteral("-e"), QStringLiteral("7"),
QStringLiteral("-i"), QStringLiteral("/tmp/lts-cc.conf"),
QStringLiteral("-t"), QStringLiteral("tcpv4_lan://10.0.0.1:7400")
});
QVERIFY(ok);
QVERIFY(parser.domainIdProvided());
QVERIFY(parser.exerciseIdProvided());
QVERIFY(parser.iniFileSet());
QVERIFY(parser.useTcpConnection());
}
void commandlineparser_unit_test::tcpConnectionUrl()
{
// the tcpv4_lan scheme is canonicalized to tcpv4lan
{
Lcp parser(Lcp::ProvideCommandLineParameterOptions(Lcp::TcpConnectionUrl));
QVERIFY(parser.parse({
QStringLiteral("prog"),
QStringLiteral("-t"), QStringLiteral("tcpv4_lan://10.0.0.1:7400")
}));
const QUrl url = parser.tcpConnectionUrl();
QCOMPARE(url.scheme(), QStringLiteral("tcpv4lan"));
QCOMPARE(url.host(), QStringLiteral("10.0.0.1"));
QCOMPARE(url.port(), 7400);
}
// http/file input is rewritten to the tcpv4lan scheme
{
Lcp parser(Lcp::ProvideCommandLineParameterOptions(Lcp::TcpConnectionUrl));
QVERIFY(parser.parse({
QStringLiteral("prog"),
QStringLiteral("-t"), QStringLiteral("http://192.168.0.2:7500")
}));
QCOMPARE(parser.tcpConnectionUrl().scheme(), QStringLiteral("tcpv4lan"));
}
// without the option enabled the URL is never returned
{
Lcp parser(Lcp::ProvideCommandLineParameterOptions(Lcp::DomainId));
const QUrl url = parser.tcpConnectionUrl();
QVERIFY(!url.isValid());
QVERIFY(!parser.useTcpConnection());
}
}
void commandlineparser_unit_test::setDomainIdOverridesGenerated()
{
Lcp parser;
parser.setDomainId(7);
// the function-set id is always returned, never the IP-generated fallback
QCOMPARE(parser.domainId(), 7);
}
void commandlineparser_unit_test::domainIdFallbackRange()
{
// without an explicit id the parser falls back to the id generated from
// the local IPv4 address (or 0 when none is found)
Lcp parser;
const int id = parser.domainId();
QVERIFY2(id >= 0 && id <= 232,
qPrintable(QStringLiteral("domainId() fallback out of range: %1").arg(id)));
}
void commandlineparser_unit_test::initCleanRun()
{
// init() parses the test executable's own argument list (program name
// only under ctest) and succeeds
Lcp parser;
QVERIFY(parser.init(false));
}
void commandlineparser_unit_test::iniFileProvidesDomainId()
{
// init() re-parses the application's own argument list and QCommandLineParser
// resets the option state on every parse, so -i can only reach it through the
// process argv. QtTest's main cannot forward CLI options, so the (non-QtTest)
// probe executable runs init() with a real command line instead.
// The ini file is created under the working directory (rather than the
// default /tmp) so the test is independent of /tmp's state.
QTemporaryDir tmp(QDir::current().absolutePath() + QStringLiteral("/lcp_ut_XXXXXX"));
QVERIFY(tmp.isValid());
const QString iniFile = tmp.path() + QStringLiteral("/lts-cc.conf");
{
QSettings s(iniFile, QSettings::IniFormat);
s.setValue(QStringLiteral("Global/DomainId"), 7);
s.sync();
}
QProcess proc;
proc.start(QStringLiteral(INI_PROBE_EXE), { QStringLiteral("-i"), iniFile });
QVERIFY(proc.waitForFinished(10000));
const QByteArray out = proc.readAllStandardOutput();
// no -d given: the domain id is read from the ini file
QVERIFY2(out.contains(QByteArrayLiteral("DOMAINID=7")),
qPrintable(QString::fromUtf8(out)));
}
void commandlineparser_unit_test::unknownOptionBehaviour()
{
// the version option is registered unless NoVersion is set
Lcp withVersion;
QVERIFY(withVersion.parse({ QStringLiteral("prog"), QStringLiteral("-v") }));
QVERIFY(withVersion.isSet(QStringLiteral("v")));
// with NoVersion, -v is not registered and parsing fails
Lcp strict(Lcp::NoVersion);
QVERIFY(!strict.parse({ QStringLiteral("prog"), QStringLiteral("-v") }));
// the help option is always registered
Lcp parser;
parser.setUnitModuleTestMode(true);
QVERIFY(parser.parse({ QStringLiteral("prog"), QStringLiteral("-h") }));
QVERIFY(parser.isSet(QStringLiteral("h")));
}
QTEST_MAIN(commandlineparser_unit_test)
#include "commandlineparser_unit_test.moc"
@@ -58,7 +58,17 @@ int main(int argc, char** argv)
part3 = mgrs.substr(5, prec); part3 = mgrs.substr(5, prec);
part4 = mgrs.substr(5 + prec, prec); part4 = mgrs.substr(5 + prec, prec);
} }
fprintf(stdout, "%13.10f, %13.10f = %s %s %s %s (UTM: %d %.2f, %.2f %c)\n", lon, lat, part1.c_str(), part2.c_str(), fprintf(stdout,
part3.c_str(), part4.c_str(), zone, x, y, northp ? 'N' : 'S'); "%13.10f, %13.10f = %s %s %s %s (UTM: %d %.2f, %.2f %c)\n",
lon,
lat,
part1.c_str(),
part2.c_str(),
part3.c_str(),
part4.c_str(),
zone,
x,
y,
northp ? 'N' : 'S');
return 0; return 0;
} }
@@ -1,12 +1,4 @@
/**
* @RDE_HEADER@
* Provide some coordinate translation functions on top of GeographicLib
* $Id$
* $HeadURL$
* $Author$
*
* Created by Christian Ehrlicher, SLSE, 2016-08-31
*/
#include "lts_coord_trans.h" #include "lts_coord_trans.h"
@@ -80,8 +72,7 @@ QString UtmCoordinate::mgrs(int prec, bool withSpaces) const
ret = QString::fromLatin1(ptr, 3) + QLatin1Char(' ') + QString::fromLatin1(ptr + 3, 2); ret = QString::fromLatin1(ptr, 3) + QLatin1Char(' ') + QString::fromLatin1(ptr + 3, 2);
if (prec > 0) if (prec > 0)
{ {
ret += QLatin1Char(' ') + QString::fromLatin1(ptr + 5, prec) + QLatin1Char(' ') + ret += QLatin1Char(' ') + QString::fromLatin1(ptr + 5, prec) + QLatin1Char(' ') + QString::fromLatin1(ptr + 5 + prec, prec);
QString::fromLatin1(ptr + 5 + prec, prec);
} }
} }
else else
@@ -104,8 +95,7 @@ QPointF UtmCoordinate::geographic(double offsetX, double offsetY) const
} }
catch (const std::exception &e) catch (const std::exception &e)
{ {
fprintf(stderr, "Error while calculating geographic from utm %d, %9.6f, %9.6f: %s\n", zone, x + offsetX, fprintf(stderr, "Error while calculating geographic from utm %d, %9.6f, %9.6f: %s\n", zone, x + offsetX, y + offsetY, e.what());
y + offsetY, e.what());
ret = QPointF(); ret = QPointF();
} }
return ret * deg2rad(); return ret * deg2rad();
@@ -225,8 +215,7 @@ QRectF addMarginToArea(const QRectF& rect_LatLon_radiant, const QSize& marginMet
return res; return res;
} }
QVector<UtmCoordinate> getMgrsSquares(const QRectF& rect, bool setAsDefaultSquares, bool setAsPreferedSquare, QVector<UtmCoordinate> getMgrsSquares(const QRectF &rect, bool setAsDefaultSquares, bool setAsPreferedSquare, bool setAsSquareWithMargin)
bool setAsSquareWithMargin)
{ {
QVector<UtmCoordinate> ret = getMgrsSquaresInternal(rect); QVector<UtmCoordinate> ret = getMgrsSquaresInternal(rect);
@@ -401,25 +390,18 @@ double squareDistance(const QPointF& p1, const QPointF& p2)
std::ostream &operator<<(std::ostream &stream, const UtmCoordinate &coord) std::ostream &operator<<(std::ostream &stream, const UtmCoordinate &coord)
{ {
stream << "UtmCoordinate(" << std::setprecision(8) << coord.x << "#" << std::setprecision(8) << coord.y stream << "UtmCoordinate(" << std::setprecision(8) << coord.x << "#" << std::setprecision(8) << coord.y << " zone=" << coord.zone << ")";
<< " zone=" << coord.zone << ")";
return stream; return stream;
} }
void dumpConversionCounter() void dumpConversionCounter()
{ {
fprintf(stderr, "LtsCoordTrans: s_conversion_counter_MGRS_Forward : - mgrs : %ld\n", fprintf(stderr, "LtsCoordTrans: s_conversion_counter_MGRS_Forward : - mgrs : %ld\n", s_conversion_counter_MGRS_Forward);
s_conversion_counter_MGRS_Forward); fprintf(stderr, "LtsCoordTrans: s_conversion_counter_MGRS_Reverse - fromMgrs : %ld\n", s_conversion_counter_MGRS_Reverse);
fprintf(stderr, "LtsCoordTrans: s_conversion_counter_MGRS_Reverse - fromMgrs : %ld\n", fprintf(stderr, "LtsCoordTrans: s_conversion_counter_WGS84_Forward - lonLatAltToGeocentric : %ld\n", s_conversion_counter_WGS84_Forward);
s_conversion_counter_MGRS_Reverse); fprintf(stderr, "LtsCoordTrans: s_conversion_counter_WGS84_Reverse - geocentric2LonLatAlt : %ld\n", s_conversion_counter_WGS84_Reverse);
fprintf(stderr, "LtsCoordTrans: s_conversion_counter_WGS84_Forward - lonLatAltToGeocentric : %ld\n", fprintf(stderr, "LtsCoordTrans: s_conversion_counter_UTMUPS_Forward - fromGeographic : %ld\n", s_conversion_counter_UTMUPS_Forward);
s_conversion_counter_WGS84_Forward); fprintf(stderr, "LtsCoordTrans: s_conversion_counter_UTMUPS_Reverse - geographic : %ld\n", s_conversion_counter_UTMUPS_Reverse);
fprintf(stderr, "LtsCoordTrans: s_conversion_counter_WGS84_Reverse - geocentric2LonLatAlt : %ld\n",
s_conversion_counter_WGS84_Reverse);
fprintf(stderr, "LtsCoordTrans: s_conversion_counter_UTMUPS_Forward - fromGeographic : %ld\n",
s_conversion_counter_UTMUPS_Forward);
fprintf(stderr, "LtsCoordTrans: s_conversion_counter_UTMUPS_Reverse - geographic : %ld\n",
s_conversion_counter_UTMUPS_Reverse);
} }
long getConversionCounter_MGRS_Forward() long getConversionCounter_MGRS_Forward()
@@ -1,12 +1,4 @@
/**
* @RDE_HEADER@
* Provide some coordinate translation functions on top of GeographicLib
* $Id$
* $HeadURL$
* $Author$
*
* Created by Christian Ehrlicher, SLSE, 2016-08-31
*/
#pragma once #pragma once
@@ -46,13 +38,16 @@ struct LTSCOORDTRANS_EXPORT UtmCoordinate
UtmCoordinate() = default; UtmCoordinate() = default;
UtmCoordinate(int zone_, double x_, double y_, bool northp_ = true) : zone(zone_), northp(northp_), x(x_), y(y_) {} UtmCoordinate(int zone_, double x_, double y_, bool northp_ = true)
: zone(zone_)
bool isValid() const , northp(northp_)
, x(x_)
, y(y_)
{ {
return zone > 0 && zone <= 60;
} }
bool isValid() const { return zone > 0 && zone <= 60; }
QString mgrs(int prec = 5, bool withSpaces = true) const; QString mgrs(int prec = 5, bool withSpaces = true) const;
QPointF toPoint() const; QPointF toPoint() const;
@@ -76,9 +71,7 @@ LTSCOORDTRANS_EXPORT QPointF geographicFromMgrs(const QString& mgrs);
LTSCOORDTRANS_EXPORT QRectF addMarginToArea(const QRectF &rect_LatLon_radiant, const QSize &marginMeter); LTSCOORDTRANS_EXPORT QRectF addMarginToArea(const QRectF &rect_LatLon_radiant, const QSize &marginMeter);
LTSCOORDTRANS_EXPORT QVector<UtmCoordinate> getMgrsSquares(const QRectF& rect, bool setAsDefaultSquares, LTSCOORDTRANS_EXPORT QVector<UtmCoordinate> getMgrsSquares(const QRectF &rect, bool setAsDefaultSquares, bool setAsPreferedSquare, bool setAsSquareWithMargin = false);
bool setAsPreferedSquare,
bool setAsSquareWithMargin = false);
QVector<UtmCoordinate> getMgrsSquaresInternal(const QRectF &rect); QVector<UtmCoordinate> getMgrsSquaresInternal(const QRectF &rect);
@@ -92,11 +85,9 @@ LTSCOORDTRANS_EXPORT QVector<UtmCoordinate> defaultMgrsSquares();
LTSCOORDTRANS_EXPORT UtmCoordinate preferedMgrsSquare(); LTSCOORDTRANS_EXPORT UtmCoordinate preferedMgrsSquare();
LTSCOORDTRANS_EXPORT bool lonLatAltToGeocentric(double lon, double lat, double altitude, double& xOut, double& yOut, LTSCOORDTRANS_EXPORT bool lonLatAltToGeocentric(double lon, double lat, double altitude, double &xOut, double &yOut, double &zOut);
double& zOut);
LTSCOORDTRANS_EXPORT bool geocentric2LonLatAlt(double x, double y, double z, double& lon, double& lat, LTSCOORDTRANS_EXPORT bool geocentric2LonLatAlt(double x, double y, double z, double &lon, double &lat, double &altitude);
double& altitude);
inline double squareDistance(const UtmCoordinate &p1, const UtmCoordinate &p2) inline double squareDistance(const UtmCoordinate &p1, const UtmCoordinate &p2)
{ {
@@ -161,12 +152,10 @@ class LTSCOORDTRANS_EXPORT UtmCoordinate3D : public LtsCoordTrans::UtmCoordinate
using BaseClass = LtsCoordTrans::UtmCoordinate; using BaseClass = LtsCoordTrans::UtmCoordinate;
public: public:
UtmCoordinate3D() UtmCoordinate3D() { reset(); }
{
reset();
}
explicit UtmCoordinate3D(const LtsCoordTrans::UtmCoordinate& utm2d, double _zValue = std::nan("")) : BaseClass() explicit UtmCoordinate3D(const LtsCoordTrans::UtmCoordinate &utm2d, double _zValue = std::nan(""))
: BaseClass()
{ {
zone = utm2d.zone; zone = utm2d.zone;
northp = utm2d.northp; northp = utm2d.northp;
@@ -185,10 +174,7 @@ class LTSCOORDTRANS_EXPORT UtmCoordinate3D : public LtsCoordTrans::UtmCoordinate
zValue = std::nan(""); zValue = std::nan("");
} }
double z() const double z() const { return zValue; }
{
return zValue;
}
protected: protected:
double zValue{std::nan("")}; double zValue{std::nan("")};
@@ -77,8 +77,7 @@ void coordtrans_test::testRelativeMetricalOffet()
QFETCH(QPoint, offset); QFETCH(QPoint, offset);
QFETCH(QString, correctMgrs); QFETCH(QString, correctMgrs);
const LtsCoordTrans::UtmCoordinate& utmRef = const LtsCoordTrans::UtmCoordinate &utmRef = LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 99990 99990"));
LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 99990 99990"));
qDebug() << "utmRef = " << utmRef.mgrs(); qDebug() << "utmRef = " << utmRef.mgrs();
{ {
@@ -103,8 +102,7 @@ QRectF createArea(const QString& base, int xCenter, int yCenter, int width, int
{ {
QRectF areaRect = QRectF(xCenter - width / 2, yCenter - height / 2, width, height); QRectF areaRect = QRectF(xCenter - width / 2, yCenter - height / 2, width, height);
LtsCoordTrans::UtmCoordinate utmBase( LtsCoordTrans::UtmCoordinate utmBase(LtsCoordTrans::UtmCoordinate::fromGeographic(LtsCoordTrans::geographicFromMgrs(base)));
LtsCoordTrans::UtmCoordinate::fromGeographic(LtsCoordTrans::geographicFromMgrs(base)));
const QPointF topLeft(utmBase.geographic(areaRect.left(), areaRect.top())); const QPointF topLeft(utmBase.geographic(areaRect.left(), areaRect.top()));
const QPointF bottomRight(utmBase.geographic(areaRect.right(), areaRect.bottom())); const QPointF bottomRight(utmBase.geographic(areaRect.right(), areaRect.bottom()));
@@ -120,13 +118,10 @@ void coordtrans_test::testAddMarginToArea()
QRectF area = createArea(QStringLiteral("32U PD 0000000000"), 50000, 10000, 30000, 30000); QRectF area = createArea(QStringLiteral("32U PD 0000000000"), 50000, 10000, 30000, 30000);
QRectF area1Increased = LtsCoordTrans::addMarginToArea(area, QSize(5000, 20000)); QRectF area1Increased = LtsCoordTrans::addMarginToArea(area, QSize(5000, 20000));
qDebug() << "topLeft : " << qSetRealNumberPrecision(15) << area.topLeft() qDebug() << "topLeft : " << qSetRealNumberPrecision(15) << area.topLeft() << " - degree:" << area.topLeft() * LtsCoordTrans::rad2deg();
<< " - degree:" << area.topLeft() * LtsCoordTrans::rad2deg(); qDebug() << "topLeftInc : " << qSetRealNumberPrecision(15) << area1Increased.topLeft() << " - degree:" << area1Increased.topLeft() * LtsCoordTrans::rad2deg();
qDebug() << "topLeftInc : " << qSetRealNumberPrecision(15) << area1Increased.topLeft()
<< " - degree:" << area1Increased.topLeft() * LtsCoordTrans::rad2deg();
qDebug() << "bottomRight : " << qSetRealNumberPrecision(15) << area.bottomRight() qDebug() << "bottomRight : " << qSetRealNumberPrecision(15) << area.bottomRight() << " - degree:" << area.bottomRight() * LtsCoordTrans::rad2deg();
<< " - degree:" << area.bottomRight() * LtsCoordTrans::rad2deg();
qDebug() << "bottomRightInc : " << qSetRealNumberPrecision(15) << area1Increased.bottomRight() qDebug() << "bottomRightInc : " << qSetRealNumberPrecision(15) << area1Increased.bottomRight()
<< " - degree:" << area1Increased.bottomRight() * LtsCoordTrans::rad2deg(); << " - degree:" << area1Increased.bottomRight() * LtsCoordTrans::rad2deg();
@@ -142,13 +137,10 @@ void coordtrans_test::testAddMarginToArea()
QRectF area = createArea(QStringLiteral("32U LA 0000000000"), 100, 100, 5000, 5000); QRectF area = createArea(QStringLiteral("32U LA 0000000000"), 100, 100, 5000, 5000);
QRectF area1Increased = LtsCoordTrans::addMarginToArea(area, QSize(50000, 20000)); QRectF area1Increased = LtsCoordTrans::addMarginToArea(area, QSize(50000, 20000));
qDebug() << "topLeft : " << qSetRealNumberPrecision(15) << area.topLeft() qDebug() << "topLeft : " << qSetRealNumberPrecision(15) << area.topLeft() << " - degree:" << area.topLeft() * LtsCoordTrans::rad2deg();
<< " - degree:" << area.topLeft() * LtsCoordTrans::rad2deg(); qDebug() << "topLeftInc : " << qSetRealNumberPrecision(15) << area1Increased.topLeft() << " - degree:" << area1Increased.topLeft() * LtsCoordTrans::rad2deg();
qDebug() << "topLeftInc : " << qSetRealNumberPrecision(15) << area1Increased.topLeft()
<< " - degree:" << area1Increased.topLeft() * LtsCoordTrans::rad2deg();
qDebug() << "bottomRight : " << qSetRealNumberPrecision(15) << area.bottomRight() qDebug() << "bottomRight : " << qSetRealNumberPrecision(15) << area.bottomRight() << " - degree:" << area.bottomRight() * LtsCoordTrans::rad2deg();
<< " - degree:" << area.bottomRight() * LtsCoordTrans::rad2deg();
qDebug() << "bottomRightInc : " << qSetRealNumberPrecision(15) << area1Increased.bottomRight() qDebug() << "bottomRightInc : " << qSetRealNumberPrecision(15) << area1Increased.bottomRight()
<< " - degree:" << area1Increased.bottomRight() * LtsCoordTrans::rad2deg(); << " - degree:" << area1Increased.bottomRight() * LtsCoordTrans::rad2deg();
@@ -167,8 +159,7 @@ void coordtrans_test::testIncreaseRect()
QString mgrs = LtsCoordTrans::mgrsFromGeographic(lonlat.x(), lonlat.y(), 9); QString mgrs = LtsCoordTrans::mgrsFromGeographic(lonlat.x(), lonlat.y(), 9);
QCOMPARE(mgrs, QStringLiteral("32U MD 745000000 840000000")); QCOMPARE(mgrs, QStringLiteral("32U MD 745000000 840000000"));
const LtsCoordTrans::UtmCoordinate centerPoint = const LtsCoordTrans::UtmCoordinate centerPoint = LtsCoordTrans::UtmCoordinate::fromGeographic(lonlat.x(), lonlat.y());
LtsCoordTrans::UtmCoordinate::fromGeographic(lonlat.x(), lonlat.y());
LtsCoordTrans::UtmCoordinate topLeftUtm; LtsCoordTrans::UtmCoordinate topLeftUtm;
LtsCoordTrans::UtmCoordinate topLeftUtm2; LtsCoordTrans::UtmCoordinate topLeftUtm2;
@@ -178,11 +169,9 @@ void coordtrans_test::testIncreaseRect()
QPointF bottomRightGeo = centerPoint.geographic(3000, -4000); QPointF bottomRightGeo = centerPoint.geographic(3000, -4000);
topLeftUtm = LtsCoordTrans::UtmCoordinate::fromGeographic(topLeftGeo); topLeftUtm = LtsCoordTrans::UtmCoordinate::fromGeographic(topLeftGeo);
const LtsCoordTrans::UtmCoordinate bottomRightUtm = const LtsCoordTrans::UtmCoordinate bottomRightUtm = LtsCoordTrans::UtmCoordinate::fromGeographic(bottomRightGeo);
LtsCoordTrans::UtmCoordinate::fromGeographic(bottomRightGeo);
qDebug() << "topLeftUtm: " << topLeftUtm.x << " - " << qSetRealNumberPrecision(15) << topLeftUtm.y; qDebug() << "topLeftUtm: " << topLeftUtm.x << " - " << qSetRealNumberPrecision(15) << topLeftUtm.y;
qDebug() << "bottomRightUtm: " << bottomRightUtm.x << " - " << qSetRealNumberPrecision(15) qDebug() << "bottomRightUtm: " << bottomRightUtm.x << " - " << qSetRealNumberPrecision(15) << bottomRightUtm.y;
<< bottomRightUtm.y;
} }
{ {
@@ -194,8 +183,7 @@ void coordtrans_test::testIncreaseRect()
bottomRightUtm2.y = centerPoint.y - 4000; bottomRightUtm2.y = centerPoint.y - 4000;
qDebug() << "topLeftUtm2: " << topLeftUtm2.x << " - " << qSetRealNumberPrecision(15) << topLeftUtm2.y; qDebug() << "topLeftUtm2: " << topLeftUtm2.x << " - " << qSetRealNumberPrecision(15) << topLeftUtm2.y;
qDebug() << "bottomRightUtm2: " << bottomRightUtm2.x << " - " << qSetRealNumberPrecision(15) qDebug() << "bottomRightUtm2: " << bottomRightUtm2.x << " - " << qSetRealNumberPrecision(15) << bottomRightUtm2.y;
<< bottomRightUtm2.y;
} }
QVERIFY2(qFuzzyCompare(topLeftUtm.x, topLeftUtm2.x), "testIncreaseRect x failed"); QVERIFY2(qFuzzyCompare(topLeftUtm.x, topLeftUtm2.x), "testIncreaseRect x failed");
@@ -213,8 +201,7 @@ void coordtrans_test::testIncreaseRect2()
QRectF myRectIncreased; QRectF myRectIncreased;
{ {
const LtsCoordTrans::UtmCoordinate centerPoint = const LtsCoordTrans::UtmCoordinate centerPoint = LtsCoordTrans::UtmCoordinate::fromGeographic(lonlat.x(), lonlat.y());
LtsCoordTrans::UtmCoordinate::fromGeographic(lonlat.x(), lonlat.y());
QPointF topLeftGeo = centerPoint.geographic(-3000, 2000); QPointF topLeftGeo = centerPoint.geographic(-3000, 2000);
QPointF bottomRightGeo = centerPoint.geographic(3000, -2000); QPointF bottomRightGeo = centerPoint.geographic(3000, -2000);
@@ -239,10 +226,8 @@ void coordtrans_test::testIncreaseRect2()
qDebug() << "myRectIncreased height: " << myRectIncreased.height(); qDebug() << "myRectIncreased height: " << myRectIncreased.height();
} }
QVERIFY2((int)(myRectIncreased.center().x() * 10000) == (int)(myRect.center().x() * 10000), QVERIFY2((int)(myRectIncreased.center().x() * 10000) == (int)(myRect.center().x() * 10000), "testIncreaseRect2 centerX failed");
"testIncreaseRect2 centerX failed"); QVERIFY2((int)(myRectIncreased.center().y() * 10000) == (int)(myRect.center().y() * 10000), "testIncreaseRect2 centerY failed");
QVERIFY2((int)(myRectIncreased.center().y() * 10000) == (int)(myRect.center().y() * 10000),
"testIncreaseRect2 centerY failed");
QVERIFY2(myRectIncreased.width() > myRect.width(), "testIncreaseRect2 width failed"); QVERIFY2(myRectIncreased.width() > myRect.width(), "testIncreaseRect2 width failed");
QVERIFY2(myRectIncreased.height() > myRect.height(), "testIncreaseRect2 height failed"); QVERIFY2(myRectIncreased.height() > myRect.height(), "testIncreaseRect2 height failed");
@@ -260,50 +245,84 @@ void coordtrans_test::testGeographicFromMgrs()
void coordtrans_test::testMgrsSquares() void coordtrans_test::testMgrsSquares()
{ {
checkArea(QStringLiteral("32U PD 0000000000"), 50000, 10000, 30000, 30000, checkArea(QStringLiteral("32U PD 0000000000"), 50000, 10000, 30000, 30000, {QStringLiteral("32U PC"), QStringLiteral("32U PD")});
{QStringLiteral("32U PC"), QStringLiteral("32U PD")}); checkArea(QStringLiteral("32U MD 0000000000"), 50000, 10000, 30000, 30000, {QStringLiteral("32U MC"), QStringLiteral("32U MD")});
checkArea(QStringLiteral("32U MD 0000000000"), 50000, 10000, 30000, 30000, checkArea(QStringLiteral("32U MD 0000000000"),
{QStringLiteral("32U MC"), QStringLiteral("32U MD")}); 89999,
checkArea(QStringLiteral("32U MD 0000000000"), 89999, 89999, 21000, 21000, 89999,
21000,
21000,
{QStringLiteral("32U MD"), QStringLiteral("32U ME"), QStringLiteral("32U ND"), QStringLiteral("32U NE")}); {QStringLiteral("32U MD"), QStringLiteral("32U ME"), QStringLiteral("32U ND"), QStringLiteral("32U NE")});
checkArea(QStringLiteral("39Q XG 0000000000"), 40000, 35000, 60000, 70000, checkArea(QStringLiteral("39Q XG 0000000000"), 40000, 35000, 60000, 70000, {QStringLiteral("39Q XG"), QStringLiteral("39R XG")});
{QStringLiteral("39Q XG"), QStringLiteral("39R XG")});
checkArea(QStringLiteral("40R CP 0000000000"), 94000, 9000, 7000, 16000, {QStringLiteral("40R CP")}); checkArea(QStringLiteral("40R CP 0000000000"), 94000, 9000, 7000, 16000, {QStringLiteral("40R CP")});
checkArea(QStringLiteral("40R DN 0000000000"), 500, 95500, 12000, 7000, checkArea(QStringLiteral("40R DN 0000000000"), 500, 95500, 12000, 7000, {QStringLiteral("40R CN"), QStringLiteral("40R DN")});
{QStringLiteral("40R CN"), QStringLiteral("40R DN")}); checkArea(QStringLiteral("40R DN 0000000000"),
checkArea(QStringLiteral("40R DN 0000000000"), 500, 96760, 30000, 30000, 500,
96760,
30000,
30000,
{QStringLiteral("40R CN"), QStringLiteral("40R CP"), QStringLiteral("40R DN"), QStringLiteral("40R DP")}); {QStringLiteral("40R CN"), QStringLiteral("40R CP"), QStringLiteral("40R DN"), QStringLiteral("40R DP")});
checkArea(QStringLiteral("40R BM 0000000000"), 59000, 59500, 46000, 40000, checkArea(QStringLiteral("40R BM 0000000000"), 59000, 59500, 46000, 40000, {QStringLiteral("40Q BM"), QStringLiteral("40R BM")});
{QStringLiteral("40Q BM"), QStringLiteral("40R BM")});
checkArea(QStringLiteral("32U LA 0000000000"), 10000, 10000, 5000, 5000, checkArea(QStringLiteral("32U LA 0000000000"),
10000,
10000,
5000,
5000,
{ {
QStringLiteral("32U LA"), QStringLiteral("32U LA"),
}); });
checkArea(QStringLiteral("32U LA 0000000000"), 100, 100, 60000, 60000, checkArea(QStringLiteral("32U LA 0000000000"),
{QStringLiteral("31U GQ"), QStringLiteral("31U GR"), QStringLiteral("32U KA"), QStringLiteral("32U KV"), 100,
QStringLiteral("32U LA"), QStringLiteral("32U LV")}); 100,
60000,
60000,
{QStringLiteral("31U GQ"), QStringLiteral("31U GR"), QStringLiteral("32U KA"), QStringLiteral("32U KV"), QStringLiteral("32U LA"), QStringLiteral("32U LV")});
checkArea(QStringLiteral("32U LA 0000000000"), 100, 100, 150000, 150000, checkArea(QStringLiteral("32U LA 0000000000"),
{QStringLiteral("31U FQ"), QStringLiteral("31U FR"), QStringLiteral("31U GQ"), QStringLiteral("31U GR"), 100,
QStringLiteral("32U KA"), QStringLiteral("32U KV"), QStringLiteral("32U LA"), QStringLiteral("32U LV")}); 100,
150000,
150000,
{QStringLiteral("31U FQ"),
QStringLiteral("31U FR"),
QStringLiteral("31U GQ"),
QStringLiteral("31U GR"),
QStringLiteral("32U KA"),
QStringLiteral("32U KV"),
QStringLiteral("32U LA"),
QStringLiteral("32U LV")});
checkArea(QStringLiteral("32U LA 0000000000"), 100, 100, 200000, 200000, checkArea(QStringLiteral("32U LA 0000000000"),
{QStringLiteral("31U FP"), QStringLiteral("31U FQ"), QStringLiteral("31U FR"), QStringLiteral("31U GP"), 100,
QStringLiteral("31U GQ"), QStringLiteral("31U GR"), QStringLiteral("31U GS"), QStringLiteral("32U KA"), 100,
QStringLiteral("32U KB"), QStringLiteral("32U KV"), QStringLiteral("32U LA"), QStringLiteral("32U LB"), 200000,
QStringLiteral("32U LV"), QStringLiteral("32U MA"), QStringLiteral("32U MB"), QStringLiteral("32U MV")}); 200000,
{QStringLiteral("31U FP"),
QStringLiteral("31U FQ"),
QStringLiteral("31U FR"),
QStringLiteral("31U GP"),
QStringLiteral("31U GQ"),
QStringLiteral("31U GR"),
QStringLiteral("31U GS"),
QStringLiteral("32U KA"),
QStringLiteral("32U KB"),
QStringLiteral("32U KV"),
QStringLiteral("32U LA"),
QStringLiteral("32U LB"),
QStringLiteral("32U LV"),
QStringLiteral("32U MA"),
QStringLiteral("32U MB"),
QStringLiteral("32U MV")});
} }
QVector<LtsCoordTrans::UtmCoordinate> checkAreaGetMgrsSquares(const QString& base, int xCenter, int yCenter, int width, QVector<LtsCoordTrans::UtmCoordinate> checkAreaGetMgrsSquares(const QString &base, int xCenter, int yCenter, int width, int height)
int height)
{ {
QRectF areaRect = QRectF(xCenter - width / 2, yCenter - height / 2, width, height); QRectF areaRect = QRectF(xCenter - width / 2, yCenter - height / 2, width, height);
LtsCoordTrans::UtmCoordinate utmBase( LtsCoordTrans::UtmCoordinate utmBase(LtsCoordTrans::UtmCoordinate::fromGeographic(LtsCoordTrans::geographicFromMgrs(base)));
LtsCoordTrans::UtmCoordinate::fromGeographic(LtsCoordTrans::geographicFromMgrs(base)));
const QPointF topLeft(utmBase.geographic(areaRect.left(), areaRect.top())); const QPointF topLeft(utmBase.geographic(areaRect.left(), areaRect.top()));
const QPointF bottomRight(utmBase.geographic(areaRect.right(), areaRect.bottom())); const QPointF bottomRight(utmBase.geographic(areaRect.right(), areaRect.bottom()));
@@ -323,20 +342,17 @@ void coordtrans_test::testMgrsSquaresWithSurrounding()
int initialSize = 5000; int initialSize = 5000;
QVector<LtsCoordTrans::UtmCoordinate> squares1 = QVector<LtsCoordTrans::UtmCoordinate> squares1 = checkAreaGetMgrsSquares(QStringLiteral("32U NC 0000000000"), 50000, 50000, initialSize, initialSize);
checkAreaGetMgrsSquares(QStringLiteral("32U NC 0000000000"), 50000, 50000, initialSize, initialSize);
QVERIFY2(squares1.size() == 1, "checkAreaGetMgrsSquares failed"); QVERIFY2(squares1.size() == 1, "checkAreaGetMgrsSquares failed");
int biggerSize = initialSize + (1 * 110000); int biggerSize = initialSize + (1 * 110000);
QVector<LtsCoordTrans::UtmCoordinate> squares9 = QVector<LtsCoordTrans::UtmCoordinate> squares9 = checkAreaGetMgrsSquares(QStringLiteral("32U NC 0000000000"), 50000, 50000, biggerSize, biggerSize);
checkAreaGetMgrsSquares(QStringLiteral("32U NC 0000000000"), 50000, 50000, biggerSize, biggerSize);
QVERIFY2(squares9.size() == 9, "checkAreaGetMgrsSquares biggerSize failed"); QVERIFY2(squares9.size() == 9, "checkAreaGetMgrsSquares biggerSize failed");
int muchBiggerSize = initialSize + (3 * 110000); int muchBiggerSize = initialSize + (3 * 110000);
QVector<LtsCoordTrans::UtmCoordinate> square33 = QVector<LtsCoordTrans::UtmCoordinate> square33 = checkAreaGetMgrsSquares(QStringLiteral("32U NC 0000000000"), 50000, 50000, muchBiggerSize, muchBiggerSize);
checkAreaGetMgrsSquares(QStringLiteral("32U NC 0000000000"), 50000, 50000, muchBiggerSize, muchBiggerSize);
QVERIFY2(square33.size() == 33, "checkAreaGetMgrsSquares muchBiggerSize failed"); QVERIFY2(square33.size() == 33, "checkAreaGetMgrsSquares muchBiggerSize failed");
@@ -376,13 +392,11 @@ void coordtrans_test::testMgrsSquaresWithSurrounding()
} }
} }
void coordtrans_test::checkArea(const QString& base, int xCenter, int yCenter, int width, int height, void coordtrans_test::checkArea(const QString &base, int xCenter, int yCenter, int width, int height, const QStringList &coords)
const QStringList& coords)
{ {
qDebug() << "checkArea : base: " << base; qDebug() << "checkArea : base: " << base;
QRectF areaRect = QRectF(xCenter - width / 2, yCenter - height / 2, width, height); QRectF areaRect = QRectF(xCenter - width / 2, yCenter - height / 2, width, height);
LtsCoordTrans::UtmCoordinate utmBase( LtsCoordTrans::UtmCoordinate utmBase(LtsCoordTrans::UtmCoordinate::fromGeographic(LtsCoordTrans::geographicFromMgrs(base)));
LtsCoordTrans::UtmCoordinate::fromGeographic(LtsCoordTrans::geographicFromMgrs(base)));
const QPointF topLeft(utmBase.geographic(areaRect.left(), areaRect.top())); const QPointF topLeft(utmBase.geographic(areaRect.left(), areaRect.top()));
const QPointF bottomRight(utmBase.geographic(areaRect.right(), areaRect.bottom())); const QPointF bottomRight(utmBase.geographic(areaRect.right(), areaRect.bottom()));
qDebug() << "TopLeft: " << topLeft * LtsCoordTrans::rad2deg(); qDebug() << "TopLeft: " << topLeft * LtsCoordTrans::rad2deg();
@@ -1,12 +1,4 @@
/**
* @RDE_HEADER@
* An Input Widget for coordinates
* $Id$
* $HeadURL$
* $Author$
*
* Created by Christian Ehrlicher, SLSE, 2016-09-08
*/
#include "lts_coord_widget.h" #include "lts_coord_widget.h"
@@ -18,7 +10,9 @@
namespace LtsCoordWidget namespace LtsCoordWidget
{ {
LtsCoordWidget::LtsCoordWidget(DisplayType dt, QWidget* parent) : QWidget(parent), m_displayType(dt) LtsCoordWidget::LtsCoordWidget(DisplayType dt, QWidget *parent)
: QWidget(parent)
, m_displayType(dt)
{ {
setFocusPolicy(Qt::StrongFocus); setFocusPolicy(Qt::StrongFocus);
rebuildUi(); rebuildUi();
@@ -157,12 +151,9 @@ void LtsCoordWidget::rebuildUi()
m_inputWidgetHandler->setSquaresEditable(m_bMgrsSquareEditable); m_inputWidgetHandler->setSquaresEditable(m_bMgrsSquareEditable);
m_inputWidgetHandler->resetButton()->setVisible(m_bWithResetButton); m_inputWidgetHandler->resetButton()->setVisible(m_bWithResetButton);
connect(m_inputWidgetHandler->resetButton(), &QToolButton::clicked, this, connect(m_inputWidgetHandler->resetButton(), &QToolButton::clicked, this, &LtsCoordWidget::onResetToDefaultCoordinate);
&LtsCoordWidget::onResetToDefaultCoordinate); connect(m_inputWidgetHandler, &LtsCoordInputWidgetHandler::coordinateChanged, this, &LtsCoordWidget::coordinateChanged);
connect(m_inputWidgetHandler, &LtsCoordInputWidgetHandler::coordinateChanged, this, connect(m_inputWidgetHandler, &LtsCoordInputWidgetHandler::invalidCoordinate, this, &LtsCoordWidget::invalidCoordinate);
&LtsCoordWidget::coordinateChanged);
connect(m_inputWidgetHandler, &LtsCoordInputWidgetHandler::invalidCoordinate, this,
&LtsCoordWidget::invalidCoordinate);
if (!m_defaultCoordinate.isNull()) if (!m_defaultCoordinate.isNull())
m_inputWidgetHandler->setCoordinate(m_defaultCoordinate); m_inputWidgetHandler->setCoordinate(m_defaultCoordinate);
} }
@@ -1,12 +1,5 @@
/**
* @RDE_HEADER@
* An Input Widget for coordinates
* $Id$
* $HeadURL$
* $Author$
*
* Created by Christian Ehrlicher, SLSE, 2016-09-08
*/
#pragma once #pragma once
#include <LtsCoordTrans/lts_coord_trans.h> #include <LtsCoordTrans/lts_coord_trans.h>
#include <LtsCoordTrans/ltscoordwidget_export.h> #include <LtsCoordTrans/ltscoordwidget_export.h>
@@ -23,14 +16,24 @@ class LTSCOORDWIDGET_EXPORT LtsCoordWidget : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
enum class DisplayType { MGRS5, MGRS7, UTM, WGS84, MGRS = DisplayType::MGRS5 }; enum class DisplayType
{
MGRS5,
MGRS7,
UTM,
WGS84,
MGRS = DisplayType::MGRS5
};
Q_ENUM(DisplayType) Q_ENUM(DisplayType)
Q_PROPERTY(DisplayType displayType READ displayType WRITE setDisplayType) Q_PROPERTY(DisplayType displayType READ displayType WRITE setDisplayType)
Q_PROPERTY(bool withResetButton READ withResetButton WRITE setWithResetButton) Q_PROPERTY(bool withResetButton READ withResetButton WRITE setWithResetButton)
Q_PROPERTY(bool showToolTip READ showToolTip WRITE setShowToolTip) Q_PROPERTY(bool showToolTip READ showToolTip WRITE setShowToolTip)
Q_PROPERTY(bool mgrsSquareEditable READ mgrsSquareEditable WRITE setMgrsSquareEditable) Q_PROPERTY(bool mgrsSquareEditable READ mgrsSquareEditable WRITE setMgrsSquareEditable)
explicit LtsCoordWidget(QWidget* parent = nullptr) : LtsCoordWidget(LtsCoordWidget::DisplayType::MGRS, parent) {} explicit LtsCoordWidget(QWidget *parent = nullptr)
: LtsCoordWidget(LtsCoordWidget::DisplayType::MGRS, parent)
{
}
explicit LtsCoordWidget(DisplayType dt, QWidget *parent = nullptr); explicit LtsCoordWidget(DisplayType dt, QWidget *parent = nullptr);
@@ -1,12 +1,4 @@
/**
* @RDE_HEADER@
* An Input Widget for coordinates
* $Id$
* $HeadURL$
* $Author$
*
* Created by Christian Ehrlicher, SLSE, 2016-09-08
*/
#include "lts_coord_widget_p.h" #include "lts_coord_widget_p.h"
@@ -27,7 +19,9 @@ void LtsCoordInputWidgetHandler::onCoordinateDataChanged()
} }
MgrsEdit::MgrsEdit(int precision, QWidget *widget) MgrsEdit::MgrsEdit(int precision, QWidget *widget)
: LtsCoordInputWidgetHandler(widget), m_precision(precision), m_ui(new Ui::Mgrs) : LtsCoordInputWidgetHandler(widget)
, m_precision(precision)
, m_ui(new Ui::Mgrs)
{ {
m_ui->setupUi(widget); m_ui->setupUi(widget);
@@ -40,8 +34,7 @@ MgrsEdit::MgrsEdit(int precision, QWidget* widget)
m_ui->leNorth->setValidator(new QIntValidator(0, upperLimit, m_ui->leNorth)); m_ui->leNorth->setValidator(new QIntValidator(0, upperLimit, m_ui->leNorth));
setDefaultMgrsSquares(); setDefaultMgrsSquares();
connect(m_ui->cbxZone, QOverload<int>::of(&QComboBox::currentIndexChanged), this, connect(m_ui->cbxZone, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &MgrsEdit::onCoordinateDataChanged);
&MgrsEdit::onCoordinateDataChanged);
connect(m_ui->leEast, &QLineEdit::editingFinished, this, &MgrsEdit::onCoordinateDataChanged); connect(m_ui->leEast, &QLineEdit::editingFinished, this, &MgrsEdit::onCoordinateDataChanged);
connect(m_ui->leNorth, &QLineEdit::editingFinished, this, &MgrsEdit::onCoordinateDataChanged); connect(m_ui->leNorth, &QLineEdit::editingFinished, this, &MgrsEdit::onCoordinateDataChanged);
} }
@@ -214,7 +207,9 @@ void MgrsEdit::setMgrsSquares(const QVector<LtsCoordTrans::UtmCoordinate>& geoCo
m_ui->cbxZone->addItems(sl); m_ui->cbxZone->addItems(sl);
} }
Wgs84Edit::Wgs84Edit(QWidget* widget) : LtsCoordInputWidgetHandler(widget), m_ui(new Ui::Wgs84) Wgs84Edit::Wgs84Edit(QWidget *widget)
: LtsCoordInputWidgetHandler(widget)
, m_ui(new Ui::Wgs84)
{ {
m_ui->setupUi(widget); m_ui->setupUi(widget);
@@ -1,12 +1,5 @@
/**
* @RDE_HEADER@
* An Input Widget for coordinates
* $Id$
* $HeadURL$
* $Author$
*
* Created by Christian Ehrlicher, SLSE, 2016-09-08
*/
#pragma once #pragma once
#include "ui_lts_coord_widget_mgrs.h" #include "ui_lts_coord_widget_mgrs.h"
@@ -24,7 +17,10 @@ class LtsCoordInputWidgetHandler : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit LtsCoordInputWidgetHandler(QObject* parent) : QObject(parent) {} explicit LtsCoordInputWidgetHandler(QObject *parent)
: QObject(parent)
{
}
virtual bool isValid() = 0; virtual bool isValid() = 0;
virtual void setCoordinate(const QPointF &geoCoord) = 0; virtual void setCoordinate(const QPointF &geoCoord) = 0;
@@ -84,20 +80,11 @@ class Wgs84Edit final : public LtsCoordInputWidgetHandler
void cleanup() override; void cleanup() override;
void clear() override; void clear() override;
void setSquaresEditable(bool bEditable) override void setSquaresEditable(bool bEditable) override { Q_UNUSED(bEditable); }
{
Q_UNUSED(bEditable);
}
void setWithSurroundingSquare(bool bEnabled) override void setWithSurroundingSquare(bool bEnabled) override { Q_UNUSED(bEnabled); }
{
Q_UNUSED(bEnabled);
}
void setMgrsSquares(const QVector<LtsCoordTrans::UtmCoordinate>& geoCoords) override void setMgrsSquares(const QVector<LtsCoordTrans::UtmCoordinate> &geoCoords) override { Q_UNUSED(geoCoords); }
{
Q_UNUSED(geoCoords);
}
private: private:
Ui::Wgs84 *m_ui; Ui::Wgs84 *m_ui;
@@ -1,12 +1,4 @@
/**
* @RDE_HEADER@
* Small test app for ltscoordwidget
* $Id$
* $HeadURL$
* $Author$
*
* Created by Christian Ehrlicher, SLSE, 2016-09-08
*/
#include "lts_coord_widget.h" #include "lts_coord_widget.h"
@@ -20,10 +12,8 @@
static void updateLabel(const QPointF &coord, QLabel *lbl, int prec) static void updateLabel(const QPointF &coord, QLabel *lbl, int prec)
{ {
QString mgrs = LtsCoordTrans::mgrsFromGeographic(coord.x(), coord.y(), prec); QString mgrs = LtsCoordTrans::mgrsFromGeographic(coord.x(), coord.y(), prec);
QString str = QStringLiteral("mgrs: %1, lon: %2, lat: %3") QString str =
.arg(mgrs) QStringLiteral("mgrs: %1, lon: %2, lat: %3").arg(mgrs).arg(coord.x() * LtsCoordTrans::rad2deg(), 0, 'f', 10).arg(coord.y() * LtsCoordTrans::rad2deg(), 0, 'f', 10);
.arg(coord.x() * LtsCoordTrans::rad2deg(), 0, 'f', 10)
.arg(coord.y() * LtsCoordTrans::rad2deg(), 0, 'f', 10);
lbl->setText(str); lbl->setText(str);
} }
@@ -41,50 +31,46 @@ int main(int argc, char** argv)
const QPointF defCoord(QPointF(53.0, 8.0) * LtsCoordTrans::deg2rad()); const QPointF defCoord(QPointF(53.0, 8.0) * LtsCoordTrans::deg2rad());
LtsCoordWidget::LtsCoordWidget* wMgrs5( LtsCoordWidget::LtsCoordWidget *wMgrs5(new LtsCoordWidget::LtsCoordWidget(LtsCoordWidget::LtsCoordWidget::DisplayType::MGRS, dialog));
new LtsCoordWidget::LtsCoordWidget(LtsCoordWidget::LtsCoordWidget::DisplayType::MGRS, dialog));
wMgrs5->setWithResetButton(true); wMgrs5->setWithResetButton(true);
wMgrs5->setCoordinate(defCoord, true); wMgrs5->setCoordinate(defCoord, true);
lay->addWidget(wMgrs5); lay->addWidget(wMgrs5);
QLabel *lbl5(new QLabel(dialog)); QLabel *lbl5(new QLabel(dialog));
lay->addWidget(lbl5); lay->addWidget(lbl5);
QObject::connect(wMgrs5, &LtsCoordWidget::LtsCoordWidget::coordinateChanged, lbl5, QObject::connect(wMgrs5, &LtsCoordWidget::LtsCoordWidget::coordinateChanged, lbl5, [lbl5](const QPointF &coord) { updateLabel(coord, lbl5, 5); });
[lbl5](const QPointF& coord) { updateLabel(coord, lbl5, 5); });
LtsCoordWidget::LtsCoordWidget* wMgrs7( LtsCoordWidget::LtsCoordWidget *wMgrs7(new LtsCoordWidget::LtsCoordWidget(LtsCoordWidget::LtsCoordWidget::DisplayType::MGRS7, dialog));
new LtsCoordWidget::LtsCoordWidget(LtsCoordWidget::LtsCoordWidget::DisplayType::MGRS7, dialog));
wMgrs7->setWithResetButton(true); wMgrs7->setWithResetButton(true);
wMgrs7->setCoordinate(defCoord, true); wMgrs7->setCoordinate(defCoord, true);
lay->addWidget(wMgrs7); lay->addWidget(wMgrs7);
QLabel *lbl7(new QLabel(dialog)); QLabel *lbl7(new QLabel(dialog));
lay->addWidget(lbl7); lay->addWidget(lbl7);
QObject::connect(wMgrs7, &LtsCoordWidget::LtsCoordWidget::coordinateChanged, wMgrs7, QObject::connect(wMgrs7, &LtsCoordWidget::LtsCoordWidget::coordinateChanged, wMgrs7, [lbl7](const QPointF &coord) { updateLabel(coord, lbl7, 7); });
[lbl7](const QPointF& coord) { updateLabel(coord, lbl7, 7); });
LtsCoordWidget::LtsCoordWidget* w84( LtsCoordWidget::LtsCoordWidget *w84(new LtsCoordWidget::LtsCoordWidget(LtsCoordWidget::LtsCoordWidget::DisplayType::WGS84, dialog));
new LtsCoordWidget::LtsCoordWidget(LtsCoordWidget::LtsCoordWidget::DisplayType::WGS84, dialog));
w84->setWithResetButton(true); w84->setWithResetButton(true);
w84->setCoordinate(defCoord, true); w84->setCoordinate(defCoord, true);
lay->addWidget(w84); lay->addWidget(w84);
QLabel *lbl84(new QLabel(dialog)); QLabel *lbl84(new QLabel(dialog));
lay->addWidget(lbl84); lay->addWidget(lbl84);
QObject::connect(w84, &LtsCoordWidget::LtsCoordWidget::coordinateChanged, w84, QObject::connect(w84, &LtsCoordWidget::LtsCoordWidget::coordinateChanged, w84, [lbl84](const QPointF &coord) { updateLabel(coord, lbl84, 11); });
[lbl84](const QPointF& coord) { updateLabel(coord, lbl84, 11); });
QHBoxLayout *hLay = new QHBoxLayout; QHBoxLayout *hLay = new QHBoxLayout;
lay->addLayout(hLay); lay->addLayout(hLay);
LtsCoordWidget::LtsCoordWidget* wChange( LtsCoordWidget::LtsCoordWidget *wChange(new LtsCoordWidget::LtsCoordWidget(LtsCoordWidget::LtsCoordWidget::DisplayType::WGS84, dialog));
new LtsCoordWidget::LtsCoordWidget(LtsCoordWidget::LtsCoordWidget::DisplayType::WGS84, dialog));
wChange->setWithResetButton(true); wChange->setWithResetButton(true);
wChange->setCoordinate(defCoord, true); wChange->setCoordinate(defCoord, true);
hLay->addWidget(wChange); hLay->addWidget(wChange);
QPushButton *pbReset(new QPushButton(QStringLiteral("With Reset"), dialog)); QPushButton *pbReset(new QPushButton(QStringLiteral("With Reset"), dialog));
hLay->addWidget(pbReset); hLay->addWidget(pbReset);
QObject::connect(pbReset, &QPushButton::clicked, wChange, QObject::connect(pbReset, &QPushButton::clicked, wChange, [wChange]() { wChange->setWithResetButton(!wChange->withResetButton()); });
[wChange]() { wChange->setWithResetButton(!wChange->withResetButton()); });
QPushButton *pbNext(new QPushButton(QStringLiteral("Next Type"), dialog)); QPushButton *pbNext(new QPushButton(QStringLiteral("Next Type"), dialog));
hLay->addWidget(pbNext); hLay->addWidget(pbNext);
QObject::connect(pbNext, &QPushButton::clicked, wChange, [wChange]() { QObject::connect(pbNext,
&QPushButton::clicked,
wChange,
[wChange]()
{
LtsCoordWidget::LtsCoordWidget::DisplayType dt = wChange->displayType(); LtsCoordWidget::LtsCoordWidget::DisplayType dt = wChange->displayType();
switch (dt) switch (dt)
{ {
@@ -38,7 +38,15 @@ int main(int argc, char** argv)
part2 = mgrs.substr(3, 2); part2 = mgrs.substr(3, 2);
part3 = mgrs.substr(5, prec); part3 = mgrs.substr(5, prec);
part4 = mgrs.substr(5 + prec, prec); part4 = mgrs.substr(5 + prec, prec);
fprintf(stdout, "%s %s %s %s = %13.10f, %13.10f ( %13.10f, %13.10f )\n", part1.c_str(), part2.c_str(), fprintf(stdout,
part3.c_str(), part4.c_str(), lonDeg, latDeg, lonDeg / 180. * M_PI, latDeg / 180. * M_PI); "%s %s %s %s = %13.10f, %13.10f ( %13.10f, %13.10f )\n",
part1.c_str(),
part2.c_str(),
part3.c_str(),
part4.c_str(),
lonDeg,
latDeg,
lonDeg / 180. * M_PI,
latDeg / 180. * M_PI);
return 0; return 0;
} }
@@ -1,10 +1,4 @@
/**
* @RDE_HEADER@
* Crypt/Decrypt functions (AES 256 CBC)
* $Id$
* $HeadURL$
* $Author$
*/
#include "aes_crypt.h" #include "aes_crypt.h"
@@ -19,8 +13,8 @@ namespace LtsLicence
struct AesCryptPrivate struct AesCryptPrivate
{ {
AesCryptPrivate() AesCryptPrivate()
: passPhrase(QLatin1String("LTS " LTS_VERSION_MAJOR "." LTS_VERSION_MINOR)), : passPhrase(QLatin1String("LTS " LTS_VERSION_MAJOR "." LTS_VERSION_MINOR))
logger(NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("LtsLicenceLib.AesCrypt")) , logger(NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("LtsLicenceLib.AesCrypt"))
{ {
#if OPENSSL_VERSION_NUMBER < 0x1010000fL #if OPENSSL_VERSION_NUMBER < 0x1010000fL
ERR_load_crypto_strings(); ERR_load_crypto_strings();
@@ -1,10 +1,4 @@
/**
* @RDE_HEADER@
* Crypt/Decrypt functions (AES 256 CBC)
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once #pragma once
@@ -18,9 +12,7 @@ namespace LtsLicence
LTSLICENCE_EXPORT void setPassPhrase(const QString &passPhrase); LTSLICENCE_EXPORT void setPassPhrase(const QString &passPhrase);
LTSLICENCE_EXPORT QString passPhrase(); LTSLICENCE_EXPORT QString passPhrase();
LTSLICENCE_EXPORT QByteArray decryptData(const QByteArray& dataToDecrypt, const QString& pw = passPhrase(), LTSLICENCE_EXPORT QByteArray decryptData(const QByteArray &dataToDecrypt, const QString &pw = passPhrase(), bool *bOk = nullptr);
bool* bOk = nullptr);
LTSLICENCE_EXPORT QByteArray encryptData(const QByteArray& dataToEncrypt, const QString& pw = passPhrase(), LTSLICENCE_EXPORT QByteArray encryptData(const QByteArray &dataToEncrypt, const QString &pw = passPhrase(), bool *bOk = nullptr);
bool* bOk = nullptr);
} // namespace LtsLicence } // namespace LtsLicence
@@ -1,10 +1,4 @@
/**
* @RDE_HEADER@
* Test for NCrypt
* $Id$
* $HeadURL$
* $Author$
*/
#include "aes_crypt_test.h" #include "aes_crypt_test.h"
@@ -1,10 +1,4 @@
/**
* @RDE_HEADER@
* Test for NCrypt
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once #pragma once
#include <QtCore/QObject> #include <QtCore/QObject>
@@ -1,11 +1,3 @@
/**
* @RDE_HEADER@
* Licence Library
* $Id$
* $HeadURL$
* $Author$
* Created by hjl, SLSE, 2016-06-01
*/
#include "lts_licence.h" #include "lts_licence.h"
@@ -59,8 +51,7 @@ QByteArray writeUnencryptedLicences(const QVector<Licence>& licences)
{ {
QDomDocument xmlDoc; QDomDocument xmlDoc;
QDomProcessingInstruction instr = xmlDoc.createProcessingInstruction( QDomProcessingInstruction instr = xmlDoc.createProcessingInstruction(QLatin1String("xml"), QLatin1String("version='1.0' encoding='UTF-8' standalone='yes'"));
QLatin1String("xml"), QLatin1String("version='1.0' encoding='UTF-8' standalone='yes'"));
xmlDoc.appendChild(instr); xmlDoc.appendChild(instr);
QDomElement root = xmlDoc.createElement(QLatin1String("licences")); QDomElement root = xmlDoc.createElement(QLatin1String("licences"));
@@ -134,10 +125,9 @@ bool extractLicence(const QDomElement& licenceElement, QVector<Licence>& licence
licence.expiration = qdt; licence.expiration = qdt;
INFO_LOG(getLogger()) << "Read licence for:'" << licence.name << "'" INFO_LOG(getLogger()) << "Read licence for:'" << licence.name << "'"
<< " IgnoreMaxCount: " << licence.ignoreMaxCount << " IgnoreMaxCount: " << licence.ignoreMaxCount << " IgnoreExpiration: " << licence.ignoreExpiration << " MaxCount: " << licence.maxCount
<< " IgnoreExpiration: " << licence.ignoreExpiration << " MaxCount: " << licence.maxCount << " Expiration: " << licence.expiration.date().toString() << " " << licence.expiration.time().toString()
<< " Expiration: " << licence.expiration.date().toString() << " " << " RefCount: " << licence.licenceRefCount;
<< licence.expiration.time().toString() << " RefCount: " << licence.licenceRefCount;
licenceVec.append(licence); licenceVec.append(licence);
return true; return true;
@@ -1,11 +1,4 @@
/**
* @RDE_HEADER@
* Licence Library
* $Id$
* $HeadURL$
* $Author$
* Created by hjl, SLSE, 2016-06-01
*/
#pragma once #pragma once
@@ -9,7 +9,9 @@
namespace LtsNotification namespace LtsNotification
{ {
LtsNotification::LtsNotification(LtsNotificationController* ctl) : QObject(), m_controller(ctl) LtsNotification::LtsNotification(LtsNotificationController *ctl)
: QObject()
, m_controller(ctl)
{ {
connect(ctl, &LtsNotificationController::destroyed, this, &LtsNotification::slotCtlDestroyed); connect(ctl, &LtsNotificationController::destroyed, this, &LtsNotification::slotCtlDestroyed);
} }
@@ -14,7 +14,9 @@ namespace LtsNotification
{ {
LtsNotificationController::LtsNotificationController(const QString &identifier) LtsNotificationController::LtsNotificationController(const QString &identifier)
: QObject(), m_count(0), m_identifier(QStringLiteral("LtsNotification%1").arg(identifier)) : QObject()
, m_count(0)
, m_identifier(QStringLiteral("LtsNotification%1").arg(identifier))
{ {
} }
@@ -48,9 +50,8 @@ void LtsNotificationController::setBackground(const int r, const int g, const in
if (r == -1 && g == -1 && b == -1) if (r == -1 && g == -1 && b == -1)
stylesheet = QStringLiteral(""); stylesheet = QStringLiteral("");
else else
stylesheet = QStringLiteral("QToolButton {background-color: rgb(") + QString::number(r) + stylesheet = QStringLiteral("QToolButton {background-color: rgb(") + QString::number(r) + QStringLiteral(",") + QString::number(g) + QStringLiteral(",") +
QStringLiteral(",") + QString::number(g) + QStringLiteral(",") + QString::number(b) + QString::number(b) + QStringLiteral(");}");
QStringLiteral(");}");
tb->setStyleSheet(stylesheet); tb->setStyleSheet(stylesheet);
} }
@@ -133,7 +134,11 @@ QToolButton* LtsNotificationController::createWidget()
b->setMaximumSize(SIZE, SIZE); b->setMaximumSize(SIZE, SIZE);
connect(b, &QToolButton::destroyed, this, &LtsNotificationController::slotNotiWidgetDestroyed); connect(b, &QToolButton::destroyed, this, &LtsNotificationController::slotNotiWidgetDestroyed);
connect(b, &QToolButton::clicked, this, [this]() { connect(b,
&QToolButton::clicked,
this,
[this]()
{
if (m_action) if (m_action)
m_action(); m_action();
}); });
@@ -37,15 +37,9 @@ class LTSNOTIFICATION_EXPORT LtsNotificationController : public QObject
void setCount(const int count); void setCount(const int count);
void setBackground(const int r, const int g, const int b); void setBackground(const int r, const int g, const int b);
const QString& identifier() const const QString &identifier() const { return m_identifier; }
{
return m_identifier;
}
const QString& tooltip() const const QString &tooltip() const { return m_toolTip; }
{
return m_toolTip;
}
void setEnabled(bool enable); void setEnabled(bool enable);
@@ -1,10 +1,4 @@
/**
* @RDE_HEADER@
* Building Config - logging facility
* $Id$
* $HeadURL$
* $Author$
*/
#include "logger.h" #include "logger.h"
@@ -1,10 +1,4 @@
/**
* @RDE_HEADER@
* Logging for XxxXxxXxx
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once #pragma once
@@ -15,9 +15,12 @@ class LTSSERIALPORTQUERRY_EXPORT LtsSerialPortQuerry : public QObject
public: public:
explicit LtsSerialPortQuerry(QObject *parent = nullptr); explicit LtsSerialPortQuerry(QObject *parent = nullptr);
void setSerialPortSettings(const QSerialPort::BaudRate& baudRate, const QSerialPort::OpenModeFlag& openModeFlag, void setSerialPortSettings(const QSerialPort::BaudRate &baudRate,
const QSerialPort::DataBits& dataBits, const QSerialPort::FlowControl& flowControll, const QSerialPort::OpenModeFlag &openModeFlag,
const QSerialPort::Parity& parity, const QSerialPort::StopBits& stopBits); const QSerialPort::DataBits &dataBits,
const QSerialPort::FlowControl &flowControll,
const QSerialPort::Parity &parity,
const QSerialPort::StopBits &stopBits);
void continueQuerry(); void continueQuerry();
void restartQuerry(); void restartQuerry();
QSerialPort *currentSerialPort(); QSerialPort *currentSerialPort();
@@ -6,10 +6,16 @@ namespace LtsSerialPortQuerry
{ {
LtsSerialPortQuerry::LtsSerialPortQuerry(QObject *parent) LtsSerialPortQuerry::LtsSerialPortQuerry(QObject *parent)
: QObject(parent), m_logger(getLogger("LtsSerialPortQuerry")), m_currentQuerry(0), : QObject(parent)
m_baudRate(QSerialPort::Baud115200), m_openModeFlag(QSerialPort::ReadWrite), m_dataBits(QSerialPort::Data8), , m_logger(getLogger("LtsSerialPortQuerry"))
m_flowControll(QSerialPort::NoFlowControl), m_parity(QSerialPort::NoParity), m_stopBits(QSerialPort::OneStop), , m_currentQuerry(0)
m_currentSerialPort(nullptr) , m_baudRate(QSerialPort::Baud115200)
, m_openModeFlag(QSerialPort::ReadWrite)
, m_dataBits(QSerialPort::Data8)
, m_flowControll(QSerialPort::NoFlowControl)
, m_parity(QSerialPort::NoParity)
, m_stopBits(QSerialPort::OneStop)
, m_currentSerialPort(nullptr)
{ {
} }
@@ -66,8 +72,7 @@ void LtsSerialPortQuerry::querrySerialPort(const QSerialPortInfo& info)
m_currentSerialPort->setStopBits(m_stopBits); m_currentSerialPort->setStopBits(m_stopBits);
m_currentSerialPort->setFlowControl(m_flowControll); m_currentSerialPort->setFlowControl(m_flowControll);
DEBUG_LOG(m_logger) << "Try opening Comport:" << m_currentSerialPort->portName() DEBUG_LOG(m_logger) << "Try opening Comport:" << m_currentSerialPort->portName() << " index is: " << m_currentQuerry;
<< " index is: " << m_currentQuerry;
if (!m_currentSerialPort->open(QSerialPort::ReadWrite)) if (!m_currentSerialPort->open(QSerialPort::ReadWrite))
{ {
@@ -78,8 +83,7 @@ void LtsSerialPortQuerry::querrySerialPort(const QSerialPortInfo& info)
} }
else else
{ {
connect(m_currentSerialPort, &QSerialPort::errorOccurred, this, &LtsSerialPortQuerry::onSerialPortError, connect(m_currentSerialPort, &QSerialPort::errorOccurred, this, &LtsSerialPortQuerry::onSerialPortError, Qt::UniqueConnection);
Qt::UniqueConnection);
DEBUG_LOG(m_logger) << "Oppened comport" << m_currentSerialPort->portName(); DEBUG_LOG(m_logger) << "Oppened comport" << m_currentSerialPort->portName();
emit connectionEstablished(); emit connectionEstablished();
} }
@@ -105,13 +109,13 @@ void LtsSerialPortQuerry::onSerialPortError(QSerialPort::SerialPortError serialP
return; return;
DEBUG_LOG(m_logger) << "Spontaneous error " << serialPortError << " doesn't have to be an error ..."; DEBUG_LOG(m_logger) << "Spontaneous error " << serialPortError << " doesn't have to be an error ...";
const QString errStr(QStringLiteral("QSerialPort::SerialPortError ") + QString::number(serialPortError) + const QString errStr(QStringLiteral("QSerialPort::SerialPortError ") + QString::number(serialPortError) + QStringLiteral(" from serial port ") +
QStringLiteral(" from serial port ") + m_currentSerialPort->portName() + m_currentSerialPort->portName() + QStringLiteral(" error: ") + m_currentSerialPort->errorString());
QStringLiteral(" error: ") + m_currentSerialPort->errorString());
switch (serialPortError) switch (serialPortError)
{ {
case QSerialPort::SerialPortError::NoError: { case QSerialPort::SerialPortError::NoError:
{
break; break;
} }
@@ -119,17 +123,20 @@ void LtsSerialPortQuerry::onSerialPortError(QSerialPort::SerialPortError serialP
case QSerialPort::SerialPortError::PermissionError: case QSerialPort::SerialPortError::PermissionError:
case QSerialPort::SerialPortError::OpenError: case QSerialPort::SerialPortError::OpenError:
case QSerialPort::SerialPortError::NotOpenError: case QSerialPort::SerialPortError::NotOpenError:
case QSerialPort::SerialPortError::UnknownError: { case QSerialPort::SerialPortError::UnknownError:
{
ERROR_LOG(m_logger) << "Closing port and try to reopen it. " << m_currentSerialPort->portName(); ERROR_LOG(m_logger) << "Closing port and try to reopen it. " << m_currentSerialPort->portName();
continueQuerry(); continueQuerry();
Q_FALLTHROUGH(); Q_FALLTHROUGH();
} }
case QSerialPort::SerialPortError::UnsupportedOperationError: { case QSerialPort::SerialPortError::UnsupportedOperationError:
{
ERROR_LOG(m_logger) << errStr; ERROR_LOG(m_logger) << errStr;
break; break;
} }
default: { default:
{
ERROR_LOG(m_logger) << "Got an Error> " << errStr << "restarting"; ERROR_LOG(m_logger) << "Got an Error> " << errStr << "restarting";
continueQuerry(); continueQuerry();
@@ -15,9 +15,12 @@ class LTSSERIALPORTQUERRY_EXPORT LtsSerialPortQuerry : public QObject
public: public:
explicit LtsSerialPortQuerry(QObject *parent = nullptr); explicit LtsSerialPortQuerry(QObject *parent = nullptr);
void setSerialPortSettings(const QSerialPort::BaudRate& baudRate, const QSerialPort::OpenModeFlag& openModeFlag, void setSerialPortSettings(const QSerialPort::BaudRate &baudRate,
const QSerialPort::DataBits& dataBits, const QSerialPort::FlowControl& flowControll, const QSerialPort::OpenModeFlag &openModeFlag,
const QSerialPort::Parity& parity, const QSerialPort::StopBits& stopBits); const QSerialPort::DataBits &dataBits,
const QSerialPort::FlowControl &flowControll,
const QSerialPort::Parity &parity,
const QSerialPort::StopBits &stopBits);
void restartQuerry(); void restartQuerry();
QSerialPort *currentSerialPort(); QSerialPort *currentSerialPort();
@@ -43,11 +43,9 @@ template <> char* toString(const QVector<int>& vec)
return qstrdup(sl.join(QLatin1Char(',')).toLatin1().constData()); return qstrdup(sl.join(QLatin1Char(',')).toLatin1().constData());
} }
#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0) #if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
template <typename T1, typename T2> template <typename T1, typename T2> inline bool qCompare(const T1 &t1, const T2 &t2, const char *actual, const char *expected, const char *file, int line)
inline bool qCompare(const T1& t1, const T2& t2, const char* actual, const char* expected, const char* file, int line)
{ {
return compare_helper(t1 == t2, "Compared values are not the same", toString(t1), toString(t2), actual, expected, return compare_helper(t1 == t2, "Compared values are not the same", toString(t1), toString(t2), actual, expected, file, line);
file, line);
} }
#endif #endif
} // namespace QTest } // namespace QTest
@@ -65,7 +63,9 @@ void LtsUtilsTest::test_promise()
results.append(1); results.append(1);
LtsUtils::Promise p([&results](LtsUtils::ResultFunction resolve, LtsUtils::ResultFunction) { LtsUtils::Promise p(
[&results](LtsUtils::ResultFunction resolve, LtsUtils::ResultFunction)
{
results.append(4); results.append(4);
qDebug() << "LtsUtils Promise: Promise executed! Resolving now"; qDebug() << "LtsUtils Promise: Promise executed! Resolving now";
@@ -75,13 +75,17 @@ void LtsUtilsTest::test_promise()
results.append(2); results.append(2);
bool resolved = false; bool resolved = false;
p.resolved([&resolved, &results](const QVariant& value) { p.resolved(
[&resolved, &results](const QVariant &value)
{
results.append(5); results.append(5);
qDebug() << "LtsUtils Promise: Promise was resolved with value" << value; qDebug() << "LtsUtils Promise: Promise was resolved with value" << value;
resolved = true; resolved = true;
}); });
p.rejected([](const QVariant& val) { p.rejected(
[](const QVariant &val)
{
qCritical() << "rejected with val" << val; qCritical() << "rejected with val" << val;
QFAIL("Promise unexpectedly rejected"); QFAIL("Promise unexpectedly rejected");
}); });
@@ -260,8 +264,7 @@ void LtsUtilsTest::test_fromIntArray2D()
{ {
qDebug("LtsUtils: test_fromIntArray2D"); qDebug("LtsUtils: test_fromIntArray2D");
QString str = LtsUtils::IntArray2D({{0, 2}, {1, 3}, {2, 999999999}, {3, -2147483647}, {4, 2147483647}, {5, 123456}}) QString str = LtsUtils::IntArray2D({{0, 2}, {1, 3}, {2, 999999999}, {3, -2147483647}, {4, 2147483647}, {5, 123456}}).toPgString();
.toPgString();
qDebug() << "LtsUtils: Result " << str; qDebug() << "LtsUtils: Result " << str;
QCOMPARE(str, QLatin1String("{{0,2},{1,3},{2,999999999},{3,-2147483647},{4,2147483647},{5,123456}}")); QCOMPARE(str, QLatin1String("{{0,2},{1,3},{2,999999999},{3,-2147483647},{4,2147483647},{5,123456}}"));
@@ -295,9 +298,7 @@ void LtsUtilsTest::test_fromBigintArray2D()
{ {
qDebug("LtsUtils: test_fromBigintArray2D"); qDebug("LtsUtils: test_fromBigintArray2D");
QString str = QString str = LtsUtils::BigintArray2D({{0, -123456789}, {1, -2147483647}, {2, 999999999999}, {3, 123456789}, {4, 2147483647}}).toPgString();
LtsUtils::BigintArray2D({{0, -123456789}, {1, -2147483647}, {2, 999999999999}, {3, 123456789}, {4, 2147483647}})
.toPgString();
qDebug() << "LtsUtils: Result " << str; qDebug() << "LtsUtils: Result " << str;
QCOMPARE(str, QLatin1String("{{0,-123456789},{1,-2147483647},{2,999999999999},{3,123456789},{4,2147483647}}")); QCOMPARE(str, QLatin1String("{{0,-123456789},{1,-2147483647},{2,999999999999},{3,123456789},{4,2147483647}}"));
@@ -336,14 +337,10 @@ void LtsUtilsTest::test_bitArray()
qDebug("LtsUtils: test_bitArray"); qDebug("LtsUtils: test_bitArray");
{ {
QVERIFY2(LtsUtils::BitArray::convert<std::vector<uint8_t>>(QBitArray(8)).size() == 1, QVERIFY2(LtsUtils::BitArray::convert<std::vector<uint8_t>>(QBitArray(8)).size() == 1, " wrong size of underlying data");
" wrong size of underlying data"); QVERIFY2(LtsUtils::BitArray::convert<std::vector<uint8_t>>(QBitArray(9)).size() == 2, " wrong size of underlying data");
QVERIFY2(LtsUtils::BitArray::convert<std::vector<uint8_t>>(QBitArray(9)).size() == 2, QVERIFY2(LtsUtils::BitArray::convert<std::vector<uint8_t>>(QBitArray(16)).size() == 2, " wrong size of underlying data");
" wrong size of underlying data"); QVERIFY2(LtsUtils::BitArray::convert<std::vector<uint8_t>>(QBitArray(17)).size() == 3, " wrong size of underlying data");
QVERIFY2(LtsUtils::BitArray::convert<std::vector<uint8_t>>(QBitArray(16)).size() == 2,
" wrong size of underlying data");
QVERIFY2(LtsUtils::BitArray::convert<std::vector<uint8_t>>(QBitArray(17)).size() == 3,
" wrong size of underlying data");
} }
{ {
@@ -513,10 +510,7 @@ class Spy : public QObject
public slots: public slots:
void slot1() void slot1() { ++m_slot1Count; }
{
++m_slot1Count;
}
public: public:
int m_slot1Count{0}; int m_slot1Count{0};
@@ -526,8 +520,7 @@ void LtsUtilsTest::test_connection()
{ {
Emitter emitter; Emitter emitter;
Spy spy; Spy spy;
std::unique_ptr<LtsUtils::IConnection> conn( std::unique_ptr<LtsUtils::IConnection> conn(LtsUtils::createConnection(&emitter, &Emitter::signal1, &spy, &Spy::slot1));
LtsUtils::createConnection(&emitter, &Emitter::signal1, &spy, &Spy::slot1));
emit emitter.signal1(); emit emitter.signal1();
QCOMPARE(spy.m_slot1Count, 0); QCOMPARE(spy.m_slot1Count, 0);
@@ -544,8 +537,7 @@ void LtsUtilsTest::test_queuedConnection()
{ {
Emitter emitter; Emitter emitter;
Spy spy; Spy spy;
std::unique_ptr<LtsUtils::IConnection> conn( std::unique_ptr<LtsUtils::IConnection> conn(LtsUtils::createConnection(&emitter, &Emitter::signal2, &spy, &Spy::slot1));
LtsUtils::createConnection(&emitter, &Emitter::signal2, &spy, &Spy::slot1));
emit emitter.signal2(42); emit emitter.signal2(42);
QCOMPARE(spy.m_slot1Count, 0); QCOMPARE(spy.m_slot1Count, 0);
@@ -560,10 +552,8 @@ void LtsUtilsTest::test_signalSignalConnection()
{ {
Emitter emitter; Emitter emitter;
Spy spy; Spy spy;
std::unique_ptr<LtsUtils::IConnection> signalSignalConn( std::unique_ptr<LtsUtils::IConnection> signalSignalConn(LtsUtils::createConnection(&emitter, &Emitter::signal2, &emitter, &Emitter::signal1));
LtsUtils::createConnection(&emitter, &Emitter::signal2, &emitter, &Emitter::signal1)); std::unique_ptr<LtsUtils::IConnection> signalSlotConn(LtsUtils::createConnection(&emitter, &Emitter::signal1, &spy, &Spy::slot1));
std::unique_ptr<LtsUtils::IConnection> signalSlotConn(
LtsUtils::createConnection(&emitter, &Emitter::signal1, &spy, &Spy::slot1));
signalSignalConn->connect(); signalSignalConn->connect();
signalSlotConn->connect(); signalSlotConn->connect();
@@ -963,10 +953,8 @@ void LtsUtilsTest::test_byteStreamFromSfmMessage()
const quint8 payloadArray[] = {0x11, 0x02, 0x03, 0x04, 0x50}; const quint8 payloadArray[] = {0x11, 0x02, 0x03, 0x04, 0x50};
msg.setPayload(QByteArray(reinterpret_cast<const char *>(payloadArray), sizeof(payloadArray))); msg.setPayload(QByteArray(reinterpret_cast<const char *>(payloadArray), sizeof(payloadArray)));
const quint8 expectedResultArray[] = {0x02, 0x80, 0x00, 0x10, 0x05, 0x80, 0x91, 0x80, const quint8 expectedResultArray[] = {0x02, 0x80, 0x00, 0x10, 0x05, 0x80, 0x91, 0x80, 0x82, 0x80, 0x83, 0x04, 0x50, 0x00, 0x03};
0x82, 0x80, 0x83, 0x04, 0x50, 0x00, 0x03}; QByteArray expectedResult = QByteArray(reinterpret_cast<const char *>(expectedResultArray), sizeof(expectedResultArray));
QByteArray expectedResult =
QByteArray(reinterpret_cast<const char*>(expectedResultArray), sizeof(expectedResultArray));
QByteArray byteMessage = byteStreamFromSfmMessage(msg); QByteArray byteMessage = byteStreamFromSfmMessage(msg);
@@ -990,8 +978,7 @@ void LtsUtilsTest::test_byteStreamToSfmMessage()
const quint8 payloadArray[] = {0x11, 0x02, 0x03, 0x04, 0x50, 0x00}; const quint8 payloadArray[] = {0x11, 0x02, 0x03, 0x04, 0x50, 0x00};
msgComplete.setPayload(QByteArray(reinterpret_cast<const char *>(payloadArray), sizeof(payloadArray))); msgComplete.setPayload(QByteArray(reinterpret_cast<const char *>(payloadArray), sizeof(payloadArray)));
const quint8 dataArray[] = {0x02, 0x80, 0x00, 0x10, 0x06, 0x80, 0x91, 0x80, const quint8 dataArray[] = {0x02, 0x80, 0x00, 0x10, 0x06, 0x80, 0x91, 0x80, 0x82, 0x80, 0x83, 0x04, 0x50, 0x00, 0xFF, 0x03};
0x82, 0x80, 0x83, 0x04, 0x50, 0x00, 0xFF, 0x03};
QByteArray dataComplete = QByteArray(reinterpret_cast<const char *>(dataArray), sizeof(dataArray)); QByteArray dataComplete = QByteArray(reinterpret_cast<const char *>(dataArray), sizeof(dataArray));
SfmMessage result; SfmMessage result;
@@ -1,16 +1,5 @@
#pragma once #pragma once
/**
* @RDE_HEADER@
* Function which waits (QEventLoop) for a success signal or a cancelation signal, optionally with a timeout
* Useful for blocking on async things
* $Id: connection.h 45834 2019-03-01 12:56:15Z ehrlicher $
* $HeadURL: svn://192.168.133.21/TDS/branches/product/features/swp_2023_devel/Lts/Common/LtsUtils/LtsUtilsCore/connection.h $
* $Author: ehrlicher $
*
* Created by Mike Wille, ESZS, 2024-03-03
*/
#include <QEventLoop> #include <QEventLoop>
#include <QtCore/QObject> #include <QtCore/QObject>
#include <QtCore/QTimer> #include <QtCore/QTimer>
@@ -18,9 +7,7 @@
namespace LtsUtils namespace LtsUtils
{ {
template <typename Func> template <typename Func> void addConnect(QEventLoop &x, bool &success, const typename QtPrivate::FunctionPointer<Func>::Object *sender, Func signal, bool isSuccess)
void addConnect(QEventLoop& x, bool& success, const typename QtPrivate::FunctionPointer<Func>::Object* sender,
Func signal, bool isSuccess)
{ {
if (isSuccess) if (isSuccess)
{ {
@@ -31,8 +18,7 @@ void addConnect(QEventLoop& x, bool& success, const typename QtPrivate::Function
} }
template <typename Func, typename... Connect> template <typename Func, typename... Connect>
void addConnect(QEventLoop& x, bool& success, const typename QtPrivate::FunctionPointer<Func>::Object* sender, void addConnect(QEventLoop &x, bool &success, const typename QtPrivate::FunctionPointer<Func>::Object *sender, Func signal, bool isSuccess, Connect... connects)
Func signal, bool isSuccess, Connect... connects)
{ {
addConnect(x, success, sender, signal, isSuccess); addConnect(x, success, sender, signal, isSuccess);
addConnect(x, success, connects...); addConnect(x, success, connects...);
@@ -63,7 +49,11 @@ template <typename... Connect> void awaitTimeout(const int timeoutMs, Connect...
{ {
t->setInterval(timeoutMs); t->setInterval(timeoutMs);
t->setSingleShot(true); t->setSingleShot(true);
QObject::connect(t.get(), &QTimer::timeout, t.get(), [&timeout]() { QObject::connect(t.get(),
&QTimer::timeout,
t.get(),
[&timeout]()
{
fprintf(stderr, "awaitTimeout: timed out!\n"); fprintf(stderr, "awaitTimeout: timed out!\n");
timeout = true; timeout = true;
}); });
@@ -80,8 +70,10 @@ template <typename... Connect> void awaitTimeout(const int timeoutMs, Connect...
} }
template <typename Func1, typename Func2> template <typename Func1, typename Func2>
void awaitWithCancelationSignal(const typename QtPrivate::FunctionPointer<Func1>::Object* sender1, Func1 signal1, void awaitWithCancelationSignal(const typename QtPrivate::FunctionPointer<Func1>::Object *sender1,
const typename QtPrivate::FunctionPointer<Func2>::Object* sender2, Func2 signal2, Func1 signal1,
const typename QtPrivate::FunctionPointer<Func2>::Object *sender2,
Func2 signal2,
const int timeoutMs = 0) noexcept(false) const int timeoutMs = 0) noexcept(false)
{ {
if (timeoutMs > 0) if (timeoutMs > 0)
@@ -1,11 +1,4 @@
/**
* @RDE_HEADER@
* General Qt-connection
* $Id$
* $HeadURL$
* $Author$
* Created by Christian Fröbel, SLSE, 2017-07-24
*/
#pragma once #pragma once
@@ -59,7 +52,10 @@ template <class Signal, class Slot> class Connection : public IConnection
public: public:
Connection(Emitter *emitter, Signal signal, Target *target, Slot slot) Connection(Emitter *emitter, Signal signal, Target *target, Slot slot)
: m_emitter(emitter), m_signal(signal), m_target(target), m_slot(slot) : m_emitter(emitter)
, m_signal(signal)
, m_target(target)
, m_slot(slot)
{ {
Q_ASSERT(emitter); Q_ASSERT(emitter);
Q_ASSERT(signal); Q_ASSERT(signal);
@@ -100,8 +96,10 @@ template <class Signal, class Slot> class Connection : public IConnection
}; };
template <class Signal, class Slot> template <class Signal, class Slot>
Connection<Signal, Slot>* createConnection(typename detail::ExtractClass<Signal>::type* emitter, Signal signal, Connection<Signal, Slot> *createConnection(typename detail::ExtractClass<Signal>::type *emitter,
typename detail::ExtractClass<Slot>::type* target, Slot slot) Signal signal,
typename detail::ExtractClass<Slot>::type *target,
Slot slot)
{ {
return new Connection<Signal, Slot>(emitter, signal, target, slot); return new Connection<Signal, Slot>(emitter, signal, target, slot);
} }
@@ -4,7 +4,12 @@
#include <ostream> #include <ostream>
enum class DataModification { eAdded, eModified, eRemoved }; enum class DataModification
{
eAdded,
eModified,
eRemoved
};
inline std::ostream &operator<<(std::ostream &str, DataModification mod) inline std::ostream &operator<<(std::ostream &str, DataModification mod)
{ {
@@ -1,11 +1,4 @@
/**
* @RDE_HEADER@
* JsonObject
* $Id$
* $HeadURL$
* $Author$
* Created by Christian Fröbel, SLSE, 2017-10-26
*/
#pragma once #pragma once
@@ -32,8 +25,7 @@ class JsonParseError : public std::runtime_error
{ {
public: public:
JsonParseError(const QJsonParseError &err) JsonParseError(const QJsonParseError &err)
: std::runtime_error("json parse error: " + err.errorString().toStdString() + " - at offset " + : std::runtime_error("json parse error: " + err.errorString().toStdString() + " - at offset " + std::to_string(err.offset))
std::to_string(err.offset))
{ {
} }
}; };
@@ -69,50 +61,37 @@ class JsonObject
JsonObject() = default; JsonObject() = default;
explicit JsonObject(const QJsonObject& json) : m_json(json), m_jsonIsSet(true) {} explicit JsonObject(const QJsonObject &json)
: m_json(json)
, m_jsonIsSet(true)
{
}
explicit JsonObject(QJsonObject&& json) : m_json(std::move(json)), m_jsonIsSet(true) {} explicit JsonObject(QJsonObject &&json)
: m_json(std::move(json))
, m_jsonIsSet(true)
{
}
static inline JsonObject fromJson(const char *json, int len = -1); static inline JsonObject fromJson(const char *json, int len = -1);
static inline JsonObject fromJson(const QByteArray& json) static inline JsonObject fromJson(const QByteArray &json) { return fromJson(json.data(), json.size()); }
{
return fromJson(json.data(), json.size());
}
static inline JsonObject fromJson(const std::string& json) static inline JsonObject fromJson(const std::string &json) { return fromJson(json.c_str(), json.size()); }
{
return fromJson(json.c_str(), json.size());
}
static inline JsonObject fromJsonSafe(const char *json, int len = -1) noexcept(false); static inline JsonObject fromJsonSafe(const char *json, int len = -1) noexcept(false);
static inline JsonObject fromJsonSafe(const QByteArray& json) noexcept(false) static inline JsonObject fromJsonSafe(const QByteArray &json) noexcept(false) { return fromJsonSafe(json.data(), json.size()); }
{
return fromJsonSafe(json.data(), json.size());
}
static inline JsonObject fromJsonSafe(const std::string& json) noexcept(false) static inline JsonObject fromJsonSafe(const std::string &json) noexcept(false) { return fromJsonSafe(json.c_str(), json.size()); }
{
return fromJsonSafe(json.c_str(), json.size());
}
template <class T> [[nodiscard]] bool contains(const Key &key) const; template <class T> [[nodiscard]] bool contains(const Key &key) const;
[[nodiscard]] bool isNull(const Key& key) const [[nodiscard]] bool isNull(const Key &key) const { return contains<void>(key); }
{
return contains<void>(key);
}
[[nodiscard]] bool isEmpty() const [[nodiscard]] bool isEmpty() const { return m_json.isEmpty(); }
{
return m_json.isEmpty();
}
[[nodiscard]] bool isValid() const [[nodiscard]] bool isValid() const { return m_jsonIsSet; }
{
return m_jsonIsSet;
}
template <class T> T value(const Key &key) const noexcept(false); template <class T> T value(const Key &key) const noexcept(false);
@@ -124,49 +103,40 @@ class JsonObject
template <class T> std::map<std::string, T> toStdMap() const; template <class T> std::map<std::string, T> toStdMap() const;
bool operator==(const JsonObject& other) const bool operator==(const JsonObject &other) const { return m_json == other.m_json; }
{
return m_json == other.m_json;
}
bool operator!=(const JsonObject& other) const bool operator!=(const JsonObject &other) const { return !(*this == other); }
{
return !(*this == other);
}
class Key class Key
{ {
public: public:
Key(QString s) : m_s(std::move(s)) {} Key(QString s)
: m_s(std::move(s))
Key(const std::string& s) : m_s(QString::fromStdString(s)) {}
Key(const char* s) : m_s(QString::fromUtf8(s)) {}
operator const QString&() const
{ {
return m_s;
} }
Key(const std::string &s)
: m_s(QString::fromStdString(s))
{
}
Key(const char *s)
: m_s(QString::fromUtf8(s))
{
}
operator const QString &() const { return m_s; }
private: private:
const QString m_s; const QString m_s;
}; };
operator const QJsonObject&() const operator const QJsonObject &() const { return m_json; }
{
return m_json;
}
[[nodiscard]] const QJsonObject& object() const [[nodiscard]] const QJsonObject &object() const { return m_json; }
{
return m_json;
}
private: private:
[[nodiscard]] bool containsAny(const QString& key) const [[nodiscard]] bool containsAny(const QString &key) const { return m_json.contains(key); }
{
return m_json.contains(key);
}
QJsonObject m_json; QJsonObject m_json;
bool m_jsonIsSet = false; bool m_jsonIsSet = false;
@@ -207,55 +177,39 @@ class JsonArray
public: public:
JsonArray() = default; JsonArray() = default;
explicit JsonArray(const QJsonArray& json) : m_json(json), m_jsonIsSet(true) {} explicit JsonArray(const QJsonArray &json)
: m_json(json)
, m_jsonIsSet(true)
{
}
explicit JsonArray(QJsonArray&& json) : m_json(std::move(json)), m_jsonIsSet(true) {} explicit JsonArray(QJsonArray &&json)
: m_json(std::move(json))
, m_jsonIsSet(true)
{
}
static inline JsonArray fromJson(const char *json, int len = -1); static inline JsonArray fromJson(const char *json, int len = -1);
static inline JsonArray fromJson(const QByteArray& json) static inline JsonArray fromJson(const QByteArray &json) { return fromJson(json.data(), json.size()); }
{
return fromJson(json.data(), json.size());
}
static inline JsonArray fromJson(const std::string& json) static inline JsonArray fromJson(const std::string &json) { return fromJson(json.c_str(), json.size()); }
{
return fromJson(json.c_str(), json.size());
}
static inline JsonArray fromJsonSafe(const char *json, int len = -1) noexcept(false); static inline JsonArray fromJsonSafe(const char *json, int len = -1) noexcept(false);
static inline JsonArray fromJsonSafe(const QByteArray& json) noexcept(false) static inline JsonArray fromJsonSafe(const QByteArray &json) noexcept(false) { return fromJson(json.data(), json.size()); }
{
return fromJson(json.data(), json.size());
}
static inline JsonArray fromJsonSafe(const std::string& json) noexcept(false) static inline JsonArray fromJsonSafe(const std::string &json) noexcept(false) { return fromJson(json.c_str(), json.size()); }
{
return fromJson(json.c_str(), json.size());
}
[[nodiscard]] int size() const [[nodiscard]] int size() const { return m_json.size(); }
{
return m_json.size();
}
[[nodiscard]] bool isEmpty() const [[nodiscard]] bool isEmpty() const { return m_json.isEmpty(); }
{
return m_json.isEmpty();
}
[[nodiscard]] bool isValid() const [[nodiscard]] bool isValid() const { return m_jsonIsSet; }
{
return m_jsonIsSet;
}
template <class T> [[nodiscard]] bool contains(int index) const noexcept(false); template <class T> [[nodiscard]] bool contains(int index) const noexcept(false);
[[nodiscard]] bool isNull(int index) const noexcept(false) [[nodiscard]] bool isNull(int index) const noexcept(false) { return contains<void>(index); }
{
return contains<void>(index);
}
template <class T> T at(int index) const noexcept(false); template <class T> T at(int index) const noexcept(false);
@@ -265,20 +219,11 @@ class JsonArray
template <class T> std::vector<T> toStdVector() const; template <class T> std::vector<T> toStdVector() const;
bool operator==(const JsonArray& other) const bool operator==(const JsonArray &other) const { return m_json == other.m_json; }
{
return m_json == other.m_json;
}
bool operator!=(const JsonArray& other) const bool operator!=(const JsonArray &other) const { return !(*this == other); }
{
return !(*this == other);
}
const QJsonArray& operator()() const const QJsonArray &operator()() const { return m_json; }
{
return m_json;
}
private: private:
QJsonArray m_json; QJsonArray m_json;
@@ -319,41 +264,23 @@ template <class T> struct JsonValue;
template <class Int> struct JsonLimits template <class Int> struct JsonLimits
{ {
static constexpr Int lowest() static constexpr Int lowest() { return std::numeric_limits<Int>::lowest(); }
{
return std::numeric_limits<Int>::lowest();
}
static constexpr Int max() static constexpr Int max() { return std::numeric_limits<Int>::max(); }
{
return std::numeric_limits<Int>::max();
}
}; };
template <> struct JsonLimits<int64_t> template <> struct JsonLimits<int64_t>
{ {
static constexpr int64_t lowest() static constexpr int64_t lowest() { return -(static_cast<int64_t>(1) << 53) + 1; }
{
return -(static_cast<int64_t>(1) << 53) + 1;
}
static constexpr int64_t max() static constexpr int64_t max() { return (static_cast<int64_t>(1) << 53) - 1; }
{
return (static_cast<int64_t>(1) << 53) - 1;
}
}; };
template <> struct JsonLimits<uint64_t> template <> struct JsonLimits<uint64_t>
{ {
static constexpr uint64_t lowest() static constexpr uint64_t lowest() { return 0; }
{
return 0;
}
static constexpr uint64_t max() static constexpr uint64_t max() { return JsonLimits<int64_t>::max(); }
{
return JsonLimits<int64_t>::max();
}
}; };
template <class Int> struct JsonIntValue template <class Int> struct JsonIntValue
@@ -407,10 +334,7 @@ template <> struct JsonValue<uint64_t> : JsonIntValue<uint64_t>
template <> struct JsonValue<double> template <> struct JsonValue<double>
{ {
static bool matchesType(const QJsonValue& value) static bool matchesType(const QJsonValue &value) { return value.isDouble(); }
{
return value.isDouble();
}
static double value(const QJsonValue &value) noexcept(false) static double value(const QJsonValue &value) noexcept(false)
{ {
@@ -422,10 +346,7 @@ template <> struct JsonValue<double>
template <> struct JsonValue<bool> template <> struct JsonValue<bool>
{ {
static bool matchesType(const QJsonValue& value) static bool matchesType(const QJsonValue &value) { return value.isBool(); }
{
return value.isBool();
}
static bool value(const QJsonValue &value) noexcept(false) static bool value(const QJsonValue &value) noexcept(false)
{ {
@@ -437,10 +358,7 @@ template <> struct JsonValue<bool>
template <> struct JsonValue<QString> template <> struct JsonValue<QString>
{ {
static bool matchesType(const QJsonValue& value) static bool matchesType(const QJsonValue &value) { return value.isString(); }
{
return value.isString();
}
static QString value(const QJsonValue &value) noexcept(false) static QString value(const QJsonValue &value) noexcept(false)
{ {
@@ -452,23 +370,14 @@ template <> struct JsonValue<QString>
template <> struct JsonValue<std::string> template <> struct JsonValue<std::string>
{ {
static bool matchesType(const QJsonValue& value) static bool matchesType(const QJsonValue &value) { return value.isString(); }
{
return value.isString();
}
static std::string value(const QJsonValue& value) static std::string value(const QJsonValue &value) { return JsonValue<QString>::value(value).toStdString(); }
{
return JsonValue<QString>::value(value).toStdString();
}
}; };
template <> struct JsonValue<QJsonObject> template <> struct JsonValue<QJsonObject>
{ {
static bool matchesType(const QJsonValue& value) static bool matchesType(const QJsonValue &value) { return value.isObject(); }
{
return value.isObject();
}
static QJsonObject value(const QJsonValue &value) noexcept(false) static QJsonObject value(const QJsonValue &value) noexcept(false)
{ {
@@ -480,31 +389,19 @@ template <> struct JsonValue<QJsonObject>
template <> struct JsonValue<JsonObject> template <> struct JsonValue<JsonObject>
{ {
static bool matchesType(const QJsonValue& value) static bool matchesType(const QJsonValue &value) { return value.isObject(); }
{
return value.isObject();
}
static JsonObject value(const QJsonValue& value) static JsonObject value(const QJsonValue &value) { return JsonObject(JsonValue<QJsonObject>::value(value)); }
{
return JsonObject(JsonValue<QJsonObject>::value(value));
}
}; };
template <> struct JsonValue<void> template <> struct JsonValue<void>
{ {
static bool matchesType(const QJsonValue& value) static bool matchesType(const QJsonValue &value) { return value.isNull(); }
{
return value.isNull();
}
}; };
template <> struct JsonValue<QJsonArray> template <> struct JsonValue<QJsonArray>
{ {
static bool matchesType(const QJsonValue& value) static bool matchesType(const QJsonValue &value) { return value.isArray(); }
{
return value.isArray();
}
static QJsonArray value(const QJsonValue &value) noexcept(false) static QJsonArray value(const QJsonValue &value) noexcept(false)
{ {
@@ -516,15 +413,9 @@ template <> struct JsonValue<QJsonArray>
template <> struct JsonValue<JsonArray> template <> struct JsonValue<JsonArray>
{ {
static bool matchesType(const QJsonValue& value) static bool matchesType(const QJsonValue &value) { return value.isArray(); }
{
return value.isArray();
}
static JsonArray value(const QJsonValue& value) static JsonArray value(const QJsonValue &value) { return JsonArray(JsonValue<QJsonArray>::value(value)); }
{
return JsonArray(JsonValue<QJsonArray>::value(value));
}
}; };
template <class T> struct JsonValue<QVector<T>> template <class T> struct JsonValue<QVector<T>>
@@ -547,10 +438,7 @@ template <class T> struct JsonValue<QVector<T>>
template <class T> struct JsonValue<std::vector<T>> template <class T> struct JsonValue<std::vector<T>>
{ {
static bool matchesType(const QJsonValue& value) static bool matchesType(const QJsonValue &value) { return JsonValue<QVector<T>>::matchesType(value); }
{
return JsonValue<QVector<T>>::matchesType(value);
}
static std::vector<T> value(const QJsonValue &value) static std::vector<T> value(const QJsonValue &value)
{ {
@@ -579,10 +467,7 @@ template <class T> struct JsonValue<QMap<QString, T>>
template <class T> struct JsonValue<std::map<std::string, T>> template <class T> struct JsonValue<std::map<std::string, T>>
{ {
static bool matchesType(const QJsonValue& value) static bool matchesType(const QJsonValue &value) { return JsonValue<QMap<QString, T>>::matchesType(value); }
{
return JsonValue<QMap<QString, T>>::matchesType(value);
}
static std::map<std::string, T> value(const QJsonValue &value) static std::map<std::string, T> value(const QJsonValue &value)
{ {
@@ -608,8 +493,7 @@ template <class T> T JsonObject::value(const Key& key) const noexcept(false)
} }
catch (const JsonTypeError &typeError) catch (const JsonTypeError &typeError)
{ {
throw JsonTypeError(std::string(typeError.what()) + throw JsonTypeError(std::string(typeError.what()) + " - key: " + static_cast<const QString &>(key).toStdString());
" - key: " + static_cast<const QString&>(key).toStdString());
} }
} }
@@ -1,16 +1,4 @@
/**
* @RDE_HEADER@
* A class that contains an identifier string and a dynmically translatable string. Useful for e.g. translating menu groups.
* Menu groups can be shared between plugins and multiple actions and are distinguished by the menu group identifier.
* Menu groups also need to be translatable as the Ui puts actions into group boxes, distinguished by a menu group.
* Menu groups are also used outside of the current Q_OBJECT context, so calling tr(..) would not work. translatedText(..)
* fixes this problem.
* $Id: $
* $HeadURL: $
* $Author: $
*
* Created by Mike Lennart Wille, SLTE, 2022-06-22
*/
#include "lts_translatable_identifier.h" #include "lts_translatable_identifier.h"
@@ -18,10 +6,10 @@
namespace LtsUtils namespace LtsUtils
{ {
LtsTranslatableIdentifier::LtsTranslatableIdentifier(const QString& identifier, const QObject* context, LtsTranslatableIdentifier::LtsTranslatableIdentifier(const QString &identifier, const QObject *context, const char *translatableText)
const char* translatableText) : m_identifier(identifier)
: m_identifier(identifier), m_translationContext(context->metaObject()->className()), , m_translationContext(context->metaObject()->className())
m_translatableText(translatableText) , m_translatableText(translatableText)
{ {
} }
@@ -1,19 +1,5 @@
#pragma once #pragma once
/**
* @RDE_HEADER@
* A class that contains an identifier string and a dynmically translatable string. Useful for e.g. translating menu groups.
* Menu groups can be shared between plugins and multiple actions and are distinguished by the menu group identifier.
* Menu groups also need to be translatable as the Ui puts actions into group boxes, distinguished by a menu group.
* Menu groups are also used outside of the current Q_OBJECT context, so calling tr(..) would not work. translatedText(..)
* fixes this problem.
* $Id: $
* $HeadURL: $
* $Author: $
*
* Created by Mike Lennart Wille, SLTE, 2022-06-22
*/
#include "ltsutilscore_export.h" #include "ltsutilscore_export.h"
#include <QtCore/QObject> #include <QtCore/QObject>
@@ -24,21 +10,19 @@ namespace LtsUtils
class LTSUTILSCORE_EXPORT LtsTranslatableIdentifier class LTSUTILSCORE_EXPORT LtsTranslatableIdentifier
{ {
public: public:
LtsTranslatableIdentifier() : m_translationContext(nullptr), m_translatableText("") {} LtsTranslatableIdentifier()
: m_translationContext(nullptr)
, m_translatableText("")
{
}
LtsTranslatableIdentifier(const QString &identifier, const QObject *context, const char *translatableText); LtsTranslatableIdentifier(const QString &identifier, const QObject *context, const char *translatableText);
const QString& identifier() const const QString &identifier() const { return m_identifier; }
{
return m_identifier;
}
const QString translatedText(const char *disambiguation = nullptr, int n = -1) const; const QString translatedText(const char *disambiguation = nullptr, int n = -1) const;
const QString _context() const const QString _context() const { return QString::fromUtf8(m_translationContext); }
{
return QString::fromUtf8(m_translationContext);
}
private: private:
QString m_identifier; QString m_identifier;
@@ -33,9 +33,7 @@ template <> LTSUTILSCORE_EXPORT QString BigintArray::toPgString() const
return convertToPgString(m_data); return convertToPgString(m_data);
} }
template <typename T> template <typename T> static inline T convertFromPgString(const QString &str, const std::function<typename T::Type(QStringView val, bool *bOk)> &convertFunc)
static inline T convertFromPgString(const QString& str,
const std::function<typename T::Type(QStringView val, bool* bOk)>& convertFunc)
{ {
typename T::ContainerType result; typename T::ContainerType result;
@@ -71,8 +69,7 @@ template <> LTSUTILSCORE_EXPORT IntArray IntArray::fromPgString(const QString& s
template <> LTSUTILSCORE_EXPORT BigintArray BigintArray::fromPgString(const QString &str) template <> LTSUTILSCORE_EXPORT BigintArray BigintArray::fromPgString(const QString &str)
{ {
return convertFromPgString<BigintArray>(str, return convertFromPgString<BigintArray>(str, [](QStringView val, bool *bOk) { return val.toString().toLongLong(bOk); });
[](QStringView val, bool* bOk) { return val.toString().toLongLong(bOk); });
} }
template <typename T> static inline QString convertToPgString(const std::map<T, T> &data) template <typename T> static inline QString convertToPgString(const std::map<T, T> &data)
@@ -82,8 +79,7 @@ template <typename T> static inline QString convertToPgString(const std::map<T,
QString ret(QLatin1Char('{')); QString ret(QLatin1Char('{'));
for (const auto &it : data) for (const auto &it : data)
{ {
ret += QLatin1Char('{') + QString::number(it.first) + QLatin1Char(',') + QString::number(it.second) + ret += QLatin1Char('{') + QString::number(it.first) + QLatin1Char(',') + QString::number(it.second) + QLatin1String("},");
QLatin1String("},");
} }
ret.chop(1); ret.chop(1);
ret += QLatin1Char('}'); ret += QLatin1Char('}');
@@ -100,9 +96,7 @@ template <> LTSUTILSCORE_EXPORT QString BigintArray2D::toPgString() const
return convertToPgString<BigintArray2D::Type>(m_data); return convertToPgString<BigintArray2D::Type>(m_data);
} }
template <typename T> template <typename T> static inline T convertFromPgString2D(const QString &str, const std::function<typename T::Type(QStringView val)> &convertFunc)
static inline T convertFromPgString2D(const QString& str,
const std::function<typename T::Type(QStringView val)>& convertFunc)
{ {
typename T::ContainerType ret; typename T::ContainerType ret;
int idxStart = str.indexOf(QLatin1Char('{')); int idxStart = str.indexOf(QLatin1Char('{'));
@@ -17,13 +17,13 @@ template <typename T, typename C> class PgArray
PgArray() = default; PgArray() = default;
Q_DECL_CONSTEXPR explicit PgArray(const C& data) : m_data(data) {} Q_DECL_CONSTEXPR explicit PgArray(const C &data)
: m_data(data)
Q_DECL_CONSTEXPR C operator()() const
{ {
return m_data;
} }
Q_DECL_CONSTEXPR C operator()() const { return m_data; }
[[nodiscard]] QString toPgString() const; [[nodiscard]] QString toPgString() const;
static PgArray fromPgString(const QString &str); static PgArray fromPgString(const QString &str);
@@ -8,7 +8,11 @@ namespace LtsUtils
{ {
Promise::Promise(const std::function<void(ResultFunction resolve, ResultFunction reject)> &function, QObject *parent) Promise::Promise(const std::function<void(ResultFunction resolve, ResultFunction reject)> &function, QObject *parent)
: QObject(parent), m_functionAlreadySet(false), m_timeout(new QTimer(this)), m_resultSet(false), m_timeoutSet(false) : QObject(parent)
, m_functionAlreadySet(false)
, m_timeout(new QTimer(this))
, m_resultSet(false)
, m_timeoutSet(false)
{ {
m_timeout->setSingleShot(true); m_timeout->setSingleShot(true);
connect(m_timeout, &QTimer::timeout, this, &Promise::slotTimeout); connect(m_timeout, &QTimer::timeout, this, &Promise::slotTimeout);
@@ -25,9 +29,7 @@ void Promise::setFunction(const std::function<void(ResultFunction resolve, Resul
if (m_timeoutSet) if (m_timeoutSet)
m_timeout->start(); m_timeout->start();
QTimer::singleShot(0, this, [this, function]() { QTimer::singleShot(0, this, [this, function]() { function([this](const QVariant &value) { resolve(value); }, [this](const QVariant &value) { reject(value); }); });
function([this](const QVariant& value) { resolve(value); }, [this](const QVariant& value) { reject(value); });
});
} }
void Promise::setTimeout(int interval) void Promise::setTimeout(int interval)
@@ -18,8 +18,7 @@ class LTSUTILSCORE_EXPORT Promise : public QObject
Q_OBJECT Q_OBJECT
public: public:
Promise(const std::function<void(ResultFunction resolve, ResultFunction reject)>& function, Promise(const std::function<void(ResultFunction resolve, ResultFunction reject)> &function, QObject *parent = nullptr);
QObject* parent = nullptr);
void setFunction(const std::function<void(ResultFunction resolve, ResultFunction reject)> &function); void setFunction(const std::function<void(ResultFunction resolve, ResultFunction reject)> &function);
@@ -19,13 +19,20 @@ void PromiseExample1_Class::doSomethingAsync2()
QTimer::singleShot(450, this, [this]() { emit signalDone2(true, 1234); }); QTimer::singleShot(450, this, [this]() { emit signalDone2(true, 1234); });
} }
PromiseExample1::PromiseExample1(QObject* parent) : QObject(parent), m_success(false) PromiseExample1::PromiseExample1(QObject *parent)
: QObject(parent)
, m_success(false)
{ {
auto func = [this](ResultFunction resolve, ResultFunction reject) { auto func = [this](ResultFunction resolve, ResultFunction reject)
{
PromiseExample1_Class *c = new PromiseExample1_Class(this); PromiseExample1_Class *c = new PromiseExample1_Class(this);
connect(c, &PromiseExample1_Class::signalDone1, this, [this, c, resolve, reject](bool didThisWork) { connect(c,
&PromiseExample1_Class::signalDone1,
this,
[this, c, resolve, reject](bool didThisWork)
{
if (!didThisWork) if (!didThisWork)
{ {
@@ -35,8 +42,11 @@ PromiseExample1::PromiseExample1(QObject* parent) : QObject(parent), m_success(f
else else
{ {
connect(c, &PromiseExample1_Class::signalDone2, this, connect(c,
[resolve, reject](bool didThisWork, int someNumberThatReturns) { &PromiseExample1_Class::signalDone2,
this,
[resolve, reject](bool didThisWork, int someNumberThatReturns)
{
if (didThisWork) if (didThisWork)
resolve(someNumberThatReturns); resolve(someNumberThatReturns);
else else
@@ -51,14 +61,19 @@ PromiseExample1::PromiseExample1(QObject* parent) : QObject(parent), m_success(f
}; };
Promise *p = new Promise(func, this); Promise *p = new Promise(func, this);
p->resolved([this](const QVariant& value) { p->resolved(
[this](const QVariant &value)
{
qDebug() << "example1 promise succeeded! 'someNumberThatReturns' was" << value; qDebug() << "example1 promise succeeded! 'someNumberThatReturns' was" << value;
m_success = true; m_success = true;
}).rejected([](const QVariant& value) { qDebug() << "example1 promise failed.." << value; }); })
.rejected([](const QVariant &value) { qDebug() << "example1 promise failed.." << value; });
} }
PromiseExample2::PromiseExample2(QObject* parent) : QObject(parent), m_success(false) PromiseExample2::PromiseExample2(QObject *parent)
: QObject(parent)
, m_success(false)
{ {
Promise* p = new Promise( Promise* p = new Promise(
@@ -71,14 +86,19 @@ PromiseExample2::PromiseExample2(QObject* parent) : QObject(parent), m_success(f
p->resolved([](const QVariant &) { QFAIL("This test case's promise should never resolve"); }); p->resolved([](const QVariant &) { QFAIL("This test case's promise should never resolve"); });
p->rejected([this](const QVariant& val) { p->rejected(
[this](const QVariant &val)
{
QVERIFY2(val == QStringLiteral("timeout"), "Promise didn't reject with string \"timeout\""); QVERIFY2(val == QStringLiteral("timeout"), "Promise didn't reject with string \"timeout\"");
qDebug() << "Promise rejected as expected"; qDebug() << "Promise rejected as expected";
m_success = true; m_success = true;
}); });
} }
PromiseExample3::PromiseExample3(QObject* parent) : QObject(parent), m_success(true), m_alreadyRejected(false) PromiseExample3::PromiseExample3(QObject *parent)
: QObject(parent)
, m_success(true)
, m_alreadyRejected(false)
{ {
Promise *p = new Promise([](ResultFunction, ResultFunction reject) { reject(QString()); }, this); Promise *p = new Promise([](ResultFunction, ResultFunction reject) { reject(QString()); }, this);
@@ -87,7 +107,9 @@ PromiseExample3::PromiseExample3(QObject* parent) : QObject(parent), m_success(t
p->resolved([](const QVariant &) { QFAIL("This test case's promise should never resolve"); }); p->resolved([](const QVariant &) { QFAIL("This test case's promise should never resolve"); });
p->rejected([this](const QVariant& val) { p->rejected(
[this](const QVariant &val)
{
qDebug() << "rejected with val" << val; qDebug() << "rejected with val" << val;
QVERIFY2(val == QString(), "Promise didn't reject with an expected empty string."); QVERIFY2(val == QString(), "Promise didn't reject with an expected empty string.");
QVERIFY2(!m_alreadyRejected, "Promise rejected more than once"); QVERIFY2(!m_alreadyRejected, "Promise rejected more than once");
@@ -25,10 +25,7 @@ class PromiseExample1 : public QObject
public: public:
explicit PromiseExample1(QObject *parent = nullptr); explicit PromiseExample1(QObject *parent = nullptr);
[[nodiscard]] bool isSuccess() const [[nodiscard]] bool isSuccess() const { return m_success; }
{
return m_success;
}
private: private:
bool m_success; bool m_success;
@@ -40,10 +37,7 @@ class PromiseExample2 : public QObject
public: public:
explicit PromiseExample2(QObject *parent = nullptr); explicit PromiseExample2(QObject *parent = nullptr);
[[nodiscard]] bool isSuccess() const [[nodiscard]] bool isSuccess() const { return m_success; }
{
return m_success;
}
private: private:
bool m_success; bool m_success;
@@ -55,10 +49,7 @@ class PromiseExample3 : public QObject
public: public:
explicit PromiseExample3(QObject *parent = nullptr); explicit PromiseExample3(QObject *parent = nullptr);
[[nodiscard]] bool isSuccess() const [[nodiscard]] bool isSuccess() const { return m_success; }
{
return m_success;
}
private: private:
bool m_success; bool m_success;
@@ -23,7 +23,8 @@ template <typename T> void inline set8Byte(const T in, QByteArray& out)
template <> void inline set8Byte(const double in, QByteArray &out) template <> void inline set8Byte(const double in, QByteArray &out)
{ {
union hack { union hack
{
double d; double d;
int64_t i; int64_t i;
} h; } h;
@@ -64,7 +65,8 @@ template <> bool inline get8Byte(const QByteArray& baData, size_t& pos, double&
{ {
out = 0.; out = 0.;
union hack { union hack
{
double d; double d;
int64_t i; int64_t i;
} h; } h;
@@ -6,7 +6,9 @@ namespace LtsUtils
{ {
QPlane3D::QPlane3D(const QPoint3D &pos, const QPoint3D &vec1, const QPoint3D &vec2) QPlane3D::QPlane3D(const QPoint3D &pos, const QPoint3D &vec1, const QPoint3D &vec2)
: m_pos(pos), m_vec1(vec1), m_vec2(vec2) : m_pos(pos)
, m_vec1(vec1)
, m_vec2(vec2)
{ {
m_normal = QPoint3D::crossProduct(m_vec1, m_vec2); m_normal = QPoint3D::crossProduct(m_vec1, m_vec2);
m_planeC = QPoint3D::dotProduct(m_pos, m_normal); m_planeC = QPoint3D::dotProduct(m_pos, m_normal);
@@ -44,7 +46,8 @@ double QPlane3D::distanceTo(const QPoint3D& point) const
} }
QPolygon3D::QPolygon3D(const QVector<QPoint3D> &vertices) QPolygon3D::QPolygon3D(const QVector<QPoint3D> &vertices)
: QPlane3D(vertices[0], vertices[1], vertices[2]), m_vertices(vertices) : QPlane3D(vertices[0], vertices[1], vertices[2])
, m_vertices(vertices)
{ {
} }
@@ -23,30 +23,15 @@ class LTSUTILSCORE_EXPORT QPlane3D
bool inPlane(const QPoint3D &point) const; bool inPlane(const QPoint3D &point) const;
double distanceTo(const QPoint3D &point) const; double distanceTo(const QPoint3D &point) const;
const QPoint3D& pos() const const QPoint3D &pos() const { return m_pos; }
{
return m_pos;
}
const QPoint3D& vec1() const const QPoint3D &vec1() const { return m_vec1; }
{
return m_vec1;
}
const QPoint3D& vec2() const const QPoint3D &vec2() const { return m_vec2; }
{
return m_vec2;
}
const QPoint3D& normal() const const QPoint3D &normal() const { return m_normal; }
{
return m_normal;
}
double planeC() const double planeC() const { return m_planeC; }
{
return m_planeC;
}
protected: protected:
QPoint3D m_pos; QPoint3D m_pos;
@@ -62,10 +47,7 @@ class LTSUTILSCORE_EXPORT QPolygon3D : public QPlane3D
public: public:
QPolygon3D(const QVector<QPoint3D> &vertices); QPolygon3D(const QVector<QPoint3D> &vertices);
bool contains(const QPoint3D& point) const bool contains(const QPoint3D &point) const { return m_vertices.contains(point); }
{
return m_vertices.contains(point);
}
bool containsPoint(const QPoint3D &point) const; bool containsPoint(const QPoint3D &point) const;
@@ -16,12 +16,21 @@ namespace LtsUtils
class QPoint3D class QPoint3D
{ {
public: public:
enum class Axis { X, Y, Z }; enum class Axis
{
X,
Y,
Z
};
constexpr QPoint3D() = default; constexpr QPoint3D() = default;
constexpr QPoint3D(double xpos, double ypos, double zpos); constexpr QPoint3D(double xpos, double ypos, double zpos);
template <typename T> explicit QPoint3D(const T& data) : xp(data.offsetX()), yp(data.offsetY()), zp(data.offsetZ()) template <typename T>
explicit QPoint3D(const T &data)
: xp(data.offsetX())
, yp(data.offsetY())
, zp(data.offsetZ())
{ {
} }
@@ -40,20 +49,11 @@ class QPoint3D
constexpr inline QPointF toPointF() const; constexpr inline QPointF toPointF() const;
static QPoint3D fromQPointF(const QPointF& p) static QPoint3D fromQPointF(const QPointF &p) { return QPoint3D(p.x(), p.y(), .0); }
{
return QPoint3D(p.x(), p.y(), .0);
}
inline double lengthSquared() const inline double lengthSquared() const { return (xp * xp) + (yp * yp) + (zp * zp); }
{
return (xp * xp) + (yp * yp) + (zp * zp);
}
inline double length() const inline double length() const { return std::sqrt(lengthSquared()); }
{
return std::sqrt(lengthSquared());
}
inline void normalize() inline void normalize()
{ {
@@ -85,21 +85,24 @@ class QPoint3D
const double cos = std::cos(phi); const double cos = std::cos(phi);
switch (axis) switch (axis)
{ {
case Axis::X: { case Axis::X:
{
const double _yp = (cos * yp) - (sin * zp); const double _yp = (cos * yp) - (sin * zp);
const double _zp = (sin * yp) + (cos * zp); const double _zp = (sin * yp) + (cos * zp);
yp = _yp; yp = _yp;
zp = _zp; zp = _zp;
break; break;
} }
case Axis::Y: { case Axis::Y:
{
const double _xp = (cos * xp) + (sin * zp); const double _xp = (cos * xp) + (sin * zp);
const double _zp = (-sin * xp) + (cos * zp); const double _zp = (-sin * xp) + (cos * zp);
xp = _xp; xp = _xp;
zp = _zp; zp = _zp;
break; break;
} }
case Axis::Z: { case Axis::Z:
{
const double _xp = (cos * xp) - (sin * yp); const double _xp = (cos * xp) - (sin * yp);
const double _yp = (sin * xp) + (cos * yp); const double _yp = (sin * xp) + (cos * yp);
xp = _xp; xp = _xp;
@@ -123,47 +126,26 @@ class QPoint3D
QPoint3D p = point + dotProduct(*this - point, direction) * direction; QPoint3D p = point + dotProduct(*this - point, direction) * direction;
return (*this - p).length(); return (*this - p).length();
} }
inline double distanceToPlane(const QPoint3D& plane, const QPoint3D& normal) const inline double distanceToPlane(const QPoint3D &plane, const QPoint3D &normal) const { return dotProduct(*this - plane, normal); }
{
return dotProduct(*this - plane, normal);
}
inline double distanceToPlane(const QPoint3D &plane1, const QPoint3D &plane2, const QPoint3D &plane3) const inline double distanceToPlane(const QPoint3D &plane1, const QPoint3D &plane2, const QPoint3D &plane3) const
{ {
QPoint3D n = normal(plane2 - plane1, plane3 - plane1); QPoint3D n = normal(plane2 - plane1, plane3 - plane1);
return dotProduct(*this - plane1, n); return dotProduct(*this - plane1, n);
} }
inline double distanceToPoint(const QPoint3D& point) const inline double distanceToPoint(const QPoint3D &point) const { return (*this - point).length(); }
{
return (*this - point).length();
}
friend constexpr inline bool operator==(const QPoint3D &p1, const QPoint3D &p2); friend constexpr inline bool operator==(const QPoint3D &p1, const QPoint3D &p2);
friend constexpr inline bool operator!=(const QPoint3D &p1, const QPoint3D &p2); friend constexpr inline bool operator!=(const QPoint3D &p1, const QPoint3D &p2);
friend constexpr inline QPoint3D operator+(const QPoint3D& p1, const QPoint3D& p2) friend constexpr inline QPoint3D operator+(const QPoint3D &p1, const QPoint3D &p2) { return QPoint3D(p1.xp + p2.xp, p1.yp + p2.yp, p1.zp + p2.zp); }
{
return QPoint3D(p1.xp + p2.xp, p1.yp + p2.yp, p1.zp + p2.zp);
}
friend constexpr inline QPoint3D operator-(const QPoint3D& p1, const QPoint3D& p2) friend constexpr inline QPoint3D operator-(const QPoint3D &p1, const QPoint3D &p2) { return QPoint3D(p1.xp - p2.xp, p1.yp - p2.yp, p1.zp - p2.zp); }
{
return QPoint3D(p1.xp - p2.xp, p1.yp - p2.yp, p1.zp - p2.zp);
}
friend constexpr inline QPoint3D operator*(const QPoint3D& p1, double factor) friend constexpr inline QPoint3D operator*(const QPoint3D &p1, double factor) { return QPoint3D(p1.xp * factor, p1.yp * factor, p1.zp * factor); }
{
return QPoint3D(p1.xp * factor, p1.yp * factor, p1.zp * factor);
}
friend constexpr inline QPoint3D operator*(double factor, const QPoint3D& p1) friend constexpr inline QPoint3D operator*(double factor, const QPoint3D &p1) { return QPoint3D(p1.xp * factor, p1.yp * factor, p1.zp * factor); }
{
return QPoint3D(p1.xp * factor, p1.yp * factor, p1.zp * factor);
}
friend constexpr inline QPoint3D operator/(const QPoint3D& p1, double factor) friend constexpr inline QPoint3D operator/(const QPoint3D &p1, double factor) { return QPoint3D(p1.xp / factor, p1.yp / factor, p1.zp / factor); }
{
return QPoint3D(p1.xp / factor, p1.yp / factor, p1.zp / factor);
}
constexpr inline QPoint3D &operator+=(const QPoint3D &o) constexpr inline QPoint3D &operator+=(const QPoint3D &o)
{ {
@@ -197,25 +179,16 @@ class QPoint3D
return *this; return *this;
} }
constexpr static inline double dotProduct(const QPoint3D& v1, const QPoint3D& v2) constexpr static inline double dotProduct(const QPoint3D &v1, const QPoint3D &v2) { return v1.xp * v2.xp + v1.yp * v2.yp + v1.zp * v2.zp; }
{
return v1.xp * v2.xp + v1.yp * v2.yp + v1.zp * v2.zp;
}
constexpr static inline QPoint3D crossProduct(const QPoint3D &v1, const QPoint3D &v2) constexpr static inline QPoint3D crossProduct(const QPoint3D &v1, const QPoint3D &v2)
{ {
return QPoint3D(v1.yp * v2.zp - v1.zp * v2.yp, v1.zp * v2.xp - v1.xp * v2.zp, v1.xp * v2.yp - v1.yp * v2.xp); return QPoint3D(v1.yp * v2.zp - v1.zp * v2.yp, v1.zp * v2.xp - v1.xp * v2.zp, v1.xp * v2.yp - v1.yp * v2.xp);
} }
static inline QPoint3D normal(const QPoint3D& v1, const QPoint3D& v2) static inline QPoint3D normal(const QPoint3D &v1, const QPoint3D &v2) { return crossProduct(v1, v2).normalized(); }
{
return crossProduct(v1, v2).normalized();
}
static inline QPoint3D normal(const QPoint3D& v1, const QPoint3D& v2, const QPoint3D& v3) static inline QPoint3D normal(const QPoint3D &v1, const QPoint3D &v2, const QPoint3D &v3) { return crossProduct((v2 - v1), (v3 - v1)).normalized(); }
{
return crossProduct((v2 - v1), (v3 - v1)).normalized();
}
friend inline bool qFuzzyCompare(const QPoint3D &v1, const QPoint3D &v2) friend inline bool qFuzzyCompare(const QPoint3D &v1, const QPoint3D &v2)
{ {
@@ -231,7 +204,12 @@ class QPoint3D
// QDataStream& operator<<(QDataStream& s, const QPoint3D& p); // QDataStream& operator<<(QDataStream& s, const QPoint3D& p);
// QDataStream& operator>>(QDataStream& s, QPoint3D& p); // QDataStream& operator>>(QDataStream& s, QPoint3D& p);
constexpr inline QPoint3D::QPoint3D(double xpos, double ypos, double zpos) : xp(xpos), yp(ypos), zp(zpos) {} constexpr inline QPoint3D::QPoint3D(double xpos, double ypos, double zpos)
: xp(xpos)
, yp(ypos)
, zp(zpos)
{
}
inline bool QPoint3D::isNull() const inline bool QPoint3D::isNull() const
{ {
@@ -1,11 +1,4 @@
/**
* @RDE_HEADER@
* ScopedConnection
* $Id$
* $HeadURL$
* $Author$
* Created by Christian Fröbel, SLSE, 2017-07-24
*/
#include "scoped_connection.h" #include "scoped_connection.h"
@@ -14,7 +7,8 @@
namespace LtsUtils namespace LtsUtils
{ {
ScopedConnection::ScopedConnection(IConnection* connection, Qt::ConnectionType connType) : m_conn(connection) ScopedConnection::ScopedConnection(IConnection *connection, Qt::ConnectionType connType)
: m_conn(connection)
{ {
Q_ASSERT(connection); Q_ASSERT(connection);
m_conn->connect(connType); m_conn->connect(connType);
@@ -1,11 +1,4 @@
/**
* @RDE_HEADER@
* ScopedConnection
* $Id$
* $HeadURL$
* $Author$
* Created by Christian Fröbel, SLSE, 2017-07-24
*/
#pragma once #pragma once
@@ -12,40 +12,19 @@ namespace LtsUtils
class LTSUTILSCORE_EXPORT SfmMessage class LTSUTILSCORE_EXPORT SfmMessage
{ {
public: public:
unsigned int id() const unsigned int id() const { return m_id; }
{
return m_id;
}
void setId(unsigned int id) void setId(unsigned int id) { m_id = id; }
{
m_id = id;
}
bool rtr() const bool rtr() const { return m_rtr; }
{
return m_rtr;
}
void setRtr(bool rtr) void setRtr(bool rtr) { m_rtr = rtr; }
{
m_rtr = rtr;
}
QByteArray payload() const QByteArray payload() const { return m_payload; }
{
return m_payload;
}
void setPayload(const QByteArray& payload) void setPayload(const QByteArray &payload) { m_payload = payload; }
{
m_payload = payload;
}
bool operator==(const SfmMessage& msg) const bool operator==(const SfmMessage &msg) const { return (m_id == msg.id() && m_rtr == msg.rtr() && m_payload == msg.payload()); }
{
return (m_id == msg.id() && m_rtr == msg.rtr() && m_payload == msg.payload());
}
protected: protected:
unsigned int m_id = 0; unsigned int m_id = 0;
@@ -45,9 +45,6 @@ if(QT6_GUI_AVAILABLE)
Qt6::Svg Qt6::Svg
) )
endif() endif()
IF(BUILD_RTI)
TARGET_LINK_LIBRARIES(LtsUtilsGuiDds PUBLIC ddscore)
ENDIF(BUILD_RTI)
NGL_TARGET_COMPILE_DEFINITIONS(LtsUtilsGuiDds NGL_TARGET_COMPILE_DEFINITIONS(LtsUtilsGuiDds
PUBLIC PUBLIC
REQUEST_HELPER_WITH_GUI REQUEST_HELPER_WITH_GUI
@@ -80,6 +77,3 @@ NGL_TARGET_LINK_LIBRARIES(LtsUtilsDds
PUBLIC PUBLIC
Qt6::Core Qt6::Core
) )
IF(BUILD_RTI)
TARGET_LINK_LIBRARIES(LtsUtilsDds PUBLIC ddscore)
ENDIF(BUILD_RTI)
@@ -20,11 +20,18 @@ namespace LtsUtils
{ {
bool RequestHelper::s_debug = false; bool RequestHelper::s_debug = false;
RequestHelper::RequestHelper(QObject* parent, bool quiet, RequestHelper::RequestHelper(QObject *parent,
bool quiet,
const std::function<void(void)>& success, const std::function<void(void)>& failure) const std::function<void(void)> &success,
: QObject(parent), m_failed(false), m_repliedId(-1), m_quiet(quiet), m_blockingCall(true), m_successFn(success), const std::function<void(void)> &failure)
m_failureFn(failure) : QObject(parent)
, m_failed(false)
, m_repliedId(-1)
, m_quiet(quiet)
, m_blockingCall(true)
, m_successFn(success)
, m_failureFn(failure)
{ {
connect(this, &RequestHelper::signalSuccess, this, m_successFn, Qt::QueuedConnection); connect(this, &RequestHelper::signalSuccess, this, m_successFn, Qt::QueuedConnection);
connect(this, &RequestHelper::signalFailed, this, m_failureFn, Qt::QueuedConnection); connect(this, &RequestHelper::signalFailed, this, m_failureFn, Qt::QueuedConnection);
@@ -45,8 +52,7 @@ RequestHelper::RequestHelper(QObject* parent, bool quiet,
} }
} }
void RequestHelper::addRequest(const std::function<int64_t()>& requestFunction, void RequestHelper::addRequest(const std::function<int64_t()> &requestFunction, const std::function<void(const Core::FunctionReply &baseReply)> &baseReplyHandler)
const std::function<void(const Core::FunctionReply& baseReply)>& baseReplyHandler)
{ {
m_requestFunctions.append(RequestFunctionContainer(requestFunction, baseReplyHandler)); m_requestFunctions.append(RequestFunctionContainer(requestFunction, baseReplyHandler));
} }
@@ -75,13 +81,11 @@ bool RequestHelper::_requestReply(const Core::FunctionReplyObject& fro, const Co
{ {
if (m_blockingCall) if (m_blockingCall)
{ {
LtsWidgets::LtsMessageDialog::showMessage(qobject_cast<QWidget*>(parent()), m_errorString, LtsWidgets::LtsMessageDialog::showMessage(qobject_cast<QWidget *>(parent()), m_errorString, tr("Request failed"));
tr("Request failed"));
} }
else else
{ {
new LtsWidgets::LtsMessageDialogNew(qobject_cast<QWidget*>(parent()), m_errorString, new LtsWidgets::LtsMessageDialogNew(qobject_cast<QWidget *>(parent()), m_errorString, tr("Request failed"));
tr("Request failed"));
} }
} }
} }
@@ -94,8 +98,7 @@ bool RequestHelper::_requestReply(const Core::FunctionReplyObject& fro, const Co
if (baseReply) if (baseReply)
m_singleRequestCustomFunctionReply(*baseReply); m_singleRequestCustomFunctionReply(*baseReply);
else else
m_singleRequestCustomFunctionReply( m_singleRequestCustomFunctionReply(Core::FunctionReply(fro.id(), fro.str(), fro.args(), fro.additionalInfo()));
Core::FunctionReply(fro.id(), fro.str(), fro.args(), fro.additionalInfo()));
} }
if (fro.error()) if (fro.error())
@@ -108,8 +111,7 @@ bool RequestHelper::_requestReply(const Core::FunctionReplyObject& fro, const Co
return true; return true;
} }
bool RequestHelper::startSingleRequest( bool RequestHelper::startSingleRequest(const std::function<int64_t()> &requestFunction,
const std::function<int64_t()>& requestFunction,
const std::function<void(const Core::FunctionReply &baseReply)> &baseReplyHandler) const std::function<void(const Core::FunctionReply &baseReply)> &baseReplyHandler)
{ {
addRequest(requestFunction, baseReplyHandler); addRequest(requestFunction, baseReplyHandler);
@@ -171,7 +173,9 @@ void RequestHelper::slotNextRequest()
else else
{ {
connect(new LtsWidgets::LtsMessageDialogNew(qobject_cast<QWidget *>(parent()), tr("Request failed")), connect(new LtsWidgets::LtsMessageDialogNew(qobject_cast<QWidget *>(parent()), tr("Request failed")),
&LtsWidgets::LtsMessageDialogNew::destroyed, this, [this]() { failure(); }); &LtsWidgets::LtsMessageDialogNew::destroyed,
this,
[this]() { failure(); });
return; return;
} }
@@ -181,8 +185,7 @@ void RequestHelper::slotNextRequest()
} }
} }
void RequestHelper::startSingleBackgroundRequest( void RequestHelper::startSingleBackgroundRequest(const std::function<int64_t()> &requestFunction,
const std::function<int64_t()>& requestFunction,
const std::function<void(const Core::FunctionReply &)> &baseReplyHandler) const std::function<void(const Core::FunctionReply &)> &baseReplyHandler)
{ {
m_blockingCall = false; m_blockingCall = false;
@@ -27,14 +27,12 @@
namespace LtsUtils namespace LtsUtils
{ {
template<typename T> template <typename T> dds::core::optional<T> toOptional(T inVal)
dds::core::optional<T> toOptional(T inVal)
{ {
return inVal != T() ? dds::core::optional<T>(inVal) : dds::core::optional<T>(); return inVal != T() ? dds::core::optional<T>(inVal) : dds::core::optional<T>();
} }
template<typename T> template <typename T> dds::core::optional<T> optional()
dds::core::optional<T> optional()
{ {
return dds::core::optional<T>(); return dds::core::optional<T>();
} }
@@ -47,7 +45,9 @@ class LTSUTILSGUIDDS_INTERNAL_EXPORT RequestHelper : public QObject // TODO: DOC
public: public:
static bool s_debug; static bool s_debug;
explicit RequestHelper(QObject *parent = nullptr, bool quiet = false, explicit RequestHelper(
QObject *parent = nullptr,
bool quiet = false,
// for non-blocking // for non-blocking
const std::function<void(void)> &success = []() {}, const std::function<void(void)> &success = []() {},
const std::function<void(void)> &failure = []() {}); const std::function<void(void)> &failure = []() {});
@@ -55,13 +55,13 @@ public:
bool quiet() const { return m_quiet; } bool quiet() const { return m_quiet; }
void setQuiet(bool quiet) { m_quiet = quiet; } void setQuiet(bool quiet) { m_quiet = quiet; }
void addRequest(const std::function<int64_t()> &requestFunction, void addRequest(const std::function<int64_t()> &requestFunction, const std::function<void(const Core::FunctionReply &baseReply)> &baseReplyHandler = nullptr);
const std::function<void(const Core::FunctionReply &baseReply)> &baseReplyHandler = nullptr);
bool startRequests(); // blocks! bool startRequests(); // blocks!
// do not throw a message if this method fails, as this method does this already // blocks! // do not throw a message if this method fails, as this method does this already // blocks!
bool startSingleRequest(const std::function<int64_t(void)> &requestFunction, bool startSingleRequest(const std::function<int64_t(void)> &requestFunction,
const std::function<void(const Core::FunctionReply &baseReply)> &baseReplyHandler = nullptr // for replies that return a custom FunctionReply, which has to be handled >>after successful execution<< const std::function<void(const Core::FunctionReply &baseReply)> &baseReplyHandler =
nullptr // for replies that return a custom FunctionReply, which has to be handled >>after successful execution<<
); );
// non-blocking ! // non-blocking !
@@ -134,7 +134,6 @@ signals:
private slots: private slots:
void slotNextRequest(); void slotNextRequest();
}; };
} // namespace LtsUtils } // namespace LtsUtils
@@ -16,7 +16,8 @@
namespace LtsUtils namespace LtsUtils
{ {
enum class SettingType { enum class SettingType
{
String = 1, String = 1,
StringList = 2, StringList = 2,
Json = 3, Json = 3,
@@ -133,7 +134,8 @@ bool ProjectSettings::initFromFile(const QString& filename)
case SettingType::Json: case SettingType::Json:
val = QJsonDocument(jVal.toObject()).toJson(); val = QJsonDocument(jVal.toObject()).toJson();
break; break;
case SettingType::StringList: { case SettingType::StringList:
{
const QJsonArray arr(jVal.toArray()); const QJsonArray arr(jVal.toArray());
QStringList sl; QStringList sl;
sl.reserve(arr.size()); sl.reserve(arr.size());
@@ -161,8 +163,7 @@ bool ProjectSettings::initFromFile(const QString& filename)
bool ProjectSettings::isFunctionEnabled(const QString &group, const QString &function) bool ProjectSettings::isFunctionEnabled(const QString &group, const QString &function)
{ {
const QStringList functionNames = const QStringList functionNames = getInstance()->value(QStringLiteral("Functionalities"), QStringLiteral("IdentifierList")).toStringList();
getInstance()->value(QStringLiteral("Functionalities"), QStringLiteral("IdentifierList")).toStringList();
return functionNames.contains(group + QLatin1Char(':') + function); return functionNames.contains(group + QLatin1Char(':') + function);
} }
@@ -180,6 +180,11 @@ NGL_INSTALL_TARGET(LtsWidgets)
# #
# Designer-Plugin # Designer-Plugin
# #
# Qt Designer development plugin (COMPONENT Devel), not part of the Release 2
# build closure: it links modules pruned from the tree (LtsDataView,
# LtsReportDisplay, LtsFileDialog, svcFlmCommon — prune commit 7fc6f6664), so
# it is only defined when those modules are present.
IF(EXISTS "${CMAKE_SOURCE_DIR}/Lts/Viewer/LtsDataView")
SET(ltswidgetsplugin_SRCS ltswidgetsplugin.cpp ltswidgetsplugin.json) SET(ltswidgetsplugin_SRCS ltswidgetsplugin.cpp ltswidgetsplugin.json)
NGL_ADD_LIBRARY(WS ltswidgetsplugin MODULE ${ltswidgetsplugin_SRCS}) NGL_ADD_LIBRARY(WS ltswidgetsplugin MODULE ${ltswidgetsplugin_SRCS})
NGL_TARGET_LINK_LIBRARIES(ltswidgetsplugin LtsWidgets ltsCoordWidget LtsDataView LtsFileDialog LtsReportDisplay svcFlmCommon) NGL_TARGET_LINK_LIBRARIES(ltswidgetsplugin LtsWidgets ltsCoordWidget LtsDataView LtsFileDialog LtsReportDisplay svcFlmCommon)
@@ -192,6 +197,7 @@ if(DEFINED QT6_INC_DIR AND EXISTS "${QT6_INC_DIR}/QtPrintSupport")
endif() endif()
NGL_SET_TARGET_PROPERTIES(ltswidgetsplugin PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib/designer) NGL_SET_TARGET_PROPERTIES(ltswidgetsplugin PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib/designer)
NGL_INSTALL_TARGET(ltswidgetsplugin DESTINATION lib/designer COMPONENT Devel) NGL_INSTALL_TARGET(ltswidgetsplugin DESTINATION lib/designer COMPONENT Devel)
ENDIF()
IF(BUILD_TESTING) IF(BUILD_TESTING)
# picture_editing_test # picture_editing_test
@@ -47,6 +47,10 @@ TARGET_INCLUDE_DIRECTORIES(RecordReplayPlugin PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
TARGET_LINK_LIBRARIES(RecordReplayPlugin PUBLIC Qt6::Core) TARGET_LINK_LIBRARIES(RecordReplayPlugin PUBLIC Qt6::Core)
# Topic Replay Interface # Topic Replay Interface
#
# Links TopicEditorBase, which was pruned from the tree (prune commit
# 7fc6f6664), so the target is only defined when the module is present.
IF(EXISTS "${CMAKE_SOURCE_DIR}/Lts/Common/TopicEditorBase")
ADD_LIBRARY(TopicReplayInterface SHARED ADD_LIBRARY(TopicReplayInterface SHARED
${CMAKE_CURRENT_SOURCE_DIR}/topic_replay_interface.h ${CMAKE_CURRENT_SOURCE_DIR}/topic_replay_interface.h
${CMAKE_CURRENT_SOURCE_DIR}/topic_replay_interface.cpp ${CMAKE_CURRENT_SOURCE_DIR}/topic_replay_interface.cpp
@@ -56,6 +60,7 @@ TARGET_INCLUDE_DIRECTORIES(TopicReplayInterface PUBLIC
${CMAKE_BINARY_DIR}/Lts/Common/TopicEditorBase # topiceditorbase_export.h ${CMAKE_BINARY_DIR}/Lts/Common/TopicEditorBase # topiceditorbase_export.h
) )
TARGET_LINK_LIBRARIES(TopicReplayInterface PUBLIC Qt6::Core TopicEditorBase) TARGET_LINK_LIBRARIES(TopicReplayInterface PUBLIC Qt6::Core TopicEditorBase)
ENDIF()
# These interface base classes (e.g. DataPluginBase::Plugin) are Q_OBJECT classes. The top-level # These interface base classes (e.g. DataPluginBase::Plugin) are Q_OBJECT classes. The top-level
# CMAKE_CXX_VISIBILITY_PRESET hidden compiles their Q_OBJECT meta symbols (staticMetaObject/vtable/ # CMAKE_CXX_VISIBILITY_PRESET hidden compiles their Q_OBJECT meta symbols (staticMetaObject/vtable/
@@ -70,8 +75,15 @@ set_target_properties(
ProjectPluginInterface ProjectPluginInterface
StylePluginInterface StylePluginInterface
RecordReplayPlugin RecordReplayPlugin
TopicReplayInterface
PROPERTIES PROPERTIES
CXX_VISIBILITY_PRESET default CXX_VISIBILITY_PRESET default
CXX_VISIBILITY_INLINES_HIDDEN OFF CXX_VISIBILITY_INLINES_HIDDEN OFF
) )
# TopicReplayInterface (pruned dependency, see above)
IF(TARGET TopicReplayInterface)
set_target_properties(TopicReplayInterface
PROPERTIES
CXX_VISIBILITY_PRESET default
CXX_VISIBILITY_INLINES_HIDDEN OFF
)
ENDIF()
@@ -1,11 +1,4 @@
/**
* @RDE_HEADER@
* Interface for HMI plugins
* $Id$
* $HeadURL$
* $Author$
* Created by Christian Ehrlicher, SLSE, 2016-02-29
*/
#pragma once #pragma once
@@ -1,12 +1,4 @@
/**
* @RDE_HEADER@
* Interface for Project Plugins (Resources)
* $Id$
* $HeadURL$
* $Author$
*
* Created by Mike Wille, SLSE, 2016-10-10
*/
#pragma once #pragma once
@@ -1,11 +1,4 @@
/**
* @RDE_HEADER@
* Provide Record/Replay functionality for dds topics in a service
* $Id$
* $HeadURL$
* $Author$
* Created by Christian Ehrlicher, SLSE, 2016-07-07
*/
#pragma once #pragma once
@@ -35,8 +28,7 @@ class RecordReplayPlugin
virtual bool initDtc(const std::shared_ptr<DDSConnector::DdsConnector> &ddsConnector, int exerciseId) = 0; virtual bool initDtc(const std::shared_ptr<DDSConnector::DdsConnector> &ddsConnector, int exerciseId) = 0;
virtual bool initDts(const std::shared_ptr<DDSConnector::DdsConnector>& ddsConnector, int exerciseId, virtual bool initDts(const std::shared_ptr<DDSConnector::DdsConnector> &ddsConnector, int exerciseId, bool bCanHandleSchemas, NSqlQuery &query) = 0;
bool bCanHandleSchemas, NSqlQuery& query) = 0;
virtual bool initCopy(int exerciseId, bool bCanHandleSchemasRead, bool bCanHandleSchemasWrite) = 0; virtual bool initCopy(int exerciseId, bool bCanHandleSchemasRead, bool bCanHandleSchemasWrite) = 0;
@@ -67,13 +59,15 @@ class RecordReplayPlugin
RecSnapshot() = default; RecSnapshot() = default;
RecSnapshot(qint64 timeStamp_, const std::map<int64_t, int64_t> &recIdArray_) RecSnapshot(qint64 timeStamp_, const std::map<int64_t, int64_t> &recIdArray_)
: timeStamp(timeStamp_), recIdArray(recIdArray_) : timeStamp(timeStamp_)
, recIdArray(recIdArray_)
{ {
} }
}; };
virtual std::map<QString, std::vector<RecSnapshot>> virtual std::map<QString, std::vector<RecSnapshot>> getSnapshotTimes(NSqlQuery &query,
getSnapshotTimes(NSqlQuery& query, qint64 toTime, qint64 interval, qint64 toTime,
qint64 interval,
const QHash<QString, qint64> &minRecordedSampleTimes) = 0; const QHash<QString, qint64> &minRecordedSampleTimes) = 0;
virtual QVector<QString> getRecordTopicNames() const = 0; virtual QVector<QString> getRecordTopicNames() const = 0;
@@ -1,12 +1,4 @@
/**
* @RDE_HEADER@
* Interface for Style Plugins (Resources & Stylesheets)
* $Id$
* $HeadURL$
* $Author$
*
* Created by Mike Wille, SLSE, 2016-10-14
*/
#pragma once #pragma once
@@ -1,12 +1,4 @@
/**
* @RDE_HEADER@
* Interface for Script Editor Playback Controls
* $Id$
* $HeadURL$
* $Author$
*
* Created by Mike Wille, SLSE, 2017-04-19
*/
#pragma once #pragma once
@@ -28,10 +20,7 @@ class Interface
{ {
public: public:
static QJsonObject timeRange(qint64 start, qint64 end) static QJsonObject timeRange(qint64 start, qint64 end) { return {{QStringLiteral("start"), start}, {QStringLiteral("end"), end}}; }
{
return {{QStringLiteral("start"), start}, {QStringLiteral("end"), end}};
}
struct SituationReplayTime struct SituationReplayTime
{ {
@@ -71,10 +60,7 @@ class Interface
Interface() = default; Interface() = default;
virtual ~Interface() = default; virtual ~Interface() = default;
virtual QWidget* createWidget() virtual QWidget *createWidget() { return nullptr; }
{
return nullptr;
}
virtual bool playbackInit(const QJsonObject &attributes) virtual bool playbackInit(const QJsonObject &attributes)
{ {
@@ -88,26 +74,18 @@ class Interface
return true; return true;
} }
virtual bool playbackPause() virtual bool playbackPause() { return true; }
{
return true;
}
virtual bool playbackStop() virtual bool playbackStop() { return true; }
{
return true;
}
virtual void setExportPlaybackTimes(qint64 startTimeSec, qint64 durationSec, virtual void setExportPlaybackTimes(qint64 startTimeSec, qint64 durationSec, const QVector<SituationReplayTime> &sitReplayTimes)
const QVector<SituationReplayTime>& sitReplayTimes)
{ {
Q_UNUSED(startTimeSec); Q_UNUSED(startTimeSec);
Q_UNUSED(durationSec); Q_UNUSED(durationSec);
Q_UNUSED(sitReplayTimes); Q_UNUSED(sitReplayTimes);
} }
virtual bool exportTopic(const QJsonObject& attributes, const QString& strFolderPath, virtual bool exportTopic(const QJsonObject &attributes, const QString &strFolderPath, TopicEditorBase::ExportNotifier *pExportNotifier) = 0;
TopicEditorBase::ExportNotifier* pExportNotifier) = 0;
virtual QVector<TopicEditorBase::TopicData> additionalTrackEntries(const QJsonObject &attributes) const virtual QVector<TopicEditorBase::TopicData> additionalTrackEntries(const QJsonObject &attributes) const
{ {
@@ -115,17 +93,13 @@ class Interface
return {}; return {};
} }
virtual QVector<TopicEditorBase::TopicData> additionalTrackEntries(const QJsonObject& attributes, virtual QVector<TopicEditorBase::TopicData> additionalTrackEntries(const QJsonObject &attributes, bool &keepOriginalTopic) const
bool& keepOriginalTopic) const
{ {
keepOriginalTopic = true; keepOriginalTopic = true;
return additionalTrackEntries(attributes); return additionalTrackEntries(attributes);
} }
virtual void setBasePath(const QString& basePath) virtual void setBasePath(const QString &basePath) { Q_UNUSED(basePath); }
{
Q_UNUSED(basePath);
}
}; };
class Factory class Factory
@@ -1,10 +1,4 @@
/**
* @RDE_HEADER@
* Project Defines
* $Id$
* $HeadURL$
* $Author$
*/
#ifndef LTS_COMMON_PROJECTCONFIG_PROJECT_DEFINES_H #ifndef LTS_COMMON_PROJECTCONFIG_PROJECT_DEFINES_H
#define LTS_COMMON_PROJECTCONFIG_PROJECT_DEFINES_H #define LTS_COMMON_PROJECTCONFIG_PROJECT_DEFINES_H
@@ -16,7 +10,8 @@
namespace IDL namespace IDL
{ {
enum class PartitionType { enum class PartitionType
{
Any, Any,
Global, Global,
Exercise, Exercise,
@@ -1,10 +1,4 @@
/**
* @RDE_HEADER@
* * GenericDataWriter (including GenericDataWriterBase)
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once #pragma once
@@ -25,6 +25,12 @@ NGL_ADD_LIBRARY2(AAR SV HLA WS ddsQoS SHARED ${SRCS})
NGL_TARGET_INCLUDE_DIRECTORIES(ddsQoS NGL_TARGET_INCLUDE_DIRECTORIES(ddsQoS
INTERFACE INTERFACE
${CMAKE_CURRENT_SOURCE_DIR}/../../ ${CMAKE_CURRENT_SOURCE_DIR}/../../
# Consumers (the generated *_topic_type_plugin.cpp) include
# DDS_DefaultQos.h -> ddsqos_export.h; the export header is generated
# into the binary dir, so export it the same way ddsfts exports its
# ddsfts_export.h. Without this every <svc>TopicTypePlugin target fails
# to compile ("ddsqos_export.h: No such file or directory").
${CMAKE_CURRENT_BINARY_DIR}
) )
NGL_TARGET_LINK_LIBRARIES(ddsQoS NGL_TARGET_LINK_LIBRARIES(ddsQoS
PRIVATE PRIVATE
@@ -1,11 +1,5 @@
/**
* @RDE_HEADER@
* Online Help Viewer Dialog
* $Id$
* $HeadURL$
* $Author$
* Created by Astrid Müller, SGAS, 2018-04-10
*/
#include "online_help_viewer_dialog.h" #include "online_help_viewer_dialog.h"
#include <NGLLogger/NGLLoggerBootstrap.h> #include <NGLLogger/NGLLoggerBootstrap.h>
@@ -16,9 +16,6 @@ else()
endif() endif()
INCLUDE(MacroRTIDDSGen)
INCLUDE(MacroCodeGenIdl)
ADD_SUBDIRECTORY(Plugins) ADD_SUBDIRECTORY(Plugins)
SET(xml_FILE tab_service.xml) SET(xml_FILE tab_service.xml)
@@ -36,6 +33,9 @@ SET(SRCS_telegrams
training_area_telegrams.h training_area_telegrams.h
) )
NGL_ADD_LIBRARY(AAR SV WS HLA tabTelegrams STATIC ${SRCS_telegrams}) NGL_ADD_LIBRARY(AAR SV WS HLA tabTelegrams STATIC ${SRCS_telegrams})
# tabTelegrams is a STATIC lib linked into shared/MODULE targets
SET_TARGET_PROPERTIES(tabTelegrams PROPERTIES POSITION_INDEPENDENT_CODE ON)
NGL_TARGET_INCLUDE_DIRECTORIES(tabTelegrams NGL_TARGET_INCLUDE_DIRECTORIES(tabTelegrams
PUBLIC PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/..
@@ -70,34 +70,17 @@ SET(SRCS_common
tab_export.h tab_export.h
) )
IF(BUILD_RTI) # Stub files (no RTI code generation in the release scope)
# Generate tab_enums.idl / tab.idl
CODEGEN_IDL_SVC(SRCS_common ${xml_FILE})
# Generate tab_db_impl.cpp/.h, tab_db.h
CODEGEN_DATABASE(SRCS_common ${xml_FILE})
# Generate *.cpp/*.hpp from idl (only with BUILD_RTI)
RTIDDSGEN(SRCS_common tab_enums.idl)
# tab.idl includes pdm.idl, so add explicit dependency on pdm.idl generation
RTIDDSGEN(SRCS_common tab.idl DEPENDS ${CMAKE_BINARY_DIR}/Lts/Services/ProjectDataManagement/pdm.idl)
# Generate tab_dt[s,c]_types.h, tab_ft[s,c]_types.h
CODEGEN_TOPIC_TYPEDEFS(SRCS_common ${xml_FILE})
# generate tab_[d|f]tc.h
CODEGEN_CLIENT_TOPICS_IFC(SRCS_common ${xml_FILE})
ELSE()
# Stub files for BUILD_RTI=OFF - NO code generation
LIST(APPEND SRCS_common LIST(APPEND SRCS_common
stubs/tab_enums_stub.hpp stubs/tab_enums_stub.hpp
stubs/tab_stub.hpp stubs/tab_stub.hpp
stubs/tab_db_stub.hpp stubs/tab_db_stub.hpp
stubs/tab_topic_type_plugin_stub.cpp stubs/tab_topic_type_plugin_stub.cpp
) )
ENDIF()
# Create target only if component flags allow # Create target only if component flags allow
NGL_ADD_LIBRARY2(AAR SV WS HLA svcTabCommon SHARED ${SRCS_common}) NGL_ADD_LIBRARY2(AAR SV WS HLA svcTabCommon SHARED ${SRCS_common})
# Generate export header ALWAYS (needed for logger.h even if target not built)
# Use custom command to create minimal export header if target wasn't created
IF(NOT TARGET svcTabCommon) IF(NOT TARGET svcTabCommon)
# Create a dummy static library just for export header generation # Create a dummy static library just for export header generation
ADD_LIBRARY(svcTabCommon STATIC ${SRCS_common}) ADD_LIBRARY(svcTabCommon STATIC ${SRCS_common})
@@ -121,211 +104,8 @@ NGL_TARGET_LINK_LIBRARIES(svcTabCommon
$<IF:$<TARGET_EXISTS:svcPdmCommon>,svcPdmCommon,> $<IF:$<TARGET_EXISTS:svcPdmCommon>,svcPdmCommon,>
LtsUtilsCoreHeaderOnly LtsUtilsCoreHeaderOnly
) )
IF(BUILD_RTI)
NGL_TARGET_LINK_LIBRARIES(svcTabCommon
PRIVATE
RTI::nddscpp2
PUBLIC
ddscore
)
ENDIF(BUILD_RTI)
NGL_INSTALL_TARGET(svcTabCommon) NGL_INSTALL_TARGET(svcTabCommon)
#
# --- Library svcTabClient --------------------------------------------------------------------------------
#
SET(SRCS_client
tab_export.h
)
IF(BUILD_RTI)
# generate tab_[d|f]tc_impl.[cpp|h]
CODEGEN_CLIENT_TOPICS_IMPL(SRCS_client ${xml_FILE})
ENDIF()
NGL_ADD_LIBRARY2(AAR SV WS HLA svcTabClient SHARED ${SRCS_client})
# NGL_ADD_LIBRARY2 (unlike NGL_ADD_LIBRARY) does not define the
# MAKE_<SYMBOL>_LIB compile guard, but the generated tab_[d|f]tc_impl.h
# headers require MAKE_SVCTABCLIENT_LIB — same situation as
# svcCoreClient/ddscore, which define their guards explicitly.
TARGET_COMPILE_DEFINITIONS(svcTabClient PRIVATE MAKE_SVCTABCLIENT_LIB)
NGL_TARGET_INCLUDE_DIRECTORIES(svcTabClient
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/../
${CMAKE_CURRENT_BINARY_DIR}/../
)
IF(BUILD_RTI)
NGL_TARGET_LINK_LIBRARIES(svcTabClient
PRIVATE
RTI::nddscpp2
ddsconnector
PUBLIC
svcTabCommon
ddsftc
)
ENDIF(BUILD_RTI)
NGL_INSTALL_TARGET(svcTabClient)
#
# --- Library svcTabServer --------------------------------------------------------------------------------
#
SET(SRCS_server
tx_mixin.cpp
tx_mixin.h
)
IF(BUILD_RTI)
# generate tab_[d|f]ts.h, tab_[d|f]ts_impl.[cpp|h]
CODEGEN_SERVER_TOPICS(SRCS_server ${xml_FILE})
ENDIF()
NGL_ADD_LIBRARY2(AAR HLA SV svcTabServer SHARED ${SRCS_server}) # NGL_ADD_LIBRARY2 won't work here - no time for investigations
# Generated tab_[d|f]ts_impl.h require MAKE_SVCTABSERVER_LIB (see svcTabClient above).
TARGET_COMPILE_DEFINITIONS(svcTabServer PRIVATE MAKE_SVCTABSERVER_LIB)
if(BUILD_SV OR BUILD_HLA)
GENERATE_EXPORT_HEADER(svcTabServer) # FIXME: quick workaround
endif()
NGL_TARGET_INCLUDE_DIRECTORIES(svcTabServer
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/../
${CMAKE_CURRENT_BINARY_DIR}/../
)
NGL_TARGET_LINK_LIBRARIES(svcTabServer
PUBLIC
svcTabCommon
ngldb
${_QT_CORE_TARGET}
$<IF:$<AND:$<BOOL:${QT6_GUI_AVAILABLE}>,$<TARGET_EXISTS:Qt6::Gui>>,Qt6::Gui,>
${_QT_NETWORK_TARGET}
)
IF(BUILD_RTI)
NGL_TARGET_LINK_LIBRARIES(svcTabServer
PRIVATE
RTI::nddscpp2
ddsconnector
ddsfts
)
ENDIF(BUILD_RTI)
NGL_INSTALL_TARGET(svcTabServer)
#
# --- Topic Type Plugin --------------------------------------------------------------
#
IF(BUILD_RTI)
CREATE_TOPIC_TYPE_PLUGIN(${xml_FILE})
ENDIF()
#
# --- RecordReplayPlugin --------------------------------------------------------------
#
IF(BUILD_RTI)
CREATE_RECORD_REPLAY_PLUGIN_SHARED(${xml_FILE})
IF (TARGET tabRecordReplayPlugin)
TARGET_SOURCES(tabRecordReplayPlugin
PRIVATE
tab_record_replay_plugin_custom.cpp
tab_record_replay_plugin_custom.h
)
ENDIF()
ENDIF()
#
# --- Executable svcTrainingAreaBase (sTAB) -------------------------------------------------
#
SET(SRCS_exe
dds_handler.cpp
dds_handler.h
exm_handler.cpp
exm_handler.h
ism_handler.cpp
ism_handler.h
main.cpp
main_handler.cpp
main_handler.h
pdm_handler.cpp
pdm_handler.h
ppm_handler.cpp
ppm_handler.h
position_handler.cpp
position_handler.h
recv_from_dds_aes.cpp
recv_from_dds_aes.h
recv_from_dds_fts.cpp
recv_from_dds_fts.h
recv_from_tab.h
send_to_dds.cpp
send_to_dds.h
send_to_tab.h
settings.cpp
settings.h
tab_export.h
tab_plugin_interface.h
WebSocketInterface/data_manager.cpp
WebSocketInterface/data_manager.h
WebSocketInterface/json_keys.h
WebSocketInterface/websocket_interface_handler.cpp
WebSocketInterface/websocket_interface_handler.h
WebSocketInterface/Messages/client_message.cpp
WebSocketInterface/Messages/client_message.h
WebSocketInterface/Messages/reply_message.cpp
WebSocketInterface/Messages/reply_message.h
# tx_mixin.cpp
# tx_mixin.h
log4cxx_tab.props
${xml_FILE}
)
IF(BUILD_RTI)
# Generate tab.sql, tab.xml
CODEGEN_SQL(SRCS_exe ${xml_FILE})
ENDIF()
NGL_ADD_SVC_ICON(SRCS_exe)
NGL_ADD_EXECUTABLE(AAR SV svcTrainingAreaBase ${SRCS_exe})
NGL_TARGET_LINK_LIBRARIES(svcTrainingAreaBase
Qt6::Core
Qt6::Network
LtsCoordTrans
LtsWebSocketServer
LtsCommandLineParser
LtsPluginLoader
LtsUtilsCoreHeaderOnly
LtsUtilsCore
svcTabCommon
svcTabServer
# main_handler.cpp includes the generated <TrainingAreaBase/tab_record_replay_plugin.h>
# and directly instantiates TrainingAreaBase::RecordReplayPluginCustom (whose methods
# live in the plugin .so). Linking the plugin target (rather than relying on a full
# `make all` having generated the header first) makes this a proper build dependency:
# the plugin's codegen runs before the exe compiles (so the generated header exists),
# the plugin's PUBLIC build-tree include dir is inherited (so the include resolves),
# and the plugin .so is linked (so the RecordReplayPluginCustom symbols resolve).
$<IF:$<TARGET_EXISTS:tabRecordReplayPlugin>,tabRecordReplayPlugin,>
svcNomClient
svcAesClient
svcOpmClient
svcCoreClient
svcAsmClient
svcExmClient
$<IF:$<TARGET_EXISTS:svcIsmClient>,svcIsmClient,>
svcPdmClient
svcPpmClient
$<IF:$<TARGET_EXISTS:ddsconnector>,ddsconnector,>
nglsettings
ProjectConfig
NGLLogger
nglcoreapplication
ngltools
tabTelegrams
)
NGL_INSTALL_TARGET(svcTrainingAreaBase)
NGL_INSTALL(AAR SV FILES log4cxx_tab.props DESTINATION bin)
NGL_ADD_TARGET_LINK(svcTrainingAreaBase sTAB)
# clientPluginInterface # clientPluginInterface
ADD_LIBRARY(tabPluginInterface INTERFACE) ADD_LIBRARY(tabPluginInterface INTERFACE)
TARGET_SOURCES(tabPluginInterface INTERFACE TARGET_SOURCES(tabPluginInterface INTERFACE
@@ -1,11 +1,5 @@
/**
* @RDE_HEADER@
* AsmHandler for AdlerJson Plugin
* $Id: pdm_handler.cpp 62304 2024-03-21 08:17:45Z ewert_j $
* $HeadURL: svn://slssvn/TDS/branches/product/features/ufom/Lts/Proxies/TrainingAreaBase/Plugins/UFomHlaJson/pdm_handler.cpp $
* $Author: ewert_j $
* Created by Hanna E. Rathje, 2025-11-18
*/
#include "asm_handler.h" #include "asm_handler.h"
#include <NGLLogger/NGLLoggerBootstrap.h> #include <NGLLogger/NGLLoggerBootstrap.h>
@@ -1,11 +1,5 @@
/**
* @RDE_HEADER@
* FlmHandler for AdlerJson Plugin
* $Id: pdm_handler.cpp 62304 2024-03-21 08:17:45Z ewert_j $
* $HeadURL: svn://slssvn/TDS/branches/product/features/ufom/Lts/Proxies/TrainingAreaBase/Plugins/UFomHlaJson/pdm_handler.cpp $
* $Author: ewert_j $
* Created by Hanna E. Rathje, 2025-11-18
*/
#include "flm_handler.h" #include "flm_handler.h"
#include <NGLLogger/NGLLoggerBootstrap.h> #include <NGLLogger/NGLLoggerBootstrap.h>
@@ -1,11 +1,5 @@
/**
* @RDE_HEADER@
* JsonHandlerTx for AdlerJson Plugin
* $Id: hla_handler_tx.cpp 62899 2024-05-29 11:08:50Z ewert_j $
* $HeadURL: svn://slssvn/TDS/branches/product/features/ufom/Lts/Proxies/TrainingAreaBase/Plugins/AdlerJson/hla_handler_tx.cpp $
* $Author: ewert_j $
* Created by Julius Ewert, ESIM, 2024-03-20
*/
#include "json_handler_tx.h" #include "json_handler_tx.h"
#include <NGLLogger/NGLLoggerBootstrap.h> #include <NGLLogger/NGLLoggerBootstrap.h>
@@ -1,11 +1,5 @@
/**
* @RDE_HEADER@
* PdmHandler for AdlerJson Plugin
* $Id: pdm_handler.cpp 62304 2024-03-21 08:17:45Z ewert_j $
* $HeadURL: svn://slssvn/TDS/branches/product/features/ufom/Lts/Proxies/TrainingAreaBase/Plugins/AdlerJson/pdm_handler.cpp $
* $Author: ewert_j $
* Created by Julius Ewert, ESIM, 2024-03-20
*/
#include "pdm_handler.h" #include "pdm_handler.h"
#include <NGLLogger/NGLLoggerBootstrap.h> #include <NGLLogger/NGLLoggerBootstrap.h>
@@ -1,11 +1,5 @@
/**
* @RDE_HEADER@
* PpmHandler for AdlerJson Plugin
* $Id: ppm_handler.cpp 62899 2024-05-29 11:08:50Z ewert_j $
* $HeadURL: svn://slssvn/TDS/branches/product/features/ufom/Lts/Proxies/TrainingAreaBase/Plugins/AdlerJson/ppm_handler.cpp $
* $Author: ewert_j $
* Created by Julius Ewert, ESIM, 2024-03-20
*/
#include "ppm_handler.h" #include "ppm_handler.h"
#include <NGLLogger/NGLLoggerBootstrap.h> #include <NGLLogger/NGLLoggerBootstrap.h>
@@ -1,11 +1,5 @@
/**
* @RDE_HEADER@
* PpmHandler for AdlerJson Plugin
* $Id: ppm_handler.h 62899 2024-05-29 11:08:50Z ewert_j $
* $HeadURL: svn://slssvn/TDS/branches/product/features/ufom/Lts/Proxies/TrainingAreaBase/Plugins/AdlerJson/ppm_handler.h $
* $Author: ewert_j $
* Created by Julius Ewert, ESIM, 2024-03-20
*/
#pragma once #pragma once
@@ -4,38 +4,5 @@
# $Author$ # $Author$
# #
IF (NOT BUILD_RPM) # Release scope: only the TetraJson plugin is in the tree (GUEZ project, no RTI)
ADD_SUBDIRECTORY(DebugJsonDir)
ENDIF()
#ADD_SUBDIRECTORY(Spu)
IF (BUILD_WLS)
ADD_SUBDIRECTORY(WlsTetra)
ELSE()
ADD_SUBDIRECTORY(TetraJson) ADD_SUBDIRECTORY(TetraJson)
ENDIF()
IF ("${_pname}" STREQUAL "commaster")
ADD_SUBDIRECTORY(Nmea)
ENDIF()
IF (BUILD_SV AND DEFINED _pname)
IF ("${_pname}" STREQUAL "guez")
ADD_SUBDIRECTORY(HlaJson)
ENDIF()
ENDIF()
IF (BUILD_SVC_HLA)
IF ("${_pname}" STREQUAL "ahtc")
ADD_SUBDIRECTORY(ApacheHlaJson)
ENDIF()
ENDIF()
ADD_SUBDIRECTORY(AdlerJson)
OPTION(BUILD_UAS_PROXY "Build the UAS TAB Plugin (default: OFF) [needs BUILD_SV = ON and UNIX-like OS]" OFF) # TODO: use 'pname = guez' if done
if (BUILD_SV AND BUILD_UAS_PROXY AND NOT WIN32)
add_subdirectory(UAS)
endif()
@@ -32,6 +32,7 @@ NGL_ADD_LIBRARY(AAR SV tabPluginTetraJson MODULE ${SRCS})
NGL_INSTALL_TARGET(tabPluginTetraJson) NGL_INSTALL_TARGET(tabPluginTetraJson)
NGL_TARGET_LINK_LIBRARIES(tabPluginTetraJson NGL_TARGET_LINK_LIBRARIES(tabPluginTetraJson
CoPrtCnv CoPrtCnv
LogViewLogger
NGLLogger NGLLogger
nglsettings nglsettings
Qt6::Core Qt6::Core
@@ -19,14 +19,14 @@ protected:
bool handleTelegram(const QByteArray &baJson, int &recvCounter); bool handleTelegram(const QByteArray &baJson, int &recvCounter);
virtual void handleAcknowledge(qint64 timeStamp, int counter) = 0; virtual void handleAcknowledge(qint64 timeStamp, int counter) = 0;
virtual void handleTetraConnectionChanged(bool bConnected) = 0; virtual void handleTetraConnectionChanged(bool bConnected) = 0;
private:
template<typename T>
void rxData(const T &data);
private: private:
template <typename T> void rxData(const T &data);
private:
static TrainingAreaBase::TetraIcd::BiteError convertBiteError(const QJsonObject &obj); static TrainingAreaBase::TetraIcd::BiteError convertBiteError(const QJsonObject &obj);
std::shared_ptr<TrainingAreaBase::RecvFromTab> m_rxHandler; std::shared_ptr<TrainingAreaBase::RecvFromTab> m_rxHandler;
protected: protected:
NGL::INGLLogger &m_logger; NGL::INGLLogger &m_logger;
bool m_bWarnedOnce; bool m_bWarnedOnce;
@@ -9,7 +9,9 @@
namespace TetraRadio namespace TetraRadio
{ {
class ConvertToJson final : public QObject, public TrainingAreaBase::SendToTab class ConvertToJson final
: public QObject
, public TrainingAreaBase::SendToTab
{ {
Q_OBJECT Q_OBJECT
public: public:
@@ -22,6 +24,7 @@ public:
bool sendTele(const QByteArray &ba); bool sendTele(const QByteArray &ba);
void setConnected(bool bConnected) { m_bConnected = bConnected; } void setConnected(bool bConnected) { m_bConnected = bConnected; }
public: public:
bool txData(const TrainingAreaBase::TetraIcd::Acknowledge &data) override; bool txData(const TrainingAreaBase::TetraIcd::Acknowledge &data) override;
bool txData(const TrainingAreaBase::TetraIcd::DemandBite &data) override; bool txData(const TrainingAreaBase::TetraIcd::DemandBite &data) override;
@@ -71,6 +74,7 @@ public:
bool sendToTx(const TrainingAreaBase::TetraIcd::TrainingAreaTelegram *data); bool sendToTx(const TrainingAreaBase::TetraIcd::TrainingAreaTelegram *data);
Q_SIGNALS: Q_SIGNALS:
void outgoingMessage(const QByteArray &msg); void outgoingMessage(const QByteArray &msg);
protected: protected:
protected: protected:
NGL::INGLLogger &m_logger; NGL::INGLLogger &m_logger;
@@ -11,7 +11,9 @@
namespace TetraRadio namespace TetraRadio
{ {
class TetraJsonPlugin : public QObject, public TrainingAreaBase::Plugin::Plugin class TetraJsonPlugin
: public QObject
, public TrainingAreaBase::Plugin::Plugin
{ {
Q_OBJECT Q_OBJECT
Q_PLUGIN_METADATA(IID "special:3:tab.jsonsocket") Q_PLUGIN_METADATA(IID "special:3:tab.jsonsocket")
@@ -31,22 +33,18 @@ class TetraJsonInterfaceImpl final : public TrainingAreaBase::Plugin::Interface
{ {
Q_OBJECT Q_OBJECT
public: public:
TetraJsonInterfaceImpl(TrainingAreaBase::Plugin::DataProvider *pdp, TetraJsonInterfaceImpl(TrainingAreaBase::Plugin::DataProvider *pdp, const std::shared_ptr<TrainingAreaBase::RecvFromTab> &recvFromTabCb, NGL::Settings *settings);
const std::shared_ptr<TrainingAreaBase::RecvFromTab> &recvFromTabCb,
NGL::Settings *settings);
~TetraJsonInterfaceImpl(); ~TetraJsonInterfaceImpl();
bool init() override; bool init() override;
std::shared_ptr<TrainingAreaBase::SendToTab> sendToTab() override; std::shared_ptr<TrainingAreaBase::SendToTab> sendToTab() override;
bool isDebugInterface() const override bool isDebugInterface() const override { return false; }
{
return false;
}
bool canSendData() const override; bool canSendData() const override;
void exerciseChanged() override; void exerciseChanged() override;
const char *name() const override { return "TETRA"; } const char *name() const override { return "TETRA"; }
private Q_SLOTS: private Q_SLOTS:
void onTetraConnectionChanged(bool bConnected); void onTetraConnectionChanged(bool bConnected);
private: private:
NGL::INGLLogger &m_logger; NGL::INGLLogger &m_logger;
void cleanupProcess(); void cleanupProcess();
@@ -10,10 +10,7 @@ namespace TetraRadio
{ {
SocketDispatcher::SocketDispatcher(TrainingAreaBase::Plugin::DataProvider *pdp, const std::shared_ptr<TrainingAreaBase::RecvFromTab> &recvFromTabCb)
SocketDispatcher::SocketDispatcher(TrainingAreaBase::Plugin::DataProvider *pdp,
const std::shared_ptr<TrainingAreaBase::RecvFromTab> &recvFromTabCb)
: QObject() : QObject()
, ConvertFromJson(recvFromTabCb, "TAB.Plugin.SocketDispatcher") , ConvertFromJson(recvFromTabCb, "TAB.Plugin.SocketDispatcher")
, m_txHandler(std::make_shared<ConvertToJson>("TxSocketHandler")) , m_txHandler(std::make_shared<ConvertToJson>("TxSocketHandler"))
@@ -25,8 +22,7 @@ SocketDispatcher::SocketDispatcher(TrainingAreaBase::Plugin::DataProvider *pdp,
{ {
m_ackTimer->setInterval(1000); m_ackTimer->setInterval(1000);
m_ackTimer->setSingleShot(false); m_ackTimer->setSingleShot(false);
connect(m_ackTimer, &QTimer::timeout, connect(m_ackTimer, &QTimer::timeout, this, &SocketDispatcher::onAckTimeout);
this, &SocketDispatcher::onAckTimeout);
} }
SocketDispatcher::~SocketDispatcher() SocketDispatcher::~SocketDispatcher()
@@ -43,12 +39,9 @@ bool SocketDispatcher::init(PrtCnv::PrtCnvApplication *prtCnvApp)
m_prtCnvApp = prtCnvApp; m_prtCnvApp = prtCnvApp;
if (m_prtCnvApp) if (m_prtCnvApp)
{ {
connect(m_txHandler.get(), &ConvertToJson::outgoingMessage, connect(m_txHandler.get(), &ConvertToJson::outgoingMessage, m_prtCnvApp, &PrtCnv::PrtCnvApplication::textMessageFromCentralToPrtCnv);
m_prtCnvApp, &PrtCnv::PrtCnvApplication::textMessageFromCentralToPrtCnv); connect(m_prtCnvApp, &PrtCnv::PrtCnvApplication::textMessageFromPrtCnvToCentral, this, &SocketDispatcher::onTextMessageReceived);
connect(m_prtCnvApp, &PrtCnv::PrtCnvApplication::textMessageFromPrtCnvToCentral, connect(m_prtCnvApp, &PrtCnv::PrtCnvApplication::warehouseMessageFromPtrCnv, this, &SocketDispatcher::warehouseMessage);
this, &SocketDispatcher::onTextMessageReceived);
connect(m_prtCnvApp, &PrtCnv::PrtCnvApplication::warehouseMessageFromPtrCnv,
this, &SocketDispatcher::warehouseMessage);
m_ackTimer->start(); m_ackTimer->start();
m_bInitialAck = true; m_bInitialAck = true;
@@ -93,16 +86,13 @@ void SocketDispatcher::handleTetraConnectionChanged(bool bConnected)
void SocketDispatcher::handleAcknowledge(qint64 timeStamp, int counter) void SocketDispatcher::handleAcknowledge(qint64 timeStamp, int counter)
{ {
TRACE_LOG(m_logger) << "Ack from Socket for time " << timeStamp TRACE_LOG(m_logger) << "Ack from Socket for time " << timeStamp << " with counter " << counter << ", initial: " << m_bInitialAck;
<< " with counter " << counter
<< ", initial: " << m_bInitialAck;
if (m_bInitialAck) if (m_bInitialAck)
{ {
m_txHandler->setConnected(true); m_txHandler->setConnected(true);
m_bInitialAck = false; m_bInitialAck = false;
onSendInitialData(); onSendInitialData();
} }
} }
void SocketDispatcher::onAckTimeout() void SocketDispatcher::onAckTimeout()
@@ -130,7 +120,6 @@ void SocketDispatcher::onSendInitialData()
const auto &aesTeles = m_dataProvider->aesTelegrams(); const auto &aesTeles = m_dataProvider->aesTelegrams();
for (TrainingAreaBase::TetraIcd::TrainingAreaTelegram *aesTele : aesTeles) for (TrainingAreaBase::TetraIcd::TrainingAreaTelegram *aesTele : aesTeles)
m_txHandler->sendToTx(aesTele); m_txHandler->sendToTx(aesTele);
} }
} }
@@ -14,12 +14,13 @@
namespace TetraRadio namespace TetraRadio
{ {
class SocketDispatcher final : public QObject, protected ConvertFromJson class SocketDispatcher final
: public QObject
, protected ConvertFromJson
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit SocketDispatcher(TrainingAreaBase::Plugin::DataProvider *pdp, explicit SocketDispatcher(TrainingAreaBase::Plugin::DataProvider *pdp, const std::shared_ptr<TrainingAreaBase::RecvFromTab> &recvFromTabCb);
const std::shared_ptr<TrainingAreaBase::RecvFromTab> &recvFromTabCb);
~SocketDispatcher(); ~SocketDispatcher();
bool init(PrtCnv::PrtCnvApplication *prtCnvApp); bool init(PrtCnv::PrtCnvApplication *prtCnvApp);
@@ -33,10 +34,12 @@ private Q_SLOTS:
void onTextMessageReceived(const QByteArray &message); void onTextMessageReceived(const QByteArray &message);
void onAckTimeout(); void onAckTimeout();
void onSendInitialData(); void onSendInitialData();
private: private:
void disconnectSocket(QWebSocket *s); void disconnectSocket(QWebSocket *s);
void handleTetraConnectionChanged(bool bConnected) override; void handleTetraConnectionChanged(bool bConnected) override;
void handleAcknowledge(qint64 timeStamp, int counter) override; void handleAcknowledge(qint64 timeStamp, int counter) override;
private: private:
std::shared_ptr<ConvertToJson> m_txHandler; std::shared_ptr<ConvertToJson> m_txHandler;
TrainingAreaBase::Plugin::DataProvider *m_dataProvider; TrainingAreaBase::Plugin::DataProvider *m_dataProvider;
+3 -10
View File
@@ -1,11 +1,5 @@
/**
* @RDE_HEADER@
* Building Config - logging facility
* $Id$
* $HeadURL$
* $Author$
* Created by Christian Ehrlicher, SLSE, 2016-04-14
*/
#include "logger.h" #include "logger.h"
@@ -25,8 +19,7 @@ LOGGER_T getLogger(const char *name)
try try
{ {
return NGL::NGLLoggerBootstrap::getNGLRootLogger(). return NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger(loggerName);
getNGLLogger(loggerName);
} }
catch (const std::exception &ex) catch (const std::exception &ex)
{ {
+2 -8
View File
@@ -1,11 +1,5 @@
/**
* @RDE_HEADER@
* Logging for TrainingAreaBase
* $Id$
* $HeadURL$
* $Author$
* Created by Christian Ehrlicher, SLSE, 2016-04-14
*/
#pragma once #pragma once
File mode changed.
+1 -1
View File
@@ -11,6 +11,7 @@ class SendToTab
protected: protected:
SendToTab() = default; SendToTab() = default;
virtual ~SendToTab() = default; virtual ~SendToTab() = default;
public: public:
virtual const char *name() const = 0; virtual const char *name() const = 0;
enum class HandleState enum class HandleState
@@ -70,6 +71,5 @@ public:
virtual bool txData(const TetraIcd::UAVPerformMission &data) = 0; virtual bool txData(const TetraIcd::UAVPerformMission &data) = 0;
virtual bool txData(const TetraIcd::UAVChangeState &data) = 0; virtual bool txData(const TetraIcd::UAVChangeState &data) = 0;
}; };
} }
@@ -1,16 +1,17 @@
// Stub file for tab_db - BUILD_RTI=OFF
// Auto-generated stub to replace RTI IDL-generated database code
#ifndef TAB_DB_STUB_HPP #ifndef TAB_DB_STUB_HPP
#define TAB_DB_STUB_HPP #define TAB_DB_STUB_HPP
#include "tab_enums_stub.hpp" #include "tab_enums_stub.hpp"
namespace tab { namespace tab
namespace db { {
namespace db
{
// Stub class to replace RTI IDL-generated database types // Stub class to replace RTI IDL-generated database types
class TrainingDatabase { class TrainingDatabase
{
public: public:
virtual ~TrainingDatabase() = default; virtual ~TrainingDatabase() = default;
}; };
@@ -1,19 +1,20 @@
// Stub file for tab_enums - BUILD_RTI=OFF
// Auto-generated stub to replace RTI IDL-generated enums
#ifndef TAB_ENUMS_STUB_HPP #ifndef TAB_ENUMS_STUB_HPP
#define TAB_ENUMS_STUB_HPP #define TAB_ENUMS_STUB_HPP
namespace tab { namespace tab
{
// Stub enums to replace RTI IDL-generated enums // Stub enums to replace RTI IDL-generated enums
enum class TrainingAreaType { enum class TrainingAreaType
{
Unknown = 0, Unknown = 0,
Standard = 1, Standard = 1,
Advanced = 2 Advanced = 2
}; };
enum class TrainingStatus { enum class TrainingStatus
{
Inactive = 0, Inactive = 0,
Active = 1, Active = 1,
Completed = 2 Completed = 2
@@ -1,16 +1,15 @@
// Stub file for tab types - BUILD_RTI=OFF
// Auto-generated stub to replace RTI IDL-generated types
#ifndef TAB_STUB_HPP #ifndef TAB_STUB_HPP
#define TAB_STUB_HPP #define TAB_STUB_HPP
#include "tab_enums_stub.hpp" #include "tab_enums_stub.hpp"
#include <string> #include <string>
namespace tab { namespace tab
{
// Stub class to replace RTI IDL-generated TrainingArea type // Stub class to replace RTI IDL-generated TrainingArea type
class TrainingArea { class TrainingArea
{
public: public:
TrainingArea() = default; TrainingArea() = default;
virtual ~TrainingArea() = default; virtual ~TrainingArea() = default;
@@ -27,7 +26,8 @@ private:
}; };
// Stub class to replace RTI IDL-generated TrainingSession type // Stub class to replace RTI IDL-generated TrainingSession type
class TrainingSession { class TrainingSession
{
public: public:
TrainingSession() = default; TrainingSession() = default;
virtual ~TrainingSession() = default; virtual ~TrainingSession() = default;
@@ -1,13 +1,13 @@
// Stub file for tab_topic_type_plugin - BUILD_RTI=OFF
// Auto-generated stub to replace RTI IDL-generated plugin code
#include "tab_enums_stub.hpp" #include "tab_enums_stub.hpp"
namespace tab { namespace tab
namespace plugin { {
namespace plugin
{
// Stub class to replace RTI IDL-generated topic type plugin // Stub class to replace RTI IDL-generated topic type plugin
class TopicTypePlugin { class TopicTypePlugin
{
public: public:
virtual ~TopicTypePlugin() = default; virtual ~TopicTypePlugin() = default;
@@ -19,8 +19,10 @@ public:
} // namespace tab } // namespace tab
// Export stub function // Export stub function
extern "C" { extern "C"
tab::plugin::TopicTypePlugin* createTopicTypePlugin() { {
tab::plugin::TopicTypePlugin *createTopicTypePlugin()
{
static tab::plugin::TopicTypePlugin instance; static tab::plugin::TopicTypePlugin instance;
return &instance; return &instance;
} }
Loaded 100 of 361 files, more files were not shown because too many files have changed in this diff. Show more