00001 #ifndef LAYOUTPLUGIN_H 00002 #define LAYOUTPLUGIN_H 00003 00004 #include <unordered_map> 00005 #include <Graph.h> 00006 #include <QVector2D> 00007 #include <QtPlugin> 00008 00009 #include <System.h> 00010 #include "Plugin.h" 00011 00012 #define LayoutPlugin_iid "ch.epfl.lap.elfe.LayoutPlugin" 00013 00014 00015 00016 namespace Elve { 00017 class GraphWidgetListener; 00018 class LayoutPlugin; 00019 typedef std::shared_ptr<LayoutPlugin> SharedLayout; 00020 class ExtendedGraph; 00021 typedef std::shared_ptr<ExtendedGraph> SharedEGraph; 00022 00033 class LayoutPlugin : public QObject, public Plugin 00034 { 00035 Q_OBJECT 00036 public: 00040 LayoutPlugin(); 00041 00046 LayoutPlugin(const LayoutPlugin& other); 00047 00053 void clear(); 00054 00059 virtual void setGraph(SharedGraph graph) = 0; 00060 00061 virtual QJsonObject json() const; 00062 00063 virtual void fromJson(const QJsonObject& layout); 00064 00075 QVector2D startPosition(const NodeID& id); 00076 00086 virtual void setGraph(SharedEGraph g, const NodePositions& positions); 00087 00094 virtual void quickSim(size_t ticks); 00095 00104 virtual void tick(float dt, bool fast); 00105 00110 virtual SharedLayout create() = 0; 00111 00116 virtual QString name() const = 0; 00117 00122 virtual std::string cliName() = 0; 00123 00134 virtual void uiStart(Elve::GraphWidgetListener* listener,const SharedEGraph& graph); 00135 00140 System& system(); 00141 00146 const System& system() const; 00147 00151 virtual ~LayoutPlugin(){} 00152 private: 00153 System mSystem; 00154 NodePositions mStartPositions; 00155 }; 00156 00157 } 00158 00159 Q_DECLARE_INTERFACE(Elve::LayoutPlugin,LayoutPlugin_iid) 00160 00161 00162 #define ELVE_LAYOUT(Layout,full_name,cli_name)\ 00163 public:\ 00164 inline Elve::SharedLayout create() override {return std::make_shared<Layout>(*this);}\ 00165 inline QString name() const override {return (full_name);}\ 00166 inline std::string cliName() override {return (cli_name);} 00167 00168 #endif // LAYOUTPLUGIN_H