📄 dot.cpp
字号:
if (format==GIF) // run dot to create a .gif image { QCString dotArgs(4096); dotArgs.sprintf("-Tgif \"%s.dot\" -o \"%s.gif\"", baseName.data(),baseName.data()); if (iSystem(Config_getString("DOT_PATH")+"dot",dotArgs)!=0) { err("Error: Problems running dot. Check your installation!\n"); QDir::setCurrent(oldDir); return baseName; } if (generateImageMap) { // run dot again to create an image map dotArgs.sprintf("-Timap \"%s.dot\" -o \"%s.map\"",baseName.data(),baseName.data()); if (iSystem(Config_getString("DOT_PATH")+"dot",dotArgs)!=0) { err("Error: Problems running dot. Check your installation!\n"); QDir::setCurrent(oldDir); return baseName; } QCString mapLabel = convertNameToFile(m_startNode->m_label+"_"+mapName); out << "<p><center><img src=\"" << baseName << ".gif\" border=\"0\" usemap=\"#" << mapLabel << "\" alt=\""; switch (m_graphType) { case Implementation: out << "Collaboration graph"; break; case Interface: out << "Interface dependency graph"; break; case Inheritance: out << "Inheritance graph"; break; } out << "\"></center>" << endl; out << "<map name=\"" << mapLabel << "\">" << endl; convertMapFile(out,baseName+".map"); out << "</map>" << endl; thisDir.remove(baseName+".map"); } } else if (format==EPS) // run dot to create a .eps image { QCString dotArgs(4096); dotArgs.sprintf("-Tps \"%s.dot\" -o \"%s.eps\"",baseName.data(),baseName.data()); if (iSystem(Config_getString("DOT_PATH")+"dot",dotArgs)!=0) { err("Error: Problems running dot. Check your installation!\n"); QDir::setCurrent(oldDir); return baseName; } int width,height; if (!readBoundingBoxEPS(baseName+".eps",&width,&height)) { err("Error: Could not extract bounding box from .eps!\n"); QDir::setCurrent(oldDir); return baseName; } if (Config_getBool("USE_PDFLATEX")) { QCString epstopdfArgs(4096); epstopdfArgs.sprintf("\"%s.eps\" --outfile=\"%s.pdf\"", baseName.data(),baseName.data()); if (iSystem("epstopdf",epstopdfArgs,TRUE)!=0) { err("Error: Problems running epstopdf. Check your TeX installation!\n"); QDir::setCurrent(oldDir); return baseName; } } int maxWidth = 420; /* approx. page width in points */ out << "\\begin{figure}[H]\n" "\\begin{center}\n" "\\leavevmode\n" "\\includegraphics[width=" << QMIN(width/2,maxWidth) << "pt]{" << baseName << "}\n" "\\end{center}\n" "\\end{figure}\n"; } if (Config_getBool("DOT_CLEANUP")) thisDir.remove(baseName+".dot"); QDir::setCurrent(oldDir); return baseName;}//--------------------------------------------------------------------void DotClassGraph::writeXML(QTextStream &t){ QDictIterator<DotNode> dni(*m_usedNodes); DotNode *node; for (;(node=dni.current());++dni) { node->writeXML(t); }}//--------------------------------------------------------------------int DotInclDepGraph::m_curNodeNumber;void DotInclDepGraph::buildGraph(DotNode *n,FileDef *fd,int distance){ QList<IncludeInfo> *includeFiles = m_inverse ? fd->includedByFileList() : fd->includeFileList(); QListIterator<IncludeInfo> ili(*includeFiles); IncludeInfo *ii; for (;(ii=ili.current());++ili) { FileDef *bfd = ii->fileDef; QCString in = ii->includeName; //printf(">>>> in=`%s' bfd=%p\n",ii->includeName.data(),bfd); bool doc=TRUE,src=FALSE; if (bfd) { in = bfd->absFilePath(); doc = bfd->isLinkableInProject(); src = bfd->generateSourceFile(); } if (doc || src) { QCString url=""; if (bfd) url=bfd->getOutputFileBase().copy(); if (!doc && src) { url+="-source"; } DotNode *bn = m_usedNodes->find(in); if (bn) // file is already a node in the graph { n->addChild(bn,0,0,0); bn->addParent(n); bn->setDistance(distance); } else { QCString tmp_url=""; if (bfd) tmp_url=bfd->getReference()+"$"+url; bn = new DotNode( m_curNodeNumber++, ii->includeName, tmp_url, distance ); if (distance>m_maxDistance) m_maxDistance=distance; n->addChild(bn,0,0,0); bn->addParent(n); m_usedNodes->insert(in,bn); if (bfd) buildGraph(bn,bfd,distance+1); } } }}DotInclDepGraph::DotInclDepGraph(FileDef *fd,bool inverse){ m_maxDistance = 0; m_inverse = inverse; ASSERT(fd!=0); m_diskName = fd->getFileBase().copy(); QCString tmp_url=fd->getReference()+"$"+fd->getFileBase(); m_startNode = new DotNode(m_curNodeNumber++, fd->name(), tmp_url.data(), 0, // distance TRUE // root node ); m_usedNodes = new QDict<DotNode>(1009); m_usedNodes->insert(fd->absFilePath(),m_startNode); buildGraph(m_startNode,fd,1);}DotInclDepGraph::~DotInclDepGraph(){ deleteNodes(m_startNode); delete m_usedNodes;}QCString DotInclDepGraph::diskName() const{ QCString result=m_diskName.copy(); if (m_inverse) result+="_dep"; result+="_incl"; return convertNameToFile(result); }QCString DotInclDepGraph::writeGraph(QTextStream &out, GraphOutputFormat format, const char *path, bool generateImageMap ){ QDir d(path); // store the original directory if (!d.exists()) { err("Error: Output dir %s does not exist!\n",path); exit(1); } QCString oldDir = convertToQCString(QDir::currentDirPath()); // go to the html output directory (i.e. path) QDir::setCurrent(d.absPath()); QDir thisDir; QCString baseName=m_diskName; if (m_inverse) baseName+="_dep"; baseName+="_incl"; baseName=convertNameToFile(baseName); QCString mapName=m_startNode->m_label.copy(); if (m_inverse) mapName+="dep"; findMaximalDotGraph(m_startNode,m_maxDistance,baseName,thisDir,format, FALSE,FALSE,!m_inverse); if (format==GIF) { // run dot to create a .gif image QCString dotArgs(4096); dotArgs.sprintf("-Tgif \"%s.dot\" -o \"%s.gif\"", baseName.data(),baseName.data()); if (iSystem(Config_getString("DOT_PATH")+"dot",dotArgs)!=0) { err("Problems running dot. Check your installation!\n"); QDir::setCurrent(oldDir); return baseName; } if (generateImageMap) { // run dot again to create an image map dotArgs.sprintf("-Timap \"%s.dot\" -o \"%s.map\"", baseName.data(),baseName.data()); if (iSystem(Config_getString("DOT_PATH")+"dot",dotArgs)!=0) { err("Problems running dot. Check your installation!\n"); QDir::setCurrent(oldDir); return baseName; } out << "<p><center><img src=\"" << baseName << ".gif\" border=\"0\" usemap=\"#" << mapName << "_map\" alt=\""; if (m_inverse) out << "Included by dependency graph"; else out << "Include dependency graph"; out << "\">"; out << "</center>" << endl; out << "<map name=\"" << mapName << "_map\">" << endl; convertMapFile(out,baseName+".map"); out << "</map>" << endl; thisDir.remove(baseName+".map"); } } else if (format==EPS) { // run dot to create a .eps image QCString dotArgs(4096); dotArgs.sprintf("-Tps \"%s.dot\" -o \"%s.eps\"", baseName.data(),baseName.data()); if (iSystem(Config_getString("DOT_PATH")+"dot",dotArgs)!=0) { err("Problems running dot. Check your installation!\n"); QDir::setCurrent(oldDir); return baseName; } int width,height; if (!readBoundingBoxEPS(baseName+".eps",&width,&height)) { err("Error: Could not extract bounding box from .eps!\n"); QDir::setCurrent(oldDir); return baseName; } if (Config_getBool("USE_PDFLATEX")) { QCString epstopdfArgs(4096); epstopdfArgs.sprintf("\"%s.eps\" --outfile=\"%s.pdf\"", baseName.data(),baseName.data()); if (iSystem("epstopdf",epstopdfArgs,TRUE)!=0) { err("Error: Problems running epstopdf. Check your TeX installation!\n"); QDir::setCurrent(oldDir); return baseName; } } int maxWidth = 420; /* approx. page width in points */ out << "\\begin{figure}[H]\n" "\\begin{center}\n" "\\leavevmode\n" //"\\setlength{\\epsfxsize}{" << QMIN(width/2,maxWidth) << "pt}\n" //"\\epsfbox{" << baseName << ".eps}\n" "\\includegraphics[width=" << QMIN(width/2,maxWidth) << "pt]{" << baseName << "}\n" "\\end{center}\n" "\\end{figure}\n"; } if (Config_getBool("DOT_CLEANUP")) thisDir.remove(baseName+".dot"); QDir::setCurrent(oldDir); return baseName;}bool DotInclDepGraph::isTrivial() const{ return m_startNode->m_children==0;}//-------------------------------------------------------------void generateGraphLegend(const char *path){ QFile dotFile((QCString)path+"/graph_legend.dot"); if (!dotFile.open(IO_WriteOnly)) { err("Could not open file %s for writing\n", convertToQCString(dotFile.name()).data()); return; } QTextStream dotText(&dotFile); #if 0 dotText << "digraph inheritance\n"; dotText << "{\n"; dotText << " Node7 [shape=\"box\",label=\"Inherited\",fontsize=10,height=0.2,width=0.4,fontname=\"doxfont\",color=\"black\",style=\"filled\" fontcolor=\"white\"];\n"; dotText << " Node8 -> Node7 [dir=back,color=\"midnightblue\",fontsize=10,style=\"solid\",fontname=\"doxfont\"];\n"; dotText << " Node8 [shape=\"box\",label=\"PublicBase\",fontsize=10,height=0.2,width=0.4,fontname=\"doxfont\",color=\"black\",URL=\"$class_publicbase.html\"];\n"; dotText << " Node9 -> Node8 [dir=back,color=\"midnightblue\",fontsize=10,style=\"solid\",fontname=\"doxfont\"];\n"; dotText << " Node9 [shape=\"box\",label=\"Truncated\",fontsize=10,height=0.2,width=0.4,fontname=\"doxfont\",color=\"red\",URL=\"$class_truncated.html\"];\n"; dotText << " Node11 -> Node7 [dir=back,color=\"darkgreen\",fontsize=10,style=\"solid\",fontname=\"doxfont\"];\n"; dotText << " Node11 [shape=\"box\",label=\"ProtectedBase\",fontsize=10,height=0.2,width=0.4,fontname=\"doxfont\",color=\"black\",URL=\"$class_protectedbase.html\"];\n"; dotText << " Node12 -> Node7 [dir=back,color=\"firebrick4\",fontsize=10,style=\"solid\",fontname=\"doxfont\"];\n"; dotText << " Node12 [shape=\"box\",label=\"PrivateBase\",fontsize=10,height=0.2,width=0.4,fontname=\"doxfont\",color=\"black\",URL=\"$class_privatebase.html\"];\n"; dotText << " Node13 -> Node7 [dir=back,color=\"midnightblue\",fontsize=10,style=\"solid\",fontname=\"doxfont\"];\n"; dotText << " Node13 [shape=\"box\",label=\"Undocumented\",fontsize=10,height=0.2,width=0.4,fontname=\"doxfont\",color=\"grey75\"];\n"; dotText << " Node14 -> Node7 [dir=back,color=\"darkorchid3\",fontsize=10,style=\"dashed\",label=\"m_usedClass\",fontname=\"doxfont\"];\n"; dotText << " Node14 [shape=\"box\",label=\"Used\",fontsize=10,height=0.2,width=0.4,fontname=\"doxfont\",color=\"black\",URL=\"$class_used.html\"];\n"; dotText << "}\n";#endif dotText << "digraph inheritance\n"; dotText << "{\n"; dotText << " Node9 [shape=\"box\",label=\"Inherited\",fontsize=10,height=0.2,width=0.4,fontname=\"doxfont\",color=\"black\",style=\"filled\" fontcolor=\"white\"];\n"; dotText << " Node10 -> Node9 [dir=back,color=\"midnightblue\",fontsize=10,style=\"solid\",fontname=\"doxfont\"];\n"; dotText << " Node10 [shape=\"box\",label=\"PublicBase\",fontsize=10,height=0.2,width=0.4,fontname=\"doxfont\",color=\"black\",URL=\"$classPublicBase.html\"];\n"; dotText << " Node11 -> Node10 [dir=back,color=\"midnightblue\",fontsize=10,style=\"solid\",fontname=\"doxfont\"];\n"; dotText << " Node11 [shape=\"box\",label=\"Truncated\",fontsize=10,height=0.2,width=0.4,fontname=\"doxfont\",color=\"red\",URL=\"$classTruncated.html\"];\n"; dotText << " Node13 -> Node9 [dir=back,color=\"darkgreen\",fontsize=10,style=\"solid\",fontname=\"doxfont\"];\n"; dotText << " Node13 [shape=\"box\",label=\"ProtectedBase\",fontsize=10,height=0.2,width=0.4,fontname=\"doxfont\",color=\"black\",URL=\"$classProtectedBase.html\"];\n"; dotText << " Node14 -> Node9 [dir=back,color=\"firebrick4\",fontsize=10,style=\"solid\",fontname=\"doxfont\"];\n"; dotText << " Node14 [shape=\"box\",label=\"PrivateBase\",fontsize=10,height=0.2,width=0.4,fontname=\"doxfont\",color=\"black\",URL=\"$classPrivateBase.html\"];\n"; dotText << " Node15 -> Node9 [dir=back,color=\"midnightblue\",fontsize=10,style=\"solid\",fontname=\"doxfont\"];\n"; dotText << " Node15 [shape=\"box\",label=\"Undocumented\",fontsize=10,height=0.2,width=0.4,fontname=\"doxfont\",color=\"grey75\"];\n"; dotText << " Node16 -> Node9 [dir=back,color=\"midnightblue\",fontsize=10,style=\"solid\",fontname=\"doxfont\"];\n"; dotText << " Node16 [shape=\"box\",label=\"Templ< int >\",fontsize=10,height=0.2,width=0.4,fontname=\"doxfont\",color=\"black\",URL=\"$classTempl.html\"];\n"; dotText << " Node17 -> Node16 [dir=back,color=\"orange\",fontsize=10,style=\"dashed\",label=\"< int >\",fontname=\"doxfont\"];\n"; dotText << " Node17 [shape=\"box\",label=\"Templ< T >\",fontsize=10,height=0.2,width=0.4,fontname=\"doxfont\",color=\"black\",URL=\"$classTempl.html\"];\n"; dotText << " Node18 -> Node9 [dir=back,color=\"darkorchid3\",fontsize=10,style=\"dashed\",label=\"m_usedClass\",fontname=\"doxfont\"];\n"; dotText << " Node18 [shape=\"box\",label=\"Used\",fontsize=10,height=0.2,width=0.4,fontname=\"doxfont\",color=\"black\",URL=\"$classUsed.html\"];\n"; dotText << "}\n"; dotFile.close(); QDir d(path); // store the original directory if (!d.exists()) { err("Error: Output dir %s does not exist!\n",path); exit(1); } QCString oldDir = convertToQCString(QDir::currentDirPath()); // go to the html output directory (i.e. path) QDir::setCurrent(d.absPath()); // run dot to generate the a .gif image from the graph QCString dotArgs(4096); dotArgs.sprintf("-Tgif graph_legend.dot -o graph_legend.gif"); if (iSystem(Config_getString("DOT_PATH")+"dot",dotArgs)!=0) { err("Problems running dot. Check your installation!\n"); QDir::setCurrent(oldDir); return; } QDir::setCurrent(oldDir);} void writeDotGraphFromFile(const char *inFile,const char *outFile, GraphOutputFormat format){ QCString dotArgs(4096); if (format==GIF) { dotArgs.sprintf("-Tgif \"%s\" -o \"%s.gif\"",inFile,outFile); } else // format==EPS { dotArgs.sprintf("-Tps \"%s\" -o \"%s.eps\"",inFile,outFile); } QCString dotExe = Config_getString("DOT_PATH")+"dot"; //printf("Running: %s %s\n",dotExe.data(),dotArgs.data()); if (iSystem(dotExe,dotArgs)!=0) { err("Problems running dot. Check your installation!\n"); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -