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 enum class LabelStyle { Plain, List, Table };
71 static constexpr auto placeholderUrl = "-";
72 static void deleteNodes(DotNode* node);
74 DotNode(DotGraph *graph,const QCString &lab,const QCString &tip,const QCString &url,
75 bool rootNode=FALSE,const ClassDef *cd=nullptr);
76
78
79 void addChild(DotNode *n,
82 const QCString &edgeLab=QCString(),
83 const QCString &edgeURL=QCString(),
84 int edgeLabCol=-1);
85 void addParent(DotNode *n);
86 void deleteNode(DotNodeRefVector &deletedList);
87 void removeChild(DotNode *n);
88 void removeParent(DotNode *n);
89 int findParent( DotNode *n );
90
92 bool topDown,bool toChildren,bool backArrows);
93 void writeXML(TextStream &t,bool isClassGraph) const;
94 void writeDocbook(TextStream &t,bool isClassGraph) const;
95 void writeDEF(TextStream &t) const;
96 void writeLabel(TextStream &t, GraphType gt) const;
97 void writeUrl(TextStream &t) const;
99 bool hasNonReachableChildren) const;
101 const EdgeInfo *ei,bool topDown, bool pointBack=TRUE) const;
102
103 QCString label() const { return m_label; }
104 int number() const { return m_number; }
105 bool isVisible() const { return m_visible; }
107 int distance() const { return m_distance; }
108 int subgraphId() const { return m_subgraphId; }
109 bool isRenumbered() const { return m_renumbered; }
110 bool hasDocumentation() const { return m_hasDoc; }
111 bool isWritten() const { return m_written; }
112
113 void clearWriteFlag();
114 void renumberNodes(int &number);
115 void markRenumbered() { m_renumbered = true; }
116 DotNode& markHasDocumentation() { m_hasDoc = true; return *this;}
117 void setSubgraphId(int id) { m_subgraphId = id; }
118
119 void colorConnectedNodes(int curColor);
120 void setDistance(int distance);
121 void markAsVisible(bool b=TRUE) { m_visible=b; }
123 const DotNodeRefVector &children() const { return m_children; }
124 const DotNodeRefVector &parents() const { return m_parents; }
125 const EdgeInfoVector &edgeInfo() const { return m_edgeInfo; }
126 DotNode &setNodeId(int number) { m_number=number; return *this; }
127
128 private:
131 QCString m_label; //!< label text
132 QCString m_tooltip; //!< node's tooltip
133 QCString m_url; //!< url of the node (format: remote$local)
134 DotNodeRefVector m_parents; //!< list of parent nodes (incoming arrows)
135 DotNodeRefVector m_children; //!< list of child nodes (outgoing arrows)
136 EdgeInfoVector m_edgeInfo; //!< edge info for each child
137 bool m_deleted = false; //!< used to mark a node as deleted
138 bool m_written = false; //!< used to mark a node as written
139 bool m_hasDoc = false; //!< used to mark a node as documented
140 bool m_isRoot; //!< indicates if this is a root node
141 const ClassDef * m_classDef; //!< class representing this node (can be 0)
142 bool m_visible = false; //!< is the node visible in the output
143 TruncState m_truncated = Unknown; //!< does the node have non-visible children/parents
144 int m_distance = 1000; //!< shortest path to the root node
145 bool m_renumbered = false; //!< indicates if the node has been renumbered (to prevent endless loops)
146 int m_subgraphId = -1;
147};
148
149class DotNodeMap : public std::map<std::string,DotNode*>
150{
151};
152
153class DotNodeDeque : public std::deque<DotNode*>
154{
155};
156
157QCString escapeTooltip(const QCString &tooltip);
158
159#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:831
int findParent(DotNode *n)
Definition dotnode.cpp:396
int m_number
Definition dotnode.h:130
int distance() const
Definition dotnode.h:107
void writeUrl(TextStream &t) const
Definition dotnode.cpp:515
QCString m_tooltip
node's tooltip
Definition dotnode.h:132
void markRenumbered()
Definition dotnode.h:115
void setDistance(int distance)
Definition dotnode.cpp:391
void markAsVisible(bool b=TRUE)
Definition dotnode.h:121
void write(TextStream &t, GraphType gt, GraphOutputFormat f, bool topDown, bool toChildren, bool backArrows)
Definition dotnode.cpp:655
bool m_isRoot
indicates if this is a root node
Definition dotnode.h:140
void clearWriteFlag()
Definition dotnode.cpp:888
void removeParent(DotNode *n)
Definition dotnode.cpp:367
QCString m_label
label text
Definition dotnode.h:131
const EdgeInfoVector & edgeInfo() const
Definition dotnode.h:125
bool m_hasDoc
used to mark a node as documented
Definition dotnode.h:139
int number() const
Definition dotnode.h:104
void writeBox(TextStream &t, GraphType gt, GraphOutputFormat f, bool hasNonReachableChildren) const
Definition dotnode.cpp:540
TruncState m_truncated
does the node have non-visible children/parents
Definition dotnode.h:143
DotNode(DotGraph *graph, const QCString &lab, const QCString &tip, const QCString &url, bool rootNode=FALSE, const ClassDef *cd=nullptr)
Definition dotnode.cpp:327
void writeDocbook(TextStream &t, bool isClassGraph) const
Definition dotnode.cpp:768
void renumberNodes(int &number)
Definition dotnode.cpp:922
bool m_written
used to mark a node as written
Definition dotnode.h:138
DotNode & markAsTruncated(bool b=TRUE)
Definition dotnode.h:122
void setSubgraphId(int id)
Definition dotnode.h:117
void removeChild(DotNode *n)
Definition dotnode.cpp:361
static QCString convertLabel(const QCString &, LabelStyle=LabelStyle::Plain)
Definition dotnode.cpp:196
static void deleteNodes(DotNode *node)
Definition dotnode.cpp:405
EdgeInfoVector m_edgeInfo
edge info for each child
Definition dotnode.h:136
bool isRenumbered() const
Definition dotnode.h:109
int m_distance
shortest path to the root node
Definition dotnode.h:144
bool m_renumbered
indicates if the node has been renumbered (to prevent endless loops)
Definition dotnode.h:145
DotNode & markHasDocumentation()
Definition dotnode.h:116
int subgraphId() const
Definition dotnode.h:108
void addParent(DotNode *n)
Definition dotnode.cpp:356
bool isVisible() const
Definition dotnode.h:105
bool isWritten() const
Definition dotnode.h:111
DotNodeRefVector m_parents
list of parent nodes (incoming arrows)
Definition dotnode.h:134
bool m_visible
is the node visible in the output
Definition dotnode.h:142
void colorConnectedNodes(int curColor)
Definition dotnode.cpp:895
DotNodeRefVector m_children
list of child nodes (outgoing arrows)
Definition dotnode.h:135
bool hasDocumentation() const
Definition dotnode.h:110
TruncState
Definition dotnode.h:77
@ Truncated
Definition dotnode.h:77
@ Untruncated
Definition dotnode.h:77
@ Unknown
Definition dotnode.h:77
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:339
const DotNodeRefVector & parents() const
Definition dotnode.h:124
const ClassDef * m_classDef
class representing this node (can be 0)
Definition dotnode.h:141
LabelStyle
Definition dotnode.h:70
static constexpr auto placeholderUrl
Definition dotnode.h:71
const DotNodeRefVector & children() const
Definition dotnode.h:123
TruncState isTruncated() const
Definition dotnode.h:106
bool m_deleted
used to mark a node as deleted
Definition dotnode.h:137
DotNode & setNodeId(int number)
Definition dotnode.h:126
void deleteNode(DotNodeRefVector &deletedList)
Definition dotnode.cpp:373
void writeLabel(TextStream &t, GraphType gt) const
Definition dotnode.cpp:415
QCString label() const
Definition dotnode.h:103
void writeArrow(TextStream &t, GraphType gt, GraphOutputFormat f, const DotNode *cn, const EdgeInfo *ei, bool topDown, bool pointBack=TRUE) const
Definition dotnode.cpp:604
DotGraph * m_graph
Definition dotnode.h:129
void writeXML(TextStream &t, bool isClassGraph) const
Definition dotnode.cpp:706
int m_subgraphId
Definition dotnode.h:146
QCString m_url
url of the node (format: remote$local)
Definition dotnode.h:133
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