Files
qt5-legatus-legacy/Lts/Plugins/PlanOverlays/Gui/plan_overlays_gui_plugin.h
T
2026-08-13 18:33:10 +02:00

254 lines
7.8 KiB
Objective-C
Executable File

/**
**
** @RDE_HEADER@
** plan_editor_gui_plugin.h
** $Id$
** $HeadURL$
** $Author$
**
** -----------------------------------------------------------------------------------------------
**
** Hardware-Environment: Intel-PC
** Software-Environment: Windows 7, Qt 5.7. ArcGIS 100
**
** Language ........: C++ 11
**
** -----------------------------------------------------------------------------------------------
**
** Author ...........: Jörg Turla, SPD G, Tel. 3132
**
** -----------------------------------------------------------------------------------------------
**
** Notes .........:
**
** 24.04.2017, JT : First edition for use with Qt5
**
** -----------------------------------------------------------------------------------------------
*/
#pragma once
#include "plan_overlay_model.h"
#include <PluginInterfaces/gui_plugin_interface.h>
#include <TopicEditorBase/topic_editor_interface.h>
#include <Common/ProjectConfig/project_defines.h>
#include <Plugins/PlanOverlays/plan_overlays_plugin_interface.h>
#include <Plugins/FileManagement/flm_data_plugin_interface.h>
#include <Plugins/ExerciseManagement/exm_data_plugin_interface.h>
#include <QObject>
namespace Core
{
class FunctionReplyObject;
}
namespace SituationMap
{
class ScriptFilterForeignGuiInterface;
}
namespace PlanOverlaysPlugin
{
/**
@class PlanEOverlaysPlugin
Implementation of plugin base to create interface instance. To use the plugin it has to be configured
in apps.json configuration file. The Type and IID habe to be set to:
- "Type": "gui"
- "IID": "planoverlays"
The PlanEditorGuiPlugin uses the file manager data plugin to read and store data with file manager service.
@see InterfaceImpl, PlanEditor, SituationMap
*/
//------------------------------------------------------------------------------
// PlanOverlaysGuiPlugin
//------------------------------------------------------------------------------
class PlanOverlaysGuiPlugin final : public QObject, public GuiPluginBase::Plugin
{
Q_PLUGIN_METADATA(IID "gui:3:planoverlays")
Q_INTERFACES(GuiPluginBase::Plugin)
Q_OBJECT
public:
explicit PlanOverlaysGuiPlugin() = default;
~PlanOverlaysGuiPlugin() = default;
QString pluginName() override { return QStringLiteral("PlanOverlaysPlugin"); }
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
class InternalData;
InternalData *m_internal;
public:
explicit InterfaceImpl(LtsSession::LtsSession *session);
~InterfaceImpl();
QVector<LtsWidgets::PluginData> getActions() override;
QString menuGroup() const override;
bool fetchInterfaces() override;
void clearInterfaces() override;
/**
Set SituationMapGuiPlugin interface from forgein session. Is used by ScriptEditor to define map view displaying plans.
@param foreignSitMapIfc Pointer to SituationMapGuiPlugin interface used to load plan into map when used by ScriptEditor
*/
void setForeignSitMapGuiIfc(SituationMap::ForeignGuiInterface *foreignSitmapIfc) override;
void setForeignPlanOverlaysGuiIfc(ForeignGuiInterface *ifc) override;
bool loadPlanByUser(int planFileId);
/**
@brief Load a plan as overlay into map
@param planFileId File-Id of plan in file management service
@return
*/
bool loadPlan(int planFileId) override; // TODO: move to slots
/**
Load a plan as overlay into map
@param planFileId File-Id of plan in file management service
@param applyMinMaxScaleOfMetadata The xmlContent may contain minScale, maxScale. Apply them?
*/
bool loadPlan(int planFileId, const QJsonObject &planItemObject) override;
/**
bool loadPlan(int planFileId) override;
Load a plan as overlay into map
@param planFileId File-Id of plan in file management service
@param applyMinMaxScaleOfMetadata The xmlContent may contain minScale, maxScale. Apply them?
@param overrideSitMapIfc Pointer to SituationMapGuiPlugin interface used to load plan into map
*/
bool loadPlan(int planFileId, bool applyMinMaxScaleOfMetadata, SituationMap::ForeignGuiInterface *overrideSitMapIfc, const QJsonObject &planItemObject = QJsonObject());
/**
* @brief unloadAllPlans
* Unload all plans: remove from update model (update GUI), removePlan from sitMap
* (Usefull for SnapshotDialog::showSnapshotInternal)
* @return true
*/
bool unloadAllPlans() override;
TopicEditorBase::TopicEditor *createTopicEditor(const TopicEditorBase::TopicData &data) override;
QWidget *openPlanOverlayDialog(const QJsonArray &planItems = QJsonArray(), bool removePlansOnClose = false) override;
PlanOverlayModel *planOverlayModel() override;
private:
/**
Reload an already loaded plan.
@param planId Id of the plan (keyId) from PlanOverlayModel
*/
void onReloadPlanById(int planId);
/**
Reload an already loaded plan.
@param planId Id of the plan (keyId) from PlanOverlayModel
*/
void onUpdatePlan(int planId);
/**
Remove a plan from map
@param planId Id of the plan (keyId) from PlanOverlayModel
*/
bool removePlan(int planId);
/**
Remove a plan from map
@param planId Id of the plan (keyId) from PlanOverlayModel
@param overrideSitMapIfc Pointer to SituationMapGuiPlugin interface used to remove plan from map
*/
bool removePlan(int planId, SituationMap::ForeignGuiInterface *overrideSitMapIfc);
void onChangePlanMinScaleOnMap(int planId, double minScale);
void onChangePlanMaxScaleOnMap(int planId, double maxScale);
/**
Change opacity of a plan
@param planId Id of the plan (keyId) from PlanOverlayModel
*/
void onChangePlanOpacityOnMap(int planId, double opacity);
/**
Change order of plans on map.
@param newIdOrder Order of plan ids
*/
void onChangePlanOrderOnMap(const QVector<int> & newIdOrder);
void onPlanContentChanged(const FileManagement::FileContent &data, DataModification modType);
void onExerciseChanged(const ExerciseManagement::Exercise &data, DataModification modType);
void onReloadPlanByName(const PlanOverlayModel::PlanItem &planItem, int exerciseId, int phaseId, bool *removeFromModel);
// Script Player
class TopicReplayInterface : public TopicReplay::Interface
{
public:
TopicReplayInterface(SituationMap::ForeignGuiInterface* overrideSitmapIfc,
InterfaceImpl *ovr);
~TopicReplayInterface();
bool playbackInit(const QJsonObject &attributes) override;
bool playbackStop() override;
// overlays are treated special, not exported here atm
bool exportTopic(const QJsonObject &,
const QString &,
TopicEditorBase::ExportNotifier *) override
{
Q_ASSERT(false);
return false;
}
QVector<TopicEditorBase::TopicData> additionalTrackEntries(const QJsonObject &attributes, bool &keepOriginalTopic) const override;
private:
InterfaceImpl *m_ovr;
SituationMap::ForeignGuiInterface *m_foreignSitmapIfc;
//int m_planFileId;
QVector<int> m_loadedPlanFileIds;
NGL::INGLLogger &m_logger;
}; // TopicReplayInterface
TopicReplay::Interface *createInterface(TopicEditorBase::TopicType) override;
ForeignGuiInterface *m_foreignIfc;
QPointer<QWidget> m_planOverlayDialog;
};
} // namespace PlanOverlaysPlugin