graph_analysis
EdgeItem.hpp
Go to the documentation of this file.
1 #ifndef GRAPH_ANALYSIS_GUI_EDGEITEM_HPP
2 #define GRAPH_ANALYSIS_GUI_EDGEITEM_HPP
3 
4 #include <QGraphicsItem>
5 #include <QGraphicsItemGroup>
6 #include <QPainter>
7 #include <math.h>
8 #include "../Edge.hpp"
9 
10 #include "GraphicsItemTypes.hpp"
11 
12 namespace graph_analysis {
13 namespace gui {
14 
15 class GraphWidget;
16 
17 namespace items {
18  class EdgeLabel;
19 }
26 class EdgeItem : public QGraphicsItemGroup
27 {
28 public:
30  EdgeItem() {}
32  ~EdgeItem() {}
33 
41  EdgeItem(GraphWidget* graphWidget, QGraphicsItem* source, QGraphicsItem* target, graph_analysis::Edge::Ptr edge);
42 
44  QGraphicsItem* sourceItem() const { return mpSourceItem; }
46  QGraphicsItem* targetItem() const { return mpTargetItem; }
47 
49  virtual void adjust();
50 
52  int type() const { return EdgeItemType; }
53 
55  graph_analysis::Edge::Ptr getEdge() { return mpEdge; }
56 
57  // virtual methods. FIXME: this should be static, really...
58  virtual EdgeItem* createNewItem(GraphWidget* graphWidget,
59  QGraphicsItem* source,
60  QGraphicsItem* target,
61  graph_analysis::Edge::Ptr edge) const
62  { throw std::runtime_error("graph_analysis::gui::EdgeItem::createNewItem (@4 args) is not reimplemented"); }
63 
64  virtual void setLabel(const std::string&) { throw std::runtime_error("graph_analysis::gui::EdgeItem::setLabel is not reimplemented"); }
65  virtual graph_analysis::gui::items::EdgeLabel* getLabel() { throw std::runtime_error("graph_analysis::gui::EdgeItem: edge label is not implemented at this level"); }
66  virtual void adjustLabel() { throw std::runtime_error("graph_analysis::gui::EdgeItem::adjustLabel is not reimplemented"); }
67 
68 protected:
72  QGraphicsItem* mpSourceItem;
74  QGraphicsItem* mpTargetItem;
75 
78 
80  QPointF mSourcePoint;
82  QPointF mTargetPoint;
84  qreal mArrowSize;
85 
87  virtual QRectF boundingRect() const;
89  virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem* option, QWidget* widget);
91 
92  virtual void hoverEnterEvent(QGraphicsSceneHoverEvent* event);
93  virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent* event);
94 
95 };
96 
97 } // end namespace gui
98 } // end namespace graph_analysis
99 #endif // GRAPH_ANALYSIS_GUI_EDGEITEM_HPP
virtual EdgeItem * createNewItem(GraphWidget *graphWidget, QGraphicsItem *source, QGraphicsItem *target, graph_analysis::Edge::Ptr edge) const
Definition: EdgeItem.hpp:58
QPointF mTargetPoint
in-scene edge target point
Definition: EdgeItem.hpp:82
virtual void adjustLabel()
Definition: EdgeItem.hpp:66
QGraphicsItem * targetItem() const
getter method to retrieve target node
Definition: EdgeItem.hpp:46
virtual graph_analysis::gui::items::EdgeLabel * getLabel()
Definition: EdgeItem.hpp:65
shared_ptr< Edge > Ptr
Definition: Edge.hpp:21
qreal mArrowSize
arrow tip size
Definition: EdgeItem.hpp:84
GraphWidget * mpGraphWidget
parent and managing graph widget
Definition: EdgeItem.hpp:70
graphical edge representation interface
Definition: EdgeItem.hpp:26
int type() const
getter method to retrieve constant
Definition: EdgeItem.hpp:52
graph_analysis::Edge::Ptr mpEdge
internal conceptual edge on whose basis the edge&#39;s been constructed
Definition: EdgeItem.hpp:77
Base-class for visual representations of a "Graph" in this framework.
Definition: GraphWidget.hpp:26
QGraphicsItem * mpSourceItem
source edge-endpoint
Definition: EdgeItem.hpp:72
virtual void setLabel(const std::string &)
Definition: EdgeItem.hpp:64
Main namespace of the graph analysis library.
Definition: BFS.cpp:3
EdgeItem()
empty constructor
Definition: EdgeItem.hpp:30
graph_analysis::Edge::Ptr getEdge()
getter method to retrieve the internal conceptual edge
Definition: EdgeItem.hpp:55
~EdgeItem()
destructor
Definition: EdgeItem.hpp:32
QPointF mSourcePoint
in-scene edge source point
Definition: EdgeItem.hpp:80
graphical edge text label implementation
Definition: EdgeLabel.hpp:18
QGraphicsItem * mpTargetItem
target edge-endpoint
Definition: EdgeItem.hpp:74
Definition: GraphicsItemTypes.hpp:11
QGraphicsItem * sourceItem() const
getter method to retrieve source node
Definition: EdgeItem.hpp:44