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 #ifndef QGVEDGE_H
19 #define QGVEDGE_H
20 
21 #include "qgv.h"
22 #include <QGraphicsItem>
23 #include <QPen>
24 
25 class QGVNode;
26 class QGVScene;
27 class QGVEdgePrivate;
28 
33 class QGVCORE_EXPORT QGVEdge : public QGraphicsItem
34 {
35 public:
36  ~QGVEdge();
37 
38  QString label() const;
39  QRectF boundingRect() const;
40  QPainterPath shape() const;
41 
42  void setLabel(const QString &label);
43 
44  void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0);
45 
46  void setAttribute(const QString &name, const QString &value);
47  QString getAttribute(const QString &name) const;
48 
49  void updateLayout();
50 
51  enum { Type = UserType + 3 };
52  int type() const
53  {
54  return Type;
55  }
56 
57 private:
58  QGVEdge(QGVEdgePrivate *edge, QGVScene *scene);
59 
60  QPolygonF toArrow(const QLineF &normal) const;
61 
62  friend class QGVScene;
63  //friend class QGVSubGraph;
64 
65  QGVScene *_scene;
66  QGVEdgePrivate* _edge;
67 
68  QPainterPath _path;
69  QPen _pen;
70  QPolygonF _head_arrow;
71  QPolygonF _tail_arrow;
72 
73  QString _label;
74  QRectF _label_rect;
75 };
76 
77 #endif // QGVEDGE_H
Node item.
Definition: QGVNode.h:33
Edge item.
Definition: QGVEdge.h:33
Definition: QGVEdgePrivate.h:6
int type() const
Definition: QGVEdge.h:52
GraphViz interactive scene.
Definition: QGVScene.h:35
#define QGVCORE_EXPORT
Definition: qgv.h:9