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