#include "dotdirdeps.h"
#include "util.h"
#include "doxygen.h"
#include "config.h"
#include "image.h"
#include <algorithm>
#include <iterator>
#include <utility>
#include <cstdint>
#include <math.h>
#include <cassert>
#include <map>
#include <memory>
#include <string>
#include <vector>
浏览源代码.
|
using | DirDefMap = std::map< std::string, const DirDef * > |
|
typedef std::vector< std::pair< std::unique_ptr< DirRelation >, bool > > | DirRelations |
| Elements consist of (1) directory relation and (2) whether it is pointing only to inherited dependees. 更多...
|
|
|
static QCString | getDirectoryBackgroundColor (int depthIndex) |
| Returns a DOT color name according to the directory depth. 更多...
|
|
static const char * | getDirectoryBorderColor (const DotDirProperty &property) |
| Returns a DOT color name according to the directory properties. 更多...
|
|
static std::string | getDirectoryBorderStyle (const DotDirProperty &property) |
| Returns a DOT node style according to the directory properties. 更多...
|
|
static void | drawDirectory (TextStream &t, const DirDef *const directory, const DotDirProperty &property, DirDefMap &directoriesInGraph, int startLevel) |
| Puts DOT code for drawing directory to stream and adds it to the list. 更多...
|
|
static bool | isAtMaxDepth (const DirDef *const directory, const int startLevel) |
| Checks, if the directory is a the maximum drawn directory level. 更多...
|
|
static void | drawClusterOpening (TextStream &outputStream, const DirDef *const directory, const DotDirProperty &directoryProperty, DirDefMap &directoriesInGraph, const bool isAncestor, int startLevel) |
| Writes DOT code for opening a cluster subgraph to stream. 更多...
|
|
static void | drawClusterClosing (TextStream &t) |
|
static void | addDependencies (DirRelations &dependencies, const DirDef *const srcDir, bool isLeaf) |
| Assembles a list of the directory relations and whether or not they result from "inheritance". 更多...
|
|
static void | drawTree (DirRelations &dependencies, TextStream &t, const DirDef *const directory, int startLevel, DirDefMap &directoriesInGraph, const bool isTreeRoot) |
| Recursively draws directory tree. 更多...
|
|
void | writeDotDirDepGraph (TextStream &t, const DirDef *dd, bool linkRelations) |
| Write DOT code for directory dependency graph. 更多...
|
|
◆ DirDefMap
◆ DirRelations
Elements consist of (1) directory relation and (2) whether it is pointing only to inherited dependees.
在文件 dotdirdeps.cpp 第 60 行定义.
◆ addDependencies()
static void addDependencies |
( |
DirRelations & |
dependencies, |
|
|
const DirDef *const |
srcDir, |
|
|
bool |
isLeaf |
|
) |
| |
|
static |
Assembles a list of the directory relations and whether or not they result from "inheritance".
- 参数
-
dependencies | Array to add the dependencies to. |
srcDir | is the source of the dependency. |
isLeaf | true, if no children are drawn for this directory. |
在文件 dotdirdeps.cpp 第 212 行定义.
214 for (
const auto &usedDirectory : srcDir->
usedDirs())
216 const auto dstDir = usedDirectory->dir();
217 if (!dstDir->isParentOf(srcDir) && (isLeaf || usedDirectory->hasDirectSrcDeps()))
220 relationName.
sprintf(
"dir_%06d_%06d", srcDir->
dirCount(), dstDir->dirCount());
221 bool directRelation = isLeaf ? usedDirectory->hasDirectDstDeps() : usedDirectory->hasDirectDeps();
222 auto &&dependency = std::make_unique<DirRelation>(relationName, srcDir, usedDirectory.get());
223 auto &&pair = std::make_pair(std::move(dependency),directRelation);
224 dependencies.emplace_back(std::move(pair));
引用了 DirDef::dirCount(), QCString::sprintf() , 以及 DirDef::usedDirs().
被这些函数引用 drawTree().
◆ drawClusterClosing()
◆ drawClusterOpening()
static void drawClusterOpening |
( |
TextStream & |
outputStream, |
|
|
const DirDef *const |
directory, |
|
|
const DotDirProperty & |
directoryProperty, |
|
|
DirDefMap & |
directoriesInGraph, |
|
|
const bool |
isAncestor, |
|
|
int |
startLevel |
|
) |
| |
|
static |
Writes DOT code for opening a cluster subgraph to stream.
Ancestor clusters directly get a label. Other clusters get a plain text node with a label instead. This is because the plain text node can be used to draw dependency relationships.
在文件 dotdirdeps.cpp 第 174 行定义.
187 outputStream <<
"\", "
195 "label=\"" << directory->
shortName() <<
"\""
引用了 addHtmlExtensionIfMissing(), Config_getInt, Config_getString, getDirectoryBackgroundColor(), getDirectoryBorderColor(), getDirectoryBorderStyle(), DirDef::getOutputFileBase(), QCString::insert(), DirDef::level(), DirDef::shortName() , 以及 QCString::str().
被这些函数引用 drawTree() , 以及 writeDotDirDepGraph().
◆ drawDirectory()
Puts DOT code for drawing directory to stream and adds it to the list.
- 参数
-
[in,out] | t | stream to which the DOT code is written to |
[in] | directory | will be mapped to a node in DOT code |
[in] | property | are evaluated for formatting |
[in,out] | directoriesInGraph | lists the directories which have been written to the output stream |
[in] | startLevel | current level to calculate relative distances from to determine the background color |
在文件 dotdirdeps.cpp 第 148 行定义.
153 "label=\"" << directory->
shortName() <<
"\", "
引用了 addHtmlExtensionIfMissing(), getDirectoryBackgroundColor(), getDirectoryBorderColor(), getDirectoryBorderStyle(), DirDef::getOutputFileBase(), QCString::insert(), DirDef::level(), DirDef::shortName() , 以及 QCString::str().
被这些函数引用 drawTree().
◆ drawTree()
Recursively draws directory tree.
在文件 dotdirdeps.cpp 第 230 行定义.
236 drawDirectory(t, directory, directoryProperty, directoriesInGraph,startLevel);
244 drawDirectory(t, directory, directoryProperty, directoriesInGraph,startLevel);
252 drawClusterOpening(t, directory, directoryProperty, directoriesInGraph,
false, startLevel);
257 for (
const auto subDirectory : directory->
subDirs())
259 drawTree(dependencies, t, subDirectory, startLevel, directoriesInGraph,
false);
引用了 addDependencies(), drawClusterClosing(), drawClusterOpening(), drawDirectory(), DirDef::hasSubdirs(), isAtMaxDepth(), DotDirPropertyBuilder::makeOriginal() , 以及 DirDef::subDirs().
◆ getDirectoryBackgroundColor()
static QCString getDirectoryBackgroundColor |
( |
int |
depthIndex | ) |
|
|
static |
Returns a DOT color name according to the directory depth.
在文件 dotdirdeps.cpp 第 63 行定义.
68 assert(depthIndex>=0 && depthIndex<=
Config_getInt(DIR_GRAPH_MAX_DEPTH));
69 float fraction = (float)depthIndex/(
float)
Config_getInt(DIR_GRAPH_MAX_DEPTH);
70 const char hex[] =
"0123456789abcdef";
72 int luma = 0xef-(int)(fraction*range);
75 pow(luma/255.0,gamma/100.0),&r,&g,&b);
76 int red = (int)(r*255.0);
77 int green = (int)(g*255.0);
78 int blue = (int)(b*255.0);
79 assert(red>=0 && red<=255);
80 assert(green>=0 && green<=255);
81 assert(blue>=0 && blue<=255);
84 colStr[1]=
hex[red>>4];
85 colStr[2]=
hex[red&0xf];
86 colStr[3]=
hex[green>>4];
87 colStr[4]=
hex[green&0xf];
88 colStr[5]=
hex[blue>>4];
89 colStr[6]=
hex[blue&0xf];
引用了 Config_getInt, hex , 以及 ColoredImage::hsl2rgb().
被这些函数引用 drawClusterOpening() , 以及 drawDirectory().
◆ getDirectoryBorderColor()
static const char* getDirectoryBorderColor |
( |
const DotDirProperty & |
property | ) |
|
|
static |
◆ getDirectoryBorderStyle()
static std::string getDirectoryBorderStyle |
( |
const DotDirProperty & |
property | ) |
|
|
static |
◆ isAtMaxDepth()
static bool isAtMaxDepth |
( |
const DirDef *const |
directory, |
|
|
const int |
startLevel |
|
) |
| |
|
static |
◆ writeDotDirDepGraph()
void writeDotDirDepGraph |
( |
TextStream & |
t, |
|
|
const DirDef * |
dd, |
|
|
bool |
linkRelations |
|
) |
| |
Write DOT code for directory dependency graph.
Code is generated for a directory. Successors (sub-directories) of this directory are recursively drawn. Recursion is limited by DIR_GRAPH_MAX_DEPTH
. The dependencies of those directories are drawn.
If a dependee is not part of directory tree above, then the dependency is drawn to the first parent of the dependee, whose parent is an ancestor (sub-directory) of the original directory.
- 参数
-
t | stream where the DOT code is written to |
dd | directory for which the graph is generated for |
linkRelations | if true, hyperlinks to the list of file dependencies are added |
在文件 dotdirdeps.cpp 第 284 行定义.
290 std::vector<const DirDef *> usedDirsNotDrawn, usedDirsDrawn;
291 for (
const auto& usedDir : dd->
usedDirs())
293 usedDirsNotDrawn.push_back(usedDir->dir());
296 auto moveDrawnDirs = [&usedDirsDrawn,&usedDirsNotDrawn](
const std::vector<const DirDef *>::iterator &newEnd)
301 std::move(newEnd,
std::end(usedDirsNotDrawn), std::back_inserter(usedDirsDrawn));
302 usedDirsNotDrawn.erase(newEnd, usedDirsNotDrawn.end());
306 const auto parent = dd->
parent();
311 makeOrphaned(parent->parent()!=
nullptr);
316 const auto newEnd = std::stable_partition(usedDirsNotDrawn.begin(), usedDirsNotDrawn.end(),
317 [&](
const DirDef *
const usedDir)
319 if (dd!=usedDir && dd->parent()==usedDir->parent())
321 const DotDirProperty usedDirProperty = DotDirPropertyBuilder().makeTruncated(usedDir->hasSubdirs());
322 drawDirectory(t, usedDir, usedDirProperty, dirsInGraph, parent->level());
327 moveDrawnDirs(newEnd);
333 drawTree(dependencies, t, dd, dd->
level(), dirsInGraph,
true);
342 const auto newEnd = std::stable_partition(usedDirsNotDrawn.begin(), usedDirsNotDrawn.end(),
343 [&](
const DirDef *
const usedDir)
345 const DirDef *dir=dd;
348 if (dir!=usedDir && dir->parent()==usedDir->parent())
350 const DotDirProperty usedDirProperty = DotDirPropertyBuilder().
351 makeOrphaned(usedDir->parent()!=nullptr).
352 makeTruncated(usedDir->hasSubdirs()).
354 drawDirectory(t, usedDir, usedDirProperty, dirsInGraph, dir->level());
361 moveDrawnDirs(newEnd);
366 for (
const auto &relationPair : dependencies)
368 const auto &relation = relationPair.first;
369 const bool directRelation = relationPair.second;
370 const auto udir = relation->destination();
371 const auto usedDir = udir->dir();
373 const bool destIsDrawn = dirsInGraph.find(usedDir->getOutputFileBase().str())!=dirsInGraph.end();
376 if (destIsSibling || (destIsDrawn && (directRelation || atMaxDepth)))
378 const auto relationName = relation->getOutputFileBase();
379 const auto dir = relation->source();
381 std::make_unique<DirRelation>(
382 relationName,dir,udir));
383 size_t nrefs = udir->filePairs().size();
384 t <<
" " << dir->getOutputFileBase() <<
"->"
385 << usedDir->getOutputFileBase();
386 t <<
" [headlabel=\"" << (
uint)nrefs <<
"\", labeldistance=1.5";
引用了 drawClusterOpening(), end(), DirDef::getOutputFileBase(), DirDef::parent(), QCString::str() , 以及 DirDef::usedDirs().
被这些函数引用 DotDirDeps::computeTheGraph().
static void hsl2rgb(double h, double s, double l, double *pRed, double *pGreen, double *pBlue)
bool isIncomplete
true if not all successors of a cluster are drawn
std::vector< std::pair< std::unique_ptr< DirRelation >, bool > > DirRelations
Elements consist of (1) directory relation and (2) whether it is pointing only to inherited dependees...
virtual int dirCount() const =0
virtual const UsedDirLinkedMap & usedDirs() const =0
bool isOrphaned
true if parent is not drawn
A model of a directory symbol.
T * add(const char *k, Args &&... args)
Adds a new object to the ordered vector if it was not added already.
bool isTruncated
true has successors, none is drawn
bool isPeripheral
true if no successor of parent of original directory
static void drawClusterOpening(TextStream &outputStream, const DirDef *const directory, const DotDirProperty &directoryProperty, DirDefMap &directoriesInGraph, const bool isAncestor, int startLevel)
Writes DOT code for opening a cluster subgraph to stream.
virtual bool hasSubdirs() const =0
virtual int level() const =0
DirIterator begin(DirIterator it) noexcept
DirIterator end(const DirIterator &) noexcept
static QCString getDirectoryBackgroundColor(int depthIndex)
Returns a DOT color name according to the directory depth.
Properties are used to format the directories in the graph distinctively.
virtual QCString getOutputFileBase() const =0
QCString addHtmlExtensionIfMissing(const QCString &fName)
virtual const QCString shortName() const =0
#define Config_getInt(name)
QCString & insert(size_t index, const QCString &s)
static void drawTree(DirRelations &dependencies, TextStream &t, const DirDef *const directory, int startLevel, DirDefMap &directoriesInGraph, const bool isTreeRoot)
Recursively draws directory tree.
std::map< std::string, const DirDef * > DirDefMap
Builder helper to create instances of the DotDirProperty struct
static std::string getDirectoryBorderStyle(const DotDirProperty &property)
Returns a DOT node style according to the directory properties.
static void drawDirectory(TextStream &t, const DirDef *const directory, const DotDirProperty &property, DirDefMap &directoriesInGraph, int startLevel)
Puts DOT code for drawing directory to stream and adds it to the list.
static DirRelationLinkedMap dirRelations
static void drawClusterClosing(TextStream &t)
#define Config_getString(name)
static const char * getDirectoryBorderColor(const DotDirProperty &property)
Returns a DOT color name according to the directory properties.
bool isOriginal
true if is the directory for which the graph is drawn
static bool isAtMaxDepth(const DirDef *const directory, const int startLevel)
Checks, if the directory is a the maximum drawn directory level.
static void addDependencies(DirRelations &dependencies, const DirDef *const srcDir, bool isLeaf)
Assembles a list of the directory relations and whether or not they result from "inheritance".
DotDirPropertyBuilder & makeOriginal(bool b=true)
virtual const DirList & subDirs() const =0
virtual DirDef * parent() const =0
QCString & sprintf(const char *format,...)
This is an alternative implementation of QCString.