graph_analysis
VertexItemTypeManager.hpp
Go to the documentation of this file.
1 #ifndef GRAPH_ANALYSIS_GUI_VERTEX_ITEM_TYPE_MANAGER_HPP
2 #define GRAPH_ANALYSIS_GUI_VERTEX_ITEM_TYPE_MANAGER_HPP
3 
4 #include <map>
5 #include <base-logging/Singleton.hpp>
6 #include "../Vertex.hpp"
7 
8 #include <QPainter>
9 #include <QPainterPath>
10 #include <QGraphicsItem>
11 #include <QGraphicsView>
12 
13 namespace graph_analysis {
14 namespace gui {
15 
16 namespace vertex {
17  typedef std::string Type;
18 }
19 
20 class VertexItemBase;
21 class GraphWidget;
22 
28 class VertexItemTypeManager : public base::Singleton<VertexItemTypeManager>
29 {
30 public:
31  typedef std::map<vertex::Type, VertexItemBase*> ClassVisualizationMap;
32 
33 private:
35  ClassVisualizationMap mClassVisualizationMap;
37  VertexItemBase* graphicsItemByType(const vertex::Type& type, bool throwOnDefault = false);
38 
39 protected:
44  friend class base::Singleton<VertexItemTypeManager>;
45 public:
46 
47  // Register visualization class
48  // takes ownership of graphicsItem
49  void registerVisualization(const vertex::Type& type, VertexItemBase* graphicsItem, bool throwOnAlreadyRegistered = false);
50 
59  VertexItemBase* createItem(GraphWidget* graphWidget,
60  const graph_analysis::Vertex::Ptr& vertex,
61  QGraphicsItem* parent,
62  const std::string& type = std::string());
63 
68  QStringList getSupportedTypes() const;
69 };
70 
71 } // end namespace gui
72 } // end namespace graph_analysis
73 #endif // GRAPH_ANALYSIS_GUI_VERTEX_ITEM_TYPE_MANAGER_HPP
std::map< vertex::Type, VertexItemBase * > ClassVisualizationMap
Definition: VertexItemTypeManager.hpp:31
factory for VertexItem-s: clones different types of VertexItem instances (i.e. graphical vertexs) ...
Definition: VertexItemTypeManager.hpp:28
std::string Type
Definition: VertexItemTypeManager.hpp:17
Base-class for visual representations of a "Graph" in this framework.
Definition: GraphWidget.hpp:26
Main namespace of the graph analysis library.
Definition: BFS.cpp:3
shared_ptr< Vertex > Ptr
Definition: Vertex.hpp:22
graphical node representation interface
Definition: VertexItemBase.hpp:26