147 lines
5.3 KiB
C++
Executable File
147 lines
5.3 KiB
C++
Executable File
/**
|
|
*@RDE_HEADER@
|
|
* Gui Plugin for SituationReplay - Replay Control
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
* Created by Patric Karwat, SLSE, 2016-07-27
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <SituationReplay/logger.h>
|
|
#include <PluginInterfaces/gui_plugin_interface.h>
|
|
#include <PluginInterfaces/topic_replay_interface.h>
|
|
#include <Plugins/SituationReplay/srp_data_plugin_interface.h>
|
|
#include <Plugins/SituationReplay/srp_gui_plugin_interface.h>
|
|
#include <Plugins/MarkerManagement/mrk_data_plugin_interface.h>
|
|
#include <Plugins/MarkerManagement/mrk_gui_plugin_interface.h>
|
|
#include <Plugins/SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
|
#include <MarkerManagement/Gui/Common/mrk_apply_filter.h>
|
|
#include <QPointer>
|
|
|
|
|
|
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<GuiPluginBase::Interface> 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<LtsWidgets::PluginData> 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<MarkerManagement::MarkerManagementApplyFilter> &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<SituationReplay::Interface::Dtc> m_dtc;
|
|
std::shared_ptr<SituationReplay::Interface::Ftc> m_ftc;
|
|
std::shared_ptr<MarkerManagement::Interface::Dtc> m_mrkDtc;
|
|
std::shared_ptr<MarkerManagement::ForeignGuiInterface> m_mrkIfc;
|
|
SituationReplay::ForeignGuiInterface *m_essentialsViewSrpIfc { nullptr };
|
|
SituationMap::ForeignGuiInterface *m_essentialsViewSitMapIfc { nullptr };
|
|
std::shared_ptr<SituationMap::ForeignGuiInterface> m_sitMapGuiIfc;
|
|
|
|
qint64 m_playbackStartTime;
|
|
qint64 m_playbackEndTime;
|
|
double m_playbackSpeed;
|
|
QPointer<SituationReplayControlWidget> m_replayWidget; // there can only be one dialog!
|
|
|
|
QPointer<MarkerManagement::MarkerManagementApplyFilter> 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<TopicEditorBase::TopicData> 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
|