Doxygen
Loading...
Searching...
No Matches
diagram.cpp
Go to the documentation of this file.
1/******************************************************************************
2 *
3 * Copyright (C) 1997-2020 by Dimitri van Heesch.
4 *
5 * Permission to use, copy, modify, and distribute this software and its
6 * documentation under the terms of the GNU General Public License is hereby
7 * granted. No representations are made about the suitability of this software
8 * for any purpose. It is provided "as is" without express or implied warranty.
9 * See the GNU General Public License for more details.
10 *
11 * Documents produced by Doxygen are derivative works derived from the
12 * input used in their production; they are not affected by this license.
13 *
14 */
15
16#include <stdio.h>
17#include <stdlib.h>
18#include <algorithm>
19
20#include "diagram.h"
21#include "image.h"
22#include "classdef.h"
23#include "config.h"
24#include "message.h"
25#include "util.h"
26#include "doxygen.h"
27#include "portable.h"
28#include "indexlist.h"
29#include "classlist.h"
30#include "textstream.h"
31#include "growbuf.h"
32#include "dir.h"
33
34//-----------------------------------------------------------------------------
35
36class TreeDiagram;
37class DiagramItem;
38using DiagramItemList = std::vector<DiagramItem*>;
39
40/** Class representing a single node in the built-in class diagram */
42{
43 public:
44 DiagramItem(DiagramItem *p,uint32_t number,const ClassDef *cd,
45 Protection prot,Specifier virt,const QCString &ts);
46 QCString label() const;
49 void move(int dx,int dy) { m_x=static_cast<uint32_t>(m_x+dx); m_y=static_cast<uint32_t>(m_y+dy); }
50 uint32_t xPos() const { return m_x; }
51 uint32_t yPos() const { return m_y; }
52 float xfPos() const { return static_cast<float>(m_x); }
53 float yfPos() const { return static_cast<float>(m_y); }
54 uint32_t avgChildPos() const;
55 uint32_t numChildren() const;
56 void addChild(DiagramItem *di);
57 uint32_t number() const { return m_num; }
58 Protection protection() const { return m_prot; }
59 Specifier virtualness() const { return m_virt; }
61 bool isInList() const { return m_inList; }
62 const ClassDef *getClassDef() const { return m_classDef; }
63 private:
66 uint32_t m_x = 0;
67 uint32_t m_y = 0;
68 uint32_t m_num;
72 bool m_inList = false;
74};
75
76/** Class representing a row in the built-in class diagram */
78{
79 public:
80 using Ptr = std::unique_ptr<DiagramItem>;
81 using Vec = std::vector<Ptr>;
82 using iterator = typename Vec::iterator;
83 using reverse_iterator = typename Vec::reverse_iterator;
84 DiagramRow(TreeDiagram *d,uint32_t l) : m_diagram(d), m_level(l) {}
85 void insertClass(DiagramItem *parent,const ClassDef *cd,bool doBases,
86 Protection prot,Specifier virt,const QCString &ts);
87
88 DiagramItem *item(int index) { return m_items.at(index).get(); }
89 uint32_t numItems() const { return static_cast<uint32_t>(m_items.size()); }
90 iterator begin() { return m_items.begin(); }
91 iterator end() { return m_items.end(); }
92 reverse_iterator rbegin() { return m_items.rbegin(); }
93 reverse_iterator rend() { return m_items.rend(); }
94 private:
96 uint32_t m_level;
98};
99
100/** Class representing the tree layout for the built-in class diagram. */
102{
103 public:
104 using Ptr = std::unique_ptr<DiagramRow>;
105 using Vec = std::vector<Ptr>;
106 using iterator = typename Vec::iterator;
107 TreeDiagram(const ClassDef *root,bool doBases);
108 void computeLayout();
109 uint32_t computeRows();
110 void moveChildren(DiagramItem *root,int dx);
111 void computeExtremes(uint32_t *labelWidth,uint32_t *xpos);
112 void drawBoxes(TextStream &t,Image *image,
113 bool doBase,bool bitmap,
114 uint32_t baseRows,uint32_t superRows,
115 uint32_t cellWidth,uint32_t cellHeight,
116 QCString relPath="",
117 bool generateMap=TRUE);
118 void drawConnectors(TextStream &t,Image *image,
119 bool doBase,bool bitmap,
120 uint32_t baseRows,uint32_t superRows,
121 uint32_t cellWidth,uint32_t cellheight);
122 DiagramRow *row(int index) { return m_rows.at(index).get(); }
123 uint32_t numRows() const { return static_cast<uint32_t>(m_rows.size()); }
124 DiagramRow *addRow(uint32_t l)
125 { m_rows.push_back(std::make_unique<DiagramRow>(this,l)); return m_rows.back().get(); }
126 iterator begin() { return m_rows.begin(); }
127 iterator end() { return m_rows.end(); }
128 private:
129 bool layoutTree(DiagramItem *root,uint32_t row);
131};
132
133
134
135//-----------------------------------------------------------------------------
136
137const uint32_t maxTreeWidth = 8;
138const uint32_t gridWidth = 100;
139const uint32_t gridHeight = 100;
140
141const uint32_t labelHorSpacing = 10; // horizontal distance between labels
142const uint32_t labelVertSpacing = 32; // vertical distance between labels
143const uint32_t labelHorMargin = 6; // horiz. spacing between label and box
144const uint32_t fontHeight = 12; // height of a character
145
146static uint32_t protToMask(Protection p)
147{
148 switch(p)
149 {
150 case Protection::Public: return 0xffffffff;
151 case Protection::Package: // package is not possible!
152 case Protection::Protected: return 0xcccccccc;
153 case Protection::Private: return 0xaaaaaaaa;
154 }
155 return 0;
156}
157
158static uint8_t protToColor(Protection p)
159{
160 switch(p)
161 {
162 case Protection::Public: return 6;
163 case Protection::Package: // package is not possible!
164 case Protection::Protected: return 5;
165 case Protection::Private: return 4;
166 }
167 return 0;
168}
169
171{
172 switch(p)
173 {
174 case Protection::Public: return "solid";
175 case Protection::Package: // package is not possible!
176 case Protection::Protected: return "dashed";
177 case Protection::Private: return "dotted";
178 }
179 return QCString();
180}
181
182static uint32_t virtToMask(Specifier p)
183{
184 switch(p)
185 {
186 case Specifier::Normal: return 0xffffffff;
187 case Specifier::Virtual: return 0xf0f0f0f0;
188 default: break;
189 }
190 return 0;
191}
192
194{
195 if (s.isEmpty()) return s;
196 GrowBuf growBuf;
197 const char *p=s.data();
198 char c=0;
199 while ((c=*p++))
200 {
201 switch (c)
202 {
203 case '(': growBuf.addStr("\\("); break;
204 case ')': growBuf.addStr("\\)"); break;
205 default: growBuf.addChar(c); break;
206 }
207 }
208 growBuf.addChar(0);
209 return growBuf.get();
210}
211
212// pre: dil is not empty
214{
215 auto it = dil.begin();
216 Protection result = Protection::Private;
217 if (it!=dil.end())
218 {
219 result=(*it)->protection();
220 for (++it;it!=dil.end();++it)
221 {
222 Protection p=(*it)->protection();
223 if (p!=result)
224 {
225 if (result==Protection::Protected && p==Protection::Public) result=p;
226 else if (result==Protection::Private) result=p;
227 }
228 }
229 }
230 return result;
231}
232
233static void writeBitmapBox(DiagramItem *di,Image *image,
234 uint32_t x,uint32_t y,uint32_t w,uint32_t h,bool firstRow,
235 bool hasDocs,bool children=FALSE)
236{
237 uint8_t colFill = hasDocs ? (firstRow ? 8 : 2) : 7;
238 uint8_t colBorder = (firstRow || !hasDocs) ? 1 : 3;
239 uint32_t l = Image::stringLength(di->label());
240 uint32_t mask=virtToMask(di->virtualness());
241 image->fillRect(x+1,y+1,w-2,h-2,colFill,mask);
242 image->drawRect(x,y,w,h,colBorder,mask);
243 image->writeString(x+(w-l)/2, y+(h-fontHeight)/2, di->label(),1);
244 if (children)
245 {
246 for (uint32_t i=0;i<5;i++)
247 {
248 image->drawHorzLine(y+h+i-6,x+w-2-i,x+w-2,firstRow?1:3,0xffffffff);
249 }
250 }
251}
252
254 float x,float y,bool children=FALSE)
255{
256 if (di->virtualness()==Specifier::Virtual) t << "dashed\n";
257 t << " (" << convertToPSString(di->label()) << ") " << x << " " << y << " box\n";
258 if (children) t << x << " " << y << " mark\n";
259 if (di->virtualness()==Specifier::Virtual) t << "solid\n";
260}
261
262static void writeMapArea(TextStream &t,const ClassDef *cd,QCString relPath,
263 uint32_t x,uint32_t y,uint32_t w,uint32_t h)
264{
265 if (cd->isLinkable())
266 {
267 QCString ref=cd->getReference();
268 t << "<area ";
269 if (!ref.isEmpty())
270 {
271 t << externalLinkTarget(true);
272 }
273 t << "href=\"";
274 t << externalRef(relPath,ref,TRUE);
275 QCString fn = cd->getOutputFileBase();
277 t << fn;
278 if (!cd->anchor().isEmpty())
279 {
280 t << "#" << cd->anchor();
281 }
282 t << "\" ";
283 QCString tooltip = cd->briefDescriptionAsTooltip();
284 if (!tooltip.isEmpty())
285 {
286 t << "title=\"" << convertToHtml(tooltip) << "\" ";
287 }
288 t << "alt=\"" << convertToXML(cd->displayName());
289 t << "\" shape=\"rect\" coords=\"" << x << "," << y << ",";
290 t << (x+w) << "," << (y+h) << "\"/>\n";
291 }
292}
293//-----------------------------------------------------------------------------
294
296 Protection pr,Specifier vi,const QCString &ts)
297 : m_parent(p), m_num(number), m_prot(pr), m_virt(vi), m_templSpec(ts), m_classDef(cd)
298{
299}
300
302{
303 QCString result;
304 if (!m_templSpec.isEmpty())
305 {
306 // we use classDef->name() here and not displayName() in order
307 // to get the name used in the inheritance relation.
308 QCString n = m_classDef->name();
309 if (n.endsWith("-p"))
310 {
311 n = n.left(n.length()-2);
312 }
314 }
315 else
316 {
317 result=m_classDef->displayName();
318 }
319 if (Config_getBool(HIDE_SCOPE_NAMES)) result=stripScope(result);
320 return result;
321}
322
324{
325 DiagramItem *di = nullptr;
326 size_t c=m_children.size();
327 if (c==0) // no children -> don't move
328 return xPos();
329 if ((di=m_children.front())->isInList()) // children should be in a list
330 return di->xPos();
331 if (c&1) // odd number of children -> get pos of middle child
332 return m_children.at(c/2)->xPos();
333 else // even number of children -> get middle of most middle children
334 return (m_children.at(c/2-1)->xPos()+m_children.at(c/2)->xPos())/2;
335}
336
338{
339 return static_cast<uint32_t>(m_children.size());
340}
341
343{
344 m_children.push_back(di);
345}
346
347//---------------------------------------------------------------------------
348
350 Protection prot,Specifier virt,const QCString &ts)
351{
352 auto di = std::make_unique<DiagramItem>(parent, m_diagram->row(m_level)->numItems(),
353 cd,prot,virt,ts);
354 DiagramItem *di_ptr = di.get();
355 if (parent) parent->addChild(di_ptr);
356 di->move(static_cast<int>(m_items.size()*gridWidth),static_cast<int>(m_level*gridHeight));
357 m_items.push_back(std::move(di));
358 int count=0;
359 for (const auto &bcd : doBases ? cd->baseClasses() : cd->subClasses())
360 {
361 /* there are base/sub classes */
362 ClassDef *ccd=bcd.classDef;
363 if (ccd && ccd->isVisibleInHierarchy()) count++;
364 }
365 if (count>0 && (prot!=Protection::Private || !doBases))
366 {
367 DiagramRow *row=nullptr;
368 if (m_diagram->numRows()<=m_level+1) /* add new row */
369 {
370 row=m_diagram->addRow(m_level+1);
371 }
372 else /* get next row */
373 {
374 row=m_diagram->row(m_level+1);
375 }
376 for (const auto &bcd : doBases ? cd->baseClasses() : cd->subClasses())
377 {
378 ClassDef *ccd=bcd.classDef;
379 if (ccd && ccd->isVisibleInHierarchy())
380 {
381 row->insertClass(di_ptr,ccd,doBases,bcd.prot,
382 doBases ? bcd.virt : Specifier::Normal,
383 doBases ? bcd.templSpecifiers : QCString());
384 }
385 }
386 }
387}
388
389//---------------------------------------------------------------------------
390
391TreeDiagram::TreeDiagram(const ClassDef *root,bool doBases)
392{
393 auto row = std::make_unique<DiagramRow>(this,0);
394 DiagramRow *row_ptr = row.get();
395 m_rows.push_back(std::move(row));
396 row_ptr->insertClass(nullptr,root,doBases,Protection::Public,Specifier::Normal,QCString());
397}
398
400{
401 for (const auto &di : root->getChildren())
402 {
403 di->move(dx,0);
404 moveChildren(di,dx);
405 }
406}
407
409{
410 bool moved=FALSE;
411 //printf("layoutTree(%s,%d)\n",qPrint(root->label()),r);
412
413 if (root->numChildren()>0)
414 {
415 auto children = root->getChildren();
416 uint32_t pPos=root->xPos();
417 uint32_t cPos=root->avgChildPos();
418 if (pPos>cPos) // move children
419 {
420 const auto &row=m_rows.at(r+1);
421 //printf("Moving children %d-%d in row %d\n",
422 // dil->getFirst()->number(),row->count()-1,r+1);
423 for (uint32_t k=children.front()->number();k<row->numItems();k++)
424 {
425 row->item(k)->move(static_cast<int>(pPos-cPos),0);
426 }
427 moved=TRUE;
428 }
429 else if (pPos<cPos) // move parent
430 {
431 const auto &row=m_rows.at(r);
432 //printf("Moving parents %d-%d in row %d\n",
433 // root->number(),row->count()-1,r);
434 for (uint32_t k=root->number();k<row->numItems();k++)
435 {
436 row->item(k)->move(static_cast<int>(cPos-pPos),0);
437 }
438 moved=TRUE;
439 }
440
441 // recurse to children
442 auto it = children.begin();
443 for (;it!=children.end() && !moved && !(*it)->isInList();++it)
444 {
445 moved = layoutTree(*it,r+1);
446 }
447 }
448 return moved;
449}
450
452{
453 auto it = m_rows.begin();
454 while (it!=m_rows.end() && (*it)->numItems()<maxTreeWidth) ++it;
455 if (it!=m_rows.end())
456 {
457 const auto &row = *it;
458 //printf("computeLayout() list row at %d\n",row->number());
459 DiagramItem *opi=nullptr;
460 int delta=0;
461 bool first=TRUE;
462 for (const auto &di : *row)
463 {
464 DiagramItem *pi=di->parentItem();
465 if (pi==opi && !first) { delta-=gridWidth; }
466 first = pi!=opi;
467 opi=pi;
468 di->move(delta,0); // collapse all items in the same
469 // list (except the first)
470 di->putInList();
471 }
472 }
473
474 // re-organize the diagram items
475 DiagramItem *root=m_rows.front()->item(0);
476 while (layoutTree(root,0)) { }
477
478 // move first items of the lists
479 if (it!=m_rows.end())
480 {
481 const auto &row = *it;
482 auto rit = row->begin();
483 while (rit!=row->end())
484 {
485 DiagramItem *pi=(*rit)->parentItem();
486 if (pi->numChildren()>1)
487 {
488 (*rit)->move(gridWidth,0);
489 while (rit!=row->end() && (*rit)->parentItem()==pi)
490 {
491 ++rit;
492 }
493 }
494 else
495 {
496 ++rit;
497 }
498 }
499 }
500}
501
503{
504 //printf("TreeDiagram::computeRows()=%d\n",count());
505 uint32_t count=0;
506 auto it = m_rows.begin();
507 while (it!=m_rows.end() && !(*it)->item(0)->isInList())
508 {
509 ++it;
510 ++count;
511 }
512
513 //printf("count=%d row=%p\n",count,row);
514 if (it!=m_rows.end())
515 {
516 const auto &row = *it;
517 uint32_t maxListLen=0;
518 uint32_t curListLen=0;
519 DiagramItem *opi=nullptr;
520 for (const auto &di : *row) // for each item in a row
521 {
522 if (di->parentItem()!=opi) curListLen=1; else curListLen++;
523 if (curListLen>maxListLen) maxListLen=curListLen;
524 opi=di->parentItem();
525 }
526 //printf("maxListLen=%d\n",maxListLen);
527 count+=maxListLen;
528 }
529 return count;
530}
531
532void TreeDiagram::computeExtremes(uint32_t *maxLabelLen,uint32_t *maxXPos)
533{
534 uint32_t ml=0,mx=0;
535 for (const auto &dr : m_rows) // for each row
536 {
537 bool done=FALSE;
538 for (const auto &di : *dr) // for each item in a row
539 {
540 if (di->isInList()) done=TRUE;
541 if (maxXPos) mx=std::max(mx,di->xPos());
542 if (maxLabelLen) ml=std::max(ml,Image::stringLength(di->label()));
543 }
544 if (done) break;
545 }
546 if (maxLabelLen) *maxLabelLen=ml;
547 if (maxXPos) *maxXPos=mx;
548}
549
550//! helper class representing an iterator that can iterate forwards or backwards
551template<class C,class I>
553{
554 public:
555 DualDirIterator(C &container,bool fwd)
556 : m_container(container), m_forward(fwd)
557 {
558 if (fwd) m_it = container.begin();
559 else m_rit = container.rbegin();
560 }
562 {
563 if (m_forward) ++m_it++; else ++m_rit;
564 }
566 {
567 return m_forward ? *m_it : *m_rit;
568 }
569
570 bool atEnd()
571 {
572 if (m_forward)
573 return m_it==m_container.end();
574 else
575 return m_rit==m_container.rend();
576 }
577
578 private:
581 typename C::iterator m_it;
582 typename C::reverse_iterator m_rit;
583};
584
586 bool doBase,bool bitmap,
587 uint32_t baseRows,uint32_t superRows,
588 uint32_t cellWidth,uint32_t cellHeight,
589 QCString relPath,
590 bool generateMap)
591{
592 auto it = m_rows.begin();
593 if (it!=m_rows.end() && !doBase) ++it;
594 bool firstRow = doBase;
595 bool done=FALSE;
596 float superRowsF = static_cast<float>(superRows);
597 for (;it!=m_rows.end() && !done;++it) // for each row
598 {
599 const auto &dr = *it;
600 uint32_t x=0,y=0;
601 float xf=0.0f,yf=0.0f;
602 DiagramItem *firstDi = dr->item(0);
603 if (firstDi->isInList()) // put boxes in a list
604 {
605 DiagramItem *opi=nullptr;
607 while (!dit.atEnd())
608 {
609 DiagramItem *di = (*dit).get();
610 if (di->parentItem()==opi)
611 {
612 if (bitmap)
613 {
614 if (doBase) y -= cellHeight+labelVertSpacing;
615 else y += cellHeight+labelVertSpacing;
616 }
617 else
618 {
619 if (doBase) yf += 1.0f;
620 else yf -= 1.0f;
621 }
622 }
623 else
624 {
625 if (bitmap)
626 {
627 x = di->xPos()*(cellWidth+labelHorSpacing)/gridWidth;
628 if (doBase)
629 {
630 y = image->height()-
631 superRows*cellHeight-
632 (superRows-1)*labelVertSpacing-
633 di->yPos()*(cellHeight+labelVertSpacing)/gridHeight;
634 }
635 else
636 {
637 y = (baseRows-1)*(cellHeight+labelVertSpacing)+
638 di->yPos()*(cellHeight+labelVertSpacing)/gridHeight;
639 }
640 }
641 else
642 {
643 xf = di->xfPos()/gridWidth;
644 if (doBase)
645 {
646 yf = di->yfPos()/gridHeight+superRowsF-1.0f;
647 }
648 else
649 {
650 yf = superRowsF-1.0f-di->yfPos()/gridHeight;
651 }
652 }
653 }
654 opi=di->parentItem();
655
656 if (bitmap)
657 {
658 bool hasDocs=di->getClassDef()->isLinkable();
659 writeBitmapBox(di,image,x,y,cellWidth,cellHeight,firstRow,
660 hasDocs,di->numChildren()>0);
661 if (!firstRow && generateMap)
662 writeMapArea(t,di->getClassDef(),relPath,x,y,cellWidth,cellHeight);
663 }
664 else
665 {
666 writeVectorBox(t,di,xf,yf,di->numChildren()>0);
667 }
668
669 ++dit;
670 }
671 done=TRUE;
672 }
673 else // draw a tree of boxes
674 {
675 for (const auto &di : *dr)
676 {
677 if (bitmap)
678 {
679 x = di->xPos()*(cellWidth+labelHorSpacing)/gridWidth;
680 if (doBase)
681 {
682 y = image->height()-
683 superRows*cellHeight-
684 (superRows-1)*labelVertSpacing-
685 di->yPos()*(cellHeight+labelVertSpacing)/gridHeight;
686 }
687 else
688 {
689 y = (baseRows-1)*(cellHeight+labelVertSpacing)+
690 di->yPos()*(cellHeight+labelVertSpacing)/gridHeight;
691 }
692 bool hasDocs=di->getClassDef()->isLinkable();
693 writeBitmapBox(di.get(),image,x,y,cellWidth,cellHeight,firstRow,hasDocs);
694 if (!firstRow && generateMap)
695 writeMapArea(t,di->getClassDef(),relPath,x,y,cellWidth,cellHeight);
696 }
697 else
698 {
699 xf=di->xfPos()/gridWidth;
700 if (doBase)
701 {
702 yf = di->yfPos()/gridHeight+superRowsF-1.0f;
703 }
704 else
705 {
706 yf = superRowsF-1.0f-di->yfPos()/gridHeight;
707 }
708 writeVectorBox(t,di.get(),xf,yf);
709 }
710 }
711 }
712 firstRow=FALSE;
713 }
714}
715
717 bool doBase,bool bitmap,
718 uint32_t baseRows,uint32_t superRows,
719 uint32_t cellWidth,uint32_t cellHeight)
720{
721 bool done=FALSE;
722 auto it = m_rows.begin();
723 float superRowsF = static_cast<float>(superRows);
724 for (;it!=m_rows.end() && !done;++it) // for each row
725 {
726 const auto &dr = *it;
727 DiagramItem *rootDi = dr->item(0);
728 if (rootDi->isInList()) // row consists of list connectors
729 {
730 uint32_t x=0,y=0,ys=0;
731 float xf=0.0f,yf=0.0f,ysf=0.0f;
732 auto rit = dr->begin();
733 while (rit!=dr->end())
734 {
735 DiagramItem *di=(*rit).get();
736 DiagramItem *pi=di->parentItem();
738 DiagramItem *last=dil.back();
739 if (di==last) // single child
740 {
741 if (bitmap) // draw pixels
742 {
743 x = di->xPos()*(cellWidth+labelHorSpacing)/gridWidth + cellWidth/2;
744 if (doBase) // base classes
745 {
746 y = image->height()-
747 (superRows-1)*(cellHeight+labelVertSpacing)-
748 di->yPos()*(cellHeight+labelVertSpacing)/gridHeight;
749 image->drawVertArrow(x,y,y+labelVertSpacing/2,
750 protToColor(di->protection()),
751 protToMask(di->protection()));
752 }
753 else // super classes
754 {
755 y = (baseRows-1)*(cellHeight+labelVertSpacing)-
757 di->yPos()*(cellHeight+labelVertSpacing)/gridHeight;
758 image->drawVertLine(x,y,y+labelVertSpacing/2,
759 protToColor(di->protection()),
760 protToMask(di->protection()));
761 }
762 }
763 else // draw vectors
764 {
765 t << protToString(di->protection()) << "\n";
766 if (doBase)
767 {
768 t << "1 " << (di->xfPos()/gridWidth) << " "
769 << (di->yfPos()/gridHeight+superRowsF-1.0f) << " in\n";
770 }
771 else
772 {
773 t << "0 " << (di->xfPos()/gridWidth) << " "
774 << (superRowsF-0.25f-di->yfPos()/gridHeight)
775 << " in\n";
776 }
777 }
778 }
779 else // multiple children, put them in a vertical list
780 {
781 if (bitmap)
782 {
783 x = di->parentItem()->xPos()*
784 (cellWidth+labelHorSpacing)/gridWidth+cellWidth/2;
785 if (doBase) // base classes
786 {
787 ys = image->height()-
788 (superRows-1)*(cellHeight+labelVertSpacing)-
789 di->yPos()*(cellHeight+labelVertSpacing)/gridHeight;
790 y = ys - cellHeight/2;
791 }
792 else // super classes
793 {
794 ys = (baseRows-1)*(cellHeight+labelVertSpacing)+
795 di->yPos()*(cellHeight+labelVertSpacing)/gridHeight;
796 y = ys + cellHeight/2;
797 }
798 }
799 else
800 {
801 xf = di->parentItem()->xfPos()/gridWidth;
802 if (doBase)
803 {
804 ysf = di->yfPos()/gridHeight+superRowsF-1.0f;
805 yf = ysf + 0.5f;
806 }
807 else
808 {
809 ysf = superRowsF-0.25f-di->yfPos()/gridHeight;
810 yf = ysf - 0.25f;
811 }
812 }
813 while (di!=last) // more children to add
814 {
815 if (bitmap)
816 {
817 if (doBase) // base classes
818 {
819 image->drawHorzArrow(y,x,x+cellWidth/2+labelHorSpacing,
820 protToColor(di->protection()),
821 protToMask(di->protection()));
822 y -= cellHeight+labelVertSpacing;
823 }
824 else // super classes
825 {
826 image->drawHorzLine(y,x,x+cellWidth/2+labelHorSpacing,
827 protToColor(di->protection()),
828 protToMask(di->protection()));
829 y += cellHeight+labelVertSpacing;
830 }
831 }
832 else
833 {
834 t << protToString(di->protection()) << "\n";
835 if (doBase)
836 {
837 t << "1 " << xf << " " << yf << " hedge\n";
838 yf += 1.0f;
839 }
840 else
841 {
842 t << "0 " << xf << " " << yf << " hedge\n";
843 yf -= 1.0f;
844 }
845 }
846 ++rit;
847 if (rit!=dr->end()) di = (*rit).get(); else di=nullptr;
848 }
849 // add last horizontal line and a vertical connection line
850 if (bitmap)
851 {
852 if (doBase) // base classes
853 {
854 image->drawHorzArrow(y,x,x+cellWidth/2+labelHorSpacing,
855 protToColor(di->protection()),
856 protToMask(di->protection()));
857 image->drawVertLine(x,y,ys+labelVertSpacing/2,
860 }
861 else // super classes
862 {
863 image->drawHorzLine(y,x,x+cellWidth/2+labelHorSpacing,
864 protToColor(di->protection()),
865 protToMask(di->protection()));
866 image->drawVertLine(x,ys-labelVertSpacing/2,y,
869 }
870 }
871 else
872 {
873 t << protToString(di->protection()) << "\n";
874 if (doBase)
875 {
876 t << "1 " << xf << " " << yf << " hedge\n";
877 }
878 else
879 {
880 t << "0 " << xf << " " << yf << " hedge\n";
881 }
882 t << protToString(getMinProtectionLevel(dil)) << "\n";
883 if (doBase)
884 {
885 t << xf << " " << ysf << " " << yf << " vedge\n";
886 }
887 else
888 {
889 t << xf << " " << (ysf + 0.25f) << " " << yf << " vedge\n";
890 }
891 }
892 }
893 if (rit!=dr->end()) ++rit;
894 }
895 done=TRUE; // the tree is drawn now
896 }
897 else // normal tree connector
898 {
899 for (const auto &di : *dr)
900 {
901 uint32_t x=0,y=0;
902 DiagramItemList dil = di->getChildren();
903 DiagramItem *parent = di->parentItem();
904 if (parent) // item has a parent -> connect to it
905 {
906 if (bitmap) // draw pixels
907 {
908 x = di->xPos()*(cellWidth+labelHorSpacing)/gridWidth + cellWidth/2;
909 if (doBase) // base classes
910 {
911 y = image->height()-
912 (superRows-1)*(cellHeight+labelVertSpacing)-
913 di->yPos()*(cellHeight+labelVertSpacing)/gridHeight;
914 /* write input line */
915 image->drawVertArrow(x,y,y+labelVertSpacing/2,
916 protToColor(di->protection()),
917 protToMask(di->protection()));
918 }
919 else // super classes
920 {
921 y = (baseRows-1)*(cellHeight+labelVertSpacing)-
923 di->yPos()*(cellHeight+labelVertSpacing)/gridHeight;
924 /* write output line */
925 image->drawVertLine(x,y,y+labelVertSpacing/2,
926 protToColor(di->protection()),
927 protToMask(di->protection()));
928 }
929 }
930 else // draw pixels
931 {
932 t << protToString(di->protection()) << "\n";
933 if (doBase)
934 {
935 t << "1 " << di->xfPos()/gridWidth << " "
936 << (di->yfPos()/gridHeight+superRowsF-1.0f) << " in\n";
937 }
938 else
939 {
940 t << "0 " << di->xfPos()/gridWidth << " "
941 << (superRowsF-0.25f-di->yfPos()/gridHeight)
942 << " in\n";
943 }
944 }
945 }
946 if (!dil.empty())
947 {
949 uint32_t mask=protToMask(p);
950 uint8_t col=protToColor(p);
951 if (bitmap)
952 {
953 x = di->xPos()*(cellWidth+labelHorSpacing)/gridWidth + cellWidth/2;
954 if (doBase) // base classes
955 {
956 y = image->height()-
957 (superRows-1)*(cellHeight+labelVertSpacing)-
958 cellHeight-labelVertSpacing/2-
959 di->yPos()*(cellHeight+labelVertSpacing)/gridHeight;
960 image->drawVertLine(x,y,y+labelVertSpacing/2-1,col,mask);
961 }
962 else // super classes
963 {
964 y = (baseRows-1)*(cellHeight+labelVertSpacing)+
965 cellHeight+
966 di->yPos()*(cellHeight+labelVertSpacing)/gridHeight;
967 image->drawVertArrow(x,y,y+labelVertSpacing/2-1,col,mask);
968 }
969 }
970 else
971 {
972 t << protToString(p) << "\n";
973 if (doBase)
974 {
975 t << "0 " << di->xfPos()/gridWidth << " "
976 << (di->yfPos()/gridHeight+superRowsF-1.0f) << " out\n";
977 }
978 else
979 {
980 t << "1 " << di->xfPos()/gridWidth << " "
981 << (superRowsF-1.75f-di->yfPos()/gridHeight)
982 << " out\n";
983 }
984 }
985 /* write input line */
986 DiagramItem *first = dil.front();
987 DiagramItem *last = dil.back();
988 if (first!=last && !first->isInList()) /* connect with all base classes */
989 {
990 if (bitmap)
991 {
992 uint32_t xs = first->xPos()*(cellWidth+labelHorSpacing)/gridWidth
993 + cellWidth/2;
994 uint32_t xe = last->xPos()*(cellWidth+labelHorSpacing)/gridWidth
995 + cellWidth/2;
996 if (doBase) // base classes
997 {
998 image->drawHorzLine(y,xs,xe,col,mask);
999 }
1000 else // super classes
1001 {
1002 image->drawHorzLine(y+labelVertSpacing/2,xs,xe,col,mask);
1003 }
1004 }
1005 else
1006 {
1007 t << protToString(p) << "\n";
1008 if (doBase)
1009 {
1010 t << first->xfPos()/gridWidth << " "
1011 << last->xfPos()/gridWidth << " "
1012 << (first->yfPos()/gridHeight+superRowsF-1.0f)
1013 << " conn\n";
1014 }
1015 else
1016 {
1017 t << first->xfPos()/gridWidth << " "
1018 << last->xfPos()/gridWidth << " "
1019 << (superRowsF-first->yfPos()/gridHeight)
1020 << " conn\n";
1021 }
1022 }
1023 }
1024 }
1025 }
1026 }
1027 }
1028}
1029
1030//-----------------------------------------------------------------
1031
1033{
1034 Private(const ClassDef *root) : base(root,true), super(root,false) {}
1037};
1038
1039//-----------------------------------------------------------------
1040
1041
1042ClassDiagram::ClassDiagram(const ClassDef *root) : p(std::make_unique<Private>(root))
1043{
1044 p->base.computeLayout();
1045 p->super.computeLayout();
1046 DiagramItem *baseItem = p->base.row(0)->item(0);
1047 DiagramItem *superItem = p->super.row(0)->item(0);
1048 uint32_t xbase = baseItem->xPos();
1049 uint32_t xsuper = superItem->xPos();
1050 if (xbase>xsuper)
1051 {
1052 int dist=static_cast<int>(xbase-xsuper);
1053 superItem->move(dist,0);
1054 p->super.moveChildren(superItem,dist);
1055 }
1056 else if (xbase<xsuper)
1057 {
1058 int dist=static_cast<int>(xsuper-xbase);
1059 baseItem->move(dist,0);
1060 p->base.moveChildren(baseItem,dist);
1061 }
1062}
1063
1064ClassDiagram::~ClassDiagram() = default;
1065
1067 const QCString &fileName) const
1068{
1069 uint32_t baseRows=p->base.computeRows();
1070 uint32_t superRows=p->super.computeRows();
1071 uint32_t baseMaxX = 0, baseMaxLabelWidth = 0, superMaxX = 0, superMaxLabelWidth = 0;
1072 p->base.computeExtremes(&baseMaxLabelWidth,&baseMaxX);
1073 p->super.computeExtremes(&superMaxLabelWidth,&superMaxX);
1074
1075 uint32_t rows=std::max(1u,baseRows+superRows-1);
1076 uint32_t cols=(std::max(baseMaxX,superMaxX)+gridWidth*2-1)/gridWidth;
1077
1078 // Estimate the image aspect width and height in pixels.
1079 float estHeight = static_cast<float>(rows)*40.0f;
1080 float estWidth = static_cast<float>(cols)*(20+static_cast<float>(std::max(baseMaxLabelWidth,superMaxLabelWidth)));
1081 //printf("Estimated size %d x %d\n",estWidth,estHeight);
1082
1083 const float pageWidth = 14.0f; // estimated page width in cm.
1084 // Somewhat lower to deal with estimation
1085 // errors.
1086
1087 // compute the image height in centimeters based on the estimates
1088 float realHeight = static_cast<float>(std::min(rows,12u)); // real height in cm
1089 float realWidth = realHeight * estWidth/estHeight;
1090 if (realWidth>pageWidth) // assume that the page width is about 15 cm
1091 {
1092 realHeight*=pageWidth/realWidth;
1093 }
1094
1095 //output << "}\n";
1096 output << "\\begin{figure}[H]\n"
1097 "\\begin{center}\n"
1098 "\\leavevmode\n";
1099 output << "\\includegraphics[height=" << realHeight << "cm]{"
1100 << fileName << "}\n";
1101 output << "\\end{center}\n"
1102 "\\end{figure}\n";
1103
1104 //printf("writeFigure rows=%d cols=%d\n",rows,cols);
1105
1106 QCString epsBaseName=QCString(path)+"/"+fileName;
1107 QCString epsName=epsBaseName+".eps";
1108 std::ofstream f = Portable::openOutputStream(epsName);
1109 if (!f.is_open())
1110 {
1111 term("Could not open file {} for writing\n",epsName);
1112 }
1113 else
1114 {
1115 TextStream t(&f);
1116
1117 //printf("writeEPS() rows=%d cols=%d\n",rows,cols);
1118
1119 // generate EPS header and postscript variables and procedures
1120
1121 t << "%!PS-Adobe-2.0 EPSF-2.0\n";
1122 t << "%%Title: ClassName\n";
1123 t << "%%Creator: Doxygen\n";
1124 t << "%%CreationDate: Time\n";
1125 t << "%%For: \n";
1126 t << "%Magnification: 1.00\n";
1127 t << "%%Orientation: Portrait\n";
1128 t << "%%BoundingBox: 0 0 500 " << estHeight*500.0f/estWidth << "\n";
1129 t << "%%Pages: 0\n";
1130 t << "%%BeginSetup\n";
1131 t << "%%EndSetup\n";
1132 t << "%%EndComments\n";
1133 t << "\n";
1134 t << "% ----- variables -----\n";
1135 t << "\n";
1136 t << "/boxwidth 0 def\n";
1137 t << "/boxheight 40 def\n";
1138 t << "/fontheight 24 def\n";
1139 t << "/marginwidth 10 def\n";
1140 t << "/distx 20 def\n";
1141 t << "/disty 40 def\n";
1142 t << "/boundaspect " << estWidth/estHeight << " def % aspect ratio of the BoundingBox (width/height)\n";
1143 t << "/boundx 500 def\n";
1144 t << "/boundy boundx boundaspect div def\n";
1145 t << "/xspacing 0 def\n";
1146 t << "/yspacing 0 def\n";
1147 t << "/rows " << rows << " def\n";
1148 t << "/cols " << cols << " def\n";
1149 t << "/scalefactor 0 def\n";
1150 t << "/boxfont /Times-Roman findfont fontheight scalefont def\n";
1151 t << "\n";
1152 t << "% ----- procedures -----\n";
1153 t << "\n";
1154 t << "/dotted { [1 4] 0 setdash } def\n";
1155 t << "/dashed { [5] 0 setdash } def\n";
1156 t << "/solid { [] 0 setdash } def\n";
1157 t << "\n";
1158 t << "/max % result = MAX(arg1,arg2)\n";
1159 t << "{\n";
1160 t << " /a exch def\n";
1161 t << " /b exch def\n";
1162 t << " a b gt {a} {b} ifelse\n";
1163 t << "} def\n";
1164 t << "\n";
1165 t << "/xoffset % result = MAX(0,(scalefactor-(boxwidth*cols+distx*(cols-1)))/2)\n";
1166 t << "{\n";
1167 t << " 0 scalefactor boxwidth cols mul distx cols 1 sub mul add sub 2 div max\n";
1168 t << "} def\n";
1169 t << "\n";
1170 t << "/cw % boxwidth = MAX(boxwidth, stringwidth(arg1))\n";
1171 t << "{\n";
1172 t << " /str exch def\n";
1173 t << " /boxwidth boxwidth str stringwidth pop max def\n";
1174 t << "} def\n";
1175 t << "\n";
1176 t << "/box % draws a box with text 'arg1' at grid pos (arg2,arg3)\n";
1177 t << "{ gsave\n";
1178 t << " 2 setlinewidth\n";
1179 t << " newpath\n";
1180 t << " exch xspacing mul xoffset add\n";
1181 t << " exch yspacing mul\n";
1182 t << " moveto\n";
1183 t << " boxwidth 0 rlineto \n";
1184 t << " 0 boxheight rlineto \n";
1185 t << " boxwidth neg 0 rlineto \n";
1186 t << " 0 boxheight neg rlineto \n";
1187 t << " closepath\n";
1188 t << " dup stringwidth pop neg boxwidth add 2 div\n";
1189 t << " boxheight fontheight 2 div sub 2 div\n";
1190 t << " rmoveto show stroke\n";
1191 t << " grestore\n";
1192 t << "} def \n";
1193 t << "\n";
1194 t << "/mark\n";
1195 t << "{ newpath\n";
1196 t << " exch xspacing mul xoffset add boxwidth add\n";
1197 t << " exch yspacing mul\n";
1198 t << " moveto\n";
1199 t << " 0 boxheight 4 div rlineto\n";
1200 t << " boxheight neg 4 div boxheight neg 4 div rlineto\n";
1201 t << " closepath\n";
1202 t << " eofill\n";
1203 t << " stroke\n";
1204 t << "} def\n";
1205 t << "\n";
1206 t << "/arrow\n";
1207 t << "{ newpath\n";
1208 t << " moveto\n";
1209 t << " 3 -8 rlineto\n";
1210 t << " -6 0 rlineto\n";
1211 t << " 3 8 rlineto\n";
1212 t << " closepath\n";
1213 t << " eofill\n";
1214 t << " stroke\n";
1215 t << "} def\n";
1216 t << "\n";
1217 t << "/out % draws an output connector for the block at (arg1,arg2)\n";
1218 t << "{\n";
1219 t << " newpath\n";
1220 t << " exch xspacing mul xoffset add boxwidth 2 div add\n";
1221 t << " exch yspacing mul boxheight add\n";
1222 t << " /y exch def\n";
1223 t << " /x exch def\n";
1224 t << " x y moveto\n";
1225 t << " 0 disty 2 div rlineto \n";
1226 t << " stroke\n";
1227 t << " 1 eq { x y disty 2 div add arrow } if\n";
1228 t << "} def\n";
1229 t << "\n";
1230 t << "/in % draws an input connector for the block at (arg1,arg2)\n";
1231 t << "{\n";
1232 t << " newpath\n";
1233 t << " exch xspacing mul xoffset add boxwidth 2 div add\n";
1234 t << " exch yspacing mul disty 2 div sub\n";
1235 t << " /y exch def\n";
1236 t << " /x exch def\n";
1237 t << " x y moveto\n";
1238 t << " 0 disty 2 div rlineto\n";
1239 t << " stroke\n";
1240 t << " 1 eq { x y disty 2 div add arrow } if\n";
1241 t << "} def\n";
1242 t << "\n";
1243 t << "/hedge\n";
1244 t << "{\n";
1245 t << " exch xspacing mul xoffset add boxwidth 2 div add\n";
1246 t << " exch yspacing mul boxheight 2 div sub\n";
1247 t << " /y exch def\n";
1248 t << " /x exch def\n";
1249 t << " newpath\n";
1250 t << " x y moveto\n";
1251 t << " boxwidth 2 div distx add 0 rlineto\n";
1252 t << " stroke\n";
1253 t << " 1 eq\n";
1254 t << " { newpath x boxwidth 2 div distx add add y moveto\n";
1255 t << " -8 3 rlineto\n";
1256 t << " 0 -6 rlineto\n";
1257 t << " 8 3 rlineto\n";
1258 t << " closepath\n";
1259 t << " eofill\n";
1260 t << " stroke\n";
1261 t << " } if\n";
1262 t << "} def\n";
1263 t << "\n";
1264 t << "/vedge\n";
1265 t << "{\n";
1266 t << " /ye exch def\n";
1267 t << " /ys exch def\n";
1268 t << " /xs exch def\n";
1269 t << " newpath\n";
1270 t << " xs xspacing mul xoffset add boxwidth 2 div add dup\n";
1271 t << " ys yspacing mul boxheight 2 div sub\n";
1272 t << " moveto\n";
1273 t << " ye yspacing mul boxheight 2 div sub\n";
1274 t << " lineto\n";
1275 t << " stroke\n";
1276 t << "} def\n";
1277 t << "\n";
1278 t << "/conn % connections the blocks from col 'arg1' to 'arg2' of row 'arg3'\n";
1279 t << "{\n";
1280 t << " /ys exch def\n";
1281 t << " /xe exch def\n";
1282 t << " /xs exch def\n";
1283 t << " newpath\n";
1284 t << " xs xspacing mul xoffset add boxwidth 2 div add\n";
1285 t << " ys yspacing mul disty 2 div sub\n";
1286 t << " moveto\n";
1287 t << " xspacing xe xs sub mul 0\n";
1288 t << " rlineto\n";
1289 t << " stroke\n";
1290 t << "} def\n";
1291 t << "\n";
1292 t << "% ----- main ------\n";
1293 t << "\n";
1294 t << "boxfont setfont\n";
1295 t << "1 boundaspect scale\n";
1296
1297
1298 for (const auto &dr : p->base)
1299 {
1300 bool done=FALSE;
1301 for (const auto &di : *dr)
1302 {
1303 done=di->isInList();
1304 t << "(" << convertToPSString(di->label()) << ") cw\n";
1305 }
1306 if (done) break;
1307 }
1308
1309 auto it = p->super.begin();
1310 if (it!=p->super.end()) ++it;
1311 for (;it!=p->super.end();++it)
1312 {
1313 const auto &dr = *it;
1314 bool done=FALSE;
1315 for (const auto &di : *dr)
1316 {
1317 done=di->isInList();
1318 t << "(" << convertToPSString(di->label()) << ") cw\n";
1319 }
1320 if (done) break;
1321 }
1322
1323 t << "/boxwidth boxwidth marginwidth 2 mul add def\n"
1324 << "/xspacing boxwidth distx add def\n"
1325 << "/yspacing boxheight disty add def\n"
1326 << "/scalefactor \n"
1327 << " boxwidth cols mul distx cols 1 sub mul add\n"
1328 << " boxheight rows mul disty rows 1 sub mul add boundaspect mul \n"
1329 << " max def\n"
1330 << "boundx scalefactor div boundy scalefactor div scale\n";
1331
1332 t << "\n% ----- classes -----\n\n";
1333 p->base.drawBoxes(t,nullptr,TRUE,FALSE,baseRows,superRows,0,0);
1334 p->super.drawBoxes(t,nullptr,FALSE,FALSE,baseRows,superRows,0,0);
1335
1336 t << "\n% ----- relations -----\n\n";
1337 p->base.drawConnectors(t,nullptr,TRUE,FALSE,baseRows,superRows,0,0);
1338 p->super.drawConnectors(t,nullptr,FALSE,FALSE,baseRows,superRows,0,0);
1339
1340 }
1341 f.close();
1342
1343 if (Config_getBool(USE_PDFLATEX))
1344 {
1345 QCString epstopdfArgs(4096, QCString::ExplicitSize);
1346 epstopdfArgs.sprintf("\"%s.eps\" --outfile=\"%s.pdf\"",
1347 qPrint(epsBaseName),qPrint(epsBaseName));
1348 //printf("Converting eps using '%s'\n",qPrint(epstopdfArgs));
1349 if (Portable::system("epstopdf",epstopdfArgs)!=0)
1350 {
1351 err("Problems running epstopdf. Check your TeX installation!\n");
1352 return;
1353 }
1354 else
1355 {
1356 Dir().remove(epsBaseName.str()+".eps");
1357 }
1358 }
1359}
1360
1361
1363 const QCString &relPath,const QCString &fileName,
1364 bool generateMap) const
1365{
1366 uint32_t baseRows=p->base.computeRows();
1367 uint32_t superRows=p->super.computeRows();
1368 uint32_t rows=baseRows+superRows-1;
1369
1370 uint32_t lb=0,ls=0,xb=0,xs=0;
1371 p->base.computeExtremes(&lb,&xb);
1372 p->super.computeExtremes(&ls,&xs);
1373
1374 uint32_t cellWidth = std::max(lb,ls)+labelHorMargin*2;
1375 uint32_t maxXPos = std::max(xb,xs);
1376 uint32_t labelVertMargin = 6; //std::max(6,(cellWidth-fontHeight)/6); // aspect at least 1:3
1377 uint32_t cellHeight = labelVertMargin*2+fontHeight;
1378 uint32_t imageWidth = (maxXPos+gridWidth)*cellWidth/gridWidth+
1379 (maxXPos*labelHorSpacing)/gridWidth;
1380 uint32_t imageHeight = rows*cellHeight+(rows-1)*labelVertSpacing;
1381
1382 Image image(imageWidth,imageHeight);
1383
1384 p->base.drawBoxes(t,&image,TRUE,TRUE,baseRows,superRows,cellWidth,cellHeight,relPath,generateMap);
1385 p->super.drawBoxes(t,&image,FALSE,TRUE,baseRows,superRows,cellWidth,cellHeight,relPath,generateMap);
1386 p->base.drawConnectors(t,&image,TRUE,TRUE,baseRows,superRows,cellWidth,cellHeight);
1387 p->super.drawConnectors(t,&image,FALSE,TRUE,baseRows,superRows,cellWidth,cellHeight);
1388
1389#define IMAGE_EXT ".png"
1390 image.save(QCString(path)+"/"+fileName+IMAGE_EXT);
1391 Doxygen::indexList->addImageFile(QCString(fileName)+IMAGE_EXT);
1392}
1393
A abstract class representing of a compound symbol.
Definition classdef.h:104
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
Definition diagram.cpp:1362
ClassDiagram(const ClassDef *root)
Definition diagram.cpp:1042
void writeFigure(TextStream &t, const QCString &path, const QCString &file) const
Definition diagram.cpp:1066
std::unique_ptr< Private > p
Definition diagram.h:42
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.
Definition diagram.cpp:42
uint32_t m_x
Definition diagram.cpp:66
Specifier virtualness() const
Definition diagram.cpp:59
DiagramItem(DiagramItem *p, uint32_t number, const ClassDef *cd, Protection prot, Specifier virt, const QCString &ts)
Definition diagram.cpp:295
void addChild(DiagramItem *di)
Definition diagram.cpp:342
DiagramItemList getChildren()
Definition diagram.cpp:48
Specifier m_virt
Definition diagram.cpp:70
uint32_t m_num
Definition diagram.cpp:68
uint32_t number() const
Definition diagram.cpp:57
const ClassDef * m_classDef
Definition diagram.cpp:73
uint32_t avgChildPos() const
Definition diagram.cpp:323
DiagramItem * parentItem()
Definition diagram.cpp:47
const ClassDef * getClassDef() const
Definition diagram.cpp:62
uint32_t m_y
Definition diagram.cpp:67
uint32_t numChildren() const
Definition diagram.cpp:337
DiagramItem * m_parent
Definition diagram.cpp:65
Protection protection() const
Definition diagram.cpp:58
QCString label() const
Definition diagram.cpp:301
float xfPos() const
Definition diagram.cpp:52
bool isInList() const
Definition diagram.cpp:61
void move(int dx, int dy)
Definition diagram.cpp:49
void putInList()
Definition diagram.cpp:60
QCString m_templSpec
Definition diagram.cpp:71
bool m_inList
Definition diagram.cpp:72
Protection m_prot
Definition diagram.cpp:69
uint32_t xPos() const
Definition diagram.cpp:50
DiagramItemList m_children
Definition diagram.cpp:64
float yfPos() const
Definition diagram.cpp:53
uint32_t yPos() const
Definition diagram.cpp:51
Class representing a row in the built-in class diagram.
Definition diagram.cpp:78
TreeDiagram * m_diagram
Definition diagram.cpp:95
uint32_t numItems() const
Definition diagram.cpp:89
std::vector< Ptr > Vec
Definition diagram.cpp:81
std::unique_ptr< DiagramItem > Ptr
Definition diagram.cpp:80
DiagramItem * item(int index)
Definition diagram.cpp:88
typename Vec::reverse_iterator reverse_iterator
Definition diagram.cpp:83
Vec m_items
Definition diagram.cpp:97
DiagramRow(TreeDiagram *d, uint32_t l)
Definition diagram.cpp:84
typename Vec::iterator iterator
Definition diagram.cpp:82
iterator begin()
Definition diagram.cpp:90
iterator end()
Definition diagram.cpp:91
void insertClass(DiagramItem *parent, const ClassDef *cd, bool doBases, Protection prot, Specifier virt, const QCString &ts)
Definition diagram.cpp:349
reverse_iterator rend()
Definition diagram.cpp:93
reverse_iterator rbegin()
Definition diagram.cpp:92
uint32_t m_level
Definition diagram.cpp:96
Class representing a directory in the file system.
Definition dir.h:75
bool remove(const std::string &path, bool acceptsAbsPath=true) const
Definition dir.cpp:314
static IndexList * indexList
Definition doxygen.h:134
helper class representing an iterator that can iterate forwards or backwards
Definition diagram.cpp:553
void operator++()
Definition diagram.cpp:561
C::reverse_iterator m_rit
Definition diagram.cpp:582
DualDirIterator(C &container, bool fwd)
Definition diagram.cpp:555
C::iterator m_it
Definition diagram.cpp:581
Class representing a string buffer optimized for growing.
Definition growbuf.h:28
void addChar(char c)
Definition growbuf.h:69
void addStr(const QCString &s)
Definition growbuf.h:72
char * get()
Definition growbuf.h:114
Class representing a bitmap image generated by doxygen.
Definition image.h:27
void drawVertLine(uint32_t x, uint32_t ys, uint32_t ye, uint8_t colIndex, uint32_t mask)
Definition image.cpp:309
void drawHorzLine(uint32_t y, uint32_t xs, uint32_t xe, uint8_t colIndex, uint32_t mask)
Definition image.cpp:289
void drawVertArrow(uint32_t x, uint32_t ys, uint32_t ye, uint8_t colIndex, uint32_t mask)
Definition image.cpp:318
void fillRect(uint32_t x, uint32_t y, uint32_t width, uint32_t height, uint8_t colIndex, uint32_t mask)
Definition image.cpp:336
uint32_t height() const
Definition image.cpp:209
void drawHorzArrow(uint32_t y, uint32_t xs, uint32_t xe, uint8_t colIndex, uint32_t mask)
Definition image.cpp:299
void drawRect(uint32_t x, uint32_t y, uint32_t width, uint32_t height, uint8_t colIndex, uint32_t mask)
Definition image.cpp:328
void writeString(uint32_t x, uint32_t y, const QCString &s, uint8_t fg)
Definition image.cpp:263
friend uint32_t stringLength(const QCString &s)
Definition image.cpp:277
This is an alternative implementation of QCString.
Definition qcstring.h:101
size_t length() const
Returns the length of the string, not counting the 0-terminator.
Definition qcstring.h:166
bool endsWith(const char *s) const
Definition qcstring.h:524
bool isEmpty() const
Returns TRUE iff the string is empty.
Definition qcstring.h:163
const std::string & str() const
Definition qcstring.h:552
QCString & sprintf(const char *format,...)
Definition qcstring.cpp:29
@ ExplicitSize
Definition qcstring.h:146
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string.
Definition qcstring.h:172
QCString left(size_t len) const
Definition qcstring.h:229
Text streaming class that buffers data.
Definition textstream.h:36
Class representing the tree layout for the built-in class diagram.
Definition diagram.cpp:102
void drawConnectors(TextStream &t, Image *image, bool doBase, bool bitmap, uint32_t baseRows, uint32_t superRows, uint32_t cellWidth, uint32_t cellheight)
Definition diagram.cpp:716
std::unique_ptr< DiagramRow > Ptr
Definition diagram.cpp:104
iterator end()
Definition diagram.cpp:127
bool layoutTree(DiagramItem *root, uint32_t row)
Definition diagram.cpp:408
DiagramRow * row(int index)
Definition diagram.cpp:122
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)
Definition diagram.cpp:585
void moveChildren(DiagramItem *root, int dx)
Definition diagram.cpp:399
typename Vec::iterator iterator
Definition diagram.cpp:106
void computeLayout()
Definition diagram.cpp:451
uint32_t computeRows()
Definition diagram.cpp:502
TreeDiagram(const ClassDef *root, bool doBases)
Definition diagram.cpp:391
DiagramRow * addRow(uint32_t l)
Definition diagram.cpp:124
void computeExtremes(uint32_t *labelWidth, uint32_t *xpos)
Definition diagram.cpp:532
std::vector< Ptr > Vec
Definition diagram.cpp:105
uint32_t numRows() const
Definition diagram.cpp:123
iterator begin()
Definition diagram.cpp:126
#define Config_getBool(name)
Definition config.h:33
const uint32_t maxTreeWidth
Definition diagram.cpp:137
const uint32_t labelHorMargin
Definition diagram.cpp:143
const uint32_t gridWidth
Definition diagram.cpp:138
static void writeMapArea(TextStream &t, const ClassDef *cd, QCString relPath, uint32_t x, uint32_t y, uint32_t w, uint32_t h)
Definition diagram.cpp:262
const uint32_t labelHorSpacing
Definition diagram.cpp:141
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)
Definition diagram.cpp:233
std::vector< DiagramItem * > DiagramItemList
Definition diagram.cpp:38
const uint32_t gridHeight
Definition diagram.cpp:139
const uint32_t fontHeight
Definition diagram.cpp:144
static Protection getMinProtectionLevel(const DiagramItemList &dil)
Definition diagram.cpp:213
static QCString convertToPSString(const QCString &s)
Definition diagram.cpp:193
static void writeVectorBox(TextStream &t, DiagramItem *di, float x, float y, bool children=FALSE)
Definition diagram.cpp:253
static uint32_t virtToMask(Specifier p)
Definition diagram.cpp:182
static uint8_t protToColor(Protection p)
Definition diagram.cpp:158
static QCString protToString(Protection p)
Definition diagram.cpp:170
#define IMAGE_EXT
static uint32_t protToMask(Protection p)
Definition diagram.cpp:146
const uint32_t labelVertSpacing
Definition diagram.cpp:142
constexpr DocNodeVariant * parent(DocNodeVariant *n)
returns the parent node of a given node n or nullptr if the node has no parent.
Definition docnode.h:1330
#define err(fmt,...)
Definition message.h:127
#define term(fmt,...)
Definition message.h:137
std::ofstream openOutputStream(const QCString &name, bool append=false)
Definition portable.cpp:649
int system(const QCString &command, const QCString &args, bool commandHasConsole=true)
Definition portable.cpp:106
Portable versions of functions that are platform dependent.
const char * qPrint(const char *s)
Definition qcstring.h:687
#define TRUE
Definition qcstring.h:37
#define FALSE
Definition qcstring.h:34
Private(const ClassDef *root)
Definition diagram.cpp:1034
Protection
Definition types.h:32
Specifier
Definition types.h:80
QCString externalRef(const QCString &relPath, const QCString &ref, bool href)
Definition util.cpp:5692
QCString insertTemplateSpecifierInScope(const QCString &scope, const QCString &templ)
Definition util.cpp:3683
QCString convertToHtml(const QCString &s, bool keepEntities)
Definition util.cpp:3900
QCString stripScope(const QCString &name)
Definition util.cpp:3716
QCString convertToXML(const QCString &s, bool keepEntities)
Definition util.cpp:3849
QCString externalLinkTarget(const bool parent)
Definition util.cpp:5648
void addHtmlExtensionIfMissing(QCString &fName)
Definition util.cpp:4850
A bunch of utility functions.