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 0029 */ 0030 0031 #include "graphnode.h" 0032 #include "canvasnode.h" 0033 #include "dotdefaults.h" 0034 #include "dotgraphview.h" 0035 #include "kgraphviewerlib_debug.h" 0036 #include "pannerview.h" 0037 0038 #include <math.h> 0039 0040 #include <QDebug> 0041 0042 namespace KGraphViewer 0043 { 0044 // 0045 // GraphNode 0046 // 0047 0048 GraphNode::GraphNode() 0049 : GraphElement() 0050 { 0051 // qCDebug(KGRAPHVIEWERLIB_LOG) ; 0052 } 0053 0054 GraphNode::GraphNode(const GraphNode &gn) 0055 : GraphElement(gn) 0056 { 0057 // qCDebug(KGRAPHVIEWERLIB_LOG) ; 0058 } 0059 0060 GraphNode::GraphNode(node_t *gn) 0061 : GraphElement() 0062 { 0063 updateWithNode(gn); 0064 } 0065 0066 void GraphNode::updateWithNode(const GraphNode &node) 0067 { 0068 qCDebug(KGRAPHVIEWERLIB_LOG) << id() << node.id(); 0069 GraphElement::updateWithElement(node); 0070 if (canvasNode()) { 0071 canvasNode()->computeBoundingRect(); 0072 canvasNode()->modelChanged(); 0073 } 0074 // qCDebug(KGRAPHVIEWERLIB_LOG) << "done"; 0075 } 0076 0077 void GraphNode::updateWithNode(node_t *node) 0078 { 0079 qCDebug(KGRAPHVIEWERLIB_LOG) << agnameof(node); 0080 m_attributes["id"] = agnameof(node); 0081 m_attributes["label"] = ND_label(node)->text; 0082 0083 DotRenderOpVec ops; 0084 // decrease mem peak 0085 setRenderOperations(ops); 0086 0087 if (agget(node, (char *)"_draw_")) { 0088 parse_renderop(agget(node, (char *)"_draw_"), ops); 0089 qCDebug(KGRAPHVIEWERLIB_LOG) << "_draw_: element renderOperations size is now " << ops.size(); 0090 } 0091 if (agget(node, (char *)"_ldraw_")) { 0092 parse_renderop(agget(node, (char *)"_ldraw_"), ops); 0093 qCDebug(KGRAPHVIEWERLIB_LOG) << "_ldraw_: element renderOperations size is now " << ops.size(); 0094 } 0095 0096 setRenderOperations(ops); 0097 0098 Agsym_t *attr = agnxtattr(agraphof(node), AGNODE, nullptr); 0099 while (attr) { 0100 qCDebug(KGRAPHVIEWERLIB_LOG) << agnameof(node) << ":" << attr->name << agxget(node, attr); 0101 m_attributes[attr->name] = agxget(node, attr); 0102 attr = agnxtattr(agraphof(node), AGNODE, attr); 0103 } 0104 } 0105 0106 QTextStream &operator<<(QTextStream &s, const GraphNode &n) 0107 { 0108 s << n.id() << " [" << dynamic_cast<const GraphElement &>(n) << "];" << Qt::endl; 0109 return s; 0110 } 0111 0112 } 0113 0114 #include "moc_graphnode.cpp"