50 void move(
int dx,
int dy) {
m_x=
static_cast<uint32_t
>(
m_x+dx);
m_y=
static_cast<uint32_t
>(
m_y+dy); }
53 float xfPos()
const {
return static_cast<float>(
m_x); }
54 float yfPos()
const {
return static_cast<float>(
m_y); }
81 using Ptr = std::unique_ptr<DiagramItem>;
82 using Vec = std::vector<Ptr>;
106 using Ptr = std::unique_ptr<DiagramRow>;
107 using Vec = std::vector<Ptr>;
115 bool doBase,
bool bitmap,
116 uint32_t baseRows,uint32_t superRows,
117 uint32_t cellWidth,uint32_t cellHeight,
119 bool generateMap=
TRUE);
121 bool doBase,
bool bitmap,
122 uint32_t baseRows,uint32_t superRows,
123 uint32_t cellWidth,uint32_t cellheight);
127 {
m_rows.push_back(std::make_unique<DiagramRow>(
this,l));
return m_rows.back().get(); }
199 const char *p=s.
data();
205 case '(': growBuf.
addStr(
"\\(");
break;
206 case ')': growBuf.
addStr(
"\\)");
break;
207 default: growBuf.
addChar(c);
break;
211 return growBuf.
get();
217 auto it = dil.begin();
221 result=(*it)->protection();
222 for (++it;it!=dil.end();++it)
236 uint32_t x,uint32_t y,uint32_t w,uint32_t h,
bool firstRow,
237 bool hasDocs,
bool children=
FALSE)
239 uint8_t colFill = hasDocs ? (firstRow ? 8 : 2) : 7;
240 uint8_t colBorder = (firstRow || !hasDocs) ? 1 : 3;
243 image->
fillRect(x+1,y+1,w-2,h-2,colFill,mask);
244 image->
drawRect(x,y,w,h,colBorder,mask);
248 for (uint32_t i=0;i<5;i++)
250 image->
drawHorzLine(y+h+i-6,x+w-2-i,x+w-2,firstRow?1:3,0xffffffff);
256 float x,
float y,
bool children=
FALSE)
260 if (children) t << x <<
" " << y <<
" mark\n";
265 uint32_t x,uint32_t y,uint32_t w,uint32_t h)
291 t <<
"\" shape=\"rect\" coords=\"" << x <<
"," << y <<
",";
292 t << (x+w) <<
"," << (y+h) <<
"\"/>\n";
346 return static_cast<uint32_t
>(
m_children.size());
364 m_items.push_back(std::move(di));
390 doBases ? bcd.templSpecifiers :
QCString());
400 auto row = std::make_unique<DiagramRow>(
this,0);
423 uint32_t pPos=root->
xPos();
430 for (uint32_t k=children.front()->number();k<row->numItems();k++)
432 row->item(k)->move(
static_cast<int>(pPos-cPos),0);
441 for (uint32_t k=root->
number();k<row->numItems();k++)
443 row->item(k)->move(
static_cast<int>(cPos-pPos),0);
449 auto it = children.begin();
450 for (;it!=children.end() && !moved && !(*it)->isInList();++it)
464 const auto &
row = *it;
469 for (
const auto &di : *
row)
472 if (pi==opi && !first) { delta-=
gridWidth; }
488 const auto &
row = *it;
489 auto rit =
row->begin();
490 while (rit!=
row->end())
496 while (rit!=
row->end() && (*rit)->parentItem()==pi)
514 while (it!=
m_rows.end() && !(*it)->item(0)->isInList())
523 const auto &
row = *it;
524 uint32_t maxListLen=0;
525 uint32_t curListLen=0;
527 for (
const auto &di : *
row)
529 if (di->parentItem()!=opi) curListLen=1;
else curListLen++;
530 if (curListLen>maxListLen) maxListLen=curListLen;
542 for (
const auto &dr :
m_rows)
545 for (
const auto &di : *dr)
547 if (di->isInList()) done=
TRUE;
548 if (maxXPos) mx=std::max(mx,di->xPos());
553 if (maxLabelLen) *maxLabelLen=ml;
554 if (maxXPos) *maxXPos=mx;
558template<
class C,
class I>
565 if (fwd)
m_it = container.begin();
566 else m_rit = container.rbegin();
593 bool doBase,
bool bitmap,
594 uint32_t baseRows,uint32_t superRows,
595 uint32_t cellWidth,uint32_t cellHeight,
600 if (it!=
m_rows.end() && !doBase) ++it;
601 bool firstRow = doBase;
603 float superRowsF =
static_cast<float>(superRows);
604 for (;it!=
m_rows.end() && !done;++it)
606 const auto &dr = *it;
608 float xf=0.0f,yf=0.0f;
626 if (doBase) yf += 1.0f;
638 superRows*cellHeight-
668 if (!firstRow && generateMap)
682 for (
const auto &di : *dr)
690 superRows*cellHeight-
699 bool hasDocs=di->getClassDef()->isLinkable();
700 writeBitmapBox(di.get(),image,x,y,cellWidth,cellHeight,firstRow,hasDocs);
701 if (!firstRow && generateMap)
702 writeMapArea(t,di->getClassDef(),relPath,x,y,cellWidth,cellHeight);
724 bool doBase,
bool bitmap,
725 uint32_t baseRows,uint32_t superRows,
726 uint32_t cellWidth,uint32_t cellHeight)
730 float superRowsF =
static_cast<float>(superRows);
731 for (;it!=
m_rows.end() && !done;++it)
733 const auto &dr = *it;
737 uint32_t x=0,y=0,ys=0;
738 float xf=0.0f,yf=0.0f,ysf=0.0f;
739 auto rit = dr->begin();
740 while (rit!=dr->end())
797 y = ys - cellHeight/2;
803 y = ys + cellHeight/2;
844 t <<
"1 " << xf <<
" " << yf <<
" hedge\n";
849 t <<
"0 " << xf <<
" " << yf <<
" hedge\n";
854 if (rit!=dr->end()) di = (*rit).get();
else di=
nullptr;
883 t <<
"1 " << xf <<
" " << yf <<
" hedge\n";
887 t <<
"0 " << xf <<
" " << yf <<
" hedge\n";
892 t << xf <<
" " << ysf <<
" " << yf <<
" vedge\n";
896 t << xf <<
" " << (ysf + 0.25f) <<
" " << yf <<
" vedge\n";
900 if (rit!=dr->end()) ++rit;
906 for (
const auto &di : *dr)
942 t <<
"1 " << di->xfPos()/
gridWidth <<
" "
943 << (di->yfPos()/
gridHeight+superRowsF-1.0f) <<
" in\n";
947 t <<
"0 " << di->xfPos()/
gridWidth <<
" "
982 t <<
"0 " << di->xfPos()/
gridWidth <<
" "
983 << (di->yfPos()/
gridHeight+superRowsF-1.0f) <<
" out\n";
987 t <<
"1 " << di->xfPos()/
gridWidth <<
" "
995 if (first!=last && !first->
isInList())
1051 p->base.computeLayout();
1052 p->super.computeLayout();
1055 uint32_t xbase = baseItem->
xPos();
1056 uint32_t xsuper = superItem->
xPos();
1059 int dist=
static_cast<int>(xbase-xsuper);
1060 superItem->
move(dist,0);
1061 p->super.moveChildren(superItem,dist);
1063 else if (xbase<xsuper)
1065 int dist=
static_cast<int>(xsuper-xbase);
1066 baseItem->
move(dist,0);
1067 p->base.moveChildren(baseItem,dist);
1076 uint32_t baseRows=
p->base.computeRows();
1077 uint32_t superRows=
p->super.computeRows();
1078 uint32_t baseMaxX = 0, baseMaxLabelWidth = 0, superMaxX = 0, superMaxLabelWidth = 0;
1079 p->base.computeExtremes(&baseMaxLabelWidth,&baseMaxX);
1080 p->super.computeExtremes(&superMaxLabelWidth,&superMaxX);
1082 uint32_t rows=std::max(1u,baseRows+superRows-1);
1086 float estHeight =
static_cast<float>(rows)*40.0f;
1087 float estWidth =
static_cast<float>(cols)*(20+
static_cast<float>(std::max(baseMaxLabelWidth,superMaxLabelWidth)));
1090 const float pageWidth = 14.0f;
1095 float realHeight =
static_cast<float>(std::min(rows,12u));
1096 float realWidth = realHeight * estWidth/estHeight;
1097 if (realWidth>pageWidth)
1099 realHeight*=pageWidth/realWidth;
1103 output <<
"\\begin{figure}[H]\n"
1106 output <<
"\\includegraphics[height=" << realHeight <<
"cm]{"
1107 << fileName <<
"}\n";
1108 output <<
"\\end{center}\n"
1114 QCString epsName=epsBaseName+
".eps";
1118 term(
"Could not open file %s for writing\n",
qPrint(epsName));
1128 t <<
"%!PS-Adobe-2.0 EPSF-2.0\n";
1129 t <<
"%%Title: ClassName\n";
1130 t <<
"%%Creator: Doxygen\n";
1131 t <<
"%%CreationDate: Time\n";
1133 t <<
"%Magnification: 1.00\n";
1134 t <<
"%%Orientation: Portrait\n";
1135 t <<
"%%BoundingBox: 0 0 500 " << estHeight*500.0f/estWidth <<
"\n";
1136 t <<
"%%Pages: 0\n";
1137 t <<
"%%BeginSetup\n";
1138 t <<
"%%EndSetup\n";
1139 t <<
"%%EndComments\n";
1141 t <<
"% ----- variables -----\n";
1143 t <<
"/boxwidth 0 def\n";
1144 t <<
"/boxheight 40 def\n";
1145 t <<
"/fontheight 24 def\n";
1146 t <<
"/marginwidth 10 def\n";
1147 t <<
"/distx 20 def\n";
1148 t <<
"/disty 40 def\n";
1149 t <<
"/boundaspect " << estWidth/estHeight <<
" def % aspect ratio of the BoundingBox (width/height)\n";
1150 t <<
"/boundx 500 def\n";
1151 t <<
"/boundy boundx boundaspect div def\n";
1152 t <<
"/xspacing 0 def\n";
1153 t <<
"/yspacing 0 def\n";
1154 t <<
"/rows " << rows <<
" def\n";
1155 t <<
"/cols " << cols <<
" def\n";
1156 t <<
"/scalefactor 0 def\n";
1157 t <<
"/boxfont /Times-Roman findfont fontheight scalefont def\n";
1159 t <<
"% ----- procedures -----\n";
1161 t <<
"/dotted { [1 4] 0 setdash } def\n";
1162 t <<
"/dashed { [5] 0 setdash } def\n";
1163 t <<
"/solid { [] 0 setdash } def\n";
1165 t <<
"/max % result = MAX(arg1,arg2)\n";
1167 t <<
" /a exch def\n";
1168 t <<
" /b exch def\n";
1169 t <<
" a b gt {a} {b} ifelse\n";
1172 t <<
"/xoffset % result = MAX(0,(scalefactor-(boxwidth*cols+distx*(cols-1)))/2)\n";
1174 t <<
" 0 scalefactor boxwidth cols mul distx cols 1 sub mul add sub 2 div max\n";
1177 t <<
"/cw % boxwidth = MAX(boxwidth, stringwidth(arg1))\n";
1179 t <<
" /str exch def\n";
1180 t <<
" /boxwidth boxwidth str stringwidth pop max def\n";
1183 t <<
"/box % draws a box with text 'arg1' at grid pos (arg2,arg3)\n";
1185 t <<
" 2 setlinewidth\n";
1187 t <<
" exch xspacing mul xoffset add\n";
1188 t <<
" exch yspacing mul\n";
1190 t <<
" boxwidth 0 rlineto \n";
1191 t <<
" 0 boxheight rlineto \n";
1192 t <<
" boxwidth neg 0 rlineto \n";
1193 t <<
" 0 boxheight neg rlineto \n";
1194 t <<
" closepath\n";
1195 t <<
" dup stringwidth pop neg boxwidth add 2 div\n";
1196 t <<
" boxheight fontheight 2 div sub 2 div\n";
1197 t <<
" rmoveto show stroke\n";
1203 t <<
" exch xspacing mul xoffset add boxwidth add\n";
1204 t <<
" exch yspacing mul\n";
1206 t <<
" 0 boxheight 4 div rlineto\n";
1207 t <<
" boxheight neg 4 div boxheight neg 4 div rlineto\n";
1208 t <<
" closepath\n";
1216 t <<
" 3 -8 rlineto\n";
1217 t <<
" -6 0 rlineto\n";
1218 t <<
" 3 8 rlineto\n";
1219 t <<
" closepath\n";
1224 t <<
"/out % draws an output connector for the block at (arg1,arg2)\n";
1227 t <<
" exch xspacing mul xoffset add boxwidth 2 div add\n";
1228 t <<
" exch yspacing mul boxheight add\n";
1229 t <<
" /y exch def\n";
1230 t <<
" /x exch def\n";
1231 t <<
" x y moveto\n";
1232 t <<
" 0 disty 2 div rlineto \n";
1234 t <<
" 1 eq { x y disty 2 div add arrow } if\n";
1237 t <<
"/in % draws an input connector for the block at (arg1,arg2)\n";
1240 t <<
" exch xspacing mul xoffset add boxwidth 2 div add\n";
1241 t <<
" exch yspacing mul disty 2 div sub\n";
1242 t <<
" /y exch def\n";
1243 t <<
" /x exch def\n";
1244 t <<
" x y moveto\n";
1245 t <<
" 0 disty 2 div rlineto\n";
1247 t <<
" 1 eq { x y disty 2 div add arrow } if\n";
1252 t <<
" exch xspacing mul xoffset add boxwidth 2 div add\n";
1253 t <<
" exch yspacing mul boxheight 2 div sub\n";
1254 t <<
" /y exch def\n";
1255 t <<
" /x exch def\n";
1257 t <<
" x y moveto\n";
1258 t <<
" boxwidth 2 div distx add 0 rlineto\n";
1261 t <<
" { newpath x boxwidth 2 div distx add add y moveto\n";
1262 t <<
" -8 3 rlineto\n";
1263 t <<
" 0 -6 rlineto\n";
1264 t <<
" 8 3 rlineto\n";
1265 t <<
" closepath\n";
1273 t <<
" /ye exch def\n";
1274 t <<
" /ys exch def\n";
1275 t <<
" /xs exch def\n";
1277 t <<
" xs xspacing mul xoffset add boxwidth 2 div add dup\n";
1278 t <<
" ys yspacing mul boxheight 2 div sub\n";
1280 t <<
" ye yspacing mul boxheight 2 div sub\n";
1285 t <<
"/conn % connections the blocks from col 'arg1' to 'arg2' of row 'arg3'\n";
1287 t <<
" /ys exch def\n";
1288 t <<
" /xe exch def\n";
1289 t <<
" /xs exch def\n";
1291 t <<
" xs xspacing mul xoffset add boxwidth 2 div add\n";
1292 t <<
" ys yspacing mul disty 2 div sub\n";
1294 t <<
" xspacing xe xs sub mul 0\n";
1299 t <<
"% ----- main ------\n";
1301 t <<
"boxfont setfont\n";
1302 t <<
"1 boundaspect scale\n";
1305 for (
const auto &dr :
p->base)
1308 for (
const auto &di : *dr)
1310 done=di->isInList();
1316 auto it =
p->super.begin();
1317 if (it!=
p->super.end()) ++it;
1318 for (;it!=
p->super.end();++it)
1320 const auto &dr = *it;
1322 for (
const auto &di : *dr)
1324 done=di->isInList();
1330 t <<
"/boxwidth boxwidth marginwidth 2 mul add def\n"
1331 <<
"/xspacing boxwidth distx add def\n"
1332 <<
"/yspacing boxheight disty add def\n"
1333 <<
"/scalefactor \n"
1334 <<
" boxwidth cols mul distx cols 1 sub mul add\n"
1335 <<
" boxheight rows mul disty rows 1 sub mul add boundaspect mul \n"
1337 <<
"boundx scalefactor div boundy scalefactor div scale\n";
1339 t <<
"\n% ----- classes -----\n\n";
1340 p->base.drawBoxes(t,
nullptr,
TRUE,
FALSE,baseRows,superRows,0,0);
1341 p->super.drawBoxes(t,
nullptr,
FALSE,
FALSE,baseRows,superRows,0,0);
1343 t <<
"\n% ----- relations -----\n\n";
1344 p->base.drawConnectors(t,
nullptr,
TRUE,
FALSE,baseRows,superRows,0,0);
1345 p->super.drawConnectors(t,
nullptr,
FALSE,
FALSE,baseRows,superRows,0,0);
1353 epstopdfArgs.
sprintf(
"\"%s.eps\" --outfile=\"%s.pdf\"",
1358 err(
"Problems running epstopdf. Check your TeX installation!\n");
1371 bool generateMap)
const
1373 uint32_t baseRows=
p->base.computeRows();
1374 uint32_t superRows=
p->super.computeRows();
1375 uint32_t rows=baseRows+superRows-1;
1377 uint32_t lb=0,ls=0,xb=0,xs=0;
1378 p->base.computeExtremes(&lb,&xb);
1379 p->super.computeExtremes(&ls,&xs);
1382 uint32_t maxXPos = std::max(xb,xs);
1383 uint32_t labelVertMargin = 6;
1384 uint32_t cellHeight = labelVertMargin*2+
fontHeight;
1389 Image image(imageWidth,imageHeight);
1391 p->base.drawBoxes(t,&image,
TRUE,
TRUE,baseRows,superRows,cellWidth,cellHeight,relPath,generateMap);
1392 p->super.drawBoxes(t,&image,
FALSE,
TRUE,baseRows,superRows,cellWidth,cellHeight,relPath,generateMap);
1393 p->base.drawConnectors(t,&image,
TRUE,
TRUE,baseRows,superRows,cellWidth,cellHeight);
1394 p->super.drawConnectors(t,&image,
FALSE,
TRUE,baseRows,superRows,cellWidth,cellHeight);
1396#define IMAGE_EXT ".png"
A abstract class representing of a compound symbol.
virtual bool isVisibleInHierarchy() const =0
the class is visible in a class diagram, or class hierarchy
virtual const BaseClassList & baseClasses() const =0
Returns the list of base classes from which this class directly inherits.
virtual const BaseClassList & subClasses() const =0
Returns the list of sub classes that directly derive from this class.
void writeImage(TextStream &t, const QCString &path, const QCString &relPath, const QCString &file, bool generateMap=true) const
ClassDiagram(const ClassDef *root)
void writeFigure(TextStream &t, const QCString &path, const QCString &file) const
std::unique_ptr< Private > p
virtual bool isLinkable() const =0
virtual QCString anchor() const =0
virtual QCString briefDescriptionAsTooltip() const =0
virtual QCString getReference() const =0
virtual QCString displayName(bool includeScope=TRUE) const =0
virtual QCString getOutputFileBase() const =0
Class representing a single node in the built-in class diagram.
Specifier virtualness() const
DiagramItem(DiagramItem *p, uint32_t number, const ClassDef *cd, Protection prot, Specifier virt, const QCString &ts)
void addChild(DiagramItem *di)
QCString fileName() const
DiagramItemList getChildren()
const ClassDef * m_classDef
uint32_t avgChildPos() const
DiagramItem * parentItem()
const ClassDef * getClassDef() const
uint32_t numChildren() const
Protection protection() const
void move(int dx, int dy)
DiagramItemList m_children
Class representing a row in the built-in class diagram.
uint32_t numItems() const
std::unique_ptr< DiagramItem > Ptr
DiagramItem * item(int index)
typename Vec::reverse_iterator reverse_iterator
DiagramRow(TreeDiagram *d, uint32_t l)
typename Vec::iterator iterator
void insertClass(DiagramItem *parent, const ClassDef *cd, bool doBases, Protection prot, Specifier virt, const QCString &ts)
reverse_iterator rbegin()
Class representing a directory in the file system.
bool remove(const std::string &path, bool acceptsAbsPath=true) const
static IndexList * indexList
helper class representing an iterator that can iterate forwards or backwards
C::reverse_iterator m_rit
DualDirIterator(C &container, bool fwd)
Class representing a string buffer optimized for growing.
void addStr(const QCString &s)
Class representing a bitmap image generated by doxygen.
void drawVertLine(uint32_t x, uint32_t ys, uint32_t ye, uint8_t colIndex, uint32_t mask)
void drawHorzLine(uint32_t y, uint32_t xs, uint32_t xe, uint8_t colIndex, uint32_t mask)
void drawVertArrow(uint32_t x, uint32_t ys, uint32_t ye, uint8_t colIndex, uint32_t mask)
void fillRect(uint32_t x, uint32_t y, uint32_t width, uint32_t height, uint8_t colIndex, uint32_t mask)
void drawHorzArrow(uint32_t y, uint32_t xs, uint32_t xe, uint8_t colIndex, uint32_t mask)
void drawRect(uint32_t x, uint32_t y, uint32_t width, uint32_t height, uint8_t colIndex, uint32_t mask)
void writeString(uint32_t x, uint32_t y, const QCString &s, uint8_t fg)
friend uint32_t stringLength(const QCString &s)
This is an alternative implementation of QCString.
size_t length() const
Returns the length of the string, not counting the 0-terminator.
bool endsWith(const char *s) const
bool isEmpty() const
Returns TRUE iff the string is empty.
const std::string & str() const
QCString & sprintf(const char *format,...)
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string.
QCString left(size_t len) const
Text streaming class that buffers data.
Class representing the tree layout for the built-in class diagram.
void drawConnectors(TextStream &t, Image *image, bool doBase, bool bitmap, uint32_t baseRows, uint32_t superRows, uint32_t cellWidth, uint32_t cellheight)
std::unique_ptr< DiagramRow > Ptr
bool layoutTree(DiagramItem *root, uint32_t row)
DiagramRow * row(int index)
void drawBoxes(TextStream &t, Image *image, bool doBase, bool bitmap, uint32_t baseRows, uint32_t superRows, uint32_t cellWidth, uint32_t cellHeight, QCString relPath="", bool generateMap=TRUE)
void moveChildren(DiagramItem *root, int dx)
typename Vec::iterator iterator
TreeDiagram(const ClassDef *root, bool doBases)
DiagramRow * addRow(uint32_t l)
void computeExtremes(uint32_t *labelWidth, uint32_t *xpos)
#define Config_getBool(name)
const uint32_t maxTreeWidth
const uint32_t labelHorMargin
static void writeMapArea(TextStream &t, const ClassDef *cd, QCString relPath, uint32_t x, uint32_t y, uint32_t w, uint32_t h)
const uint32_t labelHorSpacing
static void writeBitmapBox(DiagramItem *di, Image *image, uint32_t x, uint32_t y, uint32_t w, uint32_t h, bool firstRow, bool hasDocs, bool children=FALSE)
std::vector< DiagramItem * > DiagramItemList
const uint32_t gridHeight
const uint32_t fontHeight
static Protection getMinProtectionLevel(const DiagramItemList &dil)
static QCString convertToPSString(const QCString &s)
static void writeVectorBox(TextStream &t, DiagramItem *di, float x, float y, bool children=FALSE)
static uint32_t virtToMask(Specifier p)
static uint8_t protToColor(Protection p)
static QCString protToString(Protection p)
static uint32_t protToMask(Protection p)
const uint32_t labelVertSpacing
constexpr DocNodeVariant * parent(DocNodeVariant *n)
returns the parent node of a given node n or nullptr if the node has no parent.
std::ofstream openOutputStream(const QCString &name, bool append=false)
int system(const QCString &command, const QCString &args, bool commandHasConsole=true)
Portable versions of functions that are platform dependent.
const char * qPrint(const char *s)
Private(const ClassDef *root)
Protection
Protection level of members.
Specifier
Virtualness of a member.
QCString externalRef(const QCString &relPath, const QCString &ref, bool href)
QCString insertTemplateSpecifierInScope(const QCString &scope, const QCString &templ)
QCString convertToHtml(const QCString &s, bool keepEntities)
QCString stripScope(const QCString &name)
QCString convertToXML(const QCString &s, bool keepEntities)
QCString externalLinkTarget(const bool parent)
void addHtmlExtensionIfMissing(QCString &fName)
A bunch of utility functions.