Doxygen
dotnode.h
浏览该文件的文档.
1 /******************************************************************************
2 *
3 * Copyright (C) 1997-2019 by Dimitri van Heesch.
4 *
5 * Permission to use, copy, modify, and distribute this software and its
6 * documentation under the terms of the GNU General Public License is hereby
7 * granted. No representations are made about the suitability of this software
8 * for any purpose. It is provided "as is" without express or implied warranty.
9 * See the GNU General Public License for more details.
10 *
11 * Documents produced by Doxygen are derivative works derived from the
12 * input used in their production; they are not affected by this license.
13 *
14 */
15 
16 #ifndef DOTNODE_H
17 #define DOTNODE_H
18 
19 #include <vector>
20 #include <map>
21 #include <deque>
22 #include <iostream>
23 
24 #include "dotgraph.h"
25 
26 class ClassDef;
27 class DotNode;
28 class TextStream;
29 
30 /** Attributes of an edge of a dot graph */
31 class EdgeInfo
32 {
33  public:
34  enum Colors { Blue=0, Green=1, Red=2, Purple=3, Grey=4, Orange=5, Orange2=6 };
35  enum Styles { Solid=0, Dashed=1 };
36  EdgeInfo(int color,int style,const QCString &lab,const QCString &url,int labColor)
37  : m_color(color), m_style(style), m_label(lab), m_url(url), m_labColor(labColor) {}
38  ~EdgeInfo() {}
39  int color() const { return m_color; }
40  int style() const { return m_style; }
41  QCString label() const { return m_label; }
42  QCString url() const { return m_url; }
43  int labelColor() const { return m_labColor; }
44  private:
45  int m_color;
46  int m_style;
50 };
51 
52 using DotNodeRefVector = std::vector<DotNode*>;
53 using EdgeInfoVector = std::vector<EdgeInfo>;
54 
55 /** A node in a dot graph */
56 class DotNode
57 {
58  public:
59  static void deleteNodes(DotNode* node);
60  static QCString convertLabel(const QCString& l);
61  DotNode(int n,const QCString &lab,const QCString &tip,const QCString &url,
62  bool rootNode=FALSE,const ClassDef *cd=0);
63  ~DotNode();
64 
66 
67  void addChild(DotNode *n,
68  int edgeColor=EdgeInfo::Purple,
69  int edgeStyle=EdgeInfo::Solid,
70  const QCString &edgeLab=QCString(),
71  const QCString &edgeURL=QCString(),
72  int edgeLabCol=-1);
73  void addParent(DotNode *n);
74  void deleteNode(DotNodeRefVector &deletedList);
75  void removeChild(DotNode *n);
76  void removeParent(DotNode *n);
77  int findParent( DotNode *n );
78 
80  bool topDown,bool toChildren,bool backArrows) const;
81  void writeXML(TextStream &t,bool isClassGraph) const;
82  void writeDocbook(TextStream &t,bool isClassGraph) const;
83  void writeDEF(TextStream &t) const;
85  bool hasNonReachableChildren) const;
87  const EdgeInfo *ei,bool topDown, bool pointBack=TRUE) const;
88 
89  QCString label() const { return m_label; }
90  int number() const { return m_number; }
91  bool isVisible() const { return m_visible; }
92  TruncState isTruncated() const { return m_truncated; }
93  int distance() const { return m_distance; }
94  int subgraphId() const { return m_subgraphId; }
95  bool isRenumbered() const { return m_renumbered; }
96  bool hasDocumentation() const { return m_hasDoc; }
97  bool isWritten() const { return m_written; }
98 
99  void clearWriteFlag();
100  void renumberNodes(int &number);
101  void markRenumbered() { m_renumbered = true; }
102  void markHasDocumentation() { m_hasDoc = true; }
103  void setSubgraphId(int id) { m_subgraphId = id; }
104 
105  void colorConnectedNodes(int curColor);
106  void setDistance(int distance);
107  void markAsVisible(bool b=TRUE) { m_visible=b; }
109  const DotNodeRefVector &children() const { return m_children; }
110  const DotNodeRefVector &parents() const { return m_parents; }
111  const EdgeInfoVector &edgeInfo() const { return m_edgeInfo; }
112 
113  private:
114  int m_number;
115  QCString m_label; //!< label text
116  QCString m_tooltip; //!< node's tooltip
117  QCString m_url; //!< url of the node (format: remote$local)
118  DotNodeRefVector m_parents; //!< list of parent nodes (incoming arrows)
119  DotNodeRefVector m_children; //!< list of child nodes (outgoing arrows)
120  EdgeInfoVector m_edgeInfo; //!< edge info for each child
121  bool m_deleted = false; //!< used to mark a node as deleted
122  mutable bool m_written = false; //!< used to mark a node as written
123  bool m_hasDoc = false; //!< used to mark a node as documented
124  bool m_isRoot; //!< indicates if this is a root node
125  const ClassDef * m_classDef; //!< class representing this node (can be 0)
126  bool m_visible = false; //!< is the node visible in the output
127  TruncState m_truncated = Unknown; //!< does the node have non-visible children/parents
128  int m_distance = 1000; //!< shortest path to the root node
129  bool m_renumbered = false; //!< indicates if the node has been renumbered (to prevent endless loops)
130  int m_subgraphId = -1;
131 };
132 
133 class DotNodeMap : public std::map<std::string,DotNode*>
134 {
135 };
136 
137 class DotNodeDeque : public std::deque<DotNode*>
138 {
139 };
140 
141 #endif
DotNode::writeXML
void writeXML(TextStream &t, bool isClassGraph) const
Definition: dotnode.cpp:583
DotNode::m_deleted
bool m_deleted
used to mark a node as deleted
Definition: dotnode.h:121
DotNode::addChild
void addChild(DotNode *n, int edgeColor=EdgeInfo::Purple, int edgeStyle=EdgeInfo::Solid, const QCString &edgeLab=QCString(), const QCString &edgeURL=QCString(), int edgeLabCol=-1)
Definition: dotnode.cpp:281
DotNode::markHasDocumentation
void markHasDocumentation()
Definition: dotnode.h:102
DotNode::Untruncated
@ Untruncated
Definition: dotnode.h:65
DotNode::parents
const DotNodeRefVector & parents() const
Definition: dotnode.h:110
DotNode::Unknown
@ Unknown
Definition: dotnode.h:65
DotNode::setDistance
void setDistance(int distance)
Definition: dotnode.cpp:333
EdgeInfo::Red
@ Red
Definition: dotnode.h:34
DotNode::TruncState
TruncState
Definition: dotnode.h:65
DotNode::write
void write(TextStream &t, GraphType gt, GraphOutputFormat f, bool topDown, bool toChildren, bool backArrows) const
Definition: dotnode.cpp:532
DotNode::m_number
int m_number
Definition: dotnode.h:114
EdgeInfo::m_color
int m_color
Definition: dotnode.h:45
DotNode::m_classDef
const ClassDef * m_classDef
class representing this node (can be 0)
Definition: dotnode.h:125
DotNode::markAsTruncated
void markAsTruncated(bool b=TRUE)
Definition: dotnode.h:108
DotNode::writeDEF
void writeDEF(TextStream &t) const
Definition: dotnode.cpp:708
EdgeInfo::EdgeInfo
EdgeInfo(int color, int style, const QCString &lab, const QCString &url, int labColor)
Definition: dotnode.h:36
DotNode::deleteNodes
static void deleteNodes(DotNode *node)
Definition: dotnode.cpp:347
EdgeInfo::Styles
Styles
Definition: dotnode.h:35
DotNode::DotNode
DotNode(int n, const QCString &lab, const QCString &tip, const QCString &url, bool rootNode=FALSE, const ClassDef *cd=0)
Definition: dotnode.cpp:266
DotNode::addParent
void addParent(DotNode *n)
Definition: dotnode.cpp:298
DotNode::findParent
int findParent(DotNode *n)
Definition: dotnode.cpp:338
DotNode::isRenumbered
bool isRenumbered() const
Definition: dotnode.h:95
TextStream
Text streaming class that buffers data.
Definition: textstream.h:33
DotNode::~DotNode
~DotNode()
Definition: dotnode.cpp:277
EdgeInfo::Solid
@ Solid
Definition: dotnode.h:35
DotNode::markAsVisible
void markAsVisible(bool b=TRUE)
Definition: dotnode.h:107
DotNode::colorConnectedNodes
void colorConnectedNodes(int curColor)
Definition: dotnode.cpp:772
EdgeInfo::Orange
@ Orange
Definition: dotnode.h:34
EdgeInfo::m_label
QCString m_label
Definition: dotnode.h:47
EdgeInfo::label
QCString label() const
Definition: dotnode.h:41
DotNode::Truncated
@ Truncated
Definition: dotnode.h:65
EdgeInfoVector
std::vector< EdgeInfo > EdgeInfoVector
Definition: dotnode.h:53
EdgeInfo::labelColor
int labelColor() const
Definition: dotnode.h:43
DotNode::removeParent
void removeParent(DotNode *n)
Definition: dotnode.cpp:309
DotNode::writeDocbook
void writeDocbook(TextStream &t, bool isClassGraph) const
Definition: dotnode.cpp:645
DotNode::m_subgraphId
int m_subgraphId
Definition: dotnode.h:130
DotNode::m_written
bool m_written
used to mark a node as written
Definition: dotnode.h:122
DotNode
A node in a dot graph
Definition: dotnode.h:56
ClassDef
A abstract class representing of a compound symbol.
Definition: classdef.h:103
DotNode::m_renumbered
bool m_renumbered
indicates if the node has been renumbered (to prevent endless loops)
Definition: dotnode.h:129
DotNode::number
int number() const
Definition: dotnode.h:90
DotNode::writeBox
void writeBox(TextStream &t, GraphType gt, GraphOutputFormat f, bool hasNonReachableChildren) const
Definition: dotnode.cpp:357
GraphType
GraphType
Definition: dotgraph.h:29
DotNode::label
QCString label() const
Definition: dotnode.h:89
DotNode::m_tooltip
QCString m_tooltip
node's tooltip
Definition: dotnode.h:116
DotNode::subgraphId
int subgraphId() const
Definition: dotnode.h:94
TRUE
#define TRUE
Definition: qcstring.h:36
EdgeInfo::Blue
@ Blue
Definition: dotnode.h:34
EdgeInfo::Dashed
@ Dashed
Definition: dotnode.h:35
DotNode::clearWriteFlag
void clearWriteFlag()
Definition: dotnode.cpp:765
DotNode::isTruncated
TruncState isTruncated() const
Definition: dotnode.h:92
DotNodeMap
Definition: dotnode.h:133
EdgeInfo::m_labColor
int m_labColor
Definition: dotnode.h:49
DotNode::isVisible
bool isVisible() const
Definition: dotnode.h:91
EdgeInfo::~EdgeInfo
~EdgeInfo()
Definition: dotnode.h:38
dotgraph.h
DotNode::m_url
QCString m_url
url of the node (format: remote$local)
Definition: dotnode.h:117
DotNode::edgeInfo
const EdgeInfoVector & edgeInfo() const
Definition: dotnode.h:111
DotNode::writeArrow
void writeArrow(TextStream &t, GraphType gt, GraphOutputFormat f, const DotNode *cn, const EdgeInfo *ei, bool topDown, bool pointBack=TRUE) const
Definition: dotnode.cpp:483
EdgeInfo::m_style
int m_style
Definition: dotnode.h:46
DotNode::setSubgraphId
void setSubgraphId(int id)
Definition: dotnode.h:103
EdgeInfo
Attributes of an edge of a dot graph
Definition: dotnode.h:31
DotNodeDeque
Definition: dotnode.h:137
DotNode::removeChild
void removeChild(DotNode *n)
Definition: dotnode.cpp:303
DotNode::m_truncated
TruncState m_truncated
does the node have non-visible children/parents
Definition: dotnode.h:127
EdgeInfo::style
int style() const
Definition: dotnode.h:40
DotNode::distance
int distance() const
Definition: dotnode.h:93
DotNode::m_hasDoc
bool m_hasDoc
used to mark a node as documented
Definition: dotnode.h:123
EdgeInfo::color
int color() const
Definition: dotnode.h:39
EdgeInfo::Green
@ Green
Definition: dotnode.h:34
DotNode::m_isRoot
bool m_isRoot
indicates if this is a root node
Definition: dotnode.h:124
DotNode::m_distance
int m_distance
shortest path to the root node
Definition: dotnode.h:128
DotNode::m_edgeInfo
EdgeInfoVector m_edgeInfo
edge info for each child
Definition: dotnode.h:120
EdgeInfo::Purple
@ Purple
Definition: dotnode.h:34
DotNode::renumberNodes
void renumberNodes(int &number)
Definition: dotnode.cpp:799
DotNode::m_visible
bool m_visible
is the node visible in the output
Definition: dotnode.h:126
EdgeInfo::url
QCString url() const
Definition: dotnode.h:42
DotNode::isWritten
bool isWritten() const
Definition: dotnode.h:97
EdgeInfo::Colors
Colors
Definition: dotnode.h:34
GraphOutputFormat
GraphOutputFormat
Definition: dotgraph.h:27
DotNode::hasDocumentation
bool hasDocumentation() const
Definition: dotnode.h:96
EdgeInfo::Orange2
@ Orange2
Definition: dotnode.h:34
DotNode::convertLabel
static QCString convertLabel(const QCString &l)
Definition: dotnode.cpp:184
DotNode::m_children
DotNodeRefVector m_children
list of child nodes (outgoing arrows)
Definition: dotnode.h:119
DotNode::deleteNode
void deleteNode(DotNodeRefVector &deletedList)
Definition: dotnode.cpp:315
EdgeInfo::m_url
QCString m_url
Definition: dotnode.h:48
DotNode::m_parents
DotNodeRefVector m_parents
list of parent nodes (incoming arrows)
Definition: dotnode.h:118
DotNodeRefVector
std::vector< DotNode * > DotNodeRefVector
Definition: dotnode.h:52
DotNode::m_label
QCString m_label
label text
Definition: dotnode.h:115
EdgeInfo::Grey
@ Grey
Definition: dotnode.h:34
DotNode::children
const DotNodeRefVector & children() const
Definition: dotnode.h:109
FALSE
#define FALSE
Definition: qcstring.h:33
QCString
This is an alternative implementation of QCString.
Definition: qcstring.h:108
DotNode::markRenumbered
void markRenumbered()
Definition: dotnode.h:101