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 <QGraphicsItem>
22 #include <QPen>
23 
24 #include "qgv.h"
25 
26 class QGVEdge;
27 class QGVScene;
28 class QGVNodePrivate;
29 
34 class QGVCORE_EXPORT QGVNode : public QGraphicsItem
35 {
36  public:
37  ~QGVNode();
38 
39  QString label() const;
40  void setLabel(const QString &label);
41 
42  QRectF boundingRect() const;
43  void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
44  QWidget *widget = 0);
45  void setAttribute(const QString &label, const QString &value);
46  QString getAttribute(const QString &name) 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  private:
57  friend class QGVScene;
58  friend class QGVSubGraph;
59  void updateLayout();
60  QGVNode(QGVNodePrivate* node, QGVScene *scene);
61 
62  // Not implemented in QGVNode.cpp
63 // QPainterPath makeShape(Agnode_t* node) const;
64 // QPolygonF makeShapeHelper(Agnode_t* node) const;
65 
66  QPainterPath _path;
67  QPen _pen;
68  QBrush _brush;
69  QImage _icon;
70 
71  QGVScene *_scene;
72  QGVNodePrivate* _node;
73 };
74 
75 
76 #endif
Node item.
Definition: QGVNode.h:34
Edge item.
Definition: QGVEdge.h:36
SubGraph item.
Definition: QGVSubGraph.h:35
int type() const
Definition: QGVNode.h:51
GraphViz interactive scene.
Definition: QGVScene.h:41
#define QGVCORE_EXPORT
Definition: qgv.h:33
void updateLayout()
Definition: QGVNodePrivate.h:24