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, DString 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 102 of file diagram.cpp.

Member Typedef Documentation

◆ iterator

using TreeDiagram::iterator = typename Vec::iterator

Definition at line 107 of file diagram.cpp.

◆ Ptr

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

Definition at line 105 of file diagram.cpp.

◆ Vec

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

Definition at line 106 of file diagram.cpp.

Constructor & Destructor Documentation

◆ TreeDiagram()

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

Definition at line 392 of file diagram.cpp.

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

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

Member Function Documentation

◆ addRow()

DiagramRow * TreeDiagram::addRow ( uint32_t l)
inline

Definition at line 125 of file diagram.cpp.

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

References m_rows.

Referenced by DiagramRow::insertClass().

◆ begin()

iterator TreeDiagram::begin ( )
inline

Definition at line 127 of file diagram.cpp.

127{ return m_rows.begin(); }

References m_rows.

◆ computeExtremes()

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

Definition at line 533 of file diagram.cpp.

534{
535 uint32_t ml=0,mx=0;
536 for (const auto &dr : m_rows) // for each row
537 {
538 bool done=false;
539 for (const auto &di : *dr) // for each item in a row
540 {
541 if (di->isInList()) done=true;
542 if (maxXPos) mx=std::max(mx,di->xPos());
543 if (maxLabelLen) ml=std::max(ml,Image::stringLength(di->label()));
544 }
545 if (done) break;
546 }
547 if (maxLabelLen) *maxLabelLen=ml;
548 if (maxXPos) *maxXPos=mx;
549}
friend uint32_t stringLength(const DString &s)
Definition image.cpp:282

References m_rows, and Image::stringLength.

◆ computeLayout()

void TreeDiagram::computeLayout ( )

Definition at line 452 of file diagram.cpp.

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

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

◆ computeRows()

uint32_t TreeDiagram::computeRows ( )

Definition at line 503 of file diagram.cpp.

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

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,
DString relPath = "",
bool generateMap = true )

Definition at line 586 of file diagram.cpp.

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

References DualDirIterator< C, I >::atEnd(), DiagramItem::getClassDef(), gridHeight, gridWidth, Image::height(), DiagramItem::isInList(), Definition::isLinkable(), labelHorSpacing, labelVertSpacing, m_rows, DiagramItem::numChildren(), DiagramItem::parentItem(), 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 717 of file diagram.cpp.

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

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

◆ end()

iterator TreeDiagram::end ( )
inline

Definition at line 128 of file diagram.cpp.

128{ return m_rows.end(); }

References m_rows.

◆ layoutTree()

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

Definition at line 409 of file diagram.cpp.

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

References DiagramItem::avgChildPos(), DiagramItem::getChildren(), DiagramRow::item(), layoutTree(), m_rows, DiagramItem::move(), DiagramItem::number(), DiagramItem::numChildren(), row(), and DiagramItem::xPos().

Referenced by computeLayout(), and layoutTree().

◆ moveChildren()

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

Definition at line 400 of file diagram.cpp.

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

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

Referenced by moveChildren().

◆ numRows()

uint32_t TreeDiagram::numRows ( ) const
inline

Definition at line 124 of file diagram.cpp.

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

References m_rows.

Referenced by DiagramRow::insertClass().

◆ row()

DiagramRow * TreeDiagram::row ( int index)
inline

Definition at line 123 of file diagram.cpp.

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

References m_rows.

Referenced by computeLayout(), computeRows(), DiagramRow::insertClass(), layoutTree(), and TreeDiagram().

Member Data Documentation

◆ m_rows

Vec TreeDiagram::m_rows
private

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