QGVEdge.h
Go to the documentation of this file.
1 /***************************************************************
2 QGVCore
3 Copyright (c) 2014, Bergont Nicolas, All rights reserved.
4 
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 3.0 of the License, or (at your option) any later version.
9 
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14 
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library.
17 ***************************************************************/
18 
19 #ifndef QGVEDGE_H
20 #define QGVEDGE_H
21 
22 #include <QGraphicsItem>
23 #include <QPen>
24 
25 #include "qgv.h"
26 #include "gazebo/util/system.hh"
27 
28 class QGVNode;
29 class QGVScene;
30 class QGVEdgePrivate;
31 
36 class GZ_GUI_VISIBLE QGVEdge : public QGraphicsItem
37 {
38  public:
39  ~QGVEdge();
40 
41  QString label() const;
42  QRectF boundingRect() const;
43  QPainterPath shape() const;
44 
45  QString source() const;
46  QString target() const;
47 
48  void setLabel(const QString &label);
49 
50  void setSource(const QString &_source);
51  void setTarget(const QString &_target);
52 
53  void setColor(const QColor &_color);
54  QColor color() const;
55 
56  void paint(QPainter * painter, const QStyleOptionGraphicsItem * option,
57  QWidget * widget = 0);
58 
59  void setAttribute(const QString &name, const QString &value);
60  QString getAttribute(const QString &name) const;
61 
62  void updateLayout();
63 
64  enum { Type = UserType + 3 };
65  int type() const
66  {
67  return Type;
68  }
69 
70  private:
71  QGVEdge(QGVEdgePrivate *edge, QGVScene *scene);
72 
73  QPolygonF toArrow(const QLineF &normal) const;
74  QPolygonF toBox(const QLineF &normal) const;
75 
76  friend class QGVScene;
77  // friend class QGVSubGraph;
78 
79  QGVScene *_scene;
80  QGVEdgePrivate* _edge;
81 
82  QPainterPath _path;
83  QPen _pen;
84  QPolygonF _head_arrow;
85  QPolygonF _tail_arrow;
86 
87  QString _label;
88  QRectF _label_rect;
89 
90  QString sourceNode;
91  QString targetNode;
92 
93  QColor edgeColor;
94 };
95 
96 #endif
#define GZ_GUI_VISIBLE
Definition: system.hh:284
int type() const
Definition: QGVEdge.h:65
Node item.
Definition: QGVNode.h:34
Edge item.
Definition: QGVEdge.h:36
Definition: QGVEdgePrivate.h:24
GraphViz interactive scene.
Definition: QGVScene.h:41