Loading...
Searching...
No Matches
QGVScene.h
Go to the documentation of this file.
1/***************************************************************
2QGVCore
3Copyright (c) 2014, Bergont Nicolas, All rights reserved.
4
5This library is free software; you can redistribute it and/or
6modify it under the terms of the GNU Lesser General Public
7License as published by the Free Software Foundation; either
8version 3.0 of the License, or (at your option) any later version.
9
10This library is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13Lesser General Public License for more details.
14
15You should have received a copy of the GNU Lesser General Public
16License along with this library.
17***************************************************************/
18#ifndef QGVSCENE_H
19#define QGVSCENE_H
20
21#include <QGraphicsScene>
22
23#include "qgv.h"
24
25class QGVNode;
26class QGVEdge;
27class QGVSubGraph;
28
29class QGVGraphPrivate;
30class QGVGvcPrivate;
31
36class QGVCORE_EXPORT QGVScene : public QGraphicsScene {
37 Q_OBJECT
38 public:
39 explicit QGVScene(const QString& name, QObject* parent = 0);
40 ~QGVScene();
41
42 void setGraphAttribute(const QString& name, const QString& value);
43 void setNodeAttribute(const QString& name, const QString& value);
44 void setEdgeAttribute(const QString& name, const QString& value);
45
46 QGVNode* addNode(const QString& label);
47 QGVEdge* addEdge(QGVNode* source, QGVNode* target,
48 const QString& label = QString());
49 QGVSubGraph* addSubGraph(const QString& name, bool cluster = true);
50
51 void setRootNode(QGVNode* node);
52
53 void setNodePositionAttribute();
54
55 void loadLayout(const QString& text);
56 void applyLayout(const QString& algorithm = "dot");
57 void render(const QString& algorithm);
58 void render(const QString algorithm, const QString file);
59 void freeLayout();
60 void clear();
61
62 bool writeGraph(const QString filename);
63
64 signals:
65 void nodeContextMenu(QGVNode* node);
66 void nodeDoubleClick(QGVNode* node);
67 void nodeChanged(QGVNode* node);
68 void nodeMouseRelease(QGVNode* node);
69
70 void edgeContextMenu(QGVEdge* edge);
71 void edgeDoubleClick(QGVEdge* edge);
72
73 void subGraphContextMenu(QGVSubGraph* graph);
74 void subGraphDoubleClick(QGVSubGraph* graph);
75
76 void graphContextMenuEvent();
77
78 public slots:
79
80 protected:
81 virtual void contextMenuEvent(
82 QGraphicsSceneContextMenuEvent* contextMenuEvent);
83 virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* mouseEvent);
84 virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent* mouseEvent);
85 virtual void drawBackground(QPainter* painter, const QRectF& rect);
86
87 private:
88 friend class QGVNode;
89 friend class QGVEdge;
90 friend class QGVSubGraph;
91
92 QGVGvcPrivate* _context;
93 QGVGraphPrivate* _graph;
94 // QFont _font;
95
96 QList<QGVNode*> _nodes;
97 QList<QGVEdge*> _edges;
98 QList<QGVSubGraph*> _subGraphs;
99 QGraphicsTextItem* _label;
100};
101
102#endif // QGVSCENE_H
Edge item.
Definition: QGVEdge.h:34
Definition: QGVGraphPrivate.h:6
Definition: QGVGvcPrivate.h:6
Node item.
Definition: QGVNode.h:34
GraphViz interactive scene.
Definition: QGVScene.h:36
SubGraph item.
Definition: QGVSubGraph.h:35
#define QGVCORE_EXPORT
Definition: qgv.h:9