1 /* This file is part of KGraphViewer.
2    Copyright (C) 2005-2007 Gael de Chalendar <kleag@free.fr>
3 
4    KGraphViewer is free software; you can redistribute it and/or
5    modify it under the terms of the GNU General Public
6    License as published by the Free Software Foundation, version 2.
7 
8    This program is distributed in the hope that it will be useful,
9    but WITHOUT ANY WARRANTY; without even the implied warranty of
10    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11    General Public License for more details.
12 
13    You should have received a copy of the GNU General Public License
14    along with this program; if not, write to the Free Software
15    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16    02110-1301, USA
17 */
18 
19 /* This file was callgraphview.h, part of KCachegrind.
20    Copyright (C) 2003 Josef Weidendorfer <Josef.Weidendorfer@gmx.de>
21 
22    KCachegrind is free software; you can redistribute it and/or
23    modify it under the terms of the GNU General Public
24    License as published by the Free Software Foundation, version 2.
25 */
26 
27 
28 /*
29  * Graph Node model
30  */
31 
32 #ifndef GRAPH_NODE_H
33 #define GRAPH_NODE_H
34 
35 #include <QVector>
36 #include <QList>
37 #include <QMap>
38 #include <QTextStream>
39 
40 #include <graphviz/gvc.h>
41 
42 #include "dotrenderop.h"
43 #include "dotgrammar.h"
44 #include "graphelement.h"
45 #include "canvaselement.h"
46 #include "canvasnode.h"
47 
48 namespace KGraphViewer
49 {
50 
51 class CanvasNode;
52 
53 /**
54  * Colors and styles are DOT names
55  */
56 class GraphNode : public GraphElement
57 {
58   Q_OBJECT
59 public:
60   GraphNode();
61   explicit GraphNode(const GraphNode& gn);
62   explicit GraphNode(node_t* gn);
63 
~GraphNode()64   ~GraphNode() override {}
65 
canvasNode()66   inline CanvasNode* canvasNode() { return dynamic_cast<CanvasNode*>(canvasElement()); }
canvasNode()67   inline const CanvasNode* canvasNode() const { return dynamic_cast<const CanvasNode*>(canvasElement()); }
setCanvasNode(CanvasNode * cn)68   inline void setCanvasNode(CanvasNode* cn) { setCanvasElement((CanvasElement*)cn); }
69 
70   void updateWithNode(const GraphNode& node);
71   void updateWithNode(node_t* node);
72 
73 
74 private:
75 };
76 
77 /** A map associating the ids of a graph's nodes to these nodes */
78 typedef QMap<QString, GraphNode*> GraphNodeMap;
79 
80 QTextStream& operator<<(QTextStream& s, const GraphNode& n);
81 
82 }
83 
84 #endif
85 
86 
87 
88