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 Edge 0029 */ 0030 0031 #ifndef GRAPH_EDGE_H 0032 #define GRAPH_EDGE_H 0033 0034 #include "canvasnode.h" 0035 #include "dotgrammar.h" 0036 #include "dotrenderop.h" 0037 #include "graphelement.h" 0038 0039 #include <graphviz/gvc.h> 0040 0041 #include <QMap> 0042 #include <QStringList> 0043 #include <QTextStream> 0044 0045 namespace KGraphViewer 0046 { 0047 class CanvasEdge; 0048 0049 class GraphEdge : public GraphElement 0050 { 0051 Q_OBJECT 0052 public: 0053 GraphEdge(); 0054 ~GraphEdge() override; 0055 0056 explicit GraphEdge(const GraphEdge &edge); 0057 explicit GraphEdge(edge_t *edge); 0058 0059 CanvasEdge *canvasEdge() 0060 { 0061 return (CanvasEdge *)canvasElement(); 0062 } 0063 const CanvasEdge *canvasEdge() const 0064 { 0065 return (CanvasEdge *)canvasElement(); 0066 } 0067 void setCanvasEdge(CanvasEdge *ce) 0068 { 0069 setCanvasElement((CanvasElement *)ce); 0070 } 0071 0072 bool isVisible() 0073 { 0074 return m_visible; 0075 } 0076 void setVisible(bool v) 0077 { 0078 m_visible = v; 0079 } 0080 0081 GraphElement *fromNode() 0082 { 0083 return m_fromNode; 0084 } 0085 GraphElement *toNode() 0086 { 0087 return m_toNode; 0088 } 0089 const GraphElement *fromNode() const 0090 { 0091 return m_fromNode; 0092 } 0093 const GraphElement *toNode() const 0094 { 0095 return m_toNode; 0096 } 0097 0098 void setFromNode(GraphElement *n) 0099 { 0100 m_fromNode = n; 0101 } 0102 void setToNode(GraphElement *n) 0103 { 0104 m_toNode = n; 0105 } 0106 0107 // inline const QVector< QPair< float, float > >& edgePoints() const {return m_edgePoints;} 0108 // inline QVector< QPair< float, float > >& edgePoints() {return m_edgePoints;} 0109 // inline void edgePoints(const QVector< QPair< float, float > >& ep) {m_edgePoints = ep;} 0110 0111 inline const QStringList &colors() const 0112 { 0113 return m_colors; 0114 } 0115 const QString color(uint i); 0116 void colors(const QString &cs); 0117 0118 /* inline void labelX(float x) {m_labelX = x;} 0119 inline void labelY(float y) {m_labelY = y;} 0120 inline float labelX() const {return m_labelX;} 0121 inline float labelY() const {return m_labelY;}*/ 0122 0123 inline const QString &dir() const 0124 { 0125 return m_dir; 0126 } 0127 inline void dir(const QString &dir) 0128 { 0129 m_dir = dir; 0130 } 0131 0132 inline QList<DotRenderOp> &arrowheads() 0133 { 0134 return m_arrowheads; 0135 } 0136 inline const QList<DotRenderOp> &arrowheads() const 0137 { 0138 return m_arrowheads; 0139 } 0140 0141 void updateWithEdge(const GraphEdge &edge); 0142 void updateWithEdge(edge_t *edge); 0143 0144 private: 0145 // we have a _ce *and* _from/_to because for collapsed edges, 0146 // only _to or _from will be unequal nullptr 0147 GraphElement *m_fromNode, *m_toNode; 0148 bool m_visible; 0149 QStringList m_colors; 0150 QString m_dir; 0151 // QVector< QPair< float, float > > m_edgePoints; 0152 // float m_labelX, m_labelY; 0153 0154 QList<DotRenderOp> m_arrowheads; 0155 }; 0156 0157 /** A map associating the bounds nodes of a graph's edges to these edges */ 0158 typedef QMap<QString, GraphEdge *> GraphEdgeMap; 0159 0160 QTextStream &operator<<(QTextStream &s, const GraphEdge &e); 0161 0162 } 0163 0164 #endif