GraphTool  1.0
Tool for analyzing and graphically visualizing code dependencies for Ericsson.
 All Classes Namespaces Functions Variables Typedefs Enumerations Pages
edge_widget.h
1 
4 #ifndef GUI_EDGE_WIDGET_H_
5 #define GUI_EDGE_WIDGET_H_
6 #include <QGraphicsItem>
7 #include <QGraphicsSceneHoverEvent>
8 #include <QWidget>
9 #include <QObject>
10 #include <QDebug>
11 #include <QToolTip>
12 #include <iostream>
13 #include <qcolor.h>
14 
15 
16 #include "math.h"
17 #include "QtCore/qmath.h"
18 #include "node_widget.h"
19 
20 class NodeWidget;
21 
22 class EdgeWidget : public QGraphicsItem {
23  public:
33  EdgeWidget(NodeWidget* source_node,
34  NodeWidget* destination_node,
35  QColor color = Qt::black,
36  QColor alt_color = Qt::black,
37  Qt::PenStyle pen_style = Qt::SolidLine,
38  int opacity = 255,
39  QGraphicsItem* parent = 0);
40 
46  void set_source_node(NodeWidget* source_node);
47  void set_destination_node(NodeWidget* destination_node);
48  NodeWidget* source_node() const;
49  NodeWidget* destination_node() const;
50 
56  void set_intensity(bool intensity);
57  bool high_intensity() const;
58 
59  // Main color of the node
60  void set_color(QColor);
61  QColor color() const;
62 
63  // Alternate color of the node, can be used to specify a trigger on the node
64  void set_alternate_color(QColor);
65  QColor alternate_color() const;
66 
67  // Opacity, between 0..255
68  void set_opacity(int);
69  int opacity() const;
70 
71  // @see Qt::PenStyle
72  void set_pen_style(Qt::PenStyle pen);
73  Qt::PenStyle pen_style();
74 
78  QPainterPath shape() const;
79 
83  void adjust();
84 
88  void hoverEnterEvent(QGraphicsSceneHoverEvent* event);
89  void hoverLeaveEvent(QGraphicsSceneHoverEvent* event);
90 
95  void use_alternate_color(bool condition);
96 
97  protected:
101  void paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0 );
102 
106  QRectF boundingRect() const;
107 
108 
109  private:
113  NodeWidget *source_node_, *destination_node_;
114 
118  bool high_intensity_;
119 
123  QPointF source_point_;
124  QPointF destination_point_;
125 
129  qreal arrowSize;
130 
134  bool use_alternate_color_;
135 
136  QColor color_;
137 
138  QColor alternate_color_;
139 
140  int opacity_;
141 
142  Qt::PenStyle pen_style_;
143 };
144 
145 #endif
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=0)
Definition: edge_widget.cc:157
Definition: node_widget.h:29
void use_alternate_color(bool condition)
Definition: edge_widget.cc:146
void hoverEnterEvent(QGraphicsSceneHoverEvent *event)
Definition: edge_widget.cc:138
void adjust()
Definition: edge_widget.cc:97
QRectF boundingRect() const
Definition: edge_widget.cc:208
EdgeWidget(NodeWidget *source_node, NodeWidget *destination_node, QColor color=Qt::black, QColor alt_color=Qt::black, Qt::PenStyle pen_style=Qt::SolidLine, int opacity=255, QGraphicsItem *parent=0)
Definition: edge_widget.cc:8
void set_intensity(bool intensity)
Definition: edge_widget.cc:75
Definition: edge_widget.h:22
void set_source_node(NodeWidget *source_node)
Definition: edge_widget.cc:30
QPainterPath shape() const
Definition: edge_widget.cc:83