statepublisher_base.h
Go to the documentation of this file.
00001 #ifndef STATEPUBLISHER_TEMPLATE_H
00002 #define STATEPUBLISHER_TEMPLATE_H
00003 
00004 #include <QObject>
00005 #include <QtPlugin>
00006 #include <QMenu>
00007 #include <QDomElement>
00008 #include <functional>
00009 #include "PlotJuggler/plotdata.h"
00010 
00011 
00012 class StatePublisher{
00013 
00014 public:
00015 
00016     virtual bool enabled() const = 0;
00017 
00018     virtual const char* name() const = 0;
00019 
00020     virtual void updateState(double current_time) = 0;
00021 
00022     virtual void play(double interval) = 0;
00023 
00024     virtual ~StatePublisher() {}
00025 
00026     virtual void setEnabled(bool enabled)
00027     {
00028         auto prev = _action->blockSignals(true);
00029         _action->setChecked(enabled);
00030         _action->blockSignals(prev);
00031     }
00032 
00033     virtual bool isDebugPlugin() { return false; }
00034 
00035     virtual void setParentMenu(QMenu* parent_menu, QAction* parent_action)
00036     {
00037         _menu   = parent_menu;
00038         _action = parent_action;
00039     }
00040 
00041     virtual QWidget* embeddedWidget() { return nullptr; }
00042 
00043     virtual bool xmlSaveState(QDomDocument &doc, QDomElement &parent_element) const { return false; }
00044 
00045     virtual bool xmlLoadState(const QDomElement &parent_element ) { return false; }
00046 
00047     void setDataMap(const PlotDataMapRef* datamap) { _datamap = datamap; }
00048 
00049     QDomElement xmlSaveState(QDomDocument &doc) const
00050     {
00051         QDomElement plugin_elem = doc.createElement("plugin");
00052         plugin_elem.setAttribute("ID", QString(this->name()).replace(" ", "_") );
00053         xmlSaveState(doc, plugin_elem);
00054         return plugin_elem;
00055     }
00056 
00057 
00058 protected:
00059     QMenu* _menu;
00060     QAction* _action;
00061     const PlotDataMapRef *_datamap;
00062 };
00063 
00064 QT_BEGIN_NAMESPACE
00065 
00066 #define StatePublisher_iid "com.icarustechnology.PlotJuggler.StatePublisher"
00067 
00068 Q_DECLARE_INTERFACE(StatePublisher, StatePublisher_iid)
00069 
00070 QT_END_NAMESPACE
00071 
00072 
00073 #endif
00074 


plotjuggler
Author(s): Davide Faconti
autogenerated on Wed Jul 3 2019 19:28:05