浏览该文件的文档.
33 using DirDefMap = std::map<std::string,const DirDef *>;
60 typedef std::vector< std::pair< std::unique_ptr<DirRelation>,
bool> >
DirRelations;
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];
149 DirDefMap &directoriesInGraph,
int startLevel)
153 "label=\"" << directory->
shortName() <<
"\", "
187 outputStream <<
"\", "
195 "label=\"" << directory->
shortName() <<
"\""
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));
231 int startLevel,
DirDefMap &directoriesInGraph,
const bool isTreeRoot)
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);
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();
374 const bool atMaxDepth =
isAtMaxDepth(usedDir, dd->level());
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();
385 << usedDir->getOutputFileBase();
386 t <<
" [headlabel=\"" << (
uint)nrefs <<
"\", labeldistance=1.5";
416 md5stream <<
" compound=true\n";
434 int graphId,
bool linkRelations)
438 return DotGraph::writeGraph(out, graphFormat, textFormat, path, fileName, relPath, generateImageMap, graphId);
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
DotDirDeps(const DirDef *dir)
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.
virtual QCString getMapLabel() const
T * add(const char *k, Args &&... args)
Adds a new object to the ordered vector if it was not added already.
static void writeGraphFooter(TextStream &t)
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
Text streaming class that buffers data.
static void writeGraphHeader(TextStream &t, const QCString &title=QCString())
QCString writeGraph(TextStream &out, GraphOutputFormat gf, EmbeddedOutputFormat ef, const QCString &path, const QCString &fileName, const QCString &relPath, bool writeImageMap=TRUE, int graphId=-1, bool linkRelations=TRUE)
virtual QCString getImgAltText() const
virtual int level() const =0
DirIterator begin(DirIterator it) noexcept
DirIterator end(const DirIterator &) noexcept
QCString getOutputFileBase() const
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)
virtual QCString getBaseName() const
static void drawTree(DirRelations &dependencies, TextStream &t, const DirDef *const directory, int startLevel, DirDefMap &directoriesInGraph, const bool isTreeRoot)
Recursively draws directory tree.
DotDirPropertyBuilder & makeTruncated(bool b=true)
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.
std::string str() const
Return the contents of the buffer as a std::string object
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
QCString writeGraph(TextStream &t, GraphOutputFormat gf, EmbeddedOutputFormat ef, const QCString &path, const QCString &fileName, const QCString &relPath, bool writeImageMap=TRUE, int graphId=-1)
static void drawClusterClosing(TextStream &t)
void writeDotDirDepGraph(TextStream &t, const DirDef *dd, bool linkRelations)
Write DOT code for directory dependency graph.
DotDirPropertyBuilder & makePeripheral(bool b=true)
DotDirProperty m_property
DotDirPropertyBuilder & makeIncomplete(bool b=true)
QCString escapeCharsInString(const QCString &name, bool allowDots, bool allowUnderscore)
virtual bool depGraphIsTrivial() const =0
#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.
QCString convertToXML(const QCString &s, bool keepEntities)
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 & makeOrphaned(bool b=true)
virtual QCString displayName(bool=TRUE) const =0
DotDirPropertyBuilder & makeOriginal(bool b=true)
virtual const DirList & subDirs() const =0
virtual DirDef * parent() const =0
A bunch of utility functions.
virtual void computeTheGraph()
QCString & sprintf(const char *format,...)
This is an alternative implementation of QCString.