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 
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
graph_analysis::gui::VertexItemTypeManager
factory for VertexItem-s: clones different types of VertexItem instances (i.e. graphical vertexs)
Definition: VertexItemTypeManager.hpp:28
graph_analysis::gui::VertexItemTypeManager::createItem
VertexItemBase * createItem(GraphWidget *graphWidget, const graph_analysis::Vertex::Ptr &vertex, QGraphicsItem *parent, const std::string &type=std::string())
clones a new graphical vertex of a specified type
Definition: VertexItemTypeManager.cpp:62
graph_analysis::gui::VertexItemTypeManager::ClassVisualizationMap
std::map< vertex::Type, VertexItemBase * > ClassVisualizationMap
Definition: VertexItemTypeManager.hpp:31
graph_analysis::gui::VertexItemTypeManager::~VertexItemTypeManager
~VertexItemTypeManager()
destructor
Definition: VertexItemTypeManager.cpp:21
graph_analysis::gui::vertex::Type
std::string Type
Definition: VertexItemTypeManager.hpp:17
graph_analysis
Main namespace of the graph analysis library.
Definition: BFS.cpp:3
graph_analysis::gui::VertexItemTypeManager::getSupportedTypes
QStringList getSupportedTypes() const
Definition: VertexItemTypeManager.cpp:76
graph_analysis::Vertex::Ptr
shared_ptr< Vertex > Ptr
Definition: Vertex.hpp:22
graph_analysis::gui::VertexItemTypeManager::VertexItemTypeManager
VertexItemTypeManager()
constructor
Definition: VertexItemTypeManager.cpp:16
graph_analysis::gui::VertexItemTypeManager::registerVisualization
void registerVisualization(const vertex::Type &type, VertexItemBase *graphicsItem, bool throwOnAlreadyRegistered=false)
Definition: VertexItemTypeManager.cpp:30
graph_analysis::gui::GraphWidget
Base-class for visual representations of a "Graph" in this framework.
Definition: GraphWidget.hpp:26
graph_analysis::gui::VertexItemBase
graphical node representation interface
Definition: VertexItemBase.hpp:26