File indexing completed on 2024-05-19 15:27:49
0001 /* This file is part of KGraphViewer. 0002 Copyright (C) 2005-2007 Gael de Chalendar <kleag@free.fr> 0003 0004 KGraphViewer is free software; you can redistribute it and/or 0005 modify it under the terms of the GNU General Public 0006 License as published by the Free Software Foundation, version 2. 0007 0008 This program is distributed in the hope that it will be useful, 0009 but WITHOUT ANY WARRANTY; without even the implied warranty of 0010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0011 General Public License for more details. 0012 0013 You should have received a copy of the GNU General Public License 0014 along with this program; if not, write to the Free Software 0015 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 0016 02110-1301, USA 0017 */ 0018 0019 /* This file was callgraphview.h, part of KCachegrind. 0020 Copyright (C) 2003 Josef Weidendorfer <Josef.Weidendorfer@gmx.de> 0021 0022 KCachegrind is free software; you can redistribute it and/or 0023 modify it under the terms of the GNU General Public 0024 License as published by the Free Software Foundation, version 2. 0025 */ 0026 0027 /* 0028 * Graph Node model 0029 */ 0030 0031 #ifndef GRAPH_NODE_H 0032 #define GRAPH_NODE_H 0033 0034 #include <QList> 0035 #include <QMap> 0036 #include <QTextStream> 0037 #include <QVector> 0038 0039 #include <graphviz/gvc.h> 0040 0041 #include "canvaselement.h" 0042 #include "canvasnode.h" 0043 #include "dotgrammar.h" 0044 #include "dotrenderop.h" 0045 #include "graphelement.h" 0046 0047 namespace KGraphViewer 0048 { 0049 class CanvasNode; 0050 0051 /** 0052 * Colors and styles are DOT names 0053 */ 0054 class GraphNode : public GraphElement 0055 { 0056 Q_OBJECT 0057 public: 0058 GraphNode(); 0059 explicit GraphNode(const GraphNode &gn); 0060 explicit GraphNode(node_t *gn); 0061 0062 ~GraphNode() override 0063 { 0064 } 0065 0066 inline CanvasNode *canvasNode() 0067 { 0068 return dynamic_cast<CanvasNode *>(canvasElement()); 0069 } 0070 inline const CanvasNode *canvasNode() const 0071 { 0072 return dynamic_cast<const CanvasNode *>(canvasElement()); 0073 } 0074 inline void setCanvasNode(CanvasNode *cn) 0075 { 0076 setCanvasElement((CanvasElement *)cn); 0077 } 0078 0079 void updateWithNode(const GraphNode &node); 0080 void updateWithNode(node_t *node); 0081 0082 private: 0083 }; 0084 0085 /** A map associating the ids of a graph's nodes to these nodes */ 0086 typedef QMap<QString, GraphNode *> GraphNodeMap; 0087 0088 QTextStream &operator<<(QTextStream &s, const GraphNode &n); 0089 0090 } 0091 0092 #endif