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 103 of file diagram.cpp.

Member Typedef Documentation

◆ iterator

using TreeDiagram::iterator = typename Vec::iterator

Definition at line 108 of file diagram.cpp.

◆ Ptr

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

Definition at line 106 of file diagram.cpp.

◆ Vec

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

Definition at line 107 of file diagram.cpp.

Constructor & Destructor Documentation

◆ TreeDiagram()

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

Definition at line 398 of file diagram.cpp.

399{
400 auto row = std::make_unique<DiagramRow>(this,0);
401 DiagramRow *row_ptr = row.get();
402 m_rows.push_back(std::move(row));
403 row_ptr->insertClass(nullptr,root,doBases,Protection::Public,Specifier::Normal,QCString());
404}
void insertClass(DiagramItem *parent, const ClassDef *cd, bool doBases, Protection prot, Specifier virt, const QCString &ts)
Definition diagram.cpp:356
DiagramRow * row(int index)
Definition diagram.cpp:124
@ Public
Definition types.h:26
@ Normal
Definition types.h:29

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

Member Function Documentation

◆ addRow()

DiagramRow * TreeDiagram::addRow ( uint32_t l)
inline

Definition at line 126 of file diagram.cpp.

127 { 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 128 of file diagram.cpp.

128{ return m_rows.begin(); }

References m_rows.

◆ computeExtremes()

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

Definition at line 539 of file diagram.cpp.

540{
541 uint32_t ml=0,mx=0;
542 for (const auto &dr : m_rows) // for each row
543 {
544 bool done=FALSE;
545 for (const auto &di : *dr) // for each item in a row
546 {
547 if (di->isInList()) done=TRUE;
548 if (maxXPos) mx=std::max(mx,di->xPos());
549 if (maxLabelLen) ml=std::max(ml,Image::stringLength(di->label()));
550 }
551 if (done) break;
552 }
553 if (maxLabelLen) *maxLabelLen=ml;
554 if (maxXPos) *maxXPos=mx;
555}
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 458 of file diagram.cpp.

459{
460 auto it = m_rows.begin();
461 while (it!=m_rows.end() && (*it)->numItems()<maxTreeWidth) ++it;
462 if (it!=m_rows.end())
463 {
464 const auto &row = *it;
465 //printf("computeLayout() list row at %d\n",row->number());
466 DiagramItem *opi=nullptr;
467 int delta=0;
468 bool first=TRUE;
469 for (const auto &di : *row)
470 {
471 DiagramItem *pi=di->parentItem();
472 if (pi==opi && !first) { delta-=gridWidth; }
473 first = pi!=opi;
474 opi=pi;
475 di->move(delta,0); // collapse all items in the same
476 // list (except the first)
477 di->putInList();
478 }
479 }
480
481 // re-organize the diagram items
482 DiagramItem *root=m_rows.front()->item(0);
483 while (layoutTree(root,0)) { }
484
485 // move first items of the lists
486 if (it!=m_rows.end())
487 {
488 const auto &row = *it;
489 auto rit = row->begin();
490 while (rit!=row->end())
491 {
492 DiagramItem *pi=(*rit)->parentItem();
493 if (pi->numChildren()>1)
494 {
495 (*rit)->move(gridWidth,0);
496 while (rit!=row->end() && (*rit)->parentItem()==pi)
497 {
498 ++rit;
499 }
500 }
501 else
502 {
503 ++rit;
504 }
505 }
506 }
507}
DiagramItem * parentItem()
Definition diagram.cpp:48
uint32_t numChildren() const
Definition diagram.cpp:344
void move(int dx, int dy)
Definition diagram.cpp:50
bool layoutTree(DiagramItem *root, uint32_t row)
Definition diagram.cpp:415
const uint32_t maxTreeWidth
Definition diagram.cpp:139
const uint32_t gridWidth
Definition diagram.cpp:140

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

◆ computeRows()

uint32_t TreeDiagram::computeRows ( )

Definition at line 509 of file diagram.cpp.

510{
511 //printf("TreeDiagram::computeRows()=%d\n",count());
512 uint32_t count=0;
513 auto it = m_rows.begin();
514 while (it!=m_rows.end() && !(*it)->item(0)->isInList())
515 {
516 ++it;
517 ++count;
518 }
519
520 //printf("count=%d row=%p\n",count,row);
521 if (it!=m_rows.end())
522 {
523 const auto &row = *it;
524 uint32_t maxListLen=0;
525 uint32_t curListLen=0;
526 DiagramItem *opi=nullptr;
527 for (const auto &di : *row) // for each item in a row
528 {
529 if (di->parentItem()!=opi) curListLen=1; else curListLen++;
530 if (curListLen>maxListLen) maxListLen=curListLen;
531 opi=di->parentItem();
532 }
533 //printf("maxListLen=%d\n",maxListLen);
534 count+=maxListLen;
535 }
536 return count;
537}

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 592 of file diagram.cpp.

598{
599 auto it = m_rows.begin();
600 if (it!=m_rows.end() && !doBase) ++it;
601 bool firstRow = doBase;
602 bool done=FALSE;
603 float superRowsF = static_cast<float>(superRows);
604 for (;it!=m_rows.end() && !done;++it) // for each row
605 {
606 const auto &dr = *it;
607 uint32_t x=0,y=0;
608 float xf=0.0f,yf=0.0f;
609 DiagramItem *firstDi = dr->item(0);
610 if (firstDi->isInList()) // put boxes in a list
611 {
612 DiagramItem *opi=nullptr;
613 DualDirIterator<DiagramRow,const std::unique_ptr<DiagramItem>&> dit(*dr,!doBase);
614 while (!dit.atEnd())
615 {
616 DiagramItem *di = (*dit).get();
617 if (di->parentItem()==opi)
618 {
619 if (bitmap)
620 {
621 if (doBase) y -= cellHeight+labelVertSpacing;
622 else y += cellHeight+labelVertSpacing;
623 }
624 else
625 {
626 if (doBase) yf += 1.0f;
627 else yf -= 1.0f;
628 }
629 }
630 else
631 {
632 if (bitmap)
633 {
634 x = di->xPos()*(cellWidth+labelHorSpacing)/gridWidth;
635 if (doBase)
636 {
637 y = image->height()-
638 superRows*cellHeight-
639 (superRows-1)*labelVertSpacing-
640 di->yPos()*(cellHeight+labelVertSpacing)/gridHeight;
641 }
642 else
643 {
644 y = (baseRows-1)*(cellHeight+labelVertSpacing)+
645 di->yPos()*(cellHeight+labelVertSpacing)/gridHeight;
646 }
647 }
648 else
649 {
650 xf = di->xfPos()/gridWidth;
651 if (doBase)
652 {
653 yf = di->yfPos()/gridHeight+superRowsF-1.0f;
654 }
655 else
656 {
657 yf = superRowsF-1.0f-di->yfPos()/gridHeight;
658 }
659 }
660 }
661 opi=di->parentItem();
662
663 if (bitmap)
664 {
665 bool hasDocs=di->getClassDef()->isLinkable();
666 writeBitmapBox(di,image,x,y,cellWidth,cellHeight,firstRow,
667 hasDocs,di->numChildren()>0);
668 if (!firstRow && generateMap)
669 writeMapArea(t,di->getClassDef(),relPath,x,y,cellWidth,cellHeight);
670 }
671 else
672 {
673 writeVectorBox(t,di,xf,yf,di->numChildren()>0);
674 }
675
676 ++dit;
677 }
678 done=TRUE;
679 }
680 else // draw a tree of boxes
681 {
682 for (const auto &di : *dr)
683 {
684 if (bitmap)
685 {
686 x = di->xPos()*(cellWidth+labelHorSpacing)/gridWidth;
687 if (doBase)
688 {
689 y = image->height()-
690 superRows*cellHeight-
691 (superRows-1)*labelVertSpacing-
692 di->yPos()*(cellHeight+labelVertSpacing)/gridHeight;
693 }
694 else
695 {
696 y = (baseRows-1)*(cellHeight+labelVertSpacing)+
697 di->yPos()*(cellHeight+labelVertSpacing)/gridHeight;
698 }
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);
703 }
704 else
705 {
706 xf=di->xfPos()/gridWidth;
707 if (doBase)
708 {
709 yf = di->yfPos()/gridHeight+superRowsF-1.0f;
710 }
711 else
712 {
713 yf = superRowsF-1.0f-di->yfPos()/gridHeight;
714 }
715 writeVectorBox(t,di.get(),xf,yf);
716 }
717 }
718 }
719 firstRow=FALSE;
720 }
721}
virtual bool isLinkable() const =0
const ClassDef * getClassDef() const
Definition diagram.cpp:63
float xfPos() const
Definition diagram.cpp:53
bool isInList() const
Definition diagram.cpp:62
uint32_t xPos() const
Definition diagram.cpp:51
float yfPos() const
Definition diagram.cpp:54
uint32_t yPos() const
Definition diagram.cpp:52
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:264
const uint32_t labelHorSpacing
Definition diagram.cpp:143
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:235
const uint32_t gridHeight
Definition diagram.cpp:141
static void writeVectorBox(TextStream &t, DiagramItem *di, float x, float y, bool children=FALSE)
Definition diagram.cpp:255
const uint32_t labelVertSpacing
Definition diagram.cpp:144

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 723 of file diagram.cpp.

727{
728 bool done=FALSE;
729 auto it = m_rows.begin();
730 float superRowsF = static_cast<float>(superRows);
731 for (;it!=m_rows.end() && !done;++it) // for each row
732 {
733 const auto &dr = *it;
734 DiagramItem *rootDi = dr->item(0);
735 if (rootDi->isInList()) // row consists of list connectors
736 {
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())
741 {
742 DiagramItem *di=(*rit).get();
743 DiagramItem *pi=di->parentItem();
745 DiagramItem *last=dil.back();
746 if (di==last) // single child
747 {
748 if (bitmap) // draw pixels
749 {
750 x = di->xPos()*(cellWidth+labelHorSpacing)/gridWidth + cellWidth/2;
751 if (doBase) // base classes
752 {
753 y = image->height()-
754 (superRows-1)*(cellHeight+labelVertSpacing)-
755 di->yPos()*(cellHeight+labelVertSpacing)/gridHeight;
756 image->drawVertArrow(x,y,y+labelVertSpacing/2,
757 protToColor(di->protection()),
758 protToMask(di->protection()));
759 }
760 else // super classes
761 {
762 y = (baseRows-1)*(cellHeight+labelVertSpacing)-
764 di->yPos()*(cellHeight+labelVertSpacing)/gridHeight;
765 image->drawVertLine(x,y,y+labelVertSpacing/2,
766 protToColor(di->protection()),
767 protToMask(di->protection()));
768 }
769 }
770 else // draw vectors
771 {
772 t << protToString(di->protection()) << "\n";
773 if (doBase)
774 {
775 t << "1 " << (di->xfPos()/gridWidth) << " "
776 << (di->yfPos()/gridHeight+superRowsF-1.0f) << " in\n";
777 }
778 else
779 {
780 t << "0 " << (di->xfPos()/gridWidth) << " "
781 << (superRowsF-0.25f-di->yfPos()/gridHeight)
782 << " in\n";
783 }
784 }
785 }
786 else // multiple children, put them in a vertical list
787 {
788 if (bitmap)
789 {
790 x = di->parentItem()->xPos()*
791 (cellWidth+labelHorSpacing)/gridWidth+cellWidth/2;
792 if (doBase) // base classes
793 {
794 ys = image->height()-
795 (superRows-1)*(cellHeight+labelVertSpacing)-
796 di->yPos()*(cellHeight+labelVertSpacing)/gridHeight;
797 y = ys - cellHeight/2;
798 }
799 else // super classes
800 {
801 ys = (baseRows-1)*(cellHeight+labelVertSpacing)+
802 di->yPos()*(cellHeight+labelVertSpacing)/gridHeight;
803 y = ys + cellHeight/2;
804 }
805 }
806 else
807 {
808 xf = di->parentItem()->xfPos()/gridWidth;
809 if (doBase)
810 {
811 ysf = di->yfPos()/gridHeight+superRowsF-1.0f;
812 yf = ysf + 0.5f;
813 }
814 else
815 {
816 ysf = superRowsF-0.25f-di->yfPos()/gridHeight;
817 yf = ysf - 0.25f;
818 }
819 }
820 while (di!=last) // more children to add
821 {
822 if (bitmap)
823 {
824 if (doBase) // base classes
825 {
826 image->drawHorzArrow(y,x,x+cellWidth/2+labelHorSpacing,
827 protToColor(di->protection()),
828 protToMask(di->protection()));
829 y -= cellHeight+labelVertSpacing;
830 }
831 else // super classes
832 {
833 image->drawHorzLine(y,x,x+cellWidth/2+labelHorSpacing,
834 protToColor(di->protection()),
835 protToMask(di->protection()));
836 y += cellHeight+labelVertSpacing;
837 }
838 }
839 else
840 {
841 t << protToString(di->protection()) << "\n";
842 if (doBase)
843 {
844 t << "1 " << xf << " " << yf << " hedge\n";
845 yf += 1.0f;
846 }
847 else
848 {
849 t << "0 " << xf << " " << yf << " hedge\n";
850 yf -= 1.0f;
851 }
852 }
853 ++rit;
854 if (rit!=dr->end()) di = (*rit).get(); else di=nullptr;
855 }
856 // add last horizontal line and a vertical connection line
857 if (bitmap)
858 {
859 if (doBase) // base classes
860 {
861 image->drawHorzArrow(y,x,x+cellWidth/2+labelHorSpacing,
862 protToColor(di->protection()),
863 protToMask(di->protection()));
864 image->drawVertLine(x,y,ys+labelVertSpacing/2,
867 }
868 else // super classes
869 {
870 image->drawHorzLine(y,x,x+cellWidth/2+labelHorSpacing,
871 protToColor(di->protection()),
872 protToMask(di->protection()));
873 image->drawVertLine(x,ys-labelVertSpacing/2,y,
876 }
877 }
878 else
879 {
880 t << protToString(di->protection()) << "\n";
881 if (doBase)
882 {
883 t << "1 " << xf << " " << yf << " hedge\n";
884 }
885 else
886 {
887 t << "0 " << xf << " " << yf << " hedge\n";
888 }
889 t << protToString(getMinProtectionLevel(dil)) << "\n";
890 if (doBase)
891 {
892 t << xf << " " << ysf << " " << yf << " vedge\n";
893 }
894 else
895 {
896 t << xf << " " << (ysf + 0.25f) << " " << yf << " vedge\n";
897 }
898 }
899 }
900 if (rit!=dr->end()) ++rit;
901 }
902 done=TRUE; // the tree is drawn now
903 }
904 else // normal tree connector
905 {
906 for (const auto &di : *dr)
907 {
908 uint32_t x=0,y=0;
909 DiagramItemList dil = di->getChildren();
910 DiagramItem *parent = di->parentItem();
911 if (parent) // item has a parent -> connect to it
912 {
913 if (bitmap) // draw pixels
914 {
915 x = di->xPos()*(cellWidth+labelHorSpacing)/gridWidth + cellWidth/2;
916 if (doBase) // base classes
917 {
918 y = image->height()-
919 (superRows-1)*(cellHeight+labelVertSpacing)-
920 di->yPos()*(cellHeight+labelVertSpacing)/gridHeight;
921 /* write input line */
922 image->drawVertArrow(x,y,y+labelVertSpacing/2,
923 protToColor(di->protection()),
924 protToMask(di->protection()));
925 }
926 else // super classes
927 {
928 y = (baseRows-1)*(cellHeight+labelVertSpacing)-
930 di->yPos()*(cellHeight+labelVertSpacing)/gridHeight;
931 /* write output line */
932 image->drawVertLine(x,y,y+labelVertSpacing/2,
933 protToColor(di->protection()),
934 protToMask(di->protection()));
935 }
936 }
937 else // draw pixels
938 {
939 t << protToString(di->protection()) << "\n";
940 if (doBase)
941 {
942 t << "1 " << di->xfPos()/gridWidth << " "
943 << (di->yfPos()/gridHeight+superRowsF-1.0f) << " in\n";
944 }
945 else
946 {
947 t << "0 " << di->xfPos()/gridWidth << " "
948 << (superRowsF-0.25f-di->yfPos()/gridHeight)
949 << " in\n";
950 }
951 }
952 }
953 if (!dil.empty())
954 {
956 uint32_t mask=protToMask(p);
957 uint8_t col=protToColor(p);
958 if (bitmap)
959 {
960 x = di->xPos()*(cellWidth+labelHorSpacing)/gridWidth + cellWidth/2;
961 if (doBase) // base classes
962 {
963 y = image->height()-
964 (superRows-1)*(cellHeight+labelVertSpacing)-
965 cellHeight-labelVertSpacing/2-
966 di->yPos()*(cellHeight+labelVertSpacing)/gridHeight;
967 image->drawVertLine(x,y,y+labelVertSpacing/2-1,col,mask);
968 }
969 else // super classes
970 {
971 y = (baseRows-1)*(cellHeight+labelVertSpacing)+
972 cellHeight+
973 di->yPos()*(cellHeight+labelVertSpacing)/gridHeight;
974 image->drawVertArrow(x,y,y+labelVertSpacing/2-1,col,mask);
975 }
976 }
977 else
978 {
979 t << protToString(p) << "\n";
980 if (doBase)
981 {
982 t << "0 " << di->xfPos()/gridWidth << " "
983 << (di->yfPos()/gridHeight+superRowsF-1.0f) << " out\n";
984 }
985 else
986 {
987 t << "1 " << di->xfPos()/gridWidth << " "
988 << (superRowsF-1.75f-di->yfPos()/gridHeight)
989 << " out\n";
990 }
991 }
992 /* write input line */
993 DiagramItem *first = dil.front();
994 DiagramItem *last = dil.back();
995 if (first!=last && !first->isInList()) /* connect with all base classes */
996 {
997 if (bitmap)
998 {
999 uint32_t xs = first->xPos()*(cellWidth+labelHorSpacing)/gridWidth
1000 + cellWidth/2;
1001 uint32_t xe = last->xPos()*(cellWidth+labelHorSpacing)/gridWidth
1002 + cellWidth/2;
1003 if (doBase) // base classes
1004 {
1005 image->drawHorzLine(y,xs,xe,col,mask);
1006 }
1007 else // super classes
1008 {
1009 image->drawHorzLine(y+labelVertSpacing/2,xs,xe,col,mask);
1010 }
1011 }
1012 else
1013 {
1014 t << protToString(p) << "\n";
1015 if (doBase)
1016 {
1017 t << first->xfPos()/gridWidth << " "
1018 << last->xfPos()/gridWidth << " "
1019 << (first->yfPos()/gridHeight+superRowsF-1.0f)
1020 << " conn\n";
1021 }
1022 else
1023 {
1024 t << first->xfPos()/gridWidth << " "
1025 << last->xfPos()/gridWidth << " "
1026 << (superRowsF-first->yfPos()/gridHeight)
1027 << " conn\n";
1028 }
1029 }
1030 }
1031 }
1032 }
1033 }
1034 }
1035}
DiagramItemList getChildren()
Definition diagram.cpp:49
Protection protection() const
Definition diagram.cpp:59
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:215
static uint8_t protToColor(Protection p)
Definition diagram.cpp:160
static QCString protToString(Protection p)
Definition diagram.cpp:172
static uint32_t protToMask(Protection p)
Definition diagram.cpp:148
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:1324
Protection
Protection level of members.
Definition types.h:26

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 129 of file diagram.cpp.

129{ return m_rows.end(); }

References m_rows.

◆ layoutTree()

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

Definition at line 415 of file diagram.cpp.

416{
417 bool moved=FALSE;
418 //printf("layoutTree(%s,%d)\n",qPrint(root->label()),r);
419
420 if (root->numChildren()>0)
421 {
422 auto children = root->getChildren();
423 uint32_t pPos=root->xPos();
424 uint32_t cPos=root->avgChildPos();
425 if (pPos>cPos) // move children
426 {
427 const auto &row=m_rows.at(r+1);
428 //printf("Moving children %d-%d in row %d\n",
429 // dil->getFirst()->number(),row->count()-1,r+1);
430 for (uint32_t k=children.front()->number();k<row->numItems();k++)
431 {
432 row->item(k)->move(static_cast<int>(pPos-cPos),0);
433 }
434 moved=TRUE;
435 }
436 else if (pPos<cPos) // move parent
437 {
438 const auto &row=m_rows.at(r);
439 //printf("Moving parents %d-%d in row %d\n",
440 // root->number(),row->count()-1,r);
441 for (uint32_t k=root->number();k<row->numItems();k++)
442 {
443 row->item(k)->move(static_cast<int>(cPos-pPos),0);
444 }
445 moved=TRUE;
446 }
447
448 // recurse to children
449 auto it = children.begin();
450 for (;it!=children.end() && !moved && !(*it)->isInList();++it)
451 {
452 moved = layoutTree(*it,r+1);
453 }
454 }
455 return moved;
456}
uint32_t number() const
Definition diagram.cpp:58
uint32_t avgChildPos() const
Definition diagram.cpp:330

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 406 of file diagram.cpp.

407{
408 for (const auto &di : root->getChildren())
409 {
410 di->move(dx,0);
411 moveChildren(di,dx);
412 }
413}
void moveChildren(DiagramItem *root, int dx)
Definition diagram.cpp:406

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

Referenced by moveChildren().

◆ numRows()

uint32_t TreeDiagram::numRows ( ) const
inline

Definition at line 125 of file diagram.cpp.

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

References m_rows.

◆ row()

DiagramRow * TreeDiagram::row ( int index)
inline

Definition at line 124 of file diagram.cpp.

124{ 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: