Changeset View
Changeset View
Standalone View
Standalone View
src/part/graphedge.h
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 Edge | 28 | * Graph Edge | ||
30 | */ | 29 | */ | ||
31 | 30 | | |||
32 | #ifndef GRAPH_EDGE_H | 31 | #ifndef GRAPH_EDGE_H | ||
33 | #define GRAPH_EDGE_H | 32 | #define GRAPH_EDGE_H | ||
34 | 33 | | |||
35 | #include "canvasnode.h" | 34 | #include "canvasnode.h" | ||
36 | #include "graphelement.h" | | |||
37 | #include "dotgrammar.h" | 35 | #include "dotgrammar.h" | ||
38 | #include "dotrenderop.h" | 36 | #include "dotrenderop.h" | ||
37 | #include "graphelement.h" | ||||
39 | 38 | | |||
40 | #include <graphviz/gvc.h> | 39 | #include <graphviz/gvc.h> | ||
41 | 40 | | |||
42 | #include <QStringList> | | |||
43 | #include <QMap> | 41 | #include <QMap> | ||
42 | #include <QStringList> | ||||
44 | #include <QTextStream> | 43 | #include <QTextStream> | ||
45 | 44 | | |||
46 | namespace KGraphViewer | 45 | namespace KGraphViewer | ||
47 | { | 46 | { | ||
48 | | ||||
49 | class CanvasEdge; | 47 | class CanvasEdge; | ||
50 | 48 | | |||
51 | class GraphEdge : public GraphElement | 49 | class GraphEdge : public GraphElement | ||
52 | { | 50 | { | ||
53 | Q_OBJECT | 51 | Q_OBJECT | ||
54 | public: | 52 | public: | ||
55 | GraphEdge(); | 53 | GraphEdge(); | ||
56 | ~GraphEdge() override; | 54 | ~GraphEdge() override; | ||
57 | 55 | | |||
58 | explicit GraphEdge(const GraphEdge& edge); | 56 | explicit GraphEdge(const GraphEdge &edge); | ||
59 | explicit GraphEdge(edge_t* edge); | 57 | explicit GraphEdge(edge_t *edge); | ||
60 | 58 | | |||
61 | CanvasEdge* canvasEdge() { return (CanvasEdge*)canvasElement(); } | 59 | CanvasEdge *canvasEdge() | ||
62 | const CanvasEdge* canvasEdge() const { return (CanvasEdge*)canvasElement(); } | 60 | { | ||
63 | void setCanvasEdge(CanvasEdge* ce) { setCanvasElement((CanvasElement*)ce); } | 61 | return (CanvasEdge *)canvasElement(); | ||
64 | 62 | } | |||
65 | bool isVisible() { return m_visible; } | 63 | const CanvasEdge *canvasEdge() const | ||
66 | void setVisible(bool v) { m_visible = v; } | 64 | { | ||
67 | 65 | return (CanvasEdge *)canvasElement(); | |||
68 | GraphElement* fromNode() { return m_fromNode; } | 66 | } | ||
69 | GraphElement* toNode() { return m_toNode; } | 67 | void setCanvasEdge(CanvasEdge *ce) | ||
70 | const GraphElement* fromNode() const { return m_fromNode; } | 68 | { | ||
71 | const GraphElement* toNode() const { return m_toNode; } | 69 | setCanvasElement((CanvasElement *)ce); | ||
70 | } | ||||
71 | | ||||
72 | bool isVisible() | ||||
73 | { | ||||
74 | return m_visible; | ||||
75 | } | ||||
76 | void setVisible(bool v) | ||||
77 | { | ||||
78 | m_visible = v; | ||||
79 | } | ||||
80 | | ||||
81 | GraphElement *fromNode() | ||||
82 | { | ||||
83 | return m_fromNode; | ||||
84 | } | ||||
85 | GraphElement *toNode() | ||||
86 | { | ||||
87 | return m_toNode; | ||||
88 | } | ||||
89 | const GraphElement *fromNode() const | ||||
90 | { | ||||
91 | return m_fromNode; | ||||
92 | } | ||||
93 | const GraphElement *toNode() const | ||||
94 | { | ||||
95 | return m_toNode; | ||||
96 | } | ||||
72 | 97 | | |||
73 | void setFromNode(GraphElement* n) { m_fromNode = n; } | 98 | void setFromNode(GraphElement *n) | ||
74 | void setToNode(GraphElement* n) { m_toNode = n; } | 99 | { | ||
100 | m_fromNode = n; | ||||
101 | } | ||||
102 | void setToNode(GraphElement *n) | ||||
103 | { | ||||
104 | m_toNode = n; | ||||
105 | } | ||||
75 | 106 | | |||
76 | // inline const QVector< QPair< float, float > >& edgePoints() const {return m_edgePoints;} | 107 | // inline const QVector< QPair< float, float > >& edgePoints() const {return m_edgePoints;} | ||
77 | // inline QVector< QPair< float, float > >& edgePoints() {return m_edgePoints;} | 108 | // inline QVector< QPair< float, float > >& edgePoints() {return m_edgePoints;} | ||
78 | // inline void edgePoints(const QVector< QPair< float, float > >& ep) {m_edgePoints = ep;} | 109 | // inline void edgePoints(const QVector< QPair< float, float > >& ep) {m_edgePoints = ep;} | ||
79 | 110 | | |||
80 | inline const QStringList& colors() const {return m_colors;} | 111 | inline const QStringList &colors() const | ||
112 | { | ||||
113 | return m_colors; | ||||
114 | } | ||||
81 | const QString color(uint i); | 115 | const QString color(uint i); | ||
82 | void colors(const QString& cs); | 116 | void colors(const QString &cs); | ||
83 | 117 | | |||
84 | /* inline void labelX(float x) {m_labelX = x;} | 118 | /* inline void labelX(float x) {m_labelX = x;} | ||
85 | inline void labelY(float y) {m_labelY = y;} | 119 | inline void labelY(float y) {m_labelY = y;} | ||
86 | inline float labelX() const {return m_labelX;} | 120 | inline float labelX() const {return m_labelX;} | ||
87 | inline float labelY() const {return m_labelY;}*/ | 121 | inline float labelY() const {return m_labelY;}*/ | ||
88 | 122 | | |||
89 | inline const QString& dir() const {return m_dir;} | 123 | inline const QString &dir() const | ||
90 | inline void dir(const QString& dir) {m_dir = dir;} | 124 | { | ||
125 | return m_dir; | ||||
126 | } | ||||
127 | inline void dir(const QString &dir) | ||||
128 | { | ||||
129 | m_dir = dir; | ||||
130 | } | ||||
91 | 131 | | |||
92 | inline QList< DotRenderOp >& arrowheads() {return m_arrowheads;} | 132 | inline QList<DotRenderOp> &arrowheads() | ||
93 | inline const QList< DotRenderOp >& arrowheads() const {return m_arrowheads;} | 133 | { | ||
134 | return m_arrowheads; | ||||
135 | } | ||||
136 | inline const QList<DotRenderOp> &arrowheads() const | ||||
137 | { | ||||
138 | return m_arrowheads; | ||||
139 | } | ||||
94 | 140 | | |||
95 | void updateWithEdge(const GraphEdge& edge); | 141 | void updateWithEdge(const GraphEdge &edge); | ||
96 | void updateWithEdge(edge_t* edge); | 142 | void updateWithEdge(edge_t *edge); | ||
97 | 143 | | |||
98 | private: | 144 | private: | ||
99 | // we have a _ce *and* _from/_to because for collapsed edges, | 145 | // we have a _ce *and* _from/_to because for collapsed edges, | ||
100 | // only _to or _from will be unequal nullptr | 146 | // only _to or _from will be unequal nullptr | ||
101 | GraphElement *m_fromNode, *m_toNode; | 147 | GraphElement *m_fromNode, *m_toNode; | ||
102 | bool m_visible; | 148 | bool m_visible; | ||
103 | QStringList m_colors; | 149 | QStringList m_colors; | ||
104 | QString m_dir; | 150 | QString m_dir; | ||
105 | // QVector< QPair< float, float > > m_edgePoints; | 151 | // QVector< QPair< float, float > > m_edgePoints; | ||
106 | // float m_labelX, m_labelY; | 152 | // float m_labelX, m_labelY; | ||
107 | 153 | | |||
108 | QList< DotRenderOp > m_arrowheads; | 154 | QList<DotRenderOp> m_arrowheads; | ||
109 | }; | 155 | }; | ||
110 | 156 | | |||
111 | | ||||
112 | /** A map associating the bounds nodes of a graph's edges to these edges */ | 157 | /** A map associating the bounds nodes of a graph's edges to these edges */ | ||
113 | typedef QMap<QString, GraphEdge*> GraphEdgeMap; | 158 | typedef QMap<QString, GraphEdge *> GraphEdgeMap; | ||
114 | 159 | | |||
115 | QTextStream& operator<<(QTextStream& s, const GraphEdge& e); | 160 | QTextStream &operator<<(QTextStream &s, const GraphEdge &e); | ||
116 | 161 | | |||
117 | } | 162 | } | ||
118 | 163 | | |||
119 | #endif | 164 | #endif | ||
120 | | ||||
121 | | ||||
122 | |