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 
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;
47  QCString m_label;
48  QCString m_url;
49  int m_labColor;
50 };
51 
52 using DotNodeRefVector = std::vector<DotNode*>;
53 using EdgeInfoVector = std::vector<EdgeInfo>;
54 
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 
65  enum TruncState { Unknown, Truncated, Untruncated };
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 
79  void write(TextStream &t,GraphType gt,GraphOutputFormat f,
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;
84  void writeBox(TextStream &t,GraphType gt,GraphOutputFormat f,
85  bool hasNonReachableChildren) const;
86  void writeArrow(TextStream &t,GraphType gt,GraphOutputFormat f,const DotNode *cn,
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; }
108  void markAsTruncated(bool b=TRUE) { m_truncated=b ? Truncated : Untruncated; }
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;
116  QCString m_tooltip;
117  QCString m_url;
118  DotNodeRefVector m_parents;
119  DotNodeRefVector m_children;
120  EdgeInfoVector m_edgeInfo;
121  bool m_deleted = false;
122  mutable bool m_written = false;
123  bool m_hasDoc = false;
124  bool m_isRoot;
125  const ClassDef * m_classDef;
126  bool m_visible = false;
127  TruncState m_truncated = Unknown;
128  int m_distance = 1000;
129  bool m_renumbered = false;
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
Definition: dotnode.h:137
A node in a dot graph.
Definition: dotnode.h:56
Text streaming class that buffers data.
Definition: textstream.h:33
Definition: dotnode.h:133
Attributes of an edge of a dot graph.
Definition: dotnode.h:31
This is an alternative implementation of QCString.
Definition: qcstring.h:108
A abstract class representing of a compound symbol.
Definition: classdef.h:103