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