Initial commit

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

No files matched your search

@@ -0,0 +1,534 @@
/**
* @RDE_HEADER@
* Gui Plugin for SituationMap
* $Id$
* $HeadURL$
* $Author$
* Created by Patric Karwat, SLSE, 2016-02-29
*/
#pragma once
#include <PluginInterfaces/gui_plugin_interface.h>
#include <TopicEditorBase/topic_editor_interface.h>
#include <Plugins/SituationMapPlugin/situation_map_gui_plugin_interface.h>
#include "sitmap_register_app_handler.h"
#include "sitmap_layer_control.h"
// AdvancedSymbology
#include <Plugins/AdvancedSymbology/asb_symbol_proxy_gui_plugin_interface.h>
// ASM
#include <Plugins/AssetManagement/asm_data_plugin_interface.h>
// TopicReplay
#include <PluginInterfaces/topic_replay_interface.h>
// PlanOverlay
#include <Plugins/PlanOverlays/plan_overlays_plugin_interface.h>
// FilterManagement
#include <FilterManagement/flt_data_plugin_interface.h>
#include <LtsWidgets/lts_dialog.h>
#include <LtsWidgets/lts_drag_icon.h>
#include <Map/operator_map_settings.h>
#include <Utils/movement_track_manager.h>
#include <Rubberbands/rubberband_factory.h>
#include <QMetaMethod>
#include <QTimer>
namespace SituationMap
{
class Map;
class MapObjectSelectionLtsDialog;
class MapWidgetControl;
class LayerControlDialog;
class PluginProviderLtsSession;
class SituationMapInit;
class TerrainProfileHandler;
class ConfigureMapUrls;
//------------------------------------------------------------------------------
// MyMapWidgetDialog
//------------------------------------------------------------------------------
class MyMapWidgetDialog : public LtsWidgets::LtsDialog
{
Q_OBJECT
using BaseClass = LtsWidgets::LtsDialog;
public:
MyMapWidgetDialog(QWidget *parent = nullptr, LtsWidgets::ButtonCombination buttonCombination = LtsWidgets::ButtonCombination::CloseOnly);
virtual ~MyMapWidgetDialog();
void addWidget(QWidget *w);
Q_SIGNALS:
void aboutToCloseSignal();
protected:
void aboutToClose() override;
void retranslate() override;
};
//------------------------------------------------------------------------------
// GuiPlugin
//------------------------------------------------------------------------------
class GuiPlugin final : public QObject, public GuiPluginBase::Plugin
{
Q_PLUGIN_METADATA(IID "gui:3:sitmap")
Q_INTERFACES(GuiPluginBase::Plugin)
Q_OBJECT
public:
explicit GuiPlugin() = default;
~GuiPlugin() = default;
QString pluginName() override { return QStringLiteral("SituationMapGui"); }
std::shared_ptr<GuiPluginBase::Interface> createGuiInterface(LtsSession::LtsSession *session) override;
bool availableInPartition(IDL::PartitionType partition) const override
{
return (partition == IDL::PartitionType::Global ||
partition == IDL::PartitionType::Exercise ||
partition == IDL::PartitionType::Replay);
}
};
//------------------------------------------------------------------------------
// InterfaceImpl
//------------------------------------------------------------------------------
class InterfaceImpl final : public QObject, public ForeignGuiInterface, public GuiPluginBase::Interface
{
Q_OBJECT
public:
explicit InterfaceImpl(LtsSession::LtsSession *session);
~InterfaceImpl();
QVector<LtsWidgets::PluginData> getActions() override;
QString menuGroup() const override;
bool availableInPartition(IDL::PartitionType partition) const override
{
return partition == IDL::PartitionType::Global ||
partition == IDL::PartitionType::Exercise ||
partition == IDL::PartitionType::Replay;
}
bool fetchInterfaces() override;
void clearInterfaces() override;
// ForeignDataInterface
LtsWidgets::LtsDialog *createMapDialog(QWidget *parent) override;
QPointer<Map> map() const override;
void setMapUpdatesEnabled(bool bEnabled) override;
bool isMapReady() const override;
bool setMapReadyCallback(QObject *context, const std::function<void()> &mapReadyCallback) override;
MapMode mapMode() const override;
bool reInitToSystemDefault() override;
bool forceUpdate() override;
ResourceManagerMode resourceManagerMode() const override;
bool setResourceManagerMode(ResourceManagerMode rmm) override;
bool setResourceManagerModeChangedCallback(QObject *context, const std::function<void()> &cb) override;
bool clearObjects() override;
void enableMovementTrack(int participantId, bool enable) override;
bool isMovementTrackEnabled(int participantId) override;
bool setMovementTrackCallback(QObject *context, const std::function<void(const QVector<int32_t> &activeSimIds)> &movementTrackCallback) override;
void enableGearRanges(int participantId, bool enable) override;
bool isGearRangesEnabled(int participantId) override;
bool enableFireEventFlashing(bool enable) override;
bool isFireEventFlashingEnabled() const override;
QPointF centerPoint() const override;
void setCenterPoint(const QPointF &center, double scale = -1.0, float durationSeconds = -1.0) override;
void centerMapToParticipant(int participantId) override;
void centerMapToAesObject(int entityId) override;
void centerMapToBuildingObject(int entityId) override;
void centerMapToGuezIedObject(int entityId) override;
void centerMapToChargeEffectObject(int entityId) override;
// more general approach:
void centerMapToMapObject(MapObjectType mot, int entityId) override;
void zoomMapTo(const QVector<QPair<MapObjectType, int>> &entities, int paddingInDIPS = 100) override;
bool objectIndicatorToParticipant(int participantId, bool setSelected = false, int lifetimeMsec = -1) override;
bool objectIndicatorToAesObject(int entityId) override;
bool objectIndicatorToBuildingObject(int entityId) override;
bool objectIndicatorToGuezIedObject(int entityId) override;
// more general approach:
bool objectIndicatorToMapObject(SituationMap::MapObjectType mot, int entityId, bool setSelected = false, int lifetimeMsec = -1) override;
bool objectIndicatorToPoint(const QPointF &targetGeo, int lifetimeMsec = -1) override;
bool removeObjectIndicator() override;
/*! \name Object Selection */
//@{
bool openMapObjectSelection(MapObjectType mot, const QVector<int> &entityIds) override;
bool openMapObjectSelection(const QVector<MapObjectTypeEntityId> &mapObjectTypeEntityIdPairs) override;
bool setMapObjectSelected(MapObjectType mot, const QVector<int> &entityIds, bool selection = true) override;
bool clearMapObjectSelection(MapObjectType mot = MapObjectType::MOT_Undefined) override;
//@}
QVector<QPointF> getParallelTranslation(const QVector<QPointF> &line, double distance, bool &angleFault) override;
bool getCoordinate(QObject *objectToInform, const char *replySlot, const char *errorSlot) override;
bool getCorridor(QObject *objectToInform
, const char *replySlot
, const char *errorSlot
, double widthMin = 2
, double widthMax = 200
, double maxSegmentLength = 200
, int maxSegmentCount = 5
, bool centerLine = false
, const QVector<QPointF> &segments = QVector<QPointF>()
, double width = 0.0) override;
bool getCircle(QObject *objectToInform
, const char *replySlot
, const char *errorSlot
, double radiusMin
, double radiusMax
, const QPointF &center = QPointF()
, double initialRadius = 0.0) override;
bool getCircleSectorFixRadius(QObject *objectToInform
, const char *replySlot
, const char *errorSlot
, double radius
, const QPointF &center = QPointF()
, double openingAngle = 90.0
, double rotationDegNorth = 0.0) override;
bool getCircleSector(QObject *objectToInform
, const char *replySlot
, const char *errorSlot
, double radiusInitial, double radiusMin, double radiusMax
, const QPointF &center = QPointF()
, double openingAngle = 90.0
, double rotationDegNorth = 0.0) override;
bool getTwoCircleSector(QObject *objectToInform
, const char *replySlot
, const char *errorSlot
, double radius1Initial, double radius1Min, double radius1Max
, double radius2Initial, double radius2Min, double radius2Max
, const QPointF &center = QPointF()
, double openingAngle = 90.0
, double rotationDegNorth = 0.0) override;
bool getRectangle(QObject *objectToInform
, const char *replySlot
, const char *errorSlot
, double widthMin = -1.0
, double widthMax = -1.0
, double heightMin = -1.0
, double heightMax = -1.0
, const QPointF &bottomLeft = QPointF()
, double width = 0.0
, double height = 0.0
, double angleNorth = 0.0) override;
// get Rectangle for tactical objects
bool getRectangleNorth(QObject *objectToInform
, const char *replySlot
, const char *errorSlot
, double widthMin
, double widthMax
, double heightMin
, double heightMax
, const QPointF &center = QPointF()
, double width = 0.0
, double height = 0.0) override;
bool getPolygon(QObject *objectToInform,
const char *replySlot,
const char *errorSlot,
unsigned int minPoints = 0,
unsigned int maxPoints = 0,
double minSegmentLength = -1.0,
double maxSegmentLength = -1.0,
const QPolygonF &coordinates = QPolygonF()) override;
bool getPolyline(QObject *objectToInform,
const char *replySlot,
const char *errorSlot,
unsigned int minPoints = 0,
unsigned int maxPoints = 0,
double minSegmentLength = -1.0,
double maxSegmentLength = -1.0,
const QPolygonF &coordinates = QPolygonF()) override;
void cancelActiveRubberbands() override;
bool displayPreviewObject(QObject *parent, const QPolygonF &poly, bool closed) override;
bool displayPreviewObjects(QObject *parent, const QVector<QPolygonF> &polyVec, bool closed) override;
bool displayPreviewObject(QObject *parent, const QPointF &centerGeo, double radius) override;
bool displayPreviewObjects(QObject *parent, const QVector<QPointF> &centerGeoVec, double radius) override;
// introduced for BoobyTraps:
bool displayPreviewObject(QObject *parent, const QPointF &centerPoint, double radius, double rotationDeg, double centralAngleDeg) override;
// introduced for CollateralDamage:
bool displayPreviewObjects(QObject *parent, const QVector<PreviewCircleData> &previewCirclesAscending) override;
bool skipMapObjectSelectionDialog() const override;
void setSkipMapObjectSelectionDialog(bool asList) override;
/*! \name Tools... */
//@{
void startMeasureLength() override;
void clearMeasureLength() override;
void startTerrainProfile() override;
void clearTerrainProfile() override;
void startViewshed() override;
void clearViewshed() override;
//@}
/*! \name EmergencyCalls ... */
//@{
bool showExpiredEmergencyCalls(bool showExpired) override;
//@}
/*! \name OS situation... */
//@{
bool ocSituationRange_create(const QPointF &origin_lonLatRadiant, double radius_meter,
const ocSituationRangeAttributes &attributes = ocSituationRangeAttributes()) override;
bool ocSituationRange_create(int participantId, double radius_meter,
const ocSituationRangeAttributes &attributes = ocSituationRangeAttributes()) override;
bool ocSituationRange_show(bool visible) override;
bool ocSituationRange_remove() override;
//@}
/*! \name ESC order position...... */
//@{
bool escOrderPosition_create(const QPointF &origin_lonLatRadiant, int areaWidth, int areaDepth, int rotation, bool is_smoke,
const escOrderPositionAttributes &attributes = escOrderPositionAttributes()) override; // default color -> black
bool escOrderPosition_show(bool visible) override;
bool escOrderPosition_remove() override;
bool isEscOrderPositionVisible() override;
//@}
/*! \name OperatorMapSettings */
//@{
bool setInitialOperatorMapSettings(const QByteArray &data) override;
bool setInitialOperatorMapSettings(const QJsonValue &data) override;
QByteArray operatorMapSettingsJson() const override;
bool setOperatorMapSettingsJson(const QByteArray &data) override;
QJsonValue operatorMapSettings() const override;
bool setOperatorMapSettings(const QJsonValue &data) override;
//@}
/*! \name MovementTrackManager */
//@{
QByteArray movementTrackManagerSettingsJson() const override;
bool setMovementTrackManagerSettingsJSon(const QByteArray &data) override;
QJsonObject movementTrackManagerSettings() const override;
bool setMovementTrackManagerSettings(const QJsonValue &data) override;
//@}
/*! \name Plan / Overlay */
//@{
QList<int> planOverlayList() const override;
QList<int> planOverlayIdsFromOperatorMapSettings(const QJsonValue &data) const override;
QByteArray planOverlayContent(int id) const override;
bool planOverlaySetContent(int id, const QString &name, const QByteArray &xmlContent, bool isSnapshot = false) override;
bool planOverlayRemove(int id) override;
void planOverlayChangeOrder(const QVector<int> &orderOfIds) override;
double planOverlayOpacity(int id) override;
double planOverlayMinScale(int id) override;
double planOverlayMaxScale(int id) override;
bool planOverlayVisibility(int id) override;
void setPlanOverlayOpacity(int id, double opacity) override;
void setPlanOverlayMinScale(int id, double minScale) override;
void setPlanOverlayMaxScale(int id, double maxScale) override;
void setPlanOverlayVisibility(int id, bool on) override;
double getCurrentMapScale() const override;
//@}
/*! \name Configure Map Urls... */
//@{
LtsWidgets::LtsDialog *onShowConfigureUrlsDialog(QWidget *parent);
//@}
/*! \name Image... */
//@{
bool toImage(QObject *context, const std::function<void(const QImage &)> &imageCompletedCallback) override;
void onSaveAsImageRequested();
//@}
void showExerciseTimeString(bool visible = false) override;
void executePayload(LtsWidgets::LtsBackgroundWidget *mainBackground) override;
int executionPriority() const override { return 9999; }
// Script Player Playback Controls:
//bool addToLayout(QLayout *thatLayout) override;
//QWidget *createWidget() override;
QWidget *reCreateSituationMapInit();
void reCreateSituationMapInitAndAddToLayout();
void reCreateSituationMapInitAndAddToLayoutAndReInit();
// void playbackPause();
// void playbackStart();
TopicReplay::Interface *createInterface(TopicEditorBase::TopicType) override;
// Script Editor Topic Editor:
TopicEditorBase::TopicEditor *createTopicEditor(const TopicEditorBase::TopicData &data) override;
private:
bool checkSlots(QObject *objToInform, const char *signalToConnect, const char *replySlot, const char *errorSlot);
QMetaMethod getMethod(QObject *objectToInform, const char *slotToExecute, const char *signalSignature);
SituationMap::RB::RubberbandRectangle *getRubberbandRectangle(QObject *objectToInform, bool finishAfterCreation, double minWidth, double maxWidth, double minHeight, double maxHeight);
SituationMap::RB::RubberbandMultiPointFeature *getRubberbandMultiPoint(QObject *objectToInform, bool closed, int minPoints, int maxPoints, double minSegmentLength, double maxSegmentLength, const QPolygonF &coordinates);
template<typename T> T *createRubberband(QObject *parent);
void onError(SituationMap::RB::Rubberband *rb, const QString &errMsg);
void adjustMapAccordingRubberband(const QVector<QPointF> &coords);
bool isAutoSetExerciseTimeString() const;
void getCircleSectorRotationAndAngles(QPointF sectStart, QPointF sectEnd, double &rotationDegOut, double &openAngleDegOut);
void doFindChild();
bool restoreOperatorMapSettingsOverlays(OperatorMapSettings &oms);
void doPrint();
private Q_SLOTS:
void onSessionAboutToBeDestroyed();
void onChangeModeRequested();
bool removePreviewObject() override;
void onMapObjectsClickedByIds(const QVector<SituationMap::UniqueMapId> &uniqueMapIds, bool supportWaitDialog = true);
void onMapObjectsClicked(const SituationMap::Map::RefPointerMapObjectList &mapObjList);
void onServiceMonitorRequested(const QVector<int> &equipmentNumbers, bool replace);
void enableDisable();
void onInitialOperatorMapSettingsTimeout();
void onParticipantPositionChanged(const int32_t participantId, const Point3D &newPos);
void onTrainingAreaChanged(const AssetManagement::TrainingArea &trainingArea, DataModification modType);
bool restoreOcSituationRange();
// FilterManagement
void onTriggerFilterDataChanged(const FilterManagement::TriggerFilterData &data, DataModification modType);
private:
QPointer<MyMapWidgetDialog> m_ltsDialogSitMapWidget;
QPointer<MapWidgetControl> m_mapWidgetControl;
QPointer<LayerControlDialog> m_mapLayerControl;
QPointer<ConfigureMapUrls> m_configureMapUrls;
// enable access to menueEntries to enable/disable them according 2D, 3D etc:
// assignment is done using doFindChild
QPointer<LtsWidgets::LtsDragIcon> menueBtnMapWidgets;
QPointer<LtsWidgets::LtsDragIcon> menueBtnParticipantAggregation;
QPointer<LtsWidgets::LtsDragIcon> menueBtnRocket;
QPointer<LtsWidgets::LtsDragIcon> menueBtnClearMeasurement;
QPointer<LtsWidgets::LtsDragIcon> menueBtnStartMeasurement;
QPointer<LtsWidgets::LtsDragIcon> menueBtnBuildingOwnership;
QPointer<LtsWidgets::LtsDragIcon> menueBtnBuildingContamination;
QPointer<LtsWidgets::LtsDragIcon> menueBtn3dBuildingsVisible;
QPointer<LtsWidgets::LtsDragIcon> menueBtnConfigureMapUrls;
QPointer<LtsWidgets::LtsDragIcon> menueBtnStartTerrainProfile;
QPointer<LtsWidgets::LtsDragIcon> menueBtnClearTerrainProfile;
QPointer<LtsWidgets::LtsDragIcon> menueBtnStartViewshed;
QPointer<LtsWidgets::LtsDragIcon> menueBtnClearViewshed;
// viewshed :
void buildViewshedDialog();
double m_ViewshedAlpha = 1.0;
double m_ViewshedInnerRadius = 50.0;
double m_ViewshedObserverHeight = 1.8;
double m_ViewshedTargetHeight = 1.8;
double m_ViewshedBeamAngle = 2.0;
// : viewshed
struct OCRange
{
QPointF center;
double radius{0};
int participantId{-1};
UniqueMapId uniqueMapId = SituationMap::INVALID_MAP_ID;
QMetaObject::Connection connection;
};
OCRange m_ocRange;
struct escOrderPosition
{
QPointF origin;
int width{-1};
int depthOrRadius{-1};
int participantId{-1};
UniqueMapId uniqueMapId = SituationMap::INVALID_MAP_ID;
QMetaObject::Connection connection;
};
escOrderPosition m_escOrderStartPosition;
escOrderPosition m_escOrderAreaPosition;
QPointer<SituationMapInit> m_situationMapInit;
QPointer<SituationMap::MovementTrackManager> m_movementTrackManager;
QPointer<Map> m_situationMap;
QPointer<PluginProviderLtsSession> m_pluginProvider;
QPointer<TerrainProfileHandler> m_terrainProfileHandler;
QPointer<MapObjectSelectionLtsDialog> m_dialogMapObjectSelection;
OperatorMapSettings m_operatorMapSettings2achieve;
RegisterAppHandler &m_registerAppHandler;
QPointer<QTimer> m_waitForInitialOperatorMapSettings;
LtsWidgets::LtsDialog *onShowSituationMapDialog(QWidget *parent);
LtsWidgets::LtsDialog *onShowMapWidgetControlDialog(QWidget *parent);
LtsWidgets::LtsDialog *onShowLayerControlDialog(QWidget *parent);
QMetaMethod m_replySlot;
QMetaMethod m_errorSlot;
QObject *m_objToInform { nullptr };
QSet<UniqueMapId> m_uniqueMapIdOfPreviewObject;
std::shared_ptr<AdvancedSymbology::ForeignGuiFlmSymbolsProxyInterface> m_asbGuiIfc { nullptr };
std::shared_ptr<AssetManagement::Interface::Dtc> m_asmDtc { nullptr };
QVector<QPointF> m_trainingsAreaExtent;
};
class TopicReplayInterface : public TopicReplay::Interface
{
public:
explicit TopicReplayInterface();
~TopicReplayInterface();
QWidget *createWidget() override;
void setExportPlaybackTimes(
qint64 startTimeSec, qint64 durationSec, const QVector<SituationReplayTime> &sitReplayTimes
) override;
bool exportTopic(
const QJsonObject &attributes, const QString &folderPath, TopicEditorBase::ExportNotifier *pExportNotifier
) override;
private:
qint64 m_startTimeSec;
qint64 m_durationSec;
QVector<SituationReplayTime> m_sitReplayTimes;
NGL::INGLLogger &m_logger;
};
} // namespace SituationMap