/** * @RDE_HEADER@ * Gui Plugin for SituationMap * $Id$ * $HeadURL$ * $Author$ * Created by Patric Karwat, SLSE, 2016-02-29 */ #pragma once #include #include #include #include "sitmap_register_app_handler.h" #include "sitmap_layer_control.h" // AdvancedSymbology #include // ASM #include // TopicReplay #include // PlanOverlay #include // FilterManagement #include #include #include #include #include #include #include #include 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 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 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() const override; void setMapUpdatesEnabled(bool bEnabled) override; bool isMapReady() const override; bool setMapReadyCallback(QObject *context, const std::function &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 &cb) override; bool clearObjects() override; void enableMovementTrack(int participantId, bool enable) override; bool isMovementTrackEnabled(int participantId) override; bool setMovementTrackCallback(QObject *context, const std::function &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 ¢er, 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> &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 &entityIds) override; bool openMapObjectSelection(const QVector &mapObjectTypeEntityIdPairs) override; bool setMapObjectSelected(MapObjectType mot, const QVector &entityIds, bool selection = true) override; bool clearMapObjectSelection(MapObjectType mot = MapObjectType::MOT_Undefined) override; //@} QVector getParallelTranslation(const QVector &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 &segments = QVector() , double width = 0.0) override; bool getCircle(QObject *objectToInform , const char *replySlot , const char *errorSlot , double radiusMin , double radiusMax , const QPointF ¢er = QPointF() , double initialRadius = 0.0) override; bool getCircleSectorFixRadius(QObject *objectToInform , const char *replySlot , const char *errorSlot , double radius , const QPointF ¢er = 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 ¢er = 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 ¢er = 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 ¢er = 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 &polyVec, bool closed) override; bool displayPreviewObject(QObject *parent, const QPointF ¢erGeo, double radius) override; bool displayPreviewObjects(QObject *parent, const QVector ¢erGeoVec, double radius) override; // introduced for BoobyTraps: bool displayPreviewObject(QObject *parent, const QPointF ¢erPoint, double radius, double rotationDeg, double centralAngleDeg) override; // introduced for CollateralDamage: bool displayPreviewObjects(QObject *parent, const QVector &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 planOverlayList() const override; QList 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 &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 &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 T *createRubberband(QObject *parent); void onError(SituationMap::RB::Rubberband *rb, const QString &errMsg); void adjustMapAccordingRubberband(const QVector &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 &uniqueMapIds, bool supportWaitDialog = true); void onMapObjectsClicked(const SituationMap::Map::RefPointerMapObjectList &mapObjList); void onServiceMonitorRequested(const QVector &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 m_ltsDialogSitMapWidget; QPointer m_mapWidgetControl; QPointer m_mapLayerControl; QPointer m_configureMapUrls; // enable access to menueEntries to enable/disable them according 2D, 3D etc: // assignment is done using doFindChild QPointer menueBtnMapWidgets; QPointer menueBtnParticipantAggregation; QPointer menueBtnRocket; QPointer menueBtnClearMeasurement; QPointer menueBtnStartMeasurement; QPointer menueBtnBuildingOwnership; QPointer menueBtnBuildingContamination; QPointer menueBtn3dBuildingsVisible; QPointer menueBtnConfigureMapUrls; QPointer menueBtnStartTerrainProfile; QPointer menueBtnClearTerrainProfile; QPointer menueBtnStartViewshed; QPointer 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 m_situationMapInit; QPointer m_movementTrackManager; QPointer m_situationMap; QPointer m_pluginProvider; QPointer m_terrainProfileHandler; QPointer m_dialogMapObjectSelection; OperatorMapSettings m_operatorMapSettings2achieve; RegisterAppHandler &m_registerAppHandler; QPointer 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 m_uniqueMapIdOfPreviewObject; std::shared_ptr m_asbGuiIfc { nullptr }; std::shared_ptr m_asmDtc { nullptr }; QVector m_trainingsAreaExtent; }; class TopicReplayInterface : public TopicReplay::Interface { public: explicit TopicReplayInterface(); ~TopicReplayInterface(); QWidget *createWidget() override; void setExportPlaybackTimes( qint64 startTimeSec, qint64 durationSec, const QVector &sitReplayTimes ) override; bool exportTopic( const QJsonObject &attributes, const QString &folderPath, TopicEditorBase::ExportNotifier *pExportNotifier ) override; private: qint64 m_startTimeSec; qint64 m_durationSec; QVector m_sitReplayTimes; NGL::INGLLogger &m_logger; }; } // namespace SituationMap