Doxygen
Loading...
Searching...
No Matches
dotnode.h
Go to the documentation of this file.
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 "types.h"
25#include "dotgraph.h"
26
27class ClassDef;
28class DotNode;
29class TextStream;
30
31/** Attributes of an edge of a dot graph */
33{
34 public:
35 enum Colors { Blue=0, Green=1, Red=2, Purple=3, Grey=4, Orange=5, Orange2=6 };
36 enum Styles { Solid=0, Dashed=1 };
37 EdgeInfo(Colors color,Styles style,const QCString &lab,const QCString &url,int labColor)
38 : m_color(color), m_style(style), m_label(lab), m_url(url), m_labColor(labColor) {}
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 static constexpr Colors protectionToColor(Protection prot)
45 {
46 switch (prot)
47 {
48 case Protection::Public: return Blue;
49 case Protection::Protected: return Green;
50 case Protection::Private: return Red;
51 case Protection::Package: return Purple;
52 }
53 return Blue;
54 }
55 private:
61};
62
63using DotNodeRefVector = std::vector<DotNode*>;
64using EdgeInfoVector = std::vector<EdgeInfo>;
65
66/** A node in a dot graph */
68{
69 public:
70 static constexpr auto placeholderUrl = "-";
71 static void deleteNodes(DotNode* node);
72 static QCString convertLabel(const QCString& , bool htmlLike=false);
73 DotNode(DotGraph *graph,const QCString &lab,const QCString &tip,const QCString &url,
74 bool rootNode=FALSE,const ClassDef *cd=nullptr);
75
77
78 void addChild(DotNode *n,
81 const QCString &edgeLab=QCString(),
82 const QCString &edgeURL=QCString(),
83 int edgeLabCol=-1);
84 void addParent(DotNode *n);
85 void deleteNode(DotNodeRefVector &deletedList);
86 void removeChild(DotNode *n);
87 void removeParent(DotNode *n);
88 int findParent( DotNode *n );
89
91 bool topDown,bool toChildren,bool backArrows);
92 void writeXML(TextStream &t,bool isClassGraph) const;
93 void writeDocbook(TextStream &t,bool isClassGraph) const;
94 void writeDEF(TextStream &t) const;
95 void writeLabel(TextStream &t, GraphType gt) const;
96 void writeUrl(TextStream &t) const;
98 bool hasNonReachableChildren) const;
100 const EdgeInfo *ei,bool topDown, bool pointBack=TRUE) const;
101
102 QCString label() const { return m_label; }
103 int number() const { return m_number; }
104 bool isVisible() const { return m_visible; }
106 int distance() const { return m_distance; }
107 int subgraphId() const { return m_subgraphId; }
108 bool isRenumbered() const { return m_renumbered; }
109 bool hasDocumentation() const { return m_hasDoc; }
110 bool isWritten() const { return m_written; }
111
112 void clearWriteFlag();
113 void renumberNodes(int &number);
114 void markRenumbered() { m_renumbered = true; }
115 DotNode& markHasDocumentation() { m_hasDoc = true; return *this;}
116 void setSubgraphId(int id) { m_subgraphId = id; }
117
118 void colorConnectedNodes(int curColor);
119 void setDistance(int distance);
120 void markAsVisible(bool b=TRUE) { m_visible=b; }
122 const DotNodeRefVector &children() const { return m_children; }
123 const DotNodeRefVector &parents() const { return m_parents; }
124 const EdgeInfoVector &edgeInfo() const { return m_edgeInfo; }
125 DotNode &setNodeId(int number) { m_number=number; return *this; }
126
127 private:
130 QCString m_label; //!< label text
131 QCString m_tooltip; //!< node's tooltip
132 QCString m_url; //!< url of the node (format: remote$local)
133 DotNodeRefVector m_parents; //!< list of parent nodes (incoming arrows)
134 DotNodeRefVector m_children; //!< list of child nodes (outgoing arrows)
135 EdgeInfoVector m_edgeInfo; //!< edge info for each child
136 bool m_deleted = false; //!< used to mark a node as deleted
137 bool m_written = false; //!< used to mark a node as written
138 bool m_hasDoc = false; //!< used to mark a node as documented
139 bool m_isRoot; //!< indicates if this is a root node
140 const ClassDef * m_classDef; //!< class representing this node (can be 0)
141 bool m_visible = false; //!< is the node visible in the output
142 TruncState m_truncated = Unknown; //!< does the node have non-visible children/parents
143 int m_distance = 1000; //!< shortest path to the root node
144 bool m_renumbered = false; //!< indicates if the node has been renumbered (to prevent endless loops)
145 int m_subgraphId = -1;
146};
147
148class DotNodeMap : public std::map<std::string,DotNode*>
149{
150};
151
152class DotNodeDeque : public std::deque<DotNode*>
153{
154};
155
156QCString escapeTooltip(const QCString &tooltip);
157
158#endif
A abstract class representing of a compound symbol.
Definition classdef.h:104
A dot graph.
Definition dotgraph.h:35
A node in a dot graph.
Definition dotnode.h:68
void writeDEF(TextStream &t) const
Definition dotnode.cpp:806
int findParent(DotNode *n)
Definition dotnode.cpp:371
int m_number
Definition dotnode.h:129
int distance() const
Definition dotnode.h:106
void writeUrl(TextStream &t) const
Definition dotnode.cpp:490
QCString m_tooltip
node's tooltip
Definition dotnode.h:131
void markRenumbered()
Definition dotnode.h:114
void setDistance(int distance)
Definition dotnode.cpp:366
void markAsVisible(bool b=TRUE)
Definition dotnode.h:120
void write(TextStream &t, GraphType gt, GraphOutputFormat f, bool topDown, bool toChildren, bool backArrows)
Definition dotnode.cpp:630
bool m_isRoot
indicates if this is a root node
Definition dotnode.h:139
void clearWriteFlag()
Definition dotnode.cpp:863
void removeParent(DotNode *n)
Definition dotnode.cpp:342
QCString m_label
label text
Definition dotnode.h:130
const EdgeInfoVector & edgeInfo() const
Definition dotnode.h:124
bool m_hasDoc
used to mark a node as documented
Definition dotnode.h:138
int number() const
Definition dotnode.h:103
void writeBox(TextStream &t, GraphType gt, GraphOutputFormat f, bool hasNonReachableChildren) const
Definition dotnode.cpp:515
TruncState m_truncated
does the node have non-visible children/parents
Definition dotnode.h:142
DotNode(DotGraph *graph, const QCString &lab, const QCString &tip, const QCString &url, bool rootNode=FALSE, const ClassDef *cd=nullptr)
Definition dotnode.cpp:302
void writeDocbook(TextStream &t, bool isClassGraph) const
Definition dotnode.cpp:743
void renumberNodes(int &number)
Definition dotnode.cpp:897
bool m_written
used to mark a node as written
Definition dotnode.h:137
DotNode & markAsTruncated(bool b=TRUE)
Definition dotnode.h:121
void setSubgraphId(int id)
Definition dotnode.h:116
void removeChild(DotNode *n)
Definition dotnode.cpp:336
static void deleteNodes(DotNode *node)
Definition dotnode.cpp:380
static QCString convertLabel(const QCString &, bool htmlLike=false)
Definition dotnode.cpp:196
EdgeInfoVector m_edgeInfo
edge info for each child
Definition dotnode.h:135
bool isRenumbered() const
Definition dotnode.h:108
int m_distance
shortest path to the root node
Definition dotnode.h:143
bool m_renumbered
indicates if the node has been renumbered (to prevent endless loops)
Definition dotnode.h:144
DotNode & markHasDocumentation()
Definition dotnode.h:115
int subgraphId() const
Definition dotnode.h:107
void addParent(DotNode *n)
Definition dotnode.cpp:331
bool isVisible() const
Definition dotnode.h:104
bool isWritten() const
Definition dotnode.h:110
DotNodeRefVector m_parents
list of parent nodes (incoming arrows)
Definition dotnode.h:133
bool m_visible
is the node visible in the output
Definition dotnode.h:141
void colorConnectedNodes(int curColor)
Definition dotnode.cpp:870
DotNodeRefVector m_children
list of child nodes (outgoing arrows)
Definition dotnode.h:134
bool hasDocumentation() const
Definition dotnode.h:109
TruncState
Definition dotnode.h:76
@ Truncated
Definition dotnode.h:76
@ Untruncated
Definition dotnode.h:76
@ Unknown
Definition dotnode.h:76
void addChild(DotNode *n, EdgeInfo::Colors edgeColor=EdgeInfo::Purple, EdgeInfo::Styles edgeStyle=EdgeInfo::Solid, const QCString &edgeLab=QCString(), const QCString &edgeURL=QCString(), int edgeLabCol=-1)
Definition dotnode.cpp:314
const DotNodeRefVector & parents() const
Definition dotnode.h:123
const ClassDef * m_classDef
class representing this node (can be 0)
Definition dotnode.h:140
static constexpr auto placeholderUrl
Definition dotnode.h:70
const DotNodeRefVector & children() const
Definition dotnode.h:122
TruncState isTruncated() const
Definition dotnode.h:105
bool m_deleted
used to mark a node as deleted
Definition dotnode.h:136
DotNode & setNodeId(int number)
Definition dotnode.h:125
void deleteNode(DotNodeRefVector &deletedList)
Definition dotnode.cpp:348
void writeLabel(TextStream &t, GraphType gt) const
Definition dotnode.cpp:390
QCString label() const
Definition dotnode.h:102
void writeArrow(TextStream &t, GraphType gt, GraphOutputFormat f, const DotNode *cn, const EdgeInfo *ei, bool topDown, bool pointBack=TRUE) const
Definition dotnode.cpp:579
DotGraph * m_graph
Definition dotnode.h:128
void writeXML(TextStream &t, bool isClassGraph) const
Definition dotnode.cpp:681
int m_subgraphId
Definition dotnode.h:145
QCString m_url
url of the node (format: remote$local)
Definition dotnode.h:132
Attributes of an edge of a dot graph.
Definition dotnode.h:33
QCString m_url
Definition dotnode.h:59
int m_labColor
Definition dotnode.h:60
QCString url() const
Definition dotnode.h:42
@ Solid
Definition dotnode.h:36
@ Dashed
Definition dotnode.h:36
int style() const
Definition dotnode.h:40
int labelColor() const
Definition dotnode.h:43
int m_color
Definition dotnode.h:56
static constexpr Colors protectionToColor(Protection prot)
Definition dotnode.h:44
int color() const
Definition dotnode.h:39
int m_style
Definition dotnode.h:57
QCString m_label
Definition dotnode.h:58
QCString label() const
Definition dotnode.h:41
EdgeInfo(Colors color, Styles style, const QCString &lab, const QCString &url, int labColor)
Definition dotnode.h:37
@ Green
Definition dotnode.h:35
@ Purple
Definition dotnode.h:35
@ Orange2
Definition dotnode.h:35
@ Orange
Definition dotnode.h:35
This is an alternative implementation of QCString.
Definition qcstring.h:101
Text streaming class that buffers data.
Definition textstream.h:36
GraphType
Definition dotgraph.h:31
GraphOutputFormat
Definition dotgraph.h:29
std::vector< DotNode * > DotNodeRefVector
Definition dotnode.h:63
QCString escapeTooltip(const QCString &tooltip)
Definition dotnode.cpp:99
std::vector< EdgeInfo > EdgeInfoVector
Definition dotnode.h:64
#define TRUE
Definition qcstring.h:37
#define FALSE
Definition qcstring.h:34
This file contains a number of basic enums and types.
Protection
Protection level of members.
Definition types.h:26
@ Package
Definition types.h:26
@ Public
Definition types.h:26
@ Private
Definition types.h:26
@ Protected
Definition types.h:26