Apply clang-format to Lts/Common and DTC/enum headers
- Formatted all CodeGen module files (9 files) - Formatted LtsAppDescriptor module files - Formatted LtsAppManager/AppChooser files - Applied clang-format to all DTC and enum headers across modules - Removed coordTransTests from CommonUnitTestsPlaceholder (moved to tests/) Cosmetic changes only, no functional modifications. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
847 files changed
+17798
-28513
No files matched your search
@@ -1,4 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// STUB-HEADER: Diese Datei wird normalerweise von ddsdtc generiert
|
// STUB-HEADER: Diese Datei wird normalerweise von ddsdtc generiert
|
||||||
// Für die Migration erstellen wir minimale Forward-Declarations
|
// Für die Migration erstellen wir minimale Forward-Declarations
|
||||||
|
|
||||||
@@ -8,5 +9,5 @@ namespace Interface
|
|||||||
{
|
{
|
||||||
class Dtc;
|
class Dtc;
|
||||||
class Ftc;
|
class Ftc;
|
||||||
}
|
} // namespace Interface
|
||||||
}
|
} // namespace AreaEffectSimulation
|
||||||
@@ -1,24 +1,19 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// STUB-HEADER: Diese Datei wird normalerweise von ddsdtc generiert
|
// STUB-HEADER: Diese Datei wird normalerweise von ddsdtc generiert
|
||||||
// Für die Migration erstellen wir minimale Typ-Definitionen
|
// Für die Migration erstellen wir minimale Typ-Definitionen
|
||||||
|
|
||||||
namespace AreaEffectSimulation
|
namespace AreaEffectSimulation
|
||||||
{
|
{
|
||||||
// Placeholder enums - werden durch echte DDS-Typen ersetzt
|
// Placeholder enums - werden durch echte DDS-Typen ersetzt
|
||||||
enum class SymbolAppearance : int {
|
enum class SymbolAppearance : int { Solid = 0, Dashed = 1, Dotted = 2 };
|
||||||
Solid = 0,
|
|
||||||
Dashed = 1,
|
|
||||||
Dotted = 2
|
|
||||||
};
|
|
||||||
|
|
||||||
enum class SymbolVisibility : int {
|
enum class SymbolVisibility : int { Visible = 0, Hidden = 1 };
|
||||||
Visible = 0,
|
|
||||||
Hidden = 1
|
|
||||||
};
|
|
||||||
|
|
||||||
struct UnitSymbolPosition {
|
struct UnitSymbolPosition
|
||||||
|
{
|
||||||
double x = 0.0;
|
double x = 0.0;
|
||||||
double y = 0.0;
|
double y = 0.0;
|
||||||
double z = 0.0;
|
double z = 0.0;
|
||||||
};
|
};
|
||||||
}
|
} // namespace AreaEffectSimulation
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// STUB-HEADER: Diese Datei wird normalerweise von ddsdtc generiert
|
// STUB-HEADER: Diese Datei wird normalerweise von ddsdtc generiert
|
||||||
// Für die Migration erstellen wir minimale Forward-Declarations
|
// Für die Migration erstellen wir minimale Forward-Declarations
|
||||||
|
|
||||||
@@ -8,5 +9,5 @@ namespace Interface
|
|||||||
{
|
{
|
||||||
class Dtc;
|
class Dtc;
|
||||||
class Ftc;
|
class Ftc;
|
||||||
}
|
} // namespace Interface
|
||||||
}
|
} // namespace AssetManagement
|
||||||
@@ -1,24 +1,19 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// STUB-HEADER: Diese Datei wird normalerweise von ddsdtc generiert
|
// STUB-HEADER: Diese Datei wird normalerweise von ddsdtc generiert
|
||||||
// Für die Migration erstellen wir minimale Typ-Definitionen
|
// Für die Migration erstellen wir minimale Typ-Definitionen
|
||||||
|
|
||||||
namespace AssetManagement
|
namespace AssetManagement
|
||||||
{
|
{
|
||||||
// Placeholder enums - werden durch echte DDS-Typen ersetzt
|
// Placeholder enums - werden durch echte DDS-Typen ersetzt
|
||||||
enum class SymbolAppearance : int {
|
enum class SymbolAppearance : int { Solid = 0, Dashed = 1, Dotted = 2 };
|
||||||
Solid = 0,
|
|
||||||
Dashed = 1,
|
|
||||||
Dotted = 2
|
|
||||||
};
|
|
||||||
|
|
||||||
enum class SymbolVisibility : int {
|
enum class SymbolVisibility : int { Visible = 0, Hidden = 1 };
|
||||||
Visible = 0,
|
|
||||||
Hidden = 1
|
|
||||||
};
|
|
||||||
|
|
||||||
struct UnitSymbolPosition {
|
struct UnitSymbolPosition
|
||||||
|
{
|
||||||
double x = 0.0;
|
double x = 0.0;
|
||||||
double y = 0.0;
|
double y = 0.0;
|
||||||
double z = 0.0;
|
double z = 0.0;
|
||||||
};
|
};
|
||||||
}
|
} // namespace AssetManagement
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// STUB-HEADER: Diese Datei wird normalerweise von ddsdtc generiert
|
// STUB-HEADER: Diese Datei wird normalerweise von ddsdtc generiert
|
||||||
// Für die Migration erstellen wir minimale Forward-Declarations
|
// Für die Migration erstellen wir minimale Forward-Declarations
|
||||||
|
|
||||||
@@ -8,5 +9,5 @@ namespace Interface
|
|||||||
{
|
{
|
||||||
class Dtc;
|
class Dtc;
|
||||||
class Ftc;
|
class Ftc;
|
||||||
}
|
} // namespace Interface
|
||||||
}
|
} // namespace AudioVideoManagement
|
||||||
@@ -1,24 +1,19 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// STUB-HEADER: Diese Datei wird normalerweise von ddsdtc generiert
|
// STUB-HEADER: Diese Datei wird normalerweise von ddsdtc generiert
|
||||||
// Für die Migration erstellen wir minimale Typ-Definitionen
|
// Für die Migration erstellen wir minimale Typ-Definitionen
|
||||||
|
|
||||||
namespace AudioVideoManagement
|
namespace AudioVideoManagement
|
||||||
{
|
{
|
||||||
// Placeholder enums - werden durch echte DDS-Typen ersetzt
|
// Placeholder enums - werden durch echte DDS-Typen ersetzt
|
||||||
enum class SymbolAppearance : int {
|
enum class SymbolAppearance : int { Solid = 0, Dashed = 1, Dotted = 2 };
|
||||||
Solid = 0,
|
|
||||||
Dashed = 1,
|
|
||||||
Dotted = 2
|
|
||||||
};
|
|
||||||
|
|
||||||
enum class SymbolVisibility : int {
|
enum class SymbolVisibility : int { Visible = 0, Hidden = 1 };
|
||||||
Visible = 0,
|
|
||||||
Hidden = 1
|
|
||||||
};
|
|
||||||
|
|
||||||
struct UnitSymbolPosition {
|
struct UnitSymbolPosition
|
||||||
|
{
|
||||||
double x = 0.0;
|
double x = 0.0;
|
||||||
double y = 0.0;
|
double y = 0.0;
|
||||||
double z = 0.0;
|
double z = 0.0;
|
||||||
};
|
};
|
||||||
}
|
} // namespace AudioVideoManagement
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// STUB-HEADER: Diese Datei wird normalerweise von ddsdtc generiert
|
// STUB-HEADER: Diese Datei wird normalerweise von ddsdtc generiert
|
||||||
// Für die Migration erstellen wir minimale Forward-Declarations
|
// Für die Migration erstellen wir minimale Forward-Declarations
|
||||||
|
|
||||||
@@ -8,5 +9,5 @@ namespace Interface
|
|||||||
{
|
{
|
||||||
class Dtc;
|
class Dtc;
|
||||||
class Ftc;
|
class Ftc;
|
||||||
}
|
} // namespace Interface
|
||||||
}
|
} // namespace Buildings
|
||||||
@@ -1,24 +1,19 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// STUB-HEADER: Diese Datei wird normalerweise von ddsdtc generiert
|
// STUB-HEADER: Diese Datei wird normalerweise von ddsdtc generiert
|
||||||
// Für die Migration erstellen wir minimale Typ-Definitionen
|
// Für die Migration erstellen wir minimale Typ-Definitionen
|
||||||
|
|
||||||
namespace Buildings
|
namespace Buildings
|
||||||
{
|
{
|
||||||
// Placeholder enums - werden durch echte DDS-Typen ersetzt
|
// Placeholder enums - werden durch echte DDS-Typen ersetzt
|
||||||
enum class SymbolAppearance : int {
|
enum class SymbolAppearance : int { Solid = 0, Dashed = 1, Dotted = 2 };
|
||||||
Solid = 0,
|
|
||||||
Dashed = 1,
|
|
||||||
Dotted = 2
|
|
||||||
};
|
|
||||||
|
|
||||||
enum class SymbolVisibility : int {
|
enum class SymbolVisibility : int { Visible = 0, Hidden = 1 };
|
||||||
Visible = 0,
|
|
||||||
Hidden = 1
|
|
||||||
};
|
|
||||||
|
|
||||||
struct UnitSymbolPosition {
|
struct UnitSymbolPosition
|
||||||
|
{
|
||||||
double x = 0.0;
|
double x = 0.0;
|
||||||
double y = 0.0;
|
double y = 0.0;
|
||||||
double z = 0.0;
|
double z = 0.0;
|
||||||
};
|
};
|
||||||
}
|
} // namespace Buildings
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// STUB-HEADER: Diese Datei wird normalerweise von ddsdtc generiert
|
// STUB-HEADER: Diese Datei wird normalerweise von ddsdtc generiert
|
||||||
// Für die Migration erstellen wir minimale Forward-Declarations
|
// Für die Migration erstellen wir minimale Forward-Declarations
|
||||||
|
|
||||||
@@ -8,5 +9,5 @@ namespace Interface
|
|||||||
{
|
{
|
||||||
class Dtc;
|
class Dtc;
|
||||||
class Ftc;
|
class Ftc;
|
||||||
}
|
} // namespace Interface
|
||||||
}
|
} // namespace CentralEffectSimulation
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// STUB-HEADER: Diese Datei wird normalerweise von ddsdtc generiert
|
// STUB-HEADER: Diese Datei wird normalerweise von ddsdtc generiert
|
||||||
// Für die Migration erstellen wir minimale Forward-Declarations
|
// Für die Migration erstellen wir minimale Forward-Declarations
|
||||||
|
|
||||||
@@ -8,5 +9,5 @@ namespace Interface
|
|||||||
{
|
{
|
||||||
class Dtc;
|
class Dtc;
|
||||||
class Ftc;
|
class Ftc;
|
||||||
}
|
} // namespace Interface
|
||||||
}
|
} // namespace CodificationManagement
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// STUB-HEADER: Diese Datei wird normalerweise von ddsdtc generiert
|
// STUB-HEADER: Diese Datei wird normalerweise von ddsdtc generiert
|
||||||
// Für die Migration erstellen wir minimale Forward-Declarations
|
// Für die Migration erstellen wir minimale Forward-Declarations
|
||||||
|
|
||||||
@@ -8,5 +9,5 @@ namespace Interface
|
|||||||
{
|
{
|
||||||
class Dtc;
|
class Dtc;
|
||||||
class Ftc;
|
class Ftc;
|
||||||
}
|
} // namespace Interface
|
||||||
}
|
} // namespace ComponentMonitor
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// STUB-HEADER: Diese Datei wird normalerweise von ddsdtc generiert
|
// STUB-HEADER: Diese Datei wird normalerweise von ddsdtc generiert
|
||||||
// Für die Migration erstellen wir minimale Forward-Declarations
|
// Für die Migration erstellen wir minimale Forward-Declarations
|
||||||
|
|
||||||
@@ -8,5 +9,5 @@ namespace Interface
|
|||||||
{
|
{
|
||||||
class Dtc;
|
class Dtc;
|
||||||
class Ftc;
|
class Ftc;
|
||||||
}
|
} // namespace Interface
|
||||||
}
|
} // namespace Core
|
||||||
@@ -1,24 +1,19 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// STUB-HEADER: Diese Datei wird normalerweise von ddsdtc generiert
|
// STUB-HEADER: Diese Datei wird normalerweise von ddsdtc generiert
|
||||||
// Für die Migration erstellen wir minimale Typ-Definitionen
|
// Für die Migration erstellen wir minimale Typ-Definitionen
|
||||||
|
|
||||||
namespace Core
|
namespace Core
|
||||||
{
|
{
|
||||||
// Placeholder enums - werden durch echte DDS-Typen ersetzt
|
// Placeholder enums - werden durch echte DDS-Typen ersetzt
|
||||||
enum class SymbolAppearance : int {
|
enum class SymbolAppearance : int { Solid = 0, Dashed = 1, Dotted = 2 };
|
||||||
Solid = 0,
|
|
||||||
Dashed = 1,
|
|
||||||
Dotted = 2
|
|
||||||
};
|
|
||||||
|
|
||||||
enum class SymbolVisibility : int {
|
enum class SymbolVisibility : int { Visible = 0, Hidden = 1 };
|
||||||
Visible = 0,
|
|
||||||
Hidden = 1
|
|
||||||
};
|
|
||||||
|
|
||||||
struct UnitSymbolPosition {
|
struct UnitSymbolPosition
|
||||||
|
{
|
||||||
double x = 0.0;
|
double x = 0.0;
|
||||||
double y = 0.0;
|
double y = 0.0;
|
||||||
double z = 0.0;
|
double z = 0.0;
|
||||||
};
|
};
|
||||||
}
|
} // namespace Core
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// STUB-HEADER: Diese Datei wird normalerweise von ddsdtc generiert
|
// STUB-HEADER: Diese Datei wird normalerweise von ddsdtc generiert
|
||||||
// Für die Migration erstellen wir minimale Forward-Declarations
|
// Für die Migration erstellen wir minimale Forward-Declarations
|
||||||
|
|
||||||
@@ -8,5 +9,5 @@ namespace Interface
|
|||||||
{
|
{
|
||||||
class Dtc;
|
class Dtc;
|
||||||
class Ftc;
|
class Ftc;
|
||||||
}
|
} // namespace Interface
|
||||||
}
|
} // namespace Core
|
||||||
@@ -1,24 +1,19 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// STUB-HEADER: Diese Datei wird normalerweise von ddsdtc generiert
|
// STUB-HEADER: Diese Datei wird normalerweise von ddsdtc generiert
|
||||||
// Für die Migration erstellen wir minimale Typ-Definitionen
|
// Für die Migration erstellen wir minimale Typ-Definitionen
|
||||||
|
|
||||||
namespace Core
|
namespace Core
|
||||||
{
|
{
|
||||||
// Placeholder enums - werden durch echte DDS-Typen ersetzt
|
// Placeholder enums - werden durch echte DDS-Typen ersetzt
|
||||||
enum class SymbolAppearance : int {
|
enum class SymbolAppearance : int { Solid = 0, Dashed = 1, Dotted = 2 };
|
||||||
Solid = 0,
|
|
||||||
Dashed = 1,
|
|
||||||
Dotted = 2
|
|
||||||
};
|
|
||||||
|
|
||||||
enum class SymbolVisibility : int {
|
enum class SymbolVisibility : int { Visible = 0, Hidden = 1 };
|
||||||
Visible = 0,
|
|
||||||
Hidden = 1
|
|
||||||
};
|
|
||||||
|
|
||||||
struct UnitSymbolPosition {
|
struct UnitSymbolPosition
|
||||||
|
{
|
||||||
double x = 0.0;
|
double x = 0.0;
|
||||||
double y = 0.0;
|
double y = 0.0;
|
||||||
double z = 0.0;
|
double z = 0.0;
|
||||||
};
|
};
|
||||||
}
|
} // namespace Core
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// STUB-HEADER: Diese Datei wird normalerweise von ddsdtc generiert
|
// STUB-HEADER: Diese Datei wird normalerweise von ddsdtc generiert
|
||||||
// Für die Migration erstellen wir minimale Forward-Declarations
|
// Für die Migration erstellen wir minimale Forward-Declarations
|
||||||
|
|
||||||
@@ -8,5 +9,5 @@ namespace Interface
|
|||||||
{
|
{
|
||||||
class Dtc;
|
class Dtc;
|
||||||
class Ftc;
|
class Ftc;
|
||||||
}
|
} // namespace Interface
|
||||||
}
|
} // namespace DDS
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// STUB-HEADER: Diese Datei wird normalerweise von ddsdtc generiert
|
// STUB-HEADER: Diese Datei wird normalerweise von ddsdtc generiert
|
||||||
// Für die Migration erstellen wir minimale Forward-Declarations
|
// Für die Migration erstellen wir minimale Forward-Declarations
|
||||||
|
|
||||||
@@ -8,5 +9,5 @@ namespace Interface
|
|||||||
{
|
{
|
||||||
class Dtc;
|
class Dtc;
|
||||||
class Ftc;
|
class Ftc;
|
||||||
}
|
} // namespace Interface
|
||||||
}
|
} // namespace EffectShowClient
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// STUB-HEADER: Diese Datei wird normalerweise von ddsdtc generiert
|
// STUB-HEADER: Diese Datei wird normalerweise von ddsdtc generiert
|
||||||
// Für die Migration erstellen wir minimale Forward-Declarations
|
// Für die Migration erstellen wir minimale Forward-Declarations
|
||||||
|
|
||||||
@@ -8,5 +9,5 @@ namespace Interface
|
|||||||
{
|
{
|
||||||
class Dtc;
|
class Dtc;
|
||||||
class Ftc;
|
class Ftc;
|
||||||
}
|
} // namespace Interface
|
||||||
}
|
} // namespace EffectShowManagement
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// STUB-HEADER: Diese Datei wird normalerweise von ddsdtc generiert
|
// STUB-HEADER: Diese Datei wird normalerweise von ddsdtc generiert
|
||||||
// Für die Migration erstellen wir minimale Forward-Declarations
|
// Für die Migration erstellen wir minimale Forward-Declarations
|
||||||
|
|
||||||
@@ -8,5 +9,5 @@ namespace Interface
|
|||||||
{
|
{
|
||||||
class Dtc;
|
class Dtc;
|
||||||
class Ftc;
|
class Ftc;
|
||||||
}
|
} // namespace Interface
|
||||||
}
|
} // namespace Evaluations
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// STUB-HEADER: Diese Datei wird normalerweise von ddsdtc generiert
|
// STUB-HEADER: Diese Datei wird normalerweise von ddsdtc generiert
|
||||||
// Für die Migration erstellen wir minimale Forward-Declarations
|
// Für die Migration erstellen wir minimale Forward-Declarations
|
||||||
|
|
||||||
@@ -8,5 +9,5 @@ namespace Interface
|
|||||||
{
|
{
|
||||||
class Dtc;
|
class Dtc;
|
||||||
class Ftc;
|
class Ftc;
|
||||||
}
|
} // namespace Interface
|
||||||
}
|
} // namespace ExerciseEventManagement
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// STUB-HEADER: Diese Datei wird normalerweise von ddsdtc generiert
|
// STUB-HEADER: Diese Datei wird normalerweise von ddsdtc generiert
|
||||||
// Für die Migration erstellen wir minimale Forward-Declarations
|
// Für die Migration erstellen wir minimale Forward-Declarations
|
||||||
|
|
||||||
@@ -8,5 +9,5 @@ namespace Interface
|
|||||||
{
|
{
|
||||||
class Dtc;
|
class Dtc;
|
||||||
class Ftc;
|
class Ftc;
|
||||||
}
|
} // namespace Interface
|
||||||
}
|
} // namespace ExerciseManagement
|
||||||
@@ -1,24 +1,19 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// STUB-HEADER: Diese Datei wird normalerweise von ddsdtc generiert
|
// STUB-HEADER: Diese Datei wird normalerweise von ddsdtc generiert
|
||||||
// Für die Migration erstellen wir minimale Typ-Definitionen
|
// Für die Migration erstellen wir minimale Typ-Definitionen
|
||||||
|
|
||||||
namespace ExerciseManagement
|
namespace ExerciseManagement
|
||||||
{
|
{
|
||||||
// Placeholder enums - werden durch echte DDS-Typen ersetzt
|
// Placeholder enums - werden durch echte DDS-Typen ersetzt
|
||||||
enum class SymbolAppearance : int {
|
enum class SymbolAppearance : int { Solid = 0, Dashed = 1, Dotted = 2 };
|
||||||
Solid = 0,
|
|
||||||
Dashed = 1,
|
|
||||||
Dotted = 2
|
|
||||||
};
|
|
||||||
|
|
||||||
enum class SymbolVisibility : int {
|
enum class SymbolVisibility : int { Visible = 0, Hidden = 1 };
|
||||||
Visible = 0,
|
|
||||||
Hidden = 1
|
|
||||||
};
|
|
||||||
|
|
||||||
struct UnitSymbolPosition {
|
struct UnitSymbolPosition
|
||||||
|
{
|
||||||
double x = 0.0;
|
double x = 0.0;
|
||||||
double y = 0.0;
|
double y = 0.0;
|
||||||
double z = 0.0;
|
double z = 0.0;
|
||||||
};
|
};
|
||||||
}
|
} // namespace ExerciseManagement
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// STUB-HEADER: Diese Datei wird normalerweise von ddsdtc generiert
|
// STUB-HEADER: Diese Datei wird normalerweise von ddsdtc generiert
|
||||||
// Für die Migration erstellen wir minimale Forward-Declarations
|
// Für die Migration erstellen wir minimale Forward-Declarations
|
||||||
|
|
||||||
@@ -8,5 +9,5 @@ namespace Interface
|
|||||||
{
|
{
|
||||||
class Dtc;
|
class Dtc;
|
||||||
class Ftc;
|
class Ftc;
|
||||||
}
|
} // namespace Interface
|
||||||
}
|
} // namespace FileManagement
|
||||||
@@ -1,24 +1,19 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// STUB-HEADER: Diese Datei wird normalerweise von ddsdtc generiert
|
// STUB-HEADER: Diese Datei wird normalerweise von ddsdtc generiert
|
||||||
// Für die Migration erstellen wir minimale Typ-Definitionen
|
// Für die Migration erstellen wir minimale Typ-Definitionen
|
||||||
|
|
||||||
namespace FileManagement
|
namespace FileManagement
|
||||||
{
|
{
|
||||||
// Placeholder enums - werden durch echte DDS-Typen ersetzt
|
// Placeholder enums - werden durch echte DDS-Typen ersetzt
|
||||||
enum class SymbolAppearance : int {
|
enum class SymbolAppearance : int { Solid = 0, Dashed = 1, Dotted = 2 };
|
||||||
Solid = 0,
|
|
||||||
Dashed = 1,
|
|
||||||
Dotted = 2
|
|
||||||
};
|
|
||||||
|
|
||||||
enum class SymbolVisibility : int {
|
enum class SymbolVisibility : int { Visible = 0, Hidden = 1 };
|
||||||
Visible = 0,
|
|
||||||
Hidden = 1
|
|
||||||
};
|
|
||||||
|
|
||||||
struct UnitSymbolPosition {
|
struct UnitSymbolPosition
|
||||||
|
{
|
||||||
double x = 0.0;
|
double x = 0.0;
|
||||||
double y = 0.0;
|
double y = 0.0;
|
||||||
double z = 0.0;
|
double z = 0.0;
|
||||||
};
|
};
|
||||||
}
|
} // namespace FileManagement
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// STUB-HEADER: Diese Datei wird normalerweise von ddsdtc generiert
|
// STUB-HEADER: Diese Datei wird normalerweise von ddsdtc generiert
|
||||||
// Für die Migration erstellen wir minimale Forward-Declarations
|
// Für die Migration erstellen wir minimale Forward-Declarations
|
||||||
|
|
||||||
@@ -8,5 +9,5 @@ namespace Interface
|
|||||||
{
|
{
|
||||||
class Dtc;
|
class Dtc;
|
||||||
class Ftc;
|
class Ftc;
|
||||||
}
|
} // namespace Interface
|
||||||
}
|
} // namespace GuezIedManagement
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// STUB-HEADER: Diese Datei wird normalerweise von ddsdtc generiert
|
// STUB-HEADER: Diese Datei wird normalerweise von ddsdtc generiert
|
||||||
// Für die Migration erstellen wir minimale Forward-Declarations
|
// Für die Migration erstellen wir minimale Forward-Declarations
|
||||||
|
|
||||||
@@ -8,5 +9,5 @@ namespace Interface
|
|||||||
{
|
{
|
||||||
class Dtc;
|
class Dtc;
|
||||||
class Ftc;
|
class Ftc;
|
||||||
}
|
} // namespace Interface
|
||||||
}
|
} // namespace GuezNasat
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// STUB-HEADER: Diese Datei wird normalerweise von ddsdtc generiert
|
// STUB-HEADER: Diese Datei wird normalerweise von ddsdtc generiert
|
||||||
// Für die Migration erstellen wir minimale Forward-Declarations
|
// Für die Migration erstellen wir minimale Forward-Declarations
|
||||||
|
|
||||||
@@ -8,5 +9,5 @@ namespace Interface
|
|||||||
{
|
{
|
||||||
class Dtc;
|
class Dtc;
|
||||||
class Ftc;
|
class Ftc;
|
||||||
}
|
} // namespace Interface
|
||||||
}
|
} // namespace InfrastructureManagement
|
||||||
@@ -1,24 +1,19 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// STUB-HEADER: Diese Datei wird normalerweise von ddsdtc generiert
|
// STUB-HEADER: Diese Datei wird normalerweise von ddsdtc generiert
|
||||||
// Für die Migration erstellen wir minimale Typ-Definitionen
|
// Für die Migration erstellen wir minimale Typ-Definitionen
|
||||||
|
|
||||||
namespace InfrastructureManagement
|
namespace InfrastructureManagement
|
||||||
{
|
{
|
||||||
// Placeholder enums - werden durch echte DDS-Typen ersetzt
|
// Placeholder enums - werden durch echte DDS-Typen ersetzt
|
||||||
enum class SymbolAppearance : int {
|
enum class SymbolAppearance : int { Solid = 0, Dashed = 1, Dotted = 2 };
|
||||||
Solid = 0,
|
|
||||||
Dashed = 1,
|
|
||||||
Dotted = 2
|
|
||||||
};
|
|
||||||
|
|
||||||
enum class SymbolVisibility : int {
|
enum class SymbolVisibility : int { Visible = 0, Hidden = 1 };
|
||||||
Visible = 0,
|
|
||||||
Hidden = 1
|
|
||||||
};
|
|
||||||
|
|
||||||
struct UnitSymbolPosition {
|
struct UnitSymbolPosition
|
||||||
|
{
|
||||||
double x = 0.0;
|
double x = 0.0;
|
||||||
double y = 0.0;
|
double y = 0.0;
|
||||||
double z = 0.0;
|
double z = 0.0;
|
||||||
};
|
};
|
||||||
}
|
} // namespace InfrastructureManagement
|
||||||
Executable → Regular
+28
-51
@@ -1,10 +1,11 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "CppTopicGeneratorGrantlee.h"
|
#include "CppTopicGeneratorGrantlee.h"
|
||||||
|
|
||||||
#include "StructBuilder.h"
|
#include "StructBuilder.h"
|
||||||
#include <QCryptographicHash>
|
|
||||||
#include <NGLLogger/INGLLogger.h>
|
#include <NGLLogger/INGLLogger.h>
|
||||||
|
#include <QCryptographicHash>
|
||||||
#include <grantlee/context.h>
|
#include <grantlee/context.h>
|
||||||
|
|
||||||
#ifdef RTI_HEADER_AVAILABLE
|
#ifdef RTI_HEADER_AVAILABLE
|
||||||
@@ -13,9 +14,7 @@
|
|||||||
|
|
||||||
using namespace CodeGen;
|
using namespace CodeGen;
|
||||||
|
|
||||||
CppTopicGeneratorGrantlee::CppTopicGeneratorGrantlee()
|
CppTopicGeneratorGrantlee::CppTopicGeneratorGrantlee() : GeneratorGrantleeBase("CodeGen.CppTopicGeneratorGrantlee") {}
|
||||||
: GeneratorGrantleeBase("CodeGen.CppTopicGeneratorGrantlee")
|
|
||||||
{}
|
|
||||||
|
|
||||||
bool CppTopicGeneratorGrantlee::init(const XmlReader* reader, StructBuilder* structBuilder)
|
bool CppTopicGeneratorGrantlee::init(const XmlReader* reader, StructBuilder* structBuilder)
|
||||||
{
|
{
|
||||||
@@ -28,8 +27,6 @@ bool CppTopicGeneratorGrantlee::init(const XmlReader *reader, StructBuilder *str
|
|||||||
return initDataTopics() && initFunctionTopics() && initIdlStructs();
|
return initDataTopics() && initFunctionTopics() && initIdlStructs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool CppTopicGeneratorGrantlee::initDataTopics()
|
bool CppTopicGeneratorGrantlee::initDataTopics()
|
||||||
{
|
{
|
||||||
DataTopicsWrapper* dataTopicsWrapper = new DataTopicsWrapper(QString(), this);
|
DataTopicsWrapper* dataTopicsWrapper = new DataTopicsWrapper(QString(), this);
|
||||||
@@ -103,15 +100,13 @@ bool CppTopicGeneratorGrantlee::initDataTopics()
|
|||||||
{
|
{
|
||||||
MemberInformationListWrapper* mil = new MemberInformationListWrapper(it.key(), it.value(), this);
|
MemberInformationListWrapper* mil = new MemberInformationListWrapper(it.key(), it.value(), this);
|
||||||
jsonTopics += mil;
|
jsonTopics += mil;
|
||||||
|
|
||||||
}
|
}
|
||||||
m_ctx->insert(QStringLiteral("jsonTopics"), QVariant::fromValue(jsonTopics));
|
m_ctx->insert(QStringLiteral("jsonTopics"), QVariant::fromValue(jsonTopics));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CppTopicGeneratorGrantlee::getSpecialColumns(const CompleteTopicTypeInformation &tti,
|
bool CppTopicGeneratorGrantlee::getSpecialColumns(const CompleteTopicTypeInformation& tti, QVector<IdlData>& keyColumns,
|
||||||
QVector<IdlData> &keyColumns,
|
|
||||||
QVector<IdlData>& trColumns) const
|
QVector<IdlData>& trColumns) const
|
||||||
{
|
{
|
||||||
DEBUG_LOG(m_logger) << "Get special columns for " << tti.name << " - base is " << tti.baseValueType;
|
DEBUG_LOG(m_logger) << "Get special columns for " << tti.name << " - base is " << tti.baseValueType;
|
||||||
@@ -132,8 +127,6 @@ bool CppTopicGeneratorGrantlee::getSpecialColumns(const CompleteTopicTypeInforma
|
|||||||
return getSpecialColumns(topicTypeInformationByDerivedTopic(tti), keyColumns, trColumns);
|
return getSpecialColumns(topicTypeInformationByDerivedTopic(tti), keyColumns, trColumns);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool CppTopicGeneratorGrantlee::initFunctionTopics()
|
bool CppTopicGeneratorGrantlee::initFunctionTopics()
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -149,32 +142,30 @@ bool CppTopicGeneratorGrantlee::initFunctionTopics()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CppTopicGeneratorGrantlee::handleStruct(const FunctionTopic &ft,
|
bool CppTopicGeneratorGrantlee::handleStruct(const FunctionTopic& ft, FunctionTopicsWrapper* functionTopicsWrapper)
|
||||||
FunctionTopicsWrapper *functionTopicsWrapper)
|
|
||||||
{
|
{
|
||||||
DEBUG_LOG(m_logger) << "handling FunctionTopic: " << ft.name;
|
DEBUG_LOG(m_logger) << "handling FunctionTopic: " << ft.name;
|
||||||
|
|
||||||
const CompleteTopicTypeInformation siRequest = m_structBuilder->topicTypeInformationByStructType(ft.requestTopicType);
|
const CompleteTopicTypeInformation siRequest =
|
||||||
|
m_structBuilder->topicTypeInformationByStructType(ft.requestTopicType);
|
||||||
if (!siRequest.isValid())
|
if (!siRequest.isValid())
|
||||||
{
|
{
|
||||||
WARNING_LOG(m_logger) << "Could not get topic informations about request topic "
|
WARNING_LOG(m_logger) << "Could not get topic informations about request topic " << ft.requestTopicName;
|
||||||
<< ft.requestTopicName;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const CompleteTopicTypeInformation siReply = m_structBuilder->topicTypeInformationByStructType(ft.replyTopicType);
|
const CompleteTopicTypeInformation siReply = m_structBuilder->topicTypeInformationByStructType(ft.replyTopicType);
|
||||||
if (!siReply.isValid())
|
if (!siReply.isValid())
|
||||||
{
|
{
|
||||||
WARNING_LOG(m_logger) << "Could not get topic informations about reply topic "
|
WARNING_LOG(m_logger) << "Could not get topic informations about reply topic " << ft.replyTopicType;
|
||||||
<< ft.replyTopicType;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
FunctionTopicWrapper* ftw = functionTopicsWrapper->addFunctionTopic(ft, siRequest, siReply);
|
FunctionTopicWrapper* ftw = functionTopicsWrapper->addFunctionTopic(ft, siRequest, siReply);
|
||||||
const QByteArray hash = QCryptographicHash::hash(ft.requestTopicName.toUtf8(), QCryptographicHash::Sha3_512).toHex().left(16);
|
const QByteArray hash =
|
||||||
|
QCryptographicHash::hash(ft.requestTopicName.toUtf8(), QCryptographicHash::Sha3_512).toHex().left(16);
|
||||||
ftw->setReplyHandlerHash(QStringLiteral("0x") + QString::fromLatin1(hash) + QStringLiteral("LL"));
|
ftw->setReplyHandlerHash(QStringLiteral("0x") + QString::fromLatin1(hash) + QStringLiteral("LL"));
|
||||||
if (!addRequesterRequestParams(ft.name, siRequest, ftw) ||
|
if (!addRequesterRequestParams(ft.name, siRequest, ftw) || !addRequesterReplyParams(ft.name, siReply, ftw))
|
||||||
!addRequesterReplyParams(ft.name, siReply, ftw))
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -186,7 +177,8 @@ bool CppTopicGeneratorGrantlee::addRequesterRequestParams(const QString &request
|
|||||||
{
|
{
|
||||||
if (request.hasBaseValue())
|
if (request.hasBaseValue())
|
||||||
{
|
{
|
||||||
const CompleteTopicTypeInformation siBase = m_structBuilder->topicTypeInformationByStructType(request.baseValueType);
|
const CompleteTopicTypeInformation siBase =
|
||||||
|
m_structBuilder->topicTypeInformationByStructType(request.baseValueType);
|
||||||
if (!siBase.isValid())
|
if (!siBase.isValid())
|
||||||
{
|
{
|
||||||
WARNING_LOG(m_logger) << "Could not get topic informations about base request topic "
|
WARNING_LOG(m_logger) << "Could not get topic informations about base request topic "
|
||||||
@@ -208,11 +200,11 @@ bool CppTopicGeneratorGrantlee::addRequesterReplyParams(const QString &request_n
|
|||||||
{
|
{
|
||||||
if (reply.hasBaseValue())
|
if (reply.hasBaseValue())
|
||||||
{
|
{
|
||||||
const CompleteTopicTypeInformation siBase = m_structBuilder->topicTypeInformationByStructType(reply.baseValueType);
|
const CompleteTopicTypeInformation siBase =
|
||||||
|
m_structBuilder->topicTypeInformationByStructType(reply.baseValueType);
|
||||||
if (!siBase.isValid())
|
if (!siBase.isValid())
|
||||||
{
|
{
|
||||||
WARNING_LOG(m_logger) << "Could not get topic informations about base reply topic "
|
WARNING_LOG(m_logger) << "Could not get topic informations about base reply topic " << reply.baseValueType;
|
||||||
<< reply.baseValueType;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -224,10 +216,7 @@ bool CppTopicGeneratorGrantlee::addRequesterReplyParams(const QString &request_n
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CppTopicGeneratorGrantlee::handleIdlStruct(const CompleteTopicTypeInformation& csi, QSet<QString>& idlStructNames,
|
||||||
|
|
||||||
bool CppTopicGeneratorGrantlee::handleIdlStruct(const CompleteTopicTypeInformation &csi,
|
|
||||||
QSet<QString> &idlStructNames,
|
|
||||||
QVector<IdlStructWrapper*>& idlStructs)
|
QVector<IdlStructWrapper*>& idlStructs)
|
||||||
{
|
{
|
||||||
if (!csi.isValid())
|
if (!csi.isValid())
|
||||||
@@ -236,12 +225,10 @@ bool CppTopicGeneratorGrantlee::handleIdlStruct(const CompleteTopicTypeInformati
|
|||||||
if (idlStructNames.contains(csi.name))
|
if (idlStructNames.contains(csi.name))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (csi.hasBaseValue())
|
if (csi.hasBaseValue())
|
||||||
{
|
{
|
||||||
const CompleteTopicTypeInformation ctti = m_structBuilder->topicTypeInformationByStructType(csi.baseValueType, false);
|
const CompleteTopicTypeInformation ctti =
|
||||||
|
m_structBuilder->topicTypeInformationByStructType(csi.baseValueType, false);
|
||||||
if (ctti.isValid())
|
if (ctti.isValid())
|
||||||
{
|
{
|
||||||
#ifdef RTI_HEADER_AVAILABLE
|
#ifdef RTI_HEADER_AVAILABLE
|
||||||
@@ -266,20 +253,17 @@ bool CppTopicGeneratorGrantlee::handleIdlStruct(const CompleteTopicTypeInformati
|
|||||||
const int idx = csi.baseValueType.indexOf(QLatin1String("::"));
|
const int idx = csi.baseValueType.indexOf(QLatin1String("::"));
|
||||||
if (idx < 0)
|
if (idx < 0)
|
||||||
{
|
{
|
||||||
ERROR_LOG(m_logger) << "idlStruct '" << csi.baseValueType
|
ERROR_LOG(m_logger) << "idlStruct '" << csi.baseValueType << "' not found in idl-file";
|
||||||
<< "' not found in idl-file";
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for (const IdlData& idlData : csi.members)
|
for (const IdlData& idlData : csi.members)
|
||||||
{
|
{
|
||||||
QString idlType;
|
QString idlType;
|
||||||
DEBUG_LOG(m_logger) << "member: " << idlData.type << " - " << idlData.name
|
DEBUG_LOG(m_logger) << "member: " << idlData.type << " - " << idlData.name << " "
|
||||||
<< " " << idlData.dataTypeInfo->isStructure()
|
<< idlData.dataTypeInfo->isStructure() << " " << idlData.dataTypeInfo->isSequence();
|
||||||
<< " " << idlData.dataTypeInfo->isSequence();
|
|
||||||
if (idlData.dataTypeInfo->isStructure())
|
if (idlData.dataTypeInfo->isStructure())
|
||||||
idlType = idlData.dataTypeInfo->idlType();
|
idlType = idlData.dataTypeInfo->idlType();
|
||||||
else if (idlData.dataTypeInfo->isSequence())
|
else if (idlData.dataTypeInfo->isSequence())
|
||||||
@@ -289,18 +273,14 @@ bool CppTopicGeneratorGrantlee::handleIdlStruct(const CompleteTopicTypeInformati
|
|||||||
}
|
}
|
||||||
if (idlType.isEmpty())
|
if (idlType.isEmpty())
|
||||||
continue;
|
continue;
|
||||||
if (!handleIdlStruct(m_structBuilder->topicTypeInformationByStructType(idlType,
|
if (!handleIdlStruct(m_structBuilder->topicTypeInformationByStructType(idlType, false), idlStructNames,
|
||||||
false),
|
|
||||||
idlStructNames,
|
|
||||||
idlStructs))
|
idlStructs))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DEBUG_LOG(m_logger) << "Current structName: " << csi.name;
|
DEBUG_LOG(m_logger) << "Current structName: " << csi.name;
|
||||||
idlStructs += new IdlStructWrapper(csi, this);
|
idlStructs += new IdlStructWrapper(csi, this);
|
||||||
|
|
||||||
|
|
||||||
idlStructNames.insert(csi.name);
|
idlStructNames.insert(csi.name);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -329,21 +309,18 @@ bool CppTopicGeneratorGrantlee::initIdlStructs()
|
|||||||
idlEnumerations += new IdlEnumWrapper(ei, this);
|
idlEnumerations += new IdlEnumWrapper(ei, this);
|
||||||
m_ctx->insert(QStringLiteral("idl_enums"), QVariant::fromValue(idlEnumerations));
|
m_ctx->insert(QStringLiteral("idl_enums"), QVariant::fromValue(idlEnumerations));
|
||||||
|
|
||||||
|
|
||||||
exportUsedServices(m_reader);
|
exportUsedServices(m_reader);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CompleteTopicTypeInformation
|
||||||
CompleteTopicTypeInformation CppTopicGeneratorGrantlee::topicTypeInformationByDerivedTopic(const CompleteTopicTypeInformation &tti) const
|
CppTopicGeneratorGrantlee::topicTypeInformationByDerivedTopic(const CompleteTopicTypeInformation& tti) const
|
||||||
{
|
{
|
||||||
if (tti.baseValueType.isEmpty())
|
if (tti.baseValueType.isEmpty())
|
||||||
return CompleteTopicTypeInformation();
|
return CompleteTopicTypeInformation();
|
||||||
QString baseValueType = tti.baseValueType;
|
QString baseValueType = tti.baseValueType;
|
||||||
|
|
||||||
|
if (tti.name.contains(QLatin1String("::")) && !tti.baseValueType.contains(QLatin1String("::")))
|
||||||
if (tti.name.contains(QLatin1String("::")) &&
|
|
||||||
!tti.baseValueType.contains(QLatin1String("::")))
|
|
||||||
{
|
{
|
||||||
const QStringList sl = tti.name.split(QStringLiteral("::"));
|
const QStringList sl = tti.name.split(QStringLiteral("::"));
|
||||||
baseValueType = sl.at(0) + QLatin1String("::") + tti.baseValueType;
|
baseValueType = sl.at(0) + QLatin1String("::") + tti.baseValueType;
|
||||||
|
|||||||
Executable → Regular
+9
-15
@@ -1,11 +1,11 @@
|
|||||||
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <QObject>
|
|
||||||
|
|
||||||
#include "GeneratorGrantleeBase.h"
|
#include "GeneratorGrantleeBase.h"
|
||||||
#include "StructBuilder.h"
|
|
||||||
#include "GrantleeWrappers.h"
|
#include "GrantleeWrappers.h"
|
||||||
|
#include "StructBuilder.h"
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
namespace CodeGen
|
namespace CodeGen
|
||||||
{
|
{
|
||||||
@@ -19,24 +19,18 @@ public:
|
|||||||
bool init(const XmlReader* reader, StructBuilder* structBuilder) override;
|
bool init(const XmlReader* reader, StructBuilder* structBuilder) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
bool initDataTopics();
|
bool initDataTopics();
|
||||||
bool getSpecialColumns(const CompleteTopicTypeInformation &tti,
|
bool getSpecialColumns(const CompleteTopicTypeInformation& tti, QVector<IdlData>& keyColumns,
|
||||||
QVector<IdlData> &keyColumns,
|
|
||||||
QVector<IdlData>& trColumns) const;
|
QVector<IdlData>& trColumns) const;
|
||||||
|
|
||||||
bool initFunctionTopics();
|
bool initFunctionTopics();
|
||||||
bool handleStruct(const FunctionTopic &ft,
|
bool handleStruct(const FunctionTopic& ft, FunctionTopicsWrapper* functionTopicsWrapper);
|
||||||
FunctionTopicsWrapper *functionTopicsWrapper);
|
bool addRequesterRequestParams(const QString& request_name, const CompleteTopicTypeInformation& request,
|
||||||
bool addRequesterRequestParams(const QString &request_name,
|
|
||||||
const CompleteTopicTypeInformation &request,
|
|
||||||
FunctionTopicWrapper* ftw);
|
FunctionTopicWrapper* ftw);
|
||||||
bool addRequesterReplyParams(const QString &request_name,
|
bool addRequesterReplyParams(const QString& request_name, const CompleteTopicTypeInformation& reply,
|
||||||
const CompleteTopicTypeInformation &reply,
|
|
||||||
FunctionTopicWrapper* ftw);
|
FunctionTopicWrapper* ftw);
|
||||||
|
|
||||||
bool handleIdlStruct(const CompleteTopicTypeInformation &csi,
|
bool handleIdlStruct(const CompleteTopicTypeInformation& csi, QSet<QString>& idlStructNames,
|
||||||
QSet<QString> &idlStructNames,
|
|
||||||
QVector<IdlStructWrapper*>& idlStructs);
|
QVector<IdlStructWrapper*>& idlStructs);
|
||||||
bool initIdlStructs();
|
bool initIdlStructs();
|
||||||
|
|
||||||
@@ -44,4 +38,4 @@ private:
|
|||||||
|
|
||||||
const XmlReader* m_reader = nullptr;
|
const XmlReader* m_reader = nullptr;
|
||||||
};
|
};
|
||||||
}
|
} // namespace CodeGen
|
||||||
Executable → Regular
+4
-7
@@ -1,24 +1,21 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "DaoGeneratorGrantlee.h"
|
#include "DaoGeneratorGrantlee.h"
|
||||||
|
|
||||||
#include "StructBuilder.h"
|
#include "StructBuilder.h"
|
||||||
|
|
||||||
#include <NGLLogger/INGLLogger.h>
|
#include <NGLLogger/INGLLogger.h>
|
||||||
#include <grantlee/context.h>
|
#include <grantlee/context.h>
|
||||||
|
|
||||||
using namespace CodeGen;
|
using namespace CodeGen;
|
||||||
|
|
||||||
DaoGeneratorGrantlee::DaoGeneratorGrantlee()
|
DaoGeneratorGrantlee::DaoGeneratorGrantlee() : GeneratorGrantleeBase("CodeGen.DaoGeneratorGrantlee") {}
|
||||||
: GeneratorGrantleeBase("CodeGen.DaoGeneratorGrantlee")
|
|
||||||
{}
|
|
||||||
|
|
||||||
bool DaoGeneratorGrantlee::init(const XmlReader *reader,
|
bool DaoGeneratorGrantlee::init(const XmlReader* reader, StructBuilder* structBuilder)
|
||||||
StructBuilder *structBuilder)
|
|
||||||
{
|
{
|
||||||
if (!GeneratorGrantleeBase::initInternal(reader, structBuilder))
|
if (!GeneratorGrantleeBase::initInternal(reader, structBuilder))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
||||||
if (reader->isServiceExerciseIndependent())
|
if (reader->isServiceExerciseIndependent())
|
||||||
m_ctx->insert(QStringLiteral("isExerciseIndependent"), QLatin1String("1"));
|
m_ctx->insert(QStringLiteral("isExerciseIndependent"), QLatin1String("1"));
|
||||||
|
|
||||||
|
|||||||
Executable → Regular
+4
-5
@@ -1,11 +1,11 @@
|
|||||||
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <QObject>
|
|
||||||
|
|
||||||
#include "GeneratorGrantleeBase.h"
|
#include "GeneratorGrantleeBase.h"
|
||||||
#include "StructBuilder.h"
|
|
||||||
#include "GrantleeWrappers.h"
|
#include "GrantleeWrappers.h"
|
||||||
|
#include "StructBuilder.h"
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
namespace CodeGen
|
namespace CodeGen
|
||||||
{
|
{
|
||||||
@@ -13,7 +13,6 @@ struct CompleteStructInformation;
|
|||||||
class StructBuilder;
|
class StructBuilder;
|
||||||
class XmlReader;
|
class XmlReader;
|
||||||
|
|
||||||
|
|
||||||
class DaoGeneratorGrantlee final : public GeneratorGrantleeBase
|
class DaoGeneratorGrantlee final : public GeneratorGrantleeBase
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -22,4 +21,4 @@ public:
|
|||||||
|
|
||||||
bool init(const XmlReader* reader, StructBuilder* structBuilder) override;
|
bool init(const XmlReader* reader, StructBuilder* structBuilder) override;
|
||||||
};
|
};
|
||||||
}
|
} // namespace CodeGen
|
||||||
Executable → Regular
+8
-8
@@ -1,25 +1,24 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "DatabaseGeneratorGrantlee.h"
|
#include "DatabaseGeneratorGrantlee.h"
|
||||||
|
|
||||||
#include "StructBuilder.h"
|
#include "StructBuilder.h"
|
||||||
|
|
||||||
#include <NGLLogger/INGLLogger.h>
|
#include <NGLLogger/INGLLogger.h>
|
||||||
#include <grantlee/context.h>
|
#include <grantlee/context.h>
|
||||||
|
|
||||||
using namespace CodeGen;
|
using namespace CodeGen;
|
||||||
|
|
||||||
DatabaseGeneratorGrantlee::DatabaseGeneratorGrantlee(bool targetIsServer)
|
DatabaseGeneratorGrantlee::DatabaseGeneratorGrantlee(bool targetIsServer)
|
||||||
: GeneratorGrantleeBase("CodeGen.CppStructGeneratorGrantlee")
|
: GeneratorGrantleeBase("CodeGen.CppStructGeneratorGrantlee"), m_targetIsServer(targetIsServer)
|
||||||
, m_targetIsServer(targetIsServer)
|
{
|
||||||
{}
|
}
|
||||||
|
|
||||||
bool DatabaseGeneratorGrantlee::init(const XmlReader *reader,
|
bool DatabaseGeneratorGrantlee::init(const XmlReader* reader, StructBuilder* structBuilder)
|
||||||
StructBuilder *structBuilder)
|
|
||||||
{
|
{
|
||||||
if (!GeneratorGrantleeBase::initInternal(reader, structBuilder))
|
if (!GeneratorGrantleeBase::initInternal(reader, structBuilder))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
||||||
if (reader->isServiceExerciseIndependent())
|
if (reader->isServiceExerciseIndependent())
|
||||||
m_ctx->insert(QStringLiteral("isExerciseIndependent"), QLatin1String("1"));
|
m_ctx->insert(QStringLiteral("isExerciseIndependent"), QLatin1String("1"));
|
||||||
|
|
||||||
@@ -51,7 +50,8 @@ bool DatabaseGeneratorGrantlee::init(const XmlReader *reader,
|
|||||||
if (bHasDbNotifications)
|
if (bHasDbNotifications)
|
||||||
m_ctx->insert(QStringLiteral("has_db_notifications"), QLatin1String("1"));
|
m_ctx->insert(QStringLiteral("has_db_notifications"), QLatin1String("1"));
|
||||||
|
|
||||||
m_ctx->insert(QStringLiteral("library_target"), m_targetIsServer ? QStringLiteral("SERVER") : QStringLiteral("COMMON"));
|
m_ctx->insert(QStringLiteral("library_target"),
|
||||||
|
m_targetIsServer ? QStringLiteral("SERVER") : QStringLiteral("COMMON"));
|
||||||
|
|
||||||
exportUsedServices(reader);
|
exportUsedServices(reader);
|
||||||
|
|
||||||
|
|||||||
Executable → Regular
+5
-5
@@ -1,11 +1,11 @@
|
|||||||
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <QObject>
|
|
||||||
|
|
||||||
#include "GeneratorGrantleeBase.h"
|
#include "GeneratorGrantleeBase.h"
|
||||||
#include "StructBuilder.h"
|
|
||||||
#include "GrantleeWrappers.h"
|
#include "GrantleeWrappers.h"
|
||||||
|
#include "StructBuilder.h"
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
namespace CodeGen
|
namespace CodeGen
|
||||||
{
|
{
|
||||||
@@ -13,7 +13,6 @@ struct CompleteStructInformation;
|
|||||||
class StructBuilder;
|
class StructBuilder;
|
||||||
class XmlReader;
|
class XmlReader;
|
||||||
|
|
||||||
|
|
||||||
class DatabaseGeneratorGrantlee final : public GeneratorGrantleeBase
|
class DatabaseGeneratorGrantlee final : public GeneratorGrantleeBase
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -21,7 +20,8 @@ public:
|
|||||||
explicit DatabaseGeneratorGrantlee(bool targetIsServer);
|
explicit DatabaseGeneratorGrantlee(bool targetIsServer);
|
||||||
|
|
||||||
bool init(const XmlReader* reader, StructBuilder* structBuilder) override;
|
bool init(const XmlReader* reader, StructBuilder* structBuilder) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_targetIsServer;
|
bool m_targetIsServer;
|
||||||
};
|
};
|
||||||
}
|
} // namespace CodeGen
|
||||||
Executable → Regular
+16
-18
@@ -1,9 +1,10 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "GeneratorGrantleeBase.h"
|
#include "GeneratorGrantleeBase.h"
|
||||||
#include "XmlReader.h"
|
|
||||||
#include "GrantleeWrappers.h"
|
#include "GrantleeWrappers.h"
|
||||||
|
#include "XmlReader.h"
|
||||||
|
|
||||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
@@ -11,11 +12,13 @@
|
|||||||
#include <grantlee/engine.h>
|
#include <grantlee/engine.h>
|
||||||
|
|
||||||
using namespace CodeGen;
|
using namespace CodeGen;
|
||||||
|
|
||||||
GeneratorGrantleeBase::GeneratorGrantleeBase(const char *loggerName) : m_engine(new Grantlee::Engine)
|
GeneratorGrantleeBase::GeneratorGrantleeBase(const char *loggerName) : m_engine(new Grantlee::Engine)
|
||||||
, m_ctx(new Grantlee::Context)
|
, m_ctx(new Grantlee::Context)
|
||||||
, m_structBuilder(nullptr)
|
, m_structBuilder(nullptr)
|
||||||
.getNGLLogger(loggerName)),
|
.getNGLLogger(loggerName)),
|
||||||
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {
|
m_logger(NGL::NGLLoggerBootstrap::getLogger())
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
GeneratorGrantleeBase::~GeneratorGrantleeBase()
|
GeneratorGrantleeBase::~GeneratorGrantleeBase()
|
||||||
@@ -34,7 +37,8 @@ bool GeneratorGrantleeBase::initInternal(const XmlReader *reader, StructBuilder
|
|||||||
m_ctx->insert(QStringLiteral("namespace_abbr"), reader->getServiceAbbr().toLower());
|
m_ctx->insert(QStringLiteral("namespace_abbr"), reader->getServiceAbbr().toLower());
|
||||||
m_ctx->insert(QStringLiteral("namespace_abbr_upper"), reader->getServiceAbbr().toUpper());
|
m_ctx->insert(QStringLiteral("namespace_abbr_upper"), reader->getServiceAbbr().toUpper());
|
||||||
if (reader->getServiceNamespace() == QLatin1String("Core"))
|
if (reader->getServiceNamespace() == QLatin1String("Core"))
|
||||||
m_ctx->insert(QStringLiteral("include_prefix"), QStringLiteral("DDS/%1").arg(reader->getServiceNamespace()));
|
m_ctx->insert(QStringLiteral("include_prefix"),
|
||||||
|
QStringLiteral("DDS/%1").arg(reader->getServiceNamespace()));
|
||||||
else
|
else
|
||||||
m_ctx->insert(QStringLiteral("include_prefix"), reader->getServiceNamespace());
|
m_ctx->insert(QStringLiteral("include_prefix"), reader->getServiceNamespace());
|
||||||
m_ctx->insert(QStringLiteral("custom_record_replay"), reader->hasCustomRecordReplayPlugin());
|
m_ctx->insert(QStringLiteral("custom_record_replay"), reader->hasCustomRecordReplayPlugin());
|
||||||
@@ -47,8 +51,7 @@ bool GeneratorGrantleeBase::setTemplate(const QString &templateName, const QStri
|
|||||||
m_template = m_engine->newTemplate(tmpl, QStringLiteral("myTemplate"));
|
m_template = m_engine->newTemplate(tmpl, QStringLiteral("myTemplate"));
|
||||||
if (m_template->error())
|
if (m_template->error())
|
||||||
{
|
{
|
||||||
WARNING_LOG(m_logger) << "Error parsing template '" << templateName
|
WARNING_LOG(m_logger) << "Error parsing template '" << templateName << "': " << m_template->errorString();
|
||||||
<< "': " << m_template->errorString();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -67,9 +70,7 @@ QString GeneratorGrantleeBase::errorString() const
|
|||||||
return m_template->errorString();
|
return m_template->errorString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GeneratorGrantleeBase::generateData(const QString& templateName, const QString& outDirectory)
|
||||||
bool GeneratorGrantleeBase::generateData(const QString &templateName,
|
|
||||||
const QString &outDirectory)
|
|
||||||
{
|
{
|
||||||
QString content;
|
QString content;
|
||||||
if (!readFile(templateName, content))
|
if (!readFile(templateName, content))
|
||||||
@@ -83,12 +84,11 @@ bool GeneratorGrantleeBase::generateData(const QString &templateName,
|
|||||||
if (!getFilenameFromData(content, outFilename))
|
if (!getFilenameFromData(content, outFilename))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
||||||
QFile f(outDirectory + QLatin1Char('/') + outFilename);
|
QFile f(outDirectory + QLatin1Char('/') + outFilename);
|
||||||
if (!f.open(QIODevice::WriteOnly))
|
if (!f.open(QIODevice::WriteOnly))
|
||||||
{
|
{
|
||||||
ERROR_LOG(m_logger) << "Error opening file '" << f.fileName() << "' for writing: "
|
ERROR_LOG(m_logger) << "Error opening file '" << f.fileName() << "' for writing: " << f.errorString() << "("
|
||||||
<< f.errorString() << "(" << f.error() << ")";
|
<< f.error() << ")";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const QByteArray outData = content.toUtf8();
|
const QByteArray outData = content.toUtf8();
|
||||||
@@ -104,8 +104,7 @@ bool GeneratorGrantleeBase::readFile(const QString &filename, QString &data) con
|
|||||||
QFile f(filename);
|
QFile f(filename);
|
||||||
if (!f.open(QIODevice::ReadOnly))
|
if (!f.open(QIODevice::ReadOnly))
|
||||||
{
|
{
|
||||||
ERROR_LOG(m_logger) << "Error opening file " << filename
|
ERROR_LOG(m_logger) << "Error opening file " << filename << " - error: " << f.errorString();
|
||||||
<< " - error: " << f.errorString();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
data = QString::fromUtf8(f.readAll());
|
data = QString::fromUtf8(f.readAll());
|
||||||
@@ -120,8 +119,7 @@ bool GeneratorGrantleeBase::getFilenameFromData(const QString &dataToParse, QStr
|
|||||||
int idx = dataToParse.indexOf(filenameMarker);
|
int idx = dataToParse.indexOf(filenameMarker);
|
||||||
if (idx < 0)
|
if (idx < 0)
|
||||||
{
|
{
|
||||||
ERROR_LOG(m_logger) << "Could not find marker '" << filenameMarker
|
ERROR_LOG(m_logger) << "Could not find marker '" << filenameMarker << "' in data!";
|
||||||
<< "' in data!";
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
idx += filenameMarker.length() + 1;
|
idx += filenameMarker.length() + 1;
|
||||||
@@ -145,8 +143,8 @@ void GeneratorGrantleeBase::addCustomFunctions(const QVector<CustomServiceFuncti
|
|||||||
vlCustomDtcFunctions.reserve(customFunctions.size());
|
vlCustomDtcFunctions.reserve(customFunctions.size());
|
||||||
for (const CustomServiceFunctionInformation& csfi : customFunctions)
|
for (const CustomServiceFunctionInformation& csfi : customFunctions)
|
||||||
{
|
{
|
||||||
const QString signature(csfi.returnValue + QLatin1Char(' ') +
|
const QString signature(csfi.returnValue + QLatin1Char(' ') + csfi.methodName + QLatin1Char('(') +
|
||||||
csfi.methodName + QLatin1Char('(') + csfi.signature + QLatin1Char(')') +
|
csfi.signature + QLatin1Char(')') +
|
||||||
(csfi.isConst ? QStringLiteral(" const") : QString()));
|
(csfi.isConst ? QStringLiteral(" const") : QString()));
|
||||||
CustomFunctionWrapper* customFunctionWrapper(new CustomFunctionWrapper(signature, this));
|
CustomFunctionWrapper* customFunctionWrapper(new CustomFunctionWrapper(signature, this));
|
||||||
switch (csfi.type)
|
switch (csfi.type)
|
||||||
|
|||||||
Executable → Regular
+6
-4
@@ -3,6 +3,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "XmlReader.h"
|
#include "XmlReader.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QSharedPointer>
|
#include <QSharedPointer>
|
||||||
|
|
||||||
@@ -17,7 +18,8 @@ class Context;
|
|||||||
class Engine;
|
class Engine;
|
||||||
class TemplateImpl;
|
class TemplateImpl;
|
||||||
using Template = QSharedPointer<TemplateImpl>;
|
using Template = QSharedPointer<TemplateImpl>;
|
||||||
}
|
} // namespace Grantlee
|
||||||
|
|
||||||
namespace CodeGen
|
namespace CodeGen
|
||||||
{
|
{
|
||||||
class StructBuilder;
|
class StructBuilder;
|
||||||
@@ -31,8 +33,7 @@ public:
|
|||||||
bool setTemplate(const QString& templateName, const QString& tmpl);
|
bool setTemplate(const QString& templateName, const QString& tmpl);
|
||||||
QString render() const;
|
QString render() const;
|
||||||
QString errorString() const;
|
QString errorString() const;
|
||||||
bool generateData(const QString &templateName,
|
bool generateData(const QString& templateName, const QString& outDirectory);
|
||||||
const QString &outDirectory);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
NGL::INGLLogger& m_logger;
|
NGL::INGLLogger& m_logger;
|
||||||
@@ -43,6 +44,7 @@ protected:
|
|||||||
bool getFilenameFromData(const QString& dataToParse, QString& filename) const;
|
bool getFilenameFromData(const QString& dataToParse, QString& filename) const;
|
||||||
void addCustomFunctions(const QVector<CustomServiceFunctionInformation>& customFunctions);
|
void addCustomFunctions(const QVector<CustomServiceFunctionInformation>& customFunctions);
|
||||||
void exportUsedServices(const XmlReader* reader);
|
void exportUsedServices(const XmlReader* reader);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
NGL::INGLLogger& m_logger;
|
NGL::INGLLogger& m_logger;
|
||||||
Grantlee::Engine* m_engine;
|
Grantlee::Engine* m_engine;
|
||||||
@@ -50,4 +52,4 @@ protected:
|
|||||||
Grantlee::Template m_template;
|
Grantlee::Template m_template;
|
||||||
StructBuilder* m_structBuilder;
|
StructBuilder* m_structBuilder;
|
||||||
};
|
};
|
||||||
}
|
} // namespace CodeGen
|
||||||
Executable → Regular
+31
-78
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "GrantleeWrappers.h"
|
#include "GrantleeWrappers.h"
|
||||||
|
|
||||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
@@ -48,77 +48,50 @@ QString MemberInformationWrapper::ddsToQVariant() const
|
|||||||
|
|
||||||
QString MemberInformationWrapper::qVariantToDds() const
|
QString MemberInformationWrapper::qVariantToDds() const
|
||||||
{
|
{
|
||||||
const QString ddsType = isOptional() ?
|
const QString ddsType =
|
||||||
(QStringLiteral("dds::core::optional<") + cppDdsType() + QLatin1Char('>')) :
|
isOptional() ? (QStringLiteral("dds::core::optional<") + cppDdsType() + QLatin1Char('>')) : (cppDdsType());
|
||||||
(cppDdsType());
|
|
||||||
|
|
||||||
return QStringLiteral("data.") + cppMemberName() +
|
return QStringLiteral("data.") + cppMemberName() + QStringLiteral("() = fromQVariant<") + ddsType +
|
||||||
QStringLiteral("() = fromQVariant<") + ddsType + QStringLiteral(">(q.value(i++))");
|
QStringLiteral(">(q.value(i++))");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString MemberInformationWrapper::ddsToJsonElement() const
|
QString MemberInformationWrapper::ddsToJsonElement() const
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (cppMemberName().isEmpty())
|
if (cppMemberName().isEmpty())
|
||||||
return QStringLiteral("obj[QStringLiteral(\"") + cppType() + QStringLiteral("\")] = element;");
|
return QStringLiteral("obj[QStringLiteral(\"") + cppType() + QStringLiteral("\")] = element;");
|
||||||
|
|
||||||
const QString memberAccess = isCppStruct() ? cppMemberName() : cppMemberName() + QStringLiteral("()");
|
const QString memberAccess = isCppStruct() ? cppMemberName() : cppMemberName() + QStringLiteral("()");
|
||||||
if (!isOptional())
|
if (!isOptional())
|
||||||
return QStringLiteral("obj[QStringLiteral(\"") + cppMemberName() + QStringLiteral("\")] = ") +
|
return QStringLiteral("obj[QStringLiteral(\"") + cppMemberName() + QStringLiteral("\")] = ") + cppToJsonPre() +
|
||||||
cppToJsonPre() + QStringLiteral("element.") + memberAccess + cppToJsonPost();
|
QStringLiteral("element.") + memberAccess + cppToJsonPost();
|
||||||
|
|
||||||
const QString optionalAccess = isCppStruct() ? cppMemberName() + QStringLiteral(".is_set()") : cppMemberName() + QStringLiteral("().is_set()");
|
const QString optionalAccess =
|
||||||
|
isCppStruct() ? cppMemberName() + QStringLiteral(".is_set()") : cppMemberName() + QStringLiteral("().is_set()");
|
||||||
const QString getValue = isCppStruct() ? cppMemberName() : cppMemberName() + QStringLiteral("()");
|
const QString getValue = isCppStruct() ? cppMemberName() : cppMemberName() + QStringLiteral("()");
|
||||||
return QStringLiteral("if (element.") + optionalAccess + QStringLiteral(") ") +
|
return QStringLiteral("if (element.") + optionalAccess + QStringLiteral(") ") +
|
||||||
QStringLiteral("obj[QStringLiteral(\"") + cppMemberName() + QStringLiteral("\")] = ") +
|
QStringLiteral("obj[QStringLiteral(\"") + cppMemberName() + QStringLiteral("\")] = ") + cppToJsonPre() +
|
||||||
cppToJsonPre() + QStringLiteral("element.") + getValue + cppToJsonPost();
|
QStringLiteral("element.") + getValue + cppToJsonPost();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString MemberInformationWrapper::jsonElementToDds() const
|
QString MemberInformationWrapper::jsonElementToDds() const
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (cppMemberName().isEmpty())
|
if (cppMemberName().isEmpty())
|
||||||
return QStringLiteral("element = ") +
|
return QStringLiteral("element = ") + cppFromQvPre2() + QStringLiteral("objElement.value(QStringLiteral(\"") +
|
||||||
cppFromQvPre2() + QStringLiteral("objElement.value(QStringLiteral(\"") + cppType() + QStringLiteral("\"))") + cppFromJsonPost();
|
cppType() + QStringLiteral("\"))") + cppFromJsonPost();
|
||||||
|
|
||||||
QString ret(QStringLiteral("const QJsonValue val(objElement.value(QStringLiteral(\"") + cppMemberName() + QStringLiteral("\"))); "));
|
QString ret(QStringLiteral("const QJsonValue val(objElement.value(QStringLiteral(\"") + cppMemberName() +
|
||||||
|
QStringLiteral("\"))); "));
|
||||||
if (isOptional())
|
if (isOptional())
|
||||||
ret += QStringLiteral("if (!val.isNull()) ");
|
ret += QStringLiteral("if (!val.isNull()) ");
|
||||||
|
|
||||||
if (isCppStruct())
|
if (isCppStruct())
|
||||||
ret += QStringLiteral("element.") + cppMemberName() + QStringLiteral(" = ") +
|
ret += QStringLiteral("element.") + cppMemberName() + QStringLiteral(" = ") + cppFromJsonPre2() +
|
||||||
cppFromJsonPre2() + QStringLiteral("val") + cppFromJsonPost();
|
QStringLiteral("val") + cppFromJsonPost();
|
||||||
else
|
else
|
||||||
ret += QStringLiteral("element.") + cppMemberName() + QStringLiteral("(") +
|
ret += QStringLiteral("element.") + cppMemberName() + QStringLiteral("(") + cppFromJsonPre2() +
|
||||||
cppFromJsonPre2() + QStringLiteral("val") + cppFromJsonPost() + QStringLiteral(")");
|
QStringLiteral("val") + cppFromJsonPost() + QStringLiteral(")");
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -126,56 +99,39 @@ QString MemberInformationWrapper::jsonElementToDds() const
|
|||||||
QString MemberInformationWrapper::dbToJsonElement() const
|
QString MemberInformationWrapper::dbToJsonElement() const
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (cppMemberName().isEmpty())
|
if (cppMemberName().isEmpty())
|
||||||
return QStringLiteral("obj[QStringLiteral(\"") + cppType() + QStringLiteral("\")] = element;");
|
return QStringLiteral("obj[QStringLiteral(\"") + cppType() + QStringLiteral("\")] = element;");
|
||||||
|
|
||||||
if (isOptional() || cppType() == QStringLiteral("QDateTime"))
|
if (isOptional() || cppType() == QStringLiteral("QDateTime"))
|
||||||
{
|
{
|
||||||
QString ret = QStringLiteral("if (") + ((cppType() == QStringLiteral("QDateTime")) ? QString() : QStringLiteral("!")) +
|
QString ret = QStringLiteral("if (") +
|
||||||
|
((cppType() == QStringLiteral("QDateTime")) ? QString() : QStringLiteral("!")) +
|
||||||
QStringLiteral("element.") + cppMemberName() +
|
QStringLiteral("element.") + cppMemberName() +
|
||||||
((cppType() == QStringLiteral("QDateTime")) ? QStringLiteral(".isValid()) ") : QStringLiteral(".isNull()) ")) +
|
((cppType() == QStringLiteral("QDateTime")) ? QStringLiteral(".isValid()) ")
|
||||||
|
: QStringLiteral(".isNull()) ")) +
|
||||||
QStringLiteral("obj[QStringLiteral(\"") + cppMemberName() + QStringLiteral("\")] = ");
|
QStringLiteral("obj[QStringLiteral(\"") + cppMemberName() + QStringLiteral("\")] = ");
|
||||||
if (isOptional())
|
if (isOptional())
|
||||||
return ret += cppFromQvPre2() + QStringLiteral("element.") + cppMemberName() + cppFromQvPost();
|
return ret += cppFromQvPre2() + QStringLiteral("element.") + cppMemberName() + cppFromQvPost();
|
||||||
}
|
}
|
||||||
|
|
||||||
return QStringLiteral("obj[QStringLiteral(\"") + cppMemberName() + QStringLiteral("\")] = ") +
|
return QStringLiteral("obj[QStringLiteral(\"") + cppMemberName() + QStringLiteral("\")] = ") + cppToJsonPre() +
|
||||||
cppToJsonPre() + QStringLiteral("element.") + cppMemberName() + cppToJsonPost();
|
QStringLiteral("element.") + cppMemberName() + cppToJsonPost();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString MemberInformationWrapper::jsonElementToDb() const
|
QString MemberInformationWrapper::jsonElementToDb() const
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (cppMemberName().isEmpty())
|
if (cppMemberName().isEmpty())
|
||||||
return QStringLiteral("element = ") +
|
return QStringLiteral("element = ") + cppFromQvPre2() + QStringLiteral("objElement.value(QStringLiteral(\"") +
|
||||||
cppFromQvPre2() + QStringLiteral("objElement.value(QStringLiteral(\"") + cppType() + QStringLiteral("\"))") + cppFromJsonPost();
|
cppType() + QStringLiteral("\"))") + cppFromJsonPost();
|
||||||
|
|
||||||
QString ret(QStringLiteral("const QJsonValue val(objElement.value(QStringLiteral(\"") + cppMemberName() + QStringLiteral("\"))); "));
|
QString ret(QStringLiteral("const QJsonValue val(objElement.value(QStringLiteral(\"") + cppMemberName() +
|
||||||
|
QStringLiteral("\"))); "));
|
||||||
if (isOptional())
|
if (isOptional())
|
||||||
ret += QStringLiteral("if (!val.isUndefined()) ");
|
ret += QStringLiteral("if (!val.isUndefined()) ");
|
||||||
|
|
||||||
ret += QStringLiteral("element.") + cppMemberName() + QStringLiteral(" = ") +
|
ret += QStringLiteral("element.") + cppMemberName() + QStringLiteral(" = ") + cppFromJsonPre2() +
|
||||||
cppFromJsonPre2() + QStringLiteral("val") + cppFromJsonPost();
|
QStringLiteral("val") + cppFromJsonPost();
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -211,7 +167,6 @@ QVariantList DbStructWrapper::insertStructures()
|
|||||||
fkComplexTableKeys[mi->info().db.table] = mi;
|
fkComplexTableKeys[mi->info().db.table] = mi;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QVariantList vl;
|
QVariantList vl;
|
||||||
vl.reserve(tableNames.size());
|
vl.reserve(tableNames.size());
|
||||||
for (int i = 0; i < tableNames.size(); ++i)
|
for (int i = 0; i < tableNames.size(); ++i)
|
||||||
@@ -223,8 +178,6 @@ QVariantList DbStructWrapper::insertStructures()
|
|||||||
if (i == 0 && tableNames.size() > 1)
|
if (i == 0 && tableNames.size() > 1)
|
||||||
baseId = primaryKeys.value(tn);
|
baseId = primaryKeys.value(tn);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (tableNames.size() == 1)
|
if (tableNames.size() == 1)
|
||||||
{
|
{
|
||||||
baseId = nullptr;
|
baseId = nullptr;
|
||||||
|
|||||||
Executable → Regular
+420
-144
@@ -1,13 +1,13 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "StructBuilder.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include "StructBuilder.h"
|
|
||||||
|
|
||||||
#ifdef RTI_HEADER_AVAILABLE
|
#ifdef RTI_HEADER_AVAILABLE
|
||||||
#include <dds/core/xtypes/EnumType.hpp>
|
#include <dds/core/xtypes/EnumType.hpp>
|
||||||
@@ -22,14 +22,23 @@ class NameWrapper : public QObject
|
|||||||
Q_PROPERTY(QString nameCc READ nameCc)
|
Q_PROPERTY(QString nameCc READ nameCc)
|
||||||
Q_PROPERTY(QString nameFlc READ nameFlc)
|
Q_PROPERTY(QString nameFlc READ nameFlc)
|
||||||
public:
|
public:
|
||||||
NameWrapper(const QString &name, QObject *parent)
|
NameWrapper(const QString& name, QObject* parent) : QObject(parent), m_name(name) {}
|
||||||
: QObject(parent)
|
|
||||||
, m_name(name)
|
QString name() const
|
||||||
{}
|
{
|
||||||
|
return m_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString nameCc() const
|
||||||
|
{
|
||||||
|
return StructBuilder::camelCaseString(name(), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString nameFlc() const
|
||||||
|
{
|
||||||
|
return StructBuilder::firstCharLowercase(nameCc());
|
||||||
|
}
|
||||||
|
|
||||||
QString name() const { return m_name; }
|
|
||||||
QString nameCc() const { return StructBuilder::camelCaseString(name(), true); }
|
|
||||||
QString nameFlc() const { return StructBuilder::firstCharLowercase(nameCc()); }
|
|
||||||
private:
|
private:
|
||||||
const QString m_name;
|
const QString m_name;
|
||||||
};
|
};
|
||||||
@@ -39,8 +48,8 @@ class VariantListWrapper : public NameWrapper
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(QVariantList member READ member)
|
Q_PROPERTY(QVariantList member READ member)
|
||||||
public:
|
public:
|
||||||
|
|
||||||
using NameWrapper::NameWrapper;
|
using NameWrapper::NameWrapper;
|
||||||
|
|
||||||
~VariantListWrapper()
|
~VariantListWrapper()
|
||||||
{
|
{
|
||||||
for (const QVariant& v : std::as_const(m_member))
|
for (const QVariant& v : std::as_const(m_member))
|
||||||
@@ -50,12 +59,15 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantList member() const { return m_member; }
|
QVariantList member() const
|
||||||
|
{
|
||||||
|
return m_member;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QVariantList m_member;
|
QVariantList m_member;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class MemberInformationWrapper final : public QObject
|
class MemberInformationWrapper final : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -82,45 +94,125 @@ class MemberInformationWrapper final : public QObject
|
|||||||
Q_PROPERTY(bool isOptional READ isOptional)
|
Q_PROPERTY(bool isOptional READ isOptional)
|
||||||
Q_PROPERTY(bool isCppStruct READ isCppStruct)
|
Q_PROPERTY(bool isCppStruct READ isCppStruct)
|
||||||
public:
|
public:
|
||||||
MemberInformationWrapper(const MemberInformation &mi, QObject *parent)
|
MemberInformationWrapper(const MemberInformation& mi, QObject* parent) : QObject(parent), m_mi(mi) {}
|
||||||
: QObject(parent)
|
|
||||||
, m_mi(mi)
|
QString cppMemberName() const
|
||||||
{}
|
{
|
||||||
|
return m_mi.cpp.memberName;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString cppMemberNameCc() const
|
||||||
|
{
|
||||||
|
return StructBuilder::camelCaseString(m_mi.cpp.memberName, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString cppStructName() const
|
||||||
|
{
|
||||||
|
return m_mi.cpp.structName;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString cppType() const
|
||||||
|
{
|
||||||
|
return m_mi.cpp.type;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString cppToQvPre() const
|
||||||
|
{
|
||||||
|
return m_mi.cpp.toVariantPre;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString cppToQvPost() const
|
||||||
|
{
|
||||||
|
return m_mi.cpp.toVariantPost;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString cppFromQvPre1() const
|
||||||
|
{
|
||||||
|
return m_mi.cpp.fromVariantPre1;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString cppFromQvPre2() const
|
||||||
|
{
|
||||||
|
return m_mi.cpp.fromVariantPre2;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString cppFromQvPost() const
|
||||||
|
{
|
||||||
|
return m_mi.cpp.fromVariantPost;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString cppDefault() const
|
||||||
|
{
|
||||||
|
return m_mi.cpp.defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString dbTableName() const
|
||||||
|
{
|
||||||
|
return m_mi.db.table;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString dbColumnName() const
|
||||||
|
{
|
||||||
|
return m_mi.db.columnName;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString dbColumnNameView() const
|
||||||
|
{
|
||||||
|
return m_mi.db.getColumnNameView();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString cppDdsType() const
|
||||||
|
{
|
||||||
|
return m_mi.cpp.ddsType.isEmpty() ? cppType() : m_mi.cpp.ddsType;
|
||||||
|
}
|
||||||
|
|
||||||
QString cppMemberName() const { return m_mi.cpp.memberName; }
|
|
||||||
QString cppMemberNameCc() const { return StructBuilder::camelCaseString(m_mi.cpp.memberName, true); }
|
|
||||||
QString cppStructName() const { return m_mi.cpp.structName; }
|
|
||||||
QString cppType() const { return m_mi.cpp.type; }
|
|
||||||
QString cppToQvPre() const { return m_mi.cpp.toVariantPre; }
|
|
||||||
QString cppToQvPost() const { return m_mi.cpp.toVariantPost; }
|
|
||||||
QString cppFromQvPre1() const { return m_mi.cpp.fromVariantPre1; }
|
|
||||||
QString cppFromQvPre2() const { return m_mi.cpp.fromVariantPre2; }
|
|
||||||
QString cppFromQvPost() const { return m_mi.cpp.fromVariantPost; }
|
|
||||||
QString cppDefault() const { return m_mi.cpp.defaultValue; }
|
|
||||||
QString dbTableName() const { return m_mi.db.table; }
|
|
||||||
QString dbColumnName() const { return m_mi.db.columnName; }
|
|
||||||
QString dbColumnNameView() const { return m_mi.db.getColumnNameView(); }
|
|
||||||
QString cppDdsType() const { return m_mi.cpp.ddsType.isEmpty() ? cppType() : m_mi.cpp.ddsType; }
|
|
||||||
QString ddsToQVariant() const;
|
QString ddsToQVariant() const;
|
||||||
QString qVariantToDds() const;
|
QString qVariantToDds() const;
|
||||||
QString ddsToJsonElement() const;
|
QString ddsToJsonElement() const;
|
||||||
QString jsonElementToDds() const;
|
QString jsonElementToDds() const;
|
||||||
QString dbToJsonElement() const;
|
QString dbToJsonElement() const;
|
||||||
QString jsonElementToDb() const;
|
QString jsonElementToDb() const;
|
||||||
bool dbHasSequence() const { return m_mi.db.hasSequence; }
|
|
||||||
bool isOptional() const { return m_mi.cpp.isOptional; }
|
|
||||||
bool isCppStruct() const { return m_mi.cpp.usedForCppStruct; }
|
|
||||||
|
|
||||||
|
bool dbHasSequence() const
|
||||||
|
{
|
||||||
|
return m_mi.db.hasSequence;
|
||||||
|
}
|
||||||
|
|
||||||
QString cppToJsonPre() const { return m_mi.cpp.toJsonPre.isNull() ? m_mi.cpp.toVariantPre : m_mi.cpp.toJsonPre; }
|
bool isOptional() const
|
||||||
QString cppToJsonPost() const { return m_mi.cpp.toJsonPost.isNull() ? m_mi.cpp.toVariantPost : m_mi.cpp.toJsonPost; }
|
{
|
||||||
QString cppFromJsonPre2() const { return m_mi.cpp.fromJsonPre2.isNull() ? m_mi.cpp.fromVariantPre2: m_mi.cpp.fromJsonPre2; }
|
return m_mi.cpp.isOptional;
|
||||||
QString cppFromJsonPost() const { return m_mi.cpp.fromJsonPost.isNull() ? m_mi.cpp.fromVariantPost : m_mi.cpp.fromJsonPost; }
|
}
|
||||||
|
|
||||||
|
bool isCppStruct() const
|
||||||
|
{
|
||||||
|
return m_mi.cpp.usedForCppStruct;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString cppToJsonPre() const
|
||||||
|
{
|
||||||
|
return m_mi.cpp.toJsonPre.isNull() ? m_mi.cpp.toVariantPre : m_mi.cpp.toJsonPre;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString cppToJsonPost() const
|
||||||
|
{
|
||||||
|
return m_mi.cpp.toJsonPost.isNull() ? m_mi.cpp.toVariantPost : m_mi.cpp.toJsonPost;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString cppFromJsonPre2() const
|
||||||
|
{
|
||||||
|
return m_mi.cpp.fromJsonPre2.isNull() ? m_mi.cpp.fromVariantPre2 : m_mi.cpp.fromJsonPre2;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString cppFromJsonPost() const
|
||||||
|
{
|
||||||
|
return m_mi.cpp.fromJsonPost.isNull() ? m_mi.cpp.fromVariantPost : m_mi.cpp.fromJsonPost;
|
||||||
|
}
|
||||||
|
|
||||||
MemberInformation info() const
|
MemberInformation info() const
|
||||||
{
|
{
|
||||||
return m_mi;
|
return m_mi;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const MemberInformation m_mi;
|
const MemberInformation m_mi;
|
||||||
};
|
};
|
||||||
@@ -136,7 +228,8 @@ class MemberInformationListWrapper : public VariantListWrapper
|
|||||||
Q_PROPERTY(MemberInformationWrapper* ddsKey READ ddsKey)
|
Q_PROPERTY(MemberInformationWrapper* ddsKey READ ddsKey)
|
||||||
Q_PROPERTY(MemberInformationWrapper* primaryKey READ primaryKey)
|
Q_PROPERTY(MemberInformationWrapper* primaryKey READ primaryKey)
|
||||||
public:
|
public:
|
||||||
explicit MemberInformationListWrapper(const QString &name, const QVector<MemberInformation> &member, QObject *parent)
|
explicit MemberInformationListWrapper(const QString& name, const QVector<MemberInformation>& member,
|
||||||
|
QObject* parent)
|
||||||
: VariantListWrapper(name, parent)
|
: VariantListWrapper(name, parent)
|
||||||
{
|
{
|
||||||
for (const MemberInformation& mi : member)
|
for (const MemberInformation& mi : member)
|
||||||
@@ -160,22 +253,27 @@ public:
|
|||||||
{
|
{
|
||||||
return memberByFilter([](const MemberInformation& mi) { return mi.cpp.usedForCppStruct; });
|
return memberByFilter([](const MemberInformation& mi) { return mi.cpp.usedForCppStruct; });
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantList jsonMember() const
|
QVariantList jsonMember() const
|
||||||
{
|
{
|
||||||
return memberByFilter([](const MemberInformation& mi) { return mi.cpp.usedForJson; });
|
return memberByFilter([](const MemberInformation& mi) { return mi.cpp.usedForJson; });
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantList fkMember() const
|
QVariantList fkMember() const
|
||||||
{
|
{
|
||||||
return memberByFilter([](const MemberInformation& mi) { return mi.db.isForeignKey; });
|
return memberByFilter([](const MemberInformation& mi) { return mi.db.isForeignKey; });
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantList selectRemoveMember() const
|
QVariantList selectRemoveMember() const
|
||||||
{
|
{
|
||||||
return memberByFilter([](const MemberInformation& mi) { return mi.db.generateSelectRemove; });
|
return memberByFilter([](const MemberInformation& mi) { return mi.db.generateSelectRemove; });
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantList viewMember() const
|
QVariantList viewMember() const
|
||||||
{
|
{
|
||||||
return memberByFilter([](const MemberInformation& mi) { return mi.db.usedForView; });
|
return memberByFilter([](const MemberInformation& mi) { return mi.db.usedForView; });
|
||||||
}
|
}
|
||||||
|
|
||||||
MemberInformationWrapper* ddsKey() const
|
MemberInformationWrapper* ddsKey() const
|
||||||
{
|
{
|
||||||
for (const QVariant& v : m_member)
|
for (const QVariant& v : m_member)
|
||||||
@@ -186,6 +284,7 @@ public:
|
|||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
MemberInformationWrapper* primaryKey() const
|
MemberInformationWrapper* primaryKey() const
|
||||||
{
|
{
|
||||||
for (const QVariant& v : m_member)
|
for (const QVariant& v : m_member)
|
||||||
@@ -198,7 +297,6 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class TableWrapper final : public NameWrapper
|
class TableWrapper final : public NameWrapper
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -206,29 +304,37 @@ class TableWrapper final : public NameWrapper
|
|||||||
|
|
||||||
Q_PROPERTY(MemberInformationWrapper* serialMember READ serialMember)
|
Q_PROPERTY(MemberInformationWrapper* serialMember READ serialMember)
|
||||||
|
|
||||||
|
|
||||||
Q_PROPERTY(MemberInformationWrapper* baseId READ baseId)
|
Q_PROPERTY(MemberInformationWrapper* baseId READ baseId)
|
||||||
|
|
||||||
Q_PROPERTY(MemberInformationWrapper* primaryKey READ primaryKey)
|
Q_PROPERTY(MemberInformationWrapper* primaryKey READ primaryKey)
|
||||||
public:
|
public:
|
||||||
|
explicit TableWrapper(const QString& name, const QVector<MemberInformationWrapper*>& member,
|
||||||
|
MemberInformationWrapper* serialMember, MemberInformationWrapper* baseId,
|
||||||
|
MemberInformationWrapper* primaryKey, QObject* parent)
|
||||||
|
: NameWrapper(name, parent), m_member(member), m_serialMember(serialMember), m_baseId(baseId),
|
||||||
|
m_primaryKey(primaryKey)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
explicit TableWrapper(const QString &name,
|
QVector<MemberInformationWrapper*> member() const
|
||||||
const QVector<MemberInformationWrapper *> &member,
|
{
|
||||||
MemberInformationWrapper *serialMember,
|
return m_member;
|
||||||
MemberInformationWrapper *baseId,
|
}
|
||||||
MemberInformationWrapper *primaryKey,
|
|
||||||
QObject *parent)
|
|
||||||
: NameWrapper(name, parent)
|
|
||||||
, m_member(member)
|
|
||||||
, m_serialMember(serialMember)
|
|
||||||
, m_baseId(baseId)
|
|
||||||
, m_primaryKey(primaryKey)
|
|
||||||
{}
|
|
||||||
|
|
||||||
QVector<MemberInformationWrapper *> member() const { return m_member; }
|
MemberInformationWrapper* serialMember() const
|
||||||
MemberInformationWrapper *serialMember() const { return m_serialMember; }
|
{
|
||||||
MemberInformationWrapper *baseId() const { return m_baseId; }
|
return m_serialMember;
|
||||||
MemberInformationWrapper *primaryKey() const { return m_primaryKey; }
|
}
|
||||||
|
|
||||||
|
MemberInformationWrapper* baseId() const
|
||||||
|
{
|
||||||
|
return m_baseId;
|
||||||
|
}
|
||||||
|
|
||||||
|
MemberInformationWrapper* primaryKey() const
|
||||||
|
{
|
||||||
|
return m_primaryKey;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QVector<MemberInformationWrapper*> m_member;
|
QVector<MemberInformationWrapper*> m_member;
|
||||||
@@ -248,8 +354,7 @@ class DbStructWrapper final : public MemberInformationListWrapper
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DbStructWrapper(const CompleteStructInformation& csi, QObject* parent)
|
explicit DbStructWrapper(const CompleteStructInformation& csi, QObject* parent)
|
||||||
: MemberInformationListWrapper(csi.structName, csi.member, parent)
|
: MemberInformationListWrapper(csi.structName, csi.member, parent), m_csi(csi)
|
||||||
, m_csi(csi)
|
|
||||||
{
|
{
|
||||||
m_dbNotifications.reserve(m_csi.dbNotifications.size());
|
m_dbNotifications.reserve(m_csi.dbNotifications.size());
|
||||||
for (const auto& notification : std::as_const(m_csi.dbNotifications))
|
for (const auto& notification : std::as_const(m_csi.dbNotifications))
|
||||||
@@ -266,12 +371,29 @@ public:
|
|||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantList insertStructures();
|
QVariantList insertStructures();
|
||||||
|
|
||||||
bool deleteWithoutPkAllowed() const { return m_csi.tables.size() == 1; }
|
bool deleteWithoutPkAllowed() const
|
||||||
QVariantList dbNotifications() const { return m_dbNotifications; }
|
{
|
||||||
QString primaryTableName() const { return m_csi.primaryTable->name; }
|
return m_csi.tables.size() == 1;
|
||||||
QString viewTableName() const { return (m_csi.tables.size() == 1) ? primaryTableName() : m_csi.viewName; }
|
}
|
||||||
|
|
||||||
|
QVariantList dbNotifications() const
|
||||||
|
{
|
||||||
|
return m_dbNotifications;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString primaryTableName() const
|
||||||
|
{
|
||||||
|
return m_csi.primaryTable->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString viewTableName() const
|
||||||
|
{
|
||||||
|
return (m_csi.tables.size() == 1) ? primaryTableName() : m_csi.viewName;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const CompleteStructInformation m_csi;
|
const CompleteStructInformation m_csi;
|
||||||
QVariantList m_dbNotifications;
|
QVariantList m_dbNotifications;
|
||||||
@@ -282,29 +404,36 @@ class CustomFunctionWrapper final : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(QString signature READ signature)
|
Q_PROPERTY(QString signature READ signature)
|
||||||
public:
|
public:
|
||||||
explicit CustomFunctionWrapper(const QString &signature, QObject *parent)
|
explicit CustomFunctionWrapper(const QString& signature, QObject* parent) : QObject(parent), m_signature(signature)
|
||||||
: QObject(parent)
|
{
|
||||||
, m_signature(signature)
|
}
|
||||||
{}
|
|
||||||
QString signature() const { return m_signature; }
|
QString signature() const
|
||||||
|
{
|
||||||
|
return m_signature;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const QString m_signature;
|
const QString m_signature;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class IdlEnumKeyValueWrapper final : public QObject
|
class IdlEnumKeyValueWrapper final : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(QString key READ key)
|
Q_PROPERTY(QString key READ key)
|
||||||
Q_PROPERTY(int value READ value)
|
Q_PROPERTY(int value READ value)
|
||||||
public:
|
public:
|
||||||
explicit IdlEnumKeyValueWrapper(const EnumKeyValuePair &ekvp, QObject *parent)
|
explicit IdlEnumKeyValueWrapper(const EnumKeyValuePair& ekvp, QObject* parent) : QObject(parent), m_ekvp(ekvp) {}
|
||||||
: QObject(parent)
|
|
||||||
, m_ekvp(ekvp)
|
|
||||||
{}
|
|
||||||
|
|
||||||
QString key() const { return m_ekvp.key; }
|
QString key() const
|
||||||
int value() const { return m_ekvp.value; }
|
{
|
||||||
|
return m_ekvp.key;
|
||||||
|
}
|
||||||
|
|
||||||
|
int value() const
|
||||||
|
{
|
||||||
|
return m_ekvp.value;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const EnumKeyValuePair m_ekvp;
|
const EnumKeyValuePair m_ekvp;
|
||||||
@@ -321,19 +450,43 @@ class IdlDataWrapper final : public NameWrapper
|
|||||||
Q_PROPERTY(QString cppTypeCr READ cppTypeCr)
|
Q_PROPERTY(QString cppTypeCr READ cppTypeCr)
|
||||||
Q_PROPERTY(QString nameGetter READ nameGetter)
|
Q_PROPERTY(QString nameGetter READ nameGetter)
|
||||||
public:
|
public:
|
||||||
IdlDataWrapper(const IdlData &data,
|
IdlDataWrapper(const IdlData& data, QObject* parent) : NameWrapper(data.name, parent), m_data(data) {}
|
||||||
QObject *parent)
|
|
||||||
: NameWrapper(data.name, parent)
|
QString type() const
|
||||||
, m_data(data)
|
{
|
||||||
{}
|
return m_data.dataTypeInfo->idlType();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString comment() const
|
||||||
|
{
|
||||||
|
return m_data.comment;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString isKey() const
|
||||||
|
{
|
||||||
|
return m_data.isKey ? QStringLiteral(" \t //@key") : QString();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString isOptional() const
|
||||||
|
{
|
||||||
|
return m_data.isOptional ? QStringLiteral(" \t //@Optional") : QString();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString cppType() const
|
||||||
|
{
|
||||||
|
return m_data.dataTypeInfo->cppType();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString cppTypeCr() const
|
||||||
|
{
|
||||||
|
return m_data.dataTypeInfo->cppTypeConstRef();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString nameGetter() const
|
||||||
|
{
|
||||||
|
return m_data.name + (m_data.isOptional ? QStringLiteral("().get") : QString());
|
||||||
|
}
|
||||||
|
|
||||||
QString type() const { return m_data.dataTypeInfo->idlType(); }
|
|
||||||
QString comment() const { return m_data.comment; }
|
|
||||||
QString isKey() const { return m_data.isKey ? QStringLiteral(" \t //@key") : QString(); }
|
|
||||||
QString isOptional() const { return m_data.isOptional ? QStringLiteral(" \t //@Optional") : QString(); }
|
|
||||||
QString cppType() const { return m_data.dataTypeInfo->cppType(); }
|
|
||||||
QString cppTypeCr() const { return m_data.dataTypeInfo->cppTypeConstRef(); }
|
|
||||||
QString nameGetter() const { return m_data.name + (m_data.isOptional ? QStringLiteral("().get") : QString()); }
|
|
||||||
private:
|
private:
|
||||||
const IdlData m_data;
|
const IdlData m_data;
|
||||||
};
|
};
|
||||||
@@ -342,8 +495,7 @@ class IdlEnumWrapper final : public VariantListWrapper
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit IdlEnumWrapper(const EnumInformation &ei, QObject *parent)
|
explicit IdlEnumWrapper(const EnumInformation& ei, QObject* parent) : VariantListWrapper(ei.enumName, parent)
|
||||||
: VariantListWrapper(ei.enumName, parent)
|
|
||||||
{
|
{
|
||||||
m_member.reserve(ei.values.size());
|
m_member.reserve(ei.values.size());
|
||||||
for (const auto& val : ei.values)
|
for (const auto& val : ei.values)
|
||||||
@@ -359,17 +511,27 @@ class IdlStructWrapper final : public VariantListWrapper
|
|||||||
Q_PROPERTY(QString extensibility READ extensibility)
|
Q_PROPERTY(QString extensibility READ extensibility)
|
||||||
public:
|
public:
|
||||||
explicit IdlStructWrapper(const CompleteTopicTypeInformation& ctti, QObject* parent)
|
explicit IdlStructWrapper(const CompleteTopicTypeInformation& ctti, QObject* parent)
|
||||||
: VariantListWrapper(ctti.name, parent)
|
: VariantListWrapper(ctti.name, parent), m_ctti(ctti)
|
||||||
, m_ctti(ctti)
|
|
||||||
{
|
{
|
||||||
m_member.reserve(m_ctti.members.size());
|
m_member.reserve(m_ctti.members.size());
|
||||||
for (const auto& val : std::as_const(m_ctti.members))
|
for (const auto& val : std::as_const(m_ctti.members))
|
||||||
m_member += QVariant::fromValue(new IdlDataWrapper(val, this));
|
m_member += QVariant::fromValue(new IdlDataWrapper(val, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
QString comment() const { return m_ctti.comment; }
|
QString comment() const
|
||||||
QString baseValueType() const { return m_ctti.baseValueType; }
|
{
|
||||||
QString extensibility() const { return extensibility2String(m_ctti.extensibility); }
|
return m_ctti.comment;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString baseValueType() const
|
||||||
|
{
|
||||||
|
return m_ctti.baseValueType;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString extensibility() const
|
||||||
|
{
|
||||||
|
return extensibility2String(m_ctti.extensibility);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const CompleteTopicTypeInformation m_ctti;
|
const CompleteTopicTypeInformation m_ctti;
|
||||||
@@ -387,11 +549,20 @@ class IdlServiceWrapper final : public QObject
|
|||||||
Q_PROPERTY(QString baseFilePath READ baseFilePath)
|
Q_PROPERTY(QString baseFilePath READ baseFilePath)
|
||||||
public:
|
public:
|
||||||
IdlServiceWrapper(const QString& svcName, const QString& baseFilePath)
|
IdlServiceWrapper(const QString& svcName, const QString& baseFilePath)
|
||||||
: m_svcName(svcName)
|
: m_svcName(svcName), m_baseFilePath(baseFilePath)
|
||||||
, m_baseFilePath(baseFilePath)
|
{
|
||||||
{}
|
}
|
||||||
QString svcName() const { return m_svcName; }
|
|
||||||
QString baseFilePath() const { return m_baseFilePath; }
|
QString svcName() const
|
||||||
|
{
|
||||||
|
return m_svcName;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString baseFilePath() const
|
||||||
|
{
|
||||||
|
return m_baseFilePath;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const QString m_svcName;
|
const QString m_svcName;
|
||||||
const QString m_baseFilePath;
|
const QString m_baseFilePath;
|
||||||
@@ -423,48 +594,110 @@ class FunctionTopicWrapper final : public NameWrapper
|
|||||||
Q_PROPERTY(QVariantList requestParams READ requestParams)
|
Q_PROPERTY(QVariantList requestParams READ requestParams)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FunctionTopicWrapper(const FunctionTopic &ft,
|
FunctionTopicWrapper(const FunctionTopic& ft, const CompleteTopicTypeInformation& siRequest,
|
||||||
const CompleteTopicTypeInformation &siRequest,
|
const CompleteTopicTypeInformation& siReply, QObject* parent)
|
||||||
const CompleteTopicTypeInformation &siReply,
|
: NameWrapper(ft.name, parent), m_ft(ft), m_request(siRequest), m_reply(siReply)
|
||||||
QObject *parent)
|
{
|
||||||
: NameWrapper(ft.name, parent)
|
}
|
||||||
, m_ft(ft)
|
|
||||||
, m_request(siRequest)
|
|
||||||
, m_reply(siReply)
|
|
||||||
{}
|
|
||||||
QString onReply() const { return QLatin1String("on") + m_ft.replyTopicName; }
|
|
||||||
QString onRequest() const { return QLatin1String("on") + m_ft.requestTopicName; }
|
|
||||||
QString onError() const { return QLatin1String("on") + m_ft.name + QLatin1String("Error"); }
|
|
||||||
bool isCoreFt() const { return (m_ft.replyTopicType == QStringLiteral("Core::FunctionReply") || m_ft.replyTopicType == QStringLiteral("FunctionReply")); }
|
|
||||||
bool routeInReplay() const { return m_ft.routeInReplay; }
|
|
||||||
|
|
||||||
QString reply() const { return m_ft.replyTopicName; }
|
QString onReply() const
|
||||||
QString replyFlc() const { return StructBuilder::firstCharLowercase(reply()); }
|
{
|
||||||
QString replyHandler() const { return m_ft.replyTopicName + QLatin1String("Handler"); }
|
return QLatin1String("on") + m_ft.replyTopicName;
|
||||||
QString replyHandlerFlc() const { return StructBuilder::firstCharLowercase(replyHandler()); }
|
}
|
||||||
QString replyType() const { return m_reply.name; }
|
|
||||||
QString replyTypeFro() const { return isCoreFt() ? QStringLiteral("Core::FunctionReplyObject") : m_reply.name; }
|
|
||||||
|
|
||||||
QString request() const { return m_ft.requestTopicName; }
|
QString onRequest() const
|
||||||
QString requestFlc() const { return StructBuilder::firstCharLowercase(request()); }
|
{
|
||||||
QString requestHandler() const { return m_ft.requestTopicName + QLatin1String("Handler"); }
|
return QLatin1String("on") + m_ft.requestTopicName;
|
||||||
QString requestHandlerFlc() const { return StructBuilder::firstCharLowercase(requestHandler()); }
|
}
|
||||||
QString requestType() const { return m_request.name; }
|
|
||||||
|
QString onError() const
|
||||||
|
{
|
||||||
|
return QLatin1String("on") + m_ft.name + QLatin1String("Error");
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isCoreFt() const
|
||||||
|
{
|
||||||
|
return (m_ft.replyTopicType == QStringLiteral("Core::FunctionReply") ||
|
||||||
|
m_ft.replyTopicType == QStringLiteral("FunctionReply"));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool routeInReplay() const
|
||||||
|
{
|
||||||
|
return m_ft.routeInReplay;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString reply() const
|
||||||
|
{
|
||||||
|
return m_ft.replyTopicName;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString replyFlc() const
|
||||||
|
{
|
||||||
|
return StructBuilder::firstCharLowercase(reply());
|
||||||
|
}
|
||||||
|
|
||||||
|
QString replyHandler() const
|
||||||
|
{
|
||||||
|
return m_ft.replyTopicName + QLatin1String("Handler");
|
||||||
|
}
|
||||||
|
|
||||||
|
QString replyHandlerFlc() const
|
||||||
|
{
|
||||||
|
return StructBuilder::firstCharLowercase(replyHandler());
|
||||||
|
}
|
||||||
|
|
||||||
|
QString replyType() const
|
||||||
|
{
|
||||||
|
return m_reply.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString replyTypeFro() const
|
||||||
|
{
|
||||||
|
return isCoreFt() ? QStringLiteral("Core::FunctionReplyObject") : m_reply.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString request() const
|
||||||
|
{
|
||||||
|
return m_ft.requestTopicName;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString requestFlc() const
|
||||||
|
{
|
||||||
|
return StructBuilder::firstCharLowercase(request());
|
||||||
|
}
|
||||||
|
|
||||||
|
QString requestHandler() const
|
||||||
|
{
|
||||||
|
return m_ft.requestTopicName + QLatin1String("Handler");
|
||||||
|
}
|
||||||
|
|
||||||
|
QString requestHandlerFlc() const
|
||||||
|
{
|
||||||
|
return StructBuilder::firstCharLowercase(requestHandler());
|
||||||
|
}
|
||||||
|
|
||||||
|
QString requestType() const
|
||||||
|
{
|
||||||
|
return m_request.name;
|
||||||
|
}
|
||||||
|
|
||||||
void addRequestParams(const QVector<IdlData>& params)
|
void addRequestParams(const QVector<IdlData>& params)
|
||||||
{
|
{
|
||||||
for (const auto& param : params)
|
for (const auto& param : params)
|
||||||
m_requestParams.push_back(QVariant::fromValue(new IdlDataWrapper(param, this)));
|
m_requestParams.push_back(QVariant::fromValue(new IdlDataWrapper(param, this)));
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantList requestParams() const
|
QVariantList requestParams() const
|
||||||
{
|
{
|
||||||
return m_requestParams;
|
return m_requestParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
void addReplyParams(const QVector<IdlData>& params)
|
void addReplyParams(const QVector<IdlData>& params)
|
||||||
{
|
{
|
||||||
for (const auto& param : params)
|
for (const auto& param : params)
|
||||||
m_replyParams.push_back(QVariant::fromValue(new IdlDataWrapper(param, this)));
|
m_replyParams.push_back(QVariant::fromValue(new IdlDataWrapper(param, this)));
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantList replyParams() const
|
QVariantList replyParams() const
|
||||||
{
|
{
|
||||||
return m_replyParams;
|
return m_replyParams;
|
||||||
@@ -474,6 +707,7 @@ public:
|
|||||||
{
|
{
|
||||||
return m_replyHandlerHash;
|
return m_replyHandlerHash;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setReplyHandlerHash(const QString& hash)
|
void setReplyHandlerHash(const QString& hash)
|
||||||
{
|
{
|
||||||
m_replyHandlerHash = hash;
|
m_replyHandlerHash = hash;
|
||||||
@@ -496,8 +730,7 @@ public:
|
|||||||
|
|
||||||
using VariantListWrapper::VariantListWrapper;
|
using VariantListWrapper::VariantListWrapper;
|
||||||
|
|
||||||
FunctionTopicWrapper *addFunctionTopic(const FunctionTopic &ft,
|
FunctionTopicWrapper* addFunctionTopic(const FunctionTopic& ft, const CompleteTopicTypeInformation& siRequest,
|
||||||
const CompleteTopicTypeInformation &siRequest,
|
|
||||||
const CompleteTopicTypeInformation& siReply)
|
const CompleteTopicTypeInformation& siReply)
|
||||||
{
|
{
|
||||||
FunctionTopicWrapper* ret = new FunctionTopicWrapper(ft, siRequest, siReply, this);
|
FunctionTopicWrapper* ret = new FunctionTopicWrapper(ft, siRequest, siReply, this);
|
||||||
@@ -505,7 +738,6 @@ public:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QVariantList topicsToRouteInReplay() const
|
QVariantList topicsToRouteInReplay() const
|
||||||
{
|
{
|
||||||
QVariantList vl;
|
QVariantList vl;
|
||||||
@@ -540,11 +772,9 @@ class DataTopicWrapper final : public NameWrapper
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
DataTopicWrapper(const CompleteTopicTypeInformation& ctti, QObject* parent)
|
DataTopicWrapper(const CompleteTopicTypeInformation& ctti, QObject* parent)
|
||||||
: NameWrapper(ctti.name, parent)
|
: NameWrapper(ctti.name, parent), m_ctti(ctti), m_keyData(nullptr), m_recordData(nullptr)
|
||||||
, m_ctti(ctti)
|
{
|
||||||
, m_keyData(nullptr)
|
}
|
||||||
, m_recordData(nullptr)
|
|
||||||
{}
|
|
||||||
|
|
||||||
void setKeyColumnData(const IdlData& data)
|
void setKeyColumnData(const IdlData& data)
|
||||||
{
|
{
|
||||||
@@ -575,18 +805,63 @@ public:
|
|||||||
m_ctti.recordTopic = true;
|
m_ctti.recordTopic = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString serviceName() const { return m_ctti.serviceName; }
|
QString serviceName() const
|
||||||
QString type() const { return m_ctti.name; }
|
{
|
||||||
|
return m_ctti.serviceName;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString type() const
|
||||||
|
{
|
||||||
|
return m_ctti.name;
|
||||||
|
}
|
||||||
|
|
||||||
QString typeFq() const;
|
QString typeFq() const;
|
||||||
QVariant key() const { return m_keyData ? QVariant::fromValue(m_keyData) : QVariant(); }
|
|
||||||
bool dtsImpl() const { return m_ctti.dtsAutogen; }
|
QVariant key() const
|
||||||
bool dtcImpl() const { return m_ctti.dtcAutogen; }
|
{
|
||||||
bool recordTopic() const { return m_ctti.recordTopic && m_recordData; }
|
return m_keyData ? QVariant::fromValue(m_keyData) : QVariant();
|
||||||
bool routeToClient() const { return m_ctti.routeToClient; }
|
}
|
||||||
bool routeToServer() const { return m_ctti.routeToServer; }
|
|
||||||
bool routeInReplay() const { return m_ctti.routeInReplay; }
|
bool dtsImpl() const
|
||||||
bool isAutoSubscribe() const { return m_ctti.autosubscribe; }
|
{
|
||||||
QVariant recTable() const { return recordTopic() ? QVariant::fromValue(m_recordData) : QVariant(); }
|
return m_ctti.dtsAutogen;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dtcImpl() const
|
||||||
|
{
|
||||||
|
return m_ctti.dtcAutogen;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool recordTopic() const
|
||||||
|
{
|
||||||
|
return m_ctti.recordTopic && m_recordData;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool routeToClient() const
|
||||||
|
{
|
||||||
|
return m_ctti.routeToClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool routeToServer() const
|
||||||
|
{
|
||||||
|
return m_ctti.routeToServer;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool routeInReplay() const
|
||||||
|
{
|
||||||
|
return m_ctti.routeInReplay;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isAutoSubscribe() const
|
||||||
|
{
|
||||||
|
return m_ctti.autosubscribe;
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant recTable() const
|
||||||
|
{
|
||||||
|
return recordTopic() ? QVariant::fromValue(m_recordData) : QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CompleteTopicTypeInformation m_ctti;
|
CompleteTopicTypeInformation m_ctti;
|
||||||
IdlDataWrapper* m_keyData;
|
IdlDataWrapper* m_keyData;
|
||||||
@@ -611,7 +886,6 @@ public:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QVariantList memberByFilter(const std::function<bool(const DataTopicWrapper* dtw)>& acceptFilter) const
|
QVariantList memberByFilter(const std::function<bool(const DataTopicWrapper* dtw)>& acceptFilter) const
|
||||||
{
|
{
|
||||||
QVariantList vl;
|
QVariantList vl;
|
||||||
@@ -629,10 +903,12 @@ public:
|
|||||||
{
|
{
|
||||||
return memberByFilter([](const DataTopicWrapper* dtw) { return dtw->routeInReplay(); });
|
return memberByFilter([](const DataTopicWrapper* dtw) { return dtw->routeInReplay(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantList topicsToRouteToClient() const
|
QVariantList topicsToRouteToClient() const
|
||||||
{
|
{
|
||||||
return memberByFilter([](const DataTopicWrapper* dtw) { return dtw->routeToClient(); });
|
return memberByFilter([](const DataTopicWrapper* dtw) { return dtw->routeToClient(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantList topicsToRouteToServer() const
|
QVariantList topicsToRouteToServer() const
|
||||||
{
|
{
|
||||||
return memberByFilter([](const DataTopicWrapper* dtw) { return dtw->routeToServer(); });
|
return memberByFilter([](const DataTopicWrapper* dtw) { return dtw->routeToServer(); });
|
||||||
@@ -651,4 +927,4 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace CodeGen
|
||||||
Executable → Regular
+81
-131
@@ -1,37 +1,31 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "SqlGenerator.h"
|
#include "SqlGenerator.h"
|
||||||
|
|
||||||
#include "StructBuilder.h"
|
#include "StructBuilder.h"
|
||||||
#include "XmlReader.h"
|
#include "XmlReader.h"
|
||||||
|
|
||||||
|
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||||
|
#include <QStringList>
|
||||||
#include <QtCore/QFile>
|
#include <QtCore/QFile>
|
||||||
#include <QtCore/QTextStream>
|
#include <QtCore/QTextStream>
|
||||||
#include <QStringList>
|
|
||||||
|
|
||||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
|
||||||
|
|
||||||
using namespace CodeGen;
|
using namespace CodeGen;
|
||||||
|
|
||||||
|
|
||||||
static QString getExerciseSchemaName(int exerciseId)
|
static QString getExerciseSchemaName(int exerciseId)
|
||||||
{
|
{
|
||||||
return QStringLiteral("ex_") + QString::number(exerciseId);
|
return QStringLiteral("ex_") + QString::number(exerciseId);
|
||||||
}
|
}
|
||||||
|
|
||||||
SqlGenerator::SqlGenerator(XmlReader *xmlReader, StructBuilder *structBuilder) : m_xmlReader(xmlReader)
|
SqlGenerator::SqlGenerator(XmlReader* xmlReader, StructBuilder* structBuilder)
|
||||||
, m_structBuilder(structBuilder)
|
: m_xmlReader(xmlReader), m_structBuilder(structBuilder), m_createdByXmlFile(false), m_isValid(true),
|
||||||
, m_createdByXmlFile(false)
|
m_exerciseId(0), m_logger(NGL::NGLLoggerBootstrap::getLogger())
|
||||||
, m_isValid(true)
|
{
|
||||||
, m_exerciseId(0),
|
}
|
||||||
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {}
|
|
||||||
|
|
||||||
SqlGenerator::SqlGenerator(const QString& xmlFile)
|
SqlGenerator::SqlGenerator(const QString& xmlFile)
|
||||||
: m_xmlReader(new XmlReader)
|
: m_xmlReader(new XmlReader), m_structBuilder(new StructBuilder(m_xmlReader)), m_createdByXmlFile(true),
|
||||||
, m_structBuilder(new StructBuilder(m_xmlReader))
|
m_isValid(false), m_exerciseId(0)
|
||||||
, m_createdByXmlFile(true)
|
|
||||||
, m_isValid(false)
|
|
||||||
, m_exerciseId(0)
|
|
||||||
{
|
{
|
||||||
m_isValid = m_xmlReader->readServiceFile(xmlFile, QString()) && m_structBuilder->buildStructures();
|
m_isValid = m_xmlReader->readServiceFile(xmlFile, QString()) && m_structBuilder->buildStructures();
|
||||||
}
|
}
|
||||||
@@ -45,10 +39,10 @@ SqlGenerator::~SqlGenerator()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool SqlGenerator::generateData(int exerciseId)
|
bool SqlGenerator::generateData(int exerciseId)
|
||||||
{
|
{
|
||||||
DEBUG_LOG(m_logger) << "Generating SQL data for service " << getServiceAbbr() << " in exercise " << exerciseId << ", this: " << this;
|
DEBUG_LOG(m_logger) << "Generating SQL data for service " << getServiceAbbr() << " in exercise " << exerciseId
|
||||||
|
<< ", this: " << this;
|
||||||
|
|
||||||
m_exerciseId = exerciseId;
|
m_exerciseId = exerciseId;
|
||||||
m_sqlGlobal = SqlStatements();
|
m_sqlGlobal = SqlStatements();
|
||||||
@@ -158,19 +152,17 @@ bool SqlGenerator::handleView(const ViewInformation &vi)
|
|||||||
|
|
||||||
QStringList fqColumnNames;
|
QStringList fqColumnNames;
|
||||||
|
|
||||||
|
|
||||||
for (const MemberInformation& mi : csi.member)
|
for (const MemberInformation& mi : csi.member)
|
||||||
{
|
{
|
||||||
if (mi.db.usedForView)
|
if (mi.db.usedForView)
|
||||||
fqColumnNames += mi.db.table + QLatin1Char('.') + mi.db.columnName + QLatin1String(" AS ") + mi.db.getColumnNameView();
|
fqColumnNames += mi.db.table + QLatin1Char('.') + mi.db.columnName + QLatin1String(" AS ") +
|
||||||
|
mi.db.getColumnNameView();
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG_LOG(m_logger) << "fqColumnNames = " << fqColumnNames.join(QStringLiteral(", "));
|
DEBUG_LOG(m_logger) << "fqColumnNames = " << fqColumnNames.join(QStringLiteral(", "));
|
||||||
|
|
||||||
|
|
||||||
if (!whereConditions.isEmpty())
|
if (!whereConditions.isEmpty())
|
||||||
addToCreateViews(createViewStmt.arg(csi.viewName,
|
addToCreateViews(createViewStmt.arg(csi.viewName, fqColumnNames.join(QStringLiteral(", ")),
|
||||||
fqColumnNames.join(QStringLiteral(", ")),
|
|
||||||
fromTables.join(QStringLiteral(", ")),
|
fromTables.join(QStringLiteral(", ")),
|
||||||
whereConditions.join(QStringLiteral(" AND\n"))),
|
whereConditions.join(QStringLiteral(" AND\n"))),
|
||||||
vi.exerciseDependency);
|
vi.exerciseDependency);
|
||||||
@@ -179,7 +171,6 @@ bool SqlGenerator::handleView(const ViewInformation &vi)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SqlGenerator::handleTable(const CompleteTableInformation& cti)
|
bool SqlGenerator::handleTable(const CompleteTableInformation& cti)
|
||||||
@@ -202,20 +193,14 @@ bool SqlGenerator::handleTable(const CompleteTableInformation &cti)
|
|||||||
|
|
||||||
if ((cti.exerciseDependency & Global) == Global)
|
if ((cti.exerciseDependency & Global) == Global)
|
||||||
{
|
{
|
||||||
addToCreateTables(createTableStmt.arg(cti.name,
|
addToCreateTables(createTableStmt.arg(
|
||||||
getTableColumnCreateStatements(cti.name,
|
cti.name, getTableColumnCreateStatements(cti.name, cti.columns, &tableComments, Global)),
|
||||||
cti.columns,
|
|
||||||
&tableComments,
|
|
||||||
Global)),
|
|
||||||
Global);
|
Global);
|
||||||
}
|
}
|
||||||
if ((cti.exerciseDependency & Exercise) == Exercise)
|
if ((cti.exerciseDependency & Exercise) == Exercise)
|
||||||
{
|
{
|
||||||
addToCreateTables(createTableStmt.arg(cti.name,
|
addToCreateTables(createTableStmt.arg(cti.name, getTableColumnCreateStatements(cti.name, cti.columns,
|
||||||
getTableColumnCreateStatements(cti.name,
|
&tableComments, Exercise)),
|
||||||
cti.columns,
|
|
||||||
&tableComments,
|
|
||||||
Exercise)),
|
|
||||||
Exercise);
|
Exercise);
|
||||||
}
|
}
|
||||||
addToTables(cti.name, cti.exerciseDependency);
|
addToTables(cti.name, cti.exerciseDependency);
|
||||||
@@ -237,29 +222,29 @@ bool SqlGenerator::handleTable(const CompleteTableInformation &cti)
|
|||||||
QStringList whereConditions;
|
QStringList whereConditions;
|
||||||
fromTables += cti.name;
|
fromTables += cti.name;
|
||||||
|
|
||||||
|
|
||||||
for (const MemberInformation& mi : csi.member)
|
for (const MemberInformation& mi : csi.member)
|
||||||
{
|
{
|
||||||
if (mi.db.usedForView)
|
if (mi.db.usedForView)
|
||||||
fqColumnNames += mi.db.table + QLatin1Char('.') + mi.db.columnName + QLatin1String(" AS ") + mi.db.getColumnNameView();
|
fqColumnNames += mi.db.table + QLatin1Char('.') + mi.db.columnName + QLatin1String(" AS ") +
|
||||||
|
mi.db.getColumnNameView();
|
||||||
if (mi.cpp.isReadOnly && mi.db.isForeignKey)
|
if (mi.cpp.isReadOnly && mi.db.isForeignKey)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for (const QSharedPointer<TableInformation>& tiPtr : csi.tables)
|
for (const QSharedPointer<TableInformation>& tiPtr : csi.tables)
|
||||||
{
|
{
|
||||||
if (tiPtr->name == mi.db.table)
|
if (tiPtr->name == mi.db.table)
|
||||||
{
|
{
|
||||||
const QSharedPointer<ForeignKeyInformation> fki = tiPtr->fkInformationForColumn(mi.db.table, mi.db.columnName);
|
const QSharedPointer<ForeignKeyInformation> fki =
|
||||||
|
tiPtr->fkInformationForColumn(mi.db.table, mi.db.columnName);
|
||||||
if (!fki.isNull())
|
if (!fki.isNull())
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!fromTables.contains(fki->destination.tableName))
|
if (!fromTables.contains(fki->destination.tableName))
|
||||||
{
|
{
|
||||||
whereConditions += fki->destination.tableName + QLatin1Char('.') + fki->destination.columnName +
|
whereConditions += fki->destination.tableName + QLatin1Char('.') +
|
||||||
QLatin1String(" = ") +
|
fki->destination.columnName + QLatin1String(" = ") +
|
||||||
fki->source.tableName + QLatin1Char('.') + fki->source.columnName;
|
fki->source.tableName + QLatin1Char('.') +
|
||||||
|
fki->source.columnName;
|
||||||
fromTables += fki->destination.tableName;
|
fromTables += fki->destination.tableName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -270,8 +255,7 @@ bool SqlGenerator::handleTable(const CompleteTableInformation &cti)
|
|||||||
}
|
}
|
||||||
if (!whereConditions.isEmpty())
|
if (!whereConditions.isEmpty())
|
||||||
{
|
{
|
||||||
addToCreateViews(createViewStmt.arg(csi.viewName,
|
addToCreateViews(createViewStmt.arg(csi.viewName, fqColumnNames.join(QStringLiteral(", ")),
|
||||||
fqColumnNames.join(QStringLiteral(", ")),
|
|
||||||
fromTables.join(QStringLiteral(", ")),
|
fromTables.join(QStringLiteral(", ")),
|
||||||
whereConditions.join(QStringLiteral(" AND\n"))),
|
whereConditions.join(QStringLiteral(" AND\n"))),
|
||||||
cti.exerciseDependency);
|
cti.exerciseDependency);
|
||||||
@@ -290,17 +274,14 @@ bool SqlGenerator::handleTable(const CompleteTableInformation &cti)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString SqlGenerator::getTableColumnCreateStatements(const QString& tableName,
|
QString SqlGenerator::getTableColumnCreateStatements(const QString& tableName,
|
||||||
const QVector<MemberInformation>& columns,
|
const QVector<MemberInformation>& columns,
|
||||||
QStringList *tableComments,
|
QStringList* tableComments, ExerciseDependency ed)
|
||||||
ExerciseDependency ed)
|
|
||||||
{
|
{
|
||||||
Q_ASSERT(ed == Global || ed == Exercise);
|
Q_ASSERT(ed == Global || ed == Exercise);
|
||||||
|
|
||||||
const QString commentColumnStmt(QStringLiteral("COMMENT ON COLUMN %1 IS '%2';"));
|
const QString commentColumnStmt(QStringLiteral("COMMENT ON COLUMN %1 IS '%2';"));
|
||||||
|
|
||||||
|
|
||||||
int maxLength = 1;
|
int maxLength = 1;
|
||||||
for (const MemberInformation& mi : columns)
|
for (const MemberInformation& mi : columns)
|
||||||
maxLength = std::max(maxLength, static_cast<int>(mi.db.columnName.length()));
|
maxLength = std::max(maxLength, static_cast<int>(mi.db.columnName.length()));
|
||||||
@@ -325,8 +306,7 @@ QString SqlGenerator::getTableColumnCreateStatements(const QString &tableName,
|
|||||||
else
|
else
|
||||||
schema = getExerciseSchemaName(m_exerciseId);
|
schema = getExerciseSchemaName(m_exerciseId);
|
||||||
|
|
||||||
column += QLatin1String(" DEFAULT nextval(( '") +
|
column += QLatin1String(" DEFAULT nextval(( '") + schema + QLatin1Char('.') + seqDescr +
|
||||||
schema + QLatin1Char('.') + seqDescr +
|
|
||||||
QLatin1String("'::text)::regclass)");
|
QLatin1String("'::text)::regclass)");
|
||||||
}
|
}
|
||||||
if (!ci.canBeNull)
|
if (!ci.canBeNull)
|
||||||
@@ -351,36 +331,33 @@ QString SqlGenerator::getTableColumnCreateStatements(const QString &tableName,
|
|||||||
return retCols.join(QStringLiteral("\n "));
|
return retCols.join(QStringLiteral("\n "));
|
||||||
}
|
}
|
||||||
|
|
||||||
QString SqlGenerator::generateSequence(const QString &tableName,
|
QString SqlGenerator::generateSequence(const QString& tableName, const FullQualifiedColumnInformation& ci,
|
||||||
const FullQualifiedColumnInformation &ci,
|
|
||||||
ExerciseDependency ed)
|
ExerciseDependency ed)
|
||||||
{
|
{
|
||||||
const QString sequenceName = tableName + QLatin1Char('_') + ci.columnName + QLatin1String("_seq");
|
const QString sequenceName = tableName + QLatin1Char('_') + ci.columnName + QLatin1String("_seq");
|
||||||
|
|
||||||
|
const QString createSequenceStmt(
|
||||||
|
QLatin1String("CREATE SEQUENCE IF NOT EXISTS %1 INCREMENT %2 START %3 MINVALUE %4;"));
|
||||||
const QString createSequenceStmt(QLatin1String("CREATE SEQUENCE IF NOT EXISTS %1 INCREMENT %2 START %3 MINVALUE %4;"));
|
|
||||||
|
|
||||||
const int minValue = ci.sequenceStart < 1 ? ci.sequenceStart : 1;
|
const int minValue = ci.sequenceStart < 1 ? ci.sequenceStart : 1;
|
||||||
|
|
||||||
addToCreateSequences(createSequenceStmt.arg(sequenceName).arg(ci.sequenceIncrement).arg(ci.sequenceStart).arg(minValue), ed);
|
addToCreateSequences(
|
||||||
|
createSequenceStmt.arg(sequenceName).arg(ci.sequenceIncrement).arg(ci.sequenceStart).arg(minValue), ed);
|
||||||
addToSequences(sequenceName, ed);
|
addToSequences(sequenceName, ed);
|
||||||
|
|
||||||
return sequenceName;
|
return sequenceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SqlGenerator::generatePrimaryKey(const QString &tableName,
|
void SqlGenerator::generatePrimaryKey(const QString& tableName, const FullQualifiedColumnInformation& ci,
|
||||||
const FullQualifiedColumnInformation &ci,
|
|
||||||
ExerciseDependency ed)
|
ExerciseDependency ed)
|
||||||
{
|
{
|
||||||
QString pkName = QLatin1String("PK_") + tableName + QLatin1Char('_') + ci.columnName;
|
QString pkName = QLatin1String("PK_") + tableName + QLatin1Char('_') + ci.columnName;
|
||||||
|
|
||||||
if (pkName.size() > 63) pkName.resize(63);
|
if (pkName.size() > 63)
|
||||||
|
pkName.resize(63);
|
||||||
|
|
||||||
addToPks(pkName, ed);
|
addToPks(pkName, ed);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const QString pkConstraint(QStringLiteral("ALTER TABLE IF EXISTS %1 ADD CONSTRAINT %2 PRIMARY KEY (%3);"));
|
const QString pkConstraint(QStringLiteral("ALTER TABLE IF EXISTS %1 ADD CONSTRAINT %2 PRIMARY KEY (%3);"));
|
||||||
addToCreatePks(pkConstraint.arg(tableName, pkName, ci.columnName), ed);
|
addToCreatePks(pkConstraint.arg(tableName, pkName, ci.columnName), ed);
|
||||||
|
|
||||||
@@ -395,17 +372,14 @@ void SqlGenerator::generateForeignKeys(const QVector<QSharedPointer<ForeignKeyIn
|
|||||||
generateForeignKey(fk, ed);
|
generateForeignKey(fk, ed);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SqlGenerator::generateForeignKey(const QSharedPointer<ForeignKeyInformation> &foreignKey,
|
void SqlGenerator::generateForeignKey(const QSharedPointer<ForeignKeyInformation>& foreignKey, ExerciseDependency ed)
|
||||||
ExerciseDependency ed)
|
|
||||||
{
|
{
|
||||||
QString fkName = QLatin1String("FK_") + foreignKey->source.tableName +
|
QString fkName = QLatin1String("FK_") + foreignKey->source.tableName + QLatin1Char('_') +
|
||||||
QLatin1Char('_') + foreignKey->source.columnName +
|
foreignKey->source.columnName + QLatin1Char('_') + foreignKey->destination.tableName +
|
||||||
QLatin1Char('_') + foreignKey->destination.tableName +
|
|
||||||
QLatin1Char('_') + foreignKey->destination.columnName;
|
QLatin1Char('_') + foreignKey->destination.columnName;
|
||||||
|
|
||||||
|
if (fkName.size() > 63)
|
||||||
|
fkName = foreignKey->name;
|
||||||
if (fkName.size() > 63) fkName = foreignKey->name;
|
|
||||||
|
|
||||||
addToFks(fkName, ed);
|
addToFks(fkName, ed);
|
||||||
|
|
||||||
@@ -431,8 +405,6 @@ void SqlGenerator::generateForeignKey(const QSharedPointer<ForeignKeyInformation
|
|||||||
|
|
||||||
fkConstraint += QLatin1Char(';');
|
fkConstraint += QLatin1Char(';');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
QString destination;
|
QString destination;
|
||||||
if (!foreignKey->destination.schema.isEmpty())
|
if (!foreignKey->destination.schema.isEmpty())
|
||||||
{
|
{
|
||||||
@@ -447,55 +419,54 @@ void SqlGenerator::generateForeignKey(const QSharedPointer<ForeignKeyInformation
|
|||||||
if (!extSvcAbbr.isEmpty() && !m_referencedSevices.contains(extSvcAbbr))
|
if (!extSvcAbbr.isEmpty() && !m_referencedSevices.contains(extSvcAbbr))
|
||||||
m_referencedSevices += extSvcAbbr;
|
m_referencedSevices += extSvcAbbr;
|
||||||
|
|
||||||
addToCreateFks(fkConstraint.arg(foreignKey->source.tableName, fkName, foreignKey->source.columnName,
|
addToCreateFks(fkConstraint.arg(foreignKey->source.tableName, fkName, foreignKey->source.columnName, destination,
|
||||||
destination, foreignKey->destination.columnName), ed);
|
foreignKey->destination.columnName),
|
||||||
|
ed);
|
||||||
|
|
||||||
const QString fkDropConstraint(QStringLiteral("ALTER TABLE IF EXISTS %1 DROP CONSTRAINT IF EXISTS %2 CASCADE;"));
|
const QString fkDropConstraint(QStringLiteral("ALTER TABLE IF EXISTS %1 DROP CONSTRAINT IF EXISTS %2 CASCADE;"));
|
||||||
addToDropConstraints(fkDropConstraint.arg(foreignKey->source.tableName, fkName), ed);
|
addToDropConstraints(fkDropConstraint.arg(foreignKey->source.tableName, fkName), ed);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SqlGenerator::generateConstraints(const QString& tableName, const QVector<ConstraintInformation>& constraints,
|
||||||
void SqlGenerator::generateConstraints(const QString &tableName,
|
|
||||||
const QVector<ConstraintInformation> &constraints,
|
|
||||||
ExerciseDependency ed)
|
ExerciseDependency ed)
|
||||||
{
|
{
|
||||||
for (const ConstraintInformation& constraint : constraints)
|
for (const ConstraintInformation& constraint : constraints)
|
||||||
generateConstraint(tableName, constraint, ed);
|
generateConstraint(tableName, constraint, ed);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SqlGenerator::generateConstraint(const QString &tableName,
|
void SqlGenerator::generateConstraint(const QString& tableName, const ConstraintInformation& constraint,
|
||||||
const ConstraintInformation &constraint,
|
|
||||||
ExerciseDependency ed)
|
ExerciseDependency ed)
|
||||||
{
|
{
|
||||||
const QString dropConstraint(QStringLiteral("ALTER TABLE IF EXISTS %1 DROP CONSTRAINT IF EXISTS %2 CASCADE;"));
|
const QString dropConstraint(QStringLiteral("ALTER TABLE IF EXISTS %1 DROP CONSTRAINT IF EXISTS %2 CASCADE;"));
|
||||||
switch (constraint.type)
|
switch (constraint.type)
|
||||||
{
|
{
|
||||||
case ConstraintInformation::Type::index:
|
case ConstraintInformation::Type::index: {
|
||||||
{
|
|
||||||
QString constraintName = QLatin1String("IDX_") + tableName + QLatin1Char('_') +
|
QString constraintName = QLatin1String("IDX_") + tableName + QLatin1Char('_') +
|
||||||
constraint.affectedColumns.join(QStringLiteral("_"));
|
constraint.affectedColumns.join(QStringLiteral("_"));
|
||||||
|
|
||||||
if (constraintName.size() > 63) constraintName.resize(63);
|
if (constraintName.size() > 63)
|
||||||
|
constraintName.resize(63);
|
||||||
|
|
||||||
const QString index(QStringLiteral("CREATE INDEX %1 ON %2 (%3);"));
|
const QString index(QStringLiteral("CREATE INDEX %1 ON %2 (%3);"));
|
||||||
|
|
||||||
addToCreateConstraints(index.arg(constraintName, tableName, constraint.affectedColumns.join(QStringLiteral(", "))), ed);
|
addToCreateConstraints(
|
||||||
|
index.arg(constraintName, tableName, constraint.affectedColumns.join(QStringLiteral(", "))), ed);
|
||||||
addToConstraints(constraintName, ed);
|
addToConstraints(constraintName, ed);
|
||||||
|
|
||||||
addToDropConstraints(dropConstraint.arg(tableName, constraintName), ed);
|
addToDropConstraints(dropConstraint.arg(tableName, constraintName), ed);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ConstraintInformation::Type::unique:
|
case ConstraintInformation::Type::unique: {
|
||||||
{
|
|
||||||
QString constraintName = QLatin1String("UQ_") + tableName + QLatin1Char('_') +
|
QString constraintName = QLatin1String("UQ_") + tableName + QLatin1Char('_') +
|
||||||
constraint.affectedColumns.join(QStringLiteral("_"));
|
constraint.affectedColumns.join(QStringLiteral("_"));
|
||||||
|
|
||||||
if (constraintName.size() > 63) constraintName.resize(63);
|
if (constraintName.size() > 63)
|
||||||
|
constraintName.resize(63);
|
||||||
const QString unique(QStringLiteral("ALTER TABLE %1 ADD CONSTRAINT %2 UNIQUE (%3);"));
|
const QString unique(QStringLiteral("ALTER TABLE %1 ADD CONSTRAINT %2 UNIQUE (%3);"));
|
||||||
|
|
||||||
addToCreateConstraints(unique.arg(tableName, constraintName, constraint.affectedColumns.join(QStringLiteral(", "))), ed);
|
addToCreateConstraints(
|
||||||
|
unique.arg(tableName, constraintName, constraint.affectedColumns.join(QStringLiteral(", "))), ed);
|
||||||
addToConstraints(constraintName, ed);
|
addToConstraints(constraintName, ed);
|
||||||
|
|
||||||
addToDropConstraints(dropConstraint.arg(tableName, constraintName), ed);
|
addToDropConstraints(dropConstraint.arg(tableName, constraintName), ed);
|
||||||
@@ -543,12 +514,11 @@ QStringList SqlGenerator::handleEnumeration(const EnumInformation &ei, const QSt
|
|||||||
const QString columnNames(QStringLiteral("id, name"));
|
const QString columnNames(QStringLiteral("id, name"));
|
||||||
const QString tablename = dbSchema.isEmpty() ? ei.tableName : dbSchema + QLatin1Char('.') + ei.tableName;
|
const QString tablename = dbSchema.isEmpty() ? ei.tableName : dbSchema + QLatin1Char('.') + ei.tableName;
|
||||||
|
|
||||||
|
|
||||||
QStringList enumerationValues;
|
QStringList enumerationValues;
|
||||||
for (const EnumKeyValuePair& evp : ei.values)
|
for (const EnumKeyValuePair& evp : ei.values)
|
||||||
{
|
{
|
||||||
const QString values(QString::number(evp.value) + QLatin1String(", '") +
|
const QString values(QString::number(evp.value) + QLatin1String(", '") + fixupComment(evp.key) +
|
||||||
fixupComment(evp.key) + QLatin1Char('\''));
|
QLatin1Char('\''));
|
||||||
enumerationValues += insertEnum.arg(tablename, columnNames, values);
|
enumerationValues += insertEnum.arg(tablename, columnNames, values);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -561,8 +531,7 @@ bool SqlGenerator::generateDbNotifications(const QString &tableName,
|
|||||||
{
|
{
|
||||||
for (const DbNotifcationInformation& notification : notifications)
|
for (const DbNotifcationInformation& notification : notifications)
|
||||||
{
|
{
|
||||||
if (notification.paramNames.isEmpty() ||
|
if (notification.paramNames.isEmpty() || notification.paramNames.size() > 1)
|
||||||
notification.paramNames.size() > 1)
|
|
||||||
{
|
{
|
||||||
ERROR_LOG(m_logger) << "Can not handle more than one parameter";
|
ERROR_LOG(m_logger) << "Can not handle more than one parameter";
|
||||||
continue;
|
continue;
|
||||||
@@ -574,8 +543,7 @@ bool SqlGenerator::generateDbNotifications(const QString &tableName,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SqlGenerator::generateDbNotification(const DbNotifcationInformation ¬ification,
|
void SqlGenerator::generateDbNotification(const DbNotifcationInformation& notification, ExerciseDependency ed)
|
||||||
ExerciseDependency ed)
|
|
||||||
{
|
{
|
||||||
const QString func(QStringLiteral("CREATE OR REPLACE FUNCTION public.%1()\n"
|
const QString func(QStringLiteral("CREATE OR REPLACE FUNCTION public.%1()\n"
|
||||||
"RETURNS TRIGGER AS $$\n"
|
"RETURNS TRIGGER AS $$\n"
|
||||||
@@ -603,8 +571,7 @@ void SqlGenerator::generateDbNotification(const DbNotifcationInformation ¬ifi
|
|||||||
addToDbFunctions(func.arg(triggerFuncName, notification.methodName, notification.paramNames.first()), ed);
|
addToDbFunctions(func.arg(triggerFuncName, notification.methodName, notification.paramNames.first()), ed);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SqlGenerator::generateDbNotificationTrigger(const QString &tableName,
|
bool SqlGenerator::generateDbNotificationTrigger(const QString& tableName, const DbNotifcationInformation& notification,
|
||||||
const DbNotifcationInformation ¬ification,
|
|
||||||
ExerciseDependency ed)
|
ExerciseDependency ed)
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -643,7 +610,8 @@ bool SqlGenerator::generateDbNotificationTrigger(const QString &tableName,
|
|||||||
triggerNameShortcut = QStringLiteral("ad");
|
triggerNameShortcut = QStringLiteral("ad");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
const QString triggerName(QLatin1String("trg_") + triggerNameShortcut + QLatin1Char('_') + notification.methodName);
|
const QString triggerName(QLatin1String("trg_") + triggerNameShortcut + QLatin1Char('_') +
|
||||||
|
notification.methodName);
|
||||||
const QString triggerFuncName(getNotificationFunctionName(notification));
|
const QString triggerFuncName(getNotificationFunctionName(notification));
|
||||||
addToDbFunctionTrigger(drop.arg(triggerName, tableName), ed);
|
addToDbFunctionTrigger(drop.arg(triggerName, tableName), ed);
|
||||||
addToDbFunctionTrigger(func.arg(triggerName, when, tableName, triggerFuncName), ed);
|
addToDbFunctionTrigger(func.arg(triggerName, when, tableName, triggerFuncName), ed);
|
||||||
@@ -656,7 +624,6 @@ QString SqlGenerator::getNotificationFunctionName(const DbNotifcationInformation
|
|||||||
return getServiceAbbr() + QLatin1Char('_') + notification.methodName;
|
return getServiceAbbr() + QLatin1Char('_') + notification.methodName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString SqlGenerator::fixupComment(const QString& comment)
|
QString SqlGenerator::fixupComment(const QString& comment)
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -670,17 +637,15 @@ QStringList SqlGenerator::getDbSettings(const QString &dbSchema) const
|
|||||||
{
|
{
|
||||||
QStringList data;
|
QStringList data;
|
||||||
|
|
||||||
|
|
||||||
QString dbUser(QStringLiteral("ets_"));
|
QString dbUser(QStringLiteral("ets_"));
|
||||||
if (m_exerciseId > 0)
|
if (m_exerciseId > 0)
|
||||||
dbUser += QStringLiteral("ex_00");
|
dbUser += QStringLiteral("ex_00");
|
||||||
else
|
else
|
||||||
dbUser += m_xmlReader->getServiceAbbr().toLower();
|
dbUser += m_xmlReader->getServiceAbbr().toLower();
|
||||||
|
|
||||||
|
|
||||||
data.append(QLatin1String("ALTER DEFAULT PRIVILEGES IN SCHEMA ") + dbSchema + QLatin1Char('\n') +
|
data.append(QLatin1String("ALTER DEFAULT PRIVILEGES IN SCHEMA ") + dbSchema + QLatin1Char('\n') +
|
||||||
QLatin1String(" GRANT SELECT,INSERT,UPDATE,DELETE,TRUNCATE ON TABLES TO ") + dbUser + QLatin1Char(';'));
|
QLatin1String(" GRANT SELECT,INSERT,UPDATE,DELETE,TRUNCATE ON TABLES TO ") + dbUser +
|
||||||
|
QLatin1Char(';'));
|
||||||
|
|
||||||
data.append(QLatin1String("ALTER DEFAULT PRIVILEGES IN SCHEMA ") + dbSchema + QLatin1Char('\n') +
|
data.append(QLatin1String("ALTER DEFAULT PRIVILEGES IN SCHEMA ") + dbSchema + QLatin1Char('\n') +
|
||||||
QLatin1String(" GRANT SELECT, REFERENCES ON TABLES TO ets_ro;"));
|
QLatin1String(" GRANT SELECT, REFERENCES ON TABLES TO ets_ro;"));
|
||||||
@@ -691,7 +656,6 @@ QStringList SqlGenerator::getDbSettings(const QString &dbSchema) const
|
|||||||
data.append(QLatin1String("ALTER DEFAULT PRIVILEGES IN SCHEMA ") + dbSchema + QLatin1Char('\n') +
|
data.append(QLatin1String("ALTER DEFAULT PRIVILEGES IN SCHEMA ") + dbSchema + QLatin1Char('\n') +
|
||||||
QLatin1String(" GRANT ALL ON SEQUENCES TO ") + dbUser + QLatin1Char(';'));
|
QLatin1String(" GRANT ALL ON SEQUENCES TO ") + dbUser + QLatin1Char(';'));
|
||||||
|
|
||||||
|
|
||||||
data.append(QLatin1String("SET SEARCH_PATH TO ") + dbSchema + QLatin1String(", PUBLIC;"));
|
data.append(QLatin1String("SET SEARCH_PATH TO ") + dbSchema + QLatin1String(", PUBLIC;"));
|
||||||
|
|
||||||
QStringList deps;
|
QStringList deps;
|
||||||
@@ -704,7 +668,8 @@ QStringList SqlGenerator::getDbSettings(const QString &dbSchema) const
|
|||||||
|
|
||||||
QStringList SqlGenerator::getAllSqlStmts(const QString& dbSchema, ExerciseDependency ed) const
|
QStringList SqlGenerator::getAllSqlStmts(const QString& dbSchema, ExerciseDependency ed) const
|
||||||
{
|
{
|
||||||
DEBUG_LOG(m_logger) << "Creating statements for service " << getServiceAbbr() << " in exercise " << m_exerciseId << ", this: " << this;
|
DEBUG_LOG(m_logger) << "Creating statements for service " << getServiceAbbr() << " in exercise " << m_exerciseId
|
||||||
|
<< ", this: " << this;
|
||||||
|
|
||||||
QStringList data;
|
QStringList data;
|
||||||
|
|
||||||
@@ -715,50 +680,44 @@ QStringList SqlGenerator::getAllSqlStmts(const QString &dbSchema, ExerciseDepend
|
|||||||
if (!dbSchema.isEmpty())
|
if (!dbSchema.isEmpty())
|
||||||
data << getDbSettings(dbSchema);
|
data << getDbSettings(dbSchema);
|
||||||
|
|
||||||
|
|
||||||
data.append(QStringLiteral("\n-- Drop tables/views/sequences/constraints"));
|
data.append(QStringLiteral("\n-- Drop tables/views/sequences/constraints"));
|
||||||
data.append(sql.dropViews);
|
data.append(sql.dropViews);
|
||||||
data.append(sql.dropConstraints);
|
data.append(sql.dropConstraints);
|
||||||
data.append(sql.dropTables);
|
data.append(sql.dropTables);
|
||||||
data.append(sql.dropSequences);
|
data.append(sql.dropSequences);
|
||||||
|
|
||||||
|
|
||||||
data.append(QStringLiteral("\n-- Create tables"));
|
data.append(QStringLiteral("\n-- Create tables"));
|
||||||
data.append(sql.createTables);
|
data.append(sql.createTables);
|
||||||
|
|
||||||
|
|
||||||
data.append(QStringLiteral("\n-- Create sequence(s)"));
|
data.append(QStringLiteral("\n-- Create sequence(s)"));
|
||||||
data.append(sql.createSequences);
|
data.append(sql.createSequences);
|
||||||
|
|
||||||
|
|
||||||
data.append(QStringLiteral("\n-- Create primary keys"));
|
data.append(QStringLiteral("\n-- Create primary keys"));
|
||||||
data.append(sql.createPrimaryKeys);
|
data.append(sql.createPrimaryKeys);
|
||||||
|
|
||||||
|
|
||||||
data.append(QStringLiteral("\n-- Create foreign keys"));
|
data.append(QStringLiteral("\n-- Create foreign keys"));
|
||||||
data.append(sql.createForeignKeys);
|
data.append(sql.createForeignKeys);
|
||||||
|
|
||||||
|
|
||||||
data.append(QStringLiteral("\n-- Create views"));
|
data.append(QStringLiteral("\n-- Create views"));
|
||||||
data.append(sql.createViews);
|
data.append(sql.createViews);
|
||||||
|
|
||||||
|
data.append(
|
||||||
data.append(QStringLiteral("\n-- --------------------------------------------------------------------------------"));
|
QStringLiteral("\n-- --------------------------------------------------------------------------------"));
|
||||||
data.append(QStringLiteral("\n-- Inserts for static data i.e. enums\n"));
|
data.append(QStringLiteral("\n-- Inserts for static data i.e. enums\n"));
|
||||||
data.append(sql.enumerationValues);
|
data.append(sql.enumerationValues);
|
||||||
|
|
||||||
|
data.append(
|
||||||
data.append(QStringLiteral("\n-- --------------------------------------------------------------------------------"));
|
QStringLiteral("\n-- --------------------------------------------------------------------------------"));
|
||||||
data.append(QStringLiteral("\n-- Notify functions for callbacks (signals in db interface)\n"));
|
data.append(QStringLiteral("\n-- Notify functions for callbacks (signals in db interface)\n"));
|
||||||
data.append(sql.dbFunctions);
|
data.append(sql.dbFunctions);
|
||||||
|
|
||||||
|
data.append(
|
||||||
data.append(QStringLiteral("\n-- --------------------------------------------------------------------------------"));
|
QStringLiteral("\n-- --------------------------------------------------------------------------------"));
|
||||||
data.append(QStringLiteral("\n-- Notify function trigger for callbacks (signals in db interface)\n"));
|
data.append(QStringLiteral("\n-- Notify function trigger for callbacks (signals in db interface)\n"));
|
||||||
data.append(sql.dbFunctionTrigger);
|
data.append(sql.dbFunctionTrigger);
|
||||||
|
|
||||||
|
data.append(
|
||||||
data.append(QStringLiteral("\n-- --------------------------------------------------------------------------------"));
|
QStringLiteral("\n-- --------------------------------------------------------------------------------"));
|
||||||
data.append(QStringLiteral("\n-- Indexes \n"));
|
data.append(QStringLiteral("\n-- Indexes \n"));
|
||||||
data.append(sql.createConstraints);
|
data.append(sql.createConstraints);
|
||||||
|
|
||||||
@@ -786,7 +745,6 @@ bool SqlGenerator::writeSql(const QString &filePath, ExerciseDependency ed)
|
|||||||
{
|
{
|
||||||
Q_ASSERT(ed == Global || ed == Exercise);
|
Q_ASSERT(ed == Global || ed == Exercise);
|
||||||
|
|
||||||
|
|
||||||
QString sqlFile = filePath + getServiceAbbr();
|
QString sqlFile = filePath + getServiceAbbr();
|
||||||
if (ed == ExerciseDependency::Exercise)
|
if (ed == ExerciseDependency::Exercise)
|
||||||
sqlFile += QLatin1Char('_') + getExerciseSchemaName(m_exerciseId);
|
sqlFile += QLatin1Char('_') + getExerciseSchemaName(m_exerciseId);
|
||||||
@@ -799,22 +757,15 @@ bool SqlGenerator::writeSql(const QString &filePath, ExerciseDependency ed)
|
|||||||
return writeFile(sqlFile, QString());
|
return writeFile(sqlFile, QString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QString dbSchema =
|
||||||
|
(ed == ExerciseDependency::Exercise ? getExerciseSchemaName(m_exerciseId) : getServiceAbbr());
|
||||||
const QString dbSchema = (ed == ExerciseDependency::Exercise ?
|
|
||||||
getExerciseSchemaName(m_exerciseId) :
|
|
||||||
getServiceAbbr());
|
|
||||||
|
|
||||||
INFO_LOG(m_logger) << "Creating sql-stmt for schema (" << dbSchema << ")";
|
INFO_LOG(m_logger) << "Creating sql-stmt for schema (" << dbSchema << ")";
|
||||||
return writeSqlToFile(dbSchema, sqlFile, ed);
|
return writeSqlToFile(dbSchema, sqlFile, ed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
static void addInternal(QStringList &global,
|
static void addInternal(QStringList& global, QStringList& exercise, const T& stmt, ExerciseDependency ed)
|
||||||
QStringList &exercise,
|
|
||||||
const T &stmt,
|
|
||||||
ExerciseDependency ed)
|
|
||||||
{
|
{
|
||||||
switch (ed)
|
switch (ed)
|
||||||
{
|
{
|
||||||
@@ -928,8 +879,7 @@ bool SqlGenerator::writeFile(const QString &fn, const QString &content) const
|
|||||||
QFile f(fn);
|
QFile f(fn);
|
||||||
if (!f.open(QIODevice::WriteOnly | QIODevice::Truncate))
|
if (!f.open(QIODevice::WriteOnly | QIODevice::Truncate))
|
||||||
{
|
{
|
||||||
ERROR_LOG(m_logger) << "Error opening file '" << f.fileName() << "' for writing: "
|
ERROR_LOG(m_logger) << "Error opening file '" << f.fileName() << "' for writing: " << f.errorString();
|
||||||
<< f.errorString();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
f.write(content.toUtf8());
|
f.write(content.toUtf8());
|
||||||
|
|||||||
Executable → Regular
+41
-17
@@ -2,11 +2,12 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QStringList>
|
|
||||||
#include <QSharedPointer>
|
|
||||||
#include "StructBuilder.h"
|
#include "StructBuilder.h"
|
||||||
#include "codegen_base_export.h"
|
#include "codegen_base_export.h"
|
||||||
|
|
||||||
|
#include <QSharedPointer>
|
||||||
|
#include <QStringList>
|
||||||
|
|
||||||
namespace NGL
|
namespace NGL
|
||||||
{
|
{
|
||||||
class INGLLogger;
|
class INGLLogger;
|
||||||
@@ -65,7 +66,10 @@ public:
|
|||||||
|
|
||||||
~SqlGenerator();
|
~SqlGenerator();
|
||||||
|
|
||||||
bool isValid() const { return m_isValid; }
|
bool isValid() const
|
||||||
|
{
|
||||||
|
return m_isValid;
|
||||||
|
}
|
||||||
|
|
||||||
bool generateData(int exerciseId);
|
bool generateData(int exerciseId);
|
||||||
|
|
||||||
@@ -82,6 +86,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
QStringList getEnumerationInsertValues(const QString& table, const QString& dbSchema) const;
|
QStringList getEnumerationInsertValues(const QString& table, const QString& dbSchema) const;
|
||||||
|
|
||||||
QStringList getReferencedServices() const
|
QStringList getReferencedServices() const
|
||||||
{
|
{
|
||||||
return m_referencedSevices;
|
return m_referencedSevices;
|
||||||
@@ -89,44 +94,63 @@ public:
|
|||||||
|
|
||||||
QStringList getDbSettings(const QString& dbSchema) const;
|
QStringList getDbSettings(const QString& dbSchema) const;
|
||||||
|
|
||||||
|
|
||||||
bool writeSql(const QString& filePath, ExerciseDependency ed);
|
bool writeSql(const QString& filePath, ExerciseDependency ed);
|
||||||
|
|
||||||
bool writeSqlToFile(const QString& dbSchema, const QString& sqlFile, ExerciseDependency ed) const;
|
bool writeSqlToFile(const QString& dbSchema, const QString& sqlFile, ExerciseDependency ed) const;
|
||||||
|
|
||||||
|
QString getServiceAbbr() const
|
||||||
|
{
|
||||||
|
return m_xmlReader->getServiceAbbr();
|
||||||
|
}
|
||||||
|
|
||||||
QString getServiceAbbr() const { return m_xmlReader->getServiceAbbr(); }
|
bool isServiceExerciseIndependent() const
|
||||||
bool isServiceExerciseIndependent() const { return m_xmlReader->isServiceExerciseIndependent(); }
|
{
|
||||||
bool isServiceGlobal() const { return (m_xmlReader->defaultExerciseDependency() == CodeGen::ExerciseDependency::Global || m_xmlReader->defaultExerciseDependency() == CodeGen::ExerciseDependency::GlobalAndExercise); }
|
return m_xmlReader->isServiceExerciseIndependent();
|
||||||
CodeGen::ExerciseDependency getExerciseDependency() const { return m_xmlReader->defaultExerciseDependency();}
|
}
|
||||||
QStringList getGroupNames() const { return m_xmlReader->getGroupNames(); }
|
|
||||||
|
bool isServiceGlobal() const
|
||||||
|
{
|
||||||
|
return (m_xmlReader->defaultExerciseDependency() == CodeGen::ExerciseDependency::Global ||
|
||||||
|
m_xmlReader->defaultExerciseDependency() == CodeGen::ExerciseDependency::GlobalAndExercise);
|
||||||
|
}
|
||||||
|
|
||||||
|
CodeGen::ExerciseDependency getExerciseDependency() const
|
||||||
|
{
|
||||||
|
return m_xmlReader->defaultExerciseDependency();
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList getGroupNames() const
|
||||||
|
{
|
||||||
|
return m_xmlReader->getGroupNames();
|
||||||
|
}
|
||||||
|
|
||||||
QStringList getAllSqlStmts(const QString& dbSchema, ExerciseDependency ed) const;
|
QStringList getAllSqlStmts(const QString& dbSchema, ExerciseDependency ed) const;
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
NGL::INGLLogger& m_logger;
|
NGL::INGLLogger& m_logger;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool handleTables();
|
bool handleTables();
|
||||||
bool handleViews();
|
bool handleViews();
|
||||||
bool handleTable(const CompleteTableInformation& cti);
|
bool handleTable(const CompleteTableInformation& cti);
|
||||||
bool handleView(const ViewInformation& vi);
|
bool handleView(const ViewInformation& vi);
|
||||||
QString getTableColumnCreateStatements(const QString &tableName,
|
QString getTableColumnCreateStatements(const QString& tableName, const QVector<MemberInformation>& columns,
|
||||||
const QVector<MemberInformation> &columns,
|
|
||||||
QStringList* tableComments, ExerciseDependency ed);
|
QStringList* tableComments, ExerciseDependency ed);
|
||||||
QString generateSequence(const QString& tableName, const FullQualifiedColumnInformation& ci, ExerciseDependency ed);
|
QString generateSequence(const QString& tableName, const FullQualifiedColumnInformation& ci, ExerciseDependency ed);
|
||||||
void generatePrimaryKey(const QString& tableName, const FullQualifiedColumnInformation& ci, ExerciseDependency ed);
|
void generatePrimaryKey(const QString& tableName, const FullQualifiedColumnInformation& ci, ExerciseDependency ed);
|
||||||
void generateForeignKeys(const QVector<QSharedPointer<ForeignKeyInformation>>& foreignKeys, ExerciseDependency ed);
|
void generateForeignKeys(const QVector<QSharedPointer<ForeignKeyInformation>>& foreignKeys, ExerciseDependency ed);
|
||||||
void generateForeignKey(const QSharedPointer<ForeignKeyInformation>& foreignKey, ExerciseDependency ed);
|
void generateForeignKey(const QSharedPointer<ForeignKeyInformation>& foreignKey, ExerciseDependency ed);
|
||||||
void generateConstraints(const QString &tableName, const QVector<ConstraintInformation> &constraints, ExerciseDependency ed);
|
void generateConstraints(const QString& tableName, const QVector<ConstraintInformation>& constraints,
|
||||||
|
ExerciseDependency ed);
|
||||||
void generateConstraint(const QString& tableName, const ConstraintInformation& constraint, ExerciseDependency ed);
|
void generateConstraint(const QString& tableName, const ConstraintInformation& constraint, ExerciseDependency ed);
|
||||||
bool handleEnumerations();
|
bool handleEnumerations();
|
||||||
bool handleEnumeration(const EnumInformation& ei);
|
bool handleEnumeration(const EnumInformation& ei);
|
||||||
QStringList handleEnumeration(const EnumInformation& ei, const QString& dbSchema) const;
|
QStringList handleEnumeration(const EnumInformation& ei, const QString& dbSchema) const;
|
||||||
bool generateDbNotifications(const QString &tableName, const QVector<DbNotifcationInformation> ¬ifications, ExerciseDependency ed);
|
bool generateDbNotifications(const QString& tableName, const QVector<DbNotifcationInformation>& notifications,
|
||||||
|
ExerciseDependency ed);
|
||||||
void generateDbNotification(const DbNotifcationInformation& notification, ExerciseDependency ed);
|
void generateDbNotification(const DbNotifcationInformation& notification, ExerciseDependency ed);
|
||||||
bool generateDbNotificationTrigger(const QString &tableName, const DbNotifcationInformation ¬ification, ExerciseDependency ed);
|
bool generateDbNotificationTrigger(const QString& tableName, const DbNotifcationInformation& notification,
|
||||||
|
ExerciseDependency ed);
|
||||||
QString getNotificationFunctionName(const DbNotifcationInformation& notification) const;
|
QString getNotificationFunctionName(const DbNotifcationInformation& notification) const;
|
||||||
static QString fixupComment(const QString& comment);
|
static QString fixupComment(const QString& comment);
|
||||||
|
|
||||||
@@ -171,4 +195,4 @@ private:
|
|||||||
int m_exerciseId;
|
int m_exerciseId;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace CodeGen
|
||||||
Executable → Regular
+135
-205
@@ -1,27 +1,27 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "StructBuilder.h"
|
#include "StructBuilder.h"
|
||||||
|
|
||||||
|
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
|
||||||
|
|
||||||
using namespace CodeGen;
|
using namespace CodeGen;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class DataTypeInfoIdl : public DataTypeInfo
|
class DataTypeInfoIdl : public DataTypeInfo
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
DataTypeInfoIdl(const QString& name, const QString& idlType, bool isPod)
|
DataTypeInfoIdl(const QString& name, const QString& idlType, bool isPod)
|
||||||
: DataTypeInfo(name, isPod)
|
: DataTypeInfo(name, isPod), m_idlType(idlType)
|
||||||
, m_idlType(idlType)
|
{
|
||||||
{}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QString idlType() const override final { return m_idlType; }
|
QString idlType() const override final
|
||||||
|
{
|
||||||
|
return m_idlType;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const QString m_idlType;
|
const QString m_idlType;
|
||||||
};
|
};
|
||||||
@@ -29,20 +29,27 @@ private:
|
|||||||
class DataTypeInfoSimple : public DataTypeInfoIdl
|
class DataTypeInfoSimple : public DataTypeInfoIdl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DataTypeInfoSimple(const QString &name,
|
DataTypeInfoSimple(const QString& name, const QString& idlType, const QString& ddsType, const QString& sqlType,
|
||||||
const QString &idlType,
|
const QString& cppType, bool isPod)
|
||||||
const QString &ddsType,
|
: DataTypeInfoIdl(name, idlType, isPod), m_ddsType(ddsType), m_sqlType(sqlType), m_cppType(cppType)
|
||||||
const QString &sqlType,
|
{
|
||||||
const QString &cppType,
|
}
|
||||||
bool isPod)
|
|
||||||
: DataTypeInfoIdl(name, idlType, isPod)
|
QString ddsType() const override final
|
||||||
, m_ddsType(ddsType)
|
{
|
||||||
, m_sqlType(sqlType)
|
return m_ddsType;
|
||||||
, m_cppType(cppType)
|
}
|
||||||
{}
|
|
||||||
QString ddsType() const override final { return m_ddsType; }
|
QString sqlType() const override final
|
||||||
QString sqlType() const override final { return m_sqlType; }
|
{
|
||||||
QString cppType() const override final { return m_cppType; }
|
return m_sqlType;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString cppType() const override final
|
||||||
|
{
|
||||||
|
return m_cppType;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QString m_ddsType;
|
QString m_ddsType;
|
||||||
QString m_sqlType;
|
QString m_sqlType;
|
||||||
@@ -67,8 +74,17 @@ public:
|
|||||||
else
|
else
|
||||||
m_ddsType = m_serviceName + QStringLiteral("::") + ctti.name;
|
m_ddsType = m_serviceName + QStringLiteral("::") + ctti.name;
|
||||||
}
|
}
|
||||||
bool isStructure() const override final { return true; }
|
|
||||||
virtual QVector<QSharedPointer<DataTypeInfo>> member() const override final { return m_member; }
|
bool isStructure() const override final
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual QVector<QSharedPointer<DataTypeInfo>> member() const override final
|
||||||
|
{
|
||||||
|
return m_member;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QVector<QSharedPointer<DataTypeInfo>> m_member;
|
QVector<QSharedPointer<DataTypeInfo>> m_member;
|
||||||
QString m_serviceName;
|
QString m_serviceName;
|
||||||
@@ -77,7 +93,8 @@ private:
|
|||||||
class DataTypeInfoSequence final : public DataTypeInfoIdl
|
class DataTypeInfoSequence final : public DataTypeInfoIdl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DataTypeInfoSequence(const QString &name, const QString &idlType, StructBuilder *structBuilder, const QString &svcName)
|
DataTypeInfoSequence(const QString& name, const QString& idlType, StructBuilder* structBuilder,
|
||||||
|
const QString& svcName)
|
||||||
: DataTypeInfoIdl(name, idlType, false)
|
: DataTypeInfoIdl(name, idlType, false)
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -93,116 +110,93 @@ public:
|
|||||||
{
|
{
|
||||||
return QLatin1String("std::vector<") + m_innerDataType->ddsType() + QLatin1Char('>');
|
return QLatin1String("std::vector<") + m_innerDataType->ddsType() + QLatin1Char('>');
|
||||||
}
|
}
|
||||||
|
|
||||||
QString sqlType() const override final
|
QString sqlType() const override final
|
||||||
{
|
{
|
||||||
return QStringLiteral("jsonb");
|
return QStringLiteral("jsonb");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString cppType() const override final
|
QString cppType() const override final
|
||||||
{
|
{
|
||||||
return QLatin1String("std::vector<") + m_innerDataType->cppType() + QLatin1Char('>');
|
return QLatin1String("std::vector<") + m_innerDataType->cppType() + QLatin1Char('>');
|
||||||
}
|
}
|
||||||
|
|
||||||
QString cppTypeConstRef() const override final
|
QString cppTypeConstRef() const override final
|
||||||
{
|
{
|
||||||
return QLatin1String("const std::vector<") + m_innerDataType->cppType() + QLatin1String("> &");
|
return QLatin1String("const std::vector<") + m_innerDataType->cppType() + QLatin1String("> &");
|
||||||
}
|
}
|
||||||
virtual bool isSequence() const override final { return true; }
|
|
||||||
QSharedPointer<DataTypeInfo> innerDataType() const override final { return m_innerDataType; }
|
virtual bool isSequence() const override final
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
QSharedPointer<DataTypeInfo> innerDataType() const override final
|
||||||
|
{
|
||||||
|
return m_innerDataType;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QSharedPointer<DataTypeInfo> m_innerDataType;
|
QSharedPointer<DataTypeInfo> m_innerDataType;
|
||||||
};
|
};
|
||||||
|
|
||||||
QSharedPointer<DataTypeInfo> DataTypeInfo::fromIdlDataType(const QString &name,
|
QSharedPointer<DataTypeInfo> DataTypeInfo::fromIdlDataType(const QString& name, const QString& idlType,
|
||||||
const QString &idlType,
|
StructBuilder* structBuilder, const QString& svcName)
|
||||||
StructBuilder *structBuilder,
|
|
||||||
const QString &svcName)
|
|
||||||
{
|
{
|
||||||
const QString fullIdlType = (svcName.isEmpty() || idlType.contains(QLatin1String("::")))
|
const QString fullIdlType = (svcName.isEmpty() || idlType.contains(QLatin1String("::")))
|
||||||
? idlType : svcName + QLatin1String("::") + idlType;
|
? idlType
|
||||||
|
: svcName + QLatin1String("::") + idlType;
|
||||||
|
|
||||||
if (idlType == QLatin1String("sequence<octet>"))
|
if (idlType == QLatin1String("sequence<octet>"))
|
||||||
return QSharedPointer<DataTypeInfo>(new DataTypeInfoSimple(name,
|
return QSharedPointer<DataTypeInfo>(
|
||||||
idlType,
|
new DataTypeInfoSimple(name, idlType, QStringLiteral("std::vector<uint8_t>"), QStringLiteral("bytea"),
|
||||||
QStringLiteral("std::vector<uint8_t>"),
|
QStringLiteral("QByteArray"), false));
|
||||||
QStringLiteral("bytea"),
|
|
||||||
QStringLiteral("QByteArray"),
|
|
||||||
false));
|
|
||||||
if (idlType == QLatin1String("boolean"))
|
if (idlType == QLatin1String("boolean"))
|
||||||
return QSharedPointer<DataTypeInfo>(new DataTypeInfoSimple(name,
|
return QSharedPointer<DataTypeInfo>(new DataTypeInfoSimple(
|
||||||
idlType,
|
name, idlType, QStringLiteral("bool"), QStringLiteral("boolean"), QStringLiteral("bool"), true));
|
||||||
QStringLiteral("bool"),
|
|
||||||
QStringLiteral("boolean"),
|
|
||||||
QStringLiteral("bool"),
|
|
||||||
true));
|
|
||||||
if (idlType == QLatin1String("char"))
|
if (idlType == QLatin1String("char"))
|
||||||
return QSharedPointer<DataTypeInfo>(new DataTypeInfoSimple(name,
|
return QSharedPointer<DataTypeInfo>(new DataTypeInfoSimple(
|
||||||
idlType,
|
name, idlType, QStringLiteral("char"), QStringLiteral("char"), QStringLiteral("char"), true));
|
||||||
QStringLiteral("char"),
|
|
||||||
QStringLiteral("char"),
|
|
||||||
QStringLiteral("char"),
|
|
||||||
true));
|
|
||||||
if (idlType == QLatin1String("double"))
|
if (idlType == QLatin1String("double"))
|
||||||
return QSharedPointer<DataTypeInfo>(new DataTypeInfoSimple(name,
|
return QSharedPointer<DataTypeInfo>(new DataTypeInfoSimple(name, idlType, QStringLiteral("double"),
|
||||||
idlType,
|
|
||||||
QStringLiteral("double"),
|
|
||||||
QStringLiteral("double precision"),
|
QStringLiteral("double precision"),
|
||||||
QStringLiteral("double"),
|
QStringLiteral("double"), true));
|
||||||
true));
|
|
||||||
if (idlType == QLatin1String("long"))
|
if (idlType == QLatin1String("long"))
|
||||||
return QSharedPointer<DataTypeInfo>(new DataTypeInfoSimple(name,
|
return QSharedPointer<DataTypeInfo>(new DataTypeInfoSimple(
|
||||||
idlType,
|
name, idlType, QStringLiteral("int32_t"), QStringLiteral("integer"), QStringLiteral("qint32"), true));
|
||||||
QStringLiteral("int32_t"),
|
|
||||||
QStringLiteral("integer"),
|
|
||||||
QStringLiteral("qint32"),
|
|
||||||
true));
|
|
||||||
if (idlType == QLatin1String("long long"))
|
if (idlType == QLatin1String("long long"))
|
||||||
return QSharedPointer<DataTypeInfo>(new DataTypeInfoSimple(name,
|
return QSharedPointer<DataTypeInfo>(new DataTypeInfoSimple(name, idlType, QStringLiteral("rti::core::int64"),
|
||||||
idlType,
|
QStringLiteral("bigint"), QStringLiteral("qint64"),
|
||||||
QStringLiteral("rti::core::int64"),
|
|
||||||
QStringLiteral("bigint"),
|
|
||||||
QStringLiteral("qint64"),
|
|
||||||
true));
|
true));
|
||||||
if (idlType == QLatin1String("short"))
|
if (idlType == QLatin1String("short"))
|
||||||
return QSharedPointer<DataTypeInfo>(new DataTypeInfoSimple(name,
|
return QSharedPointer<DataTypeInfo>(new DataTypeInfoSimple(
|
||||||
idlType,
|
name, idlType, QStringLiteral("int16_t"), QStringLiteral("smallint"), QStringLiteral("qint16"), true));
|
||||||
QStringLiteral("int16_t"),
|
|
||||||
QStringLiteral("smallint"),
|
|
||||||
QStringLiteral("qint16"),
|
|
||||||
true));
|
|
||||||
if (idlType.startsWith(QLatin1String("string")))
|
if (idlType.startsWith(QLatin1String("string")))
|
||||||
return QSharedPointer<DataTypeInfo>(new DataTypeInfoSimple(name,
|
return QSharedPointer<DataTypeInfo>(new DataTypeInfoSimple(name, idlType, QStringLiteral("std::string"),
|
||||||
idlType,
|
|
||||||
QStringLiteral("std::string"),
|
|
||||||
QStringLiteral("text"),
|
QStringLiteral("text"),
|
||||||
QStringLiteral("std::string"),
|
QStringLiteral("std::string"), false));
|
||||||
false));
|
|
||||||
if (idlType.startsWith(QLatin1String("sequence")))
|
if (idlType.startsWith(QLatin1String("sequence")))
|
||||||
return QSharedPointer<DataTypeInfo>(new DataTypeInfoSequence(name, idlType, structBuilder, svcName));
|
return QSharedPointer<DataTypeInfo>(new DataTypeInfoSequence(name, idlType, structBuilder, svcName));
|
||||||
|
|
||||||
|
|
||||||
const EnumInformation ei = structBuilder->enumInformationByType(fullIdlType, true, false);
|
const EnumInformation ei = structBuilder->enumInformationByType(fullIdlType, true, false);
|
||||||
if (ei.isValid())
|
if (ei.isValid())
|
||||||
return QSharedPointer<DataTypeInfo>(new DataTypeInfoSimple(name, idlType, ei.enumName, QStringLiteral("integer"), ei.enumName, true));
|
return QSharedPointer<DataTypeInfo>(
|
||||||
|
new DataTypeInfoSimple(name, idlType, ei.enumName, QStringLiteral("integer"), ei.enumName, true));
|
||||||
|
|
||||||
const CompleteTopicTypeInformation ctti = structBuilder->topicTypeInformationByStructType(fullIdlType, true);
|
const CompleteTopicTypeInformation ctti = structBuilder->topicTypeInformationByStructType(fullIdlType, true);
|
||||||
if (ctti.isValid())
|
if (ctti.isValid())
|
||||||
return QSharedPointer<DataTypeInfo>(new DataTypeInfoStructure(name, idlType, structBuilder));
|
return QSharedPointer<DataTypeInfo>(new DataTypeInfoStructure(name, idlType, structBuilder));
|
||||||
|
|
||||||
|
return QSharedPointer<DataTypeInfo>(
|
||||||
return QSharedPointer<DataTypeInfo>(new DataTypeInfoSimple(name, idlType, idlType, QStringLiteral("integer"), idlType, true));
|
new DataTypeInfoSimple(name, idlType, idlType, QStringLiteral("integer"), idlType, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
StructBuilder::StructBuilder(XmlReader* xmlReader)
|
StructBuilder::StructBuilder(XmlReader* xmlReader)
|
||||||
: m_needPoint3d(false)
|
: m_needPoint3d(false), m_needPgArrayInclude(false), m_xmlReader(xmlReader),
|
||||||
, m_needPgArrayInclude(false)
|
m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("CodeGen.StructBuilder")),
|
||||||
, m_xmlReader(xmlReader)
|
m_loggerCSV(NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("fileCSV"))
|
||||||
, m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("CodeGen.StructBuilder"))
|
{
|
||||||
, m_loggerCSV(NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("fileCSV"))
|
}
|
||||||
{}
|
|
||||||
|
|
||||||
bool StructBuilder::buildStructures()
|
bool StructBuilder::buildStructures()
|
||||||
{
|
{
|
||||||
@@ -219,7 +213,6 @@ bool StructBuilder::buildStructures()
|
|||||||
m_needPoint3d = false;
|
m_needPoint3d = false;
|
||||||
m_needPgArrayInclude = false;
|
m_needPgArrayInclude = false;
|
||||||
|
|
||||||
|
|
||||||
const QMap<QString, QSharedPointer<TableInformation>> tables = m_xmlReader->getTables();
|
const QMap<QString, QSharedPointer<TableInformation>> tables = m_xmlReader->getTables();
|
||||||
for (const QSharedPointer<TableInformation>& ti : tables)
|
for (const QSharedPointer<TableInformation>& ti : tables)
|
||||||
{
|
{
|
||||||
@@ -240,7 +233,6 @@ bool StructBuilder::buildStructures()
|
|||||||
m_sqlViewInformations[vi->name] = cti;
|
m_sqlViewInformations[vi->name] = cti;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const QVector<EnumInformation> enumData = m_xmlReader->getEnumerations();
|
const QVector<EnumInformation> enumData = m_xmlReader->getEnumerations();
|
||||||
for (const EnumInformation& ei : enumData)
|
for (const EnumInformation& ei : enumData)
|
||||||
{
|
{
|
||||||
@@ -282,15 +274,14 @@ bool StructBuilder::handleEnum(const EnumInformation &ei)
|
|||||||
{
|
{
|
||||||
m_enumInfos.push_back(ei);
|
m_enumInfos.push_back(ei);
|
||||||
|
|
||||||
|
|
||||||
if (ei.tableName.isEmpty())
|
if (ei.tableName.isEmpty())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
QSharedPointer<TableInformation> ti = m_xmlReader->getTable(ei.tableName);
|
QSharedPointer<TableInformation> ti = m_xmlReader->getTable(ei.tableName);
|
||||||
if (ti.isNull())
|
if (ti.isNull())
|
||||||
{
|
{
|
||||||
WARNING_LOG(m_logger) << "Could not find table information for enum: "
|
WARNING_LOG(m_logger) << "Could not find table information for enum: " << ei.enumName
|
||||||
<< ei.enumName << ", table: " << ei.tableName;
|
<< ", table: " << ei.tableName;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -400,7 +391,6 @@ bool StructBuilder::loadExternalTopicType(const ServiceTypeStruct &sts)
|
|||||||
{
|
{
|
||||||
DEBUG_LOG(m_logger) << "loadExternalTopicType(" << sts.fqType() << ")";
|
DEBUG_LOG(m_logger) << "loadExternalTopicType(" << sts.fqType() << ")";
|
||||||
|
|
||||||
|
|
||||||
const TopicTypeInformation tti = m_xmlReader->loadExternalTopicType(sts.service, sts.type);
|
const TopicTypeInformation tti = m_xmlReader->loadExternalTopicType(sts.service, sts.type);
|
||||||
if (!tti.isValid())
|
if (!tti.isValid())
|
||||||
{
|
{
|
||||||
@@ -413,9 +403,7 @@ bool StructBuilder::loadExternalTopicType(const ServiceTypeStruct &sts)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool StructBuilder::getColumnsFromTable(const QString& tableName, QVector<ColumnInformationEx>& columns,
|
||||||
bool StructBuilder::getColumnsFromTable(const QString &tableName,
|
|
||||||
QVector<ColumnInformationEx> &columns,
|
|
||||||
QVector<QString>& tableNames) const
|
QVector<QString>& tableNames) const
|
||||||
{
|
{
|
||||||
if (tableName.isEmpty())
|
if (tableName.isEmpty())
|
||||||
@@ -470,21 +458,17 @@ bool StructBuilder::handleTable(const ServiceStructInformation &ssi)
|
|||||||
DEBUG_LOG(m_loggerCSV) << "primaryTable: " << csi.primaryTable.data();
|
DEBUG_LOG(m_loggerCSV) << "primaryTable: " << csi.primaryTable.data();
|
||||||
DEBUG_LOG(m_loggerCSV) << "hasStaticContent: " << csi.hasStaticContent;
|
DEBUG_LOG(m_loggerCSV) << "hasStaticContent: " << csi.hasStaticContent;
|
||||||
|
|
||||||
|
|
||||||
QVector<ColumnInformationEx> columns;
|
QVector<ColumnInformationEx> columns;
|
||||||
QVector<QString> tableNames;
|
QVector<QString> tableNames;
|
||||||
if (!getColumnsFromTable(ssi.primaryTable, columns, tableNames))
|
if (!getColumnsFromTable(ssi.primaryTable, columns, tableNames))
|
||||||
{
|
{
|
||||||
WARNING_LOG(m_logger) << "Could not retrieve columns from table "
|
WARNING_LOG(m_logger) << "Could not retrieve columns from table " << ssi.primaryTable;
|
||||||
<< ssi.primaryTable;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
DEBUG_LOG(m_logger) << "Got " << columns.size() << " columns for table "
|
DEBUG_LOG(m_logger) << "Got " << columns.size() << " columns for table " << ssi.primaryTable;
|
||||||
<< ssi.primaryTable;
|
|
||||||
|
|
||||||
QSet<QString> sqlTables;
|
QSet<QString> sqlTables;
|
||||||
|
|
||||||
|
|
||||||
csi.member.reserve(columns.size() + 1);
|
csi.member.reserve(columns.size() + 1);
|
||||||
MemberInformation miPkFirstTable, miPkLastTable;
|
MemberInformation miPkFirstTable, miPkLastTable;
|
||||||
for (const ColumnInformationEx& ci : std::as_const(columns))
|
for (const ColumnInformationEx& ci : std::as_const(columns))
|
||||||
@@ -494,8 +478,8 @@ bool StructBuilder::handleTable(const ServiceStructInformation &ssi)
|
|||||||
const QSharedPointer<TableInformation> ti = ci.table;
|
const QSharedPointer<TableInformation> ti = ci.table;
|
||||||
if (ti.isNull())
|
if (ti.isNull())
|
||||||
{
|
{
|
||||||
WARNING_LOG(m_logger) << "Could not find table for column " << ci.columnName
|
WARNING_LOG(m_logger) << "Could not find table for column " << ci.columnName << " primary table is "
|
||||||
<< " primary table is " << ssi.primaryTable.data();
|
<< ssi.primaryTable.data();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
csi.tables += ti;
|
csi.tables += ti;
|
||||||
@@ -571,8 +555,7 @@ bool StructBuilder::handleTable(const ServiceStructInformation &ssi)
|
|||||||
ei = enumInformationByType(enumType, true, false);
|
ei = enumInformationByType(enumType, true, false);
|
||||||
DEBUG_LOG(m_logger) << "Checking if " << enumType << " is an enum: " << ei.isValid();
|
DEBUG_LOG(m_logger) << "Checking if " << enumType << " is an enum: " << ei.isValid();
|
||||||
}
|
}
|
||||||
if (ei.isValid() &&
|
if (ei.isValid() && ei.tableName == fki->destination.tableName)
|
||||||
ei.tableName == fki->destination.tableName)
|
|
||||||
memberInfo.enumeration = QSharedPointer<EnumInformation>(new EnumInformation(ei));
|
memberInfo.enumeration = QSharedPointer<EnumInformation>(new EnumInformation(ei));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -594,12 +577,10 @@ bool StructBuilder::handleTable(const ServiceStructInformation &ssi)
|
|||||||
memberInfo.cpp.type = memberInfo.ea.type;
|
memberInfo.cpp.type = memberInfo.ea.type;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fixupCustomDbDatatypes(memberInfo, csi.member) ||
|
if (!fixupCustomDbDatatypes(memberInfo, csi.member) || !fixupQVariantConversions(memberInfo))
|
||||||
!fixupQVariantConversions(memberInfo))
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!fixupCustomDbDatatypes(memberInfoJson, csi.member) ||
|
if (!fixupCustomDbDatatypes(memberInfoJson, csi.member) || !fixupQVariantConversions(memberInfoJson))
|
||||||
!fixupQVariantConversions(memberInfoJson))
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (ci.isPrimaryKey && tableNames.first() == ti->name)
|
if (ci.isPrimaryKey && tableNames.first() == ti->name)
|
||||||
@@ -632,13 +613,11 @@ bool StructBuilder::handleTable(const ServiceStructInformation &ssi)
|
|||||||
if (tableNames.size() > 1 && !miPkLastTable.isEmpty())
|
if (tableNames.size() > 1 && !miPkLastTable.isEmpty())
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
miPkLastTable.db.usedForInsert = false;
|
miPkLastTable.db.usedForInsert = false;
|
||||||
miPkLastTable.db.usedForView = true;
|
miPkLastTable.db.usedForView = true;
|
||||||
miPkLastTable.cpp.usedForCppStruct = true;
|
miPkLastTable.cpp.usedForCppStruct = true;
|
||||||
miPkLastTable.db.isAssignmentForPrimaryTablePk = true;
|
miPkLastTable.db.isAssignmentForPrimaryTablePk = true;
|
||||||
miPkLastTable.db.columnNameView =
|
miPkLastTable.db.columnNameView = miPkLastTable.db.table + QLatin1Char('_') + miPkLastTable.db.columnName;
|
||||||
miPkLastTable.db.table + QLatin1Char('_') + miPkLastTable.db.columnName;
|
|
||||||
|
|
||||||
QString name = miPkLastTable.db.table;
|
QString name = miPkLastTable.db.table;
|
||||||
if (name.startsWith(m_xmlReader->getServiceAbbr().toLower()))
|
if (name.startsWith(m_xmlReader->getServiceAbbr().toLower()))
|
||||||
@@ -647,7 +626,6 @@ bool StructBuilder::handleTable(const ServiceStructInformation &ssi)
|
|||||||
csi.member.push_back(miPkLastTable);
|
csi.member.push_back(miPkLastTable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
m_structInfos.push_back(csi);
|
m_structInfos.push_back(csi);
|
||||||
|
|
||||||
m_sqlTableInformationsAlreadyAvailable += sqlTables;
|
m_sqlTableInformationsAlreadyAvailable += sqlTables;
|
||||||
@@ -655,8 +633,7 @@ bool StructBuilder::handleTable(const ServiceStructInformation &ssi)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool StructBuilder::handleIdlStructInfo(const TopicTypeInformation& tti,
|
bool StructBuilder::handleIdlStructInfo(const TopicTypeInformation& tti,
|
||||||
QVector<CompleteTopicTypeInformation> &destination,
|
QVector<CompleteTopicTypeInformation>& destination, const QString& svcName)
|
||||||
const QString &svcName)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
for (const CompleteTopicTypeInformation& c : std::as_const(destination))
|
for (const CompleteTopicTypeInformation& c : std::as_const(destination))
|
||||||
@@ -668,27 +645,22 @@ bool StructBuilder::handleIdlStructInfo(const TopicTypeInformation &tti,
|
|||||||
CompleteTopicTypeInformation ctti(tti);
|
CompleteTopicTypeInformation ctti(tti);
|
||||||
ctti.members.reserve(tti.columns.size());
|
ctti.members.reserve(tti.columns.size());
|
||||||
|
|
||||||
|
|
||||||
for (const auto& ci : tti.columns)
|
for (const auto& ci : tti.columns)
|
||||||
{
|
{
|
||||||
IdlData idlData(ci);
|
IdlData idlData(ci);
|
||||||
idlData.dataTypeInfo = DataTypeInfo::fromIdlDataType(idlData.name, idlData.type, this, svcName);
|
idlData.dataTypeInfo = DataTypeInfo::fromIdlDataType(idlData.name, idlData.type, this, svcName);
|
||||||
ctti.members.push_back(idlData);
|
ctti.members.push_back(idlData);
|
||||||
|
|
||||||
|
|
||||||
if (idlData.isKey && idlData.isOptional)
|
if (idlData.isKey && idlData.isOptional)
|
||||||
{
|
{
|
||||||
ERROR_LOG(m_logger) << "Column option isKey & isOptional are mutually exclusive!";
|
ERROR_LOG(m_logger) << "Column option isKey & isOptional are mutually exclusive!";
|
||||||
ERROR_LOG(m_logger) << "Change column '" << tti.name << "."
|
ERROR_LOG(m_logger) << "Change column '" << tti.name << "." << idlData.name
|
||||||
<< idlData.name << "'' to have either key or optional parameter ";
|
<< "'' to have either key or optional parameter ";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!svcName.isEmpty() && !ctti.baseValueType.isEmpty() && !ctti.baseValueType.contains(QLatin1String("::")))
|
||||||
if (!svcName.isEmpty() &&
|
|
||||||
!ctti.baseValueType.isEmpty() &&
|
|
||||||
!ctti.baseValueType.contains(QLatin1String("::")))
|
|
||||||
ctti.baseValueType = svcName + QStringLiteral("::") + ctti.baseValueType;
|
ctti.baseValueType = svcName + QStringLiteral("::") + ctti.baseValueType;
|
||||||
|
|
||||||
ctti.serviceName = svcName.isEmpty() ? m_xmlReader->getServiceNamespace() : svcName;
|
ctti.serviceName = svcName.isEmpty() ? m_xmlReader->getServiceNamespace() : svcName;
|
||||||
@@ -709,8 +681,7 @@ bool StructBuilder::fixupCustomDbDatatypes(MemberInformation &memberInfo, QVecto
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StructBuilder::fixupDatatypePoint2d(MemberInformation &memberInfo,
|
bool StructBuilder::fixupDatatypePoint2d(MemberInformation& memberInfo, QVector<MemberInformation>& members)
|
||||||
QVector<MemberInformation> &members)
|
|
||||||
{
|
{
|
||||||
if (memberInfo.ea.type.toLower() != QLatin1String("point_2d"))
|
if (memberInfo.ea.type.toLower() != QLatin1String("point_2d"))
|
||||||
return true;
|
return true;
|
||||||
@@ -720,7 +691,6 @@ bool StructBuilder::fixupDatatypePoint2d(MemberInformation &memberInfo,
|
|||||||
mi.cpp.type = QStringLiteral("QPointF");
|
mi.cpp.type = QStringLiteral("QPointF");
|
||||||
mi.cpp.fromVariantPost = QStringLiteral(".toDouble()");
|
mi.cpp.fromVariantPost = QStringLiteral(".toDouble()");
|
||||||
|
|
||||||
|
|
||||||
MemberInformation miX = mi;
|
MemberInformation miX = mi;
|
||||||
MemberInformation miY = mi;
|
MemberInformation miY = mi;
|
||||||
|
|
||||||
@@ -738,7 +708,6 @@ bool StructBuilder::fixupDatatypePoint2d(MemberInformation &memberInfo,
|
|||||||
|
|
||||||
miX.cpp.memberName = camelCaseString(miX.cpp.memberName);
|
miX.cpp.memberName = camelCaseString(miX.cpp.memberName);
|
||||||
|
|
||||||
|
|
||||||
miX.cpp.toJsonPre = QStringLiteral("toJson(");
|
miX.cpp.toJsonPre = QStringLiteral("toJson(");
|
||||||
miX.cpp.toJsonPost = QStringLiteral(")");
|
miX.cpp.toJsonPost = QStringLiteral(")");
|
||||||
miX.cpp.fromJsonPre2 = QStringLiteral("fromJson<QPointF>(");
|
miX.cpp.fromJsonPre2 = QStringLiteral("fromJson<QPointF>(");
|
||||||
@@ -756,8 +725,7 @@ bool StructBuilder::fixupDatatypePoint2d(MemberInformation &memberInfo,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StructBuilder::fixupDatatypePoint3d(MemberInformation &memberInfo,
|
bool StructBuilder::fixupDatatypePoint3d(MemberInformation& memberInfo, QVector<MemberInformation>& members)
|
||||||
QVector<MemberInformation> &members)
|
|
||||||
{
|
{
|
||||||
if (memberInfo.ea.type.toLower() != QLatin1String("point_3d"))
|
if (memberInfo.ea.type.toLower() != QLatin1String("point_3d"))
|
||||||
return true;
|
return true;
|
||||||
@@ -767,7 +735,6 @@ bool StructBuilder::fixupDatatypePoint3d(MemberInformation &memberInfo,
|
|||||||
mi.cpp.type = QStringLiteral("LtsUtils::QPoint3D");
|
mi.cpp.type = QStringLiteral("LtsUtils::QPoint3D");
|
||||||
mi.cpp.fromVariantPost = QStringLiteral(".toDouble()");
|
mi.cpp.fromVariantPost = QStringLiteral(".toDouble()");
|
||||||
|
|
||||||
|
|
||||||
MemberInformation miX = mi;
|
MemberInformation miX = mi;
|
||||||
MemberInformation miY = mi;
|
MemberInformation miY = mi;
|
||||||
MemberInformation miZ = mi;
|
MemberInformation miZ = mi;
|
||||||
@@ -791,7 +758,6 @@ bool StructBuilder::fixupDatatypePoint3d(MemberInformation &memberInfo,
|
|||||||
|
|
||||||
miX.cpp.memberName = camelCaseString(miX.cpp.memberName);
|
miX.cpp.memberName = camelCaseString(miX.cpp.memberName);
|
||||||
|
|
||||||
|
|
||||||
miX.cpp.toJsonPre = QStringLiteral("toJson(");
|
miX.cpp.toJsonPre = QStringLiteral("toJson(");
|
||||||
miX.cpp.toJsonPost = QStringLiteral(")");
|
miX.cpp.toJsonPost = QStringLiteral(")");
|
||||||
miX.cpp.fromJsonPre2 = QStringLiteral("fromJson<LtsUtils::QPoint3D>(");
|
miX.cpp.fromJsonPre2 = QStringLiteral("fromJson<LtsUtils::QPoint3D>(");
|
||||||
@@ -872,7 +838,6 @@ bool StructBuilder::fixupDatatypeIntegerArray(MemberInformation &memberInfo)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool StructBuilder::fixupQVariantConversions(MemberInformation& mi) const
|
bool StructBuilder::fixupQVariantConversions(MemberInformation& mi) const
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -890,22 +855,20 @@ bool StructBuilder::fixupQVariantConversions(MemberInformation &mi) const
|
|||||||
if (!svcName.isEmpty())
|
if (!svcName.isEmpty())
|
||||||
svcName += QStringLiteral("::");
|
svcName += QStringLiteral("::");
|
||||||
mi.cpp.type = svcName + mi.enumeration->enumName;
|
mi.cpp.type = svcName + mi.enumeration->enumName;
|
||||||
mi.cpp.fromVariantPre2 = QStringLiteral("static_cast<") +
|
mi.cpp.fromVariantPre2 =
|
||||||
svcName + mi.enumeration->enumName +
|
QStringLiteral("static_cast<") + svcName + mi.enumeration->enumName + QStringLiteral("_def::type>(");
|
||||||
QStringLiteral("_def::type>(");
|
|
||||||
mi.cpp.fromVariantPost = QStringLiteral(".toInt())");
|
mi.cpp.fromVariantPost = QStringLiteral(".toInt())");
|
||||||
mi.cpp.toVariantPre = QStringLiteral("static_cast<int>(");
|
mi.cpp.toVariantPre = QStringLiteral("static_cast<int>(");
|
||||||
mi.cpp.toVariantPost = QStringLiteral(".underlying())");
|
mi.cpp.toVariantPost = QStringLiteral(".underlying())");
|
||||||
if (!mi.enumeration->values.isEmpty())
|
if (!mi.enumeration->values.isEmpty())
|
||||||
{
|
{
|
||||||
mi.cpp.defaultValue = svcName + mi.enumeration->enumName + QStringLiteral("::") +
|
mi.cpp.defaultValue =
|
||||||
mi.enumeration->values.first().key;
|
svcName + mi.enumeration->enumName + QStringLiteral("::") + mi.enumeration->values.first().key;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
const QString datatype = mi.cpp.type.toLower();
|
const QString datatype = mi.cpp.type.toLower();
|
||||||
if (datatype == QLatin1String("bigint") ||
|
if (datatype == QLatin1String("bigint") || datatype == QLatin1String("qint64") ||
|
||||||
datatype == QLatin1String("qint64") ||
|
|
||||||
datatype == QLatin1String("long long"))
|
datatype == QLatin1String("long long"))
|
||||||
{
|
{
|
||||||
mi.cpp.type = QStringLiteral("qint64");
|
mi.cpp.type = QStringLiteral("qint64");
|
||||||
@@ -913,15 +876,13 @@ bool StructBuilder::fixupQVariantConversions(MemberInformation &mi) const
|
|||||||
mi.cpp.fromJsonPost = QStringLiteral(".toDouble()");
|
mi.cpp.fromJsonPost = QStringLiteral(".toDouble()");
|
||||||
mi.cpp.defaultValue = QLatin1Char('0');
|
mi.cpp.defaultValue = QLatin1Char('0');
|
||||||
}
|
}
|
||||||
else if (datatype == QLatin1String("boolean") ||
|
else if (datatype == QLatin1String("boolean") || datatype == QLatin1String("bool"))
|
||||||
datatype == QLatin1String("bool"))
|
|
||||||
{
|
{
|
||||||
mi.cpp.type = QStringLiteral("bool");
|
mi.cpp.type = QStringLiteral("bool");
|
||||||
mi.cpp.fromVariantPost = QStringLiteral(".toBool()");
|
mi.cpp.fromVariantPost = QStringLiteral(".toBool()");
|
||||||
mi.cpp.defaultValue = QStringLiteral("false");
|
mi.cpp.defaultValue = QStringLiteral("false");
|
||||||
}
|
}
|
||||||
else if (datatype == QLatin1String("bytea") ||
|
else if (datatype == QLatin1String("bytea") || datatype == QLatin1String("QByteArray"))
|
||||||
datatype == QLatin1String("QByteArray"))
|
|
||||||
{
|
{
|
||||||
|
|
||||||
mi.cpp.type = QStringLiteral("QByteArray");
|
mi.cpp.type = QStringLiteral("QByteArray");
|
||||||
@@ -958,50 +919,43 @@ bool StructBuilder::fixupQVariantConversions(MemberInformation &mi) const
|
|||||||
mi.cpp.fromJsonPost = QStringLiteral(".toInt()");
|
mi.cpp.fromJsonPost = QStringLiteral(".toInt()");
|
||||||
mi.cpp.defaultValue = QStringLiteral("\\0");
|
mi.cpp.defaultValue = QStringLiteral("\\0");
|
||||||
}
|
}
|
||||||
else if (datatype == QLatin1String("integer") ||
|
else if (datatype == QLatin1String("integer") || datatype == QLatin1String("qint32") ||
|
||||||
datatype == QLatin1String("qint32") ||
|
|
||||||
datatype == QLatin1String("long"))
|
datatype == QLatin1String("long"))
|
||||||
{
|
{
|
||||||
mi.cpp.type = QStringLiteral("qint32");
|
mi.cpp.type = QStringLiteral("qint32");
|
||||||
mi.cpp.fromVariantPost = QStringLiteral(".toInt()");
|
mi.cpp.fromVariantPost = QStringLiteral(".toInt()");
|
||||||
mi.cpp.defaultValue = QLatin1Char('0');
|
mi.cpp.defaultValue = QLatin1Char('0');
|
||||||
}
|
}
|
||||||
else if (datatype == QLatin1String("real") ||
|
else if (datatype == QLatin1String("real") || datatype == QLatin1String("double") ||
|
||||||
datatype == QLatin1String("double") ||
|
datatype == QLatin1String("double precision") || datatype == QLatin1String("float"))
|
||||||
datatype == QLatin1String("double precision") ||
|
|
||||||
datatype == QLatin1String("float"))
|
|
||||||
{
|
{
|
||||||
mi.cpp.type = QStringLiteral("double");
|
mi.cpp.type = QStringLiteral("double");
|
||||||
mi.cpp.fromVariantPost = QStringLiteral(".toDouble()");
|
mi.cpp.fromVariantPost = QStringLiteral(".toDouble()");
|
||||||
mi.cpp.defaultValue = QStringLiteral("0.0");
|
mi.cpp.defaultValue = QStringLiteral("0.0");
|
||||||
mi.db.datatype = QStringLiteral("double precision");
|
mi.db.datatype = QStringLiteral("double precision");
|
||||||
}
|
}
|
||||||
else if (datatype == QLatin1String("numeric") ||
|
else if (datatype == QLatin1String("numeric") || datatype == QLatin1String("decimal"))
|
||||||
datatype == QLatin1String("decimal"))
|
|
||||||
{
|
{
|
||||||
mi.cpp.type = QStringLiteral("double");
|
mi.cpp.type = QStringLiteral("double");
|
||||||
mi.cpp.fromVariantPost = QStringLiteral(".toDouble()");
|
mi.cpp.fromVariantPost = QStringLiteral(".toDouble()");
|
||||||
mi.cpp.defaultValue = QStringLiteral("0.0");
|
mi.cpp.defaultValue = QStringLiteral("0.0");
|
||||||
mi.db.datatype = QStringLiteral("numeric");
|
mi.db.datatype = QStringLiteral("numeric");
|
||||||
}
|
}
|
||||||
else if (datatype == QLatin1String("smallint") ||
|
else if (datatype == QLatin1String("smallint") || datatype == QLatin1String("qint16") ||
|
||||||
datatype == QLatin1String("qint16") ||
|
|
||||||
datatype == QLatin1String("short"))
|
datatype == QLatin1String("short"))
|
||||||
{
|
{
|
||||||
mi.cpp.type = QStringLiteral("qint16");
|
mi.cpp.type = QStringLiteral("qint16");
|
||||||
mi.cpp.fromVariantPost = QStringLiteral(".toInt()");
|
mi.cpp.fromVariantPost = QStringLiteral(".toInt()");
|
||||||
mi.cpp.defaultValue = QLatin1Char('0');
|
mi.cpp.defaultValue = QLatin1Char('0');
|
||||||
}
|
}
|
||||||
else if (datatype == QLatin1String("text") ||
|
else if (datatype == QLatin1String("text") || datatype == QLatin1String("QString"))
|
||||||
datatype == QLatin1String("QString"))
|
|
||||||
{
|
{
|
||||||
|
|
||||||
mi.cpp.type = QStringLiteral("QString");
|
mi.cpp.type = QStringLiteral("QString");
|
||||||
mi.cpp.fromVariantPost = QStringLiteral(".toString()");
|
mi.cpp.fromVariantPost = QStringLiteral(".toString()");
|
||||||
mi.cpp.defaultValue = QString();
|
mi.cpp.defaultValue = QString();
|
||||||
}
|
}
|
||||||
else if (datatype == QLatin1String("json") ||
|
else if (datatype == QLatin1String("json") || datatype == QLatin1String("jsonb"))
|
||||||
datatype == QLatin1String("jsonb"))
|
|
||||||
{
|
{
|
||||||
|
|
||||||
mi.cpp.type = QStringLiteral("QString");
|
mi.cpp.type = QStringLiteral("QString");
|
||||||
@@ -1025,8 +979,7 @@ bool StructBuilder::fixupQVariantConversions(MemberInformation &mi) const
|
|||||||
mi.cpp.fromJsonPre2 = QStringLiteral("fromJson<std::string>(");
|
mi.cpp.fromJsonPre2 = QStringLiteral("fromJson<std::string>(");
|
||||||
mi.cpp.fromJsonPost = QStringLiteral(")");
|
mi.cpp.fromJsonPost = QStringLiteral(")");
|
||||||
}
|
}
|
||||||
else if (datatype == QLatin1String("timestamp") ||
|
else if (datatype == QLatin1String("timestamp") || datatype == QLatin1String("qdatetime"))
|
||||||
datatype == QLatin1String("qdatetime"))
|
|
||||||
{
|
{
|
||||||
mi.db.datatype = QStringLiteral("bigint");
|
mi.db.datatype = QStringLiteral("bigint");
|
||||||
if (mi.db.defaultValue.toLower() == QStringLiteral("now()"))
|
if (mi.db.defaultValue.toLower() == QStringLiteral("now()"))
|
||||||
@@ -1043,7 +996,6 @@ bool StructBuilder::fixupQVariantConversions(MemberInformation &mi) const
|
|||||||
}
|
}
|
||||||
else if (datatype == QLatin1String("qvariant"))
|
else if (datatype == QLatin1String("qvariant"))
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1053,11 +1005,6 @@ bool StructBuilder::fixupQVariantConversions(MemberInformation &mi) const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
QVector<MemberInformation> StructBuilder::buildDbTableInformationFromIdlData(const CompleteTopicTypeInformation& ctti,
|
QVector<MemberInformation> StructBuilder::buildDbTableInformationFromIdlData(const CompleteTopicTypeInformation& ctti,
|
||||||
const QString& tableName,
|
const QString& tableName,
|
||||||
const QString& columnNamePrefix,
|
const QString& columnNamePrefix,
|
||||||
@@ -1069,10 +1016,8 @@ QVector<MemberInformation> StructBuilder::buildDbTableInformationFromIdlData(con
|
|||||||
|
|
||||||
if (!ctti.baseValueType.isEmpty())
|
if (!ctti.baseValueType.isEmpty())
|
||||||
{
|
{
|
||||||
ret += buildDbTableInformationFromIdlData(topicTypeInformationByStructType(ctti.baseValueType),
|
ret += buildDbTableInformationFromIdlData(topicTypeInformationByStructType(ctti.baseValueType), tableName,
|
||||||
tableName,
|
columnNamePrefix, cppStructure);
|
||||||
columnNamePrefix,
|
|
||||||
cppStructure);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const IdlData& member : ctti.members)
|
for (const IdlData& member : ctti.members)
|
||||||
@@ -1089,28 +1034,21 @@ QVector<MemberInformation> StructBuilder::buildDbTableInformationFromIdlData(con
|
|||||||
if (!columnNamePrefix.isEmpty())
|
if (!columnNamePrefix.isEmpty())
|
||||||
pre += columnNamePrefix;
|
pre += columnNamePrefix;
|
||||||
pre += member.name + QLatin1Char('_');
|
pre += member.name + QLatin1Char('_');
|
||||||
ret += buildDbTableInformationFromIdlData(cttiChild,
|
ret += buildDbTableInformationFromIdlData(cttiChild, tableName, StructBuilder::camelCaseToUnderline(pre),
|
||||||
tableName,
|
cppStructure + member.name + QStringLiteral("()."));
|
||||||
StructBuilder::camelCaseToUnderline(pre),
|
|
||||||
cppStructure + member.name + QStringLiteral("().")
|
|
||||||
);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (member.dataTypeInfo->isSequence() && member.dataTypeInfo->innerDataType()->isStructure())
|
if (member.dataTypeInfo->isSequence() && member.dataTypeInfo->innerDataType()->isStructure())
|
||||||
{
|
{
|
||||||
const CompleteTopicTypeInformation &cttiChild = topicTypeInformationByStructType(member.dataTypeInfo->innerDataType()->idlType());
|
const CompleteTopicTypeInformation& cttiChild =
|
||||||
|
topicTypeInformationByStructType(member.dataTypeInfo->innerDataType()->idlType());
|
||||||
if (!cttiChild.isValid())
|
if (!cttiChild.isValid())
|
||||||
{
|
{
|
||||||
ERROR_LOG(m_logger) << "Can not find structure '" << member.type << "'";
|
ERROR_LOG(m_logger) << "Can not find structure '" << member.type << "'";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
buildDbTableInformationFromIdlData(cttiChild,
|
buildDbTableInformationFromIdlData(cttiChild, tableName, columnNamePrefix, member.name);
|
||||||
tableName,
|
|
||||||
columnNamePrefix,
|
|
||||||
member.name
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MemberInformation mi;
|
MemberInformation mi;
|
||||||
@@ -1124,23 +1062,22 @@ QVector<MemberInformation> StructBuilder::buildDbTableInformationFromIdlData(con
|
|||||||
mi.cpp.usedForCppStruct = true;
|
mi.cpp.usedForCppStruct = true;
|
||||||
mi.cpp.isOptional = member.isOptional;
|
mi.cpp.isOptional = member.isOptional;
|
||||||
|
|
||||||
|
|
||||||
const EnumInformation ei = enumInformationByType(member.type, true, false);
|
const EnumInformation ei = enumInformationByType(member.type, true, false);
|
||||||
if (ei.isValid())
|
if (ei.isValid())
|
||||||
mi.enumeration = QSharedPointer<EnumInformation>(new EnumInformation(ei));
|
mi.enumeration = QSharedPointer<EnumInformation>(new EnumInformation(ei));
|
||||||
|
|
||||||
if ((member.dataTypeInfo->isSequence() && member.dataTypeInfo->innerDataType()->idlType() != QLatin1String("octet")) ||
|
if ((member.dataTypeInfo->isSequence() &&
|
||||||
|
member.dataTypeInfo->innerDataType()->idlType() != QLatin1String("octet")) ||
|
||||||
(member.dataTypeInfo->isStructure() && member.isOptional))
|
(member.dataTypeInfo->isStructure() && member.isOptional))
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
mi.db.datatype = QStringLiteral("jsonb");
|
mi.db.datatype = QStringLiteral("jsonb");
|
||||||
mi.cpp.toJsonPre = QStringLiteral("toJson(");
|
mi.cpp.toJsonPre = QStringLiteral("toJson(");
|
||||||
mi.cpp.toJsonPost = QStringLiteral(")");
|
mi.cpp.toJsonPost = QStringLiteral(")");
|
||||||
mi.cpp.type = member.dataTypeInfo->ddsType();
|
mi.cpp.type = member.dataTypeInfo->ddsType();
|
||||||
|
|
||||||
|
mi.cpp.fromVariantPre2 =
|
||||||
mi.cpp.fromVariantPre2 = QStringLiteral("fromJson<") + member.dataTypeInfo->ddsType() + QStringLiteral(">(");
|
QStringLiteral("fromJson<") + member.dataTypeInfo->ddsType() + QStringLiteral(">(");
|
||||||
mi.cpp.fromVariantPost = QStringLiteral(")");
|
mi.cpp.fromVariantPost = QStringLiteral(")");
|
||||||
|
|
||||||
if (member.dataTypeInfo->isSequence())
|
if (member.dataTypeInfo->isSequence())
|
||||||
@@ -1158,11 +1095,6 @@ QVector<MemberInformation> StructBuilder::buildDbTableInformationFromIdlData(con
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool StructBuilder::buildJSonStructureInformationFromIdlData(const CompleteTopicTypeInformation& ctti)
|
bool StructBuilder::buildJSonStructureInformationFromIdlData(const CompleteTopicTypeInformation& ctti)
|
||||||
{
|
{
|
||||||
if (!ctti.isValid())
|
if (!ctti.isValid())
|
||||||
@@ -1206,8 +1138,8 @@ bool StructBuilder::buildJSonStructureInformationFromIdlData(const CompleteTopic
|
|||||||
mi.cpp.toJsonPost = QStringLiteral(")");
|
mi.cpp.toJsonPost = QStringLiteral(")");
|
||||||
mi.cpp.type = member.dataTypeInfo->ddsType();
|
mi.cpp.type = member.dataTypeInfo->ddsType();
|
||||||
|
|
||||||
|
mi.cpp.fromVariantPre2 =
|
||||||
mi.cpp.fromVariantPre2 = QStringLiteral("fromJson<") + member.dataTypeInfo->ddsType() + QStringLiteral(">(");
|
QStringLiteral("fromJson<") + member.dataTypeInfo->ddsType() + QStringLiteral(">(");
|
||||||
mi.cpp.fromVariantPost = QStringLiteral(")");
|
mi.cpp.fromVariantPost = QStringLiteral(")");
|
||||||
}
|
}
|
||||||
else if (member.dataTypeInfo->isSequence() &&
|
else if (member.dataTypeInfo->isSequence() &&
|
||||||
@@ -1226,15 +1158,13 @@ bool StructBuilder::buildJSonStructureInformationFromIdlData(const CompleteTopic
|
|||||||
WARNING_LOG(m_logger) << "Can not find structure '" << member.type << "'";
|
WARNING_LOG(m_logger) << "Can not find structure '" << member.type << "'";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
mi.db.datatype = QStringLiteral("jsonb");
|
mi.db.datatype = QStringLiteral("jsonb");
|
||||||
mi.cpp.toJsonPre = QStringLiteral("toJson(");
|
mi.cpp.toJsonPre = QStringLiteral("toJson(");
|
||||||
mi.cpp.toJsonPost = QStringLiteral(")");
|
mi.cpp.toJsonPost = QStringLiteral(")");
|
||||||
mi.cpp.type = member.dataTypeInfo->ddsType();
|
mi.cpp.type = member.dataTypeInfo->ddsType();
|
||||||
|
|
||||||
|
mi.cpp.fromVariantPre2 =
|
||||||
mi.cpp.fromVariantPre2 = QStringLiteral("fromJson<") + member.dataTypeInfo->ddsType() + QStringLiteral(">(");
|
QStringLiteral("fromJson<") + member.dataTypeInfo->ddsType() + QStringLiteral(">(");
|
||||||
mi.cpp.fromVariantPost = QStringLiteral(")");
|
mi.cpp.fromVariantPost = QStringLiteral(")");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
Executable → Regular
+118
-74
@@ -2,10 +2,11 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QtCore/QString>
|
|
||||||
#include "XmlReader.h"
|
#include "XmlReader.h"
|
||||||
#include "codegen_base_export.h"
|
#include "codegen_base_export.h"
|
||||||
|
|
||||||
|
#include <QtCore/QString>
|
||||||
|
|
||||||
namespace NGL
|
namespace NGL
|
||||||
{
|
{
|
||||||
class INGLLogger;
|
class INGLLogger;
|
||||||
@@ -23,9 +24,7 @@ struct EaData
|
|||||||
|
|
||||||
QString toString() const
|
QString toString() const
|
||||||
{
|
{
|
||||||
return table +
|
return table + QLatin1Char(';') + column + QLatin1Char(';') + type;
|
||||||
QLatin1Char(';') + column +
|
|
||||||
QLatin1Char(';') + type;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -36,51 +35,80 @@ struct FullQualifiedColumnInformation : public ColumnInformation
|
|||||||
bool usedForView = false;
|
bool usedForView = false;
|
||||||
QString columnNameView;
|
QString columnNameView;
|
||||||
|
|
||||||
QString getColumnNameView() const { return columnNameView.isEmpty() ? columnName : columnNameView; }
|
QString getColumnNameView() const
|
||||||
|
{
|
||||||
|
return columnNameView.isEmpty() ? columnName : columnNameView;
|
||||||
|
}
|
||||||
|
|
||||||
FullQualifiedColumnInformation() = default;
|
FullQualifiedColumnInformation() = default;
|
||||||
|
|
||||||
FullQualifiedColumnInformation(const ColumnInformation& ci, const QString& tableName)
|
FullQualifiedColumnInformation(const ColumnInformation& ci, const QString& tableName)
|
||||||
: ColumnInformation(ci)
|
: ColumnInformation(ci), table(tableName)
|
||||||
, table(tableName)
|
{
|
||||||
{}
|
}
|
||||||
|
|
||||||
QString toString() const
|
QString toString() const
|
||||||
{
|
{
|
||||||
return table +
|
return table + QLatin1Char(';') + columnName + QLatin1Char(';') + datatype +
|
||||||
QLatin1Char(';') + columnName +
|
|
||||||
QLatin1Char(';') + datatype +
|
|
||||||
|
|
||||||
QLatin1Char(';') + (isPrimaryKey ? QLatin1String("true") : QLatin1String("false")) +
|
QLatin1Char(';') + (isPrimaryKey ? QLatin1String("true") : QLatin1String("false")) + QLatin1Char(';') +
|
||||||
QLatin1Char(';') + (isForeignKey ? QLatin1String("true") : QLatin1String("false")) +
|
(isForeignKey ? QLatin1String("true") : QLatin1String("false")) + QLatin1Char(';') +
|
||||||
QLatin1Char(';') + (usedForInsert ? QLatin1String("true") : QLatin1String("false")) +
|
(usedForInsert ? QLatin1String("true") : QLatin1String("false")) + QLatin1Char(';') +
|
||||||
QLatin1Char(';') + (usedForView ? QLatin1String("true") : QLatin1String("false"));
|
(usedForView ? QLatin1String("true") : QLatin1String("false"));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class DataTypeInfo
|
class DataTypeInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DataTypeInfo(const QString &name, bool isPod)
|
DataTypeInfo(const QString& name, bool isPod) : m_name(name), m_isPod(isPod) {}
|
||||||
: m_name(name)
|
|
||||||
, m_isPod(isPod)
|
|
||||||
{}
|
|
||||||
virtual ~DataTypeInfo() = default;
|
virtual ~DataTypeInfo() = default;
|
||||||
virtual QString name() const { return m_name; }
|
|
||||||
|
virtual QString name() const
|
||||||
|
{
|
||||||
|
return m_name;
|
||||||
|
}
|
||||||
|
|
||||||
virtual QString idlType() const = 0;
|
virtual QString idlType() const = 0;
|
||||||
virtual QString ddsType() const = 0;
|
virtual QString ddsType() const = 0;
|
||||||
virtual QString sqlType() const = 0;
|
virtual QString sqlType() const = 0;
|
||||||
virtual QString cppType() const = 0;
|
virtual QString cppType() const = 0;
|
||||||
virtual QString cppTypeConstRef() const { return isPod() ? cppType() : QLatin1String("const ") + cppType() + QLatin1String(" &"); }
|
|
||||||
virtual bool isPod() const { return m_isPod; }
|
|
||||||
virtual bool isSequence() const { return false; }
|
|
||||||
virtual bool isStructure() const { return false; }
|
|
||||||
virtual QVector<QSharedPointer<DataTypeInfo>> member() const { return QVector<QSharedPointer<DataTypeInfo>>(); }
|
|
||||||
virtual QSharedPointer<DataTypeInfo> innerDataType() const { return QSharedPointer<DataTypeInfo>(); }
|
|
||||||
|
|
||||||
static QSharedPointer<DataTypeInfo> fromIdlDataType(const QString &name,
|
virtual QString cppTypeConstRef() const
|
||||||
const QString &idlType,
|
{
|
||||||
|
return isPod() ? cppType() : QLatin1String("const ") + cppType() + QLatin1String(" &");
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool isPod() const
|
||||||
|
{
|
||||||
|
return m_isPod;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool isSequence() const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool isStructure() const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual QVector<QSharedPointer<DataTypeInfo>> member() const
|
||||||
|
{
|
||||||
|
return QVector<QSharedPointer<DataTypeInfo>>();
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual QSharedPointer<DataTypeInfo> innerDataType() const
|
||||||
|
{
|
||||||
|
return QSharedPointer<DataTypeInfo>();
|
||||||
|
}
|
||||||
|
|
||||||
|
static QSharedPointer<DataTypeInfo> fromIdlDataType(const QString& name, const QString& idlType,
|
||||||
StructBuilder* structBuilder,
|
StructBuilder* structBuilder,
|
||||||
const QString& svcName = QString());
|
const QString& svcName = QString());
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const QString m_name;
|
const QString m_name;
|
||||||
const bool m_isPod;
|
const bool m_isPod;
|
||||||
@@ -91,22 +119,18 @@ struct IdlData : public IdlColumnInformation
|
|||||||
QSharedPointer<DataTypeInfo> dataTypeInfo;
|
QSharedPointer<DataTypeInfo> dataTypeInfo;
|
||||||
|
|
||||||
IdlData() = default;
|
IdlData() = default;
|
||||||
explicit IdlData(const IdlColumnInformation &ci)
|
|
||||||
: IdlColumnInformation(ci)
|
explicit IdlData(const IdlColumnInformation& ci) : IdlColumnInformation(ci) {}
|
||||||
{}
|
|
||||||
|
|
||||||
QString toString() const
|
QString toString() const
|
||||||
{
|
{
|
||||||
return name +
|
return name + QLatin1Char(';') + type +
|
||||||
QLatin1Char(';') + type +
|
|
||||||
|
|
||||||
QLatin1Char(';') + (isKey ? QLatin1String("true") : QLatin1String("false")) +
|
QLatin1Char(';') + (isKey ? QLatin1String("true") : QLatin1String("false")) + QLatin1Char(';') +
|
||||||
QLatin1Char(';') + (isOptional ? QLatin1String("true") : QLatin1String("false"));
|
(isOptional ? QLatin1String("true") : QLatin1String("false"));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct CppData
|
struct CppData
|
||||||
{
|
{
|
||||||
QString structName;
|
QString structName;
|
||||||
@@ -131,16 +155,11 @@ struct CppData
|
|||||||
|
|
||||||
QString toString() const
|
QString toString() const
|
||||||
{
|
{
|
||||||
return structName +
|
return structName + QLatin1Char(';') + memberName + QLatin1Char(';') +
|
||||||
QLatin1Char(';') + memberName +
|
(usedForCppStruct ? QLatin1String("true") : QLatin1String("false")) + QLatin1Char(';') +
|
||||||
QLatin1Char(';') + (usedForCppStruct ? QLatin1String("true") : QLatin1String("false")) +
|
(isReadOnly ? QLatin1String("true") : QLatin1String("false")) + QLatin1Char(';') + type +
|
||||||
QLatin1Char(';') + (isReadOnly ? QLatin1String("true") : QLatin1String("false")) +
|
QLatin1Char(';') + toVariantPre + QLatin1Char(';') + toVariantPost + QLatin1Char(';') + fromVariantPre1 +
|
||||||
QLatin1Char(';') + type +
|
QLatin1Char(';') + fromVariantPre2 + QLatin1Char(';') + fromVariantPost;
|
||||||
QLatin1Char(';') + toVariantPre +
|
|
||||||
QLatin1Char(';') + toVariantPost +
|
|
||||||
QLatin1Char(';') + fromVariantPre1 +
|
|
||||||
QLatin1Char(';') + fromVariantPre2 +
|
|
||||||
QLatin1Char(';') + fromVariantPost;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -155,10 +174,9 @@ struct MemberInformation
|
|||||||
|
|
||||||
QString toString() const
|
QString toString() const
|
||||||
{
|
{
|
||||||
return ea.toString() + QLatin1Char(';') +
|
return ea.toString() + QLatin1Char(';') + db.toString() + QLatin1Char(';') + cpp.toString();
|
||||||
db.toString() + QLatin1Char(';') +
|
|
||||||
cpp.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isEmpty() const
|
bool isEmpty() const
|
||||||
{
|
{
|
||||||
return ea.column.isEmpty();
|
return ea.column.isEmpty();
|
||||||
@@ -188,23 +206,32 @@ struct CompleteTopicTypeInformation final : public TopicTypeInformationBase
|
|||||||
QVector<IdlData> members;
|
QVector<IdlData> members;
|
||||||
|
|
||||||
CompleteTopicTypeInformation() = default;
|
CompleteTopicTypeInformation() = default;
|
||||||
explicit CompleteTopicTypeInformation(const TopicTypeInformationBase &s)
|
|
||||||
: TopicTypeInformationBase(s)
|
|
||||||
{}
|
|
||||||
|
|
||||||
bool hasBaseValue() const { return !baseValueType.isEmpty(); }
|
explicit CompleteTopicTypeInformation(const TopicTypeInformationBase& s) : TopicTypeInformationBase(s) {}
|
||||||
bool isValid() const { return TopicTypeInformationBase::isValid() && !members.isEmpty(); }
|
|
||||||
|
bool hasBaseValue() const
|
||||||
|
{
|
||||||
|
return !baseValueType.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isValid() const
|
||||||
|
{
|
||||||
|
return TopicTypeInformationBase::isValid() && !members.isEmpty();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct CompleteTableInformation : public TableInformation
|
struct CompleteTableInformation : public TableInformation
|
||||||
{
|
{
|
||||||
QVector<MemberInformation> columns;
|
QVector<MemberInformation> columns;
|
||||||
explicit CompleteTableInformation(const TableInformation &o)
|
|
||||||
: TableInformation(o)
|
explicit CompleteTableInformation(const TableInformation& o) : TableInformation(o) {}
|
||||||
{}
|
|
||||||
CompleteTableInformation() = default;
|
CompleteTableInformation() = default;
|
||||||
bool isEmpty() const { return columns.isEmpty(); }
|
|
||||||
|
bool isEmpty() const
|
||||||
|
{
|
||||||
|
return columns.isEmpty();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class CODEGEN_BASE_EXPORT StructBuilder
|
class CODEGEN_BASE_EXPORT StructBuilder
|
||||||
@@ -214,11 +241,11 @@ class CODEGEN_BASE_EXPORT StructBuilder
|
|||||||
QSharedPointer<TableInformation> table;
|
QSharedPointer<TableInformation> table;
|
||||||
|
|
||||||
ColumnInformationEx() = default;
|
ColumnInformationEx() = default;
|
||||||
ColumnInformationEx(const ColumnInformation &o,
|
|
||||||
const QSharedPointer<TableInformation> &ti)
|
ColumnInformationEx(const ColumnInformation& o, const QSharedPointer<TableInformation>& ti)
|
||||||
: ColumnInformation(o)
|
: ColumnInformation(o), table(ti)
|
||||||
, table(ti)
|
{
|
||||||
{}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -227,19 +254,33 @@ public:
|
|||||||
QString service;
|
QString service;
|
||||||
QString type;
|
QString type;
|
||||||
bool bIsSequence = false;
|
bool bIsSequence = false;
|
||||||
bool isExternalType() const { return !service.isEmpty(); }
|
|
||||||
bool isSequence() const { return bIsSequence; }
|
bool isExternalType() const
|
||||||
QString fqType() const { return service + QStringLiteral("::") + type; }
|
{
|
||||||
|
return !service.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isSequence() const
|
||||||
|
{
|
||||||
|
return bIsSequence;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString fqType() const
|
||||||
|
{
|
||||||
|
return service + QStringLiteral("::") + type;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit StructBuilder(XmlReader* xmlReader);
|
explicit StructBuilder(XmlReader* xmlReader);
|
||||||
~StructBuilder() = default;
|
~StructBuilder() = default;
|
||||||
|
|
||||||
bool buildStructures();
|
bool buildStructures();
|
||||||
|
|
||||||
QVector<CompleteStructInformation> structInformations() const
|
QVector<CompleteStructInformation> structInformations() const
|
||||||
{
|
{
|
||||||
return m_structInfos;
|
return m_structInfos;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<CompleteTopicTypeInformation> topicTypeInformations() const
|
QVector<CompleteTopicTypeInformation> topicTypeInformations() const
|
||||||
{
|
{
|
||||||
return m_topicTypeInfos;
|
return m_topicTypeInfos;
|
||||||
@@ -288,18 +329,20 @@ public:
|
|||||||
Q_REQUIRED_RESULT static QString camelCaseToUnderline(const QString& in);
|
Q_REQUIRED_RESULT static QString camelCaseToUnderline(const QString& in);
|
||||||
|
|
||||||
bool buildJSonStructureInformationFromIdlData(const CompleteTopicTypeInformation& ctti);
|
bool buildJSonStructureInformationFromIdlData(const CompleteTopicTypeInformation& ctti);
|
||||||
QMap<QString, QVector<MemberInformation>> jsonStructureInformation() const { return m_jsonStructureInformation; }
|
|
||||||
|
QMap<QString, QVector<MemberInformation>> jsonStructureInformation() const
|
||||||
|
{
|
||||||
|
return m_jsonStructureInformation;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool handleEnum(const EnumInformation& ei);
|
bool handleEnum(const EnumInformation& ei);
|
||||||
bool handleTable(const ServiceStructInformation& ssi);
|
bool handleTable(const ServiceStructInformation& ssi);
|
||||||
bool handleIdlStructInfo(const TopicTypeInformation &tti,
|
bool handleIdlStructInfo(const TopicTypeInformation& tti, QVector<CompleteTopicTypeInformation>& destination,
|
||||||
QVector<CompleteTopicTypeInformation> &destination,
|
|
||||||
const QString& svcName = QString());
|
const QString& svcName = QString());
|
||||||
bool loadExternalTopicType(const ServiceTypeStruct& sts);
|
bool loadExternalTopicType(const ServiceTypeStruct& sts);
|
||||||
|
|
||||||
bool getColumnsFromTable(const QString &tableName,
|
bool getColumnsFromTable(const QString& tableName, QVector<ColumnInformationEx>& columns,
|
||||||
QVector<ColumnInformationEx> &columns,
|
|
||||||
QVector<QString>& tableNames) const;
|
QVector<QString>& tableNames) const;
|
||||||
|
|
||||||
bool fixupCustomDbDatatypes(MemberInformation& memberInfo, QVector<MemberInformation>& members);
|
bool fixupCustomDbDatatypes(MemberInformation& memberInfo, QVector<MemberInformation>& members);
|
||||||
@@ -319,6 +362,7 @@ private:
|
|||||||
ServiceTypeStruct extractServiceAndTypeFromTypename(const QString& type);
|
ServiceTypeStruct extractServiceAndTypeFromTypename(const QString& type);
|
||||||
|
|
||||||
void addToSqlTableInformation(const MemberInformation& mi);
|
void addToSqlTableInformation(const MemberInformation& mi);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QVector<CompleteStructInformation> m_structInfos;
|
QVector<CompleteStructInformation> m_structInfos;
|
||||||
QVector<CompleteTopicTypeInformation> m_topicTypeInfos;
|
QVector<CompleteTopicTypeInformation> m_topicTypeInfos;
|
||||||
@@ -338,4 +382,4 @@ private:
|
|||||||
NGL::INGLLogger& m_logger;
|
NGL::INGLLogger& m_logger;
|
||||||
NGL::INGLLogger& m_loggerCSV;
|
NGL::INGLLogger& m_loggerCSV;
|
||||||
};
|
};
|
||||||
}
|
} // namespace CodeGen
|
||||||
Executable → Regular
+49
-85
@@ -1,25 +1,21 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "XmlReader.h"
|
#include "XmlReader.h"
|
||||||
#include <utility>
|
|
||||||
|
|
||||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||||
|
|
||||||
#include <QDirIterator>
|
#include <QDirIterator>
|
||||||
#include <QFile>
|
|
||||||
#include <QDomDocument>
|
#include <QDomDocument>
|
||||||
|
#include <QFile>
|
||||||
#include <QXmlStreamReader>
|
#include <QXmlStreamReader>
|
||||||
#include <ngltools/ngltools_filesystem.h>
|
#include <ngltools/ngltools_filesystem.h>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
using namespace CodeGen;
|
using namespace CodeGen;
|
||||||
|
|
||||||
|
|
||||||
class XmlReaderException : public std::exception
|
class XmlReaderException : public std::exception
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit XmlReaderException(const QString &msg) noexcept
|
explicit XmlReaderException(const QString& msg) noexcept : m_msg(msg.toUtf8()) {}
|
||||||
: m_msg(msg.toUtf8())
|
|
||||||
{}
|
|
||||||
|
|
||||||
~XmlReaderException() = default;
|
~XmlReaderException() = default;
|
||||||
|
|
||||||
@@ -27,15 +23,14 @@ public:
|
|||||||
{
|
{
|
||||||
return m_msg.data();
|
return m_msg.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const QByteArray m_msg;
|
const QByteArray m_msg;
|
||||||
};
|
};
|
||||||
|
|
||||||
XmlReader::XmlReader() : m_logger(NGL::NGLLoggerBootstrap::getLogger()) {}
|
XmlReader::XmlReader() : m_logger(NGL::NGLLoggerBootstrap::getLogger()) {}
|
||||||
|
|
||||||
bool XmlReader::readServiceFile(const QString &svcFile,
|
bool XmlReader::readServiceFile(const QString& svcFile, const QString& idlServiceInfoFile, const XmlReader* parent)
|
||||||
const QString &idlServiceInfoFile,
|
|
||||||
const XmlReader *parent)
|
|
||||||
{
|
{
|
||||||
m_externalXmlInformations.clear();
|
m_externalXmlInformations.clear();
|
||||||
m_idlFiles.clear();
|
m_idlFiles.clear();
|
||||||
@@ -61,7 +56,6 @@ bool XmlReader::readServiceFile(const QString &svcFile,
|
|||||||
m_prio = 0;
|
m_prio = 0;
|
||||||
m_svcDevMode = false;
|
m_svcDevMode = false;
|
||||||
|
|
||||||
|
|
||||||
if (parent)
|
if (parent)
|
||||||
{
|
{
|
||||||
m_idlFiles = parent->m_idlFiles;
|
m_idlFiles = parent->m_idlFiles;
|
||||||
@@ -70,11 +64,8 @@ bool XmlReader::readServiceFile(const QString &svcFile,
|
|||||||
m_externalXmlInformations = parent->m_externalXmlInformations;
|
m_externalXmlInformations = parent->m_externalXmlInformations;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
loadIdlInfofile(idlServiceInfoFile);
|
loadIdlInfofile(idlServiceInfoFile);
|
||||||
|
|
||||||
|
|
||||||
QFile f(svcFile);
|
QFile f(svcFile);
|
||||||
if (!f.exists())
|
if (!f.exists())
|
||||||
{
|
{
|
||||||
@@ -83,35 +74,27 @@ bool XmlReader::readServiceFile(const QString &svcFile,
|
|||||||
}
|
}
|
||||||
if (!f.open(QIODevice::ReadOnly))
|
if (!f.open(QIODevice::ReadOnly))
|
||||||
{
|
{
|
||||||
m_errorString = QLatin1String("Can not open service file '") + svcFile +
|
m_errorString =
|
||||||
QLatin1String("' for reading: ") + f.errorString();
|
QLatin1String("Can not open service file '") + svcFile + QLatin1String("' for reading: ") + f.errorString();
|
||||||
ERROR_LOG(m_logger) << m_errorString;
|
ERROR_LOG(m_logger) << m_errorString;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
INFO_LOG(m_logger) << "SvcFile: " << svcFile;
|
INFO_LOG(m_logger) << "SvcFile: " << svcFile;
|
||||||
|
|
||||||
|
|
||||||
QString errMsg;
|
QString errMsg;
|
||||||
int errLine = 0;
|
int errLine = 0;
|
||||||
int errColumn = 0;
|
int errColumn = 0;
|
||||||
QDomDocument doc;
|
QDomDocument doc;
|
||||||
if (!doc.setContent(&f, &errMsg, &errLine, &errColumn))
|
if (!doc.setContent(&f, &errMsg, &errLine, &errColumn))
|
||||||
{
|
{
|
||||||
m_errorString = QLatin1String("Error parsing service file '") + svcFile + QLatin1String("': ") +
|
m_errorString = QLatin1String("Error parsing service file '") + svcFile + QLatin1String("': ") + errMsg +
|
||||||
errMsg + QLatin1String(" at ") + QString::number(errLine) +
|
QLatin1String(" at ") + QString::number(errLine) + QLatin1Char(':') +
|
||||||
QLatin1Char(':') + QString::number(errColumn);
|
QString::number(errColumn);
|
||||||
ERROR_LOG(m_logger) << m_errorString;
|
ERROR_LOG(m_logger) << m_errorString;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
QDomElement domRoot = doc.documentElement();
|
QDomElement domRoot = doc.documentElement();
|
||||||
if (!domRoot.hasAttribute(QStringLiteral("namespace")))
|
if (!domRoot.hasAttribute(QStringLiteral("namespace")))
|
||||||
{
|
{
|
||||||
@@ -126,8 +109,7 @@ bool XmlReader::readServiceFile(const QString &svcFile,
|
|||||||
m_customRecordReplay = getAttributeBool(domRoot, QStringLiteral("customRecordReplay"), true, false);
|
m_customRecordReplay = getAttributeBool(domRoot, QStringLiteral("customRecordReplay"), true, false);
|
||||||
|
|
||||||
QString devModeStr = getAttribute(domRoot, QStringLiteral("devMode"), true);
|
QString devModeStr = getAttribute(domRoot, QStringLiteral("devMode"), true);
|
||||||
m_svcDevMode = devModeStr == QStringLiteral("1") ||
|
m_svcDevMode = devModeStr == QStringLiteral("1") || devModeStr == QStringLiteral("true");
|
||||||
devModeStr == QStringLiteral("true");
|
|
||||||
INFO_LOG(m_logger) << "devMode: " << m_svcDevMode;
|
INFO_LOG(m_logger) << "devMode: " << m_svcDevMode;
|
||||||
|
|
||||||
const QString groupNamesString = getAttribute(domRoot, QStringLiteral("groups"), true);
|
const QString groupNamesString = getAttribute(domRoot, QStringLiteral("groups"), true);
|
||||||
@@ -141,15 +123,13 @@ bool XmlReader::readServiceFile(const QString &svcFile,
|
|||||||
|
|
||||||
m_exerciseDependency = string2ExerciseDependency(getAttribute(domRoot, QStringLiteral("exerciseDependency"), true));
|
m_exerciseDependency = string2ExerciseDependency(getAttribute(domRoot, QStringLiteral("exerciseDependency"), true));
|
||||||
|
|
||||||
|
if (m_groupNames.contains(QStringLiteral("Core")) || m_groupNames.contains(QStringLiteral("Master")))
|
||||||
|
|
||||||
if (m_groupNames.contains(QStringLiteral("Core")) ||
|
|
||||||
m_groupNames.contains(QStringLiteral("Master")))
|
|
||||||
{
|
{
|
||||||
if (m_exerciseDependency != ExerciseDependency::Global &&
|
if (m_exerciseDependency != ExerciseDependency::Global &&
|
||||||
m_exerciseDependency != ExerciseDependency::GlobalAndExercise)
|
m_exerciseDependency != ExerciseDependency::GlobalAndExercise)
|
||||||
{
|
{
|
||||||
WARNING_LOG(m_logger) << "Service " << getServiceNamespace()
|
WARNING_LOG(m_logger)
|
||||||
|
<< "Service " << getServiceNamespace()
|
||||||
<< " is not marked as exercise independent but should be started in group Core/Master";
|
<< " is not marked as exercise independent but should be started in group Core/Master";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -239,23 +219,20 @@ bool XmlReader::readServiceFile(const QString &svcFile,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString XmlReader::getAttribute(const QDomElement &element,
|
QString XmlReader::getAttribute(const QDomElement& element, const QString& attributeName, bool bOptional)
|
||||||
const QString &attributeName,
|
|
||||||
bool bOptional)
|
|
||||||
{
|
{
|
||||||
if (!element.hasAttribute(attributeName))
|
if (!element.hasAttribute(attributeName))
|
||||||
{
|
{
|
||||||
if (bOptional)
|
if (bOptional)
|
||||||
return QString();
|
return QString();
|
||||||
throw XmlReaderException(QLatin1String("Element ") + element.tagName() +
|
throw XmlReaderException(QLatin1String("Element ") + element.tagName() + QLatin1String(" has no attribute ") +
|
||||||
QLatin1String(" has no attribute ") + attributeName);
|
attributeName);
|
||||||
}
|
}
|
||||||
return element.attribute(attributeName);
|
return element.attribute(attributeName);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool XmlReader::getAttributeBool(const QDomElement &element,
|
bool XmlReader::getAttributeBool(const QDomElement& element, const QString& attributeName, bool bOptional,
|
||||||
const QString &attributeName,
|
bool defaultValue)
|
||||||
bool bOptional, bool defaultValue)
|
|
||||||
{
|
{
|
||||||
QString str = getAttribute(element, attributeName, bOptional);
|
QString str = getAttribute(element, attributeName, bOptional);
|
||||||
if (str.isEmpty())
|
if (str.isEmpty())
|
||||||
@@ -267,9 +244,8 @@ bool XmlReader::getAttributeBool(const QDomElement &element,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int XmlReader::getAttributeInt(const QDomElement &element,
|
int XmlReader::getAttributeInt(const QDomElement& element, const QString& attributeName, bool bOptional,
|
||||||
const QString &attributeName,
|
int defaultValue)
|
||||||
bool bOptional, int defaultValue)
|
|
||||||
{
|
{
|
||||||
QString str = getAttribute(element, attributeName, bOptional);
|
QString str = getAttribute(element, attributeName, bOptional);
|
||||||
if (str.isEmpty())
|
if (str.isEmpty())
|
||||||
@@ -291,7 +267,6 @@ void XmlReader::parseDBSserviceStructs(const QDomElement &rootElement)
|
|||||||
if (rootElement.isNull())
|
if (rootElement.isNull())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
QDomElement domDbStruct = rootElement.firstChildElement(QStringLiteral("serviceStruct"));
|
QDomElement domDbStruct = rootElement.firstChildElement(QStringLiteral("serviceStruct"));
|
||||||
while (!domDbStruct.isNull())
|
while (!domDbStruct.isNull())
|
||||||
{
|
{
|
||||||
@@ -320,7 +295,6 @@ void XmlReader::parseDBSserviceStructs(const QDomElement &rootElement)
|
|||||||
}
|
}
|
||||||
std::sort(m_structsToGenerate.begin(), m_structsToGenerate.end());
|
std::sort(m_structsToGenerate.begin(), m_structsToGenerate.end());
|
||||||
|
|
||||||
|
|
||||||
domDbStruct = rootElement.firstChildElement(QStringLiteral("table"));
|
domDbStruct = rootElement.firstChildElement(QStringLiteral("table"));
|
||||||
while (!domDbStruct.isNull())
|
while (!domDbStruct.isNull())
|
||||||
{
|
{
|
||||||
@@ -345,7 +319,8 @@ void XmlReader::parseDBTables(const QDomElement &rootElement)
|
|||||||
ti->name = getAttribute(domDbTable, QStringLiteral("name"));
|
ti->name = getAttribute(domDbTable, QStringLiteral("name"));
|
||||||
ti->structName = QLatin1String("t_") + ti->name;
|
ti->structName = QLatin1String("t_") + ti->name;
|
||||||
ti->comment = getAttribute(domDbTable, QStringLiteral("comment"), true);
|
ti->comment = getAttribute(domDbTable, QStringLiteral("comment"), true);
|
||||||
ti->exerciseDependency = string2ExerciseDependency(getAttribute(domDbTable, QStringLiteral("exerciseDependency"), true));
|
ti->exerciseDependency =
|
||||||
|
string2ExerciseDependency(getAttribute(domDbTable, QStringLiteral("exerciseDependency"), true));
|
||||||
|
|
||||||
QDomElement domColumn = domDbTable.firstChildElement(QStringLiteral("column"));
|
QDomElement domColumn = domDbTable.firstChildElement(QStringLiteral("column"));
|
||||||
while (!domColumn.isNull())
|
while (!domColumn.isNull())
|
||||||
@@ -390,11 +365,11 @@ void XmlReader::parseDBViews(const QDomElement &rootElement)
|
|||||||
vi->baseTable = getAttribute(domDbView, QStringLiteral("base"));
|
vi->baseTable = getAttribute(domDbView, QStringLiteral("base"));
|
||||||
vi->comment = getAttribute(domDbView, QStringLiteral("comment"), true);
|
vi->comment = getAttribute(domDbView, QStringLiteral("comment"), true);
|
||||||
vi->filter = getAttribute(domDbView, QStringLiteral("filter"));
|
vi->filter = getAttribute(domDbView, QStringLiteral("filter"));
|
||||||
vi->exerciseDependency = string2ExerciseDependency(getAttribute(domDbView, QStringLiteral("exerciseDependency"), true));
|
vi->exerciseDependency =
|
||||||
|
string2ExerciseDependency(getAttribute(domDbView, QStringLiteral("exerciseDependency"), true));
|
||||||
|
|
||||||
DEBUG_LOG(m_logger) << "Base table = " << vi->baseTable;
|
DEBUG_LOG(m_logger) << "Base table = " << vi->baseTable;
|
||||||
|
|
||||||
|
|
||||||
m_views.insert(vi->name, vi);
|
m_views.insert(vi->name, vi);
|
||||||
|
|
||||||
domDbView = domDbView.nextSiblingElement(domDbView.tagName());
|
domDbView = domDbView.nextSiblingElement(domDbView.tagName());
|
||||||
@@ -454,14 +429,11 @@ void XmlReader::parseCustomDtcFunctions(const QDomElement &rootElement)
|
|||||||
INFO_LOG(m_logger) << "Read " << m_enumerations.size() << " customDtcFunction(s)";
|
INFO_LOG(m_logger) << "Read " << m_enumerations.size() << " customDtcFunction(s)";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void XmlReader::parseTopicTypes(const QDomElement& rootElement)
|
void XmlReader::parseTopicTypes(const QDomElement& rootElement)
|
||||||
{
|
{
|
||||||
if (rootElement.isNull())
|
if (rootElement.isNull())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
QDomElement domIdlStruct = rootElement.firstChildElement(QStringLiteral("topicType"));
|
QDomElement domIdlStruct = rootElement.firstChildElement(QStringLiteral("topicType"));
|
||||||
while (!domIdlStruct.isNull())
|
while (!domIdlStruct.isNull())
|
||||||
{
|
{
|
||||||
@@ -469,7 +441,6 @@ void XmlReader::parseTopicTypes(const QDomElement &rootElement)
|
|||||||
isi.name = getAttribute(domIdlStruct, QStringLiteral("name"));
|
isi.name = getAttribute(domIdlStruct, QStringLiteral("name"));
|
||||||
isi.baseValueType = getAttribute(domIdlStruct, QStringLiteral("baseValueType"), true);
|
isi.baseValueType = getAttribute(domIdlStruct, QStringLiteral("baseValueType"), true);
|
||||||
|
|
||||||
|
|
||||||
const QStringList sl = isi.baseValueType.split(QStringLiteral("::"));
|
const QStringList sl = isi.baseValueType.split(QStringLiteral("::"));
|
||||||
if (sl.size() == 2)
|
if (sl.size() == 2)
|
||||||
loadExternalTopicType(sl.at(0), sl.at(1));
|
loadExternalTopicType(sl.at(0), sl.at(1));
|
||||||
@@ -477,9 +448,12 @@ void XmlReader::parseTopicTypes(const QDomElement &rootElement)
|
|||||||
const QString tmp = getAttribute(domIdlStruct, QStringLiteral("extensibility"), true);
|
const QString tmp = getAttribute(domIdlStruct, QStringLiteral("extensibility"), true);
|
||||||
|
|
||||||
#ifdef RTI_HEADER_AVAILABLE
|
#ifdef RTI_HEADER_AVAILABLE
|
||||||
if (tmp.compare(QLatin1String("FINAL"), Qt::CaseInsensitive) == 0) isi.extensibility = dds::core::xtypes::ExtensibilityKind::FINAL;
|
if (tmp.compare(QLatin1String("FINAL"), Qt::CaseInsensitive) == 0)
|
||||||
if (tmp.compare(QLatin1String("MUTABLE"), Qt::CaseInsensitive) == 0) isi.extensibility = dds::core::xtypes::ExtensibilityKind::MUTABLE;
|
isi.extensibility = dds::core::xtypes::ExtensibilityKind::FINAL;
|
||||||
if (tmp.compare(QLatin1String("EXTENSIBLE"), Qt::CaseInsensitive) == 0) isi.extensibility = dds::core::xtypes::ExtensibilityKind::EXTENSIBLE;
|
if (tmp.compare(QLatin1String("MUTABLE"), Qt::CaseInsensitive) == 0)
|
||||||
|
isi.extensibility = dds::core::xtypes::ExtensibilityKind::MUTABLE;
|
||||||
|
if (tmp.compare(QLatin1String("EXTENSIBLE"), Qt::CaseInsensitive) == 0)
|
||||||
|
isi.extensibility = dds::core::xtypes::ExtensibilityKind::EXTENSIBLE;
|
||||||
#else
|
#else
|
||||||
// RTI not available - skip extensibility parsing
|
// RTI not available - skip extensibility parsing
|
||||||
Q_UNUSED(tmp)
|
Q_UNUSED(tmp)
|
||||||
@@ -502,13 +476,11 @@ void XmlReader::parseTopicTypes(const QDomElement &rootElement)
|
|||||||
domColumn = domColumn.nextSiblingElement(domColumn.tagName());
|
domColumn = domColumn.nextSiblingElement(domColumn.tagName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
m_idlStructsToGenerate.insert(isi.name, isi);
|
m_idlStructsToGenerate.insert(isi.name, isi);
|
||||||
|
|
||||||
domIdlStruct = domIdlStruct.nextSiblingElement(domIdlStruct.tagName());
|
domIdlStruct = domIdlStruct.nextSiblingElement(domIdlStruct.tagName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
INFO_LOG(m_logger) << "Read " << m_idlStructsToGenerate.size() << " idl struct(s)";
|
INFO_LOG(m_logger) << "Read " << m_idlStructsToGenerate.size() << " idl struct(s)";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -517,7 +489,6 @@ void XmlReader::parseFunctionTopics(const QDomElement &rootElement)
|
|||||||
if (rootElement.isNull())
|
if (rootElement.isNull())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
QDomElement domFunctionTopic = rootElement.firstChildElement(QStringLiteral("functionTopic"));
|
QDomElement domFunctionTopic = rootElement.firstChildElement(QStringLiteral("functionTopic"));
|
||||||
while (!domFunctionTopic.isNull())
|
while (!domFunctionTopic.isNull())
|
||||||
{
|
{
|
||||||
@@ -565,8 +536,8 @@ ColumnInformation XmlReader::parseTableColumn(const QDomElement &column, const Q
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ci.columnName.toLower() != ci.columnName)
|
if (ci.columnName.toLower() != ci.columnName)
|
||||||
WARNING_LOG(m_logger) << "Column " << ci.columnName << " in Table "
|
WARNING_LOG(m_logger) << "Column " << ci.columnName << " in Table " << tableName
|
||||||
<< tableName << " has has upper-case chars which is not allowed!";
|
<< " has has upper-case chars which is not allowed!";
|
||||||
|
|
||||||
return ci;
|
return ci;
|
||||||
}
|
}
|
||||||
@@ -673,7 +644,6 @@ CustomServiceFunctionInformation XmlReader::parseCustomFunction(const QDomElemen
|
|||||||
paramName.append(QLatin1String(" = ") + paramDefault);
|
paramName.append(QLatin1String(" = ") + paramDefault);
|
||||||
paramHelper[pos] = qMakePair(paramName, paramType);
|
paramHelper[pos] = qMakePair(paramName, paramType);
|
||||||
domParam = domParam.nextSiblingElement(domParam.tagName());
|
domParam = domParam.nextSiblingElement(domParam.tagName());
|
||||||
|
|
||||||
}
|
}
|
||||||
ret.paramNames.reserve(paramHelper.size());
|
ret.paramNames.reserve(paramHelper.size());
|
||||||
ret.paramTypes.reserve(paramHelper.size());
|
ret.paramTypes.reserve(paramHelper.size());
|
||||||
@@ -699,26 +669,27 @@ DbNotifcationInformation XmlReader::parseDbNotification(const QDomElement &custo
|
|||||||
|
|
||||||
const QString attribute(getAttribute(customFunc, QStringLiteral("notificationTypes")).toLower());
|
const QString attribute(getAttribute(customFunc, QStringLiteral("notificationTypes")).toLower());
|
||||||
const QStringList nfTypes = attribute.split(QLatin1Char(','));
|
const QStringList nfTypes = attribute.split(QLatin1Char(','));
|
||||||
static const QMap<QString, DbNotifcationInformation::NotificationType> s_nfTypeMap =
|
static const QMap<QString, DbNotifcationInformation::NotificationType> s_nfTypeMap = {
|
||||||
{
|
|
||||||
{QLatin1String("beforeinsert"), DbNotifcationInformation::NotificationType::BeforeInsert},
|
{QLatin1String("beforeinsert"), DbNotifcationInformation::NotificationType::BeforeInsert},
|
||||||
{QLatin1String("afterinsert"), DbNotifcationInformation::NotificationType::AfterInsert},
|
{QLatin1String("afterinsert"), DbNotifcationInformation::NotificationType::AfterInsert},
|
||||||
{QLatin1String("beforeupdate"), DbNotifcationInformation::NotificationType::BeforeUpdate},
|
{QLatin1String("beforeupdate"), DbNotifcationInformation::NotificationType::BeforeUpdate},
|
||||||
{QLatin1String("afterupdate"), DbNotifcationInformation::NotificationType::AfterUpdate},
|
{QLatin1String("afterupdate"), DbNotifcationInformation::NotificationType::AfterUpdate},
|
||||||
{QLatin1String("beforedelete"), DbNotifcationInformation::NotificationType::BeforeDelete},
|
{QLatin1String("beforedelete"), DbNotifcationInformation::NotificationType::BeforeDelete},
|
||||||
{ QLatin1String("afterdelete"), DbNotifcationInformation::NotificationType::AfterDelete }
|
{QLatin1String("afterdelete"), DbNotifcationInformation::NotificationType::AfterDelete}};
|
||||||
};
|
|
||||||
for (const QString& nfType : nfTypes)
|
for (const QString& nfType : nfTypes)
|
||||||
{
|
{
|
||||||
const auto it = s_nfTypeMap.find(nfType);
|
const auto it = s_nfTypeMap.find(nfType);
|
||||||
if (it == s_nfTypeMap.end())
|
if (it == s_nfTypeMap.end())
|
||||||
throw XmlReaderException(QStringLiteral("Can not find notification type %2 in type map for function %1").arg(ret.methodName, nfType));
|
throw XmlReaderException(QStringLiteral("Can not find notification type %2 in type map for function %1")
|
||||||
|
.arg(ret.methodName, nfType));
|
||||||
ret.notificationType += it.value();
|
ret.notificationType += it.value();
|
||||||
}
|
}
|
||||||
if (ret.notificationType.isEmpty())
|
if (ret.notificationType.isEmpty())
|
||||||
throw XmlReaderException(QStringLiteral("Notification function '%1' without a valid notification type").arg(ret.methodName));
|
throw XmlReaderException(
|
||||||
|
QStringLiteral("Notification function '%1' without a valid notification type").arg(ret.methodName));
|
||||||
if (ret.paramTypes.size() != 1)
|
if (ret.paramTypes.size() != 1)
|
||||||
throw XmlReaderException(QStringLiteral("Notification function '%1' must have exactly one parameter").arg(ret.methodName));
|
throw XmlReaderException(
|
||||||
|
QStringLiteral("Notification function '%1' must have exactly one parameter").arg(ret.methodName));
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -729,8 +700,8 @@ TopicTypeInformation XmlReader::loadExternalTopicType(const QString &externalSer
|
|||||||
|
|
||||||
if (!loadExternalService(externalServiceName))
|
if (!loadExternalService(externalServiceName))
|
||||||
{
|
{
|
||||||
WARNING_LOG(m_logger) << "Could not find service " << externalServiceName
|
WARNING_LOG(m_logger) << "Could not find service " << externalServiceName << " referenced by external topic "
|
||||||
<< " referenced by external topic " << topicTypeName;
|
<< topicTypeName;
|
||||||
return TopicTypeInformation();
|
return TopicTypeInformation();
|
||||||
}
|
}
|
||||||
auto extXmlReader = m_externalXmlInformations.value(externalServiceName);
|
auto extXmlReader = m_externalXmlInformations.value(externalServiceName);
|
||||||
@@ -748,13 +719,13 @@ TopicTypeInformation XmlReader::loadExternalTopicType(const QString &externalSer
|
|||||||
m_usedServices[externalServiceName] = true;
|
m_usedServices[externalServiceName] = true;
|
||||||
return tti;
|
return tti;
|
||||||
}
|
}
|
||||||
WARNING_LOG(m_logger) << "Could not find topic " << topicTypeName
|
WARNING_LOG(m_logger) << "Could not find topic " << topicTypeName << " in external service definition for service "
|
||||||
<< " in external service definition for service "
|
|
||||||
<< externalServiceName;
|
<< externalServiceName;
|
||||||
return TopicTypeInformation();
|
return TopicTypeInformation();
|
||||||
}
|
}
|
||||||
|
|
||||||
EnumInformation XmlReader::getExternalEnumeration(const QString &externalServiceName, const QString &enumName, bool verbose)
|
EnumInformation XmlReader::getExternalEnumeration(const QString& externalServiceName, const QString& enumName,
|
||||||
|
bool verbose)
|
||||||
{
|
{
|
||||||
DEBUG_LOG(m_logger) << "externalServiceName: " << externalServiceName << ", topicTypeName: " << enumName;
|
DEBUG_LOG(m_logger) << "externalServiceName: " << externalServiceName << ", topicTypeName: " << enumName;
|
||||||
|
|
||||||
@@ -782,14 +753,12 @@ EnumInformation XmlReader::getExternalEnumeration(const QString &externalService
|
|||||||
}
|
}
|
||||||
if (verbose)
|
if (verbose)
|
||||||
{
|
{
|
||||||
WARNING_LOG(m_logger) << "Could not find enumeration " << enumName
|
WARNING_LOG(m_logger) << "Could not find enumeration " << enumName << " in external service definition for '"
|
||||||
<< " in external service definition for '"
|
|
||||||
<< externalServiceName << "'";
|
<< externalServiceName << "'";
|
||||||
}
|
}
|
||||||
return EnumInformation();
|
return EnumInformation();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool XmlReader::loadExternalService(const QString& serviceName)
|
bool XmlReader::loadExternalService(const QString& serviceName)
|
||||||
{
|
{
|
||||||
if (serviceName == getServiceNamespace())
|
if (serviceName == getServiceNamespace())
|
||||||
@@ -824,8 +793,7 @@ bool XmlReader::loadExternalService(const QString &serviceName)
|
|||||||
auto extXmlReader = QSharedPointer<XmlReader>(new XmlReader);
|
auto extXmlReader = QSharedPointer<XmlReader>(new XmlReader);
|
||||||
if (!extXmlReader->readServiceFile(fileName, QString(), this))
|
if (!extXmlReader->readServiceFile(fileName, QString(), this))
|
||||||
{
|
{
|
||||||
WARNING_LOG(m_logger) << "Error reading service file " << fileName
|
WARNING_LOG(m_logger) << "Error reading service file " << fileName << " for service " << serviceName;
|
||||||
<< " for service " << serviceName;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
m_externalXmlInformations[serviceName] = extXmlReader;
|
m_externalXmlInformations[serviceName] = extXmlReader;
|
||||||
@@ -871,14 +839,12 @@ void XmlReader::loadIdlInfofile(const QString &idlServiceInfoFile)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString XmlReader::getIdlFileForService(const QMap<QString, QString> &data,
|
QString XmlReader::getIdlFileForService(const QMap<QString, QString>& data, const QString& serviceName) const
|
||||||
const QString &serviceName) const
|
|
||||||
{
|
{
|
||||||
const QString serviceAbbr = serviceNameAbbreviation(serviceName);
|
const QString serviceAbbr = serviceNameAbbreviation(serviceName);
|
||||||
return data.value(serviceAbbr);
|
return data.value(serviceAbbr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString XmlReader::serviceNameAbbreviation(const QString& serviceName) const
|
QString XmlReader::serviceNameAbbreviation(const QString& serviceName) const
|
||||||
{
|
{
|
||||||
return m_fullServiceName2Abbreviation.value(serviceName);
|
return m_fullServiceName2Abbreviation.value(serviceName);
|
||||||
@@ -889,7 +855,6 @@ void XmlReader::getServiceNameInfoFromFilePath(const QStringList &parts)
|
|||||||
if (parts.size() < 2)
|
if (parts.size() < 2)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
const QString abbreviation = parts.last().split(QLatin1Char('.')).first().split(QLatin1Char('_')).first();
|
const QString abbreviation = parts.last().split(QLatin1Char('.')).first().split(QLatin1Char('_')).first();
|
||||||
const QString serviceName = parts.at(parts.size() - 2);
|
const QString serviceName = parts.at(parts.size() - 2);
|
||||||
DEBUG_LOG(m_logger) << "serviceName: " << serviceName << " = " << abbreviation;
|
DEBUG_LOG(m_logger) << "serviceName: " << serviceName << " = " << abbreviation;
|
||||||
@@ -928,4 +893,3 @@ QString XmlReader::serviceNamespaceFromFile(const QString &fn)
|
|||||||
}
|
}
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
Executable → Regular
+92
-72
@@ -31,13 +31,7 @@ class QDomElement;
|
|||||||
namespace CodeGen
|
namespace CodeGen
|
||||||
{
|
{
|
||||||
|
|
||||||
enum ExerciseDependency
|
enum ExerciseDependency { Undefined = 0, Global = 0x1, Exercise = 0x2, GlobalAndExercise = 0x3 };
|
||||||
{
|
|
||||||
Undefined = 0,
|
|
||||||
Global = 0x1,
|
|
||||||
Exercise = 0x2,
|
|
||||||
GlobalAndExercise = 0x3
|
|
||||||
};
|
|
||||||
|
|
||||||
struct EnumKeyValuePair
|
struct EnumKeyValuePair
|
||||||
{
|
{
|
||||||
@@ -52,7 +46,10 @@ struct EnumInformation
|
|||||||
QString serviceName;
|
QString serviceName;
|
||||||
QVector<EnumKeyValuePair> values;
|
QVector<EnumKeyValuePair> values;
|
||||||
|
|
||||||
bool isValid() const { return !enumName.isEmpty(); }
|
bool isValid() const
|
||||||
|
{
|
||||||
|
return !enumName.isEmpty();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ColumnInformation
|
struct ColumnInformation
|
||||||
@@ -82,7 +79,6 @@ struct IdlColumnInformation
|
|||||||
bool isTranslatable = false;
|
bool isTranslatable = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct ForeignKeyInformation
|
struct ForeignKeyInformation
|
||||||
{
|
{
|
||||||
struct Endpoint
|
struct Endpoint
|
||||||
@@ -97,8 +93,7 @@ struct ForeignKeyInformation
|
|||||||
QString name;
|
QString name;
|
||||||
Endpoint source;
|
Endpoint source;
|
||||||
Endpoint destination;
|
Endpoint destination;
|
||||||
enum class OnDeleteAction
|
enum class OnDeleteAction {
|
||||||
{
|
|
||||||
NoAction,
|
NoAction,
|
||||||
Cascade,
|
Cascade,
|
||||||
Restrict,
|
Restrict,
|
||||||
@@ -115,40 +110,23 @@ struct CustomServiceFunctionInformation
|
|||||||
bool isConst = false;
|
bool isConst = false;
|
||||||
QVector<QString> paramTypes;
|
QVector<QString> paramTypes;
|
||||||
QVector<QString> paramNames;
|
QVector<QString> paramNames;
|
||||||
enum class Type
|
enum class Type { Db, DbNotify, Dtc } type = Type::Db;
|
||||||
{
|
|
||||||
Db,
|
|
||||||
DbNotify,
|
|
||||||
Dtc
|
|
||||||
} type = Type::Db;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DbNotifcationInformation : public CustomServiceFunctionInformation
|
struct DbNotifcationInformation : public CustomServiceFunctionInformation
|
||||||
{
|
{
|
||||||
DbNotifcationInformation() = default;
|
DbNotifcationInformation() = default;
|
||||||
explicit DbNotifcationInformation(const CustomServiceFunctionInformation &d)
|
|
||||||
: CustomServiceFunctionInformation(d)
|
explicit DbNotifcationInformation(const CustomServiceFunctionInformation& d) : CustomServiceFunctionInformation(d)
|
||||||
{}
|
|
||||||
enum class NotificationType
|
|
||||||
{
|
{
|
||||||
BeforeInsert,
|
}
|
||||||
AfterInsert,
|
enum class NotificationType { BeforeInsert, AfterInsert, BeforeUpdate, AfterUpdate, BeforeDelete, AfterDelete };
|
||||||
BeforeUpdate,
|
|
||||||
AfterUpdate,
|
|
||||||
BeforeDelete,
|
|
||||||
AfterDelete
|
|
||||||
};
|
|
||||||
QVector<NotificationType> notificationType;
|
QVector<NotificationType> notificationType;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ConstraintInformation
|
struct ConstraintInformation
|
||||||
{
|
{
|
||||||
enum struct Type
|
enum struct Type { unknown = 0x00, unique = 0x01, index = 0x02 } type = Type::unknown;
|
||||||
{
|
|
||||||
unknown = 0x00,
|
|
||||||
unique = 0x01,
|
|
||||||
index = 0x02
|
|
||||||
} type = Type::unknown;
|
|
||||||
QString name;
|
QString name;
|
||||||
QStringList affectedColumns;
|
QStringList affectedColumns;
|
||||||
};
|
};
|
||||||
@@ -168,8 +146,7 @@ struct TableInformation
|
|||||||
{
|
{
|
||||||
for (const QSharedPointer<ForeignKeyInformation>& fki : foreignKeys)
|
for (const QSharedPointer<ForeignKeyInformation>& fki : foreignKeys)
|
||||||
{
|
{
|
||||||
if (fki->source.columnName == columnName &&
|
if (fki->source.columnName == columnName && fki->source.tableName == tableName)
|
||||||
fki->source.tableName == tableName)
|
|
||||||
return fki;
|
return fki;
|
||||||
}
|
}
|
||||||
return QSharedPointer<ForeignKeyInformation>();
|
return QSharedPointer<ForeignKeyInformation>();
|
||||||
@@ -201,6 +178,7 @@ struct ServiceStructInformation
|
|||||||
return name < o.name;
|
return name < o.name;
|
||||||
return primaryTable < o.primaryTable;
|
return primaryTable < o.primaryTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<DbNotifcationInformation> dbNotifications;
|
QVector<DbNotifcationInformation> dbNotifications;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -227,7 +205,10 @@ struct TopicTypeInformationBase
|
|||||||
int extensibility = 0; // Placeholder when RTI DDS is not available
|
int extensibility = 0; // Placeholder when RTI DDS is not available
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
virtual bool isValid() const { return !name.isEmpty(); }
|
virtual bool isValid() const
|
||||||
|
{
|
||||||
|
return !name.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
bool operator<(const TopicTypeInformationBase& o) const
|
bool operator<(const TopicTypeInformationBase& o) const
|
||||||
{
|
{
|
||||||
@@ -252,39 +233,84 @@ struct FunctionTopic
|
|||||||
bool routeInReplay = false;
|
bool routeInReplay = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class CODEGEN_BASE_EXPORT XmlReader final
|
class CODEGEN_BASE_EXPORT XmlReader final
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
XmlReader();
|
XmlReader();
|
||||||
|
|
||||||
bool readServiceFile(const QString &svcFile,
|
bool readServiceFile(const QString& svcFile, const QString& idlServiceInfoFile = QString(),
|
||||||
const QString &idlServiceInfoFile = QString(),
|
|
||||||
const XmlReader* parent = nullptr);
|
const XmlReader* parent = nullptr);
|
||||||
|
|
||||||
QString errorString() const
|
QString errorString() const
|
||||||
{
|
{
|
||||||
return m_errorString;
|
return m_errorString;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString getServiceNamespace() const { return m_svcNamespace; }
|
QString getServiceNamespace() const
|
||||||
QString getServiceAbbr() const { return m_svcAbbr; }
|
{
|
||||||
QStringList getGroupNames() const { return m_groupNames; }
|
return m_svcNamespace;
|
||||||
int getPrio() const { return m_prio;}
|
}
|
||||||
QStringList getProcNames() const { return m_svcProcNames; }
|
|
||||||
bool hasCustomRecordReplayPlugin() const { return m_customRecordReplay; }
|
|
||||||
bool getDevMode() const { return m_svcDevMode; }
|
|
||||||
|
|
||||||
bool isServiceExerciseIndependent() const { return m_exerciseDependency == ExerciseDependency::Global; }
|
QString getServiceAbbr() const
|
||||||
ExerciseDependency defaultExerciseDependency() const { return m_exerciseDependency; }
|
{
|
||||||
|
return m_svcAbbr;
|
||||||
|
}
|
||||||
|
|
||||||
QMap<QString, QVector<QString> > getDbClass2TableMapping() const { return m_dbClassTables; }
|
QStringList getGroupNames() const
|
||||||
|
{
|
||||||
|
return m_groupNames;
|
||||||
|
}
|
||||||
|
|
||||||
|
int getPrio() const
|
||||||
|
{
|
||||||
|
return m_prio;
|
||||||
|
}
|
||||||
|
|
||||||
QMap<QString, QString> getStruct2BaseClassRelations() const { return m_struct2BaseClass; }
|
QStringList getProcNames() const
|
||||||
QVector<ServiceStructInformation> getStructToGenerate() const { return m_structsToGenerate; }
|
{
|
||||||
|
return m_svcProcNames;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool hasCustomRecordReplayPlugin() const
|
||||||
|
{
|
||||||
|
return m_customRecordReplay;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool getDevMode() const
|
||||||
|
{
|
||||||
|
return m_svcDevMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isServiceExerciseIndependent() const
|
||||||
|
{
|
||||||
|
return m_exerciseDependency == ExerciseDependency::Global;
|
||||||
|
}
|
||||||
|
|
||||||
|
ExerciseDependency defaultExerciseDependency() const
|
||||||
|
{
|
||||||
|
return m_exerciseDependency;
|
||||||
|
}
|
||||||
|
|
||||||
|
QMap<QString, QVector<QString>> getDbClass2TableMapping() const
|
||||||
|
{
|
||||||
|
return m_dbClassTables;
|
||||||
|
}
|
||||||
|
|
||||||
|
QMap<QString, QString> getStruct2BaseClassRelations() const
|
||||||
|
{
|
||||||
|
return m_struct2BaseClass;
|
||||||
|
}
|
||||||
|
|
||||||
|
QVector<ServiceStructInformation> getStructToGenerate() const
|
||||||
|
{
|
||||||
|
return m_structsToGenerate;
|
||||||
|
}
|
||||||
|
|
||||||
|
QMap<QString, TopicTypeInformation> getIdlStructInformation() const
|
||||||
|
{
|
||||||
|
return m_idlStructsToGenerate;
|
||||||
|
}
|
||||||
|
|
||||||
QMap<QString, TopicTypeInformation > getIdlStructInformation() const { return m_idlStructsToGenerate; }
|
|
||||||
QVector<TopicTypeInformation> getIdlStructToGenerate() const
|
QVector<TopicTypeInformation> getIdlStructToGenerate() const
|
||||||
{
|
{
|
||||||
QVector<TopicTypeInformation> res;
|
QVector<TopicTypeInformation> res;
|
||||||
@@ -298,23 +324,26 @@ public:
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QMap<QString, QSharedPointer<TableInformation>> getTables() const
|
QMap<QString, QSharedPointer<TableInformation>> getTables() const
|
||||||
{
|
{
|
||||||
return m_tables;
|
return m_tables;
|
||||||
}
|
}
|
||||||
|
|
||||||
QMap<QString, QSharedPointer<ViewInformation>> getViews() const
|
QMap<QString, QSharedPointer<ViewInformation>> getViews() const
|
||||||
{
|
{
|
||||||
return m_views;
|
return m_views;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSharedPointer<TableInformation> getTable(const QString& table) const
|
QSharedPointer<TableInformation> getTable(const QString& table) const
|
||||||
{
|
{
|
||||||
return m_tables.value(table);
|
return m_tables.value(table);
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<EnumInformation> getEnumerations() const
|
QVector<EnumInformation> getEnumerations() const
|
||||||
{
|
{
|
||||||
return m_enumerations;
|
return m_enumerations;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<IdlColumnInformation> getIdlColumns(const QString& structName) const
|
QVector<IdlColumnInformation> getIdlColumns(const QString& structName) const
|
||||||
{
|
{
|
||||||
return m_idlStructsToGenerate.value(structName).columns;
|
return m_idlStructsToGenerate.value(structName).columns;
|
||||||
@@ -324,6 +353,7 @@ public:
|
|||||||
{
|
{
|
||||||
return m_functionTopics;
|
return m_functionTopics;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<TopicTypeInformation> getExternalTopicTypes() const
|
QVector<TopicTypeInformation> getExternalTopicTypes() const
|
||||||
{
|
{
|
||||||
return m_externalTopicTypes;
|
return m_externalTopicTypes;
|
||||||
@@ -349,7 +379,6 @@ public:
|
|||||||
return m_customFunctions;
|
return m_customFunctions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TopicTypeInformation loadExternalTopicType(const QString& externalServiceName, const QString& topicTypeName);
|
TopicTypeInformation loadExternalTopicType(const QString& externalServiceName, const QString& topicTypeName);
|
||||||
EnumInformation getExternalEnumeration(const QString& externalServiceName, const QString& enumName, bool verbose);
|
EnumInformation getExternalEnumeration(const QString& externalServiceName, const QString& enumName, bool verbose);
|
||||||
|
|
||||||
@@ -368,15 +397,11 @@ private:
|
|||||||
void parseFunctionTopics(const QDomElement& rootElement);
|
void parseFunctionTopics(const QDomElement& rootElement);
|
||||||
void parseCustomDtcFunctions(const QDomElement& rootElement);
|
void parseCustomDtcFunctions(const QDomElement& rootElement);
|
||||||
|
|
||||||
static QString getAttribute(const QDomElement &element,
|
static QString getAttribute(const QDomElement& element, const QString& attributeName, bool bOptional = false);
|
||||||
const QString &attributeName,
|
static bool getAttributeBool(const QDomElement& element, const QString& attributeName, bool bOptional,
|
||||||
bool bOptional = false);
|
bool defaultValue);
|
||||||
static bool getAttributeBool(const QDomElement &element,
|
static int getAttributeInt(const QDomElement& element, const QString& attributeName, bool bOptional = false,
|
||||||
const QString &attributeName,
|
int defaultValue = 0);
|
||||||
bool bOptional, bool defaultValue);
|
|
||||||
static int getAttributeInt(const QDomElement &element,
|
|
||||||
const QString &attributeName,
|
|
||||||
bool bOptional = false, int defaultValue = 0);
|
|
||||||
|
|
||||||
ColumnInformation parseTableColumn(const QDomElement& column, const QString& tableName) const;
|
ColumnInformation parseTableColumn(const QDomElement& column, const QString& tableName) const;
|
||||||
IdlColumnInformation parseIdlStructColumn(const QDomElement& column) const;
|
IdlColumnInformation parseIdlStructColumn(const QDomElement& column) const;
|
||||||
@@ -385,7 +410,8 @@ private:
|
|||||||
ForeignKeyInformation::Endpoint parseForeignKeyEndpoint(const QString& foreignKeyName,
|
ForeignKeyInformation::Endpoint parseForeignKeyEndpoint(const QString& foreignKeyName,
|
||||||
const QDomElement& endpoint) const;
|
const QDomElement& endpoint) const;
|
||||||
ConstraintInformation parseConstraint(const QDomElement& constraint) const;
|
ConstraintInformation parseConstraint(const QDomElement& constraint) const;
|
||||||
CustomServiceFunctionInformation parseCustomFunction(const QDomElement &customFunc, CustomServiceFunctionInformation::Type funcType) const;
|
CustomServiceFunctionInformation parseCustomFunction(const QDomElement& customFunc,
|
||||||
|
CustomServiceFunctionInformation::Type funcType) const;
|
||||||
DbNotifcationInformation parseDbNotification(const QDomElement& customFunc) const;
|
DbNotifcationInformation parseDbNotification(const QDomElement& customFunc) const;
|
||||||
bool loadExternalService(const QString& serviceName);
|
bool loadExternalService(const QString& serviceName);
|
||||||
void loadIdlInfofile(const QString& idlServiceInfoFile);
|
void loadIdlInfofile(const QString& idlServiceInfoFile);
|
||||||
@@ -394,7 +420,6 @@ private:
|
|||||||
void getServiceNameInfoFromFilePath(const QStringList& parts);
|
void getServiceNameInfoFromFilePath(const QStringList& parts);
|
||||||
static QString serviceNamespaceFromFile(const QString& fn);
|
static QString serviceNamespaceFromFile(const QString& fn);
|
||||||
|
|
||||||
|
|
||||||
QString m_svcNamespace;
|
QString m_svcNamespace;
|
||||||
|
|
||||||
QString m_svcAbbr;
|
QString m_svcAbbr;
|
||||||
@@ -403,13 +428,10 @@ private:
|
|||||||
|
|
||||||
bool m_customRecordReplay;
|
bool m_customRecordReplay;
|
||||||
|
|
||||||
|
|
||||||
ExerciseDependency m_exerciseDependency{ExerciseDependency::Exercise};
|
ExerciseDependency m_exerciseDependency{ExerciseDependency::Exercise};
|
||||||
|
|
||||||
|
|
||||||
QMap<QString, QVector<QString>> m_dbClassTables;
|
QMap<QString, QVector<QString>> m_dbClassTables;
|
||||||
|
|
||||||
|
|
||||||
QMap<QString, QString> m_struct2BaseClass;
|
QMap<QString, QString> m_struct2BaseClass;
|
||||||
QVector<ServiceStructInformation> m_structsToGenerate;
|
QVector<ServiceStructInformation> m_structsToGenerate;
|
||||||
|
|
||||||
@@ -419,13 +441,11 @@ private:
|
|||||||
QVector<TopicTypeInformation> m_externalTopicTypes;
|
QVector<TopicTypeInformation> m_externalTopicTypes;
|
||||||
QVector<CustomServiceFunctionInformation> m_customFunctions;
|
QVector<CustomServiceFunctionInformation> m_customFunctions;
|
||||||
|
|
||||||
|
|
||||||
QMap<QString, QSharedPointer<TableInformation>> m_tables;
|
QMap<QString, QSharedPointer<TableInformation>> m_tables;
|
||||||
QMap<QString, QSharedPointer<ViewInformation>> m_views;
|
QMap<QString, QSharedPointer<ViewInformation>> m_views;
|
||||||
QVector<EnumInformation> m_enumerations;
|
QVector<EnumInformation> m_enumerations;
|
||||||
QString m_errorString;
|
QString m_errorString;
|
||||||
|
|
||||||
|
|
||||||
QMap<QString, QSharedPointer<XmlReader>> m_externalXmlInformations;
|
QMap<QString, QSharedPointer<XmlReader>> m_externalXmlInformations;
|
||||||
QMap<QString, QString> m_idlFiles;
|
QMap<QString, QString> m_idlFiles;
|
||||||
QMap<QString, QString> m_xmlFiles;
|
QMap<QString, QString> m_xmlFiles;
|
||||||
@@ -436,4 +456,4 @@ private:
|
|||||||
int m_prio;
|
int m_prio;
|
||||||
bool m_svcDevMode{false};
|
bool m_svcDevMode{false};
|
||||||
};
|
};
|
||||||
}
|
} // namespace CodeGen
|
||||||
Executable → Regular
File mode changed.
Executable → Regular
+34
-39
@@ -1,48 +1,37 @@
|
|||||||
|
|
||||||
|
|
||||||
|
#include "CppTopicGeneratorGrantlee.h"
|
||||||
#include "StructBuilder.h"
|
|
||||||
#include "XmlReader.h"
|
|
||||||
#include "DaoGeneratorGrantlee.h"
|
#include "DaoGeneratorGrantlee.h"
|
||||||
#include "DatabaseGeneratorGrantlee.h"
|
#include "DatabaseGeneratorGrantlee.h"
|
||||||
#include "CppTopicGeneratorGrantlee.h"
|
|
||||||
#include "SqlGenerator.h"
|
#include "SqlGenerator.h"
|
||||||
|
#include "StructBuilder.h"
|
||||||
|
#include "XmlReader.h"
|
||||||
|
|
||||||
#include <nglapplication/nglcoreapplication.h>
|
|
||||||
#include <QDir>
|
|
||||||
#include <NGLLogger/INGLLogger.h>
|
|
||||||
#include <LtsCommandLineParser/LtsCommandLineParser.h>
|
#include <LtsCommandLineParser/LtsCommandLineParser.h>
|
||||||
|
#include <NGLLogger/INGLLogger.h>
|
||||||
|
#include <QDir>
|
||||||
|
#include <nglapplication/nglcoreapplication.h>
|
||||||
|
|
||||||
class CmdLineParser : public LtsCommandLineParser::LtsCommandLineParser
|
class CmdLineParser : public LtsCommandLineParser::LtsCommandLineParser
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CmdLineParser()
|
CmdLineParser() : LtsCommandLineParser(LtsCommandLineParser::LtsCommandLineParser::None)
|
||||||
: LtsCommandLineParser(LtsCommandLineParser::LtsCommandLineParser::None)
|
|
||||||
{
|
{
|
||||||
addOption({QStringList() << QStringLiteral("s") << QStringLiteral("servicefile"),
|
addOption({QStringList() << QStringLiteral("s") << QStringLiteral("servicefile"),
|
||||||
QStringLiteral("full path to the service xml-file"),
|
QStringLiteral("full path to the service xml-file"), QStringLiteral("service xml-file"),
|
||||||
QStringLiteral("service xml-file"),
|
QStringLiteral("/home")});
|
||||||
QStringLiteral("/home")
|
|
||||||
});
|
|
||||||
|
|
||||||
addOption({QStringList() << QStringLiteral("a") << QStringLiteral("action"),
|
addOption({QStringList() << QStringLiteral("a") << QStringLiteral("action"),
|
||||||
QStringLiteral("the action to execute"),
|
QStringLiteral("the action to execute"), QStringLiteral("DATABASE|DATABASE_SERVER|IDL|DDS_TOPICS"),
|
||||||
QStringLiteral("DATABASE|DATABASE_SERVER|IDL|DDS_TOPICS"),
|
QStringLiteral("/0")});
|
||||||
QStringLiteral("/0")
|
|
||||||
});
|
|
||||||
|
|
||||||
addOption({QStringList() << QStringLiteral("o") << QStringLiteral("outdir"),
|
addOption({QStringList() << QStringLiteral("o") << QStringLiteral("outdir"),
|
||||||
QStringLiteral("the output directory where to put the generated files"),
|
QStringLiteral("the output directory where to put the generated files"),
|
||||||
QStringLiteral("output directory"),
|
QStringLiteral("output directory"), QStringLiteral("/home")});
|
||||||
QStringLiteral("/home")
|
|
||||||
});
|
|
||||||
|
|
||||||
addOption({QStringList() << QStringLiteral("i") << QStringLiteral("idlinfo"),
|
addOption({QStringList() << QStringLiteral("i") << QStringLiteral("idlinfo"),
|
||||||
QStringLiteral("the info file with all available idl service files"),
|
QStringLiteral("the info file with all available idl service files"),
|
||||||
QStringLiteral("info file for idl"),
|
QStringLiteral("info file for idl"), QStringLiteral("/0")});
|
||||||
QStringLiteral("/0")
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool init()
|
bool init()
|
||||||
@@ -58,10 +47,25 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString serviceFile() const { return value(QStringLiteral("s")); }
|
QString serviceFile() const
|
||||||
QString action() const { return value(QStringLiteral("a")); }
|
{
|
||||||
QString outDir() const { return value(QStringLiteral("o")); }
|
return value(QStringLiteral("s"));
|
||||||
QString idlInfoFile() const { return value(QStringLiteral("i")); }
|
}
|
||||||
|
|
||||||
|
QString action() const
|
||||||
|
{
|
||||||
|
return value(QStringLiteral("a"));
|
||||||
|
}
|
||||||
|
|
||||||
|
QString outDir() const
|
||||||
|
{
|
||||||
|
return value(QStringLiteral("o"));
|
||||||
|
}
|
||||||
|
|
||||||
|
QString idlInfoFile() const
|
||||||
|
{
|
||||||
|
return value(QStringLiteral("i"));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
@@ -81,8 +85,7 @@ int main(int argc, char **argv)
|
|||||||
DEBUG_LOG(m_logger) << "IdlInfoFile: " << options.idlInfoFile();
|
DEBUG_LOG(m_logger) << "IdlInfoFile: " << options.idlInfoFile();
|
||||||
if (!reader->readServiceFile(options.serviceFile(), options.idlInfoFile()))
|
if (!reader->readServiceFile(options.serviceFile(), options.idlInfoFile()))
|
||||||
{
|
{
|
||||||
ERROR_LOG(m_logger) << "Error parsing service file '" << options.serviceFile()
|
ERROR_LOG(m_logger) << "Error parsing service file '" << options.serviceFile() << ": " << reader->errorString();
|
||||||
<< ": " << reader->errorString();
|
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,8 +93,7 @@ int main(int argc, char **argv)
|
|||||||
DEBUG_LOG(m_logger) << "Directory: " << options.outDir();
|
DEBUG_LOG(m_logger) << "Directory: " << options.outDir();
|
||||||
if (!dir.exists() && !dir.mkpath(options.outDir()))
|
if (!dir.exists() && !dir.mkpath(options.outDir()))
|
||||||
{
|
{
|
||||||
ERROR_LOG(m_logger) << "Directory '" << options.outDir()
|
ERROR_LOG(m_logger) << "Directory '" << options.outDir() << "' does not exist and can not be created!";
|
||||||
<< "' does not exist and can not be created!";
|
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,7 +106,6 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
const QString action = options.action().toLower();
|
const QString action = options.action().toLower();
|
||||||
|
|
||||||
|
|
||||||
QScopedPointer<CodeGen::GeneratorGrantleeBase> generator;
|
QScopedPointer<CodeGen::GeneratorGrantleeBase> generator;
|
||||||
if (action == QStringLiteral("dao"))
|
if (action == QStringLiteral("dao"))
|
||||||
generator.reset(new CodeGen::DaoGeneratorGrantlee);
|
generator.reset(new CodeGen::DaoGeneratorGrantlee);
|
||||||
@@ -120,7 +121,6 @@ int main(int argc, char **argv)
|
|||||||
if (!sql.generateData(35))
|
if (!sql.generateData(35))
|
||||||
return 8;
|
return 8;
|
||||||
|
|
||||||
|
|
||||||
if (!sql.writeSql(dir.absolutePath() + QLatin1Char('/'), CodeGen::ExerciseDependency::Exercise))
|
if (!sql.writeSql(dir.absolutePath() + QLatin1Char('/'), CodeGen::ExerciseDependency::Exercise))
|
||||||
{
|
{
|
||||||
ERROR_LOG(m_logger) << "Error while writing sql information for service " << sql.getServiceAbbr();
|
ERROR_LOG(m_logger) << "Error while writing sql information for service " << sql.getServiceAbbr();
|
||||||
@@ -130,14 +130,12 @@ int main(int argc, char **argv)
|
|||||||
if (!sql.generateData(42))
|
if (!sql.generateData(42))
|
||||||
return 8;
|
return 8;
|
||||||
|
|
||||||
|
|
||||||
if (!sql.writeSql(dir.absolutePath() + QLatin1Char('/'), CodeGen::ExerciseDependency::Exercise))
|
if (!sql.writeSql(dir.absolutePath() + QLatin1Char('/'), CodeGen::ExerciseDependency::Exercise))
|
||||||
{
|
{
|
||||||
ERROR_LOG(m_logger) << "Error while writing sql information for service " << sql.getServiceAbbr();
|
ERROR_LOG(m_logger) << "Error while writing sql information for service " << sql.getServiceAbbr();
|
||||||
return 10;
|
return 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sql.generateData(0);
|
sql.generateData(0);
|
||||||
if (!sql.writeSql(dir.absolutePath() + QLatin1Char('/'), CodeGen::ExerciseDependency::Global))
|
if (!sql.writeSql(dir.absolutePath() + QLatin1Char('/'), CodeGen::ExerciseDependency::Global))
|
||||||
{
|
{
|
||||||
@@ -158,9 +156,6 @@ int main(int argc, char **argv)
|
|||||||
return 6;
|
return 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const auto posArgs = options.positionalArguments();
|
const auto posArgs = options.positionalArguments();
|
||||||
for (const QString& file : posArgs)
|
for (const QString& file : posArgs)
|
||||||
{
|
{
|
||||||
|
|||||||
Executable → Regular
+22
-32
@@ -1,44 +1,32 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "main_grantlee_gui.h"
|
#include "main_grantlee_gui.h"
|
||||||
#include "ui_main_grantlee_gui.h"
|
|
||||||
#include "StructBuilder.h"
|
|
||||||
#include "XmlReader.h"
|
|
||||||
#include "CppTopicGeneratorGrantlee.h"
|
#include "CppTopicGeneratorGrantlee.h"
|
||||||
#include "DatabaseGeneratorGrantlee.h"
|
#include "DatabaseGeneratorGrantlee.h"
|
||||||
|
#include "StructBuilder.h"
|
||||||
|
#include "XmlReader.h"
|
||||||
|
#include "ui_main_grantlee_gui.h"
|
||||||
|
|
||||||
#include <nglapplication/nglapplication.h>
|
|
||||||
#include <NGLLogger/INGLLogger.h>
|
#include <NGLLogger/INGLLogger.h>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <grantlee/engine.h>
|
#include <grantlee/engine.h>
|
||||||
|
#include <nglapplication/nglapplication.h>
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget* parent)
|
MainWindow::MainWindow(QWidget* parent)
|
||||||
: QMainWindow(parent)
|
: QMainWindow(parent), m_xmlReader(nullptr), m_structBuilder(nullptr),
|
||||||
, m_xmlReader(nullptr)
|
m_generator(new CodeGen::CppTopicGeneratorGrantlee), m_engine(new Grantlee::Engine), m_ui(new Ui_MainGrantleeGui)
|
||||||
, m_structBuilder(nullptr)
|
|
||||||
, m_generator(new CodeGen::CppTopicGeneratorGrantlee)
|
|
||||||
, m_engine(new Grantlee::Engine)
|
|
||||||
, m_ui(new Ui_MainGrantleeGui)
|
|
||||||
{
|
{
|
||||||
m_idlServiceInfoFile = QStringLiteral("/home/chehrlic/TDS/TDS-build-product-clang/service_idl_files.txt");
|
m_idlServiceInfoFile = QStringLiteral("/home/chehrlic/TDS/TDS-build-product-clang/service_idl_files.txt");
|
||||||
m_ui->setupUi(this);
|
m_ui->setupUi(this);
|
||||||
connect(m_ui->actionExit, &QAction::triggered,
|
connect(m_ui->actionExit, &QAction::triggered, this, &MainWindow::close);
|
||||||
this, &MainWindow::close);
|
connect(m_ui->actionSelect_Data_Source, &QAction::triggered, this, &MainWindow::onSelectDataSource);
|
||||||
connect(m_ui->actionSelect_Data_Source, &QAction::triggered,
|
connect(m_ui->actionOpen_Template, &QAction::triggered, this, &MainWindow::onOpenTemplate);
|
||||||
this, &MainWindow::onSelectDataSource);
|
connect(m_ui->actionSave_Template, &QAction::triggered, this, &MainWindow::onSaveTemplate);
|
||||||
connect(m_ui->actionOpen_Template, &QAction::triggered,
|
connect(m_ui->pbRefresh, &QPushButton::clicked, this, &MainWindow::onRefreshOutput);
|
||||||
this, &MainWindow::onOpenTemplate);
|
connect(m_ui->actionDatabaseGenerator, &QAction::triggered, this, &MainWindow::onGeneratorDb);
|
||||||
connect(m_ui->actionSave_Template, &QAction::triggered,
|
connect(m_ui->actionDDS_Generator, &QAction::triggered, this, &MainWindow::onGeneratorDds);
|
||||||
this, &MainWindow::onSaveTemplate);
|
|
||||||
connect(m_ui->pbRefresh, &QPushButton::clicked,
|
|
||||||
this, &MainWindow::onRefreshOutput);
|
|
||||||
connect(m_ui->actionDatabaseGenerator, &QAction::triggered,
|
|
||||||
this, &MainWindow::onGeneratorDb);
|
|
||||||
connect(m_ui->actionDDS_Generator, &QAction::triggered,
|
|
||||||
this, &MainWindow::onGeneratorDds);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
@@ -54,14 +42,16 @@ static QLatin1String s_startDir("/home/chehrlic/TDS/TDS-source-product/Lts/");
|
|||||||
|
|
||||||
void MainWindow::onSelectDataSource()
|
void MainWindow::onSelectDataSource()
|
||||||
{
|
{
|
||||||
const QString dataSource = QFileDialog::getOpenFileName(this, tr("Select data source"), s_startDir, tr("Service Files (*.xml)"));
|
const QString dataSource =
|
||||||
|
QFileDialog::getOpenFileName(this, tr("Select data source"), s_startDir, tr("Service Files (*.xml)"));
|
||||||
if (dataSource.isEmpty())
|
if (dataSource.isEmpty())
|
||||||
return;
|
return;
|
||||||
delete m_xmlReader;
|
delete m_xmlReader;
|
||||||
m_xmlReader = new CodeGen::XmlReader;
|
m_xmlReader = new CodeGen::XmlReader;
|
||||||
if (!m_xmlReader->readServiceFile(dataSource, m_idlServiceInfoFile))
|
if (!m_xmlReader->readServiceFile(dataSource, m_idlServiceInfoFile))
|
||||||
{
|
{
|
||||||
QMessageBox::warning(this, tr("Invalid data source"), tr("The selected data source is not valid: %1").arg(m_xmlReader->errorString()));
|
QMessageBox::warning(this, tr("Invalid data source"),
|
||||||
|
tr("The selected data source is not valid: %1").arg(m_xmlReader->errorString()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
delete m_structBuilder;
|
delete m_structBuilder;
|
||||||
@@ -78,7 +68,8 @@ void MainWindow::onSelectDataSource()
|
|||||||
|
|
||||||
void MainWindow::onOpenTemplate()
|
void MainWindow::onOpenTemplate()
|
||||||
{
|
{
|
||||||
const QString templateFile = QFileDialog::getOpenFileName(this, tr("Select data source"), s_startDir, tr("Templates (*.grantlee)"));
|
const QString templateFile =
|
||||||
|
QFileDialog::getOpenFileName(this, tr("Select data source"), s_startDir, tr("Templates (*.grantlee)"));
|
||||||
if (templateFile.isEmpty())
|
if (templateFile.isEmpty())
|
||||||
return;
|
return;
|
||||||
QFile f(templateFile);
|
QFile f(templateFile);
|
||||||
@@ -102,7 +93,8 @@ void MainWindow::onSaveTemplate()
|
|||||||
}
|
}
|
||||||
f.write(m_ui->teInput->toPlainText().toUtf8());
|
f.write(m_ui->teInput->toPlainText().toUtf8());
|
||||||
f.close();
|
f.close();
|
||||||
QMessageBox::information(this, tr("Saving template file"), tr("Successfully saved template to %1").arg(m_templateFile));
|
QMessageBox::information(this, tr("Saving template file"),
|
||||||
|
tr("Successfully saved template to %1").arg(m_templateFile));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onRefreshOutput()
|
void MainWindow::onRefreshOutput()
|
||||||
@@ -136,7 +128,6 @@ void MainWindow::onGeneratorDds()
|
|||||||
m_generator->init(m_xmlReader, m_structBuilder);
|
m_generator->init(m_xmlReader, m_structBuilder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
NGLApplication app(argc, argv);
|
NGLApplication app(argc, argv);
|
||||||
@@ -155,4 +146,3 @@ int main(int argc, char **argv)
|
|||||||
SHUTDOWN_LOG(m_logger);
|
SHUTDOWN_LOG(m_logger);
|
||||||
return iRet;
|
return iRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
Executable → Regular
+5
-3
@@ -1,21 +1,22 @@
|
|||||||
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <QObject>
|
|
||||||
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
namespace CodeGen
|
namespace CodeGen
|
||||||
{
|
{
|
||||||
class XmlReader;
|
class XmlReader;
|
||||||
class StructBuilder;
|
class StructBuilder;
|
||||||
class GeneratorGrantleeBase;
|
class GeneratorGrantleeBase;
|
||||||
}
|
} // namespace CodeGen
|
||||||
|
|
||||||
namespace Grantlee
|
namespace Grantlee
|
||||||
{
|
{
|
||||||
class Engine;
|
class Engine;
|
||||||
}
|
}
|
||||||
class Ui_MainGrantleeGui;
|
class Ui_MainGrantleeGui;
|
||||||
|
|
||||||
class MainWindow : public QMainWindow
|
class MainWindow : public QMainWindow
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -29,6 +30,7 @@ private Q_SLOTS:
|
|||||||
void onRefreshOutput();
|
void onRefreshOutput();
|
||||||
void onGeneratorDb();
|
void onGeneratorDb();
|
||||||
void onGeneratorDds();
|
void onGeneratorDds();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CodeGen::XmlReader* m_xmlReader;
|
CodeGen::XmlReader* m_xmlReader;
|
||||||
CodeGen::StructBuilder* m_structBuilder;
|
CodeGen::StructBuilder* m_structBuilder;
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QDir>
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QDir>
|
||||||
#include <grantlee/engine.h>
|
#include <grantlee/engine.h>
|
||||||
#include <grantlee/templateloader.h>
|
#include <grantlee/templateloader.h>
|
||||||
|
|
||||||
@@ -10,7 +9,8 @@ int main(int argc, char **argv)
|
|||||||
QCoreApplication app(argc, argv);
|
QCoreApplication app(argc, argv);
|
||||||
|
|
||||||
QString templatesDir = QDir::currentPath();
|
QString templatesDir = QDir::currentPath();
|
||||||
if (argc > 1) {
|
if (argc > 1)
|
||||||
|
{
|
||||||
templatesDir = QString::fromLocal8Bit(argv[1]);
|
templatesDir = QString::fromLocal8Bit(argv[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -21,7 +21,8 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
QDir d(templatesDir);
|
QDir d(templatesDir);
|
||||||
QStringList files = d.entryList(QStringList() << QStringLiteral("*.grantlee"), QDir::Files);
|
QStringList files = d.entryList(QStringList() << QStringLiteral("*.grantlee"), QDir::Files);
|
||||||
if (files.isEmpty()) {
|
if (files.isEmpty())
|
||||||
|
{
|
||||||
qDebug() << "No .grantlee templates found in" << templatesDir;
|
qDebug() << "No .grantlee templates found in" << templatesDir;
|
||||||
// Treat absence as successful parse (nothing to check) to avoid failing
|
// Treat absence as successful parse (nothing to check) to avoid failing
|
||||||
// when directory is empty in different setups.
|
// when directory is empty in different setups.
|
||||||
@@ -29,21 +30,27 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
for (const QString &f : files) {
|
for (const QString& f : files)
|
||||||
|
{
|
||||||
Grantlee::Template t;
|
Grantlee::Template t;
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
t = engine.loadByName(f);
|
t = engine.loadByName(f);
|
||||||
} catch (...) {
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
qDebug() << "Exception while loading" << f;
|
qDebug() << "Exception while loading" << f;
|
||||||
ok = false;
|
ok = false;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!t) {
|
if (!t)
|
||||||
|
{
|
||||||
qDebug() << "Failed to load template" << f;
|
qDebug() << "Failed to load template" << f;
|
||||||
ok = false;
|
ok = false;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (t->error() != Grantlee::NoError) {
|
if (t->error() != Grantlee::NoError)
|
||||||
|
{
|
||||||
qDebug() << "Parse error in" << f << ":" << t->errorString();
|
qDebug() << "Parse error in" << f << ":" << t->errorString();
|
||||||
ok = false;
|
ok = false;
|
||||||
continue;
|
continue;
|
||||||
@@ -51,7 +58,8 @@ int main(int argc, char **argv)
|
|||||||
// Render with empty context to ensure rendering path also works.
|
// Render with empty context to ensure rendering path also works.
|
||||||
Grantlee::Context ctx;
|
Grantlee::Context ctx;
|
||||||
QString out = t->render(&ctx);
|
QString out = t->render(&ctx);
|
||||||
if (out.isNull()) {
|
if (out.isNull())
|
||||||
|
{
|
||||||
qDebug() << "Rendering produced null for" << f;
|
qDebug() << "Rendering produced null for" << f;
|
||||||
ok = false;
|
ok = false;
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
-12
@@ -1,12 +0,0 @@
|
|||||||
#include "mocks/MockCoordTrans.h"
|
|
||||||
#include <gtest/gtest.h>
|
|
||||||
|
|
||||||
TEST(CoordTransGTest, ForwardInverseRoundtrip) {
|
|
||||||
auto p = MockCoordTrans::forward(1.2345, 2.3456);
|
|
||||||
EXPECT_NEAR(p.first, 1.2345 * 111000.0, 1e-6);
|
|
||||||
EXPECT_NEAR(p.second, 2.3456 * 111000.0, 1e-6);
|
|
||||||
|
|
||||||
auto inv = MockCoordTrans::inverse(p.first, p.second);
|
|
||||||
EXPECT_NEAR(inv.first, 1.2345, 1e-9);
|
|
||||||
EXPECT_NEAR(inv.second, 2.3456, 1e-9);
|
|
||||||
}
|
|
||||||
-15
@@ -1,15 +0,0 @@
|
|||||||
#include <QtTest/QtTest>
|
|
||||||
#include "mocks/MockCoordTrans.h"
|
|
||||||
|
|
||||||
class CoordTransSmoke : public QObject {
|
|
||||||
Q_OBJECT
|
|
||||||
private slots:
|
|
||||||
void testForward() {
|
|
||||||
auto p = MockCoordTrans::forward(10.0, 20.0);
|
|
||||||
QVERIFY(qFuzzyCompare(p.first, 10.0 * 111000.0));
|
|
||||||
QVERIFY(qFuzzyCompare(p.second, 20.0 * 111000.0));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
QTEST_MAIN(CoordTransSmoke)
|
|
||||||
#include "coordTransTests_smoke.moc"
|
|
||||||
-16
@@ -1,16 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <utility>
|
|
||||||
|
|
||||||
// Minimal realistic mock for coordinate transforms used during migration.
|
|
||||||
// Forward conversion returns approximate meters using lat/lon*111000.
|
|
||||||
class MockCoordTrans {
|
|
||||||
public:
|
|
||||||
// approximate forward: (lat, lon) -> (x_m, y_m)
|
|
||||||
static std::pair<double,double> forward(double lat_deg, double lon_deg) {
|
|
||||||
return {lat_deg * 111000.0, lon_deg * 111000.0};
|
|
||||||
}
|
|
||||||
// approximate inverse
|
|
||||||
static std::pair<double,double> inverse(double x_m, double y_m) {
|
|
||||||
return {x_m / 111000.0, y_m / 111000.0};
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Executable → Regular
+11
-32
@@ -1,16 +1,13 @@
|
|||||||
#include <LtsAppDescriptor/lts_app_descriptor.h>
|
#include <LtsAppDescriptor/lts_app_descriptor.h>
|
||||||
#include <utility>
|
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
|
#include <QDirIterator>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QFileInfoList>
|
#include <QFileInfoList>
|
||||||
#include <QDirIterator>
|
|
||||||
#include <QTextStream>
|
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QRegularExpressionMatch>
|
#include <QRegularExpressionMatch>
|
||||||
|
#include <QTextStream>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
@@ -31,7 +28,8 @@ 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(), f.errorString().toStdString().c_str());
|
printf("LtsAppDescriptorChecker: cannot open apps.json at %s: %s\n", appsJsonFilePath.toStdString().c_str(),
|
||||||
|
f.errorString().toStdString().c_str());
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,16 +38,16 @@ int main(int argc, char *argv[])
|
|||||||
QStringList lastErrors;
|
QStringList lastErrors;
|
||||||
QStringList dummy1;
|
QStringList dummy1;
|
||||||
QString dummy2;
|
QString dummy2;
|
||||||
LtsAppDescriptor::AppDescriptionVector adv = LtsAppDescriptor::LtsAppDescriptor::getAppDescriptionVector(f.readAll(), lastErrors, dummy1, dummy2);
|
LtsAppDescriptor::AppDescriptionVector adv =
|
||||||
|
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(), lastErrors.join(QStringLiteral("\r\n\r\n")).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());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
QFileInfoList guiPluginFiles;
|
QFileInfoList guiPluginFiles;
|
||||||
QDirIterator it(QStringLiteral("%1/../../Plugins/").arg(currentSrcDir), QDirIterator::Subdirectories);
|
QDirIterator it(QStringLiteral("%1/../../Plugins/").arg(currentSrcDir), QDirIterator::Subdirectories);
|
||||||
|
|
||||||
@@ -72,7 +70,6 @@ int main(int argc, char *argv[])
|
|||||||
filenames += fi.absoluteFilePath();
|
filenames += fi.absoluteFilePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QStringList guiPluginIIDs;
|
QStringList guiPluginIIDs;
|
||||||
for (const QFileInfo& fi : std::as_const(guiPluginFiles))
|
for (const QFileInfo& fi : std::as_const(guiPluginFiles))
|
||||||
{
|
{
|
||||||
@@ -102,8 +99,6 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
|
|
||||||
for (const LtsAppDescriptor::AppDescription& appdesc : std::as_const(adv))
|
for (const LtsAppDescriptor::AppDescription& appdesc : std::as_const(adv))
|
||||||
@@ -112,28 +107,12 @@ 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", appsJsonFilePath.toStdString().c_str(), pi.iid.toStdString().c_str());
|
printf("LtsAppDescriptorChecker: apps.json at '%s' uses unknown IID '%s'\n",
|
||||||
|
appsJsonFilePath.toStdString().c_str(), pi.iid.toStdString().c_str());
|
||||||
ok = false;
|
ok = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return !ok;
|
return !ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Executable → Regular
+25
-34
@@ -1,17 +1,13 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "lts_app_descriptor.h"
|
#include "lts_app_descriptor.h"
|
||||||
|
|
||||||
#include <QJsonDocument>
|
#include <QCoreApplication>
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
|
#include <QJsonDocument>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QJsonParseError>
|
#include <QJsonParseError>
|
||||||
#include <QJsonValue>
|
#include <QJsonValue>
|
||||||
#include <QCoreApplication>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace LtsAppDescriptor
|
namespace LtsAppDescriptor
|
||||||
{
|
{
|
||||||
@@ -20,7 +16,6 @@ static void addOptionToPlugin(PluginInfo &pluginInfo, const PluginInfo::Flag &fl
|
|||||||
pluginInfo.flags |= flag;
|
pluginInfo.flags |= flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void addOptionToPlugin(QVector<PluginInfo>& pluginInfos, const PluginInfo::Flag& flag, const QString& pluginName)
|
static void addOptionToPlugin(QVector<PluginInfo>& pluginInfos, const PluginInfo::Flag& flag, const QString& pluginName)
|
||||||
{
|
{
|
||||||
for (PluginInfo& pi : pluginInfos)
|
for (PluginInfo& pi : pluginInfos)
|
||||||
@@ -39,10 +34,9 @@ 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 QString &optionIdentifier, const QStringList &ignoredPlugins,
|
const QStringList& ignoredPlugins, const QJsonObject& optionsObject,
|
||||||
const QJsonObject &optionsObject, const PluginInfo::Flag flag, QStringList &lastErrors,
|
const PluginInfo::Flag flag, QStringList& lastErrors, bool atLeastOnePluginNeeded)
|
||||||
bool atLeastOnePluginNeeded)
|
|
||||||
{
|
{
|
||||||
bool hasPlugins = false;
|
bool hasPlugins = false;
|
||||||
auto optionsObjectIt = optionsObject.constFind(optionIdentifier);
|
auto optionsObjectIt = optionsObject.constFind(optionIdentifier);
|
||||||
@@ -63,14 +57,14 @@ 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'").arg(optionIdentifier, appDesc.appName));
|
lastErrors.append(QCoreApplication::tr("No plugins specified for '%1' option for app '%2'")
|
||||||
|
.arg(optionIdentifier, appDesc.appName));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
App LtsAppDescriptor::appFromInteger(int i)
|
App LtsAppDescriptor::appFromInteger(int i)
|
||||||
{
|
{
|
||||||
switch (i)
|
switch (i)
|
||||||
@@ -102,13 +96,11 @@ App LtsAppDescriptor::appFromInteger(int i)
|
|||||||
return App::Login;
|
return App::Login;
|
||||||
}
|
}
|
||||||
|
|
||||||
AppDescriptionVector LtsAppDescriptor::getAppDescriptionVector(const QByteArray &jsonDocument,
|
AppDescriptionVector LtsAppDescriptor::getAppDescriptionVector(const QByteArray& jsonDocument, QStringList& lastErrors,
|
||||||
QStringList &lastErrors,
|
|
||||||
const QStringList& ignoredPlugins,
|
const QStringList& ignoredPlugins,
|
||||||
QString& loginPluginIid)
|
QString& loginPluginIid)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
AppDescriptionVector appDescriptions;
|
AppDescriptionVector appDescriptions;
|
||||||
|
|
||||||
QJsonParseError parseError;
|
QJsonParseError parseError;
|
||||||
@@ -117,7 +109,6 @@ AppDescriptionVector LtsAppDescriptor::getAppDescriptionVector(const QByteArray
|
|||||||
if (parseError.error != QJsonParseError::NoError)
|
if (parseError.error != QJsonParseError::NoError)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
int row = 0;
|
int row = 0;
|
||||||
int column = 0;
|
int column = 0;
|
||||||
QChar x = QLatin1Char('\n');
|
QChar x = QLatin1Char('\n');
|
||||||
@@ -138,8 +129,10 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,14 +147,11 @@ AppDescriptionVector LtsAppDescriptor::getAppDescriptionVector(const QByteArray
|
|||||||
return appDescriptions;
|
return appDescriptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for (const auto& appElem : appArray)
|
for (const auto& appElem : appArray)
|
||||||
{
|
{
|
||||||
AppDescription appDesc;
|
AppDescription appDesc;
|
||||||
const QJsonObject appObject = appElem.toObject();
|
const QJsonObject appObject = appElem.toObject();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
appDesc.id = appFromInteger(appObject.value(QStringLiteral("Id")).toInt(-1));
|
appDesc.id = appFromInteger(appObject.value(QStringLiteral("Id")).toInt(-1));
|
||||||
if (appDesc.id == App::Login)
|
if (appDesc.id == App::Login)
|
||||||
{
|
{
|
||||||
@@ -176,7 +166,9 @@ 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)").arg(appDesc.appName).arg((int)valueActive.type()));
|
lastErrors.append(QCoreApplication::tr("App '%1': value App.Active is not a bool (%2)")
|
||||||
|
.arg(appDesc.appName)
|
||||||
|
.arg((int)valueActive.type()));
|
||||||
return appDescriptions;
|
return appDescriptions;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -185,7 +177,9 @@ 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)").arg(appDesc.appName).arg((int)valueVisible.type()));
|
lastErrors.append(QCoreApplication::tr("App '%1': value App.Visible is not a bool (%2)")
|
||||||
|
.arg(appDesc.appName)
|
||||||
|
.arg((int)valueVisible.type()));
|
||||||
return appDescriptions;
|
return appDescriptions;
|
||||||
}
|
}
|
||||||
appDesc.visible = valueVisible.toBool(true);
|
appDesc.visible = valueVisible.toBool(true);
|
||||||
@@ -194,22 +188,19 @@ AppDescriptionVector LtsAppDescriptor::getAppDescriptionVector(const QByteArray
|
|||||||
for (const QJsonValue& value : array)
|
for (const QJsonValue& value : array)
|
||||||
appDesc.requiredAcls.append(value.toInt());
|
appDesc.requiredAcls.append(value.toInt());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const QJsonObject optionsObject(appObject.value(QStringLiteral("Options")).toObject());
|
const QJsonObject optionsObject(appObject.value(QStringLiteral("Options")).toObject());
|
||||||
|
|
||||||
addOptionsToPlugin(appDesc, QStringLiteral("Payloads"), ignoredPlugins, optionsObject, PluginInfo::Flag::PAYLOAD, lastErrors, false);
|
addOptionsToPlugin(appDesc, QStringLiteral("Payloads"), ignoredPlugins, optionsObject,
|
||||||
addOptionsToPlugin(appDesc, QStringLiteral("Actions"), ignoredPlugins, optionsObject, PluginInfo::Flag::ACTIONS, lastErrors, true );
|
PluginInfo::Flag::PAYLOAD, lastErrors, false);
|
||||||
addOptionsToPlugin(appDesc, QStringLiteral("Main"), ignoredPlugins, optionsObject, PluginInfo::Flag::MAIN, lastErrors, false);
|
addOptionsToPlugin(appDesc, QStringLiteral("Actions"), ignoredPlugins, optionsObject, PluginInfo::Flag::ACTIONS,
|
||||||
|
lastErrors, true);
|
||||||
|
addOptionsToPlugin(appDesc, QStringLiteral("Main"), ignoredPlugins, optionsObject, PluginInfo::Flag::MAIN,
|
||||||
|
lastErrors, false);
|
||||||
|
|
||||||
appDescriptions.append(appDesc);
|
appDescriptions.append(appDesc);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return appDescriptions;
|
return appDescriptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace LtsAppDescriptor
|
||||||
Executable → Regular
+14
-15
@@ -1,10 +1,9 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QVector>
|
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
#include <QVector>
|
||||||
|
|
||||||
#ifndef LTSAPPDESCRIPTOR_EXPORT
|
#ifndef LTSAPPDESCRIPTOR_EXPORT
|
||||||
#ifdef BUILD_STATIC_LIBRARIES
|
#ifdef BUILD_STATIC_LIBRARIES
|
||||||
@@ -18,12 +17,10 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
namespace LtsAppDescriptor
|
namespace LtsAppDescriptor
|
||||||
{
|
{
|
||||||
|
|
||||||
enum class App
|
enum class App {
|
||||||
{
|
|
||||||
Login = -1,
|
Login = -1,
|
||||||
Situation = 0,
|
Situation = 0,
|
||||||
ResourceManager = 1,
|
ResourceManager = 1,
|
||||||
@@ -49,15 +46,13 @@ enum class App
|
|||||||
|
|
||||||
struct PluginInfo
|
struct PluginInfo
|
||||||
{
|
{
|
||||||
enum class PluginType
|
enum class PluginType {
|
||||||
{
|
|
||||||
UNKNOWN,
|
UNKNOWN,
|
||||||
DATA,
|
DATA,
|
||||||
GUI,
|
GUI,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class Flag
|
enum class Flag {
|
||||||
{
|
|
||||||
UNKNOWN = 1 << 0,
|
UNKNOWN = 1 << 0,
|
||||||
ACTIONS = 1 << 1,
|
ACTIONS = 1 << 1,
|
||||||
MAIN = 1 << 2,
|
MAIN = 1 << 2,
|
||||||
@@ -80,17 +75,21 @@ struct AppDescription
|
|||||||
QVector<int> requiredAcls;
|
QVector<int> requiredAcls;
|
||||||
QVector<PluginInfo> pluginInfos;
|
QVector<PluginInfo> pluginInfos;
|
||||||
|
|
||||||
bool isValid() const { return !appName.isEmpty(); }
|
bool isValid() const
|
||||||
|
{
|
||||||
|
return !appName.isEmpty();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef QVector<AppDescription> AppDescriptionVector;
|
typedef QVector<AppDescription> AppDescriptionVector;
|
||||||
|
|
||||||
|
|
||||||
namespace LtsAppDescriptor
|
namespace LtsAppDescriptor
|
||||||
{
|
{
|
||||||
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
|
||||||
Executable → Regular
+46
-67
@@ -1,18 +1,16 @@
|
|||||||
#include "lts_app_descriptor_editor.h"
|
#include "lts_app_descriptor_editor.h"
|
||||||
|
|
||||||
#include "ui_lts_app_descriptor_editor.h"
|
#include "ui_lts_app_descriptor_editor.h"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QJsonDocument>
|
|
||||||
#include <QStringListModel>
|
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
|
#include <QJsonDocument>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QStringListModel>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
#include <QDebug>
|
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();
|
||||||
@@ -50,10 +48,10 @@ LtsAppDescriptorEditor::~LtsAppDescriptorEditor()
|
|||||||
delete m_ui;
|
delete m_ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LtsAppDescriptorEditor::getAppDescriptionVector()
|
void LtsAppDescriptorEditor::getAppDescriptionVector()
|
||||||
{
|
{
|
||||||
m_fileName = QFileDialog::getOpenFileName(this, tr("Open JSON"), QLatin1Literal("/shd/CTC/TOOLS/TDS/TDS-source/Lts/Projects/Legatus/resources/"),
|
m_fileName = 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;
|
||||||
@@ -110,9 +108,9 @@ 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 + QLatin1String("]"));
|
pluginList << QString(type + QLatin1String(": ") + reqPlugin.iid + QLatin1String(" [ ") + strFlags +
|
||||||
|
QLatin1String("]"));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
updatePluginModel(pluginList);
|
updatePluginModel(pluginList);
|
||||||
|
|
||||||
@@ -188,8 +186,7 @@ void LtsAppDescriptorEditor::pluginTypeChanged()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QMessageBox msgBox(QMessageBox::Information,
|
QMessageBox msgBox(QMessageBox::Information, tr("Error"),
|
||||||
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());
|
||||||
@@ -202,9 +199,7 @@ void LtsAppDescriptorEditor::onAppAddClicked()
|
|||||||
|
|
||||||
if (m_ui->leAppName->text().isEmpty())
|
if (m_ui->leAppName->text().isEmpty())
|
||||||
{
|
{
|
||||||
QMessageBox msgBox(QMessageBox::Critical,
|
QMessageBox msgBox(QMessageBox::Critical, tr("Error"), tr("The App needs to have a name."));
|
||||||
tr("Error"),
|
|
||||||
tr("The App needs to have a name."));
|
|
||||||
msgBox.exec();
|
msgBox.exec();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -217,8 +212,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,
|
QMessageBox msgBox(QMessageBox::Critical, tr("Error"),
|
||||||
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;
|
||||||
@@ -230,7 +224,6 @@ void LtsAppDescriptorEditor::onAppAddClicked()
|
|||||||
m_vector.append(newApp);
|
m_vector.append(newApp);
|
||||||
|
|
||||||
updateAppModel();
|
updateAppModel();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LtsAppDescriptorEditor::onPluginAddClicked()
|
void LtsAppDescriptorEditor::onPluginAddClicked()
|
||||||
@@ -239,17 +232,13 @@ void LtsAppDescriptorEditor::onPluginAddClicked()
|
|||||||
|
|
||||||
if (m_ui->lePluginType->text().isEmpty())
|
if (m_ui->lePluginType->text().isEmpty())
|
||||||
{
|
{
|
||||||
QMessageBox msgBox(QMessageBox::Critical,
|
QMessageBox msgBox(QMessageBox::Critical, tr("Error"), tr("The Plugin needs to contain a type."));
|
||||||
tr("Error"),
|
|
||||||
tr("The Plugin needs to contain a type."));
|
|
||||||
msgBox.exec();
|
msgBox.exec();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (m_ui->lePluginName->text().isEmpty())
|
if (m_ui->lePluginName->text().isEmpty())
|
||||||
{
|
{
|
||||||
QMessageBox msgBox(QMessageBox::Critical,
|
QMessageBox msgBox(QMessageBox::Critical, tr("Error"), tr("The Plugin needs to have a name."));
|
||||||
tr("Error"),
|
|
||||||
tr("The Plugin needs to have a name."));
|
|
||||||
msgBox.exec();
|
msgBox.exec();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -262,14 +251,12 @@ 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,
|
QMessageBox msgBox(QMessageBox::Critical, tr("Error"),
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LtsAppDescriptor::PluginInfo newPlugin;
|
LtsAppDescriptor::PluginInfo newPlugin;
|
||||||
|
|
||||||
newPlugin.iid = m_ui->lePluginName->text();
|
newPlugin.iid = m_ui->lePluginName->text();
|
||||||
@@ -292,21 +279,19 @@ void LtsAppDescriptorEditor::onPluginAddClicked()
|
|||||||
|
|
||||||
onAppsClicked(m_appIndex);
|
onAppsClicked(m_appIndex);
|
||||||
onNewpluginClicked();
|
onNewpluginClicked();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LtsAppDescriptorEditor::onAppDeleteClicked()
|
void LtsAppDescriptorEditor::onAppDeleteClicked()
|
||||||
{
|
{
|
||||||
m_changed = true;
|
m_changed = true;
|
||||||
|
|
||||||
if(!m_appIndex.isValid()) return;
|
if (!m_appIndex.isValid())
|
||||||
|
return;
|
||||||
|
|
||||||
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::Warning, QMessageBox::Yes | QMessageBox::Default,
|
||||||
QMessageBox::Yes | QMessageBox::Default,
|
QMessageBox::No | QMessageBox::Escape, QMessageBox::NoButton);
|
||||||
QMessageBox::No | QMessageBox::Escape,
|
|
||||||
QMessageBox::NoButton);
|
|
||||||
|
|
||||||
if (msgBox.exec() == QMessageBox::No)
|
if (msgBox.exec() == QMessageBox::No)
|
||||||
return;
|
return;
|
||||||
@@ -314,21 +299,19 @@ void LtsAppDescriptorEditor::onAppDeleteClicked()
|
|||||||
m_vector.remove(m_appIndex.row());
|
m_vector.remove(m_appIndex.row());
|
||||||
|
|
||||||
updateAppModel();
|
updateAppModel();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LtsAppDescriptorEditor::onPluginDeletedClicked()
|
void LtsAppDescriptorEditor::onPluginDeletedClicked()
|
||||||
{
|
{
|
||||||
m_changed = true;
|
m_changed = true;
|
||||||
|
|
||||||
if(!m_pluginIndex.isValid()) return;
|
if (!m_pluginIndex.isValid())
|
||||||
|
return;
|
||||||
|
|
||||||
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::Warning, QMessageBox::Yes | QMessageBox::Default,
|
||||||
QMessageBox::Yes | QMessageBox::Default,
|
QMessageBox::No | QMessageBox::Escape, QMessageBox::NoButton);
|
||||||
QMessageBox::No | QMessageBox::Escape,
|
|
||||||
QMessageBox::NoButton);
|
|
||||||
|
|
||||||
if (msgBox.exec() == QMessageBox::No)
|
if (msgBox.exec() == QMessageBox::No)
|
||||||
return;
|
return;
|
||||||
@@ -354,17 +337,13 @@ void LtsAppDescriptorEditor::onUpdateClicked()
|
|||||||
|
|
||||||
if (m_ui->lePluginType->text().isEmpty())
|
if (m_ui->lePluginType->text().isEmpty())
|
||||||
{
|
{
|
||||||
QMessageBox msgBox(QMessageBox::Critical,
|
QMessageBox msgBox(QMessageBox::Critical, tr("Error"), tr("The Plugin needs to contain a type."));
|
||||||
tr("Error"),
|
|
||||||
tr("The Plugin needs to contain a type."));
|
|
||||||
msgBox.exec();
|
msgBox.exec();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (m_ui->lePluginName->text().isEmpty())
|
if (m_ui->lePluginName->text().isEmpty())
|
||||||
{
|
{
|
||||||
QMessageBox msgBox(QMessageBox::Critical,
|
QMessageBox msgBox(QMessageBox::Critical, tr("Error"), tr("The Plugin needs to have a name."));
|
||||||
tr("Error"),
|
|
||||||
tr("The Plugin needs to have a name."));
|
|
||||||
msgBox.exec();
|
msgBox.exec();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -372,20 +351,27 @@ 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 = LtsAppDescriptor::PluginInfo::PluginType::GUI;
|
m_vector[m_appIndex.row()].requiredPlugins[m_pluginIndex.row()].type =
|
||||||
|
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 = LtsAppDescriptor::PluginInfo::PluginType::DATA;
|
m_vector[m_appIndex.row()].requiredPlugins[m_pluginIndex.row()].type =
|
||||||
|
LtsAppDescriptor::PluginInfo::PluginType::DATA;
|
||||||
else
|
else
|
||||||
m_vector[m_appIndex.row()].requiredPlugins[m_pluginIndex.row()].type = LtsAppDescriptor::PluginInfo::PluginType::UNKNOWN;
|
m_vector[m_appIndex.row()].requiredPlugins[m_pluginIndex.row()].type =
|
||||||
|
LtsAppDescriptor::PluginInfo::PluginType::UNKNOWN;
|
||||||
|
|
||||||
m_vector[m_appIndex.row()].requiredPlugins[m_pluginIndex.row()].flags = QFlags<LtsAppDescriptor::PluginInfo::Flag>();
|
m_vector[m_appIndex.row()].requiredPlugins[m_pluginIndex.row()].flags =
|
||||||
|
QFlags<LtsAppDescriptor::PluginInfo::Flag>();
|
||||||
|
|
||||||
if (m_ui->chbActions->isChecked())
|
if (m_ui->chbActions->isChecked())
|
||||||
m_vector[m_appIndex.row()].requiredPlugins[m_pluginIndex.row()].flags |= LtsAppDescriptor::PluginInfo::Flag::ACTIONS;
|
m_vector[m_appIndex.row()].requiredPlugins[m_pluginIndex.row()].flags |=
|
||||||
|
LtsAppDescriptor::PluginInfo::Flag::ACTIONS;
|
||||||
if (m_ui->chbMain->isChecked())
|
if (m_ui->chbMain->isChecked())
|
||||||
m_vector[m_appIndex.row()].requiredPlugins[m_pluginIndex.row()].flags |= LtsAppDescriptor::PluginInfo::Flag::MAIN;
|
m_vector[m_appIndex.row()].requiredPlugins[m_pluginIndex.row()].flags |=
|
||||||
|
LtsAppDescriptor::PluginInfo::Flag::MAIN;
|
||||||
if (m_ui->chbPayload->isChecked())
|
if (m_ui->chbPayload->isChecked())
|
||||||
m_vector[m_appIndex.row()].requiredPlugins[m_pluginIndex.row()].flags |= LtsAppDescriptor::PluginInfo::Flag::PAYLOAD;
|
m_vector[m_appIndex.row()].requiredPlugins[m_pluginIndex.row()].flags |=
|
||||||
|
LtsAppDescriptor::PluginInfo::Flag::PAYLOAD;
|
||||||
|
|
||||||
onAppsClicked(m_appIndex);
|
onAppsClicked(m_appIndex);
|
||||||
onNewpluginClicked();
|
onNewpluginClicked();
|
||||||
@@ -465,12 +451,9 @@ void LtsAppDescriptorEditor::checkSave()
|
|||||||
{
|
{
|
||||||
if (m_changed)
|
if (m_changed)
|
||||||
{
|
{
|
||||||
QMessageBox msgBox(tr("Warning"),
|
QMessageBox msgBox(tr("Warning"), tr("The Data has been modified.\nDo you want to save your changes?"),
|
||||||
tr("The Data has been modified.\nDo you want to save your changes?"),
|
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::Yes)
|
if (msgBox.exec() == QMessageBox::Yes)
|
||||||
onSaveAsClicked();
|
onSaveAsClicked();
|
||||||
@@ -479,7 +462,8 @@ void LtsAppDescriptorEditor::checkSave()
|
|||||||
|
|
||||||
void LtsAppDescriptorEditor::onSaveAsClicked()
|
void LtsAppDescriptorEditor::onSaveAsClicked()
|
||||||
{
|
{
|
||||||
QString fileName = QFileDialog::getSaveFileName(this, tr("Save JSON"), QLatin1Literal("/shd/CTC/TOOLS/TDS/TDS-source/Lts/Projects/Legatus/resources/"),
|
QString fileName = 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;
|
||||||
@@ -494,9 +478,7 @@ void LtsAppDescriptorEditor::onSaveAsClicked()
|
|||||||
|
|
||||||
m_changed = false;
|
m_changed = false;
|
||||||
|
|
||||||
QMessageBox msgBox(QMessageBox::Information,
|
QMessageBox msgBox(QMessageBox::Information, tr("Success"), tr("Your file has been saved."));
|
||||||
tr("Success"),
|
|
||||||
tr("Your file has been saved."));
|
|
||||||
msgBox.exec();
|
msgBox.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -511,9 +493,7 @@ void LtsAppDescriptorEditor::onSaveClicked()
|
|||||||
|
|
||||||
m_changed = false;
|
m_changed = false;
|
||||||
|
|
||||||
QMessageBox msgBox(QMessageBox::Information,
|
QMessageBox msgBox(QMessageBox::Information, tr("Success"), tr("Your file has been saved."));
|
||||||
tr("Success"),
|
|
||||||
tr("Your file has been saved."));
|
|
||||||
msgBox.exec();
|
msgBox.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -540,7 +520,6 @@ void LtsAppDescriptorEditor::onNewClicked()
|
|||||||
|
|
||||||
updateAppModel();
|
updateAppModel();
|
||||||
updatePluginModel(QStringList());
|
updatePluginModel(QStringList());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LtsAppDescriptorEditor::enableNewPlugin()
|
void LtsAppDescriptorEditor::enableNewPlugin()
|
||||||
|
|||||||
Executable → Regular
+4
-6
@@ -1,11 +1,10 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <QObject>
|
|
||||||
|
|
||||||
#include <QtWidgets/QWidget>
|
|
||||||
#include <QModelIndex>
|
|
||||||
|
|
||||||
#include "lts_app_descriptor.h"
|
#include "lts_app_descriptor.h"
|
||||||
|
|
||||||
|
#include <QModelIndex>
|
||||||
|
#include <QObject>
|
||||||
|
#include <QtWidgets/QWidget>
|
||||||
|
|
||||||
#ifndef LTSAPPDESCRIPTOREDITOR_EXPORT
|
#ifndef LTSAPPDESCRIPTOREDITOR_EXPORT
|
||||||
#ifdef BUILD_STATIC_LIBRARIES
|
#ifdef BUILD_STATIC_LIBRARIES
|
||||||
#define LTSAPPDESCRIPTOREDITOR_EXPORT
|
#define LTSAPPDESCRIPTOREDITOR_EXPORT
|
||||||
@@ -20,7 +19,6 @@
|
|||||||
|
|
||||||
class Ui_LtsAppDescriptionEditor;
|
class Ui_LtsAppDescriptionEditor;
|
||||||
|
|
||||||
|
|
||||||
class LTSAPPDESCRIPTOREDITOR_EXPORT LtsAppDescriptorEditor : public QWidget
|
class LTSAPPDESCRIPTOREDITOR_EXPORT LtsAppDescriptorEditor : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|||||||
Executable → Regular
+1
-2
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "lts_app_descriptor_editor.h"
|
#include "lts_app_descriptor_editor.h"
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
@@ -39,7 +39,6 @@ int main(int argc, char *argv[])
|
|||||||
quitAct->setStatusTip(QObject::tr("Quit the Application"));
|
quitAct->setStatusTip(QObject::tr("Quit the Application"));
|
||||||
fileMenu->addAction(quitAct);
|
fileMenu->addAction(quitAct);
|
||||||
|
|
||||||
|
|
||||||
LtsAppDescriptorEditor* editor = new LtsAppDescriptorEditor(mainWindow);
|
LtsAppDescriptorEditor* editor = new LtsAppDescriptorEditor(mainWindow);
|
||||||
mainWindow->setCentralWidget(editor);
|
mainWindow->setCentralWidget(editor);
|
||||||
QObject::connect(openAct, &QAction::triggered, editor, &LtsAppDescriptorEditor::onOpenClicked);
|
QObject::connect(openAct, &QAction::triggered, editor, &LtsAppDescriptorEditor::onOpenClicked);
|
||||||
|
|||||||
Executable → Regular
+4
-7
@@ -1,17 +1,14 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "app.h"
|
#include "app.h"
|
||||||
#include "ui_app.h"
|
|
||||||
#include "AppChooser/app_chooser_model.h"
|
|
||||||
|
|
||||||
|
#include "AppChooser/app_chooser_model.h"
|
||||||
|
#include "ui_app.h"
|
||||||
|
|
||||||
namespace LtsAppManager
|
namespace LtsAppManager
|
||||||
{
|
{
|
||||||
|
|
||||||
CustomViewApp::CustomViewApp(QWidget *parent)
|
CustomViewApp::CustomViewApp(QWidget* parent) : AbstractDisplayWidget(parent), m_ui(new Ui::CustomViewApp)
|
||||||
: AbstractDisplayWidget(parent)
|
|
||||||
, m_ui(new Ui::CustomViewApp)
|
|
||||||
{
|
{
|
||||||
m_ui->setupUi(this);
|
m_ui->setupUi(this);
|
||||||
m_ui->image->setMenuEnabled(false);
|
m_ui->image->setMenuEnabled(false);
|
||||||
@@ -32,4 +29,4 @@ bool CustomViewApp::init(const QModelIndex &idx)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace LtsAppManager
|
||||||
Executable → Regular
+1
-4
@@ -2,10 +2,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
#include <Viewer/LtsDataView/abstract_display_widget.h>
|
#include <Viewer/LtsDataView/abstract_display_widget.h>
|
||||||
|
|
||||||
|
|
||||||
namespace Ui
|
namespace Ui
|
||||||
{
|
{
|
||||||
class CustomViewApp;
|
class CustomViewApp;
|
||||||
@@ -25,7 +23,6 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::CustomViewApp* m_ui;
|
Ui::CustomViewApp* m_ui;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace LtsAppManager
|
||||||
Executable → Regular
+12
-25
@@ -1,38 +1,30 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "AppChooser/app_chooser.h"
|
#include "AppChooser/app_chooser.h"
|
||||||
#include "ui_app_chooser.h"
|
|
||||||
|
#include "AppChooser/CustomViews/app.h"
|
||||||
#include "AppChooser/app_chooser_model.h"
|
#include "AppChooser/app_chooser_model.h"
|
||||||
#include "lts_app_manager.h"
|
#include "lts_app_manager.h"
|
||||||
#include "AppChooser/CustomViews/app.h"
|
#include "ui_app_chooser.h"
|
||||||
|
|
||||||
#include <QCloseEvent>
|
#include <QCloseEvent>
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
|
||||||
namespace LtsAppManager
|
namespace LtsAppManager
|
||||||
{
|
{
|
||||||
|
|
||||||
AppChooser::AppChooser()
|
AppChooser::AppChooser() : QWidget(nullptr), m_ui(new Ui::AppChooser), m_model(), m_madeSelection(false)
|
||||||
: QWidget(nullptr)
|
|
||||||
, m_ui(new Ui::AppChooser)
|
|
||||||
, m_model()
|
|
||||||
, m_madeSelection(false)
|
|
||||||
{
|
{
|
||||||
m_ui->setupUi(this);
|
m_ui->setupUi(this);
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
|
||||||
connect(m_ui->widget, &LtsDataView::LtsDataView::LtsDataView::signalDoubleClicked,
|
connect(m_ui->widget, &LtsDataView::LtsDataView::LtsDataView::signalDoubleClicked, this,
|
||||||
this, &AppChooser::slotAppSelected);
|
&AppChooser::slotAppSelected);
|
||||||
connect(m_ui->widget, &LtsDataView::LtsDataView::LtsDataView::signalEnterPressed,
|
connect(m_ui->widget, &LtsDataView::LtsDataView::LtsDataView::signalEnterPressed, this,
|
||||||
this, &AppChooser::slotAppSelected);
|
&AppChooser::slotAppSelected);
|
||||||
connect(m_ui->widget, &LtsDataView::LtsDataView::LtsDataView::signalSelectionChanged,
|
connect(m_ui->widget, &LtsDataView::LtsDataView::LtsDataView::signalSelectionChanged, this, &AppChooser::enaDisa);
|
||||||
this, &AppChooser::enaDisa);
|
connect(m_ui->pbQuit, &QPushButton::clicked, this, &QWidget::close);
|
||||||
connect(m_ui->pbQuit, &QPushButton::clicked,
|
connect(m_ui->pbSelect, &QPushButton::clicked, this, &AppChooser::slotAppSelected);
|
||||||
this, &QWidget::close);
|
|
||||||
connect(m_ui->pbSelect, &QPushButton::clicked,
|
|
||||||
this, &AppChooser::slotAppSelected);
|
|
||||||
|
|
||||||
m_model = new AppChooserModel(this);
|
m_model = new AppChooserModel(this);
|
||||||
m_model->initModel(LtsAppManager::getInstance()->getAvailableApps());
|
m_model->initModel(LtsAppManager::getInstance()->getAvailableApps());
|
||||||
@@ -43,14 +35,12 @@ AppChooser::AppChooser()
|
|||||||
m_ui->widget->hideColumn(AppChooserModel::Columns::Visible);
|
m_ui->widget->hideColumn(AppChooserModel::Columns::Visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
AppChooser::~AppChooser()
|
AppChooser::~AppChooser()
|
||||||
{
|
{
|
||||||
|
|
||||||
delete m_ui;
|
delete m_ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AppChooser::slotQuit()
|
void AppChooser::slotQuit()
|
||||||
{
|
{
|
||||||
if (m_alreadyCloseEmitted)
|
if (m_alreadyCloseEmitted)
|
||||||
@@ -59,14 +49,12 @@ void AppChooser::slotQuit()
|
|||||||
emit signalLogout();
|
emit signalLogout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AppChooser::closeEvent(QCloseEvent*)
|
void AppChooser::closeEvent(QCloseEvent*)
|
||||||
{
|
{
|
||||||
if (!m_madeSelection)
|
if (!m_madeSelection)
|
||||||
slotQuit();
|
slotQuit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AppChooser::slotAppSelected()
|
void AppChooser::slotAppSelected()
|
||||||
{
|
{
|
||||||
const QModelIndex idx = m_ui->widget->currentIndex();
|
const QModelIndex idx = m_ui->widget->currentIndex();
|
||||||
@@ -81,7 +69,6 @@ void AppChooser::slotAppSelected()
|
|||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AppChooser::enaDisa()
|
void AppChooser::enaDisa()
|
||||||
{
|
{
|
||||||
const QModelIndexList selectedRows = m_ui->widget->selectedRows();
|
const QModelIndexList selectedRows = m_ui->widget->selectedRows();
|
||||||
@@ -90,4 +77,4 @@ void AppChooser::enaDisa()
|
|||||||
m_ui->pbSelect->setEnabled(cntSelectedRows == 1);
|
m_ui->pbSelect->setEnabled(cntSelectedRows == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace LtsAppManager
|
||||||
Executable → Regular
+3
-6
@@ -1,16 +1,14 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <QObject>
|
|
||||||
|
|
||||||
#include <QWidget>
|
|
||||||
#include <LtsAppDescriptor/lts_app_descriptor.h>
|
#include <LtsAppDescriptor/lts_app_descriptor.h>
|
||||||
|
#include <QObject>
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
namespace Ui
|
namespace Ui
|
||||||
{
|
{
|
||||||
class AppChooser;
|
class AppChooser;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace LtsAppManager
|
namespace LtsAppManager
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -42,7 +40,6 @@ signals:
|
|||||||
private slots:
|
private slots:
|
||||||
void slotAppSelected();
|
void slotAppSelected();
|
||||||
void slotQuit();
|
void slotQuit();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace LtsAppManager
|
||||||
Executable → Regular
+3
-5
@@ -4,15 +4,14 @@
|
|||||||
|
|
||||||
#include <LtsSession/lts_session.h>
|
#include <LtsSession/lts_session.h>
|
||||||
|
|
||||||
|
|
||||||
namespace LtsAppManager
|
namespace LtsAppManager
|
||||||
{
|
{
|
||||||
|
|
||||||
AppChooserModel::AppChooserModel(QObject* parent)
|
AppChooserModel::AppChooserModel(QObject* parent)
|
||||||
: LtsWidgets::LtsAbstractTableModel<LtsAppDescriptor::AppDescription>({tr("Name")}, parent)
|
: LtsWidgets::LtsAbstractTableModel<LtsAppDescriptor::AppDescription>({tr("Name")}, parent)
|
||||||
|
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
bool AppChooserModel::initModel(const LtsAppDescriptor::AppDescriptionVector& availableApps)
|
bool AppChooserModel::initModel(const LtsAppDescriptor::AppDescriptionVector& availableApps)
|
||||||
{
|
{
|
||||||
@@ -29,7 +28,6 @@ bool AppChooserModel::initModel(const LtsAppDescriptor::AppDescriptionVector &av
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QVariant AppChooserModel::data(const QModelIndex& index, int role) const
|
QVariant AppChooserModel::data(const QModelIndex& index, int role) const
|
||||||
{
|
{
|
||||||
if (role != Qt::DisplayRole || !indexIsValid(index))
|
if (role != Qt::DisplayRole || !indexIsValid(index))
|
||||||
@@ -47,4 +45,4 @@ QVariant AppChooserModel::data(const QModelIndex &index, int role) const
|
|||||||
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
}
|
} // namespace LtsAppManager
|
||||||
Executable → Regular
+3
-8
@@ -1,12 +1,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <QObject>
|
|
||||||
|
|
||||||
|
|
||||||
#include <LtsAppDescriptor/lts_app_descriptor.h>
|
#include <LtsAppDescriptor/lts_app_descriptor.h>
|
||||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
|
||||||
namespace LtsAppManager
|
namespace LtsAppManager
|
||||||
{
|
{
|
||||||
@@ -15,8 +11,7 @@ class AppChooserModel final : public LtsWidgets::LtsAbstractTableModel<LtsAppDes
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum Columns
|
enum Columns {
|
||||||
{
|
|
||||||
Name = 0,
|
Name = 0,
|
||||||
Visible,
|
Visible,
|
||||||
};
|
};
|
||||||
@@ -27,4 +22,4 @@ public:
|
|||||||
|
|
||||||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override final;
|
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override final;
|
||||||
};
|
};
|
||||||
}
|
} // namespace LtsAppManager
|
||||||
Executable → Regular
+120
-309
File diff suppressed because it is too large.
Load diff
Executable → Regular
+36
-23
@@ -1,14 +1,13 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <LtsAppDescriptor/lts_app_descriptor.h>
|
|
||||||
#include <Lts/Common/ProjectConfig/project_defines.h>
|
#include <Lts/Common/ProjectConfig/project_defines.h>
|
||||||
#include <LtsWidgets/lts_dialog.h>
|
#include <LtsAppDescriptor/lts_app_descriptor.h>
|
||||||
#include <LtsWidgets/lts_base_layout_widget.h>
|
|
||||||
#include <LtsSession/lts_session.h>
|
#include <LtsSession/lts_session.h>
|
||||||
#include <memory>
|
#include <LtsWidgets/lts_base_layout_widget.h>
|
||||||
|
#include <LtsWidgets/lts_dialog.h>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#ifndef LTSAPPMANAGER_EXPORT
|
#ifndef LTSAPPMANAGER_EXPORT
|
||||||
#ifdef BUILD_STATIC_LIBRARIES
|
#ifdef BUILD_STATIC_LIBRARIES
|
||||||
@@ -22,7 +21,6 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
namespace LtsPluginManager
|
namespace LtsPluginManager
|
||||||
{
|
{
|
||||||
class LtsPluginManager;
|
class LtsPluginManager;
|
||||||
@@ -37,7 +35,7 @@ namespace LtsSession
|
|||||||
{
|
{
|
||||||
class LtsSession;
|
class LtsSession;
|
||||||
struct DdsConnectionParams;
|
struct DdsConnectionParams;
|
||||||
}
|
} // namespace LtsSession
|
||||||
|
|
||||||
namespace DeveloperTools
|
namespace DeveloperTools
|
||||||
{
|
{
|
||||||
@@ -46,7 +44,6 @@ class DevDialog;
|
|||||||
|
|
||||||
class QTcpSocket;
|
class QTcpSocket;
|
||||||
|
|
||||||
|
|
||||||
namespace LtsAppManager
|
namespace LtsAppManager
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -59,14 +56,30 @@ public:
|
|||||||
|
|
||||||
void showLogin();
|
void showLogin();
|
||||||
|
|
||||||
|
LtsPluginManager::LtsPluginManager* createApp(LtsAppDescriptor::App appId,
|
||||||
|
const LtsSession::DdsConnectionParams& connParams,
|
||||||
|
const QString& workspaceId = QString(), bool hidden = false,
|
||||||
|
bool force = false);
|
||||||
|
bool startAppOrLetUserChoose(LtsAppDescriptor::App appId, const LtsSession::DdsConnectionParams& connParams,
|
||||||
|
bool force = false);
|
||||||
|
|
||||||
|
void setLoginPluginIid(const QString& loginPluginIid)
|
||||||
|
{
|
||||||
|
m_loginPluginIid = loginPluginIid;
|
||||||
|
}
|
||||||
|
|
||||||
LtsPluginManager::LtsPluginManager *createApp(LtsAppDescriptor::App appId, const LtsSession::DdsConnectionParams &connParams,
|
|
||||||
const QString &workspaceId = QString(), bool hidden = false, bool force = false);
|
|
||||||
bool startAppOrLetUserChoose(LtsAppDescriptor::App appId, const LtsSession::DdsConnectionParams &connParams, bool force = false);
|
|
||||||
void setLoginPluginIid(const QString &loginPluginIid) { m_loginPluginIid = loginPluginIid; }
|
|
||||||
void setMainApp(LtsAppDescriptor::App appId = LtsAppDescriptor::App::Login);
|
void setMainApp(LtsAppDescriptor::App appId = LtsAppDescriptor::App::Login);
|
||||||
QVector<LtsPluginManager::LtsPluginManager *> getAppList() const { return m_appList ;}
|
|
||||||
LtsAppDescriptor::AppDescriptionVector getAvailableApps() const { return m_availableApps; }
|
QVector<LtsPluginManager::LtsPluginManager*> getAppList() const
|
||||||
|
{
|
||||||
|
return m_appList;
|
||||||
|
}
|
||||||
|
|
||||||
|
LtsAppDescriptor::AppDescriptionVector getAvailableApps() const
|
||||||
|
{
|
||||||
|
return m_availableApps;
|
||||||
|
}
|
||||||
|
|
||||||
void setAvailableApps(const LtsAppDescriptor::AppDescriptionVector& availableApps);
|
void setAvailableApps(const LtsAppDescriptor::AppDescriptionVector& availableApps);
|
||||||
bool hasRightForApp(const LtsAppDescriptor::AppDescription& appDescription) const;
|
bool hasRightForApp(const LtsAppDescriptor::AppDescription& appDescription) const;
|
||||||
LtsAppDescriptor::AppDescription getApp(LtsAppDescriptor::App appId) const;
|
LtsAppDescriptor::AppDescription getApp(LtsAppDescriptor::App appId) const;
|
||||||
@@ -74,11 +87,10 @@ public:
|
|||||||
int getNumberOfSituationMapInstances() const;
|
int getNumberOfSituationMapInstances() const;
|
||||||
void debugSendMessage(const QString& msg);
|
void debugSendMessage(const QString& msg);
|
||||||
|
|
||||||
|
bool otherSessionsResponsibility(LtsSession::LtsSession* thisSession,
|
||||||
|
const QVector<LtsAppDescriptor::App>& requiredAppTypes,
|
||||||
bool otherSessionsResponsibility(LtsSession::LtsSession *thisSession, const QVector<LtsAppDescriptor::App> &requiredAppTypes,
|
const QVector<IDL::PartitionType>& requiredPartitionTypes,
|
||||||
const QVector<IDL::PartitionType> &requiredPartitionTypes, const QString &menuGroup,
|
const QString& menuGroup, const QString& identifier, LtsWidgets::LayoutArea area);
|
||||||
const QString &identifier, LtsWidgets::LayoutArea area);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend struct LtsAppManagerHandler;
|
friend struct LtsAppManagerHandler;
|
||||||
@@ -87,11 +99,12 @@ private:
|
|||||||
LtsAppManager();
|
LtsAppManager();
|
||||||
~LtsAppManager();
|
~LtsAppManager();
|
||||||
|
|
||||||
bool startAppOrLetUserChoose(const LtsAppDescriptor::AppDescription &appDescription, const LtsSession::DdsConnectionParams &connParams, bool force = false);
|
bool startAppOrLetUserChoose(const LtsAppDescriptor::AppDescription& appDescription,
|
||||||
|
const LtsSession::DdsConnectionParams& connParams, bool force = false);
|
||||||
LtsPluginManager::LtsPluginManager* createApp(const LtsAppDescriptor::AppDescription& appDescription,
|
LtsPluginManager::LtsPluginManager* createApp(const LtsAppDescriptor::AppDescription& appDescription,
|
||||||
const LtsSession::DdsConnectionParams& connParams,
|
const LtsSession::DdsConnectionParams& connParams,
|
||||||
const QString &workspaceId = QString(),
|
const QString& workspaceId = QString(), bool hidden = false,
|
||||||
bool hidden = false, bool force = false);
|
bool force = false);
|
||||||
void saveState();
|
void saveState();
|
||||||
|
|
||||||
LtsAppDescriptor::AppDescriptionVector m_availableApps;
|
LtsAppDescriptor::AppDescriptionVector m_availableApps;
|
||||||
@@ -120,4 +133,4 @@ signals:
|
|||||||
void signalCommand(QTcpSocket* client, const QStringList argList);
|
void signalCommand(QTcpSocket* client, const QStringList argList);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace LtsAppManager
|
||||||
Executable → Regular
+18
-21
@@ -1,20 +1,19 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "LtsCommandLineParser.h"
|
#include "LtsCommandLineParser.h"
|
||||||
#include <ngltools/ngltools_filesystem.h>
|
|
||||||
#include <QNetworkInterface>
|
|
||||||
#include <QFlags>
|
#include <QFlags>
|
||||||
|
#include <QNetworkInterface>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
#include <ngltools/ngltools_filesystem.h>
|
||||||
|
|
||||||
namespace LtsCommandLineParser
|
namespace LtsCommandLineParser
|
||||||
{
|
{
|
||||||
static constexpr int s_maxDomainId = 232;
|
static constexpr int s_maxDomainId = 232;
|
||||||
|
|
||||||
LtsCommandLineParser::LtsCommandLineParser(ProvideCommandLineParameterOptions opts)
|
LtsCommandLineParser::LtsCommandLineParser(ProvideCommandLineParameterOptions opts)
|
||||||
: QCommandLineParser()
|
: QCommandLineParser(), m_enabledOptions(opts)
|
||||||
, m_enabledOptions(opts)
|
|
||||||
{
|
{
|
||||||
if (NGL::isAppInBuildBasePath() || m_enabledOptions.testFlag(CreateDomainIdFromIp))
|
if (NGL::isAppInBuildBasePath() || m_enabledOptions.testFlag(CreateDomainIdFromIp))
|
||||||
{
|
{
|
||||||
@@ -26,7 +25,6 @@ LtsCommandLineParser::LtsCommandLineParser(ProvideCommandLineParameterOptions op
|
|||||||
if (address.protocol() != QAbstractSocket::IPv4Protocol)
|
if (address.protocol() != QAbstractSocket::IPv4Protocol)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
||||||
m_generatedDomainId = (address.toIPv4Address() & 0x000000ff) % 232;
|
m_generatedDomainId = (address.toIPv4Address() & 0x000000ff) % 232;
|
||||||
if (m_generatedDomainId == 0)
|
if (m_generatedDomainId == 0)
|
||||||
m_generatedDomainId = s_maxDomainId;
|
m_generatedDomainId = s_maxDomainId;
|
||||||
@@ -38,22 +36,19 @@ LtsCommandLineParser::LtsCommandLineParser(ProvideCommandLineParameterOptions op
|
|||||||
addOption({{QStringLiteral("e"), QStringLiteral("exerciseid")},
|
addOption({{QStringLiteral("e"), QStringLiteral("exerciseid")},
|
||||||
QStringLiteral("Default: -1 (invalid, get from lts-cc.conf)"),
|
QStringLiteral("Default: -1 (invalid, get from lts-cc.conf)"),
|
||||||
QStringLiteral("exerciseId"),
|
QStringLiteral("exerciseId"),
|
||||||
QStringLiteral("-1")
|
QStringLiteral("-1")});
|
||||||
});
|
|
||||||
if (m_enabledOptions.testFlag(DomainId))
|
if (m_enabledOptions.testFlag(DomainId))
|
||||||
addOption({{QStringLiteral("d"), QStringLiteral("domainid")},
|
addOption({{QStringLiteral("d"), QStringLiteral("domainid")},
|
||||||
QStringLiteral("Default: ") + QString::number(m_generatedDomainId),
|
QStringLiteral("Default: ") + QString::number(m_generatedDomainId),
|
||||||
QStringLiteral("domainId"),
|
QStringLiteral("domainId"),
|
||||||
QString::number(m_generatedDomainId)
|
QString::number(m_generatedDomainId)});
|
||||||
});
|
|
||||||
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("Default: ") + cf,
|
||||||
QStringLiteral("filename"),
|
QStringLiteral("filename"),
|
||||||
cf
|
cf});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
if (m_enabledOptions.testFlag(TcpConnectionUrl))
|
if (m_enabledOptions.testFlag(TcpConnectionUrl))
|
||||||
{
|
{
|
||||||
@@ -61,8 +56,7 @@ LtsCommandLineParser::LtsCommandLineParser(ProvideCommandLineParameterOptions op
|
|||||||
addOption({{QStringLiteral("t"), QStringLiteral("tcpurl")},
|
addOption({{QStringLiteral("t"), QStringLiteral("tcpurl")},
|
||||||
QStringLiteral("Default: ") + defaultTcpUrl,
|
QStringLiteral("Default: ") + defaultTcpUrl,
|
||||||
QStringLiteral("hostname:port"),
|
QStringLiteral("hostname:port"),
|
||||||
defaultTcpUrl
|
defaultTcpUrl});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
addHelpOption();
|
addHelpOption();
|
||||||
|
|
||||||
@@ -76,9 +70,15 @@ int LtsCommandLineParser::domainId() const
|
|||||||
{
|
{
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
|
||||||
fprintf(stdout, "\n\nAttention: using a default domain id != 0 because executable is run inside builddir - default domainid is %d\n\n", m_generatedDomainId);
|
fprintf(stdout,
|
||||||
|
"\n\nAttention: using a default domain id != 0 because executable is run inside builddir - default "
|
||||||
|
"domainid is %d\n\n",
|
||||||
|
m_generatedDomainId);
|
||||||
#else
|
#else
|
||||||
fprintf(stdout, "\n\n\e[31mAttention: using a default domain id != 0 because executable is run inside builddir - default domainid is %d\e[0m\n\n", m_generatedDomainId);
|
fprintf(stdout,
|
||||||
|
"\n\n\e[31mAttention: using a default domain id != 0 because executable is run inside builddir - "
|
||||||
|
"default domainid is %d\e[0m\n\n",
|
||||||
|
m_generatedDomainId);
|
||||||
#endif
|
#endif
|
||||||
return m_generatedDomainId;
|
return m_generatedDomainId;
|
||||||
}
|
}
|
||||||
@@ -115,8 +115,7 @@ QUrl LtsCommandLineParser::tcpConnectionUrl() const
|
|||||||
|
|
||||||
str.replace(QLatin1String("tcpv4_lan"), QLatin1String("tcpv4lan"));
|
str.replace(QLatin1String("tcpv4_lan"), QLatin1String("tcpv4lan"));
|
||||||
QUrl url = QUrl::fromUserInput(str);
|
QUrl url = QUrl::fromUserInput(str);
|
||||||
if (url.scheme() == QLatin1String("http") ||
|
if (url.scheme() == QLatin1String("http") || url.scheme() == QLatin1String("file"))
|
||||||
url.scheme() == QLatin1String("file"))
|
|
||||||
url.setScheme(QStringLiteral("tcpv4lan"));
|
url.setScheme(QStringLiteral("tcpv4lan"));
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
@@ -161,7 +160,6 @@ void LtsCommandLineParser::showHelp(int exitCode)
|
|||||||
if (!m_additionalHelpStr.isEmpty())
|
if (!m_additionalHelpStr.isEmpty())
|
||||||
fprintf(stdout, "%s", qPrintable(m_additionalHelpStr));
|
fprintf(stdout, "%s", qPrintable(m_additionalHelpStr));
|
||||||
|
|
||||||
|
|
||||||
QCommandLineParser::showHelp(exitCode);
|
QCommandLineParser::showHelp(exitCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,5 +177,4 @@ bool LtsCommandLineParser::exerciseIdProvided() const
|
|||||||
return isSet(QStringLiteral("e"));
|
return isSet(QStringLiteral("e"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace LtsCommandLineParser
|
||||||
}
|
|
||||||
Executable → Regular
+22
-9
@@ -1,19 +1,19 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QCommandLineParser>
|
|
||||||
#include "ltscommandlineparser_export.h"
|
#include "ltscommandlineparser_export.h"
|
||||||
|
|
||||||
|
#include <QCommandLineParser>
|
||||||
|
|
||||||
class QUrl;
|
class QUrl;
|
||||||
|
|
||||||
namespace LtsCommandLineParser
|
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,
|
||||||
@@ -23,12 +23,22 @@ public:
|
|||||||
NoVersion = 0x0020
|
NoVersion = 0x0020
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit LtsCommandLineParser(ProvideCommandLineParameterOptions opts = ProvideCommandLineParameterOptions(CreateDomainIdFromIp|DomainId|ExerciseId|CustomConfigFile));
|
explicit LtsCommandLineParser(ProvideCommandLineParameterOptions opts = ProvideCommandLineParameterOptions(
|
||||||
|
CreateDomainIdFromIp | DomainId | ExerciseId | CustomConfigFile));
|
||||||
virtual ~LtsCommandLineParser() = default;
|
virtual ~LtsCommandLineParser() = default;
|
||||||
int domainId() const;
|
int domainId() const;
|
||||||
void setDomainId(int id);
|
void setDomainId(int id);
|
||||||
int exerciseId() const { return m_exerciseId; }
|
|
||||||
QString iniFile() const { return m_iniFile; }
|
int exerciseId() const
|
||||||
|
{
|
||||||
|
return m_exerciseId;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString iniFile() const
|
||||||
|
{
|
||||||
|
return m_iniFile;
|
||||||
|
}
|
||||||
|
|
||||||
bool iniFileSet() const;
|
bool iniFileSet() const;
|
||||||
bool useTcpConnection() const;
|
bool useTcpConnection() const;
|
||||||
QUrl tcpConnectionUrl() const;
|
QUrl tcpConnectionUrl() const;
|
||||||
@@ -38,7 +48,10 @@ public:
|
|||||||
bool domainIdProvided() const;
|
bool domainIdProvided() const;
|
||||||
bool exerciseIdProvided() const;
|
bool exerciseIdProvided() const;
|
||||||
|
|
||||||
void setUnitModuleTestMode(bool onOff) { m_unitModuleTestMode = onOff; }
|
void setUnitModuleTestMode(bool onOff)
|
||||||
|
{
|
||||||
|
m_unitModuleTestMode = onOff;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QString m_additionalHelpStr;
|
QString m_additionalHelpStr;
|
||||||
@@ -53,4 +66,4 @@ private:
|
|||||||
QString m_iniFile;
|
QString m_iniFile;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace LtsCommandLineParser
|
||||||
Executable → Regular
+3
-6
@@ -1,8 +1,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include <GeographicLib/UTMUPS.hpp>
|
|
||||||
#include <GeographicLib/MGRS.hpp>
|
#include <GeographicLib/MGRS.hpp>
|
||||||
|
#include <GeographicLib/UTMUPS.hpp>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
@@ -59,9 +58,7 @@ 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",
|
fprintf(stdout, "%13.10f, %13.10f = %s %s %s %s (UTM: %d %.2f, %.2f %c)\n", lon, lat, part1.c_str(), part2.c_str(),
|
||||||
lon, lat,
|
part3.c_str(), part4.c_str(), zone, x, y, northp ? 'N' : 'S');
|
||||||
part1.c_str(), part2.c_str(), part3.c_str(), part4.c_str(),
|
|
||||||
zone, x, y, northp ? 'N' : 'S');
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
Executable → Regular
+56
-55
@@ -1,19 +1,16 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "lts_coord_trans.h"
|
#include "lts_coord_trans.h"
|
||||||
#include <utility>
|
|
||||||
|
|
||||||
#include <GeographicLib/Geocentric.hpp>
|
#include <GeographicLib/Geocentric.hpp>
|
||||||
#include <GeographicLib/UTMUPS.hpp>
|
|
||||||
#include <GeographicLib/MGRS.hpp>
|
#include <GeographicLib/MGRS.hpp>
|
||||||
|
#include <GeographicLib/UTMUPS.hpp>
|
||||||
#include <QPointF>
|
#include <QPointF>
|
||||||
#include <QRectF>
|
#include <QRectF>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
|
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
namespace LtsCoordTrans
|
namespace LtsCoordTrans
|
||||||
{
|
{
|
||||||
@@ -27,7 +24,6 @@ static long s_conversion_counter_WGS84_Reverse = 0;
|
|||||||
static long s_conversion_counter_UTMUPS_Forward = 0;
|
static long s_conversion_counter_UTMUPS_Forward = 0;
|
||||||
static long s_conversion_counter_UTMUPS_Reverse = 0;
|
static long s_conversion_counter_UTMUPS_Reverse = 0;
|
||||||
|
|
||||||
|
|
||||||
inline void incrementCounter(long& counterRef)
|
inline void incrementCounter(long& counterRef)
|
||||||
{
|
{
|
||||||
#ifdef LTS_DEBUG
|
#ifdef LTS_DEBUG
|
||||||
@@ -35,7 +31,6 @@ inline void incrementCounter(long &counterRef)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static inline std::string cleanupMgrsString(const QString& in)
|
static inline std::string cleanupMgrsString(const QString& in)
|
||||||
{
|
{
|
||||||
const QByteArray ba(in.toLatin1());
|
const QByteArray ba(in.toLatin1());
|
||||||
@@ -74,12 +69,11 @@ QString UtmCoordinate::mgrs(int prec, bool withSpaces) const
|
|||||||
|
|
||||||
const char* ptr = mgrs.c_str();
|
const char* ptr = mgrs.c_str();
|
||||||
|
|
||||||
ret = QString::fromLatin1(ptr, 3) + QLatin1Char(' ') +
|
ret = QString::fromLatin1(ptr, 3) + QLatin1Char(' ') + QString::fromLatin1(ptr + 3, 2);
|
||||||
QString::fromLatin1(ptr + 3, 2);
|
|
||||||
if (prec > 0)
|
if (prec > 0)
|
||||||
{
|
{
|
||||||
ret += QLatin1Char(' ') + QString::fromLatin1(ptr + 5, prec) +
|
ret += QLatin1Char(' ') + QString::fromLatin1(ptr + 5, prec) + QLatin1Char(' ') +
|
||||||
QLatin1Char(' ') + QString::fromLatin1(ptr + 5 + prec, prec);
|
QString::fromLatin1(ptr + 5 + prec, prec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -102,7 +96,8 @@ 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, y + offsetY, e.what());
|
fprintf(stderr, "Error while calculating geographic from utm %d, %9.6f, %9.6f: %s\n", zone, x + offsetX,
|
||||||
|
y + offsetY, e.what());
|
||||||
ret = QPointF();
|
ret = QPointF();
|
||||||
}
|
}
|
||||||
return ret * deg2rad();
|
return ret * deg2rad();
|
||||||
@@ -157,7 +152,6 @@ UtmCoordinate UtmCoordinate::fromMgrs(const QString &mgrs)
|
|||||||
|
|
||||||
GeographicLib::MGRS::Reverse(cleanupMgrsString(mgrs), utm.zone, utm.northp, utm.x, utm.y, prec, true);
|
GeographicLib::MGRS::Reverse(cleanupMgrsString(mgrs), utm.zone, utm.northp, utm.x, utm.y, prec, true);
|
||||||
incrementCounter(s_conversion_counter_MGRS_Reverse);
|
incrementCounter(s_conversion_counter_MGRS_Reverse);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (const std::exception& e)
|
catch (const std::exception& e)
|
||||||
{
|
{
|
||||||
@@ -182,27 +176,24 @@ QVector<UtmCoordinate> &staticDefaultSquaresHelper()
|
|||||||
static QVector<UtmCoordinate> s_defaultMgrsSquares;
|
static QVector<UtmCoordinate> s_defaultMgrsSquares;
|
||||||
return s_defaultMgrsSquares;
|
return s_defaultMgrsSquares;
|
||||||
}
|
}
|
||||||
|
|
||||||
UtmCoordinate& staticPreferedMgrsSquareHelper()
|
UtmCoordinate& staticPreferedMgrsSquareHelper()
|
||||||
{
|
{
|
||||||
static UtmCoordinate s_preferedMgrsSquare;
|
static UtmCoordinate s_preferedMgrsSquare;
|
||||||
return s_preferedMgrsSquare;
|
return s_preferedMgrsSquare;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<UtmCoordinate>& staticMgrsSquaresWithOffsetsHelper()
|
QVector<UtmCoordinate>& staticMgrsSquaresWithOffsetsHelper()
|
||||||
{
|
{
|
||||||
static QVector<UtmCoordinate> s_mgrsSquaresWithOffsets;
|
static QVector<UtmCoordinate> s_mgrsSquaresWithOffsets;
|
||||||
return s_mgrsSquaresWithOffsets;
|
return s_mgrsSquaresWithOffsets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QRectF addMarginToArea(const QRectF& rect_LatLon_radiant, const QSize& marginMeter)
|
QRectF addMarginToArea(const QRectF& rect_LatLon_radiant, const QSize& marginMeter)
|
||||||
{
|
{
|
||||||
double lonMin, lonMax, latMin, latMmax;
|
double lonMin, lonMax, latMin, latMmax;
|
||||||
rect_LatLon_radiant.normalized().getCoords(&lonMin, &latMin, &lonMax, &latMmax);
|
rect_LatLon_radiant.normalized().getCoords(&lonMin, &latMin, &lonMax, &latMmax);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
LtsCoordTrans::UtmCoordinate basePoint;
|
LtsCoordTrans::UtmCoordinate basePoint;
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -210,7 +201,6 @@ QRectF addMarginToArea(const QRectF &rect_LatLon_radiant, const QSize &marginMet
|
|||||||
QString mgrs = LtsCoordTrans::mgrsFromGeographic(centerRad.x(), centerRad.y(), -1);
|
QString mgrs = LtsCoordTrans::mgrsFromGeographic(centerRad.x(), centerRad.y(), -1);
|
||||||
mgrs += QStringLiteral("00000000000000");
|
mgrs += QStringLiteral("00000000000000");
|
||||||
|
|
||||||
|
|
||||||
basePoint = LtsCoordTrans::UtmCoordinate::fromMgrs(mgrs);
|
basePoint = LtsCoordTrans::UtmCoordinate::fromMgrs(mgrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -227,8 +217,8 @@ 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);
|
||||||
|
|
||||||
@@ -241,7 +231,6 @@ QVector<UtmCoordinate> getMgrsSquares(const QRectF &rect, bool setAsDefaultSquar
|
|||||||
if (setAsSquareWithMargin)
|
if (setAsSquareWithMargin)
|
||||||
staticMgrsSquaresWithOffsetsHelper() = ret;
|
staticMgrsSquaresWithOffsetsHelper() = ret;
|
||||||
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -250,11 +239,9 @@ QVector<UtmCoordinate> getMgrsSquaresInternal(const QRectF &rect)
|
|||||||
QVector<UtmCoordinate> ret;
|
QVector<UtmCoordinate> ret;
|
||||||
QVector<QString> tmpMgrsSquares;
|
QVector<QString> tmpMgrsSquares;
|
||||||
|
|
||||||
|
|
||||||
double lonMin, lonMax, latMin, latMmax;
|
double lonMin, lonMax, latMin, latMmax;
|
||||||
rect.normalized().getCoords(&lonMin, &latMin, &lonMax, &latMmax);
|
rect.normalized().getCoords(&lonMin, &latMin, &lonMax, &latMmax);
|
||||||
|
|
||||||
|
|
||||||
bool withInSingleUtmSquare = true;
|
bool withInSingleUtmSquare = true;
|
||||||
{
|
{
|
||||||
const UtmCoordinate upperRight(UtmCoordinate::fromGeographic(lonMax, latMmax));
|
const UtmCoordinate upperRight(UtmCoordinate::fromGeographic(lonMax, latMmax));
|
||||||
@@ -262,10 +249,6 @@ QVector<UtmCoordinate> getMgrsSquaresInternal(const QRectF &rect)
|
|||||||
withInSingleUtmSquare = upperRight.zone == lowerLeft.zone;
|
withInSingleUtmSquare = upperRight.zone == lowerLeft.zone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
LtsCoordTrans::UtmCoordinate basePoint;
|
LtsCoordTrans::UtmCoordinate basePoint;
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -273,7 +256,6 @@ QVector<UtmCoordinate> getMgrsSquaresInternal(const QRectF &rect)
|
|||||||
QString mgrs = LtsCoordTrans::mgrsFromGeographic(centerRad.x(), centerRad.y(), -1);
|
QString mgrs = LtsCoordTrans::mgrsFromGeographic(centerRad.x(), centerRad.y(), -1);
|
||||||
mgrs += QStringLiteral("00000000000000");
|
mgrs += QStringLiteral("00000000000000");
|
||||||
|
|
||||||
|
|
||||||
basePoint = LtsCoordTrans::UtmCoordinate::fromMgrs(mgrs);
|
basePoint = LtsCoordTrans::UtmCoordinate::fromMgrs(mgrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -283,8 +265,6 @@ QVector<UtmCoordinate> getMgrsSquaresInternal(const QRectF &rect)
|
|||||||
const double maxX(upperRight.x - lowerLeft.x);
|
const double maxX(upperRight.x - lowerLeft.x);
|
||||||
const double maxY(upperRight.y - lowerLeft.y);
|
const double maxY(upperRight.y - lowerLeft.y);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const int increment = withInSingleUtmSquare ? 10000 : 1000;
|
const int increment = withInSingleUtmSquare ? 10000 : 1000;
|
||||||
for (double x = 0; x <= maxX + increment; x += increment)
|
for (double x = 0; x <= maxX + increment; x += increment)
|
||||||
{
|
{
|
||||||
@@ -315,7 +295,6 @@ QStringList getMgrsSurroundingSquares(const QRectF &geoRect, const QSize &offset
|
|||||||
for (const auto& utm : mainUtms)
|
for (const auto& utm : mainUtms)
|
||||||
mainSquares.append(utm.mgrs(0));
|
mainSquares.append(utm.mgrs(0));
|
||||||
|
|
||||||
|
|
||||||
const QRectF rectWithOffset = addMarginToArea(geoRect, offsetMeter);
|
const QRectF rectWithOffset = addMarginToArea(geoRect, offsetMeter);
|
||||||
|
|
||||||
QVector<UtmCoordinate> mainUtmsWithOffset = getMgrsSquaresInternal(rectWithOffset);
|
QVector<UtmCoordinate> mainUtmsWithOffset = getMgrsSquaresInternal(rectWithOffset);
|
||||||
@@ -324,7 +303,6 @@ QStringList getMgrsSurroundingSquares(const QRectF &geoRect, const QSize &offset
|
|||||||
for (const auto& utm : std::as_const(mainUtmsWithOffset))
|
for (const auto& utm : std::as_const(mainUtmsWithOffset))
|
||||||
mainSquaresWithOffset.append(utm.mgrs(0));
|
mainSquaresWithOffset.append(utm.mgrs(0));
|
||||||
|
|
||||||
|
|
||||||
QStringList surroundingSquares;
|
QStringList surroundingSquares;
|
||||||
surroundingSquares.reserve(mainSquaresWithOffset.count());
|
surroundingSquares.reserve(mainSquaresWithOffset.count());
|
||||||
for (const auto& mgrs0 : mainSquaresWithOffset)
|
for (const auto& mgrs0 : mainSquaresWithOffset)
|
||||||
@@ -341,7 +319,6 @@ QVector<UtmCoordinate> defaultMgrsSquareWithOffsets()
|
|||||||
return staticMgrsSquaresWithOffsetsHelper();
|
return staticMgrsSquaresWithOffsetsHelper();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void setDefaultMgrsSquares(const QVector<QString>& squares)
|
void setDefaultMgrsSquares(const QVector<QString>& squares)
|
||||||
{
|
{
|
||||||
QVector<UtmCoordinate> coords;
|
QVector<UtmCoordinate> coords;
|
||||||
@@ -361,7 +338,6 @@ UtmCoordinate preferedMgrsSquare()
|
|||||||
return staticPreferedMgrsSquareHelper();
|
return staticPreferedMgrsSquareHelper();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool lonLatAltToGeocentric(double lon, double lat, double altitude, double& xOut, double& yOut, double& zOut)
|
bool lonLatAltToGeocentric(double lon, double lat, double altitude, double& xOut, double& yOut, double& zOut)
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -383,11 +359,9 @@ bool lonLatAltToGeocentric(double lon, double lat, double altitude, double &xOut
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool geocentric2LonLatAlt(double x, double y, double z,
|
bool geocentric2LonLatAlt(double x, double y, double z, double& lon, double& lat, double& altitude)
|
||||||
double &lon, double &lat, double &altitude)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
GeographicLib::Geocentric::WGS84().Reverse(x, y, z, lat, lon, altitude);
|
GeographicLib::Geocentric::WGS84().Reverse(x, y, z, lat, lon, altitude);
|
||||||
@@ -416,31 +390,58 @@ double squareDistance(const QPointF &p1, const QPointF &p2)
|
|||||||
return squareDistance(p1.x(), p1.y(), p2.x(), p2.y());
|
return squareDistance(p1.x(), p1.y(), p2.x(), p2.y());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostream &operator<< (std::ostream &stream,
|
std::ostream& operator<<(std::ostream& stream, const UtmCoordinate& coord)
|
||||||
const UtmCoordinate &coord)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
stream << "UtmCoordinate(" << std::setprecision(8) << coord.x
|
stream << "UtmCoordinate(" << std::setprecision(8) << coord.x << "#" << std::setprecision(8) << coord.y
|
||||||
<< "#" << 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" , s_conversion_counter_MGRS_Forward);
|
fprintf(stderr, "LtsCoordTrans: s_conversion_counter_MGRS_Forward : - mgrs : %ld\n",
|
||||||
fprintf(stderr, "LtsCoordTrans: s_conversion_counter_MGRS_Reverse - fromMgrs : %ld\n" , s_conversion_counter_MGRS_Reverse);
|
s_conversion_counter_MGRS_Forward);
|
||||||
fprintf(stderr, "LtsCoordTrans: s_conversion_counter_WGS84_Forward - lonLatAltToGeocentric : %ld\n" , s_conversion_counter_WGS84_Forward);
|
fprintf(stderr, "LtsCoordTrans: s_conversion_counter_MGRS_Reverse - fromMgrs : %ld\n",
|
||||||
fprintf(stderr, "LtsCoordTrans: s_conversion_counter_WGS84_Reverse - geocentric2LonLatAlt : %ld\n" , s_conversion_counter_WGS84_Reverse);
|
s_conversion_counter_MGRS_Reverse);
|
||||||
fprintf(stderr, "LtsCoordTrans: s_conversion_counter_UTMUPS_Forward - fromGeographic : %ld\n" , s_conversion_counter_UTMUPS_Forward);
|
fprintf(stderr, "LtsCoordTrans: s_conversion_counter_WGS84_Forward - lonLatAltToGeocentric : %ld\n",
|
||||||
fprintf(stderr, "LtsCoordTrans: s_conversion_counter_UTMUPS_Reverse - geographic : %ld\n" , s_conversion_counter_UTMUPS_Reverse);
|
s_conversion_counter_WGS84_Forward);
|
||||||
|
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() { return s_conversion_counter_MGRS_Forward; }
|
long getConversionCounter_MGRS_Forward()
|
||||||
long getConversionCounter_MGRS_Reverse() { return s_conversion_counter_MGRS_Reverse; }
|
{
|
||||||
long getConversionCounter_WGS84_Forward() { return s_conversion_counter_WGS84_Forward; }
|
return s_conversion_counter_MGRS_Forward;
|
||||||
long getConversionCounter_WGS84_Reverse() { return s_conversion_counter_WGS84_Reverse; }
|
|
||||||
long getConversionCounter_UTMUPS_Forward() { return s_conversion_counter_UTMUPS_Forward; }
|
|
||||||
long getConversionCounter_UTMUPS_Reverse() { return s_conversion_counter_UTMUPS_Reverse; }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
long getConversionCounter_MGRS_Reverse()
|
||||||
|
{
|
||||||
|
return s_conversion_counter_MGRS_Reverse;
|
||||||
|
}
|
||||||
|
|
||||||
|
long getConversionCounter_WGS84_Forward()
|
||||||
|
{
|
||||||
|
return s_conversion_counter_WGS84_Forward;
|
||||||
|
}
|
||||||
|
|
||||||
|
long getConversionCounter_WGS84_Reverse()
|
||||||
|
{
|
||||||
|
return s_conversion_counter_WGS84_Reverse;
|
||||||
|
}
|
||||||
|
|
||||||
|
long getConversionCounter_UTMUPS_Forward()
|
||||||
|
{
|
||||||
|
return s_conversion_counter_UTMUPS_Forward;
|
||||||
|
}
|
||||||
|
|
||||||
|
long getConversionCounter_UTMUPS_Reverse()
|
||||||
|
{
|
||||||
|
return s_conversion_counter_UTMUPS_Reverse;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace LtsCoordTrans
|
||||||
Executable → Regular
+34
-94
@@ -1,13 +1,11 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <ltscoordtrans_export.h>
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <cmath>
|
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
|
#include <cmath>
|
||||||
|
#include <ltscoordtrans_export.h>
|
||||||
|
#include <string>
|
||||||
class QPointF;
|
class QPointF;
|
||||||
class QRectF;
|
class QRectF;
|
||||||
class QSize;
|
class QSize;
|
||||||
@@ -16,12 +14,20 @@ class QString;
|
|||||||
namespace LtsCoordTrans
|
namespace LtsCoordTrans
|
||||||
{
|
{
|
||||||
|
|
||||||
|
inline Q_CONSTEXPR double pi()
|
||||||
|
{
|
||||||
|
return M_PI;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Q_CONSTEXPR double deg2rad()
|
||||||
|
{
|
||||||
|
return pi() / 180.;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Q_CONSTEXPR double rad2deg()
|
||||||
inline Q_CONSTEXPR double pi() { return M_PI; }
|
{
|
||||||
inline Q_CONSTEXPR double deg2rad() { return pi() / 180.; }
|
return 1. / deg2rad();
|
||||||
inline Q_CONSTEXPR double rad2deg() { return 1. / deg2rad(); }
|
}
|
||||||
|
|
||||||
struct LTSCOORDTRANS_EXPORT UtmCoordinate
|
struct LTSCOORDTRANS_EXPORT UtmCoordinate
|
||||||
{
|
{
|
||||||
@@ -31,99 +37,58 @@ struct LTSCOORDTRANS_EXPORT UtmCoordinate
|
|||||||
double y = 0.;
|
double y = 0.;
|
||||||
|
|
||||||
UtmCoordinate() = default;
|
UtmCoordinate() = default;
|
||||||
UtmCoordinate(int zone_, double x_, double y_, bool northp_ = true)
|
|
||||||
: zone(zone_)
|
|
||||||
, northp(northp_)
|
|
||||||
, x(x_)
|
|
||||||
, y(y_)
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool isValid() const { return zone > 0 && zone <= 60; }
|
|
||||||
|
|
||||||
|
UtmCoordinate(int zone_, double x_, double y_, bool northp_ = true) : zone(zone_), northp(northp_), x(x_), y(y_) {}
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
QPointF geographic(double offsetX = 0., double offsetY = 0.) const;
|
QPointF geographic(double offsetX = 0., double offsetY = 0.) const;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
QPointF geographic(const QPointF& offset) const;
|
QPointF geographic(const QPointF& offset) const;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
QPointF relativeTo(const UtmCoordinate& other) const;
|
QPointF relativeTo(const UtmCoordinate& other) const;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static UtmCoordinate fromGeographic(double lon, double lat, int setZone = -1);
|
static UtmCoordinate fromGeographic(double lon, double lat, int setZone = -1);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static UtmCoordinate fromGeographic(const QPointF& lonLat, int setZone = -1);
|
static UtmCoordinate fromGeographic(const QPointF& lonLat, int setZone = -1);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static UtmCoordinate fromMgrs(const QString& mgrs);
|
static UtmCoordinate fromMgrs(const QString& mgrs);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
LTSCOORDTRANS_EXPORT QString mgrsFromGeographic(double lon, double lat, int prec = 5, bool withSpaces = true);
|
LTSCOORDTRANS_EXPORT QString mgrsFromGeographic(double lon, double lat, int prec = 5, bool withSpaces = true);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
LTSCOORDTRANS_EXPORT QPointF geographicFromMgrs(const QString& mgrs);
|
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,
|
||||||
|
bool setAsPreferedSquare,
|
||||||
LTSCOORDTRANS_EXPORT QVector<UtmCoordinate> getMgrsSquares(const QRectF &rect, bool setAsDefaultSquares, bool setAsPreferedSquare, bool setAsSquareWithMargin = false);
|
bool setAsSquareWithMargin = false);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
QVector<UtmCoordinate> getMgrsSquaresInternal(const QRectF& rect);
|
QVector<UtmCoordinate> getMgrsSquaresInternal(const QRectF& rect);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
QStringList getMgrsSurroundingSquares(const QRectF& geoRect, const QSize& offsetMeter);
|
QStringList getMgrsSurroundingSquares(const QRectF& geoRect, const QSize& offsetMeter);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
LTSCOORDTRANS_EXPORT QVector<UtmCoordinate> defaultMgrsSquareWithOffsets();
|
LTSCOORDTRANS_EXPORT QVector<UtmCoordinate> defaultMgrsSquareWithOffsets();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
LTSCOORDTRANS_EXPORT void setDefaultMgrsSquares(const QVector<QString>& squares);
|
LTSCOORDTRANS_EXPORT void setDefaultMgrsSquares(const QVector<QString>& squares);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
LTSCOORDTRANS_EXPORT QVector<UtmCoordinate> defaultMgrsSquares();
|
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,
|
||||||
|
double& zOut);
|
||||||
|
|
||||||
|
LTSCOORDTRANS_EXPORT bool geocentric2LonLatAlt(double x, double y, double z, double& lon, double& lat,
|
||||||
LTSCOORDTRANS_EXPORT bool lonLatAltToGeocentric(double lon, double lat, double altitude, double &xOut, double &yOut, double &zOut);
|
double& altitude);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
LTSCOORDTRANS_EXPORT bool geocentric2LonLatAlt(double x, double y, double z,
|
|
||||||
double &lon, double &lat, double &altitude);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
inline double squareDistance(const UtmCoordinate& p1, const UtmCoordinate& p2)
|
inline double squareDistance(const UtmCoordinate& p1, const UtmCoordinate& p2)
|
||||||
{
|
{
|
||||||
@@ -135,12 +100,8 @@ inline double squareDistance(const UtmCoordinate &p1, const UtmCoordinate &p2)
|
|||||||
return std::pow(p1.x - p2.x, 2) + std::pow(p1.y - p2.y, 2);
|
return std::pow(p1.x - p2.x, 2) + std::pow(p1.y - p2.y, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
LTSCOORDTRANS_EXPORT double squareDistance(const QPointF& p1, const QPointF& p2);
|
LTSCOORDTRANS_EXPORT double squareDistance(const QPointF& p1, const QPointF& p2);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
inline double squareDistance(const double lon1, const double lat1, const double lon2, const double lat2)
|
inline double squareDistance(const double lon1, const double lat1, const double lon2, const double lat2)
|
||||||
{
|
{
|
||||||
const auto p1(UtmCoordinate::fromGeographic(lon1, lat1));
|
const auto p1(UtmCoordinate::fromGeographic(lon1, lat1));
|
||||||
@@ -148,16 +109,12 @@ inline double squareDistance(const double lon1, const double lat1, const double
|
|||||||
return squareDistance(p1, p2);
|
return squareDistance(p1, p2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
inline double squareDistance(const UtmCoordinate& p1, const double lon2, const double lat2)
|
inline double squareDistance(const UtmCoordinate& p1, const double lon2, const double lat2)
|
||||||
{
|
{
|
||||||
const auto p2(UtmCoordinate::fromGeographic(lon2, lat2, p1.zone));
|
const auto p2(UtmCoordinate::fromGeographic(lon2, lat2, p1.zone));
|
||||||
return squareDistance(p1, p2);
|
return squareDistance(p1, p2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
inline double distance(const UtmCoordinate& p1, const UtmCoordinate& p2)
|
inline double distance(const UtmCoordinate& p1, const UtmCoordinate& p2)
|
||||||
{
|
{
|
||||||
if (p1.zone != p2.zone)
|
if (p1.zone != p2.zone)
|
||||||
@@ -168,12 +125,8 @@ inline double distance(const UtmCoordinate &p1, const UtmCoordinate &p2)
|
|||||||
return sqrt(squareDistance(p1, p2));
|
return sqrt(squareDistance(p1, p2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
LTSCOORDTRANS_EXPORT double distance(const QPointF& p1, const QPointF& p2);
|
LTSCOORDTRANS_EXPORT double distance(const QPointF& p1, const QPointF& p2);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
inline double distance(const double lon1, const double lat1, const double lon2, const double lat2)
|
inline double distance(const double lon1, const double lat1, const double lon2, const double lat2)
|
||||||
{
|
{
|
||||||
return sqrt(squareDistance(lon1, lat1, lon2, lat2));
|
return sqrt(squareDistance(lon1, lat1, lon2, lat2));
|
||||||
@@ -184,7 +137,6 @@ inline double distance(const UtmCoordinate &p1, const double lon2, const double
|
|||||||
return sqrt(squareDistance(p1, lon2, lat2));
|
return sqrt(squareDistance(p1, lon2, lat2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LTSCOORDTRANS_EXPORT void dumpConversionCounter();
|
LTSCOORDTRANS_EXPORT void dumpConversionCounter();
|
||||||
|
|
||||||
LTSCOORDTRANS_EXPORT long getConversionCounter_MGRS_Forward();
|
LTSCOORDTRANS_EXPORT long getConversionCounter_MGRS_Forward();
|
||||||
@@ -194,15 +146,7 @@ LTSCOORDTRANS_EXPORT long getConversionCounter_WGS84_Reverse();
|
|||||||
LTSCOORDTRANS_EXPORT long getConversionCounter_UTMUPS_Forward();
|
LTSCOORDTRANS_EXPORT long getConversionCounter_UTMUPS_Forward();
|
||||||
LTSCOORDTRANS_EXPORT long getConversionCounter_UTMUPS_Reverse();
|
LTSCOORDTRANS_EXPORT long getConversionCounter_UTMUPS_Reverse();
|
||||||
|
|
||||||
|
LTSCOORDTRANS_EXPORT std::ostream& operator<<(std::ostream& stream, const UtmCoordinate& coord);
|
||||||
LTSCOORDTRANS_EXPORT std::ostream &operator<< (std::ostream &stream,
|
|
||||||
const UtmCoordinate &coord);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class LTSCOORDTRANS_EXPORT UtmCoordinate3D : public LtsCoordTrans::UtmCoordinate
|
class LTSCOORDTRANS_EXPORT UtmCoordinate3D : public LtsCoordTrans::UtmCoordinate
|
||||||
{
|
{
|
||||||
@@ -214,8 +158,7 @@ public:
|
|||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
explicit UtmCoordinate3D(const LtsCoordTrans::UtmCoordinate &utm2d, double _zValue = std::nan(""))
|
explicit UtmCoordinate3D(const LtsCoordTrans::UtmCoordinate& utm2d, double _zValue = std::nan("")) : BaseClass()
|
||||||
:BaseClass()
|
|
||||||
{
|
{
|
||||||
zone = utm2d.zone;
|
zone = utm2d.zone;
|
||||||
northp = utm2d.northp;
|
northp = utm2d.northp;
|
||||||
@@ -229,21 +172,18 @@ public:
|
|||||||
zone = -1;
|
zone = -1;
|
||||||
northp = true;
|
northp = true;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
x = 0.;
|
x = 0.;
|
||||||
y = 0.;
|
y = 0.;
|
||||||
zValue = std::nan("");
|
zValue = std::nan("");
|
||||||
}
|
}
|
||||||
|
|
||||||
double z() const { return zValue; }
|
double z() const
|
||||||
|
{
|
||||||
|
return zValue;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
double zValue{std::nan("")};
|
double zValue{std::nan("")};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace LtsCoordTrans
|
||||||
}
|
|
||||||
Executable → Regular
+81
-151
@@ -1,12 +1,13 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "lts_coord_trans_unit_test.h"
|
#include "lts_coord_trans_unit_test.h"
|
||||||
#include <utility>
|
|
||||||
#include "lts_coord_trans.h"
|
#include "lts_coord_trans.h"
|
||||||
|
|
||||||
#include <GeographicLib/Math.hpp>
|
#include <GeographicLib/Math.hpp>
|
||||||
#include <QTest>
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QTest>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
QTEST_MAIN(coordtrans_test)
|
QTEST_MAIN(coordtrans_test)
|
||||||
|
|
||||||
@@ -15,14 +16,11 @@ void coordtrans_test::initTestCase()
|
|||||||
qDebug("sizeof(UtmCoordinate) = %lu", sizeof(LtsCoordTrans::UtmCoordinate));
|
qDebug("sizeof(UtmCoordinate) = %lu", sizeof(LtsCoordTrans::UtmCoordinate));
|
||||||
}
|
}
|
||||||
|
|
||||||
void coordtrans_test::cleanupTestCase()
|
void coordtrans_test::cleanupTestCase() {}
|
||||||
{}
|
|
||||||
|
|
||||||
void coordtrans_test::testFromGeographic()
|
void coordtrans_test::testFromGeographic()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
LtsCoordTrans::UtmCoordinate utm;
|
LtsCoordTrans::UtmCoordinate utm;
|
||||||
QPointF lonlat;
|
QPointF lonlat;
|
||||||
|
|
||||||
@@ -44,8 +42,6 @@ void coordtrans_test::testFromGeographic()
|
|||||||
utm = LtsCoordTrans::UtmCoordinate::fromGeographic(lonlat.x(), lonlat.y());
|
utm = LtsCoordTrans::UtmCoordinate::fromGeographic(lonlat.x(), lonlat.y());
|
||||||
QCOMPARE(utm.mgrs(5), QStringLiteral("40R BM 85000 85000"));
|
QCOMPARE(utm.mgrs(5), QStringLiteral("40R BM 85000 85000"));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
utm = LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("40R BM 00000 00000"));
|
utm = LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("40R BM 00000 00000"));
|
||||||
QCOMPARE(utm.mgrs(0), QStringLiteral("40Q BM"));
|
QCOMPARE(utm.mgrs(0), QStringLiteral("40Q BM"));
|
||||||
}
|
}
|
||||||
@@ -70,10 +66,8 @@ void coordtrans_test::testRelativeMetricalOffet_data()
|
|||||||
QTest::addColumn<QPoint>("offset");
|
QTest::addColumn<QPoint>("offset");
|
||||||
QTest::addColumn<QString>("correctMgrs");
|
QTest::addColumn<QString>("correctMgrs");
|
||||||
|
|
||||||
|
|
||||||
QTest::newRow("set 1") << QPoint(5, 5) << QStringLiteral("32U PD 99995 99995");
|
QTest::newRow("set 1") << QPoint(5, 5) << QStringLiteral("32U PD 99995 99995");
|
||||||
|
|
||||||
|
|
||||||
QTest::newRow("set 2") << QPoint(100, 100) << QStringLiteral("32U QE 00090 00090");
|
QTest::newRow("set 2") << QPoint(100, 100) << QStringLiteral("32U QE 00090 00090");
|
||||||
QTest::newRow("set 3") << QPoint(500, 500) << QStringLiteral("32U QE 00490 00490");
|
QTest::newRow("set 3") << QPoint(500, 500) << QStringLiteral("32U QE 00490 00490");
|
||||||
}
|
}
|
||||||
@@ -83,7 +77,8 @@ void coordtrans_test::testRelativeMetricalOffet()
|
|||||||
QFETCH(QPoint, offset);
|
QFETCH(QPoint, offset);
|
||||||
QFETCH(QString, correctMgrs);
|
QFETCH(QString, correctMgrs);
|
||||||
|
|
||||||
const LtsCoordTrans::UtmCoordinate &utmRef = LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 99990 99990"));
|
const LtsCoordTrans::UtmCoordinate& utmRef =
|
||||||
|
LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 99990 99990"));
|
||||||
qDebug() << "utmRef = " << utmRef.mgrs();
|
qDebug() << "utmRef = " << utmRef.mgrs();
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -96,36 +91,27 @@ void coordtrans_test::testRelativeMetricalOffet()
|
|||||||
QCOMPARE(utmRaw.mgrs(), correctMgrs);
|
QCOMPARE(utmRaw.mgrs(), correctMgrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
const LtsCoordTrans::UtmCoordinate utmSimple(utmRef.zone,
|
const LtsCoordTrans::UtmCoordinate utmSimple(utmRef.zone, utmRef.x + offset.x(), utmRef.y + offset.y());
|
||||||
utmRef.x + offset.x(),
|
|
||||||
utmRef.y + offset.y());
|
|
||||||
|
|
||||||
qDebug() << "offset = " << offset << " - utmSimple = " << utmSimple.mgrs();
|
qDebug() << "offset = " << offset << " - utmSimple = " << utmSimple.mgrs();
|
||||||
QCOMPARE(utmSimple.mgrs(), correctMgrs);
|
QCOMPARE(utmSimple.mgrs(), correctMgrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF createArea(const QString &base,
|
QRectF createArea(const QString& base, int xCenter, int yCenter, int width, int height)
|
||||||
int xCenter, int yCenter, int width, 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::fromGeographic(LtsCoordTrans::geographicFromMgrs(base)));
|
LtsCoordTrans::UtmCoordinate utmBase(
|
||||||
|
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()));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
QRectF rect(topLeft, bottomRight);
|
QRectF rect(topLeft, bottomRight);
|
||||||
return rect;
|
return rect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void coordtrans_test::testAddMarginToArea()
|
void coordtrans_test::testAddMarginToArea()
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -134,11 +120,15 @@ 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() << " - degree:" << area.topLeft()*LtsCoordTrans::rad2deg();
|
qDebug() << "topLeft : " << qSetRealNumberPrecision(15) << area.topLeft()
|
||||||
qDebug() << "topLeftInc : " << qSetRealNumberPrecision(15) << area1Increased.topLeft() << " - degree:" << area1Increased.topLeft()*LtsCoordTrans::rad2deg();
|
<< " - degree:" << area.topLeft() * LtsCoordTrans::rad2deg();
|
||||||
|
qDebug() << "topLeftInc : " << qSetRealNumberPrecision(15) << area1Increased.topLeft()
|
||||||
|
<< " - degree:" << area1Increased.topLeft() * LtsCoordTrans::rad2deg();
|
||||||
|
|
||||||
qDebug() << "bottomRight : " << qSetRealNumberPrecision(15) << area.bottomRight() << " - degree:" << area.bottomRight()*LtsCoordTrans::rad2deg();
|
qDebug() << "bottomRight : " << qSetRealNumberPrecision(15) << area.bottomRight()
|
||||||
qDebug() << "bottomRightInc : " << qSetRealNumberPrecision(15) << area1Increased.bottomRight() << " - degree:" << area1Increased.bottomRight()*LtsCoordTrans::rad2deg();
|
<< " - degree:" << area.bottomRight() * LtsCoordTrans::rad2deg();
|
||||||
|
qDebug() << "bottomRightInc : " << qSetRealNumberPrecision(15) << area1Increased.bottomRight()
|
||||||
|
<< " - degree:" << area1Increased.bottomRight() * LtsCoordTrans::rad2deg();
|
||||||
|
|
||||||
QVERIFY2(area1Increased.topLeft().x() < area.topLeft().x(), "addMarginToArea topLeft X failed");
|
QVERIFY2(area1Increased.topLeft().x() < area.topLeft().x(), "addMarginToArea topLeft X failed");
|
||||||
QVERIFY2(area1Increased.topLeft().y() < area.topLeft().y(), "addMarginToArea topLeft Y failed");
|
QVERIFY2(area1Increased.topLeft().y() < area.topLeft().y(), "addMarginToArea topLeft Y failed");
|
||||||
@@ -147,17 +137,20 @@ void coordtrans_test::testAddMarginToArea()
|
|||||||
QVERIFY2(area1Increased.bottomRight().y() > area.bottomRight().y(), "addMarginToArea bottomRight Y failed");
|
QVERIFY2(area1Increased.bottomRight().y() > area.bottomRight().y(), "addMarginToArea bottomRight Y failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
qDebug() << "Luxemburg";
|
qDebug() << "Luxemburg";
|
||||||
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() << " - degree:" << area.topLeft()*LtsCoordTrans::rad2deg();
|
qDebug() << "topLeft : " << qSetRealNumberPrecision(15) << area.topLeft()
|
||||||
qDebug() << "topLeftInc : " << qSetRealNumberPrecision(15) << area1Increased.topLeft() << " - degree:" << area1Increased.topLeft()*LtsCoordTrans::rad2deg();
|
<< " - degree:" << area.topLeft() * LtsCoordTrans::rad2deg();
|
||||||
|
qDebug() << "topLeftInc : " << qSetRealNumberPrecision(15) << area1Increased.topLeft()
|
||||||
|
<< " - degree:" << area1Increased.topLeft() * LtsCoordTrans::rad2deg();
|
||||||
|
|
||||||
qDebug() << "bottomRight : " << qSetRealNumberPrecision(15) << area.bottomRight() << " - degree:" << area.bottomRight()*LtsCoordTrans::rad2deg();
|
qDebug() << "bottomRight : " << qSetRealNumberPrecision(15) << area.bottomRight()
|
||||||
qDebug() << "bottomRightInc : " << qSetRealNumberPrecision(15) << area1Increased.bottomRight() << " - degree:" << area1Increased.bottomRight()*LtsCoordTrans::rad2deg();
|
<< " - degree:" << area.bottomRight() * LtsCoordTrans::rad2deg();
|
||||||
|
qDebug() << "bottomRightInc : " << qSetRealNumberPrecision(15) << area1Increased.bottomRight()
|
||||||
|
<< " - degree:" << area1Increased.bottomRight() * LtsCoordTrans::rad2deg();
|
||||||
|
|
||||||
QVERIFY2(area1Increased.topLeft().x() < area.topLeft().x(), "addMarginToArea topLeft X failed");
|
QVERIFY2(area1Increased.topLeft().x() < area.topLeft().x(), "addMarginToArea topLeft X failed");
|
||||||
QVERIFY2(area1Increased.topLeft().y() < area.topLeft().y(), "addMarginToArea topLeft Y failed");
|
QVERIFY2(area1Increased.topLeft().y() < area.topLeft().y(), "addMarginToArea topLeft Y failed");
|
||||||
@@ -174,23 +167,24 @@ 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 = LtsCoordTrans::UtmCoordinate::fromGeographic(lonlat.x(), lonlat.y());
|
const LtsCoordTrans::UtmCoordinate centerPoint =
|
||||||
|
LtsCoordTrans::UtmCoordinate::fromGeographic(lonlat.x(), lonlat.y());
|
||||||
|
|
||||||
LtsCoordTrans::UtmCoordinate topLeftUtm;
|
LtsCoordTrans::UtmCoordinate topLeftUtm;
|
||||||
LtsCoordTrans::UtmCoordinate topLeftUtm2;
|
LtsCoordTrans::UtmCoordinate topLeftUtm2;
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
QPointF topLeftGeo = centerPoint.geographic(-1111, 2222);
|
QPointF topLeftGeo = centerPoint.geographic(-1111, 2222);
|
||||||
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 = LtsCoordTrans::UtmCoordinate::fromGeographic(bottomRightGeo);
|
const LtsCoordTrans::UtmCoordinate bottomRightUtm =
|
||||||
|
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) << bottomRightUtm.y;
|
qDebug() << "bottomRightUtm: " << bottomRightUtm.x << " - " << qSetRealNumberPrecision(15)
|
||||||
|
<< bottomRightUtm.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
topLeftUtm2.x = centerPoint.x - 1111;
|
topLeftUtm2.x = centerPoint.x - 1111;
|
||||||
topLeftUtm2.y = centerPoint.y + 2222;
|
topLeftUtm2.y = centerPoint.y + 2222;
|
||||||
@@ -200,7 +194,8 @@ 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) << bottomRightUtm2.y;
|
qDebug() << "bottomRightUtm2: " << bottomRightUtm2.x << " - " << qSetRealNumberPrecision(15)
|
||||||
|
<< bottomRightUtm2.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVERIFY2(qFuzzyCompare(topLeftUtm.x, topLeftUtm2.x), "testIncreaseRect x failed");
|
QVERIFY2(qFuzzyCompare(topLeftUtm.x, topLeftUtm2.x), "testIncreaseRect x failed");
|
||||||
@@ -218,7 +213,8 @@ void coordtrans_test::testIncreaseRect2()
|
|||||||
QRectF myRectIncreased;
|
QRectF myRectIncreased;
|
||||||
|
|
||||||
{
|
{
|
||||||
const LtsCoordTrans::UtmCoordinate centerPoint = LtsCoordTrans::UtmCoordinate::fromGeographic(lonlat.x(), lonlat.y());
|
const LtsCoordTrans::UtmCoordinate centerPoint =
|
||||||
|
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);
|
||||||
@@ -229,7 +225,6 @@ void coordtrans_test::testIncreaseRect2()
|
|||||||
qDebug() << "myRect height : " << myRect.height();
|
qDebug() << "myRect height : " << myRect.height();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
const QPointF centerGeo = myRect.center();
|
const QPointF centerGeo = myRect.center();
|
||||||
const LtsCoordTrans::UtmCoordinate centerUtm = LtsCoordTrans::UtmCoordinate::fromGeographic(centerGeo);
|
const LtsCoordTrans::UtmCoordinate centerUtm = LtsCoordTrans::UtmCoordinate::fromGeographic(centerGeo);
|
||||||
@@ -242,26 +237,22 @@ void coordtrans_test::testIncreaseRect2()
|
|||||||
qDebug() << "myRectIncreased : " << myRectIncreased;
|
qDebug() << "myRectIncreased : " << myRectIncreased;
|
||||||
qDebug() << "myRectIncreased center: " << myRectIncreased.center();
|
qDebug() << "myRectIncreased center: " << myRectIncreased.center();
|
||||||
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");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void coordtrans_test::testGeographicFromMgrs()
|
void coordtrans_test::testGeographicFromMgrs()
|
||||||
{
|
{
|
||||||
|
|
||||||
QString mgrs(QStringLiteral("32UPD7654398765"));
|
QString mgrs(QStringLiteral("32UPD7654398765"));
|
||||||
|
|
||||||
|
|
||||||
QPointF geographic = LtsCoordTrans::geographicFromMgrs(mgrs);
|
QPointF geographic = LtsCoordTrans::geographicFromMgrs(mgrs);
|
||||||
QCOMPARE(geographic, QPointF(11.6436815550, 53.2088411454) * LtsCoordTrans::deg2rad());
|
QCOMPARE(geographic, QPointF(11.6436815550, 53.2088411454) * LtsCoordTrans::deg2rad());
|
||||||
}
|
}
|
||||||
@@ -269,93 +260,53 @@ void coordtrans_test::testGeographicFromMgrs()
|
|||||||
void coordtrans_test::testMgrsSquares()
|
void coordtrans_test::testMgrsSquares()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
checkArea(QStringLiteral("32U PD 0000000000"), 50000, 10000, 30000, 30000,
|
||||||
|
{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"), 89999, 89999, 21000, 21000,
|
||||||
|
{QStringLiteral("32U MD"), QStringLiteral("32U ME"), QStringLiteral("32U ND"), QStringLiteral("32U NE")});
|
||||||
|
|
||||||
|
checkArea(QStringLiteral("39Q XG 0000000000"), 40000, 35000, 60000, 70000,
|
||||||
|
{QStringLiteral("39Q XG"), QStringLiteral("39R XG")});
|
||||||
checkArea(QStringLiteral("32U PD 0000000000"), 50000, 10000, 30000, 30000, { 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"), 89999, 89999, 21000, 21000, { QStringLiteral("32U MD"),
|
|
||||||
QStringLiteral("32U ME"),
|
|
||||||
QStringLiteral("32U ND"),
|
|
||||||
QStringLiteral("32U NE")
|
|
||||||
});
|
|
||||||
|
|
||||||
checkArea(QStringLiteral("39Q XG 0000000000"), 40000, 35000, 60000, 70000, { 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, { QStringLiteral("40R CN"),
|
checkArea(QStringLiteral("40R DN 0000000000"), 500, 95500, 12000, 7000,
|
||||||
QStringLiteral("40R DN")
|
{QStringLiteral("40R CN"), QStringLiteral("40R DN")});
|
||||||
});
|
checkArea(QStringLiteral("40R DN 0000000000"), 500, 96760, 30000, 30000,
|
||||||
checkArea(QStringLiteral("40R DN 0000000000"), 500, 96760, 30000, 30000, { QStringLiteral("40R CN"),
|
{QStringLiteral("40R CN"), QStringLiteral("40R CP"), QStringLiteral("40R DN"), QStringLiteral("40R DP")});
|
||||||
QStringLiteral("40R CP"),
|
checkArea(QStringLiteral("40R BM 0000000000"), 59000, 59500, 46000, 40000,
|
||||||
QStringLiteral("40R DN"),
|
{QStringLiteral("40Q BM"), QStringLiteral("40R BM")});
|
||||||
QStringLiteral("40R DP")
|
|
||||||
});
|
|
||||||
checkArea(QStringLiteral("40R BM 0000000000"), 59000, 59500, 46000, 40000, { 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"),
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
checkArea(QStringLiteral("32U LA 0000000000"), 100, 100, 60000, 60000, { QStringLiteral("31U GQ"),
|
|
||||||
QStringLiteral("31U GR"),
|
|
||||||
QStringLiteral("32U KA"),
|
|
||||||
QStringLiteral("32U KV"),
|
|
||||||
QStringLiteral("32U LA"),
|
QStringLiteral("32U LA"),
|
||||||
QStringLiteral("32U LV")
|
|
||||||
});
|
});
|
||||||
|
|
||||||
checkArea(QStringLiteral("32U LA 0000000000"), 100, 100,150000,150000, { QStringLiteral("31U FQ"),
|
checkArea(QStringLiteral("32U LA 0000000000"), 100, 100, 60000, 60000,
|
||||||
QStringLiteral("31U FR"),
|
{QStringLiteral("31U GQ"), QStringLiteral("31U GR"), QStringLiteral("32U KA"), QStringLiteral("32U KV"),
|
||||||
QStringLiteral("31U GQ"),
|
QStringLiteral("32U LA"), QStringLiteral("32U LV")});
|
||||||
QStringLiteral("31U GR"),
|
|
||||||
QStringLiteral("32U KA"),
|
|
||||||
QStringLiteral("32U KV"),
|
|
||||||
QStringLiteral("32U LA"),
|
|
||||||
QStringLiteral("32U LV")
|
|
||||||
});
|
|
||||||
|
|
||||||
checkArea(QStringLiteral("32U LA 0000000000"), 100, 100,200000,200000, { QStringLiteral("31U FP"),
|
checkArea(QStringLiteral("32U LA 0000000000"), 100, 100, 150000, 150000,
|
||||||
QStringLiteral("31U FQ"),
|
{QStringLiteral("31U FQ"), QStringLiteral("31U FR"), QStringLiteral("31U GQ"), QStringLiteral("31U GR"),
|
||||||
QStringLiteral("31U FR"),
|
QStringLiteral("32U KA"), QStringLiteral("32U KV"), QStringLiteral("32U LA"), QStringLiteral("32U LV")});
|
||||||
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")
|
|
||||||
});
|
|
||||||
|
|
||||||
|
checkArea(QStringLiteral("32U LA 0000000000"), 100, 100, 200000, 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 height)
|
||||||
int xCenter, int yCenter, int width, 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::fromGeographic(LtsCoordTrans::geographicFromMgrs(base)));
|
LtsCoordTrans::UtmCoordinate utmBase(
|
||||||
|
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()));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const auto squares = LtsCoordTrans::getMgrsSquares(QRectF(topLeft, bottomRight), false, false);
|
const auto squares = LtsCoordTrans::getMgrsSquares(QRectF(topLeft, bottomRight), false, false);
|
||||||
|
|
||||||
QStringList src;
|
QStringList src;
|
||||||
@@ -364,49 +315,31 @@ QVector<LtsCoordTrans::UtmCoordinate> checkAreaGetMgrsSquares(const QString &bas
|
|||||||
src += utm.mgrs(0);
|
src += utm.mgrs(0);
|
||||||
src.sort();
|
src.sort();
|
||||||
|
|
||||||
|
|
||||||
return squares;
|
return squares;
|
||||||
}
|
}
|
||||||
|
|
||||||
void coordtrans_test::testMgrsSquaresWithSurrounding()
|
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 = checkAreaGetMgrsSquares(QStringLiteral("32U NC 0000000000"), 50000, 50000, biggerSize, biggerSize);
|
QVector<LtsCoordTrans::UtmCoordinate> squares9 =
|
||||||
|
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 = checkAreaGetMgrsSquares(QStringLiteral("32U NC 0000000000"), 50000, 50000, muchBiggerSize, muchBiggerSize);
|
QVector<LtsCoordTrans::UtmCoordinate> square33 =
|
||||||
|
checkAreaGetMgrsSquares(QStringLiteral("32U NC 0000000000"), 50000, 50000, muchBiggerSize, muchBiggerSize);
|
||||||
|
|
||||||
QVERIFY2(square33.size() == 33, "checkAreaGetMgrsSquares muchBiggerSize failed");
|
QVERIFY2(square33.size() == 33, "checkAreaGetMgrsSquares muchBiggerSize failed");
|
||||||
|
|
||||||
|
|
||||||
QStringList string1;
|
QStringList string1;
|
||||||
string1.reserve(squares1.size());
|
string1.reserve(squares1.size());
|
||||||
for (const LtsCoordTrans::UtmCoordinate& item : std::as_const(squares1))
|
for (const LtsCoordTrans::UtmCoordinate& item : std::as_const(squares1))
|
||||||
@@ -441,16 +374,15 @@ void coordtrans_test::testMgrsSquaresWithSurrounding()
|
|||||||
|
|
||||||
QVERIFY2(surroundingStrings.size() == 32, "checkAreaGetMgrsSquares squaresDiff failed");
|
QVERIFY2(surroundingStrings.size() == 32, "checkAreaGetMgrsSquares squaresDiff failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void coordtrans_test::checkArea(const QString &base,
|
void coordtrans_test::checkArea(const QString& base, int xCenter, int yCenter, int width, int height,
|
||||||
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::fromGeographic(LtsCoordTrans::geographicFromMgrs(base)));
|
LtsCoordTrans::UtmCoordinate utmBase(
|
||||||
|
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();
|
||||||
@@ -466,5 +398,3 @@ void coordtrans_test::checkArea(const QString &base,
|
|||||||
qDebug() << "src: '" << src << "' expected: '" << coords << "'";
|
qDebug() << "src: '" << src << "' expected: '" << coords << "'";
|
||||||
QCOMPARE(src, coords);
|
QCOMPARE(src, coords);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Executable → Regular
+1
-4
@@ -27,8 +27,5 @@ private Q_SLOTS:
|
|||||||
void testMgrsSquaresWithSurrounding();
|
void testMgrsSquaresWithSurrounding();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void checkArea(const QString &base,
|
void checkArea(const QString& base, int xCenter, int yCenter, int width, int height, const QStringList& coords);
|
||||||
int xCenter, int yCenter, int width, int height,
|
|
||||||
const QStringList &coords);
|
|
||||||
|
|
||||||
};
|
};
|
||||||
Executable → Regular
+9
-18
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "lts_coord_widget.h"
|
#include "lts_coord_widget.h"
|
||||||
|
|
||||||
#include "lts_coord_widget_p.h"
|
#include "lts_coord_widget_p.h"
|
||||||
|
|
||||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||||
@@ -10,9 +10,7 @@
|
|||||||
namespace LtsCoordWidget
|
namespace LtsCoordWidget
|
||||||
{
|
{
|
||||||
|
|
||||||
LtsCoordWidget::LtsCoordWidget(DisplayType dt, QWidget *parent)
|
LtsCoordWidget::LtsCoordWidget(DisplayType dt, QWidget* parent) : QWidget(parent), m_displayType(dt)
|
||||||
: QWidget(parent)
|
|
||||||
, m_displayType(dt)
|
|
||||||
{
|
{
|
||||||
setFocusPolicy(Qt::StrongFocus);
|
setFocusPolicy(Qt::StrongFocus);
|
||||||
rebuildUi();
|
rebuildUi();
|
||||||
@@ -46,7 +44,6 @@ QPointF LtsCoordWidget::coordinate() const
|
|||||||
return m_inputWidgetHandler->coordinate();
|
return m_inputWidgetHandler->coordinate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LtsCoordWidget::DisplayType LtsCoordWidget::displayType() const
|
LtsCoordWidget::DisplayType LtsCoordWidget::displayType() const
|
||||||
{
|
{
|
||||||
return m_displayType;
|
return m_displayType;
|
||||||
@@ -114,7 +111,6 @@ void LtsCoordWidget::setMgrsSquares(const QVector<LtsCoordTrans::UtmCoordinate>
|
|||||||
m_inputWidgetHandler->setMgrsSquares(geoCoords);
|
m_inputWidgetHandler->setMgrsSquares(geoCoords);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool LtsCoordWidget::event(QEvent* event)
|
bool LtsCoordWidget::event(QEvent* event)
|
||||||
{
|
{
|
||||||
if (event->type() == QEvent::ToolTip)
|
if (event->type() == QEvent::ToolTip)
|
||||||
@@ -122,13 +118,9 @@ bool LtsCoordWidget::event(QEvent *event)
|
|||||||
return QWidget::event(event);
|
return QWidget::event(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LtsCoordWidget::rebuildUi()
|
void LtsCoordWidget::rebuildUi()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (m_inputWidgetHandler)
|
if (m_inputWidgetHandler)
|
||||||
{
|
{
|
||||||
m_inputWidgetHandler->cleanup();
|
m_inputWidgetHandler->cleanup();
|
||||||
@@ -157,12 +149,12 @@ 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,
|
connect(m_inputWidgetHandler->resetButton(), &QToolButton::clicked, this,
|
||||||
this, &LtsCoordWidget::onResetToDefaultCoordinate);
|
&LtsCoordWidget::onResetToDefaultCoordinate);
|
||||||
connect(m_inputWidgetHandler, &LtsCoordInputWidgetHandler::coordinateChanged,
|
connect(m_inputWidgetHandler, &LtsCoordInputWidgetHandler::coordinateChanged, this,
|
||||||
this, &LtsCoordWidget::coordinateChanged);
|
&LtsCoordWidget::coordinateChanged);
|
||||||
connect(m_inputWidgetHandler, &LtsCoordInputWidgetHandler::invalidCoordinate,
|
connect(m_inputWidgetHandler, &LtsCoordInputWidgetHandler::invalidCoordinate, this,
|
||||||
this, &LtsCoordWidget::invalidCoordinate);
|
&LtsCoordWidget::invalidCoordinate);
|
||||||
if (!m_defaultCoordinate.isNull())
|
if (!m_defaultCoordinate.isNull())
|
||||||
m_inputWidgetHandler->setCoordinate(m_defaultCoordinate);
|
m_inputWidgetHandler->setCoordinate(m_defaultCoordinate);
|
||||||
}
|
}
|
||||||
@@ -183,7 +175,6 @@ void LtsCoordWidget::updateToolTip()
|
|||||||
setToolTip(tt);
|
setToolTip(tt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LtsCoordWidget::onResetToDefaultCoordinate()
|
void LtsCoordWidget::onResetToDefaultCoordinate()
|
||||||
{
|
{
|
||||||
if (!m_inputWidgetHandler)
|
if (!m_inputWidgetHandler)
|
||||||
@@ -193,4 +184,4 @@ void LtsCoordWidget::onResetToDefaultCoordinate()
|
|||||||
m_inputWidgetHandler->setCoordinate(m_defaultCoordinate);
|
m_inputWidgetHandler->setCoordinate(m_defaultCoordinate);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace LtsCoordWidget
|
||||||
Executable → Regular
+12
-37
@@ -1,15 +1,12 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "lts_coord_widget_p.h"
|
#include "lts_coord_widget_p.h"
|
||||||
#include <utility>
|
|
||||||
|
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
namespace LtsCoordWidget
|
namespace LtsCoordWidget
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void LtsCoordInputWidgetHandler::onCoordinateDataChanged()
|
void LtsCoordInputWidgetHandler::onCoordinateDataChanged()
|
||||||
{
|
{
|
||||||
const QPointF coord(coordinate());
|
const QPointF coord(coordinate());
|
||||||
@@ -21,13 +18,8 @@ void LtsCoordInputWidgetHandler::onCoordinateDataChanged()
|
|||||||
emit coordinateChanged(coord);
|
emit coordinateChanged(coord);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
MgrsEdit::MgrsEdit(int precision, QWidget* widget)
|
MgrsEdit::MgrsEdit(int precision, QWidget* widget)
|
||||||
: LtsCoordInputWidgetHandler(widget)
|
: LtsCoordInputWidgetHandler(widget), m_precision(precision), m_ui(new Ui::Mgrs)
|
||||||
, m_precision(precision)
|
|
||||||
, m_ui(new Ui::Mgrs)
|
|
||||||
{
|
{
|
||||||
m_ui->setupUi(widget);
|
m_ui->setupUi(widget);
|
||||||
|
|
||||||
@@ -40,12 +32,10 @@ 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),
|
connect(m_ui->cbxZone, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
|
||||||
this, &MgrsEdit::onCoordinateDataChanged);
|
&MgrsEdit::onCoordinateDataChanged);
|
||||||
connect(m_ui->leEast, &QLineEdit::editingFinished,
|
connect(m_ui->leEast, &QLineEdit::editingFinished, this, &MgrsEdit::onCoordinateDataChanged);
|
||||||
this, &MgrsEdit::onCoordinateDataChanged);
|
connect(m_ui->leNorth, &QLineEdit::editingFinished, this, &MgrsEdit::onCoordinateDataChanged);
|
||||||
connect(m_ui->leNorth, &QLineEdit::editingFinished,
|
|
||||||
this, &MgrsEdit::onCoordinateDataChanged);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MgrsEdit::~MgrsEdit()
|
MgrsEdit::~MgrsEdit()
|
||||||
@@ -86,7 +76,6 @@ void MgrsEdit::setCoordinate(const QPointF &geoCoord)
|
|||||||
m_ui->leEast->setText(QString());
|
m_ui->leEast->setText(QString());
|
||||||
m_ui->leNorth->setText(QString());
|
m_ui->leNorth->setText(QString());
|
||||||
|
|
||||||
|
|
||||||
const QString mgrsSquare = mgrsString.left(3) + QLatin1Char(' ') + mgrsString.mid(3, 2);
|
const QString mgrsSquare = mgrsString.left(3) + QLatin1Char(' ') + mgrsString.mid(3, 2);
|
||||||
QString east = mgrsString.mid(5, m_precision);
|
QString east = mgrsString.mid(5, m_precision);
|
||||||
QString north = mgrsString.mid(5 + m_precision, m_precision);
|
QString north = mgrsString.mid(5 + m_precision, m_precision);
|
||||||
@@ -131,7 +120,6 @@ QToolButton *MgrsEdit::resetButton()
|
|||||||
void MgrsEdit::cleanup()
|
void MgrsEdit::cleanup()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
delete m_ui->horizontalLayout;
|
delete m_ui->horizontalLayout;
|
||||||
delete m_ui->cbxZone;
|
delete m_ui->cbxZone;
|
||||||
delete m_ui->leEast;
|
delete m_ui->leEast;
|
||||||
@@ -174,7 +162,6 @@ static QString preferedMgrsSquare()
|
|||||||
return c.mgrs(0);
|
return c.mgrs(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MgrsEdit::setDefaultMgrsSquares()
|
void MgrsEdit::setDefaultMgrsSquares()
|
||||||
{
|
{
|
||||||
m_ui->cbxZone->addItems(defaultMgrsSquares());
|
m_ui->cbxZone->addItems(defaultMgrsSquares());
|
||||||
@@ -219,12 +206,7 @@ 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);
|
||||||
|
|
||||||
@@ -236,10 +218,8 @@ Wgs84Edit::Wgs84Edit(QWidget *widget)
|
|||||||
v->setNotation(QDoubleValidator::StandardNotation);
|
v->setNotation(QDoubleValidator::StandardNotation);
|
||||||
m_ui->leLat->setValidator(v);
|
m_ui->leLat->setValidator(v);
|
||||||
|
|
||||||
connect(m_ui->leLon, &QLineEdit::editingFinished,
|
connect(m_ui->leLon, &QLineEdit::editingFinished, this, &Wgs84Edit::onCoordinateDataChanged);
|
||||||
this, &Wgs84Edit::onCoordinateDataChanged);
|
connect(m_ui->leLat, &QLineEdit::editingFinished, this, &Wgs84Edit::onCoordinateDataChanged);
|
||||||
connect(m_ui->leLat, &QLineEdit::editingFinished,
|
|
||||||
this, &Wgs84Edit::onCoordinateDataChanged);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Wgs84Edit::~Wgs84Edit()
|
Wgs84Edit::~Wgs84Edit()
|
||||||
@@ -266,7 +246,6 @@ QPointF Wgs84Edit::coordinate() const
|
|||||||
QPointF ret;
|
QPointF ret;
|
||||||
const QLocale l;
|
const QLocale l;
|
||||||
|
|
||||||
|
|
||||||
const QString lonStr = m_ui->leLon->text().remove(l.groupSeparator());
|
const QString lonStr = m_ui->leLon->text().remove(l.groupSeparator());
|
||||||
const QString latStr = m_ui->leLat->text().remove(l.groupSeparator());
|
const QString latStr = m_ui->leLat->text().remove(l.groupSeparator());
|
||||||
if (lonStr.isEmpty() || latStr.isEmpty())
|
if (lonStr.isEmpty() || latStr.isEmpty())
|
||||||
@@ -286,7 +265,6 @@ QToolButton *Wgs84Edit::resetButton()
|
|||||||
void Wgs84Edit::cleanup()
|
void Wgs84Edit::cleanup()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
delete m_ui->horizontalLayout;
|
delete m_ui->horizontalLayout;
|
||||||
delete m_ui->leLon;
|
delete m_ui->leLon;
|
||||||
delete m_ui->leLat;
|
delete m_ui->leLat;
|
||||||
@@ -301,12 +279,10 @@ void Wgs84Edit::clear()
|
|||||||
m_ui->leLat->clear();
|
m_ui->leLat->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
DoubleValidator::DoubleValidator(double bottom, double top, int decimals, QObject* parent)
|
DoubleValidator::DoubleValidator(double bottom, double top, int decimals, QObject* parent)
|
||||||
: QDoubleValidator(bottom, top, decimals, parent)
|
: QDoubleValidator(bottom, top, decimals, parent)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
QValidator::State DoubleValidator::validate(QString& input, int& pos) const
|
QValidator::State DoubleValidator::validate(QString& input, int& pos) const
|
||||||
{
|
{
|
||||||
@@ -322,5 +298,4 @@ QValidator::State DoubleValidator::validate(QString &input, int &pos) const
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace LtsCoordWidget
|
||||||
|
|
||||||
Executable → Regular
+26
-13
@@ -2,24 +2,22 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
#include <QWidget>
|
|
||||||
#include <QComboBox>
|
|
||||||
#include <QVBoxLayout>
|
|
||||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
|
||||||
|
|
||||||
#include "ui_lts_coord_widget_mgrs.h"
|
#include "ui_lts_coord_widget_mgrs.h"
|
||||||
#include "ui_lts_coord_widget_wgs84.h"
|
#include "ui_lts_coord_widget_wgs84.h"
|
||||||
|
|
||||||
|
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||||
|
#include <QComboBox>
|
||||||
|
#include <QObject>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
namespace LtsCoordWidget
|
namespace LtsCoordWidget
|
||||||
{
|
{
|
||||||
class LtsCoordInputWidgetHandler : public QObject
|
class LtsCoordInputWidgetHandler : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit LtsCoordInputWidgetHandler(QObject *parent)
|
explicit LtsCoordInputWidgetHandler(QObject* parent) : 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;
|
||||||
@@ -53,10 +51,12 @@ public:
|
|||||||
void setSquaresEditable(bool bEditable) override;
|
void setSquaresEditable(bool bEditable) override;
|
||||||
void setWithSurroundingSquare(bool bEnabled) override;
|
void setWithSurroundingSquare(bool bEnabled) override;
|
||||||
void setMgrsSquares(const QVector<LtsCoordTrans::UtmCoordinate>& geoCoords) override;
|
void setMgrsSquares(const QVector<LtsCoordTrans::UtmCoordinate>& geoCoords) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setDefaultMgrsSquares();
|
void setDefaultMgrsSquares();
|
||||||
void addMgrsSquare(const QString& newMgrsSquare);
|
void addMgrsSquare(const QString& newMgrsSquare);
|
||||||
QStringList utmCoordsToList(const QVector<LtsCoordTrans::UtmCoordinate>& coords);
|
QStringList utmCoordsToList(const QVector<LtsCoordTrans::UtmCoordinate>& coords);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int m_precision;
|
int m_precision;
|
||||||
bool m_withMgrsSquareOffset = false;
|
bool m_withMgrsSquareOffset = false;
|
||||||
@@ -76,9 +76,22 @@ public:
|
|||||||
QToolButton* resetButton() override;
|
QToolButton* resetButton() override;
|
||||||
void cleanup() override;
|
void cleanup() override;
|
||||||
void clear() override;
|
void clear() override;
|
||||||
void setSquaresEditable(bool bEditable) override { Q_UNUSED(bEditable); }
|
|
||||||
void setWithSurroundingSquare(bool bEnabled) override { Q_UNUSED(bEnabled); }
|
void setSquaresEditable(bool bEditable) override
|
||||||
void setMgrsSquares(const QVector<LtsCoordTrans::UtmCoordinate> &geoCoords) override { Q_UNUSED(geoCoords); }
|
{
|
||||||
|
Q_UNUSED(bEditable);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setWithSurroundingSquare(bool bEnabled) override
|
||||||
|
{
|
||||||
|
Q_UNUSED(bEnabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setMgrsSquares(const QVector<LtsCoordTrans::UtmCoordinate>& geoCoords) override
|
||||||
|
{
|
||||||
|
Q_UNUSED(geoCoords);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::Wgs84* m_ui;
|
Ui::Wgs84* m_ui;
|
||||||
};
|
};
|
||||||
@@ -91,4 +104,4 @@ public:
|
|||||||
|
|
||||||
QValidator::State validate(QString& input, int& pos) const override;
|
QValidator::State validate(QString& input, int& pos) const override;
|
||||||
};
|
};
|
||||||
}
|
} // namespace LtsCoordWidget
|
||||||
Executable → Regular
+26
-35
@@ -1,13 +1,13 @@
|
|||||||
|
|
||||||
|
|
||||||
|
#include "lts_coord_widget.h"
|
||||||
|
|
||||||
|
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
#include <QLabel>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QLabel>
|
|
||||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
|
||||||
#include "lts_coord_widget.h"
|
|
||||||
|
|
||||||
static void updateLabel(const QPointF& coord, QLabel* lbl, int prec)
|
static void updateLabel(const QPointF& coord, QLabel* lbl, int prec)
|
||||||
{
|
{
|
||||||
@@ -31,79 +31,70 @@ int main(int argc, char **argv)
|
|||||||
QDialog* dialog(new QDialog);
|
QDialog* dialog(new QDialog);
|
||||||
QVBoxLayout* lay(new QVBoxLayout(dialog));
|
QVBoxLayout* lay(new QVBoxLayout(dialog));
|
||||||
|
|
||||||
|
|
||||||
const QPointF defCoord(QPointF(53.0, 8.0) * LtsCoordTrans::deg2rad());
|
const QPointF defCoord(QPointF(53.0, 8.0) * LtsCoordTrans::deg2rad());
|
||||||
|
|
||||||
LtsCoordWidget::LtsCoordWidget *wMgrs5(new LtsCoordWidget::LtsCoordWidget(LtsCoordWidget::LtsCoordWidget::DisplayType::MGRS, dialog));
|
LtsCoordWidget::LtsCoordWidget* wMgrs5(
|
||||||
|
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,
|
QObject::connect(wMgrs5, &LtsCoordWidget::LtsCoordWidget::coordinateChanged, lbl5,
|
||||||
lbl5, [lbl5](const QPointF & coord)
|
[lbl5](const QPointF& coord) { updateLabel(coord, lbl5, 5); });
|
||||||
{
|
|
||||||
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,
|
QObject::connect(wMgrs7, &LtsCoordWidget::LtsCoordWidget::coordinateChanged, wMgrs7,
|
||||||
wMgrs7, [lbl7](const QPointF & coord)
|
[lbl7](const QPointF& coord) { updateLabel(coord, lbl7, 7); });
|
||||||
{
|
|
||||||
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,
|
QObject::connect(w84, &LtsCoordWidget::LtsCoordWidget::coordinateChanged, w84,
|
||||||
w84, [lbl84](const QPointF & coord)
|
[lbl84](const QPointF& coord) { updateLabel(coord, lbl84, 11); });
|
||||||
{
|
|
||||||
updateLabel(coord, lbl84, 11);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
QHBoxLayout* hLay = new QHBoxLayout;
|
QHBoxLayout* hLay = new QHBoxLayout;
|
||||||
lay->addLayout(hLay);
|
lay->addLayout(hLay);
|
||||||
LtsCoordWidget::LtsCoordWidget *wChange(new LtsCoordWidget::LtsCoordWidget(LtsCoordWidget::LtsCoordWidget::DisplayType::WGS84, dialog));
|
LtsCoordWidget::LtsCoordWidget* wChange(
|
||||||
|
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,
|
QObject::connect(pbReset, &QPushButton::clicked, wChange,
|
||||||
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,
|
QObject::connect(pbNext, &QPushButton::clicked, wChange, [wChange]() {
|
||||||
wChange, [wChange]()
|
|
||||||
{
|
|
||||||
LtsCoordWidget::LtsCoordWidget::DisplayType dt = wChange->displayType();
|
LtsCoordWidget::LtsCoordWidget::DisplayType dt = wChange->displayType();
|
||||||
switch (dt)
|
switch (dt)
|
||||||
{
|
{
|
||||||
case LtsCoordWidget::LtsCoordWidget::DisplayType::MGRS5:
|
case LtsCoordWidget::LtsCoordWidget::DisplayType::MGRS5:
|
||||||
dt = LtsCoordWidget::LtsCoordWidget::DisplayType::MGRS7; break;
|
dt = LtsCoordWidget::LtsCoordWidget::DisplayType::MGRS7;
|
||||||
|
break;
|
||||||
case LtsCoordWidget::LtsCoordWidget::DisplayType::MGRS7:
|
case LtsCoordWidget::LtsCoordWidget::DisplayType::MGRS7:
|
||||||
dt = LtsCoordWidget::LtsCoordWidget::DisplayType::WGS84; break;
|
dt = LtsCoordWidget::LtsCoordWidget::DisplayType::WGS84;
|
||||||
|
break;
|
||||||
case LtsCoordWidget::LtsCoordWidget::DisplayType::WGS84:
|
case LtsCoordWidget::LtsCoordWidget::DisplayType::WGS84:
|
||||||
dt = LtsCoordWidget::LtsCoordWidget::DisplayType::MGRS5; break;
|
dt = LtsCoordWidget::LtsCoordWidget::DisplayType::MGRS5;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
wChange->setDisplayType(dt);
|
wChange->setDisplayType(dt);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
QPushButton* pb(new QPushButton(QStringLiteral("Quit"), dialog));
|
QPushButton* pb(new QPushButton(QStringLiteral("Quit"), dialog));
|
||||||
lay->addWidget(pb);
|
lay->addWidget(pb);
|
||||||
QObject::connect(pb, &QPushButton::clicked, qApp, QCoreApplication::quit);
|
QObject::connect(pb, &QPushButton::clicked, qApp, QCoreApplication::quit);
|
||||||
|
|||||||
Executable → Regular
+3
-4
@@ -1,8 +1,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include <GeographicLib/UTMUPS.hpp>
|
|
||||||
#include <GeographicLib/MGRS.hpp>
|
#include <GeographicLib/MGRS.hpp>
|
||||||
|
#include <GeographicLib/UTMUPS.hpp>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
@@ -39,7 +38,7 @@ 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",
|
fprintf(stdout, "%s %s %s %s = %13.10f, %13.10f ( %13.10f, %13.10f )\n", part1.c_str(), part2.c_str(),
|
||||||
part1.c_str(), part2.c_str(), part3.c_str(), part4.c_str(), lonDeg, latDeg, lonDeg / 180. * M_PI, latDeg / 180. * M_PI);
|
part3.c_str(), part4.c_str(), lonDeg, latDeg, lonDeg / 180. * M_PI, latDeg / 180. * M_PI);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
Executable → Regular
+109
-212
@@ -1,33 +1,23 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "lts_coordinate_unit_test.h"
|
#include "lts_coordinate_unit_test.h"
|
||||||
|
|
||||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
|
||||||
#include <LtsCoordinate/lts_coordinate.h>
|
|
||||||
#include <LtsCoordinate/lts_coord_vector.h>
|
|
||||||
#include <ElevationMap/elevation_map_manager.h>
|
#include <ElevationMap/elevation_map_manager.h>
|
||||||
|
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||||
#include <nglapplication/nglcoreapplication.h>
|
#include <LtsCoordinate/lts_coord_vector.h>
|
||||||
|
#include <LtsCoordinate/lts_coordinate.h>
|
||||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||||
#include <QtTest/QTest>
|
#include <QtTest/QTest>
|
||||||
|
#include <nglapplication/nglcoreapplication.h>
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(LtsUtils::QPoint3D);
|
Q_DECLARE_METATYPE(LtsUtils::QPoint3D);
|
||||||
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
static const int s_id{4711};
|
static const int s_id{4711};
|
||||||
static LtsElevation::LtsElevationManager* s_eleMgr{nullptr};
|
static LtsElevation::LtsElevationManager* s_eleMgr{nullptr};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class MyLtsElevationManagerBootstrap : public LtsElevation::LtsElevationManager
|
class MyLtsElevationManagerBootstrap : public LtsElevation::LtsElevationManager
|
||||||
{
|
{
|
||||||
using BaseClass = LtsElevation::LtsElevationManager;
|
using BaseClass = LtsElevation::LtsElevationManager;
|
||||||
@@ -37,21 +27,16 @@ public:
|
|||||||
{
|
{
|
||||||
return BaseClass::createInstanceUnitTest(id, filePaths_rough_to_fine);
|
return BaseClass::createInstanceUnitTest(id, filePaths_rough_to_fine);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
UnitTestCoordinate::UnitTestCoordinate()
|
UnitTestCoordinate::UnitTestCoordinate()
|
||||||
: m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("UnitTestCoordinate"))
|
: m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("UnitTestCoordinate"))
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void UnitTestCoordinate::initTestCase()
|
void UnitTestCoordinate::initTestCase()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
QString filePath(QStringLiteral("/usr/share/arcgis/resources/elevation/Altmark_dt1.tif"));
|
QString filePath(QStringLiteral("/usr/share/arcgis/resources/elevation/Altmark_dt1.tif"));
|
||||||
|
|
||||||
s_eleMgr = MyLtsElevationManagerBootstrap::createInstanceUnitTest(s_id, {filePath});
|
s_eleMgr = MyLtsElevationManagerBootstrap::createInstanceUnitTest(s_id, {filePath});
|
||||||
@@ -59,7 +44,6 @@ void UnitTestCoordinate::initTestCase()
|
|||||||
const bool bIsValid = s_eleMgr->isValid();
|
const bool bIsValid = s_eleMgr->isValid();
|
||||||
std::cerr << "myBootstrapMgr->isValid() 1 = " << bIsValid << std::endl;
|
std::cerr << "myBootstrapMgr->isValid() 1 = " << bIsValid << std::endl;
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
s_eleMgr->waitForInitialization();
|
s_eleMgr->waitForInitialization();
|
||||||
const bool bIsValid = s_eleMgr->isValid();
|
const bool bIsValid = s_eleMgr->isValid();
|
||||||
@@ -68,12 +52,9 @@ void UnitTestCoordinate::initTestCase()
|
|||||||
|
|
||||||
QVERIFY2(s_eleMgr, "static LtsElevationManager does not exist");
|
QVERIFY2(s_eleMgr, "static LtsElevationManager does not exist");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
using namespace std::placeholders;
|
using namespace std::placeholders;
|
||||||
LtsCoordTrans::LtsCoordinate::elevationCbFunc elevationCB = std::bind(&LtsElevation::LtsElevationManager::elevation,
|
LtsCoordTrans::LtsCoordinate::elevationCbFunc elevationCB =
|
||||||
s_eleMgr, _1, _2, _3, _4);
|
std::bind(&LtsElevation::LtsElevationManager::elevation, s_eleMgr, _1, _2, _3, _4);
|
||||||
LtsCoordTrans::LtsCoordinate::setElevationCallback(elevationCB);
|
LtsCoordTrans::LtsCoordinate::setElevationCallback(elevationCB);
|
||||||
|
|
||||||
QVERIFY2(LtsCoordTrans::LtsCoordinate::hasElevationCallback(), "setElevationCallback failed");
|
QVERIFY2(LtsCoordTrans::LtsCoordinate::hasElevationCallback(), "setElevationCallback failed");
|
||||||
@@ -90,7 +71,6 @@ void UnitTestCoordinate::test_NaN()
|
|||||||
bool equal = qFuzzyCompare(std::nan(""), std::nan(""));
|
bool equal = qFuzzyCompare(std::nan(""), std::nan(""));
|
||||||
NOTICE_LOG(m_logger) << " qFuzzyCompare(NaN, NaN) = " << equal;
|
NOTICE_LOG(m_logger) << " qFuzzyCompare(NaN, NaN) = " << equal;
|
||||||
|
|
||||||
|
|
||||||
QVERIFY2(equal == false, "qFuzzyCompare(NaN, NaN) failed");
|
QVERIFY2(equal == false, "qFuzzyCompare(NaN, NaN) failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,7 +121,6 @@ void UnitTestCoordinate::test_coordinate_simple2()
|
|||||||
const QPointF& utm = ltsCoord.toUtm<QPointF>();
|
const QPointF& utm = ltsCoord.toUtm<QPointF>();
|
||||||
NOTICE_LOG(m_logger) << " utmCoordinateAsPointF = " << utm;
|
NOTICE_LOG(m_logger) << " utmCoordinateAsPointF = " << utm;
|
||||||
|
|
||||||
|
|
||||||
const Core::GeoPosition& geoPos2 = ltsCoord.geoPosition();
|
const Core::GeoPosition& geoPos2 = ltsCoord.geoPosition();
|
||||||
NOTICE_LOG(m_logger) << " geoPosition2 = " << geoPos2;
|
NOTICE_LOG(m_logger) << " geoPosition2 = " << geoPos2;
|
||||||
QVERIFY2(qFuzzyIsNull(geoPos2.lon()), "geoPosition2 failed");
|
QVERIFY2(qFuzzyIsNull(geoPos2.lon()), "geoPosition2 failed");
|
||||||
@@ -153,7 +132,6 @@ void UnitTestCoordinate::test_coordinate_simple3()
|
|||||||
{
|
{
|
||||||
static const Core::GeoPosition s_invalidPos(std::nan(""), std::nan(""), std::nan(""));
|
static const Core::GeoPosition s_invalidPos(std::nan(""), std::nan(""), std::nan(""));
|
||||||
|
|
||||||
|
|
||||||
LtsCoordTrans::LtsCoordinate ltsCoord(s_invalidPos);
|
LtsCoordTrans::LtsCoordinate ltsCoord(s_invalidPos);
|
||||||
|
|
||||||
QVERIFY2(ltsCoord.isValid() == false, "isValid failed");
|
QVERIFY2(ltsCoord.isValid() == false, "isValid failed");
|
||||||
@@ -174,13 +152,12 @@ void UnitTestCoordinate::test_coordinate_simple4()
|
|||||||
LtsCoordTrans::LtsCoordinate::resetConversionCounter();
|
LtsCoordTrans::LtsCoordinate::resetConversionCounter();
|
||||||
QVERIFY2(LtsCoordTrans::LtsCoordinate::getConversionCounter() == 0, "getConversionCounter failed");
|
QVERIFY2(LtsCoordTrans::LtsCoordinate::getConversionCounter() == 0, "getConversionCounter failed");
|
||||||
|
|
||||||
const LtsCoordTrans::UtmCoordinate &utmIn = LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32 U PD 70000 10000"));
|
const LtsCoordTrans::UtmCoordinate& utmIn =
|
||||||
|
LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32 U PD 70000 10000"));
|
||||||
const double zValue = 2.3;
|
const double zValue = 2.3;
|
||||||
|
|
||||||
const LtsCoordTrans::LtsCoordinate ltsCoord(utmIn.geographic(), zValue);
|
const LtsCoordTrans::LtsCoordinate ltsCoord(utmIn.geographic(), zValue);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const LtsCoordTrans::UtmCoordinate& utmCoord_FirstTry = ltsCoord.utmCoordinate();
|
const LtsCoordTrans::UtmCoordinate& utmCoord_FirstTry = ltsCoord.utmCoordinate();
|
||||||
Q_UNUSED(utmCoord_FirstTry);
|
Q_UNUSED(utmCoord_FirstTry);
|
||||||
QVERIFY2(LtsCoordTrans::LtsCoordinate::getConversionCounter() == 1, "getConversionCounter failed");
|
QVERIFY2(LtsCoordTrans::LtsCoordinate::getConversionCounter() == 1, "getConversionCounter failed");
|
||||||
@@ -191,15 +168,13 @@ void UnitTestCoordinate::test_coordinate_simple4()
|
|||||||
QVERIFY2(LtsCoordTrans::LtsCoordinate::getConversionCounter() == 1, "getConversionCounter failed");
|
QVERIFY2(LtsCoordTrans::LtsCoordinate::getConversionCounter() == 1, "getConversionCounter failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void UnitTestCoordinate::test_coordinate_fromUtm()
|
void UnitTestCoordinate::test_coordinate_fromUtm()
|
||||||
{
|
{
|
||||||
const LtsCoordTrans::UtmCoordinate &utmIn = LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32 U PD 70000 10000"));
|
const LtsCoordTrans::UtmCoordinate& utmIn =
|
||||||
|
LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32 U PD 70000 10000"));
|
||||||
const double zValue = 2.3;
|
const double zValue = 2.3;
|
||||||
NOTICE_LOG(m_logger) << " utmIn = " << utmIn;
|
NOTICE_LOG(m_logger) << " utmIn = " << utmIn;
|
||||||
|
|
||||||
|
|
||||||
LtsCoordTrans::LtsCoordinate ltsCoord(utmIn.geographic(), zValue);
|
LtsCoordTrans::LtsCoordinate ltsCoord(utmIn.geographic(), zValue);
|
||||||
|
|
||||||
const LtsCoordTrans::UtmCoordinate& utmCoord = ltsCoord.utmCoordinate();
|
const LtsCoordTrans::UtmCoordinate& utmCoord = ltsCoord.utmCoordinate();
|
||||||
@@ -207,7 +182,6 @@ void UnitTestCoordinate::test_coordinate_fromUtm()
|
|||||||
NOTICE_LOG(m_logger) << " utmCoord = " << utmCoord.mgrs();
|
NOTICE_LOG(m_logger) << " utmCoord = " << utmCoord.mgrs();
|
||||||
QVERIFY2(utmCoord.mgrs() == QStringLiteral("32U PD 70000 10000"), "utmCoordinate failed");
|
QVERIFY2(utmCoord.mgrs() == QStringLiteral("32U PD 70000 10000"), "utmCoordinate failed");
|
||||||
|
|
||||||
|
|
||||||
const Core::GeoPosition& geoPos = ltsCoord.geoPosition();
|
const Core::GeoPosition& geoPos = ltsCoord.geoPosition();
|
||||||
NOTICE_LOG(m_logger) << " geoPosition = " << geoPos;
|
NOTICE_LOG(m_logger) << " geoPosition = " << geoPos;
|
||||||
|
|
||||||
@@ -215,7 +189,6 @@ void UnitTestCoordinate::test_coordinate_fromUtm()
|
|||||||
QVERIFY2(qFuzzyCompare(geoPos.lat(), 0.914792952478694), "geoPosition failed");
|
QVERIFY2(qFuzzyCompare(geoPos.lat(), 0.914792952478694), "geoPosition failed");
|
||||||
QVERIFY2(qFuzzyCompare(geoPos.z(), zValue), "geoPosition failed");
|
QVERIFY2(qFuzzyCompare(geoPos.z(), zValue), "geoPosition failed");
|
||||||
|
|
||||||
|
|
||||||
const QPointF& utmP2D = ltsCoord.toUtm<QPointF>();
|
const QPointF& utmP2D = ltsCoord.toUtm<QPointF>();
|
||||||
NOTICE_LOG(m_logger) << " utmP2D = " << utmP2D;
|
NOTICE_LOG(m_logger) << " utmP2D = " << utmP2D;
|
||||||
QVERIFY2(qFuzzyCompare(utmP2D.x(), 670000.5), "utm1 failed");
|
QVERIFY2(qFuzzyCompare(utmP2D.x(), 670000.5), "utm1 failed");
|
||||||
@@ -233,27 +206,27 @@ void UnitTestCoordinate::test_coordinate_fromUtm()
|
|||||||
QVERIFY2(qFuzzyCompare(utmCoord3D.y, 5810000.5), "utmCoord3D failed");
|
QVERIFY2(qFuzzyCompare(utmCoord3D.y, 5810000.5), "utmCoord3D failed");
|
||||||
QVERIFY2(qFuzzyCompare(utmCoord3D.z(), zValue), "utmCoord3D failed");
|
QVERIFY2(qFuzzyCompare(utmCoord3D.z(), zValue), "utmCoord3D failed");
|
||||||
|
|
||||||
|
|
||||||
const LtsCoordTrans::UtmCoordinate& utmCoord2D = utmCoord3D;
|
const LtsCoordTrans::UtmCoordinate& utmCoord2D = utmCoord3D;
|
||||||
NOTICE_LOG(m_logger) << " utmCoord2D = " << utmCoord2D;
|
NOTICE_LOG(m_logger) << " utmCoord2D = " << utmCoord2D;
|
||||||
QVERIFY2(qFuzzyCompare(utmCoord2D.x, 670000.5), "utmCoord2D failed");
|
QVERIFY2(qFuzzyCompare(utmCoord2D.x, 670000.5), "utmCoord2D failed");
|
||||||
QVERIFY2(qFuzzyCompare(utmCoord2D.y, 5810000.5), "utmCoord2D failed");
|
QVERIFY2(qFuzzyCompare(utmCoord2D.y, 5810000.5), "utmCoord2D failed");
|
||||||
|
|
||||||
|
|
||||||
const LtsCoordTrans::UtmCoordinate& utm = ltsCoord.utmCoordinate();
|
const LtsCoordTrans::UtmCoordinate& utm = ltsCoord.utmCoordinate();
|
||||||
QVERIFY2(utm.mgrs() == QStringLiteral("32U PD 70000 10000"), "utmCoordinate failed");
|
QVERIFY2(utm.mgrs() == QStringLiteral("32U PD 70000 10000"), "utmCoordinate failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnitTestCoordinate::test_coordinate_fromUtm2()
|
void UnitTestCoordinate::test_coordinate_fromUtm2()
|
||||||
{
|
{
|
||||||
const LtsCoordTrans::UtmCoordinate &utmInZone32 = LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32 U LA 10000 00000"));
|
const LtsCoordTrans::UtmCoordinate& utmInZone32 =
|
||||||
|
LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32 U LA 10000 00000"));
|
||||||
const double zValue = 2.3;
|
const double zValue = 2.3;
|
||||||
NOTICE_LOG(m_logger) << " utmInZone32 = " << utmInZone32;
|
NOTICE_LOG(m_logger) << " utmInZone32 = " << utmInZone32;
|
||||||
|
|
||||||
const QPointF& utmInDefQPointF = utmInZone32.geographic();
|
const QPointF& utmInDefQPointF = utmInZone32.geographic();
|
||||||
|
|
||||||
const int zone31 = 31;
|
const int zone31 = 31;
|
||||||
const LtsCoordTrans::UtmCoordinate &utmInZone31 = LtsCoordTrans::UtmCoordinate::fromGeographic(utmInDefQPointF, zone31);
|
const LtsCoordTrans::UtmCoordinate& utmInZone31 =
|
||||||
|
LtsCoordTrans::UtmCoordinate::fromGeographic(utmInDefQPointF, zone31);
|
||||||
NOTICE_LOG(m_logger) << " utmInZone31 = " << utmInZone31;
|
NOTICE_LOG(m_logger) << " utmInZone31 = " << utmInZone31;
|
||||||
|
|
||||||
NOTICE_LOG(m_logger) << " utmInZone31.geographic() = " << utmInZone31.geographic();
|
NOTICE_LOG(m_logger) << " utmInZone31.geographic() = " << utmInZone31.geographic();
|
||||||
@@ -282,10 +255,10 @@ void UnitTestCoordinate::test_coordinate_fromUtm2()
|
|||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
LtsCoordTrans::LtsCoordinate ltsFromUtm31 =
|
||||||
|
LtsCoordTrans::LtsCoordinate::fromUtmCoordinate(utmInZone31, zValue);
|
||||||
LtsCoordTrans::LtsCoordinate ltsFromUtm31 = LtsCoordTrans::LtsCoordinate::fromUtmCoordinate(utmInZone31, zValue);
|
LtsCoordTrans::LtsCoordinate ltsFromUtm32 =
|
||||||
LtsCoordTrans::LtsCoordinate ltsFromUtm32 = LtsCoordTrans::LtsCoordinate::fromUtmCoordinate(utmInZone32, zValue);
|
LtsCoordTrans::LtsCoordinate::fromUtmCoordinate(utmInZone32, zValue);
|
||||||
|
|
||||||
double dist = ltsFromUtm31.distanceUtm3D(ltsFromUtm32);
|
double dist = ltsFromUtm31.distanceUtm3D(ltsFromUtm32);
|
||||||
NOTICE_LOG(m_logger) << " dist3 = " << dist;
|
NOTICE_LOG(m_logger) << " dist3 = " << dist;
|
||||||
@@ -311,31 +284,28 @@ void UnitTestCoordinate::test_coordinate_fromUtm2()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void UnitTestCoordinate::test_coordinate_elevationAt()
|
void UnitTestCoordinate::test_coordinate_elevationAt()
|
||||||
{
|
{
|
||||||
const double zValue = 1.23;
|
const double zValue = 1.23;
|
||||||
|
|
||||||
const LtsCoordTrans::UtmCoordinate &utmIn = LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32 U PD 70000 10000"));
|
const LtsCoordTrans::UtmCoordinate& utmIn =
|
||||||
|
LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32 U PD 70000 10000"));
|
||||||
NOTICE_LOG(m_logger) << " utmIn = " << utmIn;
|
NOTICE_LOG(m_logger) << " utmIn = " << utmIn;
|
||||||
|
|
||||||
LtsCoordTrans::LtsCoordinate ltsFromUtm(utmIn.geographic(), zValue);
|
LtsCoordTrans::LtsCoordinate ltsFromUtm(utmIn.geographic(), zValue);
|
||||||
NOTICE_LOG(m_logger) << " ltsFromUtm1 = " << ltsFromUtm;
|
NOTICE_LOG(m_logger) << " ltsFromUtm1 = " << ltsFromUtm;
|
||||||
QVERIFY2(qFuzzyCompare(ltsFromUtm.geoPosition().z(), zValue), "geoPosition failed");
|
QVERIFY2(qFuzzyCompare(ltsFromUtm.geoPosition().z(), zValue), "geoPosition failed");
|
||||||
|
|
||||||
|
|
||||||
const double ele = ltsFromUtm.elevationAt();
|
const double ele = ltsFromUtm.elevationAt();
|
||||||
QVERIFY2(qFuzzyCompare(ele, 75), "elevationAt failed");
|
QVERIFY2(qFuzzyCompare(ele, 75), "elevationAt failed");
|
||||||
|
|
||||||
NOTICE_LOG(m_logger) << " ltsFromUtm2 = " << ltsFromUtm;
|
NOTICE_LOG(m_logger) << " ltsFromUtm2 = " << ltsFromUtm;
|
||||||
QVERIFY2(qFuzzyCompare(ltsFromUtm.geoPosition().z(), zValue), "geoPosition failed");
|
QVERIFY2(qFuzzyCompare(ltsFromUtm.geoPosition().z(), zValue), "geoPosition failed");
|
||||||
|
|
||||||
|
|
||||||
ltsFromUtm.setZValueAccordingElevation();
|
ltsFromUtm.setZValueAccordingElevation();
|
||||||
NOTICE_LOG(m_logger) << " ltsFromUtm3 = " << ltsFromUtm;
|
NOTICE_LOG(m_logger) << " ltsFromUtm3 = " << ltsFromUtm;
|
||||||
QVERIFY2(qFuzzyCompare(ltsFromUtm.geoPosition().z(), 75), "setZValueAccordingElevation failed");
|
QVERIFY2(qFuzzyCompare(ltsFromUtm.geoPosition().z(), 75), "setZValueAccordingElevation failed");
|
||||||
|
|
||||||
|
|
||||||
const LtsUtils::QPoint3D& utmP3D = ltsFromUtm.toUtm<LtsUtils::QPoint3D>();
|
const LtsUtils::QPoint3D& utmP3D = ltsFromUtm.toUtm<LtsUtils::QPoint3D>();
|
||||||
NOTICE_LOG(m_logger) << " utmP3D_a = " << utmP3D;
|
NOTICE_LOG(m_logger) << " utmP3D_a = " << utmP3D;
|
||||||
QVERIFY2(qFuzzyCompare(utmP3D.z(), 75), "utmCoordinateAsPoint3D failed");
|
QVERIFY2(qFuzzyCompare(utmP3D.z(), 75), "utmCoordinateAsPoint3D failed");
|
||||||
@@ -348,11 +318,6 @@ void UnitTestCoordinate::test_coordinate_elevationAt()
|
|||||||
QVERIFY2(qFuzzyCompare(ele, ele3), "LtsCoordinate::elevationAt failed");
|
QVERIFY2(qFuzzyCompare(ele, ele3), "LtsCoordinate::elevationAt failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
LtsCoordTrans::UtmCoordinate utmMoved = ltsFromUtm.utmCoordinate();
|
LtsCoordTrans::UtmCoordinate utmMoved = ltsFromUtm.utmCoordinate();
|
||||||
utmMoved.x += 11;
|
utmMoved.x += 11;
|
||||||
utmMoved.y += 22;
|
utmMoved.y += 22;
|
||||||
@@ -360,7 +325,6 @@ void UnitTestCoordinate::test_coordinate_elevationAt()
|
|||||||
ltsFromUtm = LtsCoordTrans::LtsCoordinate(utmMoved.geographic(), zValueNew);
|
ltsFromUtm = LtsCoordTrans::LtsCoordinate(utmMoved.geographic(), zValueNew);
|
||||||
NOTICE_LOG(m_logger) << " ltsFromUtm4 = " << ltsFromUtm;
|
NOTICE_LOG(m_logger) << " ltsFromUtm4 = " << ltsFromUtm;
|
||||||
|
|
||||||
|
|
||||||
const double ele2 = ltsFromUtm.elevationAt();
|
const double ele2 = ltsFromUtm.elevationAt();
|
||||||
NOTICE_LOG(m_logger) << " ltsFromUtm5 = " << ltsFromUtm;
|
NOTICE_LOG(m_logger) << " ltsFromUtm5 = " << ltsFromUtm;
|
||||||
QVERIFY2(ele2 != 75, "setZValueAccordingElevation failed");
|
QVERIFY2(ele2 != 75, "setZValueAccordingElevation failed");
|
||||||
@@ -368,8 +332,10 @@ void UnitTestCoordinate::test_coordinate_elevationAt()
|
|||||||
|
|
||||||
void UnitTestCoordinate::test_coordinate_elevationAt_isCovered()
|
void UnitTestCoordinate::test_coordinate_elevationAt_isCovered()
|
||||||
{
|
{
|
||||||
const LtsCoordTrans::UtmCoordinate &utmIn1 = LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32 U PD 70000 10000"));
|
const LtsCoordTrans::UtmCoordinate& utmIn1 =
|
||||||
const LtsCoordTrans::UtmCoordinate &utmIn2 = LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32 U MD 10000 10000"));
|
LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32 U PD 70000 10000"));
|
||||||
|
const LtsCoordTrans::UtmCoordinate& utmIn2 =
|
||||||
|
LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32 U MD 10000 10000"));
|
||||||
|
|
||||||
LtsCoordTrans::LtsCoordinate ltsFromUtm1(utmIn1.geographic(), 11);
|
LtsCoordTrans::LtsCoordinate ltsFromUtm1(utmIn1.geographic(), 11);
|
||||||
LtsCoordTrans::LtsCoordinate ltsFromUtm2(utmIn2.geographic(), 11);
|
LtsCoordTrans::LtsCoordinate ltsFromUtm2(utmIn2.geographic(), 11);
|
||||||
@@ -380,20 +346,16 @@ void UnitTestCoordinate::test_coordinate_elevationAt_isCovered()
|
|||||||
Q_UNUSED(ele);
|
Q_UNUSED(ele);
|
||||||
QVERIFY2(bIsCovered == true, "elevationAt1a failed");
|
QVERIFY2(bIsCovered == true, "elevationAt1a failed");
|
||||||
|
|
||||||
|
|
||||||
bIsCovered = false;
|
bIsCovered = false;
|
||||||
ele = ltsFromUtm1.elevationAt(-123, &bIsCovered);
|
ele = ltsFromUtm1.elevationAt(-123, &bIsCovered);
|
||||||
Q_UNUSED(ele);
|
Q_UNUSED(ele);
|
||||||
QVERIFY2(bIsCovered == true, "elevationAt1b failed");
|
QVERIFY2(bIsCovered == true, "elevationAt1b failed");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bIsCovered = false;
|
bIsCovered = false;
|
||||||
ele = LtsCoordTrans::LtsCoordinate::elevationAt(ltsFromUtm1, -123, &bIsCovered);
|
ele = LtsCoordTrans::LtsCoordinate::elevationAt(ltsFromUtm1, -123, &bIsCovered);
|
||||||
Q_UNUSED(ele);
|
Q_UNUSED(ele);
|
||||||
QVERIFY2(bIsCovered == true, "elevationAt2a failed");
|
QVERIFY2(bIsCovered == true, "elevationAt2a failed");
|
||||||
|
|
||||||
|
|
||||||
bIsCovered = false;
|
bIsCovered = false;
|
||||||
ele = LtsCoordTrans::LtsCoordinate::elevationAt(ltsFromUtm1, -123, &bIsCovered);
|
ele = LtsCoordTrans::LtsCoordinate::elevationAt(ltsFromUtm1, -123, &bIsCovered);
|
||||||
Q_UNUSED(ele);
|
Q_UNUSED(ele);
|
||||||
@@ -406,7 +368,6 @@ void UnitTestCoordinate::test_coordinate_elevationAt_isCovered()
|
|||||||
Q_UNUSED(ele);
|
Q_UNUSED(ele);
|
||||||
QVERIFY2(bIsCovered == false, "elevationAt2 failed");
|
QVERIFY2(bIsCovered == false, "elevationAt2 failed");
|
||||||
|
|
||||||
|
|
||||||
bIsCovered = true;
|
bIsCovered = true;
|
||||||
ele = LtsCoordTrans::LtsCoordinate::elevationAt(ltsFromUtm2, -123, &bIsCovered);
|
ele = LtsCoordTrans::LtsCoordinate::elevationAt(ltsFromUtm2, -123, &bIsCovered);
|
||||||
Q_UNUSED(ele);
|
Q_UNUSED(ele);
|
||||||
@@ -420,12 +381,12 @@ void UnitTestCoordinate::test_coordinate_elevation_data()
|
|||||||
QTest::addColumn<double>("elevationIn");
|
QTest::addColumn<double>("elevationIn");
|
||||||
QTest::addColumn<double>("elevationRef");
|
QTest::addColumn<double>("elevationRef");
|
||||||
|
|
||||||
|
|
||||||
QTest::newRow("elevation 10 ") << QStringLiteral("32 U PD 70000 10000") << std::nan("") << 75.0;
|
QTest::newRow("elevation 10 ") << QStringLiteral("32 U PD 70000 10000") << std::nan("") << 75.0;
|
||||||
QTest::newRow("elevation 11 ") << QStringLiteral("32 U PD 70000 10000") << 0.0 << 75.0;
|
QTest::newRow("elevation 11 ") << QStringLiteral("32 U PD 70000 10000") << 0.0 << 75.0;
|
||||||
QTest::newRow("elevation 20 ") << QStringLiteral("32 U PD 72000 13000") << std::nan("") << 80.0;
|
QTest::newRow("elevation 20 ") << QStringLiteral("32 U PD 72000 13000") << std::nan("") << 80.0;
|
||||||
QTest::newRow("elevation 21 ") << QStringLiteral("32 U PD 72000 13000") << 0.340 << 80.0;
|
QTest::newRow("elevation 21 ") << QStringLiteral("32 U PD 72000 13000") << 0.340 << 80.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnitTestCoordinate::test_coordinate_elevation()
|
void UnitTestCoordinate::test_coordinate_elevation()
|
||||||
{
|
{
|
||||||
QFETCH(QString, mgrs);
|
QFETCH(QString, mgrs);
|
||||||
@@ -438,15 +399,12 @@ void UnitTestCoordinate::test_coordinate_elevation()
|
|||||||
LtsCoordTrans::LtsCoordinate ltsFromUtm(utmIn.geographic(), elevationIn);
|
LtsCoordTrans::LtsCoordinate ltsFromUtm(utmIn.geographic(), elevationIn);
|
||||||
NOTICE_LOG(m_logger) << " ltsFromUtm = " << ltsFromUtm;
|
NOTICE_LOG(m_logger) << " ltsFromUtm = " << ltsFromUtm;
|
||||||
|
|
||||||
|
|
||||||
NOTICE_LOG(m_logger) << " geoPosition = " << ltsFromUtm.geoPosition();
|
NOTICE_LOG(m_logger) << " geoPosition = " << ltsFromUtm.geoPosition();
|
||||||
ltsFromUtm.replaceZValueByElevationIfValue(elevationIn);
|
ltsFromUtm.replaceZValueByElevationIfValue(elevationIn);
|
||||||
|
|
||||||
|
|
||||||
NOTICE_LOG(m_logger) << " geoPosition = " << ltsFromUtm.geoPosition();
|
NOTICE_LOG(m_logger) << " geoPosition = " << ltsFromUtm.geoPosition();
|
||||||
QVERIFY2(qFuzzyCompare(ltsFromUtm.geoPosition().z(), elevationRef), "elevation failed");
|
QVERIFY2(qFuzzyCompare(ltsFromUtm.geoPosition().z(), elevationRef), "elevation failed");
|
||||||
|
|
||||||
|
|
||||||
const LtsUtils::QPoint3D& utmP3D = ltsFromUtm.toUtm<LtsUtils::QPoint3D>();
|
const LtsUtils::QPoint3D& utmP3D = ltsFromUtm.toUtm<LtsUtils::QPoint3D>();
|
||||||
NOTICE_LOG(m_logger) << " utmP3D = " << utmP3D;
|
NOTICE_LOG(m_logger) << " utmP3D = " << utmP3D;
|
||||||
QVERIFY2(qFuzzyCompare(utmP3D.z(), elevationRef), "utmCoordinateAsPoint3D failed");
|
QVERIFY2(qFuzzyCompare(utmP3D.z(), elevationRef), "utmCoordinateAsPoint3D failed");
|
||||||
@@ -454,7 +412,8 @@ void UnitTestCoordinate::test_coordinate_elevation()
|
|||||||
|
|
||||||
void UnitTestCoordinate::test_coordinate_mgrs()
|
void UnitTestCoordinate::test_coordinate_mgrs()
|
||||||
{
|
{
|
||||||
const LtsCoordTrans::UtmCoordinate &utmIn = LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32 U PD 70000 10000"));
|
const LtsCoordTrans::UtmCoordinate& utmIn =
|
||||||
|
LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32 U PD 70000 10000"));
|
||||||
NOTICE_LOG(m_logger) << " utmIn = " << utmIn.mgrs();
|
NOTICE_LOG(m_logger) << " utmIn = " << utmIn.mgrs();
|
||||||
|
|
||||||
LtsCoordTrans::LtsCoordinate ltsFromUtm(utmIn.geographic());
|
LtsCoordTrans::LtsCoordinate ltsFromUtm(utmIn.geographic());
|
||||||
@@ -473,27 +432,28 @@ void UnitTestCoordinate::test_coordinate_mgrs()
|
|||||||
{
|
{
|
||||||
const LtsCoordTrans::LtsCoordinate coord(0.200706392814992, 0.914792952478694, 123);
|
const LtsCoordTrans::LtsCoordinate coord(0.200706392814992, 0.914792952478694, 123);
|
||||||
|
|
||||||
|
|
||||||
const QString str1 = coord.toString();
|
const QString str1 = coord.toString();
|
||||||
NOTICE_LOG(m_logger) << " str1 cheap = " << str1;
|
NOTICE_LOG(m_logger) << " str1 cheap = " << str1;
|
||||||
QVERIFY2(str1.compare(QStringLiteral("LtsCoordinate(m_geo=[[lon: 0.200706392814992, lat: 0.914792952478694]z: 123], m_utm2D.x 0, m_utm2D.y 0, m_utm2D.zone -1, elevation nan)")) == 0, "toString failed");
|
QVERIFY2(str1.compare(QStringLiteral("LtsCoordinate(m_geo=[[lon: 0.200706392814992, lat: 0.914792952478694]z: "
|
||||||
|
"123], m_utm2D.x 0, m_utm2D.y 0, m_utm2D.zone -1, elevation nan)")) == 0,
|
||||||
|
"toString failed");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const bool fullAndExpensive = true;
|
const bool fullAndExpensive = true;
|
||||||
const QString str2 = coord.toString(fullAndExpensive);
|
const QString str2 = coord.toString(fullAndExpensive);
|
||||||
NOTICE_LOG(m_logger) << " str2 expensive = " << str2;
|
NOTICE_LOG(m_logger) << " str2 expensive = " << str2;
|
||||||
QVERIFY2(str2.compare(QStringLiteral("LtsCoordinate(m_geo=[[lon: 0.200706392814992, lat: 0.914792952478694]z: 123], m_utm2D.x 670000.499999998, m_utm2D.y 5810000.5, m_utm2D.zone 32, m_utm2D.mgrs '32U PD 70000 10000', elevation 75.000)")) == 0, "toString failed");
|
QVERIFY2(str2.compare(QStringLiteral("LtsCoordinate(m_geo=[[lon: 0.200706392814992, lat: 0.914792952478694]z: "
|
||||||
|
"123], m_utm2D.x 670000.499999998, m_utm2D.y 5810000.5, m_utm2D.zone 32, "
|
||||||
|
"m_utm2D.mgrs '32U PD 70000 10000', elevation 75.000)")) == 0,
|
||||||
|
"toString failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnitTestCoordinate::test_coordinate_distance()
|
void UnitTestCoordinate::test_coordinate_distance()
|
||||||
{
|
{
|
||||||
const LtsCoordTrans::UtmCoordinate &utmIn1 = LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32 U PD 70000 10000"));
|
const LtsCoordTrans::UtmCoordinate& utmIn1 =
|
||||||
const LtsCoordTrans::UtmCoordinate &utmIn2 = LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32 U PD 70010 10100"));
|
LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32 U PD 70000 10000"));
|
||||||
|
const LtsCoordTrans::UtmCoordinate& utmIn2 =
|
||||||
|
LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32 U PD 70010 10100"));
|
||||||
NOTICE_LOG(m_logger) << " XXutmIn1 = " << utmIn1;
|
NOTICE_LOG(m_logger) << " XXutmIn1 = " << utmIn1;
|
||||||
NOTICE_LOG(m_logger) << " XXutmIn2 = " << utmIn2;
|
NOTICE_LOG(m_logger) << " XXutmIn2 = " << utmIn2;
|
||||||
|
|
||||||
@@ -516,16 +476,15 @@ void UnitTestCoordinate::test_coordinate_distance()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void UnitTestCoordinate::test_coordinate_distanceDiffZones()
|
void UnitTestCoordinate::test_coordinate_distanceDiffZones()
|
||||||
{
|
{
|
||||||
const LtsCoordTrans::UtmCoordinate &utmIn1 = LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("31 U FR 99999 00000"));
|
const LtsCoordTrans::UtmCoordinate& utmIn1 =
|
||||||
const LtsCoordTrans::UtmCoordinate &utmIn2 = LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32 U LA 00000 00000"));
|
LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("31 U FR 99999 00000"));
|
||||||
|
const LtsCoordTrans::UtmCoordinate& utmIn2 =
|
||||||
|
LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32 U LA 00000 00000"));
|
||||||
NOTICE_LOG(m_logger) << " XXutmIn1 = " << utmIn1;
|
NOTICE_LOG(m_logger) << " XXutmIn1 = " << utmIn1;
|
||||||
NOTICE_LOG(m_logger) << " XXutmIn2 = " << utmIn2;
|
NOTICE_LOG(m_logger) << " XXutmIn2 = " << utmIn2;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
LtsCoordTrans::LtsCoordinate lts1(utmIn1.geographic(), 0);
|
LtsCoordTrans::LtsCoordinate lts1(utmIn1.geographic(), 0);
|
||||||
LtsCoordTrans::LtsCoordinate lts2(utmIn2.geographic(), 0);
|
LtsCoordTrans::LtsCoordinate lts2(utmIn2.geographic(), 0);
|
||||||
NOTICE_LOG(m_logger) << " lts1 = " << lts1;
|
NOTICE_LOG(m_logger) << " lts1 = " << lts1;
|
||||||
@@ -539,10 +498,14 @@ void UnitTestCoordinate::test_coordinate_distanceDiffZones()
|
|||||||
|
|
||||||
void UnitTestCoordinate::test_squareInDifferentZone()
|
void UnitTestCoordinate::test_squareInDifferentZone()
|
||||||
{
|
{
|
||||||
const LtsCoordTrans::UtmCoordinate &utm_bl = LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32 U PD 70000 10000"));
|
const LtsCoordTrans::UtmCoordinate& utm_bl =
|
||||||
const LtsCoordTrans::UtmCoordinate &utm_br = LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32 U PD 70000 11000"));
|
LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32 U PD 70000 10000"));
|
||||||
const LtsCoordTrans::UtmCoordinate &utm_tl = LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32 U PD 71000 10000"));
|
const LtsCoordTrans::UtmCoordinate& utm_br =
|
||||||
const LtsCoordTrans::UtmCoordinate &utm_tr = LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32 U PD 71000 11000"));
|
LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32 U PD 70000 11000"));
|
||||||
|
const LtsCoordTrans::UtmCoordinate& utm_tl =
|
||||||
|
LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32 U PD 71000 10000"));
|
||||||
|
const LtsCoordTrans::UtmCoordinate& utm_tr =
|
||||||
|
LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32 U PD 71000 11000"));
|
||||||
|
|
||||||
const LtsCoordTrans::LtsCoordinate lts_bl(utm_bl.geographic(), 0);
|
const LtsCoordTrans::LtsCoordinate lts_bl(utm_bl.geographic(), 0);
|
||||||
const LtsCoordTrans::LtsCoordinate lts_br(utm_br.geographic(), 0);
|
const LtsCoordTrans::LtsCoordinate lts_br(utm_br.geographic(), 0);
|
||||||
@@ -560,43 +523,39 @@ void UnitTestCoordinate::test_squareInDifferentZone()
|
|||||||
QVERIFY2(qFuzzyCompare(lts_br.distanceUtm2D(lts_tl), 1414.213562373177), "distance3D 6 failed");
|
QVERIFY2(qFuzzyCompare(lts_br.distanceUtm2D(lts_tl), 1414.213562373177), "distance3D 6 failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
const LtsCoordTrans::UtmCoordinate& utm31_bl = LtsCoordTrans::UtmCoordinate(31, utm_bl.x, utm_bl.y);
|
const LtsCoordTrans::UtmCoordinate& utm31_bl = LtsCoordTrans::UtmCoordinate(31, utm_bl.x, utm_bl.y);
|
||||||
const LtsCoordTrans::UtmCoordinate& utm31_br = LtsCoordTrans::UtmCoordinate(31, utm_br.x, utm_br.y);
|
const LtsCoordTrans::UtmCoordinate& utm31_br = LtsCoordTrans::UtmCoordinate(31, utm_br.x, utm_br.y);
|
||||||
const LtsCoordTrans::UtmCoordinate& utm31_tl = LtsCoordTrans::UtmCoordinate(31, utm_tl.x, utm_tl.y);
|
const LtsCoordTrans::UtmCoordinate& utm31_tl = LtsCoordTrans::UtmCoordinate(31, utm_tl.x, utm_tl.y);
|
||||||
const LtsCoordTrans::UtmCoordinate& utm31_tr = LtsCoordTrans::UtmCoordinate(31, utm_tr.x, utm_tr.y);
|
const LtsCoordTrans::UtmCoordinate& utm31_tr = LtsCoordTrans::UtmCoordinate(31, utm_tr.x, utm_tr.y);
|
||||||
|
|
||||||
|
QVERIFY2(qFuzzyCompare(LtsCoordTrans::distance(utm31_bl, utm31_br), 1000.0),
|
||||||
|
"LtsCoordTrans::distance 1 failed");
|
||||||
|
QVERIFY2(qFuzzyCompare(LtsCoordTrans::distance(utm31_tl, utm31_tr), 1000.0),
|
||||||
|
"LtsCoordTrans::distance 2 failed");
|
||||||
|
QVERIFY2(qFuzzyCompare(LtsCoordTrans::distance(utm31_br, utm31_tr), 1000.0),
|
||||||
|
"LtsCoordTrans::distance 3 failed");
|
||||||
|
QVERIFY2(qFuzzyCompare(LtsCoordTrans::distance(utm31_bl, utm31_tl), 1000.0),
|
||||||
|
"LtsCoordTrans::distance 4 failed");
|
||||||
|
|
||||||
QVERIFY2(qFuzzyCompare(LtsCoordTrans::distance(utm31_bl, utm31_br), 1000.0), "LtsCoordTrans::distance 1 failed");
|
QVERIFY2(qFuzzyCompare(LtsCoordTrans::distance(utm31_bl, utm31_tr), 1414.213562373095),
|
||||||
QVERIFY2(qFuzzyCompare(LtsCoordTrans::distance(utm31_tl, utm31_tr), 1000.0), "LtsCoordTrans::distance 2 failed");
|
"LtsCoordTrans::distance 5 failed");
|
||||||
QVERIFY2(qFuzzyCompare(LtsCoordTrans::distance(utm31_br, utm31_tr), 1000.0), "LtsCoordTrans::distance 3 failed");
|
QVERIFY2(qFuzzyCompare(LtsCoordTrans::distance(utm31_br, utm31_tl), 1414.213562373095),
|
||||||
QVERIFY2(qFuzzyCompare(LtsCoordTrans::distance(utm31_bl, utm31_tl), 1000.0), "LtsCoordTrans::distance 4 failed");
|
"LtsCoordTrans::distance 6 failed");
|
||||||
|
|
||||||
QVERIFY2(qFuzzyCompare(LtsCoordTrans::distance(utm31_bl, utm31_tr), 1414.213562373095), "LtsCoordTrans::distance 5 failed");
|
|
||||||
QVERIFY2(qFuzzyCompare(LtsCoordTrans::distance(utm31_br, utm31_tl), 1414.213562373095), "LtsCoordTrans::distance 6 failed");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnitTestCoordinate::test_coordinate_angle()
|
void UnitTestCoordinate::test_coordinate_angle()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
const LtsCoordTrans::UtmCoordinate& utm_ul =
|
||||||
const LtsCoordTrans::UtmCoordinate &utm_ul = LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32 U PD 70000 10000"));
|
LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32 U PD 70000 10000"));
|
||||||
const LtsCoordTrans::LtsCoordinate lts_ul(utm_ul.geographic(), 0);
|
const LtsCoordTrans::LtsCoordinate lts_ul(utm_ul.geographic(), 0);
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
const LtsCoordTrans::UtmCoordinate &utm_2 = LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32 U PD 70000 11000"));
|
const LtsCoordTrans::UtmCoordinate& utm_2 =
|
||||||
|
LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32 U PD 70000 11000"));
|
||||||
const LtsCoordTrans::LtsCoordinate lts_2(utm_2.geographic(), 0);
|
const LtsCoordTrans::LtsCoordinate lts_2(utm_2.geographic(), 0);
|
||||||
double angle = LtsCoordTrans::LtsCoordinate::angleDegreeUtm2D(lts_ul, lts_2);
|
double angle = LtsCoordTrans::LtsCoordinate::angleDegreeUtm2D(lts_ul, lts_2);
|
||||||
QVERIFY2(qFuzzyCompare(angle, 0.0), "angleUtm2D 1 failed");
|
QVERIFY2(qFuzzyCompare(angle, 0.0), "angleUtm2D 1 failed");
|
||||||
@@ -604,7 +563,8 @@ void UnitTestCoordinate::test_coordinate_angle()
|
|||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
const LtsCoordTrans::UtmCoordinate &utm_2 = LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32 U PD 71000 10000"));
|
const LtsCoordTrans::UtmCoordinate& utm_2 =
|
||||||
|
LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32 U PD 71000 10000"));
|
||||||
const LtsCoordTrans::LtsCoordinate lts_2(utm_2.geographic(), 0);
|
const LtsCoordTrans::LtsCoordinate lts_2(utm_2.geographic(), 0);
|
||||||
double angle = LtsCoordTrans::LtsCoordinate::angleDegreeUtm2D(lts_ul, lts_2);
|
double angle = LtsCoordTrans::LtsCoordinate::angleDegreeUtm2D(lts_ul, lts_2);
|
||||||
QVERIFY2(qFuzzyCompare(angle, 90.0), "angleUtm2D 1 failed");
|
QVERIFY2(qFuzzyCompare(angle, 90.0), "angleUtm2D 1 failed");
|
||||||
@@ -612,7 +572,8 @@ void UnitTestCoordinate::test_coordinate_angle()
|
|||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
const LtsCoordTrans::UtmCoordinate &utm_2 = LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32 U PD 70000 09000"));
|
const LtsCoordTrans::UtmCoordinate& utm_2 =
|
||||||
|
LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32 U PD 70000 09000"));
|
||||||
const LtsCoordTrans::LtsCoordinate lts_2(utm_2.geographic(), 0);
|
const LtsCoordTrans::LtsCoordinate lts_2(utm_2.geographic(), 0);
|
||||||
double angle = LtsCoordTrans::LtsCoordinate::angleDegreeUtm2D(lts_ul, lts_2);
|
double angle = LtsCoordTrans::LtsCoordinate::angleDegreeUtm2D(lts_ul, lts_2);
|
||||||
QVERIFY2(qFuzzyCompare(angle, 180.0), "angleUtm2D 1 failed");
|
QVERIFY2(qFuzzyCompare(angle, 180.0), "angleUtm2D 1 failed");
|
||||||
@@ -620,15 +581,16 @@ void UnitTestCoordinate::test_coordinate_angle()
|
|||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
const LtsCoordTrans::UtmCoordinate &utm_2 = LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32 U PD 69000 10000"));
|
const LtsCoordTrans::UtmCoordinate& utm_2 =
|
||||||
|
LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32 U PD 69000 10000"));
|
||||||
const LtsCoordTrans::LtsCoordinate lts_2(utm_2.geographic(), 0);
|
const LtsCoordTrans::LtsCoordinate lts_2(utm_2.geographic(), 0);
|
||||||
double angle = LtsCoordTrans::LtsCoordinate::angleDegreeUtm2D(lts_ul, lts_2);
|
double angle = LtsCoordTrans::LtsCoordinate::angleDegreeUtm2D(lts_ul, lts_2);
|
||||||
QVERIFY2(qFuzzyCompare(angle, 270.0), "angleUtm2D 1 failed");
|
QVERIFY2(qFuzzyCompare(angle, 270.0), "angleUtm2D 1 failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
const LtsCoordTrans::UtmCoordinate &utm_or = LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32 U PD 71000 12000"));
|
const LtsCoordTrans::UtmCoordinate& utm_or =
|
||||||
|
LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32 U PD 71000 12000"));
|
||||||
const LtsCoordTrans::LtsCoordinate lts_or(utm_or.geographic(), 0);
|
const LtsCoordTrans::LtsCoordinate lts_or(utm_or.geographic(), 0);
|
||||||
double angle = LtsCoordTrans::LtsCoordinate::angleDegreeUtm2D(lts_ul, lts_or);
|
double angle = LtsCoordTrans::LtsCoordinate::angleDegreeUtm2D(lts_ul, lts_or);
|
||||||
|
|
||||||
@@ -644,13 +606,15 @@ void UnitTestCoordinate::test_coordinate_cont()
|
|||||||
stdVec.push_back(Core::GeoPosition(0.2, 0.22, 2));
|
stdVec.push_back(Core::GeoPosition(0.2, 0.22, 2));
|
||||||
stdVec.push_back(Core::GeoPosition(0.3, 0.33, 3));
|
stdVec.push_back(Core::GeoPosition(0.3, 0.33, 3));
|
||||||
|
|
||||||
const QVector<LtsCoordTrans::LtsCoordinate> &newCont = LtsCoordTrans::convert<QVector<LtsCoordTrans::LtsCoordinate>>(stdVec);
|
const QVector<LtsCoordTrans::LtsCoordinate>& newCont =
|
||||||
|
LtsCoordTrans::convert<QVector<LtsCoordTrans::LtsCoordinate>>(stdVec);
|
||||||
|
|
||||||
NOTICE_LOG(m_logger) << " newCont.size() = " << newCont.size();
|
NOTICE_LOG(m_logger) << " newCont.size() = " << newCont.size();
|
||||||
QVERIFY2(stdVec.size() == static_cast<size_t>(newCont.size()), "convert failed");
|
QVERIFY2(stdVec.size() == static_cast<size_t>(newCont.size()), "convert failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
using namespace LtsCoordTrans;
|
using namespace LtsCoordTrans;
|
||||||
|
|
||||||
class ParticpantPositionStore
|
class ParticpantPositionStore
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -663,35 +627,20 @@ public:
|
|||||||
m_ltsCoord_NoImplicitCopy.updateGeoPosition(newGeoPos);
|
m_ltsCoord_NoImplicitCopy.updateGeoPosition(newGeoPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
LtsCoordinate getLtsCoord_copy()
|
LtsCoordinate getLtsCoord_copy()
|
||||||
{
|
{
|
||||||
return m_ltsCoord;
|
return m_ltsCoord;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const LtsCoordinateNoImplicitCopy& getLtsCoord_noCopy()
|
const LtsCoordinateNoImplicitCopy& getLtsCoord_noCopy()
|
||||||
{
|
{
|
||||||
return m_ltsCoord_NoImplicitCopy;
|
return m_ltsCoord_NoImplicitCopy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
LtsCoordinate m_ltsCoord;
|
LtsCoordinate m_ltsCoord;
|
||||||
LtsCoordinateNoImplicitCopy m_ltsCoord_NoImplicitCopy;
|
LtsCoordinateNoImplicitCopy m_ltsCoord_NoImplicitCopy;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
void UnitTestCoordinate::test_coordinate_avoid_copy()
|
void UnitTestCoordinate::test_coordinate_avoid_copy()
|
||||||
{
|
{
|
||||||
LtsCoordTrans::LtsCoordinate::resetConversionCounter();
|
LtsCoordTrans::LtsCoordinate::resetConversionCounter();
|
||||||
@@ -699,19 +648,11 @@ void UnitTestCoordinate::test_coordinate_avoid_copy()
|
|||||||
|
|
||||||
ParticpantPositionStore store;
|
ParticpantPositionStore store;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const UtmCoordinate& utmIn = LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32 U PD 70000 10000"));
|
const UtmCoordinate& utmIn = LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32 U PD 70000 10000"));
|
||||||
const LtsCoordinate ltsIn(utmIn.geographic(), 11);
|
const LtsCoordinate ltsIn(utmIn.geographic(), 11);
|
||||||
|
|
||||||
store.getLtsCoord_noCopy().updateGeoPosition(ltsIn.geoPosition());
|
store.getLtsCoord_noCopy().updateGeoPosition(ltsIn.geoPosition());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const LtsCoordinateNoImplicitCopy& justReference = store.getLtsCoord_noCopy();
|
const LtsCoordinateNoImplicitCopy& justReference = store.getLtsCoord_noCopy();
|
||||||
NOTICE_LOG(m_logger) << " justReference = " << justReference.mgrs();
|
NOTICE_LOG(m_logger) << " justReference = " << justReference.mgrs();
|
||||||
|
|
||||||
@@ -721,54 +662,37 @@ void UnitTestCoordinate::test_coordinate_avoid_copy()
|
|||||||
QVERIFY2(qFuzzyCompare(convertedToUtm.y, 5810000.5), "convert failed");
|
QVERIFY2(qFuzzyCompare(convertedToUtm.y, 5810000.5), "convert failed");
|
||||||
QVERIFY2(LtsCoordTrans::LtsCoordinate::getConversionCounter() == 1, "getConversionCounter failed");
|
QVERIFY2(LtsCoordTrans::LtsCoordinate::getConversionCounter() == 1, "getConversionCounter failed");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const LtsCoordTrans::UtmCoordinate& convertedToUtmSecondTry = justReference.utmCoordinate();
|
const LtsCoordTrans::UtmCoordinate& convertedToUtmSecondTry = justReference.utmCoordinate();
|
||||||
Q_UNUSED(convertedToUtmSecondTry)
|
Q_UNUSED(convertedToUtmSecondTry)
|
||||||
QVERIFY2(LtsCoordTrans::LtsCoordinate::getConversionCounter() == 1, "getConversionCounter failed");
|
QVERIFY2(LtsCoordTrans::LtsCoordinate::getConversionCounter() == 1, "getConversionCounter failed");
|
||||||
|
|
||||||
|
|
||||||
std::vector<LtsCoordinateNoImplicitCopy> myVec;
|
std::vector<LtsCoordinateNoImplicitCopy> myVec;
|
||||||
myVec.push_back(justReference);
|
myVec.push_back(justReference);
|
||||||
|
|
||||||
|
|
||||||
const LtsCoordTrans::LtsCoordinateNoImplicitCopy& retrievedUtmRef = myVec.front();
|
const LtsCoordTrans::LtsCoordinateNoImplicitCopy& retrievedUtmRef = myVec.front();
|
||||||
NOTICE_LOG(m_logger) << " retrievedUtm = " << retrievedUtmRef.mgrs();
|
NOTICE_LOG(m_logger) << " retrievedUtm = " << retrievedUtmRef.mgrs();
|
||||||
|
|
||||||
|
|
||||||
QVERIFY2(justReference.mgrs() == retrievedUtmRef.mgrs(), "getConversionCounter failed");
|
QVERIFY2(justReference.mgrs() == retrievedUtmRef.mgrs(), "getConversionCounter failed");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
QVERIFY2(LtsCoordTrans::LtsCoordinate::getConversionCounter() == 1, "getConversionCounter failed");
|
QVERIFY2(LtsCoordTrans::LtsCoordinate::getConversionCounter() == 1, "getConversionCounter failed");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T> void removeItem(T& map, int key)
|
||||||
|
{
|
||||||
|
map.erase(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <> void removeItem(QMap<int, int>& map, int key)
|
||||||
|
{
|
||||||
|
map.remove(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <> void removeItem(QHash<int, int>& map, int key)
|
||||||
|
{
|
||||||
|
map.remove(key);
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T> void test_references(T& map)
|
||||||
void removeItem(T& map, int key) { map.erase(key); }
|
|
||||||
|
|
||||||
|
|
||||||
template <>
|
|
||||||
void removeItem(QMap<int, int>& map, int key) { map.remove(key); }
|
|
||||||
|
|
||||||
|
|
||||||
template <>
|
|
||||||
void removeItem(QHash<int, int>& map, int key) { map.remove(key); }
|
|
||||||
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
void test_references(T& map)
|
|
||||||
{
|
{
|
||||||
for (int i = 2; i < 10; ++i)
|
for (int i = 2; i < 10; ++i)
|
||||||
map[i] = i;
|
map[i] = i;
|
||||||
@@ -789,7 +713,6 @@ void test_references(T& map)
|
|||||||
QVERIFY2(ref7 == 7, "ref failed");
|
QVERIFY2(ref7 == 7, "ref failed");
|
||||||
QVERIFY2(ref8 == 8, "ref failed");
|
QVERIFY2(ref8 == 8, "ref failed");
|
||||||
|
|
||||||
|
|
||||||
removeItem(map, 1);
|
removeItem(map, 1);
|
||||||
removeItem(map, 3);
|
removeItem(map, 3);
|
||||||
removeItem(map, 5);
|
removeItem(map, 5);
|
||||||
@@ -804,7 +727,6 @@ void test_references(T& map)
|
|||||||
QVERIFY2(ref8 == 8, "ref failed");
|
QVERIFY2(ref8 == 8, "ref failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
map[0] = 0;
|
map[0] = 0;
|
||||||
map[1] = 1;
|
map[1] = 1;
|
||||||
const int& ref0 = map[0];
|
const int& ref0 = map[0];
|
||||||
@@ -822,20 +744,11 @@ void test_references(T& map)
|
|||||||
QVERIFY2(ref7 == 7, "ref failed");
|
QVERIFY2(ref7 == 7, "ref failed");
|
||||||
QVERIFY2(ref8 == 8, "ref failed");
|
QVERIFY2(ref8 == 8, "ref failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnitTestCoordinate::test_container_references()
|
void UnitTestCoordinate::test_container_references()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
std::unordered_map<int, int> std_unordered_map;
|
std::unordered_map<int, int> std_unordered_map;
|
||||||
test_references(std_unordered_map);
|
test_references(std_unordered_map);
|
||||||
@@ -854,10 +767,6 @@ void UnitTestCoordinate::test_container_references()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void UnitTestCoordinate::test_coordVector()
|
void UnitTestCoordinate::test_coordVector()
|
||||||
{
|
{
|
||||||
std::vector<Core::GeoPosition> geoVec;
|
std::vector<Core::GeoPosition> geoVec;
|
||||||
@@ -882,74 +791,65 @@ void UnitTestCoordinate::test_coordVector()
|
|||||||
{
|
{
|
||||||
const std::vector<LtsCoordTrans::UtmCoordinate>& utmVec = coordVec.toStdUtmCoord(32);
|
const std::vector<LtsCoordTrans::UtmCoordinate>& utmVec = coordVec.toStdUtmCoord(32);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
QVERIFY2(utmVec.size() == 3, "size failed");
|
QVERIFY2(utmVec.size() == 3, "size failed");
|
||||||
QVERIFY2(utmVec.front().mgrs() == QStringLiteral("32U LB 00001 50001"), "mgrs failed");
|
QVERIFY2(utmVec.front().mgrs() == QStringLiteral("32U LB 00001 50001"), "mgrs failed");
|
||||||
QVERIFY2(utmVec.back().mgrs() == QStringLiteral("32U LB 00003 50001"), "mgrs failed");
|
QVERIFY2(utmVec.back().mgrs() == QStringLiteral("32U LB 00003 50001"), "mgrs failed");
|
||||||
QVERIFY2(LtsCoordTrans::getConversionCounter_UTMUPS_Forward() - cnt == 3, "getConversionCounterUTMUPS_Forward failed");
|
QVERIFY2(LtsCoordTrans::getConversionCounter_UTMUPS_Forward() - cnt == 3,
|
||||||
|
"getConversionCounterUTMUPS_Forward failed");
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
const std::vector<LtsCoordTrans::UtmCoordinate>& utmVec = coordVec.toStdUtmCoord(32);
|
const std::vector<LtsCoordTrans::UtmCoordinate>& utmVec = coordVec.toStdUtmCoord(32);
|
||||||
QVERIFY2(utmVec.size() == 3, "size failed");
|
QVERIFY2(utmVec.size() == 3, "size failed");
|
||||||
QVERIFY2(utmVec.front().mgrs() == QStringLiteral("32U LB 00001 50001"), "mgrs failed");
|
QVERIFY2(utmVec.front().mgrs() == QStringLiteral("32U LB 00001 50001"), "mgrs failed");
|
||||||
QVERIFY2(utmVec.back().mgrs() == QStringLiteral("32U LB 00003 50001"), "mgrs failed");
|
QVERIFY2(utmVec.back().mgrs() == QStringLiteral("32U LB 00003 50001"), "mgrs failed");
|
||||||
QVERIFY2(LtsCoordTrans::getConversionCounter_UTMUPS_Forward() - cnt == 3, "getConversionCounterUTMUPS_Forward failed");
|
QVERIFY2(LtsCoordTrans::getConversionCounter_UTMUPS_Forward() - cnt == 3,
|
||||||
|
"getConversionCounterUTMUPS_Forward failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const std::vector<LtsCoordTrans::UtmCoordinate>& utmVec = coordVec.toStdUtmCoord(31);
|
const std::vector<LtsCoordTrans::UtmCoordinate>& utmVec = coordVec.toStdUtmCoord(31);
|
||||||
QVERIFY2(utmVec.size() == 3, "size failed");
|
QVERIFY2(utmVec.size() == 3, "size failed");
|
||||||
QVERIFY2(LtsCoordTrans::getConversionCounter_UTMUPS_Forward() - cnt == 6, "getConversionCounterUTMUPS_Forward failed");
|
QVERIFY2(LtsCoordTrans::getConversionCounter_UTMUPS_Forward() - cnt == 6,
|
||||||
|
"getConversionCounterUTMUPS_Forward failed");
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
const std::vector<LtsCoordTrans::UtmCoordinate>& utmVec = coordVec.toStdUtmCoord(31);
|
const std::vector<LtsCoordTrans::UtmCoordinate>& utmVec = coordVec.toStdUtmCoord(31);
|
||||||
QVERIFY2(utmVec.size() == 3, "size failed");
|
QVERIFY2(utmVec.size() == 3, "size failed");
|
||||||
QVERIFY2(LtsCoordTrans::getConversionCounter_UTMUPS_Forward() - cnt == 6, "getConversionCounterUTMUPS_Forward failed");
|
QVERIFY2(LtsCoordTrans::getConversionCounter_UTMUPS_Forward() - cnt == 6,
|
||||||
|
"getConversionCounterUTMUPS_Forward failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
const QVector<LtsCoordTrans::UtmCoordinate>& utmVec = coordVec.toQVectorUtmCoord(32);
|
const QVector<LtsCoordTrans::UtmCoordinate>& utmVec = coordVec.toQVectorUtmCoord(32);
|
||||||
QVERIFY2(utmVec.size() == 3, "size failed");
|
QVERIFY2(utmVec.size() == 3, "size failed");
|
||||||
QVERIFY2(utmVec.front().mgrs() == QStringLiteral("32U LB 00001 50001"), "mgrs failed");
|
QVERIFY2(utmVec.front().mgrs() == QStringLiteral("32U LB 00001 50001"), "mgrs failed");
|
||||||
QVERIFY2(utmVec.back().mgrs() == QStringLiteral("32U LB 00003 50001"), "mgrs failed");
|
QVERIFY2(utmVec.back().mgrs() == QStringLiteral("32U LB 00003 50001"), "mgrs failed");
|
||||||
QVERIFY2(LtsCoordTrans::getConversionCounter_UTMUPS_Forward() - cnt == 6, "getConversionCounterUTMUPS_Forward failed");
|
QVERIFY2(LtsCoordTrans::getConversionCounter_UTMUPS_Forward() - cnt == 6,
|
||||||
|
"getConversionCounterUTMUPS_Forward failed");
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
const QVector<LtsCoordTrans::UtmCoordinate>& utmVec = coordVec.toQVectorUtmCoord(32);
|
const QVector<LtsCoordTrans::UtmCoordinate>& utmVec = coordVec.toQVectorUtmCoord(32);
|
||||||
QVERIFY2(utmVec.size() == 3, "size failed");
|
QVERIFY2(utmVec.size() == 3, "size failed");
|
||||||
QVERIFY2(utmVec.front().mgrs() == QStringLiteral("32U LB 00001 50001"), "mgrs failed");
|
QVERIFY2(utmVec.front().mgrs() == QStringLiteral("32U LB 00001 50001"), "mgrs failed");
|
||||||
QVERIFY2(utmVec.back().mgrs() == QStringLiteral("32U LB 00003 50001"), "mgrs failed");
|
QVERIFY2(utmVec.back().mgrs() == QStringLiteral("32U LB 00003 50001"), "mgrs failed");
|
||||||
QVERIFY2(LtsCoordTrans::getConversionCounter_UTMUPS_Forward() - cnt == 6, "getConversionCounterUTMUPS_Forward failed");
|
QVERIFY2(LtsCoordTrans::getConversionCounter_UTMUPS_Forward() - cnt == 6,
|
||||||
|
"getConversionCounterUTMUPS_Forward failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
const QVector<QPointF>& utmVec = coordVec.toQVectorQPointF(32);
|
const QVector<QPointF>& utmVec = coordVec.toQVectorQPointF(32);
|
||||||
QVERIFY2(utmVec.size() == 3, "size failed");
|
QVERIFY2(utmVec.size() == 3, "size failed");
|
||||||
QVERIFY2(LtsCoordTrans::getConversionCounter_UTMUPS_Forward() - cnt == 6, "getConversionCounterUTMUPS_Forward failed");
|
QVERIFY2(LtsCoordTrans::getConversionCounter_UTMUPS_Forward() - cnt == 6,
|
||||||
|
"getConversionCounterUTMUPS_Forward failed");
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
const QVector<LtsCoordTrans::UtmCoordinate>& utmVec = coordVec.toQVectorUtmCoord(32);
|
const QVector<LtsCoordTrans::UtmCoordinate>& utmVec = coordVec.toQVectorUtmCoord(32);
|
||||||
QVERIFY2(utmVec.size() == 3, "size failed");
|
QVERIFY2(utmVec.size() == 3, "size failed");
|
||||||
QVERIFY2(LtsCoordTrans::getConversionCounter_UTMUPS_Forward() - cnt == 6, "getConversionCounterUTMUPS_Forward failed");
|
QVERIFY2(LtsCoordTrans::getConversionCounter_UTMUPS_Forward() - cnt == 6,
|
||||||
|
"getConversionCounterUTMUPS_Forward failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
NGLCoreApplication app(argc, argv);
|
NGLCoreApplication app(argc, argv);
|
||||||
@@ -959,7 +859,6 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
int ret = QTest::qExec(&tc, argc, argv);
|
int ret = QTest::qExec(&tc, argc, argv);
|
||||||
|
|
||||||
|
|
||||||
if (s_eleMgr)
|
if (s_eleMgr)
|
||||||
{
|
{
|
||||||
s_eleMgr->cleanupAll();
|
s_eleMgr->cleanupAll();
|
||||||
@@ -967,5 +866,3 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Executable → Regular
+4
-29
@@ -1,23 +1,15 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <QObject>
|
|
||||||
|
|
||||||
#include <LtsElevation/lts_elevation_manager.h>
|
|
||||||
|
|
||||||
#include <ElevationMap/elevation_map_manager.h>
|
#include <ElevationMap/elevation_map_manager.h>
|
||||||
|
#include <LtsElevation/lts_elevation_manager.h>
|
||||||
#include <QCoreApplication>
|
|
||||||
#include <QtTest/QTest>
|
|
||||||
#include <NGLLogger/INGLLogger.h>
|
#include <NGLLogger/INGLLogger.h>
|
||||||
|
#include <QCoreApplication>
|
||||||
|
#include <QObject>
|
||||||
|
#include <QtTest/QTest>
|
||||||
|
|
||||||
using LOGGER_T = NGL::INGLLogger&;
|
using LOGGER_T = NGL::INGLLogger&;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class UnitTestCoordinate : public QObject
|
class UnitTestCoordinate : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -25,20 +17,12 @@ class UnitTestCoordinate : public QObject
|
|||||||
public:
|
public:
|
||||||
UnitTestCoordinate();
|
UnitTestCoordinate();
|
||||||
|
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void initTestCase();
|
void initTestCase();
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void test_NaN();
|
void test_NaN();
|
||||||
|
|
||||||
void test_coordinate_simple1();
|
void test_coordinate_simple1();
|
||||||
@@ -68,18 +52,9 @@ private Q_SLOTS:
|
|||||||
|
|
||||||
void test_coordinate_avoid_copy();
|
void test_coordinate_avoid_copy();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void test_container_references();
|
void test_container_references();
|
||||||
void test_coordVector();
|
void test_coordVector();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
NGL::INGLLogger& m_logger;
|
NGL::INGLLogger& m_logger;
|
||||||
};
|
};
|
||||||
Executable → Regular
+1
-22
@@ -1,7 +1,5 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "lts_coord_vector.h"
|
#include "lts_coord_vector.h"
|
||||||
|
|
||||||
namespace LtsCoordTrans
|
namespace LtsCoordTrans
|
||||||
@@ -10,7 +8,6 @@ namespace LtsCoordTrans
|
|||||||
LtsCoordVector::LtsCoordVector(const std::vector<Core::GeoPosition>& geo_coordinates)
|
LtsCoordVector::LtsCoordVector(const std::vector<Core::GeoPosition>& geo_coordinates)
|
||||||
: m_geo_coordinates(geo_coordinates)
|
: m_geo_coordinates(geo_coordinates)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<UtmCoordinate>& LtsCoordVector::toStdUtmCoord(int zone) const
|
const std::vector<UtmCoordinate>& LtsCoordVector::toStdUtmCoord(int zone) const
|
||||||
@@ -45,10 +42,6 @@ void LtsCoordVector::convertGeoToQVectorUtm(int zone) const
|
|||||||
if (it != m_utmMapQVector.end())
|
if (it != m_utmMapQVector.end())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
convertGeoToStdUtm(zone);
|
convertGeoToStdUtm(zone);
|
||||||
QVector<LtsCoordTrans::UtmCoordinate>& utmVectorRef = m_utmMapQVector[zone];
|
QVector<LtsCoordTrans::UtmCoordinate>& utmVectorRef = m_utmMapQVector[zone];
|
||||||
utmVectorRef.clear();
|
utmVectorRef.clear();
|
||||||
@@ -73,18 +66,4 @@ void LtsCoordVector::convertGeoToQVectorQPointF(int zone) const
|
|||||||
QVectorQPointFRef.push_back(QPointF(utmCoord.x, utmCoord.y));
|
QVectorQPointFRef.push_back(QPointF(utmCoord.x, utmCoord.y));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace LtsCoordTrans
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Executable → Regular
+13
-33
@@ -1,57 +1,47 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "ltscoordinate_export.h"
|
#include "ltscoordinate_export.h"
|
||||||
#include <utility>
|
|
||||||
|
|
||||||
#include <Core/core.hpp>
|
#include <Core/core.hpp>
|
||||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||||
|
#include <QDebug>
|
||||||
#include <unordered_map>
|
|
||||||
#include <QPointF>
|
#include <QPointF>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
#include <iosfwd>
|
#include <iosfwd>
|
||||||
|
#include <unordered_map>
|
||||||
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
namespace LtsCoordTrans
|
namespace LtsCoordTrans
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class LTSCOORDINATE_EXPORT LtsCoordVector
|
class LTSCOORDINATE_EXPORT LtsCoordVector
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
explicit LtsCoordVector(const std::vector<Core::GeoPosition>& geo_coordinates);
|
explicit LtsCoordVector(const std::vector<Core::GeoPosition>& geo_coordinates);
|
||||||
|
|
||||||
|
int size() const
|
||||||
|
{
|
||||||
|
return m_geo_coordinates.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::vector<Core::GeoPosition>& geoPosition() const
|
||||||
int size() const { return m_geo_coordinates.size() ; }
|
{
|
||||||
const std::vector<Core::GeoPosition> &geoPosition() const { return m_geo_coordinates; }
|
return m_geo_coordinates;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const std::vector<LtsCoordTrans::UtmCoordinate>& toStdUtmCoord(int zone) const;
|
const std::vector<LtsCoordTrans::UtmCoordinate>& toStdUtmCoord(int zone) const;
|
||||||
const QVector<LtsCoordTrans::UtmCoordinate>& toQVectorUtmCoord(int zone) const;
|
const QVector<LtsCoordTrans::UtmCoordinate>& toQVectorUtmCoord(int zone) const;
|
||||||
const QVector<QPointF>& toQVectorQPointF(int zone) const;
|
const QVector<QPointF>& toQVectorQPointF(int zone) const;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void convertGeoToStdUtm(int zone) const;
|
void convertGeoToStdUtm(int zone) const;
|
||||||
void convertGeoToQVectorUtm(int zone) const;
|
void convertGeoToQVectorUtm(int zone) const;
|
||||||
void convertGeoToQVectorQPointF(int zone) const;
|
void convertGeoToQVectorQPointF(int zone) const;
|
||||||
|
|
||||||
template<typename T>
|
template <typename T> void convertGeoToUtmInternal(int zone, T& utmVectorRef) const
|
||||||
void convertGeoToUtmInternal(int zone, T &utmVectorRef) const
|
|
||||||
{
|
{
|
||||||
|
|
||||||
utmVectorRef.clear();
|
utmVectorRef.clear();
|
||||||
@@ -64,19 +54,9 @@ protected:
|
|||||||
protected:
|
protected:
|
||||||
std::vector<Core::GeoPosition> m_geo_coordinates;
|
std::vector<Core::GeoPosition> m_geo_coordinates;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
mutable std::unordered_map<int, std::vector<LtsCoordTrans::UtmCoordinate>> m_utmMapStd;
|
mutable std::unordered_map<int, std::vector<LtsCoordTrans::UtmCoordinate>> m_utmMapStd;
|
||||||
mutable std::unordered_map<int, QVector<LtsCoordTrans::UtmCoordinate>> m_utmMapQVector;
|
mutable std::unordered_map<int, QVector<LtsCoordTrans::UtmCoordinate>> m_utmMapQVector;
|
||||||
mutable std::unordered_map<int, QVector<QPointF>> m_utmMapQVectorQPointF;
|
mutable std::unordered_map<int, QVector<QPointF>> m_utmMapQVectorQPointF;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace LtsCoordTrans
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Executable → Regular
+7
-43
@@ -1,8 +1,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "lts_coordinate.h"
|
#include "lts_coordinate.h"
|
||||||
|
|
||||||
#include <QLineF>
|
#include <QLineF>
|
||||||
|
|
||||||
namespace LtsCoordTrans
|
namespace LtsCoordTrans
|
||||||
@@ -10,12 +9,8 @@ namespace LtsCoordTrans
|
|||||||
|
|
||||||
static long s_conversion_counter = 0;
|
static long s_conversion_counter = 0;
|
||||||
|
|
||||||
|
|
||||||
std::function<double(double, double, double, bool*)> LtsCoordinate::m_getElevationCB;
|
std::function<double(double, double, double, bool*)> LtsCoordinate::m_getElevationCB;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void LtsCoordinate::setElevationCallback(const elevationCbFunc& elevationCB)
|
void LtsCoordinate::setElevationCallback(const elevationCbFunc& elevationCB)
|
||||||
{
|
{
|
||||||
m_getElevationCB = elevationCB;
|
m_getElevationCB = elevationCB;
|
||||||
@@ -29,8 +24,6 @@ bool LtsCoordinate::hasElevationCallback()
|
|||||||
double LtsCoordinate::elevationAt(double defaultElevation, bool* bIsCovered) const
|
double LtsCoordinate::elevationAt(double defaultElevation, bool* bIsCovered) const
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (!bIsCovered)
|
if (!bIsCovered)
|
||||||
if (!std::isnan(m_elevation))
|
if (!std::isnan(m_elevation))
|
||||||
return m_elevation;
|
return m_elevation;
|
||||||
@@ -52,12 +45,7 @@ double LtsCoordinate::elevationAt(const LtsCoordinate &coordinate, double defaul
|
|||||||
void LtsCoordinate::replaceZValueByElevationIfValue(double zValueToBeReplaced, double defaultElevation)
|
void LtsCoordinate::replaceZValueByElevationIfValue(double zValueToBeReplaced, double defaultElevation)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if ((std::isnan(zValueToBeReplaced) && std::isnan(m_geo.z())) || qFuzzyCompare(m_geo.z(), zValueToBeReplaced))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ((std::isnan(zValueToBeReplaced) && std::isnan(m_geo.z())) ||
|
|
||||||
qFuzzyCompare(m_geo.z(), zValueToBeReplaced))
|
|
||||||
setZValueAccordingElevation(defaultElevation);
|
setZValueAccordingElevation(defaultElevation);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,25 +58,6 @@ double LtsCoordinate::angleDegreeUtm2D(const LtsCoordinate &coord1, const LtsCoo
|
|||||||
QLineF poly(QPointF(), offsetUtm);
|
QLineF poly(QPointF(), offsetUtm);
|
||||||
const double angle = poly.angle();
|
const double angle = poly.angle();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return fmod(angle + 90.0, 360);
|
return fmod(angle + 90.0, 360);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,7 +107,6 @@ QString LtsCoordinate::mgrsWithZ(int prec, bool withSpaces) const
|
|||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString LtsCoordinate::toString(bool fullAndExpensive) const
|
QString LtsCoordinate::toString(bool fullAndExpensive) const
|
||||||
{
|
{
|
||||||
if (fullAndExpensive)
|
if (fullAndExpensive)
|
||||||
@@ -147,12 +115,11 @@ QString LtsCoordinate::toString(bool fullAndExpensive) const
|
|||||||
elevationAt();
|
elevationAt();
|
||||||
}
|
}
|
||||||
std::ostringstream stream;
|
std::ostringstream stream;
|
||||||
stream << "LtsCoordinate(m_geo=" << m_geo
|
stream << "LtsCoordinate(m_geo=" << m_geo << ", m_utm2D.x " << m_utm2D.x << ", m_utm2D.y " << m_utm2D.y
|
||||||
<< ", m_utm2D.x " << m_utm2D.x << ", m_utm2D.y " << m_utm2D.y << ", m_utm2D.zone " << m_utm2D.zone;
|
<< ", m_utm2D.zone " << m_utm2D.zone;
|
||||||
if (!qFuzzyIsNull(m_utm2D.x) || !qFuzzyIsNull(m_utm2D.y))
|
if (!qFuzzyIsNull(m_utm2D.x) || !qFuzzyIsNull(m_utm2D.y))
|
||||||
stream << ", m_utm2D.mgrs '" << m_utm2D.mgrs().toUtf8().constData() << "'";
|
stream << ", m_utm2D.mgrs '" << m_utm2D.mgrs().toUtf8().constData() << "'";
|
||||||
stream << ", elevation " << std::fixed << std::setprecision(3) << m_elevation
|
stream << ", elevation " << std::fixed << std::setprecision(3) << m_elevation << ")";
|
||||||
<< ")";
|
|
||||||
return QString::fromStdString(stream.str());
|
return QString::fromStdString(stream.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,19 +127,16 @@ void LtsCoordinate::resetConversionCounter()
|
|||||||
{
|
{
|
||||||
s_conversion_counter = 0;
|
s_conversion_counter = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
long LtsCoordinate::getConversionCounter()
|
long LtsCoordinate::getConversionCounter()
|
||||||
{
|
{
|
||||||
return s_conversion_counter;
|
return s_conversion_counter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::ostream& operator<<(std::ostream& stream, const LtsCoordinate& value)
|
std::ostream& operator<<(std::ostream& stream, const LtsCoordinate& value)
|
||||||
{
|
{
|
||||||
stream << value.toString().toStdString();
|
stream << value.toString().toStdString();
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace LtsCoordTrans
|
||||||
|
|
||||||
|
|
||||||
Executable → Regular
+96
-167
@@ -1,22 +1,18 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "ltscoordinate_export.h"
|
#include "ltscoordinate_export.h"
|
||||||
#include <utility>
|
|
||||||
|
|
||||||
#include <Core/core.hpp>
|
#include <Core/core.hpp>
|
||||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||||
#include <LtsUtils/LtsUtilsCore/qpoint3d.h>
|
#include <LtsUtils/LtsUtilsCore/qpoint3d.h>
|
||||||
|
|
||||||
#include <QPointF>
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QPointF>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <iosfwd>
|
#include <iosfwd>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
namespace LtsCoordTrans
|
namespace LtsCoordTrans
|
||||||
{
|
{
|
||||||
@@ -24,37 +20,22 @@ namespace LtsCoordTrans
|
|||||||
using UtmCoordinate2D = LtsCoordTrans::UtmCoordinate;
|
using UtmCoordinate2D = LtsCoordTrans::UtmCoordinate;
|
||||||
using QPoint3D = LtsUtils::QPoint3D;
|
using QPoint3D = LtsUtils::QPoint3D;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class LTSCOORDINATE_EXPORT LtsCoordinate
|
class LTSCOORDINATE_EXPORT LtsCoordinate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
explicit LtsCoordinate(double lon = 0, double lat = 0, double z = std::nan(""))
|
explicit LtsCoordinate(double lon = 0, double lat = 0, double z = std::nan(""))
|
||||||
: m_geo(Core::GeoPosition(lon, lat, z))
|
: m_geo(Core::GeoPosition(lon, lat, z))
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
explicit LtsCoordinate(const QPointF& lonLat, double z = std::nan(""))
|
explicit LtsCoordinate(const QPointF& lonLat, double z = std::nan(""))
|
||||||
: m_geo(Core::GeoPosition(lonLat.x(), lonLat.y(), z))
|
: m_geo(Core::GeoPosition(lonLat.x(), lonLat.y(), z))
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
explicit LtsCoordinate(const Core::GeoPosition &geoPos)
|
|
||||||
: m_geo(geoPos)
|
|
||||||
{}
|
|
||||||
|
|
||||||
explicit LtsCoordinate(const Core::GeoPosition2D &geoPos2D)
|
|
||||||
: m_geo(geoPos2D.lon(), geoPos2D.lat(), std::nan(""))
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
explicit LtsCoordinate(const Core::GeoPosition& geoPos) : m_geo(geoPos) {}
|
||||||
|
|
||||||
|
explicit LtsCoordinate(const Core::GeoPosition2D& geoPos2D) : m_geo(geoPos2D.lon(), geoPos2D.lat(), std::nan("")) {}
|
||||||
|
|
||||||
LtsCoordinate(const LtsCoordTrans::UtmCoordinate& utm2D, double zValue) = delete;
|
LtsCoordinate(const LtsCoordTrans::UtmCoordinate& utm2D, double zValue) = delete;
|
||||||
|
|
||||||
@@ -63,13 +44,10 @@ public:
|
|||||||
return LtsCoordinate(lon, lat, z);
|
return LtsCoordinate(lon, lat, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static LtsCoordinate fromUtmCoordinate(const LtsCoordTrans::UtmCoordinate& utm2D, double zValue)
|
static LtsCoordinate fromUtmCoordinate(const LtsCoordTrans::UtmCoordinate& utm2D, double zValue)
|
||||||
{
|
{
|
||||||
Q_ASSERT_X(utm2D.zone > 0, "LtsCoordinate", "zone has to be set");
|
Q_ASSERT_X(utm2D.zone > 0, "LtsCoordinate", "zone has to be set");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const QPointF& geoPnt = utm2D.geographic();
|
const QPointF& geoPnt = utm2D.geographic();
|
||||||
|
|
||||||
return LtsCoordinate(geoPnt.x(), geoPnt.y(), zValue);
|
return LtsCoordinate(geoPnt.x(), geoPnt.y(), zValue);
|
||||||
@@ -82,36 +60,39 @@ public:
|
|||||||
return LtsCoordinate(geoPnt.x(), geoPnt.y(), zValue);
|
return LtsCoordinate(geoPnt.x(), geoPnt.y(), zValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isValid() const
|
||||||
|
{
|
||||||
|
return hasGeo() || hasUtm();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool hasGeo() const
|
||||||
|
{
|
||||||
|
return !(valueIsNullOrNan(m_geo.lon()) || valueIsNullOrNan(m_geo.lat()));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool hasUtm() const
|
||||||
|
{
|
||||||
|
return m_utm2D.isValid();
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool valueIsNullOrNan(double value)
|
||||||
|
{
|
||||||
bool isValid() const { return hasGeo() || hasUtm(); }
|
return qFuzzyIsNull(value) || std::isnan(value);
|
||||||
bool hasGeo() const { return !(valueIsNullOrNan(m_geo.lon()) ||
|
}
|
||||||
valueIsNullOrNan(m_geo.lat())); }
|
|
||||||
bool hasUtm() const { return m_utm2D.isValid(); }
|
|
||||||
|
|
||||||
static bool valueIsNullOrNan(double value) { return qFuzzyIsNull(value) || std::isnan(value); }
|
|
||||||
|
|
||||||
QString mgrs(int prec = 5, bool withSpaces = true) const;
|
QString mgrs(int prec = 5, bool withSpaces = true) const;
|
||||||
QString mgrsWithZ(int prec = 5, bool withSpaces = true) const;
|
QString mgrsWithZ(int prec = 5, bool withSpaces = true) const;
|
||||||
|
|
||||||
QString toString(bool fullAndExpensive = false) const;
|
QString toString(bool fullAndExpensive = false) const;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void resetConversionCounter();
|
static void resetConversionCounter();
|
||||||
static long getConversionCounter();
|
static long getConversionCounter();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const Core::GeoPosition& geoPosition() const
|
const Core::GeoPosition& geoPosition() const
|
||||||
{
|
{
|
||||||
return m_geo;
|
return m_geo;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Core::GeoPosition2D& geoPosition2D() const
|
const Core::GeoPosition2D& geoPosition2D() const
|
||||||
{
|
{
|
||||||
return m_geo;
|
return m_geo;
|
||||||
@@ -124,95 +105,81 @@ public:
|
|||||||
return m_utm2D;
|
return m_utm2D;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double& rz()
|
||||||
|
{
|
||||||
|
return m_geo.z();
|
||||||
|
}
|
||||||
|
|
||||||
double &rz() { return m_geo.z(); }
|
double z() const
|
||||||
double z() const { return m_geo.z(); }
|
{
|
||||||
void setZ(double value) { m_geo.z(value); }
|
return m_geo.z();
|
||||||
|
}
|
||||||
|
|
||||||
|
void setZ(double value)
|
||||||
|
{
|
||||||
|
m_geo.z(value);
|
||||||
|
}
|
||||||
|
|
||||||
LtsCoordTrans::UtmCoordinate utmCoordinateDiffZone(int zone) const
|
LtsCoordTrans::UtmCoordinate utmCoordinateDiffZone(int zone) const
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
m_utm2D_differentZone = LtsCoordTrans::UtmCoordinate::fromGeographic(m_geo.lon(), m_geo.lat(), zone);
|
m_utm2D_differentZone = LtsCoordTrans::UtmCoordinate::fromGeographic(m_geo.lon(), m_geo.lat(), zone);
|
||||||
return m_utm2D_differentZone;
|
return m_utm2D_differentZone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T> T toUtm(int zone = -1) const
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
T toUtm(int zone = -1) const
|
|
||||||
{
|
{
|
||||||
T obj;
|
T obj;
|
||||||
helperToUtm(obj, zone);
|
helperToUtm(obj, zone);
|
||||||
return obj;
|
return obj;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QPointF toUtmPointF() const { return toUtm<QPointF>(); }
|
QPointF toUtmPointF() const
|
||||||
QPoint3D toUtmPoint3D() const { return toUtm<QPoint3D>(); }
|
{
|
||||||
|
return toUtm<QPointF>();
|
||||||
|
}
|
||||||
|
|
||||||
QPointF toGeoPointF() const { return QPointF (m_geo.lon(), m_geo.lat()); }
|
QPoint3D toUtmPoint3D() const
|
||||||
QPoint3D toGeoPoint3D() const { return QPoint3D(m_geo.lon(), m_geo.lat(), m_geo.z() ); }
|
{
|
||||||
|
return toUtm<QPoint3D>();
|
||||||
|
}
|
||||||
|
|
||||||
|
QPointF toGeoPointF() const
|
||||||
|
{
|
||||||
|
return QPointF(m_geo.lon(), m_geo.lat());
|
||||||
|
}
|
||||||
|
|
||||||
|
QPoint3D toGeoPoint3D() const
|
||||||
|
{
|
||||||
|
return QPoint3D(m_geo.lon(), m_geo.lat(), m_geo.z());
|
||||||
|
}
|
||||||
|
|
||||||
UtmCoordinate3D toUtmCoordinate3D() const
|
UtmCoordinate3D toUtmCoordinate3D() const
|
||||||
{
|
{
|
||||||
return UtmCoordinate3D(utmCoordinate(), m_geo.z());
|
return UtmCoordinate3D(utmCoordinate(), m_geo.z());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
using elevationCbFunc = std::function<double(double, double, double, bool*)>;
|
using elevationCbFunc = std::function<double(double, double, double, bool*)>;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void setElevationCallback(const elevationCbFunc& elevationCB);
|
static void setElevationCallback(const elevationCbFunc& elevationCB);
|
||||||
static bool hasElevationCallback();
|
static bool hasElevationCallback();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
double elevationAt(double defaultElevation = 0.0, bool* bIsCovered = nullptr) const;
|
double elevationAt(double defaultElevation = 0.0, bool* bIsCovered = nullptr) const;
|
||||||
void setZValueAccordingElevation(double defaultElevation = 0.0);
|
void setZValueAccordingElevation(double defaultElevation = 0.0);
|
||||||
|
|
||||||
static double elevationAt(const LtsCoordinate &coordinate, double defaultElevation = 0.0, bool *bIsCovered = nullptr);
|
static double elevationAt(const LtsCoordinate& coordinate, double defaultElevation = 0.0,
|
||||||
|
bool* bIsCovered = nullptr);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void replaceZValueByElevationIfValue(double zValueToBeReplaced = std::nan(""), double defaultElevation = 0.0);
|
void replaceZValueByElevationIfValue(double zValueToBeReplaced = std::nan(""), double defaultElevation = 0.0);
|
||||||
|
|
||||||
|
double heightOverElevation() const
|
||||||
|
{
|
||||||
|
return m_geo.z() - elevationAt();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
double heightOverElevation() const { return m_geo.z() - elevationAt(); }
|
|
||||||
|
|
||||||
|
|
||||||
double distanceUtm2D(const LtsCoordinate& other) const
|
double distanceUtm2D(const LtsCoordinate& other) const
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
const LtsCoordTrans::UtmCoordinate& thisUtm2D = utmCoordinate();
|
const LtsCoordTrans::UtmCoordinate& thisUtm2D = utmCoordinate();
|
||||||
const LtsCoordTrans::UtmCoordinate& otherUtm2D = other.utmCoordinateDiffZone(m_utm2D.zone);
|
const LtsCoordTrans::UtmCoordinate& otherUtm2D = other.utmCoordinateDiffZone(m_utm2D.zone);
|
||||||
return LtsCoordTrans::distance(thisUtm2D, otherUtm2D);
|
return LtsCoordTrans::distance(thisUtm2D, otherUtm2D);
|
||||||
@@ -221,7 +188,6 @@ public:
|
|||||||
double distanceUtm3D(const LtsCoordinate& other) const
|
double distanceUtm3D(const LtsCoordinate& other) const
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
const QPoint3D& thisUtm3D = toUtm<QPoint3D>();
|
const QPoint3D& thisUtm3D = toUtm<QPoint3D>();
|
||||||
const QPoint3D& otherUtm3D = other.toUtm<QPoint3D>(m_utm2D.zone);
|
const QPoint3D& otherUtm3D = other.toUtm<QPoint3D>(m_utm2D.zone);
|
||||||
const double dist3D = (thisUtm3D - otherUtm3D).length();
|
const double dist3D = (thisUtm3D - otherUtm3D).length();
|
||||||
@@ -231,39 +197,49 @@ public:
|
|||||||
return dist3D;
|
return dist3D;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static double angleDegreeUtm2D(const LtsCoordinate& coord1, const LtsCoordinate& coord2);
|
static double angleDegreeUtm2D(const LtsCoordinate& coord1, const LtsCoordinate& coord2);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
void clearGeo() const
|
||||||
|
{
|
||||||
|
clearGeoLonLat();
|
||||||
|
m_geo.z(std::nan(""));
|
||||||
|
}
|
||||||
|
|
||||||
void clearGeo() const { clearGeoLonLat(); m_geo.z(std::nan("")); }
|
void clearGeoLonLat() const
|
||||||
void clearGeoLonLat() const { m_geo.lon(0); m_geo.lat(0); }
|
{
|
||||||
void clearUtm() const { m_utm2D = m_utm2D_differentZone = UtmCoordinate2D(); }
|
m_geo.lon(0);
|
||||||
void clearElevation() const { m_elevation = std::nan(""); }
|
m_geo.lat(0);
|
||||||
void clear() const { clearGeo(); clearUtm(); clearElevation(); }
|
}
|
||||||
|
|
||||||
|
void clearUtm() const
|
||||||
|
{
|
||||||
|
m_utm2D = m_utm2D_differentZone = UtmCoordinate2D();
|
||||||
|
}
|
||||||
|
|
||||||
|
void clearElevation() const
|
||||||
|
{
|
||||||
|
m_elevation = std::nan("");
|
||||||
|
}
|
||||||
|
|
||||||
|
void clear() const
|
||||||
|
{
|
||||||
|
clearGeo();
|
||||||
|
clearUtm();
|
||||||
|
clearElevation();
|
||||||
|
}
|
||||||
|
|
||||||
const LtsCoordTrans::UtmCoordinate& utmCoordinateInternal(int zone = -1) const;
|
const LtsCoordTrans::UtmCoordinate& utmCoordinateInternal(int zone = -1) const;
|
||||||
void convertGeoToUtm() const;
|
void convertGeoToUtm() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void helperToUtm(QPointF& pntRef, int zone = -1) const
|
void helperToUtm(QPointF& pntRef, int zone = -1) const
|
||||||
{
|
{
|
||||||
const auto& utmTemp = utmCoordinateInternal(zone);
|
const auto& utmTemp = utmCoordinateInternal(zone);
|
||||||
pntRef.rx() = utmTemp.x;
|
pntRef.rx() = utmTemp.x;
|
||||||
pntRef.ry() = utmTemp.y;
|
pntRef.ry() = utmTemp.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
void helperToUtm(QPoint3D& pntRef, int zone = -1) const
|
void helperToUtm(QPoint3D& pntRef, int zone = -1) const
|
||||||
{
|
{
|
||||||
const auto& utmTemp = utmCoordinateInternal(zone);
|
const auto& utmTemp = utmCoordinateInternal(zone);
|
||||||
@@ -281,48 +257,24 @@ protected:
|
|||||||
static elevationCbFunc m_getElevationCB;
|
static elevationCbFunc m_getElevationCB;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class LTSCOORDINATE_EXPORT LtsCoordinateNoImplicitCopy : public LtsCoordinate
|
class LTSCOORDINATE_EXPORT LtsCoordinateNoImplicitCopy : public LtsCoordinate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using BaseClass = LtsCoordinate;
|
using BaseClass = LtsCoordinate;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
LtsCoordinateNoImplicitCopy() = default;
|
LtsCoordinateNoImplicitCopy() = default;
|
||||||
explicit LtsCoordinateNoImplicitCopy(const LtsCoordinateNoImplicitCopy&) = default;
|
explicit LtsCoordinateNoImplicitCopy(const LtsCoordinateNoImplicitCopy&) = default;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
~LtsCoordinateNoImplicitCopy() = default;
|
~LtsCoordinateNoImplicitCopy() = default;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
explicit LtsCoordinateNoImplicitCopy(const QPointF& lonLat, double z = std::nan(""))
|
explicit LtsCoordinateNoImplicitCopy(const QPointF& lonLat, double z = std::nan(""))
|
||||||
: BaseClass(Core::GeoPosition(lonLat.x(), lonLat.y(), z))
|
: BaseClass(Core::GeoPosition(lonLat.x(), lonLat.y(), z))
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
explicit LtsCoordinateNoImplicitCopy(const Core::GeoPosition &geoPos)
|
|
||||||
: BaseClass(geoPos)
|
|
||||||
{}
|
|
||||||
|
|
||||||
explicit LtsCoordinateNoImplicitCopy(const Core::GeoPosition2D &geoPos2D)
|
|
||||||
: BaseClass(geoPos2D)
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
|
explicit LtsCoordinateNoImplicitCopy(const Core::GeoPosition& geoPos) : BaseClass(geoPos) {}
|
||||||
|
|
||||||
|
explicit LtsCoordinateNoImplicitCopy(const Core::GeoPosition2D& geoPos2D) : BaseClass(geoPos2D) {}
|
||||||
|
|
||||||
void updateGeoPosition(const Core::GeoPosition& geoPos) const
|
void updateGeoPosition(const Core::GeoPosition& geoPos) const
|
||||||
{
|
{
|
||||||
@@ -331,25 +283,7 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <typename T_OUT, typename T_IN> T_OUT convert(const T_IN& contIn)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template<typename T_OUT, typename T_IN>
|
|
||||||
T_OUT convert(const T_IN& contIn)
|
|
||||||
{
|
{
|
||||||
T_OUT out;
|
T_OUT out;
|
||||||
out.reserve(contIn.size());
|
out.reserve(contIn.size());
|
||||||
@@ -358,11 +292,6 @@ T_OUT convert(const T_IN& contIn)
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LTSCOORDINATE_EXPORT std::ostream& operator<<(std::ostream& stream, const LtsCoordinate& value);
|
||||||
|
|
||||||
|
} // namespace LtsCoordTrans
|
||||||
LTSCOORDINATE_EXPORT std::ostream &operator<< (std::ostream &stream,
|
|
||||||
const LtsCoordinate &value);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Executable → Regular
+23
-55
@@ -1,15 +1,12 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "elevation_unit_test.h"
|
#include "elevation_unit_test.h"
|
||||||
|
|
||||||
#include <ElevationMap/elevation_map_manager.h>
|
#include <ElevationMap/elevation_map_manager.h>
|
||||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||||
|
|
||||||
#include <nglapplication/nglcoreapplication.h>
|
|
||||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||||
#include <QtTest/QTest>
|
#include <QtTest/QTest>
|
||||||
|
#include <nglapplication/nglcoreapplication.h>
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(LtsUtils::QPoint3D);
|
Q_DECLARE_METATYPE(LtsUtils::QPoint3D);
|
||||||
Q_DECLARE_METATYPE(LtsElevation::LineOfSight);
|
Q_DECLARE_METATYPE(LtsElevation::LineOfSight);
|
||||||
@@ -19,12 +16,6 @@ Q_DECLARE_METATYPE(LtsElevation::LineOfSight);
|
|||||||
static const int s_id{4711};
|
static const int s_id{4711};
|
||||||
static LtsElevation::LtsElevationManager* s_eleMgr{nullptr};
|
static LtsElevation::LtsElevationManager* s_eleMgr{nullptr};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class MyLtsElevationManagerBootstrap : public LtsElevation::LtsElevationManager
|
class MyLtsElevationManagerBootstrap : public LtsElevation::LtsElevationManager
|
||||||
{
|
{
|
||||||
using BaseClass = LtsElevation::LtsElevationManager;
|
using BaseClass = LtsElevation::LtsElevationManager;
|
||||||
@@ -34,21 +25,16 @@ public:
|
|||||||
{
|
{
|
||||||
return BaseClass::createInstanceUnitTest(id, filePaths_rough_to_fine);
|
return BaseClass::createInstanceUnitTest(id, filePaths_rough_to_fine);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
UnitTestElevation::UnitTestElevation()
|
UnitTestElevation::UnitTestElevation()
|
||||||
: m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("UnitTestElevation"))
|
: m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("UnitTestElevation"))
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void UnitTestElevation::initTestCase()
|
void UnitTestElevation::initTestCase()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
QString filePath(QStringLiteral("/usr/share/arcgis/resources/elevation/Altmark_dt1.tif"));
|
QString filePath(QStringLiteral("/usr/share/arcgis/resources/elevation/Altmark_dt1.tif"));
|
||||||
|
|
||||||
s_eleMgr = MyLtsElevationManagerBootstrap::createInstanceUnitTest(s_id, {filePath});
|
s_eleMgr = MyLtsElevationManagerBootstrap::createInstanceUnitTest(s_id, {filePath});
|
||||||
@@ -56,7 +42,6 @@ void UnitTestElevation::initTestCase()
|
|||||||
const bool bIsValid = s_eleMgr->isValid();
|
const bool bIsValid = s_eleMgr->isValid();
|
||||||
std::cerr << "myBootstrapMgr->isValid() 1 = " << bIsValid << std::endl;
|
std::cerr << "myBootstrapMgr->isValid() 1 = " << bIsValid << std::endl;
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
s_eleMgr->waitForInitialization();
|
s_eleMgr->waitForInitialization();
|
||||||
const bool bIsValid = s_eleMgr->isValid();
|
const bool bIsValid = s_eleMgr->isValid();
|
||||||
@@ -69,22 +54,18 @@ void UnitTestElevation::init()
|
|||||||
QVERIFY2(s_eleMgr, "static LtsElevationManager does not exist");
|
QVERIFY2(s_eleMgr, "static LtsElevationManager does not exist");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void UnitTestElevation::test_elevation_data()
|
void UnitTestElevation::test_elevation_data()
|
||||||
{
|
{
|
||||||
QTest::addColumn<QPointF>("lonLat");
|
QTest::addColumn<QPointF>("lonLat");
|
||||||
QTest::addColumn<double>("elevationRef");
|
QTest::addColumn<double>("elevationRef");
|
||||||
|
|
||||||
|
QTest::newRow("elevation 1 ")
|
||||||
|
<< LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 70000 10000")).geographic() << 75.0;
|
||||||
|
QTest::newRow("elevation 2 ")
|
||||||
|
<< LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 72000 13000")).geographic() << 80.0;
|
||||||
|
|
||||||
QTest::newRow("elevation 1 ") << LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 70000 10000")).geographic() << 75.0;
|
QTest::newRow("elevation 3 ")
|
||||||
QTest::newRow("elevation 2 ") << LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 72000 13000")).geographic() << 80.0;
|
<< LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 76925 18625")).geographic() << 92.0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
QTest::newRow("elevation 3 ") << LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 76925 18625")).geographic() << 92.0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnitTestElevation::test_elevation()
|
void UnitTestElevation::test_elevation()
|
||||||
@@ -135,9 +116,6 @@ void UnitTestElevation::test_elevation_defaultValue()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void UnitTestElevation::test_lineOfSightCalculation_data()
|
void UnitTestElevation::test_lineOfSightCalculation_data()
|
||||||
{
|
{
|
||||||
QTest::addColumn<QPointF>("startGeo2D");
|
QTest::addColumn<QPointF>("startGeo2D");
|
||||||
@@ -146,35 +124,35 @@ void UnitTestElevation::test_lineOfSightCalculation_data()
|
|||||||
QTest::addColumn<double>("endObjH");
|
QTest::addColumn<double>("endObjH");
|
||||||
QTest::addColumn<LtsElevation::LineOfSight>("expectedResult");
|
QTest::addColumn<LtsElevation::LineOfSight>("expectedResult");
|
||||||
|
|
||||||
|
QTest::newRow("losDataset 1 ")
|
||||||
|
<< LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 60000 10000")).geographic() << 1.0
|
||||||
|
|
||||||
QTest::newRow("losDataset 1 ") << LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 60000 10000")).geographic() << 1.0
|
|
||||||
<< LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 60000 60000")).geographic() << 1.0
|
<< LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 60000 60000")).geographic() << 1.0
|
||||||
<< LtsElevation::LineOfSight::LOS_ERROR;
|
<< LtsElevation::LineOfSight::LOS_ERROR;
|
||||||
|
|
||||||
|
QTest::newRow("losDataset 2 ")
|
||||||
QTest::newRow("losDataset 2 ") << LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 77200 17600")).geographic() << 1.0
|
<< LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 77200 17600")).geographic() << 1.0
|
||||||
<< LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 77600 17600")).geographic() << 1.0
|
<< LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 77600 17600")).geographic() << 1.0
|
||||||
<< LtsElevation::LineOfSight::LOS_INVISIBLE;
|
<< LtsElevation::LineOfSight::LOS_INVISIBLE;
|
||||||
|
|
||||||
|
QTest::newRow("losDataset 3 ")
|
||||||
QTest::newRow("losDataset 3 ") << LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 77200 17600")).geographic() << 20.0
|
<< LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 77200 17600")).geographic() << 20.0
|
||||||
<< LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 77600 17600")).geographic() << 20.0
|
<< LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 77600 17600")).geographic() << 20.0
|
||||||
<< LtsElevation::LineOfSight::LOS_VISIBLE;
|
<< LtsElevation::LineOfSight::LOS_VISIBLE;
|
||||||
|
|
||||||
|
QTest::newRow("losDataset 4 ")
|
||||||
QTest::newRow("losDataset 4 ") << LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 77200 17600")).geographic() << -1.0
|
<< LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 77200 17600")).geographic() << -1.0
|
||||||
<< LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 77600 17600")).geographic() << 1.0
|
<< LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 77600 17600")).geographic() << 1.0
|
||||||
<< LtsElevation::LineOfSight::LOS_ERROR;
|
<< LtsElevation::LineOfSight::LOS_ERROR;
|
||||||
QTest::newRow("losDataset 5 ") << LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 77200 17600")).geographic() << 1.0
|
QTest::newRow("losDataset 5 ")
|
||||||
|
<< LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 77200 17600")).geographic() << 1.0
|
||||||
<< LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 77600 17600")).geographic() << -1.0
|
<< LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 77600 17600")).geographic() << -1.0
|
||||||
<< LtsElevation::LineOfSight::LOS_ERROR;
|
<< LtsElevation::LineOfSight::LOS_ERROR;
|
||||||
QTest::newRow("losDataset 6 ") << LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 77200 17600")).geographic() << 0.0
|
QTest::newRow("losDataset 6 ")
|
||||||
|
<< LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 77200 17600")).geographic() << 0.0
|
||||||
<< LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 77600 17600")).geographic() << 0.0
|
<< LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 77600 17600")).geographic() << 0.0
|
||||||
<< LtsElevation::LineOfSight::LOS_INVISIBLE;
|
<< LtsElevation::LineOfSight::LOS_INVISIBLE;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnitTestElevation::test_lineOfSightCalculation()
|
void UnitTestElevation::test_lineOfSightCalculation()
|
||||||
{
|
{
|
||||||
QFETCH(QPointF, startGeo2D);
|
QFETCH(QPointF, startGeo2D);
|
||||||
@@ -195,20 +173,13 @@ void UnitTestElevation::test_lineOfSightCalculation()
|
|||||||
NOTICE_LOG(m_logger) << "los = " << los;
|
NOTICE_LOG(m_logger) << "los = " << los;
|
||||||
|
|
||||||
{
|
{
|
||||||
LtsElevation::LineOfSight los2 = s_eleMgr->lineOfSightCalculation(startGeo2D, startObjH,
|
LtsElevation::LineOfSight los2 = s_eleMgr->lineOfSightCalculation(startGeo2D, startObjH, endGeo2D, endObjH);
|
||||||
endGeo2D, endObjH);
|
|
||||||
QVERIFY2(los == los2, " got different lineOfSightCalculation result");
|
QVERIFY2(los == los2, " got different lineOfSightCalculation result");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
QVERIFY2(los == expectedResult, " got lineOfSightCalculation result");
|
QVERIFY2(los == expectedResult, " got lineOfSightCalculation result");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
NGLCoreApplication app(argc, argv);
|
NGLCoreApplication app(argc, argv);
|
||||||
@@ -218,7 +189,6 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
int ret = QTest::qExec(&tc, argc, argv);
|
int ret = QTest::qExec(&tc, argc, argv);
|
||||||
|
|
||||||
|
|
||||||
if (s_eleMgr)
|
if (s_eleMgr)
|
||||||
{
|
{
|
||||||
s_eleMgr->cleanupAll();
|
s_eleMgr->cleanupAll();
|
||||||
@@ -226,5 +196,3 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Executable → Regular
+4
-27
@@ -1,23 +1,16 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
#include <LtsElevation/lts_elevation_manager.h>
|
|
||||||
|
|
||||||
#include <ElevationMap/elevation_map_manager.h>
|
#include <ElevationMap/elevation_map_manager.h>
|
||||||
|
#include <LtsElevation/lts_elevation_manager.h>
|
||||||
#include <QCoreApplication>
|
|
||||||
#include <QtTest/QTest>
|
|
||||||
#include <NGLLogger/INGLLogger.h>
|
#include <NGLLogger/INGLLogger.h>
|
||||||
|
#include <QCoreApplication>
|
||||||
|
#include <QObject>
|
||||||
|
#include <QtTest/QTest>
|
||||||
|
|
||||||
using LOGGER_T = NGL::INGLLogger&;
|
using LOGGER_T = NGL::INGLLogger&;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class UnitTestElevation : public QObject
|
class UnitTestElevation : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -25,21 +18,12 @@ class UnitTestElevation : public QObject
|
|||||||
public:
|
public:
|
||||||
UnitTestElevation();
|
UnitTestElevation();
|
||||||
|
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void initTestCase();
|
void initTestCase();
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void test_elevation_data();
|
void test_elevation_data();
|
||||||
void test_elevation();
|
void test_elevation();
|
||||||
|
|
||||||
@@ -49,13 +33,6 @@ private Q_SLOTS:
|
|||||||
void test_lineOfSightCalculation_data();
|
void test_lineOfSightCalculation_data();
|
||||||
void test_lineOfSightCalculation();
|
void test_lineOfSightCalculation();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
NGL::INGLLogger& m_logger;
|
NGL::INGLLogger& m_logger;
|
||||||
};
|
};
|
||||||
Executable → Regular
+2
-4
@@ -1,6 +1,5 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
|
|
||||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||||
@@ -19,8 +18,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)
|
||||||
{
|
{
|
||||||
@@ -29,4 +27,4 @@ LOGGER_T getLogger(const char *name)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace LtsElevation
|
||||||
Executable → Regular
+2
-3
@@ -1,7 +1,5 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <NGLLogger/INGLLogger.h>
|
#include <NGLLogger/INGLLogger.h>
|
||||||
@@ -11,8 +9,9 @@ namespace LtsElevation
|
|||||||
typedef NGL::INGLLogger& LOGGER_T;
|
typedef NGL::INGLLogger& LOGGER_T;
|
||||||
|
|
||||||
LOGGER_T getLogger(const char* name);
|
LOGGER_T getLogger(const char* name);
|
||||||
|
|
||||||
inline LOGGER_T getLogger(const QString& loggerName)
|
inline LOGGER_T getLogger(const QString& loggerName)
|
||||||
{
|
{
|
||||||
return getLogger(loggerName.toUtf8().constData());
|
return getLogger(loggerName.toUtf8().constData());
|
||||||
}
|
}
|
||||||
}
|
} // namespace LtsElevation
|
||||||
Executable → Regular
+59
-97
@@ -1,36 +1,36 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "lts_elevation_manager.h"
|
#include "lts_elevation_manager.h"
|
||||||
#include <utility>
|
|
||||||
#include <Plugins/ExerciseManagement/exm_data_plugin_interface.h>
|
|
||||||
#include <Plugins/AssetManagement/asm_data_plugin_interface.h>
|
#include <Plugins/AssetManagement/asm_data_plugin_interface.h>
|
||||||
|
#include <Plugins/ExerciseManagement/exm_data_plugin_interface.h>
|
||||||
#include <Viewer/SituationMap/ElevationMap/elevation_map_manager.h>
|
|
||||||
#include <Viewer/SituationMap/Common/resource_path.h>
|
|
||||||
|
|
||||||
#include <QSharedPointer>
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QUrl>
|
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
|
#include <QSharedPointer>
|
||||||
|
#include <QUrl>
|
||||||
|
#include <Viewer/SituationMap/Common/resource_path.h>
|
||||||
|
#include <Viewer/SituationMap/ElevationMap/elevation_map_manager.h>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
|
static_assert((int)SituationMap::ElevationMapManager::LineOfSight::LOS_UNDEFINED ==
|
||||||
|
(int)LtsElevation::LineOfSight::LOS_UNDEFINED,
|
||||||
|
"LineOfSight mismatch");
|
||||||
static_assert((int)SituationMap::ElevationMapManager::LineOfSight::LOS_UNDEFINED == (int)LtsElevation::LineOfSight::LOS_UNDEFINED, "LineOfSight mismatch");
|
static_assert((int)SituationMap::ElevationMapManager::LineOfSight::LOS_ERROR ==
|
||||||
static_assert((int)SituationMap::ElevationMapManager::LineOfSight::LOS_ERROR == (int)LtsElevation::LineOfSight::LOS_ERROR, "LineOfSight mismatch");
|
(int)LtsElevation::LineOfSight::LOS_ERROR,
|
||||||
static_assert((int)SituationMap::ElevationMapManager::LineOfSight::LOS_VISIBLE == (int)LtsElevation::LineOfSight::LOS_VISIBLE, "LineOfSight mismatch");
|
"LineOfSight mismatch");
|
||||||
static_assert((int)SituationMap::ElevationMapManager::LineOfSight::LOS_INVISIBLE == (int)LtsElevation::LineOfSight::LOS_INVISIBLE, "LineOfSight mismatch");
|
static_assert((int)SituationMap::ElevationMapManager::LineOfSight::LOS_VISIBLE ==
|
||||||
|
(int)LtsElevation::LineOfSight::LOS_VISIBLE,
|
||||||
|
"LineOfSight mismatch");
|
||||||
|
static_assert((int)SituationMap::ElevationMapManager::LineOfSight::LOS_INVISIBLE ==
|
||||||
|
(int)LtsElevation::LineOfSight::LOS_INVISIBLE,
|
||||||
|
"LineOfSight mismatch");
|
||||||
|
|
||||||
namespace LtsElevation
|
namespace LtsElevation
|
||||||
{
|
{
|
||||||
class LtsElevationManager;
|
class LtsElevationManager;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
using LtsElevatioMgrMapTrainingAreaId = QMap<int, LTS_ELEVATION_MANAGER_TYPE>;
|
using LtsElevatioMgrMapTrainingAreaId = QMap<int, LTS_ELEVATION_MANAGER_TYPE>;
|
||||||
|
|
||||||
|
|
||||||
static LtsElevatioMgrMapTrainingAreaId& ltsElevatioMgrMapTrainingAreaId()
|
static LtsElevatioMgrMapTrainingAreaId& ltsElevatioMgrMapTrainingAreaId()
|
||||||
{
|
{
|
||||||
static LtsElevatioMgrMapTrainingAreaId s_ltsElevatioMgrMapTrainingAreaId;
|
static LtsElevatioMgrMapTrainingAreaId s_ltsElevatioMgrMapTrainingAreaId;
|
||||||
@@ -53,17 +53,16 @@ LtsElevatioMgrMapTrainingAreaId &getLtsElevationMgrMapTrainingAreaId()
|
|||||||
|
|
||||||
static long s_counter{0};
|
static long s_counter{0};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class LtsElevationManager::Private
|
class LtsElevationManager::Private
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Private() = default;
|
Private() = default;
|
||||||
|
|
||||||
~Private()
|
~Private()
|
||||||
{
|
{
|
||||||
delete m_elevationManager;
|
delete m_elevationManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<ExerciseManagement::Interface::Dtc> m_exmDtc;
|
std::shared_ptr<ExerciseManagement::Interface::Dtc> m_exmDtc;
|
||||||
std::shared_ptr<AssetManagement::Interface::Dtc> m_asmDtc;
|
std::shared_ptr<AssetManagement::Interface::Dtc> m_asmDtc;
|
||||||
|
|
||||||
@@ -71,13 +70,7 @@ public:
|
|||||||
SituationMap::ElevationMapManager* m_elevationManager{nullptr};
|
SituationMap::ElevationMapManager* m_elevationManager{nullptr};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
LtsElevationManager::LtsElevationManager() : QObject(nullptr), d(new Private)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
LtsElevationManager::LtsElevationManager()
|
|
||||||
: QObject(nullptr)
|
|
||||||
, d(new Private)
|
|
||||||
{
|
{
|
||||||
++s_counter;
|
++s_counter;
|
||||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START, s_counter=" << s_counter << " this=" << this;
|
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START, s_counter=" << s_counter << " this=" << this;
|
||||||
@@ -92,8 +85,8 @@ LtsElevationManager::~LtsElevationManager()
|
|||||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END, s_counter=" << s_counter << " this=" << this;
|
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END, s_counter=" << s_counter << " this=" << this;
|
||||||
}
|
}
|
||||||
|
|
||||||
LTS_ELEVATION_MANAGER_TYPE LtsElevationManager::createInstance(int exerciseId,
|
LTS_ELEVATION_MANAGER_TYPE
|
||||||
const std::shared_ptr<ExerciseManagement::Interface::Dtc> &exmDtc,
|
LtsElevationManager::createInstance(int exerciseId, const std::shared_ptr<ExerciseManagement::Interface::Dtc>& exmDtc,
|
||||||
const std::shared_ptr<AssetManagement::Interface::Dtc>& asmDtc)
|
const std::shared_ptr<AssetManagement::Interface::Dtc>& asmDtc)
|
||||||
{
|
{
|
||||||
LOGGER_T logger = getLogger("LtsElevationManager");
|
LOGGER_T logger = getLogger("LtsElevationManager");
|
||||||
@@ -107,59 +100,43 @@ LTS_ELEVATION_MANAGER_TYPE LtsElevationManager::createInstance(int exerciseId,
|
|||||||
|
|
||||||
int trainingAreaId = -1;
|
int trainingAreaId = -1;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static QHash<int, int> s_exIdToTaIdStore;
|
static QHash<int, int> s_exIdToTaIdStore;
|
||||||
|
|
||||||
const auto exTaIt = s_exIdToTaIdStore.find(exerciseId);
|
const auto exTaIt = s_exIdToTaIdStore.find(exerciseId);
|
||||||
if (exTaIt != s_exIdToTaIdStore.end())
|
if (exTaIt != s_exIdToTaIdStore.end())
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
trainingAreaId = *exTaIt;
|
trainingAreaId = *exTaIt;
|
||||||
|
}
|
||||||
} else {
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
if (!exmDtc || !asmDtc)
|
if (!exmDtc || !asmDtc)
|
||||||
{
|
{
|
||||||
ERROR_LOG(logger) << Q_FUNC_INFO << " no dtcs for exerciseId=" << exerciseId
|
ERROR_LOG(logger) << Q_FUNC_INFO << " no dtcs for exerciseId=" << exerciseId << ", asmDtc=" << asmDtc
|
||||||
<< ", asmDtc=" << asmDtc
|
|
||||||
<< ", exmDtc=" << exmDtc;
|
<< ", exmDtc=" << exmDtc;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
trainingAreaId = exerciseIdToTrainingAreaId(exerciseId, exmDtc);
|
trainingAreaId = exerciseIdToTrainingAreaId(exerciseId, exmDtc);
|
||||||
if (trainingAreaId <= 0)
|
if (trainingAreaId <= 0)
|
||||||
{
|
{
|
||||||
ERROR_LOG(logger) << Q_FUNC_INFO << " Error getting trainingAreaId"
|
ERROR_LOG(logger) << Q_FUNC_INFO << " Error getting trainingAreaId"
|
||||||
<< ", exerciseId=" << exerciseId
|
<< ", exerciseId=" << exerciseId << ", trainingAreaId=" << trainingAreaId;
|
||||||
<< ", trainingAreaId=" << trainingAreaId;
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
s_exIdToTaIdStore[exerciseId] = trainingAreaId;
|
s_exIdToTaIdStore[exerciseId] = trainingAreaId;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
LTS_ELEVATION_MANAGER_TYPE temp = createInstanceForTrainingAreaId(trainingAreaId, asmDtc);
|
LTS_ELEVATION_MANAGER_TYPE temp = createInstanceForTrainingAreaId(trainingAreaId, asmDtc);
|
||||||
if (!temp)
|
if (!temp)
|
||||||
{
|
{
|
||||||
ERROR_LOG(logger) << Q_FUNC_INFO << " Error on createInstanceForTrainingAreaId"
|
ERROR_LOG(logger) << Q_FUNC_INFO << " Error on createInstanceForTrainingAreaId"
|
||||||
<< ", exerciseId=" << exerciseId
|
<< ", exerciseId=" << exerciseId << ", trainingAreaId=" << trainingAreaId;
|
||||||
<< ", trainingAreaId=" << trainingAreaId;
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
temp->initDDS(exmDtc, asmDtc);
|
temp->initDDS(exmDtc, asmDtc);
|
||||||
|
|
||||||
TRACE_LOG(logger) << Q_FUNC_INFO << " END, exerciseId=" << exerciseId;
|
TRACE_LOG(logger) << Q_FUNC_INFO << " END, exerciseId=" << exerciseId;
|
||||||
@@ -171,7 +148,8 @@ LTS_ELEVATION_MANAGER_TYPE LtsElevationManager::getInstance(int exerciseId)
|
|||||||
return LtsElevationManager::createInstance(exerciseId);
|
return LtsElevationManager::createInstance(exerciseId);
|
||||||
}
|
}
|
||||||
|
|
||||||
LTS_ELEVATION_MANAGER_TYPE LtsElevationManager::createInstanceForTrainingAreaId(int trainingAreaId,
|
LTS_ELEVATION_MANAGER_TYPE
|
||||||
|
LtsElevationManager::createInstanceForTrainingAreaId(int trainingAreaId,
|
||||||
const std::shared_ptr<AssetManagement::Interface::Dtc>& asmDtc)
|
const std::shared_ptr<AssetManagement::Interface::Dtc>& asmDtc)
|
||||||
{
|
{
|
||||||
LOGGER_T logger = getLogger("LtsElevationManager");
|
LOGGER_T logger = getLogger("LtsElevationManager");
|
||||||
@@ -183,28 +161,23 @@ LTS_ELEVATION_MANAGER_TYPE LtsElevationManager::createInstanceForTrainingAreaId(
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LtsElevatioMgrMapTrainingAreaId& map = getLtsElevationMgrMapTrainingAreaId();
|
LtsElevatioMgrMapTrainingAreaId& map = getLtsElevationMgrMapTrainingAreaId();
|
||||||
QMap<int, LTS_ELEVATION_MANAGER_TYPE>::iterator it = map.find(trainingAreaId);
|
QMap<int, LTS_ELEVATION_MANAGER_TYPE>::iterator it = map.find(trainingAreaId);
|
||||||
|
|
||||||
|
|
||||||
if (it != map.end())
|
if (it != map.end())
|
||||||
{
|
{
|
||||||
DEBUG_LOG(logger) << " LtsElevationMgrMap contains instances: " << map.size();
|
DEBUG_LOG(logger) << " LtsElevationMgrMap contains instances: " << map.size();
|
||||||
return it.value();
|
return it.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!asmDtc)
|
if (!asmDtc)
|
||||||
{
|
{
|
||||||
ERROR_LOG(logger) << Q_FUNC_INFO << " no dtcs for trainingAreaId=" << trainingAreaId
|
ERROR_LOG(logger) << Q_FUNC_INFO << " no dtcs for trainingAreaId=" << trainingAreaId << ", asmDtc=" << asmDtc;
|
||||||
<< ", asmDtc=" << asmDtc;
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
LTS_ELEVATION_MANAGER_TYPE temp = new LtsElevationManager();
|
LTS_ELEVATION_MANAGER_TYPE temp = new LtsElevationManager();
|
||||||
|
|
||||||
|
|
||||||
temp->initDDS(nullptr, asmDtc);
|
temp->initDDS(nullptr, asmDtc);
|
||||||
|
|
||||||
const QStringList& filenames = temp->getFilenamesForTrainingArea(trainingAreaId);
|
const QStringList& filenames = temp->getFilenamesForTrainingArea(trainingAreaId);
|
||||||
@@ -215,7 +188,6 @@ LTS_ELEVATION_MANAGER_TYPE LtsElevationManager::createInstanceForTrainingAreaId(
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool bInitFilenames = temp->init(filenames);
|
bool bInitFilenames = temp->init(filenames);
|
||||||
if (!bInitFilenames)
|
if (!bInitFilenames)
|
||||||
{
|
{
|
||||||
@@ -232,27 +204,22 @@ LTS_ELEVATION_MANAGER_TYPE LtsElevationManager::createInstanceForTrainingAreaId(
|
|||||||
return map[trainingAreaId];
|
return map[trainingAreaId];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LTS_ELEVATION_MANAGER_TYPE LtsElevationManager::createInstanceUnitTest(int id,
|
||||||
|
const QStringList& filePaths_rough_to_fine)
|
||||||
|
|
||||||
LTS_ELEVATION_MANAGER_TYPE LtsElevationManager::createInstanceUnitTest(int id, const QStringList &filePaths_rough_to_fine)
|
|
||||||
{
|
{
|
||||||
LOGGER_T logger = getLogger("LtsElevationManager");
|
LOGGER_T logger = getLogger("LtsElevationManager");
|
||||||
|
|
||||||
LtsElevatioMgrMapTrainingAreaId& map = getLtsElevationMgrMapTrainingAreaId();
|
LtsElevatioMgrMapTrainingAreaId& map = getLtsElevationMgrMapTrainingAreaId();
|
||||||
QMap<int, LTS_ELEVATION_MANAGER_TYPE>::iterator it = map.find(id);
|
QMap<int, LTS_ELEVATION_MANAGER_TYPE>::iterator it = map.find(id);
|
||||||
|
|
||||||
|
|
||||||
if (it != map.end())
|
if (it != map.end())
|
||||||
{
|
{
|
||||||
DEBUG_LOG(logger) << " LtsElevationMgrMap contains instances: " << map.size();
|
DEBUG_LOG(logger) << " LtsElevationMgrMap contains instances: " << map.size();
|
||||||
return it.value();
|
return it.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LTS_ELEVATION_MANAGER_TYPE temp = new LtsElevationManager();
|
LTS_ELEVATION_MANAGER_TYPE temp = new LtsElevationManager();
|
||||||
|
|
||||||
|
|
||||||
bool bInitFilenames = temp->init(filePaths_rough_to_fine);
|
bool bInitFilenames = temp->init(filePaths_rough_to_fine);
|
||||||
if (!bInitFilenames)
|
if (!bInitFilenames)
|
||||||
{
|
{
|
||||||
@@ -267,12 +234,8 @@ LTS_ELEVATION_MANAGER_TYPE LtsElevationManager::createInstanceUnitTest(int id, c
|
|||||||
|
|
||||||
TRACE_LOG(logger) << Q_FUNC_INFO << " END, trainingAreaId=" << id;
|
TRACE_LOG(logger) << Q_FUNC_INFO << " END, trainingAreaId=" << id;
|
||||||
return map[id];
|
return map[id];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LtsElevationManager::cleanupAll()
|
void LtsElevationManager::cleanupAll()
|
||||||
{
|
{
|
||||||
LOGGER_T logger = getLogger("LtsElevationManager");
|
LOGGER_T logger = getLogger("LtsElevationManager");
|
||||||
@@ -281,7 +244,8 @@ void LtsElevationManager::cleanupAll()
|
|||||||
TRACE_LOG(logger) << Q_FUNC_INFO << " END";
|
TRACE_LOG(logger) << Q_FUNC_INFO << " END";
|
||||||
}
|
}
|
||||||
|
|
||||||
void LtsElevationManager::initDDS(const std::shared_ptr<ExerciseManagement::Interface::Dtc> &exmDtc, const std::shared_ptr<AssetManagement::Interface::Dtc> &asmDtc)
|
void LtsElevationManager::initDDS(const std::shared_ptr<ExerciseManagement::Interface::Dtc>& exmDtc,
|
||||||
|
const std::shared_ptr<AssetManagement::Interface::Dtc>& asmDtc)
|
||||||
{
|
{
|
||||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START";
|
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START";
|
||||||
|
|
||||||
@@ -307,19 +271,18 @@ QStringList LtsElevationManager::getFilenamesForExercise(int exerciseId)
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int trainingAreaId = exerciseIdToTrainingAreaId(exerciseId, d->m_exmDtc);
|
int trainingAreaId = exerciseIdToTrainingAreaId(exerciseId, d->m_exmDtc);
|
||||||
if (trainingAreaId <= 0)
|
if (trainingAreaId <= 0)
|
||||||
{
|
{
|
||||||
ERROR_LOG(m_logger) << Q_FUNC_INFO << " Error getting trainingAreaId"
|
ERROR_LOG(m_logger) << Q_FUNC_INFO << " Error getting trainingAreaId"
|
||||||
<< ", exerciseId=" << exerciseId
|
<< ", exerciseId=" << exerciseId << ", trainingAreaId=" << trainingAreaId;
|
||||||
<< ", trainingAreaId=" << trainingAreaId;
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList filePaths_rough_to_fine = getFilenamesForTrainingArea(trainingAreaId);
|
QStringList filePaths_rough_to_fine = getFilenamesForTrainingArea(trainingAreaId);
|
||||||
|
|
||||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END, filePaths_rough_to_fine=" << filePaths_rough_to_fine.join(QStringLiteral(";"));
|
TRACE_LOG(m_logger) << Q_FUNC_INFO
|
||||||
|
<< " END, filePaths_rough_to_fine=" << filePaths_rough_to_fine.join(QStringLiteral(";"));
|
||||||
return filePaths_rough_to_fine;
|
return filePaths_rough_to_fine;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -334,7 +297,6 @@ QStringList LtsElevationManager::getFilenamesForTrainingArea(int trainingAreaId)
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QStringList filePaths_rough_to_fine;
|
QStringList filePaths_rough_to_fine;
|
||||||
{
|
{
|
||||||
d->m_asmDtc->waitForHistoricalDataTrainingArea(1000);
|
d->m_asmDtc->waitForHistoricalDataTrainingArea(1000);
|
||||||
@@ -359,7 +321,8 @@ QStringList LtsElevationManager::getFilenamesForTrainingArea(int trainingAreaId)
|
|||||||
filePaths_rough_to_fine.append(filePathAbs);
|
filePaths_rough_to_fine.append(filePathAbs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END, filePaths_rough_to_fine=" << filePaths_rough_to_fine.join(QStringLiteral(";"));
|
TRACE_LOG(m_logger) << Q_FUNC_INFO
|
||||||
|
<< " END, filePaths_rough_to_fine=" << filePaths_rough_to_fine.join(QStringLiteral(";"));
|
||||||
return filePaths_rough_to_fine;
|
return filePaths_rough_to_fine;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -384,7 +347,8 @@ bool LtsElevationManager::init(const QStringList &filePaths_rough_to_fine)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int LtsElevationManager::exerciseIdToTrainingAreaId(int exerciseId, const std::shared_ptr<ExerciseManagement::Interface::Dtc> &exmDtc)
|
int LtsElevationManager::exerciseIdToTrainingAreaId(int exerciseId,
|
||||||
|
const std::shared_ptr<ExerciseManagement::Interface::Dtc>& exmDtc)
|
||||||
{
|
{
|
||||||
LOGGER_T logger = getLogger("LtsElevationManager");
|
LOGGER_T logger = getLogger("LtsElevationManager");
|
||||||
|
|
||||||
@@ -395,7 +359,6 @@ int LtsElevationManager::exerciseIdToTrainingAreaId(int exerciseId, const std::s
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int trainingAreaId = -1;
|
int trainingAreaId = -1;
|
||||||
{
|
{
|
||||||
exmDtc->waitForHistoricalDataExercise(1000);
|
exmDtc->waitForHistoricalDataExercise(1000);
|
||||||
@@ -412,8 +375,7 @@ int LtsElevationManager::exerciseIdToTrainingAreaId(int exerciseId, const std::s
|
|||||||
if (trainingAreaId <= 0)
|
if (trainingAreaId <= 0)
|
||||||
{
|
{
|
||||||
ERROR_LOG(logger) << Q_FUNC_INFO << " Error getting trainingAreaId"
|
ERROR_LOG(logger) << Q_FUNC_INFO << " Error getting trainingAreaId"
|
||||||
<< ", exerciseId=" << exerciseId
|
<< ", exerciseId=" << exerciseId << ", trainingAreaId=" << trainingAreaId;
|
||||||
<< ", trainingAreaId=" << trainingAreaId;
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -444,7 +406,9 @@ double LtsElevationManager::elevation(double lon_rad, double lat_rad, double def
|
|||||||
LineOfSight LtsElevationManager::lineOfSightCalculation(const LtsUtils::QPoint3D& startPointGeo_absZ,
|
LineOfSight LtsElevationManager::lineOfSightCalculation(const LtsUtils::QPoint3D& startPointGeo_absZ,
|
||||||
const LtsUtils::QPoint3D& endPointGeo_absZ)
|
const LtsUtils::QPoint3D& endPointGeo_absZ)
|
||||||
{
|
{
|
||||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START" << ", startPointGeo_absZ = " << startPointGeo_absZ << ", endPointGeo_absZ = " << endPointGeo_absZ;
|
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START"
|
||||||
|
<< ", startPointGeo_absZ = " << startPointGeo_absZ
|
||||||
|
<< ", endPointGeo_absZ = " << endPointGeo_absZ;
|
||||||
|
|
||||||
if (!isValid())
|
if (!isValid())
|
||||||
{
|
{
|
||||||
@@ -452,38 +416,36 @@ LineOfSight LtsElevationManager::lineOfSightCalculation(const LtsUtils::QPoint3D
|
|||||||
return LineOfSight::LOS_ERROR;
|
return LineOfSight::LOS_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SituationMap::ElevationMapManager::LineOfSight eleMapMgrResult =
|
||||||
SituationMap::ElevationMapManager::LineOfSight eleMapMgrResult = d->m_elevationManager->lineOfSightCalculation(startPointGeo_absZ,endPointGeo_absZ);
|
d->m_elevationManager->lineOfSightCalculation(startPointGeo_absZ, endPointGeo_absZ);
|
||||||
|
|
||||||
|
|
||||||
LtsElevation::LineOfSight result = static_cast<LtsElevation::LineOfSight>(eleMapMgrResult);
|
LtsElevation::LineOfSight result = static_cast<LtsElevation::LineOfSight>(eleMapMgrResult);
|
||||||
|
|
||||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END" << ", startPointGeo = " << startPointGeo_absZ << ", endPointGeo = " << endPointGeo_absZ
|
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END"
|
||||||
|
<< ", startPointGeo = " << startPointGeo_absZ << ", endPointGeo = " << endPointGeo_absZ
|
||||||
<< " -> LineOfSight " << result;
|
<< " -> LineOfSight " << result;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
LineOfSight LtsElevationManager::lineOfSightCalculation(const QPointF &startPointGeo, double startHat, const QPointF &endPointGeo, double endHat)
|
LineOfSight LtsElevationManager::lineOfSightCalculation(const QPointF& startPointGeo, double startHat,
|
||||||
|
const QPointF& endPointGeo, double endHat)
|
||||||
{
|
{
|
||||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START"
|
TRACE_LOG(m_logger) << Q_FUNC_INFO << " START"
|
||||||
<< ", startPointGeo = " << startPointGeo << ", startHat = " << startHat
|
<< ", startPointGeo = " << startPointGeo << ", startHat = " << startHat
|
||||||
<< ", endPointGeo = " << endPointGeo << ", endHat = " << endHat;
|
<< ", endPointGeo = " << endPointGeo << ", endHat = " << endHat;
|
||||||
|
|
||||||
|
SituationMap::ElevationMapManager::LineOfSight eleMapMgrResult =
|
||||||
SituationMap::ElevationMapManager::LineOfSight eleMapMgrResult = d->m_elevationManager->lineOfSightCalculation(startPointGeo, startHat,
|
d->m_elevationManager->lineOfSightCalculation(startPointGeo, startHat, endPointGeo, endHat);
|
||||||
endPointGeo, endHat);
|
|
||||||
|
|
||||||
|
|
||||||
LtsElevation::LineOfSight result = static_cast<LtsElevation::LineOfSight>(eleMapMgrResult);
|
LtsElevation::LineOfSight result = static_cast<LtsElevation::LineOfSight>(eleMapMgrResult);
|
||||||
|
|
||||||
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END"
|
TRACE_LOG(m_logger) << Q_FUNC_INFO << " END"
|
||||||
<< ", startPointGeo = " << startPointGeo << ", startHat = " << startHat
|
<< ", startPointGeo = " << startPointGeo << ", startHat = " << startHat
|
||||||
<< ", endPointGeo = " << endPointGeo << ", endHat = " << endHat
|
<< ", endPointGeo = " << endPointGeo << ", endHat = " << endHat << " -> LineOfSight "
|
||||||
<< " -> LineOfSight " << static_cast<int>(eleMapMgrResult);
|
<< static_cast<int>(eleMapMgrResult);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const QString toString(const LineOfSight& value)
|
const QString toString(const LineOfSight& value)
|
||||||
{
|
{
|
||||||
switch (value)
|
switch (value)
|
||||||
@@ -507,4 +469,4 @@ std::ostream &operator<<(std::ostream &stream, const LineOfSight value)
|
|||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace LtsElevation
|
||||||
Executable → Regular
+18
-49
@@ -1,23 +1,17 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
#include "ltselevation_export.h"
|
#include "ltselevation_export.h"
|
||||||
|
|
||||||
#include <LtsUtilsCore/qpoint3d.h>
|
#include <LtsUtilsCore/qpoint3d.h>
|
||||||
|
#include <QCoreApplication>
|
||||||
|
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QCoreApplication>
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
#include <iosfwd>
|
#include <iosfwd>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
|
||||||
namespace LtsSession
|
namespace LtsSession
|
||||||
{
|
{
|
||||||
@@ -30,7 +24,7 @@ namespace Interface
|
|||||||
{
|
{
|
||||||
class Dtc;
|
class Dtc;
|
||||||
}
|
}
|
||||||
}
|
} // namespace ExerciseManagement
|
||||||
|
|
||||||
namespace AssetManagement
|
namespace AssetManagement
|
||||||
{
|
{
|
||||||
@@ -38,81 +32,59 @@ namespace Interface
|
|||||||
{
|
{
|
||||||
class Dtc;
|
class Dtc;
|
||||||
}
|
}
|
||||||
}
|
} // namespace AssetManagement
|
||||||
|
|
||||||
|
|
||||||
namespace LtsElevation
|
namespace LtsElevation
|
||||||
{
|
{
|
||||||
|
|
||||||
enum class LineOfSight { LOS_UNDEFINED,
|
enum class LineOfSight { LOS_UNDEFINED, LOS_ERROR, LOS_VISIBLE, LOS_INVISIBLE };
|
||||||
LOS_ERROR,
|
|
||||||
LOS_VISIBLE,
|
|
||||||
LOS_INVISIBLE };
|
|
||||||
|
|
||||||
class LtsElevationManager;
|
class LtsElevationManager;
|
||||||
using LTS_ELEVATION_MANAGER_TYPE = QPointer<LtsElevationManager>;
|
using LTS_ELEVATION_MANAGER_TYPE = QPointer<LtsElevationManager>;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class LTSELEVATION_EXPORT LtsElevationManager : public QObject
|
class LTSELEVATION_EXPORT LtsElevationManager : public QObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
static LTS_ELEVATION_MANAGER_TYPE
|
||||||
|
createInstance(int exerciseId, const std::shared_ptr<ExerciseManagement::Interface::Dtc>& exmDtc = {},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static LTS_ELEVATION_MANAGER_TYPE createInstance(int exerciseId,
|
|
||||||
const std::shared_ptr<ExerciseManagement::Interface::Dtc> &exmDtc = {},
|
|
||||||
const std::shared_ptr<AssetManagement::Interface::Dtc>& asmDtc = {});
|
const std::shared_ptr<AssetManagement::Interface::Dtc>& asmDtc = {});
|
||||||
|
|
||||||
static LTS_ELEVATION_MANAGER_TYPE getInstance(int exerciseId);
|
static LTS_ELEVATION_MANAGER_TYPE getInstance(int exerciseId);
|
||||||
|
|
||||||
|
static LTS_ELEVATION_MANAGER_TYPE
|
||||||
static LTS_ELEVATION_MANAGER_TYPE createInstanceForTrainingAreaId(int trainingAreaId,
|
createInstanceForTrainingAreaId(int trainingAreaId,
|
||||||
const std::shared_ptr<AssetManagement::Interface::Dtc>& asmDtc = nullptr);
|
const std::shared_ptr<AssetManagement::Interface::Dtc>& asmDtc = nullptr);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void cleanupAll();
|
static void cleanupAll();
|
||||||
virtual ~LtsElevationManager();
|
virtual ~LtsElevationManager();
|
||||||
|
|
||||||
|
|
||||||
bool waitForInitialization();
|
bool waitForInitialization();
|
||||||
bool isValid() const;
|
bool isValid() const;
|
||||||
|
|
||||||
double elevation(double lon_rad, double lat_rad, double defaultValue = std::numeric_limits<double>::min(), bool *bIsCovered = nullptr) const;
|
double elevation(double lon_rad, double lat_rad, double defaultValue = std::numeric_limits<double>::min(),
|
||||||
|
bool* bIsCovered = nullptr) const;
|
||||||
|
|
||||||
LineOfSight lineOfSightCalculation(const LtsUtils::QPoint3D& startPointGeo_absZ,
|
LineOfSight lineOfSightCalculation(const LtsUtils::QPoint3D& startPointGeo_absZ,
|
||||||
const LtsUtils::QPoint3D& endPointGeo_absZ);
|
const LtsUtils::QPoint3D& endPointGeo_absZ);
|
||||||
|
|
||||||
LineOfSight lineOfSightCalculation(const QPointF &startPointGeo, double startHat,
|
LineOfSight lineOfSightCalculation(const QPointF& startPointGeo, double startHat, const QPointF& endPointGeo,
|
||||||
const QPointF &endPointGeo, double endHat);
|
double endHat);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit LtsElevationManager();
|
explicit LtsElevationManager();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void initDDS(const std::shared_ptr<ExerciseManagement::Interface::Dtc>& exmDtc,
|
void initDDS(const std::shared_ptr<ExerciseManagement::Interface::Dtc>& exmDtc,
|
||||||
const std::shared_ptr<AssetManagement::Interface::Dtc>& asmDtc);
|
const std::shared_ptr<AssetManagement::Interface::Dtc>& asmDtc);
|
||||||
bool init(const QStringList& filePaths_rough_to_fine);
|
bool init(const QStringList& filePaths_rough_to_fine);
|
||||||
static int exerciseIdToTrainingAreaId(int exerciseId, const std::shared_ptr<ExerciseManagement::Interface::Dtc> &exmDtc);
|
static int exerciseIdToTrainingAreaId(int exerciseId,
|
||||||
|
const std::shared_ptr<ExerciseManagement::Interface::Dtc>& exmDtc);
|
||||||
|
|
||||||
QStringList getFilenamesForExercise(int exerciseId);
|
QStringList getFilenamesForExercise(int exerciseId);
|
||||||
QStringList getFilenamesForTrainingArea(int trainingAreaId);
|
QStringList getFilenamesForTrainingArea(int trainingAreaId);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static LTS_ELEVATION_MANAGER_TYPE createInstanceUnitTest(int id, const QStringList& filePaths_rough_to_fine);
|
static LTS_ELEVATION_MANAGER_TYPE createInstanceUnitTest(int id, const QStringList& filePaths_rough_to_fine);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
||||||
class Private;
|
class Private;
|
||||||
|
|
||||||
Private* d;
|
Private* d;
|
||||||
@@ -121,9 +93,6 @@ private:
|
|||||||
|
|
||||||
LTSELEVATION_EXPORT const QString toString(const LtsElevation::LineOfSight& value);
|
LTSELEVATION_EXPORT const QString toString(const LtsElevation::LineOfSight& value);
|
||||||
|
|
||||||
LTSELEVATION_EXPORT std::ostream &operator<< (std::ostream &stream,
|
LTSELEVATION_EXPORT std::ostream& operator<<(std::ostream& stream, const LtsElevation::LineOfSight value);
|
||||||
const LtsElevation::LineOfSight value);
|
|
||||||
|
|
||||||
|
} // namespace LtsElevation
|
||||||
|
|
||||||
}
|
|
||||||
Executable → Regular
+19
-66
@@ -1,25 +1,26 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "aes_crypt.h"
|
#include "aes_crypt.h"
|
||||||
#include <QtCore/QByteArray>
|
|
||||||
#include <openssl/evp.h>
|
|
||||||
#include <openssl/err.h>
|
|
||||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||||
|
#include <QtCore/QByteArray>
|
||||||
|
#include <openssl/err.h>
|
||||||
|
#include <openssl/evp.h>
|
||||||
|
|
||||||
namespace LtsLicence
|
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"))
|
||||||
{
|
{
|
||||||
qsrand(time(nullptr));
|
qsrand(time(nullptr));
|
||||||
#if OPENSSL_VERSION_NUMBER < 0x1010000fL
|
#if OPENSSL_VERSION_NUMBER < 0x1010000fL
|
||||||
ERR_load_crypto_strings();
|
ERR_load_crypto_strings();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
~AesCryptPrivate()
|
~AesCryptPrivate()
|
||||||
{
|
{
|
||||||
#if OPENSSL_VERSION_NUMBER < 0x1010000fL
|
#if OPENSSL_VERSION_NUMBER < 0x1010000fL
|
||||||
@@ -42,9 +43,7 @@ QString passPhrase()
|
|||||||
return s_Private->passPhrase;
|
return s_Private->passPhrase;
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray decryptData(const QByteArray &dataToDecrypt,
|
QByteArray decryptData(const QByteArray& dataToDecrypt, const QString& pw, bool* bOk)
|
||||||
const QString &pw,
|
|
||||||
bool *bOk)
|
|
||||||
{
|
{
|
||||||
if (bOk)
|
if (bOk)
|
||||||
*bOk = false;
|
*bOk = false;
|
||||||
@@ -54,17 +53,9 @@ QByteArray decryptData(const QByteArray &dataToDecrypt,
|
|||||||
int outSize2 = 0;
|
int outSize2 = 0;
|
||||||
unsigned char key[32];
|
unsigned char key[32];
|
||||||
|
|
||||||
|
|
||||||
const QByteArray baPassword = pw.toUtf8();
|
const QByteArray baPassword = pw.toUtf8();
|
||||||
const unsigned char* dataPw = reinterpret_cast<const unsigned char*>(baPassword.data());
|
const unsigned char* dataPw = reinterpret_cast<const unsigned char*>(baPassword.data());
|
||||||
int i = EVP_BytesToKey(EVP_aes_256_cbc(),
|
int i = EVP_BytesToKey(EVP_aes_256_cbc(), EVP_sha1(), nullptr, dataPw, baPassword.size(), 5, key, nullptr);
|
||||||
EVP_sha1(),
|
|
||||||
nullptr,
|
|
||||||
dataPw,
|
|
||||||
baPassword.size(),
|
|
||||||
5,
|
|
||||||
key,
|
|
||||||
nullptr);
|
|
||||||
if (i != 32)
|
if (i != 32)
|
||||||
{
|
{
|
||||||
ERROR_LOG(s_Private->logger) << "Wrong key size - should be 256 bits";
|
ERROR_LOG(s_Private->logger) << "Wrong key size - should be 256 bits";
|
||||||
@@ -77,11 +68,7 @@ QByteArray decryptData(const QByteArray &dataToDecrypt,
|
|||||||
const QByteArray bufEncrypted = dataToDecrypt.mid(EVP_MAX_IV_LENGTH);
|
const QByteArray bufEncrypted = dataToDecrypt.mid(EVP_MAX_IV_LENGTH);
|
||||||
|
|
||||||
EVP_CIPHER_CTX* ctx = EVP_CIPHER_CTX_new();
|
EVP_CIPHER_CTX* ctx = EVP_CIPHER_CTX_new();
|
||||||
ret = EVP_DecryptInit_ex(ctx,
|
ret = EVP_DecryptInit_ex(ctx, EVP_aes_256_cbc(), nullptr, key, salt);
|
||||||
EVP_aes_256_cbc(),
|
|
||||||
nullptr,
|
|
||||||
key,
|
|
||||||
salt);
|
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
{
|
{
|
||||||
EVP_CIPHER_CTX_free(ctx);
|
EVP_CIPHER_CTX_free(ctx);
|
||||||
@@ -91,17 +78,12 @@ QByteArray decryptData(const QByteArray &dataToDecrypt,
|
|||||||
return QByteArray();
|
return QByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QByteArray bufDecrypted;
|
QByteArray bufDecrypted;
|
||||||
bufDecrypted.resize(bufEncrypted.size() + EVP_CIPHER_CTX_block_size(ctx));
|
bufDecrypted.resize(bufEncrypted.size() + EVP_CIPHER_CTX_block_size(ctx));
|
||||||
const unsigned char* dataIn = reinterpret_cast<const unsigned char*>(bufEncrypted.data());
|
const unsigned char* dataIn = reinterpret_cast<const unsigned char*>(bufEncrypted.data());
|
||||||
unsigned char* dataOut = reinterpret_cast<unsigned char*>(bufDecrypted.data());
|
unsigned char* dataOut = reinterpret_cast<unsigned char*>(bufDecrypted.data());
|
||||||
|
|
||||||
ret = EVP_DecryptUpdate(ctx,
|
ret = EVP_DecryptUpdate(ctx, dataOut, &outSize1, dataIn, bufEncrypted.size());
|
||||||
dataOut,
|
|
||||||
&outSize1,
|
|
||||||
dataIn,
|
|
||||||
bufEncrypted.size());
|
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
{
|
{
|
||||||
EVP_CIPHER_CTX_free(ctx);
|
EVP_CIPHER_CTX_free(ctx);
|
||||||
@@ -111,9 +93,7 @@ QByteArray decryptData(const QByteArray &dataToDecrypt,
|
|||||||
return QByteArray();
|
return QByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = EVP_DecryptFinal_ex(ctx,
|
ret = EVP_DecryptFinal_ex(ctx, dataOut + outSize1, &outSize2);
|
||||||
dataOut + outSize1,
|
|
||||||
&outSize2);
|
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
{
|
{
|
||||||
EVP_CIPHER_CTX_free(ctx);
|
EVP_CIPHER_CTX_free(ctx);
|
||||||
@@ -132,10 +112,7 @@ QByteArray decryptData(const QByteArray &dataToDecrypt,
|
|||||||
return bufDecrypted;
|
return bufDecrypted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QByteArray encryptData(const QByteArray& dataToEncrypt, const QString& pw, bool* bOk)
|
||||||
QByteArray encryptData(const QByteArray &dataToEncrypt,
|
|
||||||
const QString &pw,
|
|
||||||
bool *bOk)
|
|
||||||
{
|
{
|
||||||
if (bOk)
|
if (bOk)
|
||||||
*bOk = false;
|
*bOk = false;
|
||||||
@@ -146,36 +123,22 @@ QByteArray encryptData(const QByteArray &dataToEncrypt,
|
|||||||
unsigned char key[32];
|
unsigned char key[32];
|
||||||
QByteArray bufEncrypted;
|
QByteArray bufEncrypted;
|
||||||
|
|
||||||
|
|
||||||
const QByteArray baPassword = pw.toUtf8();
|
const QByteArray baPassword = pw.toUtf8();
|
||||||
const unsigned char* dataPw = reinterpret_cast<const unsigned char*>(baPassword.data());
|
const unsigned char* dataPw = reinterpret_cast<const unsigned char*>(baPassword.data());
|
||||||
int i = EVP_BytesToKey(EVP_aes_256_cbc(),
|
int i = EVP_BytesToKey(EVP_aes_256_cbc(), EVP_sha1(), nullptr, dataPw, baPassword.size(), 5, key, nullptr);
|
||||||
EVP_sha1(),
|
|
||||||
nullptr,
|
|
||||||
dataPw,
|
|
||||||
baPassword.size(),
|
|
||||||
5,
|
|
||||||
key,
|
|
||||||
nullptr);
|
|
||||||
if (i != 32)
|
if (i != 32)
|
||||||
{
|
{
|
||||||
ERROR_LOG(s_Private->logger) << "Wrong key size - should be 256 bits";
|
ERROR_LOG(s_Private->logger) << "Wrong key size - should be 256 bits";
|
||||||
return QByteArray();
|
return QByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QByteArray baSalt(EVP_MAX_IV_LENGTH, 0);
|
QByteArray baSalt(EVP_MAX_IV_LENGTH, 0);
|
||||||
for (int i = 0; i < EVP_MAX_IV_LENGTH; ++i)
|
for (int i = 0; i < EVP_MAX_IV_LENGTH; ++i)
|
||||||
baSalt[i] = qrand();
|
baSalt[i] = qrand();
|
||||||
const unsigned char* salt = reinterpret_cast<const unsigned char*>(baSalt.data());
|
const unsigned char* salt = reinterpret_cast<const unsigned char*>(baSalt.data());
|
||||||
|
|
||||||
|
|
||||||
EVP_CIPHER_CTX* ctx = EVP_CIPHER_CTX_new();
|
EVP_CIPHER_CTX* ctx = EVP_CIPHER_CTX_new();
|
||||||
ret = EVP_EncryptInit_ex(ctx,
|
ret = EVP_EncryptInit_ex(ctx, EVP_aes_256_cbc(), nullptr, key, salt);
|
||||||
EVP_aes_256_cbc(),
|
|
||||||
nullptr,
|
|
||||||
key,
|
|
||||||
salt);
|
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
{
|
{
|
||||||
EVP_CIPHER_CTX_free(ctx);
|
EVP_CIPHER_CTX_free(ctx);
|
||||||
@@ -185,19 +148,12 @@ QByteArray encryptData(const QByteArray &dataToEncrypt,
|
|||||||
return QByteArray();
|
return QByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bufEncrypted = QByteArray::fromRawData(reinterpret_cast<const char*>(salt), EVP_MAX_IV_LENGTH);
|
bufEncrypted = QByteArray::fromRawData(reinterpret_cast<const char*>(salt), EVP_MAX_IV_LENGTH);
|
||||||
bufEncrypted.resize(bufEncrypted.size() +
|
bufEncrypted.resize(bufEncrypted.size() + dataToEncrypt.size() + EVP_CIPHER_CTX_block_size(ctx));
|
||||||
dataToEncrypt.size() +
|
|
||||||
EVP_CIPHER_CTX_block_size(ctx));
|
|
||||||
const unsigned char* dataIn = reinterpret_cast<const unsigned char*>(dataToEncrypt.data());
|
const unsigned char* dataIn = reinterpret_cast<const unsigned char*>(dataToEncrypt.data());
|
||||||
unsigned char* dataOut = reinterpret_cast<unsigned char*>(bufEncrypted.data());
|
unsigned char* dataOut = reinterpret_cast<unsigned char*>(bufEncrypted.data());
|
||||||
dataOut += baSalt.size();
|
dataOut += baSalt.size();
|
||||||
ret = EVP_EncryptUpdate(ctx,
|
ret = EVP_EncryptUpdate(ctx, dataOut, &outSize1, dataIn, dataToEncrypt.size());
|
||||||
dataOut,
|
|
||||||
&outSize1,
|
|
||||||
dataIn,
|
|
||||||
dataToEncrypt.size());
|
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
{
|
{
|
||||||
EVP_CIPHER_CTX_free(ctx);
|
EVP_CIPHER_CTX_free(ctx);
|
||||||
@@ -207,10 +163,7 @@ QByteArray encryptData(const QByteArray &dataToEncrypt,
|
|||||||
return QByteArray();
|
return QByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret = EVP_EncryptFinal_ex(ctx, dataOut + outSize1, &outSize2);
|
||||||
ret = EVP_EncryptFinal_ex(ctx,
|
|
||||||
dataOut + outSize1,
|
|
||||||
&outSize2);
|
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
{
|
{
|
||||||
EVP_CIPHER_CTX_free(ctx);
|
EVP_CIPHER_CTX_free(ctx);
|
||||||
@@ -229,4 +182,4 @@ QByteArray encryptData(const QByteArray &dataToEncrypt,
|
|||||||
return bufEncrypted;
|
return bufEncrypted;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace LtsLicence
|
||||||
Executable → Regular
+5
-7
@@ -1,22 +1,20 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QtCore/QString>
|
|
||||||
#include "ltslicence_export.h"
|
#include "ltslicence_export.h"
|
||||||
|
|
||||||
|
#include <QtCore/QString>
|
||||||
|
|
||||||
namespace LtsLicence
|
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,
|
LTSLICENCE_EXPORT QByteArray decryptData(const QByteArray& dataToDecrypt, const QString& pw = passPhrase(),
|
||||||
const QString &pw = passPhrase(),
|
|
||||||
bool* bOk = nullptr);
|
bool* bOk = nullptr);
|
||||||
|
|
||||||
LTSLICENCE_EXPORT QByteArray encryptData(const QByteArray &dataToEncrypt,
|
LTSLICENCE_EXPORT QByteArray encryptData(const QByteArray& dataToEncrypt, const QString& pw = passPhrase(),
|
||||||
const QString &pw = passPhrase(),
|
|
||||||
bool* bOk = nullptr);
|
bool* bOk = nullptr);
|
||||||
}
|
} // namespace LtsLicence
|
||||||
Executable → Regular
+6
-7
@@ -1,13 +1,13 @@
|
|||||||
|
|
||||||
|
|
||||||
|
#include "aes_crypt_test.h"
|
||||||
#include <QtCore/QCoreApplication>
|
|
||||||
#include <QtTest/QTest>
|
|
||||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
|
||||||
#include <openssl/evp.h>
|
|
||||||
|
|
||||||
#include "aes_crypt.h"
|
#include "aes_crypt.h"
|
||||||
#include "aes_crypt_test.h"
|
|
||||||
|
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||||
|
#include <QtCore/QCoreApplication>
|
||||||
|
#include <QtTest/QTest>
|
||||||
|
#include <openssl/evp.h>
|
||||||
|
|
||||||
QTEST_MAIN(aes_crypt_test)
|
QTEST_MAIN(aes_crypt_test)
|
||||||
|
|
||||||
@@ -30,7 +30,6 @@ void aes_crypt_test::truePassTest()
|
|||||||
QVERIFY2(bOk, "Error encrypting data...");
|
QVERIFY2(bOk, "Error encrypting data...");
|
||||||
QCOMPARE(dec, content);
|
QCOMPARE(dec, content);
|
||||||
|
|
||||||
|
|
||||||
const QByteArray bigContent(12345, '1');
|
const QByteArray bigContent(12345, '1');
|
||||||
const QByteArray bigEnc = LtsLicence::encryptData(bigContent, pw, &bOk);
|
const QByteArray bigEnc = LtsLicence::encryptData(bigContent, pw, &bOk);
|
||||||
QVERIFY2(bOk, "Error encrypting data...");
|
QVERIFY2(bOk, "Error encrypting data...");
|
||||||
|
|||||||
Executable → Regular
-2
@@ -1,9 +1,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
|
|
||||||
class aes_crypt_test : public QObject
|
class aes_crypt_test : public QObject
|
||||||
|
|||||||
Executable → Regular
+12
-35
@@ -1,15 +1,15 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "lts_licence.h"
|
#include "lts_licence.h"
|
||||||
#include <QDomDocument>
|
|
||||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||||
|
#include <QDomDocument>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
namespace LtsLicence
|
namespace LtsLicence
|
||||||
{
|
{
|
||||||
static bool extractLicence(const QDomElement& licenceElement, QVector<Licence>& licenceVec);
|
static bool extractLicence(const QDomElement& licenceElement, QVector<Licence>& licenceVec);
|
||||||
|
|
||||||
static NGL::INGLLogger& getLogger()
|
static NGL::INGLLogger& getLogger()
|
||||||
{
|
{
|
||||||
return NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("LtsLicence");
|
return NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("LtsLicence");
|
||||||
@@ -26,8 +26,8 @@ QVector<Licence> readLicences(const QByteArray &unencryptedXmlData)
|
|||||||
|
|
||||||
if (!xmlDoc.setContent(unencryptedXmlData, &errorMsg, &errorLine, &errorColumn))
|
if (!xmlDoc.setContent(unencryptedXmlData, &errorMsg, &errorLine, &errorColumn))
|
||||||
{
|
{
|
||||||
ERROR_LOG(getLogger()) << "Error reading xml data, " << "error in line " << errorLine
|
ERROR_LOG(getLogger()) << "Error reading xml data, "
|
||||||
<< ", column " << errorColumn
|
<< "error in line " << errorLine << ", column " << errorColumn
|
||||||
<< ", message: " << errorMsg;
|
<< ", message: " << errorMsg;
|
||||||
return licenceVec;
|
return licenceVec;
|
||||||
}
|
}
|
||||||
@@ -49,13 +49,12 @@ QVector<Licence> readLicences(const QByteArray &unencryptedXmlData)
|
|||||||
return licenceVec;
|
return licenceVec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QByteArray writeUnencryptedLicences(const QVector<Licence>& licences)
|
QByteArray writeUnencryptedLicences(const QVector<Licence>& licences)
|
||||||
{
|
{
|
||||||
QDomDocument xmlDoc;
|
QDomDocument xmlDoc;
|
||||||
|
|
||||||
QDomProcessingInstruction instr = xmlDoc.createProcessingInstruction(QLatin1String("xml"),
|
QDomProcessingInstruction instr = xmlDoc.createProcessingInstruction(
|
||||||
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"));
|
||||||
@@ -66,35 +65,29 @@ QByteArray writeUnencryptedLicences(const QVector<Licence> &licences)
|
|||||||
QDomElement lic = xmlDoc.createElement(QLatin1String("licence"));
|
QDomElement lic = xmlDoc.createElement(QLatin1String("licence"));
|
||||||
root.appendChild(lic);
|
root.appendChild(lic);
|
||||||
|
|
||||||
|
|
||||||
QDomElement element = xmlDoc.createElement(QLatin1String("name"));
|
QDomElement element = xmlDoc.createElement(QLatin1String("name"));
|
||||||
QDomText text = xmlDoc.createTextNode(licences[i].name);
|
QDomText text = xmlDoc.createTextNode(licences[i].name);
|
||||||
element.appendChild(text);
|
element.appendChild(text);
|
||||||
lic.appendChild(element);
|
lic.appendChild(element);
|
||||||
|
|
||||||
|
|
||||||
element = xmlDoc.createElement(QLatin1String("ignoreMaxCount"));
|
element = xmlDoc.createElement(QLatin1String("ignoreMaxCount"));
|
||||||
text = xmlDoc.createTextNode(QString::number(licences[i].ignoreMaxCount));
|
text = xmlDoc.createTextNode(QString::number(licences[i].ignoreMaxCount));
|
||||||
element.appendChild(text);
|
element.appendChild(text);
|
||||||
lic.appendChild(element);
|
lic.appendChild(element);
|
||||||
|
|
||||||
|
|
||||||
element = xmlDoc.createElement(QLatin1String("ignoreExpiration"));
|
element = xmlDoc.createElement(QLatin1String("ignoreExpiration"));
|
||||||
text = xmlDoc.createTextNode(QString::number(licences[i].ignoreExpiration));
|
text = xmlDoc.createTextNode(QString::number(licences[i].ignoreExpiration));
|
||||||
element.appendChild(text);
|
element.appendChild(text);
|
||||||
lic.appendChild(element);
|
lic.appendChild(element);
|
||||||
|
|
||||||
|
|
||||||
element = xmlDoc.createElement(QLatin1String("maxCount"));
|
element = xmlDoc.createElement(QLatin1String("maxCount"));
|
||||||
text = xmlDoc.createTextNode(QString::number(licences[i].maxCount));
|
text = xmlDoc.createTextNode(QString::number(licences[i].maxCount));
|
||||||
element.appendChild(text);
|
element.appendChild(text);
|
||||||
lic.appendChild(element);
|
lic.appendChild(element);
|
||||||
|
|
||||||
|
|
||||||
const QLatin1String format("dd.MM.yyyy hh:mm:ss");
|
const QLatin1String format("dd.MM.yyyy hh:mm:ss");
|
||||||
const QString qs = licences[i].expiration.toString(format);
|
const QString qs = licences[i].expiration.toString(format);
|
||||||
|
|
||||||
|
|
||||||
element = xmlDoc.createElement(QLatin1String("expiration"));
|
element = xmlDoc.createElement(QLatin1String("expiration"));
|
||||||
text = xmlDoc.createTextNode(qs);
|
text = xmlDoc.createTextNode(qs);
|
||||||
element.appendChild(text);
|
element.appendChild(text);
|
||||||
@@ -104,60 +97,46 @@ QByteArray writeUnencryptedLicences(const QVector<Licence> &licences)
|
|||||||
return xmlDoc.toByteArray();
|
return xmlDoc.toByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool extractLicence(const QDomElement& licenceElement, QVector<Licence>& licenceVec)
|
bool extractLicence(const QDomElement& licenceElement, QVector<Licence>& licenceVec)
|
||||||
{
|
{
|
||||||
Licence licence;
|
Licence licence;
|
||||||
|
|
||||||
|
|
||||||
QDomElement tag = licenceElement.firstChildElement(QLatin1String("name"));
|
QDomElement tag = licenceElement.firstChildElement(QLatin1String("name"));
|
||||||
licence.name = tag.text();
|
licence.name = tag.text();
|
||||||
|
|
||||||
|
|
||||||
tag = licenceElement.firstChildElement(QLatin1String("ignoreMaxCount"));
|
tag = licenceElement.firstChildElement(QLatin1String("ignoreMaxCount"));
|
||||||
licence.ignoreMaxCount = tag.text().toInt();
|
licence.ignoreMaxCount = tag.text().toInt();
|
||||||
|
|
||||||
|
|
||||||
tag = licenceElement.firstChildElement(QLatin1String("ignoreExpiration"));
|
tag = licenceElement.firstChildElement(QLatin1String("ignoreExpiration"));
|
||||||
licence.ignoreExpiration = tag.text().toInt();
|
licence.ignoreExpiration = tag.text().toInt();
|
||||||
|
|
||||||
|
|
||||||
tag = licenceElement.firstChildElement(QLatin1String("maxCount"));
|
tag = licenceElement.firstChildElement(QLatin1String("maxCount"));
|
||||||
licence.maxCount = tag.text().toInt();
|
licence.maxCount = tag.text().toInt();
|
||||||
|
|
||||||
|
|
||||||
tag = licenceElement.firstChildElement(QLatin1String("expiration"));
|
tag = licenceElement.firstChildElement(QLatin1String("expiration"));
|
||||||
|
|
||||||
const QString qs(tag.text());
|
const QString qs(tag.text());
|
||||||
|
|
||||||
|
|
||||||
const QLatin1String format("dd.MM.yyyy hh:mm:ss");
|
const QLatin1String format("dd.MM.yyyy hh:mm:ss");
|
||||||
const QDateTime qdt = QDateTime::fromString(qs, format);
|
const QDateTime qdt = QDateTime::fromString(qs, format);
|
||||||
|
|
||||||
if (!qdt.isValid())
|
if (!qdt.isValid())
|
||||||
{
|
{
|
||||||
ERROR_LOG(getLogger()) << "Invalid expiration format! " << qs
|
ERROR_LOG(getLogger()) << "Invalid expiration format! " << qs << " used format: " << format;
|
||||||
<< " used format: " << format
|
|
||||||
;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
<< " IgnoreExpiration: " << licence.ignoreExpiration << " MaxCount: " << licence.maxCount
|
||||||
<< " MaxCount: " << licence.maxCount
|
<< " Expiration: " << licence.expiration.date().toString() << " "
|
||||||
<< " Expiration: " << licence.expiration.date().toString()
|
<< licence.expiration.time().toString() << " RefCount: " << licence.licenceRefCount;
|
||||||
<< " " << licence.expiration.time().toString()
|
|
||||||
<< " RefCount: " << licence.licenceRefCount
|
|
||||||
;
|
|
||||||
|
|
||||||
licenceVec.append(licence);
|
licenceVec.append(licence);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
QString Licence::toString() const
|
QString Licence::toString() const
|
||||||
{
|
{
|
||||||
return QObject::tr("Name: %1, Count: %2, ExpireDate: %3, Expires: %4, UseMaxCount: %5")
|
return QObject::tr("Name: %1, Count: %2, ExpireDate: %3, Expires: %4, UseMaxCount: %5")
|
||||||
@@ -168,6 +147,4 @@ QString Licence::toString() const
|
|||||||
.arg(ignoreMaxCount);
|
.arg(ignoreMaxCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace LtsLicence
|
||||||
|
|
||||||
}
|
|
||||||
Executable → Regular
+3
-7
@@ -1,12 +1,12 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "ltslicence_export.h"
|
#include "ltslicence_export.h"
|
||||||
|
|
||||||
|
#include <QDateTime>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
#include <QDateTime>
|
|
||||||
|
|
||||||
namespace LtsLicence
|
namespace LtsLicence
|
||||||
{
|
{
|
||||||
@@ -23,11 +23,7 @@ struct LTSLICENCE_EXPORT Licence
|
|||||||
QString toString() const;
|
QString toString() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
LTSLICENCE_EXPORT QVector<Licence> readLicences(const QByteArray& unencryptedXmlData);
|
LTSLICENCE_EXPORT QVector<Licence> readLicences(const QByteArray& unencryptedXmlData);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
LTSLICENCE_EXPORT QByteArray writeUnencryptedLicences(const QVector<Licence>& licences);
|
LTSLICENCE_EXPORT QByteArray writeUnencryptedLicences(const QVector<Licence>& licences);
|
||||||
}
|
} // namespace LtsLicence
|
||||||
Executable → Regular
+10
-12
@@ -1,21 +1,18 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "logout_info_dialog.h"
|
#include "logout_info_dialog.h"
|
||||||
|
|
||||||
#include "ui_logout_info_dialog.h"
|
#include "ui_logout_info_dialog.h"
|
||||||
|
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
|
|
||||||
namespace LtsLogin
|
namespace LtsLogin
|
||||||
{
|
{
|
||||||
|
|
||||||
LogoutInformationDialog::LogoutInformationDialog(int timeOut, AssetManagement::ShutdownAction shutdownAction, QWidget *parent)
|
LogoutInformationDialog::LogoutInformationDialog(int timeOut, AssetManagement::ShutdownAction shutdownAction,
|
||||||
: LtsWidgets::LtsFramelessDialog(parent, LtsWidgets::Behaviour::Modal)
|
QWidget* parent)
|
||||||
, m_ui(new Ui::LogoutInformationDialog)
|
: LtsWidgets::LtsFramelessDialog(parent, LtsWidgets::Behaviour::Modal), m_ui(new Ui::LogoutInformationDialog),
|
||||||
, m_timer(new QTimer(this))
|
m_timer(new QTimer(this)), m_timeOut(timeOut), m_secsLeft(timeOut)
|
||||||
, m_timeOut(timeOut)
|
|
||||||
, m_secsLeft(timeOut)
|
|
||||||
{
|
{
|
||||||
m_ui->setupUi(this);
|
m_ui->setupUi(this);
|
||||||
QString actionText;
|
QString actionText;
|
||||||
@@ -35,8 +32,10 @@ LogoutInformationDialog::LogoutInformationDialog(int timeOut, AssetManagement::S
|
|||||||
|
|
||||||
setText(tr("A %1 was triggered by a remote workstation.").arg(actionText));
|
setText(tr("A %1 was triggered by a remote workstation.").arg(actionText));
|
||||||
|
|
||||||
connect(m_ui->buttonBox->getButton(LtsWidgets::DialogButton::Ok), &QPushButton::clicked, this, &LogoutInformationDialog::acceptClicked);
|
connect(m_ui->buttonBox->getButton(LtsWidgets::DialogButton::Ok), &QPushButton::clicked, this,
|
||||||
connect(m_ui->buttonBox->getButton(LtsWidgets::DialogButton::Close), &QPushButton::clicked, this, &LogoutInformationDialog::closeClicked);
|
&LogoutInformationDialog::acceptClicked);
|
||||||
|
connect(m_ui->buttonBox->getButton(LtsWidgets::DialogButton::Close), &QPushButton::clicked, this,
|
||||||
|
&LogoutInformationDialog::closeClicked);
|
||||||
connect(m_timer, &QTimer::timeout, this, &LogoutInformationDialog::onTimerTimeout);
|
connect(m_timer, &QTimer::timeout, this, &LogoutInformationDialog::onTimerTimeout);
|
||||||
|
|
||||||
m_timer->setInterval(1000);
|
m_timer->setInterval(1000);
|
||||||
@@ -75,7 +74,6 @@ void LogoutInformationDialog::closeClicked()
|
|||||||
{
|
{
|
||||||
m_timer->stop();
|
m_timer->stop();
|
||||||
reject();
|
reject();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogoutInformationDialog::setCloseButtonText(int secsLeft)
|
void LogoutInformationDialog::setCloseButtonText(int secsLeft)
|
||||||
@@ -91,4 +89,4 @@ void LogoutInformationDialog::showEvent(QShowEvent *event)
|
|||||||
LtsWidgets::LtsFramelessDialog::showEvent(event);
|
LtsWidgets::LtsFramelessDialog::showEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace LtsLogin
|
||||||
Executable → Regular
+7
-7
@@ -1,15 +1,16 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <QObject>
|
|
||||||
|
|
||||||
#include <LtsWidgets/lts_frameless_dialog.h>
|
|
||||||
#include <AssetManagement/asm.hpp>
|
#include <AssetManagement/asm.hpp>
|
||||||
|
#include <LtsWidgets/lts_frameless_dialog.h>
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
class QTimer;
|
class QTimer;
|
||||||
|
|
||||||
namespace Ui { class LogoutInformationDialog; }
|
namespace Ui
|
||||||
|
{
|
||||||
|
class LogoutInformationDialog;
|
||||||
|
}
|
||||||
|
|
||||||
namespace LtsLogin
|
namespace LtsLogin
|
||||||
{
|
{
|
||||||
@@ -36,9 +37,8 @@ private:
|
|||||||
int m_timeOut;
|
int m_timeOut;
|
||||||
int m_secsLeft;
|
int m_secsLeft;
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void showEvent(QShowEvent* event) override final;
|
void showEvent(QShowEvent* event) override final;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace LtsLogin
|
||||||
Executable → Regular
+22
-52
@@ -1,34 +1,31 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "lts_login.h"
|
#include "lts_login.h"
|
||||||
|
|
||||||
#include "logout_info_dialog.h"
|
#include "logout_info_dialog.h"
|
||||||
|
|
||||||
#include <LtsPluginManager/lts_plugin_manager.h>
|
|
||||||
#include <LtsAppDescriptor/lts_app_descriptor.h>
|
#include <LtsAppDescriptor/lts_app_descriptor.h>
|
||||||
#include <LtsSession/lts_session_manager.h>
|
#include <LtsPluginManager/lts_plugin_manager.h>
|
||||||
#include <LtsSession/lts_session.h>
|
#include <LtsSession/lts_session.h>
|
||||||
#include <LtsSession/lts_session_data.h>
|
#include <LtsSession/lts_session_data.h>
|
||||||
#include <LtsWidgets/lts_wait_dialog.h>
|
#include <LtsSession/lts_session_manager.h>
|
||||||
#include <LtsUtilsCore/dds_vector.h>
|
#include <LtsUtilsCore/dds_vector.h>
|
||||||
#include <LtsUtilsSettings/settings.h>
|
#include <LtsUtilsSettings/settings.h>
|
||||||
|
#include <LtsWidgets/lts_wait_dialog.h>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QProcess>
|
|
||||||
#include <QMessageBox>
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QProcess>
|
||||||
|
|
||||||
namespace LtsLogin
|
namespace LtsLogin
|
||||||
{
|
{
|
||||||
const int logoutShutdownTimeout = 2 * 60;
|
const int logoutShutdownTimeout = 2 * 60;
|
||||||
|
|
||||||
LtsLogin::LtsLogin()
|
LtsLogin::LtsLogin()
|
||||||
: m_loginApp(nullptr)
|
: m_loginApp(nullptr), m_shutdownAction(AssetManagement::ShutdownAction::NoAction), m_isInLogoutDialog(false)
|
||||||
, m_shutdownAction(AssetManagement::ShutdownAction::NoAction)
|
{
|
||||||
, m_isInLogoutDialog(false)
|
}
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
LtsLogin::~LtsLogin()
|
LtsLogin::~LtsLogin()
|
||||||
{
|
{
|
||||||
@@ -36,7 +33,6 @@ LtsLogin::~LtsLogin()
|
|||||||
m_loginApp = nullptr;
|
m_loginApp = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LtsLogin::login()
|
void LtsLogin::login()
|
||||||
{
|
{
|
||||||
LtsAppDescriptor::PluginInfo opmDataPlugin;
|
LtsAppDescriptor::PluginInfo opmDataPlugin;
|
||||||
@@ -87,13 +83,8 @@ void LtsLogin::login()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
connect(m_loginApp, &LtsPluginManager::LtsPluginManager::signalInitializationFinished, this, [this]() {
|
||||||
|
disconnect(m_loginApp, &LtsPluginManager::LtsPluginManager::signalInitializationFinished, this, nullptr);
|
||||||
connect(m_loginApp, &LtsPluginManager::LtsPluginManager::signalInitializationFinished,
|
|
||||||
this, [this]()
|
|
||||||
{
|
|
||||||
disconnect(m_loginApp, &LtsPluginManager::LtsPluginManager::signalInitializationFinished,
|
|
||||||
this, nullptr);
|
|
||||||
|
|
||||||
LtsSession::LtsSession* session = getAdminSession();
|
LtsSession::LtsSession* session = getAdminSession();
|
||||||
|
|
||||||
@@ -107,26 +98,24 @@ void LtsLogin::login()
|
|||||||
if (session->isInitializationDone())
|
if (session->isInitializationDone())
|
||||||
QMetaObject::invokeMethod(this, &LtsLogin::slotLoginDone);
|
QMetaObject::invokeMethod(this, &LtsLogin::slotLoginDone);
|
||||||
else
|
else
|
||||||
connect(session, &LtsSession::LtsSession::signalDoneInitializingSession,
|
connect(session, &LtsSession::LtsSession::signalDoneInitializingSession, this, &LtsLogin::slotLoginDone,
|
||||||
this, &LtsLogin::slotLoginDone, Qt::UniqueConnection);
|
Qt::UniqueConnection);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LtsLogin::slotLoginDone()
|
void LtsLogin::slotLoginDone()
|
||||||
{
|
{
|
||||||
LtsSession::LtsSession* session = getAdminSession();
|
LtsSession::LtsSession* session = getAdminSession();
|
||||||
|
|
||||||
if (session != nullptr)
|
if (session != nullptr)
|
||||||
{
|
{
|
||||||
disconnect(session, &LtsSession::LtsSession::signalDoneInitializingSession,
|
disconnect(session, &LtsSession::LtsSession::signalDoneInitializingSession, this, &LtsLogin::slotLoginDone);
|
||||||
this, &LtsLogin::slotLoginDone);
|
|
||||||
|
|
||||||
if (session->getDtc<AssetManagement::DataInterface>(m_asmDtc))
|
if (session->getDtc<AssetManagement::DataInterface>(m_asmDtc))
|
||||||
{
|
{
|
||||||
m_asmDtc->enableWorkstationLogout();
|
m_asmDtc->enableWorkstationLogout();
|
||||||
connect(m_asmDtc.get(), &AssetManagement::Interface::Dtc::workstationLogoutChanged,
|
connect(m_asmDtc.get(), &AssetManagement::Interface::Dtc::workstationLogoutChanged, this,
|
||||||
this, &LtsLogin::slotLogoutShutdown);
|
&LtsLogin::slotLogoutShutdown);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
qWarning() << "LtsLogin: no asm dtc, no remote logout/shutdown!";
|
qWarning() << "LtsLogin: no asm dtc, no remote logout/shutdown!";
|
||||||
@@ -141,28 +130,20 @@ void LtsLogin::slotLoginDone()
|
|||||||
emit signalLoginDone();
|
emit signalLoginDone();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LtsLogin::showLogoutInformationDialog(AssetManagement::ShutdownAction action)
|
void LtsLogin::showLogoutInformationDialog(AssetManagement::ShutdownAction action)
|
||||||
{
|
{
|
||||||
LogoutInformationDialog* lid = new LogoutInformationDialog(logoutShutdownTimeout, action, nullptr);
|
LogoutInformationDialog* lid = new LogoutInformationDialog(logoutShutdownTimeout, action, nullptr);
|
||||||
connect(lid, &LogoutInformationDialog::accepted,
|
connect(lid, &LogoutInformationDialog::accepted, this, [this, action]() {
|
||||||
this, [this, action]()
|
|
||||||
{
|
|
||||||
m_shutdownAction = action;
|
m_shutdownAction = action;
|
||||||
m_isInLogoutDialog = false;
|
m_isInLogoutDialog = false;
|
||||||
emit signalLogout();
|
emit signalLogout();
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(lid, &LogoutInformationDialog::rejected,
|
connect(lid, &LogoutInformationDialog::rejected, this, [this]() { m_isInLogoutDialog = false; });
|
||||||
this, [this]()
|
|
||||||
{
|
|
||||||
m_isInLogoutDialog = false;
|
|
||||||
});
|
|
||||||
|
|
||||||
lid->show();
|
lid->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LtsLogin::slotLogoutShutdown(const AssetManagement::WorkstationLogout& data, DataModification modType)
|
void LtsLogin::slotLogoutShutdown(const AssetManagement::WorkstationLogout& data, DataModification modType)
|
||||||
{
|
{
|
||||||
if (m_isInLogoutDialog)
|
if (m_isInLogoutDialog)
|
||||||
@@ -175,7 +156,8 @@ void LtsLogin::slotLogoutShutdown(const AssetManagement::WorkstationLogout &data
|
|||||||
m_asmDtc->enableAsset();
|
m_asmDtc->enableAsset();
|
||||||
for (int id : data.ids())
|
for (int id : data.ids())
|
||||||
{
|
{
|
||||||
if (QString::fromStdString(m_asmDtc->asset(id).name()).compare(LtsSession::LtsSession::workstationName(), Qt::CaseInsensitive) == 0)
|
if (QString::fromStdString(m_asmDtc->asset(id).name())
|
||||||
|
.compare(LtsSession::LtsSession::workstationName(), Qt::CaseInsensitive) == 0)
|
||||||
{
|
{
|
||||||
m_isInLogoutDialog = true;
|
m_isInLogoutDialog = true;
|
||||||
showLogoutInformationDialog(data.shutdownAction());
|
showLogoutInformationDialog(data.shutdownAction());
|
||||||
@@ -184,13 +166,11 @@ void LtsLogin::slotLogoutShutdown(const AssetManagement::WorkstationLogout &data
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LtsSession::LtsSession* LtsLogin::getAdminSession()
|
LtsSession::LtsSession* LtsLogin::getAdminSession()
|
||||||
{
|
{
|
||||||
return m_loginApp->m_sessionManager->getSession(IDL::PartitionType::Global, 0);
|
return m_loginApp->m_sessionManager->getSession(IDL::PartitionType::Global, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LtsLogin::logoff()
|
void LtsLogin::logoff()
|
||||||
{
|
{
|
||||||
if (m_loginApp == nullptr)
|
if (m_loginApp == nullptr)
|
||||||
@@ -199,8 +179,6 @@ void LtsLogin::logoff()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
LtsSession::LtsSession* datSession = getAdminSession();
|
LtsSession::LtsSession* datSession = getAdminSession();
|
||||||
|
|
||||||
if (!datSession)
|
if (!datSession)
|
||||||
@@ -215,11 +193,8 @@ void LtsLogin::logoff()
|
|||||||
LtsSessionData::LtsSessionData::getInstance()->clear();
|
LtsSessionData::LtsSessionData::getInstance()->clear();
|
||||||
|
|
||||||
std::shared_ptr<OperatorManagement::Interface::Ftc> opmFtc;
|
std::shared_ptr<OperatorManagement::Interface::Ftc> opmFtc;
|
||||||
if (operatorId == -1 ||
|
if (operatorId == -1 || !datSession->getFtc<OperatorManagement::DataInterface>(opmFtc))
|
||||||
!datSession->getFtc<OperatorManagement::DataInterface>(opmFtc)
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -230,7 +205,6 @@ void LtsLogin::logoff()
|
|||||||
|
|
||||||
const QByteArray settings = os->exportSettings();
|
const QByteArray settings = os->exportSettings();
|
||||||
|
|
||||||
|
|
||||||
const auto vec(LtsUtils::convert<std::vector<uint8_t>>(settings));
|
const auto vec(LtsUtils::convert<std::vector<uint8_t>>(settings));
|
||||||
os->clear();
|
os->clear();
|
||||||
opmFtc->operatorGetSetSettingsRequest(OperatorManagement::OperatorGetSetSettingsRequest(operatorId, vec));
|
opmFtc->operatorGetSetSettingsRequest(OperatorManagement::OperatorGetSetSettingsRequest(operatorId, vec));
|
||||||
@@ -240,7 +214,6 @@ void LtsLogin::logoff()
|
|||||||
qCritical() << "Saving operator settings failed!" << err.what();
|
qCritical() << "Saving operator settings failed!" << err.what();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::shared_ptr<SituationReplayManagement::ForeignDataInterface> srmIfc;
|
std::shared_ptr<SituationReplayManagement::ForeignDataInterface> srmIfc;
|
||||||
if (datSession->getForeignDataInterface<SituationReplayManagement::DataInterface>(srmIfc))
|
if (datSession->getForeignDataInterface<SituationReplayManagement::DataInterface>(srmIfc))
|
||||||
{
|
{
|
||||||
@@ -263,7 +236,6 @@ void LtsLogin::logoff()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
opmFtc->operatorLogoutRequest(OperatorManagement::OperatorLogoutRequest(operatorId));
|
opmFtc->operatorLogoutRequest(OperatorManagement::OperatorLogoutRequest(operatorId));
|
||||||
@@ -272,8 +244,6 @@ void LtsLogin::logoff()
|
|||||||
{
|
{
|
||||||
qCritical() << "Logout failed!" << err.what();
|
qCritical() << "Logout failed!" << err.what();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_loginApp->deleteLater();
|
m_loginApp->deleteLater();
|
||||||
@@ -309,4 +279,4 @@ void LtsLogin::logoff()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace LtsLogin
|
||||||
Executable → Regular
+11
-9
@@ -1,27 +1,26 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <Plugins/AssetManagement/asm_data_plugin_interface.h>
|
||||||
|
|
||||||
#include <ltslogin_export.h>
|
|
||||||
#include <Plugins/OperatorManagement/opm_data_plugin_interface.h>
|
#include <Plugins/OperatorManagement/opm_data_plugin_interface.h>
|
||||||
#include <Plugins/SituationReplayManagement/srm_data_plugin_interface.h>
|
#include <Plugins/SituationReplayManagement/srm_data_plugin_interface.h>
|
||||||
#include <Plugins/AssetManagement/asm_data_plugin_interface.h>
|
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
#include <ltslogin_export.h>
|
||||||
|
|
||||||
namespace LtsPluginManager
|
namespace LtsPluginManager
|
||||||
{
|
{
|
||||||
class LtsPluginManager;
|
class LtsPluginManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace LtsUtils
|
namespace LtsUtils
|
||||||
{
|
{
|
||||||
class RequestHelper;
|
class RequestHelper;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace LtsSession
|
namespace LtsSession
|
||||||
{
|
{
|
||||||
class LtsSession;
|
class LtsSession;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace DeveloperTools
|
namespace DeveloperTools
|
||||||
{
|
{
|
||||||
class DevDialog;
|
class DevDialog;
|
||||||
@@ -40,7 +39,11 @@ public:
|
|||||||
|
|
||||||
void login();
|
void login();
|
||||||
void logoff();
|
void logoff();
|
||||||
void setLoginPlugin(const QString &loginPluginIid) { m_loginPluginIid = loginPluginIid; }
|
|
||||||
|
void setLoginPlugin(const QString& loginPluginIid)
|
||||||
|
{
|
||||||
|
m_loginPluginIid = loginPluginIid;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class DeveloperTools::DevDialog;
|
friend class DeveloperTools::DevDialog;
|
||||||
@@ -63,7 +66,6 @@ signals:
|
|||||||
void signalStopBlock();
|
void signalStopBlock();
|
||||||
void signalLoginDone();
|
void signalLoginDone();
|
||||||
void signalLogoffDone();
|
void signalLogoffDone();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace LtsLogin
|
||||||
Loaded 100 of 847 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user