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 
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
graph_analysis::gui::EdgeItem::adjust
virtual void adjust()
updates edge graphics: edge lenght and endpoints positioning
graph_analysis::gui::EdgeItem::~EdgeItem
~EdgeItem()
destructor
Definition: EdgeItem.hpp:32
graph_analysis::gui::EdgeItem::getEdge
graph_analysis::Edge::Ptr getEdge()
getter method to retrieve the internal conceptual edge
Definition: EdgeItem.hpp:55
graph_analysis::gui::EdgeItem
graphical edge representation interface
Definition: EdgeItem.hpp:26
graph_analysis::gui::EdgeItem::mSourcePoint
QPointF mSourcePoint
in-scene edge source point
Definition: EdgeItem.hpp:80
graph_analysis::gui::items::EdgeLabel
graphical edge text label implementation
Definition: EdgeLabel.hpp:18
graph_analysis
Main namespace of the graph analysis library.
Definition: BFS.cpp:3
graph_analysis::Edge::Ptr
shared_ptr< Edge > Ptr
Definition: Edge.hpp:21
graph_analysis::gui::EdgeItem::boundingRect
virtual QRectF boundingRect() const
retrieves the bounding rectangular box around the area occupied by the node in the scene
GraphicsItemTypes.hpp
graph_analysis::gui::EdgeItem::hoverEnterEvent
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event)
retrieves the path of the bounding rectangular box around the area occupied by the node in the scene
graph_analysis::gui::EdgeItem::mpTargetItem
QGraphicsItem * mpTargetItem
target edge-endpoint
Definition: EdgeItem.hpp:74
graph_analysis::gui::EdgeItem::sourceItem
QGraphicsItem * sourceItem() const
getter method to retrieve source node
Definition: EdgeItem.hpp:44
graph_analysis::gui::EdgeItem::paint
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
qt node painting method - here the node components get placed in the scene
graph_analysis::gui::EdgeItem::mTargetPoint
QPointF mTargetPoint
in-scene edge target point
Definition: EdgeItem.hpp:82
graph_analysis::gui::EdgeItem::createNewItem
virtual EdgeItem * createNewItem(GraphWidget *graphWidget, QGraphicsItem *source, QGraphicsItem *target, graph_analysis::Edge::Ptr edge) const
Definition: EdgeItem.hpp:58
graph_analysis::gui::EdgeItem::adjustLabel
virtual void adjustLabel()
Definition: EdgeItem.hpp:66
graph_analysis::gui::EdgeItem::targetItem
QGraphicsItem * targetItem() const
getter method to retrieve target node
Definition: EdgeItem.hpp:46
graph_analysis::gui::EdgeItem::getLabel
virtual graph_analysis::gui::items::EdgeLabel * getLabel()
Definition: EdgeItem.hpp:65
graph_analysis::gui::EdgeItem::mArrowSize
qreal mArrowSize
arrow tip size
Definition: EdgeItem.hpp:84
graph_analysis::gui::EdgeItemType
@ EdgeItemType
Definition: GraphicsItemTypes.hpp:11
graph_analysis::gui::EdgeItem::type
int type() const
getter method to retrieve constant
Definition: EdgeItem.hpp:52
graph_analysis::gui::EdgeItem::hoverLeaveEvent
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
graph_analysis::gui::GraphWidget
Base-class for visual representations of a "Graph" in this framework.
Definition: GraphWidget.hpp:26
graph_analysis::gui::EdgeItem::mpSourceItem
QGraphicsItem * mpSourceItem
source edge-endpoint
Definition: EdgeItem.hpp:72
graph_analysis::gui::EdgeItem::mpGraphWidget
GraphWidget * mpGraphWidget
parent and managing graph widget
Definition: EdgeItem.hpp:70
graph_analysis::gui::EdgeItem::setLabel
virtual void setLabel(const std::string &)
Definition: EdgeItem.hpp:64
graph_analysis::gui::EdgeItem::mpEdge
graph_analysis::Edge::Ptr mpEdge
internal conceptual edge on whose basis the edge's been constructed
Definition: EdgeItem.hpp:77
graph_analysis::gui::EdgeItem::EdgeItem
EdgeItem()
empty constructor
Definition: EdgeItem.hpp:30