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);