Doxygen
Loading...
Searching...
No Matches
TreeDiagram Class Reference

Class representing the tree layout for the built-in class diagram. More...

Public Types

using Ptr = std::unique_ptr<DiagramRow>
using Vec = std::vector<Ptr>
using iterator = typename Vec::iterator

Public Member Functions

 TreeDiagram (const ClassDef *root, bool doBases)
void computeLayout ()
uint32_t computeRows ()
void moveChildren (DiagramItem *root, int dx)
void computeExtremes (uint32_t *labelWidth, uint32_t *xpos)
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 drawConnectors (TextStream &t, Image *image, bool doBase, bool bitmap, uint32_t baseRows, uint32_t superRows, uint32_t cellWidth, uint32_t cellheight)
DiagramRowrow (int index)
uint32_t numRows () const
DiagramRowaddRow (uint32_t l)
iterator begin ()
iterator end ()

Private Member Functions

bool layoutTree (DiagramItem *root, uint32_t row)

Private Attributes

Vec m_rows

Detailed Description

Class representing the tree layout for the built-in class diagram.

Definition at line 101 of file diagram.cpp.

Member Typedef Documentation

◆ iterator

using TreeDiagram::iterator = typename Vec::iterator

Definition at line 106 of file diagram.cpp.

◆ Ptr

using TreeDiagram::Ptr = std::unique_ptr<DiagramRow>

Definition at line 104 of file diagram.cpp.

◆ Vec

using TreeDiagram::Vec = std::vector<Ptr>

Definition at line 105 of file diagram.cpp.

Constructor & Destructor Documentation

◆ TreeDiagram()

TreeDiagram::TreeDiagram ( const ClassDef * root,
bool doBases )

Definition at line 391 of file diagram.cpp.

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}
void insertClass(DiagramItem *parent, const ClassDef *cd, bool doBases, Protection prot, Specifier virt, const QCString &ts)
Definition diagram.cpp:349
DiagramRow * row(int index)
Definition diagram.cpp:122

References DiagramRow::insertClass(), m_rows, and row().

Member Function Documentation

◆ addRow()

DiagramRow * TreeDiagram::addRow ( uint32_t l)
inline

Definition at line 124 of file diagram.cpp.

125 { m_rows.push_back(std::make_unique<DiagramRow>(this,l)); return m_rows.back().get(); }

References m_rows.

◆ begin()

iterator TreeDiagram::begin ( )
inline

Definition at line 126 of file diagram.cpp.

126{ return m_rows.begin(); }

References m_rows.

◆ computeExtremes()

void TreeDiagram::computeExtremes ( uint32_t * labelWidth,
uint32_t * xpos )

Definition at line 532 of file diagram.cpp.

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}
friend uint32_t stringLength(const QCString &s)
Definition image.cpp:277
#define TRUE
Definition qcstring.h:37
#define FALSE
Definition qcstring.h:34

References FALSE, m_rows, Image::stringLength, and TRUE.

◆ computeLayout()

void TreeDiagram::computeLayout ( )

Definition at line 451 of file diagram.cpp.

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}
DiagramItem * parentItem()
Definition diagram.cpp:47
uint32_t numChildren() const
Definition diagram.cpp:337
void move(int dx, int dy)
Definition diagram.cpp:49
bool layoutTree(DiagramItem *root, uint32_t row)
Definition diagram.cpp:408
const uint32_t maxTreeWidth
Definition diagram.cpp:137
const uint32_t gridWidth
Definition diagram.cpp:138

References gridWidth, layoutTree(), m_rows, maxTreeWidth, DiagramItem::move(), DiagramItem::numChildren(), DiagramItem::parentItem(), row(), and TRUE.

◆ computeRows()

uint32_t TreeDiagram::computeRows ( )

Definition at line 502 of file diagram.cpp.

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}

References m_rows, DiagramItem::parentItem(), and row().

◆ drawBoxes()

void TreeDiagram::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 at line 585 of file diagram.cpp.

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;
606 DualDirIterator<DiagramRow,const std::unique_ptr<DiagramItem>&> dit(*dr,!doBase);
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}
virtual bool isLinkable() const =0
const ClassDef * getClassDef() const
Definition diagram.cpp:62
float xfPos() const
Definition diagram.cpp:52
bool isInList() const
Definition diagram.cpp:61
uint32_t xPos() const
Definition diagram.cpp:50
float yfPos() const
Definition diagram.cpp:53
uint32_t yPos() const
Definition diagram.cpp:51
uint32_t height() const
Definition image.cpp:209
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
const uint32_t gridHeight
Definition diagram.cpp:139
static void writeVectorBox(TextStream &t, DiagramItem *di, float x, float y, bool children=FALSE)
Definition diagram.cpp:253
const uint32_t labelVertSpacing
Definition diagram.cpp:142

