/** *@RDE_HEADER@ * Gui Plugin for SituationReplay - Replay Control * $Id$ * $HeadURL$ * $Author$ * Created by Patric Karwat, SLSE, 2016-07-27 */ #pragma once #include #include #include #include #include #include #include #include #include #include namespace LtsScriptTimeline { class TopicEditor; } namespace TopicEditorBase { struct TopicData; } namespace SituationReplay { class SituationReplayControlWidget; class GuiPlugin final : public QObject, public GuiPluginBase::Plugin { Q_PLUGIN_METADATA(IID "gui:3:srp") Q_INTERFACES(GuiPluginBase::Plugin) Q_OBJECT public: GuiPlugin() = default; ~GuiPlugin() = default; QString pluginName() override { return QStringLiteral("SituationReplayControl"); } std::shared_ptr createGuiInterface(LtsSession::LtsSession *session) override; bool availableInPartition(IDL::PartitionType partition) const override { return partition == IDL::PartitionType::Replay || partition == IDL::PartitionType::Exercise; // TODO: why exercise? // needed for no good reason inside InterfaceImpl::transportTopicsToReplaySession() - don't // know why there the plugins must be loaded ... } }; class InterfaceImpl final : public QObject, public ForeignGuiInterface, public GuiPluginBase::Interface { Q_OBJECT signals: void signalEssentialsViewChanged(SituationReplay::ForeignGuiInterface *essentialsViewSrpIfc, SituationMap::ForeignGuiInterface *sitMapIfc); public: explicit InterfaceImpl(LtsSession::LtsSession *session); QVector getActions() override; QString menuGroup() const override; bool fetchInterfaces() override; void clearInterfaces() override; bool availableInPartition(IDL::PartitionType partition) const override { return partition == IDL::PartitionType::Replay; } bool startReplay(const qint64 start, const qint64 end = 0/*infinite*/, const double speed = 1.0, const QJsonObject &attributes = QJsonObject()) override; void pauseReplay() override; void stopReplay() override; // for Topic Editor in Script Editor to start a replay in Essentials View instead of the Script Editor void setSitMapIfc(SituationMap::ForeignGuiInterface *sitMapIfc) override; void setEssentialsViewInterfaces(ForeignGuiInterface *srpIfc, SituationMap::ForeignGuiInterface *sitMapIfc) override; void setApplyFilter(const QPointer &applyFilter) override; // Play (single instance only) bool playbackInit(const QJsonObject &attributes); bool playbackStart(int secondsOffset); bool playbackPause(); //void resetMap(); // Edit TopicEditorBase::TopicEditor *createTopicEditor(const TopicEditorBase::TopicData &data) override; LtsSession::LtsSession* getSession() { return m_session; } QWidget *createControlWidget(bool useExistingReplay) override; private: void createReplayDialogIfNeeded(bool useExistingReplay = true); LtsWidgets::LtsDialog *onShowReplayControlDialog(QWidget *parent); private: std::shared_ptr m_dtc; std::shared_ptr m_ftc; std::shared_ptr m_mrkDtc; std::shared_ptr m_mrkIfc; SituationReplay::ForeignGuiInterface *m_essentialsViewSrpIfc { nullptr }; SituationMap::ForeignGuiInterface *m_essentialsViewSitMapIfc { nullptr }; std::shared_ptr m_sitMapGuiIfc; qint64 m_playbackStartTime; qint64 m_playbackEndTime; double m_playbackSpeed; QPointer m_replayWidget; // there can only be one dialog! QPointer m_applyFilter; // QJsonValue m_oldMapData; // QJsonValue m_oldFilterData; SituationMap::ForeignGuiInterface *m_sitMapIfc { nullptr }; // NOTE: this TRI covers the Situation *and* the SituationReplay topic! class TopicReplayInterface : public TopicReplay::Interface { public: explicit TopicReplayInterface(TopicEditorBase::TopicType type, InterfaceImpl *replayControl); ~TopicReplayInterface(); // Script Playback Controls: bool playbackInit(const QJsonObject &attributes) override; bool playbackStart(int secondsOffset) override; bool playbackPause() override; bool exportTopic(const QJsonObject &attributes, const QString &folderPath, TopicEditorBase::ExportNotifier *pExportNotifier) override; QVector additionalTrackEntries(const QJsonObject &attributes, bool &keepOriginalTopic) const override; private: InterfaceImpl *m_replayControl; TopicEditorBase::TopicType m_type; }; TopicReplay::Interface *createInterface(TopicEditorBase::TopicType type) override { return new TopicReplayInterface(type, this); } }; } // namespace SituationReplay