Changeset View
Changeset View
Standalone View
Standalone View
src/part/graphnode.cpp
Show All 18 Lines | |||||
19 | /* This file was callgraphview.h, part of KCachegrind. | 19 | /* This file was callgraphview.h, part of KCachegrind. | ||
20 | Copyright (C) 2003 Josef Weidendorfer <Josef.Weidendorfer@gmx.de> | 20 | Copyright (C) 2003 Josef Weidendorfer <Josef.Weidendorfer@gmx.de> | ||
21 | 21 | | |||
22 | KCachegrind is free software; you can redistribute it and/or | 22 | KCachegrind is free software; you can redistribute it and/or | ||
23 | modify it under the terms of the GNU General Public | 23 | modify it under the terms of the GNU General Public | ||
24 | License as published by the Free Software Foundation, version 2. | 24 | License as published by the Free Software Foundation, version 2. | ||
25 | */ | 25 | */ | ||
26 | 26 | | |||
27 | | ||||
28 | /* | 27 | /* | ||
29 | * Graph Node | 28 | * Graph Node | ||
30 | */ | 29 | */ | ||
31 | 30 | | |||
32 | #include "graphnode.h" | 31 | #include "graphnode.h" | ||
33 | #include "dotgraphview.h" | | |||
34 | #include "pannerview.h" | | |||
35 | #include "canvasnode.h" | 32 | #include "canvasnode.h" | ||
36 | #include "dotdefaults.h" | 33 | #include "dotdefaults.h" | ||
34 | #include "dotgraphview.h" | ||||
37 | #include "kgraphviewerlib_debug.h" | 35 | #include "kgraphviewerlib_debug.h" | ||
36 | #include "pannerview.h" | ||||
38 | 37 | | |||
39 | #include <math.h> | 38 | #include <math.h> | ||
40 | 39 | | |||
41 | #include <QDebug> | 40 | #include <QDebug> | ||
42 | 41 | | |||
43 | namespace KGraphViewer | 42 | namespace KGraphViewer | ||
44 | { | 43 | { | ||
45 | | ||||
46 | // | 44 | // | ||
47 | // GraphNode | 45 | // GraphNode | ||
48 | // | 46 | // | ||
49 | 47 | | |||
50 | GraphNode::GraphNode() : | 48 | GraphNode::GraphNode() | ||
51 | GraphElement() | 49 | : GraphElement() | ||
52 | { | 50 | { | ||
53 | // qCDebug(KGRAPHVIEWERLIB_LOG) ; | 51 | // qCDebug(KGRAPHVIEWERLIB_LOG) ; | ||
54 | } | 52 | } | ||
55 | 53 | | |||
56 | GraphNode::GraphNode(const GraphNode& gn) : | 54 | GraphNode::GraphNode(const GraphNode &gn) | ||
57 | GraphElement(gn) | 55 | : GraphElement(gn) | ||
58 | { | 56 | { | ||
59 | // qCDebug(KGRAPHVIEWERLIB_LOG) ; | 57 | // qCDebug(KGRAPHVIEWERLIB_LOG) ; | ||
60 | } | 58 | } | ||
61 | 59 | | |||
62 | GraphNode::GraphNode(node_t* gn) : GraphElement() | 60 | GraphNode::GraphNode(node_t *gn) | ||
61 | : GraphElement() | ||||
63 | { | 62 | { | ||
64 | updateWithNode(gn); | 63 | updateWithNode(gn); | ||
65 | } | 64 | } | ||
66 | 65 | | |||
67 | void GraphNode::updateWithNode(const GraphNode& node) | 66 | void GraphNode::updateWithNode(const GraphNode &node) | ||
68 | { | 67 | { | ||
69 | qCDebug(KGRAPHVIEWERLIB_LOG) << id() << node.id(); | 68 | qCDebug(KGRAPHVIEWERLIB_LOG) << id() << node.id(); | ||
70 | GraphElement::updateWithElement(node); | 69 | GraphElement::updateWithElement(node); | ||
71 | if (canvasNode()) | 70 | if (canvasNode()) { | ||
72 | { | | |||
73 | canvasNode()->computeBoundingRect(); | 71 | canvasNode()->computeBoundingRect(); | ||
74 | canvasNode()->modelChanged(); | 72 | canvasNode()->modelChanged(); | ||
75 | } | 73 | } | ||
76 | // qCDebug(KGRAPHVIEWERLIB_LOG) << "done"; | 74 | // qCDebug(KGRAPHVIEWERLIB_LOG) << "done"; | ||
77 | } | 75 | } | ||
78 | 76 | | |||
79 | void GraphNode::updateWithNode(node_t* node) | 77 | void GraphNode::updateWithNode(node_t *node) | ||
80 | { | 78 | { | ||
81 | qCDebug(KGRAPHVIEWERLIB_LOG) << agnameof(node); | 79 | qCDebug(KGRAPHVIEWERLIB_LOG) << agnameof(node); | ||
82 | m_attributes["id"] = agnameof(node); | 80 | m_attributes["id"] = agnameof(node); | ||
83 | m_attributes["label"] = ND_label(node)->text; | 81 | m_attributes["label"] = ND_label(node)->text; | ||
84 | 82 | | |||
85 | DotRenderOpVec ops; | 83 | DotRenderOpVec ops; | ||
86 | // decrease mem peak | 84 | // decrease mem peak | ||
87 | setRenderOperations(ops); | 85 | setRenderOperations(ops); | ||
88 | 86 | | |||
89 | if (agget(node, (char*)"_draw_")) | 87 | if (agget(node, (char *)"_draw_")) { | ||
90 | { | | |||
91 | parse_renderop(agget(node, (char*)"_draw_"), ops); | 88 | parse_renderop(agget(node, (char *)"_draw_"), ops); | ||
92 | qCDebug(KGRAPHVIEWERLIB_LOG) << "_draw_: element renderOperations size is now " << ops.size(); | 89 | qCDebug(KGRAPHVIEWERLIB_LOG) << "_draw_: element renderOperations size is now " << ops.size(); | ||
93 | } | 90 | } | ||
94 | if (agget(node, (char*)"_ldraw_")) | 91 | if (agget(node, (char *)"_ldraw_")) { | ||
95 | { | | |||
96 | parse_renderop(agget(node, (char*)"_ldraw_"), ops); | 92 | parse_renderop(agget(node, (char *)"_ldraw_"), ops); | ||
97 | qCDebug(KGRAPHVIEWERLIB_LOG) << "_ldraw_: element renderOperations size is now " << ops.size(); | 93 | qCDebug(KGRAPHVIEWERLIB_LOG) << "_ldraw_: element renderOperations size is now " << ops.size(); | ||
98 | } | 94 | } | ||
99 | 95 | | |||
100 | setRenderOperations(ops); | 96 | setRenderOperations(ops); | ||
101 | 97 | | |||
102 | Agsym_t *attr = agnxtattr(agraphof(node), AGNODE, nullptr); | 98 | Agsym_t *attr = agnxtattr(agraphof(node), AGNODE, nullptr); | ||
103 | while(attr) | 99 | while (attr) { | ||
104 | { | | |||
105 | qCDebug(KGRAPHVIEWERLIB_LOG) << agnameof(node) << ":" << attr->name << agxget(node,attr); | 100 | qCDebug(KGRAPHVIEWERLIB_LOG) << agnameof(node) << ":" << attr->name << agxget(node, attr); | ||
106 | m_attributes[attr->name] = agxget(node,attr); | 101 | m_attributes[attr->name] = agxget(node, attr); | ||
107 | attr = agnxtattr(agraphof(node), AGNODE, attr); | 102 | attr = agnxtattr(agraphof(node), AGNODE, attr); | ||
108 | } | 103 | } | ||
109 | } | 104 | } | ||
110 | 105 | | |||
111 | QTextStream& operator<<(QTextStream& s, const GraphNode& n) | 106 | QTextStream &operator<<(QTextStream &s, const GraphNode &n) | ||
112 | { | 107 | { | ||
113 | s << n.id() << " [" | 108 | s << n.id() << " [" << dynamic_cast<const GraphElement &>(n) << "];" << endl; | ||
114 | << dynamic_cast<const GraphElement&>(n) | | |||
115 | <<"];"<<endl; | | |||
116 | return s; | 109 | return s; | ||
117 | } | 110 | } | ||
118 | 111 | | |||
119 | } | 112 | } |