ELVE  1
ELVE Logic Visualization Explorer
/home/travis/build/stdgregwar/elve/Core/ExtendedGraph.h
00001 #ifndef EGRAPH_H
00002 #define EGRAPH_H
00003 
00004 #include "Graph.h"
00005 #include <array>
00006 #include "interfaces/LayoutPlugin.h"
00007 #include "interfaces/LookFactoryPlugin.h"
00008 #include "Selection.h"
00009 #include "CommandHistory.h"
00010 #include <memory>
00011 
00012 namespace Elve {
00013 
00014 class ExtendedGraph;
00015 
00016 typedef std::shared_ptr<ExtendedGraph> SharedEGraph;
00017 typedef std::array<Selection,10> SelectionMasks;
00018 
00019 class GraphWidget;
00020 
00027 class ExtendedGraph : public std::enable_shared_from_this<ExtendedGraph>
00028 {
00029 public:
00035     ExtendedGraph(const SharedGraph& g, const NodePositions& positions = NodePositions());
00036 
00042     static SharedEGraph fromJSON(const QJsonObject& obj);
00043 
00049     static SharedEGraph fromGraph(const SharedGraph& g);
00050 
00056     static SharedEGraph fromFile(const QString& filename);
00057 
00062     void toFile(const QString& filename);
00063 
00070     SharedEGraph group(const NodeIDSet &names, const NodeName &groupName);
00071 
00077     SharedEGraph ungroup(const NodeIDSet &names) const;
00078 
00083     SelectionMasks& selections();
00084 
00090     Selection& selection(size_t i);
00091 
00097     Selection invertedSelection(size_t i) const;
00098 
00103     Selection& currentSelection();
00104 
00109     QJsonObject json() const;
00110 
00115     const NodePositions &positions() const;
00116 
00121     const SharedGraph& graph() const;
00122 
00127     void setLayout(const SharedLayout& l);
00128 
00133     void setLook(const SharedLook& l);
00134 
00139     void setMask(int id);
00140 
00145     int mask() const;
00146 
00151     const SharedLayout& layout();
00152 
00157     const SharedLook& look();
00158 
00163     CommandHistory& history();
00164 
00169     void setView(GraphWidget* view);
00170 
00175     GraphWidget* view();
00176     SharedEGraph clone(const SharedGraph& graph, const NodePositions& positions = {}) const;
00177     ~ExtendedGraph();
00178 private:
00179     mutable bool mPosDirty;
00180     SharedGraph mGraph;
00181     mutable NodePositions mPositions; //Defining last saved node positions
00182     CommandHistory mHistory;
00183     SharedLayout mLayout;
00184     SharedLook mLook;
00185     GraphWidget* mView;
00186     SelectionMasks mSelections;
00187     int mMaskId; 
00188 };
00189 
00190 }
00191 
00192 #endif // EGRAPH_H
 All Classes Functions