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 31 /** A dot graph */ 32 class DotGraph 33 { 34 public: DotGraph()35 DotGraph() : m_doNotAddImageToIndex(FALSE), m_noDivTag(FALSE), 36 m_zoomable(TRUE), m_urlOnly(FALSE) {} ~DotGraph()37 virtual ~DotGraph() {} 38 39 protected: 40 /** returns node numbers. The Counter is reset by the constructor */ getNextNodeNumber()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; absMapName()66 virtual QCString absMapName() const { return m_absPath + m_baseName + ".map"; } 67 virtual QCString getMapLabel() const = 0; getImgAltText()68 virtual QCString getImgAltText() const { return ""; } 69 70 virtual void computeTheGraph() = 0; 71 absBaseName()72 QCString absBaseName() const { return m_absPath + m_baseName; } absDotName()73 QCString absDotName() const { return m_absPath + m_baseName + ".dot"; } 74 QCString imgName() const; absImgName()75 QCString absImgName() const { return m_absPath + imgName(); } relImgName()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 107