doxygen
dotgraph.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 DOTGRAPH_H
17 #define DOTGRAPH_H
18 
19 #include <iostream>
20 #include <map>
21 
22 #include "qcstring.h"
23 #include "dir.h"
24 #include "construct.h"
25 
26 class DotNode;
27 class TextStream;
28 
29 enum GraphOutputFormat { GOF_BITMAP, GOF_EPS };
30 enum EmbeddedOutputFormat { EOF_Html, EOF_LaTeX, EOF_Rtf, EOF_DocBook };
31 enum GraphType { Dependency, Inheritance, Collaboration, Hierarchy, CallGraph };
32 
34 class DotGraph
35 {
36  friend class DotNode;
37  public:
38  DotGraph() : m_doNotAddImageToIndex(FALSE), m_noDivTag(FALSE),
39  m_zoomable(TRUE), m_urlOnly(FALSE) {}
40  virtual ~DotGraph() = default;
41  NON_COPYABLE(DotGraph)
42 
43  protected:
45  int getNextNodeNumber() { return ++m_curNodeNumber; }
47  int getNextEdgeNumber() { return ++m_curEdgeNumber; }
48 
49  QCString writeGraph(TextStream &t,
50  GraphOutputFormat gf,
51  EmbeddedOutputFormat ef,
52  const QCString &path,
53  const QCString &fileName,
54  const QCString &relPath,
55  bool writeImageMap=TRUE,
56  int graphId=-1
57  );
58 
59  static void writeGraphHeader(TextStream& t, const QCString& title = QCString());
60  static void writeGraphFooter(TextStream& t);
61  static void computeGraph(DotNode* root,
62  GraphType gt,
63  GraphOutputFormat format,
64  const QCString& rank, // either "LR", "RL", or ""
65  bool renderParents,
66  bool backArrows,
67  const QCString& title,
68  QCString& graphStr
69  );
70 
71  virtual QCString getBaseName() const = 0;
72  virtual QCString absMapName() const { return m_absPath + m_baseName + ".map"; }
73  virtual QCString getMapLabel() const = 0;
74  virtual QCString getImgAltText() const { return ""; }
75 
76  virtual void computeTheGraph() = 0;
77 
78  QCString absBaseName() const { return m_absPath + m_baseName; }
79  QCString absDotName() const { return m_absPath + m_baseName + ".dot"; }
80  QCString imgName() const;
81  QCString absImgName() const { return m_absPath + imgName(); }
82  QCString relImgName() const { return m_relPath + imgName(); }
83 
84  // the following variables are used while writing the graph to a .dot file
85  GraphOutputFormat m_graphFormat = GOF_BITMAP;
86  EmbeddedOutputFormat m_textFormat = EOF_Html;
87  Dir m_dir;
88  QCString m_fileName;
89  QCString m_relPath;
90  bool m_generateImageMap = false;
91  int m_graphId = 0;
92 
93  QCString m_absPath;
94  QCString m_baseName;
95  QCString m_theGraph;
96  bool m_regenerate = false;
97  bool m_doNotAddImageToIndex = false;
98  bool m_noDivTag = false;
99  bool m_zoomable = true;
100  bool m_urlOnly = false;
101 
102  private:
103 
104  bool prepareDotFile();
105  void generateCode(TextStream &t);
106 
107  int m_curNodeNumber = 0;
108  int m_curEdgeNumber = 0;
109 };
110 
111 #endif
A node in a dot graph.
Definition: dotnode.h:67
Text streaming class that buffers data.
Definition: textstream.h:35
int getNextEdgeNumber()
returns the edge number.
Definition: dotgraph.h:47
Class representing a directory in the file system.
Definition: dir.h:74
A dot graph.
Definition: dotgraph.h:34
int getNextNodeNumber()
returns the node number.
Definition: dotgraph.h:45
This is an alternative implementation of QCString.
Definition: qcstring.h:93