References DualDirIterator< C, I >::atEnd(), FALSE, DiagramItem::getClassDef(), gridHeight, gridWidth, Image::height(), DiagramItem::isInList(), Definition::isLinkable(), labelHorSpacing, labelVertSpacing, m_rows, DiagramItem::numChildren(), DiagramItem::parentItem(), TRUE, writeBitmapBox(), writeMapArea(), writeVectorBox(), DiagramItem::xfPos(), DiagramItem::xPos(), DiagramItem::yfPos(), and DiagramItem::yPos().

◆ drawConnectors()

void TreeDiagram::drawConnectors ( TextStream & t,
Image * image,
bool doBase,
bool bitmap,
uint32_t baseRows,
uint32_t superRows,
uint32_t cellWidth,
uint32_t cellheight )

Definition at line 716 of file diagram.cpp.

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}
DiagramItemList getChildren()
Definition diagram.cpp:48
Protection protection() const
Definition diagram.cpp:58
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 drawHorzArrow(uint32_t y, uint32_t xs, uint32_t xe, uint8_t colIndex, uint32_t mask)
Definition image.cpp:299
std::vector< DiagramItem * > DiagramItemList
Definition diagram.cpp:38
static Protection getMinProtectionLevel(const DiagramItemList &dil)
Definition diagram.cpp:213
static uint8_t protToColor(Protection p)
Definition diagram.cpp:158
static QCString protToString(Protection p)
Definition diagram.cpp:170
static uint32_t protToMask(Protection p)
Definition diagram.cpp:146
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
Protection
Definition types.h:32

References Image::drawHorzArrow(), Image::drawHorzLine(), Image::drawVertArrow(), Image::drawVertLine(), FALSE, DiagramItem::getChildren(), getMinProtectionLevel(), gridHeight, gridWidth, Image::height(), DiagramItem::isInList(), labelHorSpacing, labelVertSpacing, m_rows, parent(), DiagramItem::parentItem(), DiagramItem::protection(), protToColor(), protToMask(), protToString(), TRUE, DiagramItem::xfPos(), DiagramItem::xPos(), DiagramItem::yfPos(), and DiagramItem::yPos().

◆ end()

iterator TreeDiagram::end ( )
inline

Definition at line 127 of file diagram.cpp.

127{ return m_rows.end(); }

References m_rows.

◆ layoutTree()

bool TreeDiagram::layoutTree ( DiagramItem * root,
uint32_t row )
private

Definition at line 408 of file diagram.cpp.

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}
uint32_t number() const
Definition diagram.cpp:57
uint32_t avgChildPos() const
Definition diagram.cpp:323

References DiagramItem::avgChildPos(), FALSE, DiagramItem::getChildren(), layoutTree(), m_rows, DiagramItem::number(), DiagramItem::numChildren(), row(), TRUE, and DiagramItem::xPos().

Referenced by computeLayout(), and layoutTree().

◆ moveChildren()

void TreeDiagram::moveChildren ( DiagramItem * root,
int dx )

Definition at line 399 of file diagram.cpp.

400{
401 for (const auto &di : root->getChildren())
402 {
403 di->move(dx,0);
404 moveChildren(di,dx);
405 }
406}
void moveChildren(DiagramItem *root, int dx)
Definition diagram.cpp:399

References DiagramItem::getChildren(), and moveChildren().

Referenced by moveChildren().

◆ numRows()

uint32_t TreeDiagram::numRows ( ) const
inline

Definition at line 123 of file diagram.cpp.

123{ return static_cast<uint32_t>(m_rows.size()); }

References m_rows.

◆ row()

DiagramRow * TreeDiagram::row ( int index)
inline

Definition at line 122 of file diagram.cpp.

122{ return m_rows.at(index).get(); }

References m_rows.

Referenced by computeLayout(), computeRows(), layoutTree(), and TreeDiagram().

Member Data Documentation

◆ m_rows

Vec TreeDiagram::m_rows
private

The documentation for this class was generated from the following file: