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

Member Typedef Documentation

◆ iterator

using TreeDiagram::iterator = typename Vec::iterator

Definition at line 105 of file diagram.cpp.

◆ Ptr

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

Definition at line 103 of file diagram.cpp.

◆ Vec

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

Definition at line 104 of file diagram.cpp.

Constructor & Destructor Documentation

◆ TreeDiagram()

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

Definition at line 390 of file diagram.cpp.

391{
392 auto row = std::make_unique<DiagramRow>(this,0);
393 DiagramRow *row_ptr = row.get();
394 m_rows.push_back(std::move(row));
395 row_ptr->insertClass(nullptr,root,doBases,Protection::Public,Specifier::Normal,QCString());
396}
void insertClass(DiagramItem *parent, const ClassDef *cd, bool doBases, Protection prot, Specifier virt, const QCString &ts)
Definition diagram.cpp:348
DiagramRow * row(int index)
Definition diagram.cpp:121

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

Member Function Documentation

◆ addRow()

DiagramRow * TreeDiagram::addRow ( uint32_t l)
inline

Definition at line 123 of file diagram.cpp.

124 { 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 125 of file diagram.cpp.

125{ return m_rows.begin(); }

References m_rows.

◆ computeExtremes()

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

Definition at line 531 of file diagram.cpp.

532{
533 uint32_t ml=0,mx=0;
534 for (const auto &dr : m_rows) // for each row
535 {
536 bool done=FALSE;
537 for (const auto &di : *dr) // for each item in a row
538 {
539 if (di->isInList()) done=TRUE;
540 if (maxXPos) mx=std::max(mx,di->xPos());
541 if (maxLabelLen) ml=std::max(ml,Image::stringLength(di->label()));
542 }
543 if (done) break;
544 }
545 if (maxLabelLen) *maxLabelLen=ml;
546 if (maxXPos) *maxXPos=mx;
547}
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 450 of file diagram.cpp.

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

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

◆ computeRows()

uint32_t TreeDiagram::computeRows ( )

Definition at line 501 of file diagram.cpp.

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

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

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

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

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

126{ return m_rows.end(); }

References m_rows.

◆ layoutTree()

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

Definition at line 407 of file diagram.cpp.

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

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

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

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

Referenced by moveChildren().

◆ numRows()

uint32_t TreeDiagram::numRows ( ) const
inline

Definition at line 122 of file diagram.cpp.

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

References m_rows.

◆ row()

DiagramRow * TreeDiagram::row ( int index)
inline

Definition at line 121 of file diagram.cpp.

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