QGVNode.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 QGVNODE_H
19 #define QGVNODE_H
20 
21 #include "qgv.h"
22 #include <QGraphicsItem>
23 #include <QPen>
24 
25 class QGVEdge;
26 class QGVScene;
27 class QGVNodePrivate;
28 
33 class QGVCORE_EXPORT QGVNode : public QGraphicsItem
34 {
35 public:
36  ~QGVNode();
37 
38  QString label() const;
39  void setLabel(const QString &label);
40 
41  QRectF boundingRect() const;
42  void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0);
43  void setAttribute(const QString &label, const QString &value);
44  QString getAttribute(const QString &name) const;
45 
46  QString posToAttributeString () const;
47 
48  void setIcon(const QImage &icon);
49 
50  enum { Type = UserType + 2 };
51  int type() const
52  {
53  return Type;
54  }
55 
56  void updateLayout();
57 
58 protected:
59  QVariant itemChange (GraphicsItemChange change, const QVariant & value);
60 
61 private:
62  friend class QGVScene;
63  friend class QGVSubGraph;
64  QGVNode(QGVNodePrivate* node, QGVScene *scene);
65 
66  // Not implemented in QGVNode.cpp
67 // QPainterPath makeShape(Agnode_t* node) const;
68 // QPolygonF makeShapeHelper(Agnode_t* node) const;
69 
70  QPainterPath _path;
71  QPen _pen;
72  QBrush _brush;
73  QImage _icon;
74 
75  QGVScene *_scene;
76  QGVNodePrivate* _node;
77 };
78 
79 
80 #endif // QGVNODE_H
Node item.
Definition: QGVNode.h:33
Edge item.
Definition: QGVEdge.h:33
SubGraph item.
Definition: QGVSubGraph.h:34
GraphViz interactive scene.
Definition: QGVScene.h:35
#define QGVCORE_EXPORT
Definition: qgv.h:9
int type() const
Definition: QGVNode.h:51
Definition: QGVNodePrivate.h:6