Public Member Functions | Private Member Functions | List of all members
TreeDiagram Class Reference
Inheritance diagram for TreeDiagram:
QList< DiagramRow > QGList

Public Member Functions

 TreeDiagram (ClassDef *root, bool doBases)
 
 ~TreeDiagram ()
 
void computeLayout ()
 
uint computeRows ()
 
void moveChildren (DiagramItem *root, int dx)
 
void computeExtremes (uint *labelWidth, uint *xpos)
 
void drawBoxes (FTextStream &t, Image *image, bool doBase, bool bitmap, uint baseRows, uint superRows, uint cellWidth, uint cellHeight, QCString relPath="", bool generateMap=TRUE)
 
void drawConnectors (FTextStream &t, Image *image, bool doBase, bool bitmap, uint baseRows, uint superRows, uint cellWidth, uint cellheight)
 
- Public Member Functions inherited from QList< DiagramRow >
 QList ()
 
 QList (const QList< DiagramRow > &l)
 
 ~QList ()
 
QList< DiagramRow > & operator= (const QList< DiagramRow > &l)
 
bool operator== (const QList< DiagramRow > &list) const
 
uint count () const
 
bool isEmpty () const
 
bool insert (uint i, const DiagramRow *d)
 
void inSort (const DiagramRow *d)
 
void prepend (const DiagramRow *d)
 
void append (const DiagramRow *d)
 
bool remove (uint i)
 
bool remove (const DiagramRow *d)
 
bool removeRef (const DiagramRow *d)
 
bool removeFirst ()
 
bool removeLast ()
 
DiagramRowtake (uint i)
 
void clear ()
 
void sort ()
 
int find (const DiagramRow *d) const
 
int findRef (const DiagramRow *d) const
 
uint contains (const DiagramRow *d) const
 
uint containsRef (const DiagramRow *d) const
 
DiagramRowat (uint i) const
 
DiagramRowgetFirst () const
 
DiagramRowgetLast () const
 
void setAutoDelete (bool enable)
 

Private Member Functions

bool layoutTree (DiagramItem *root, int row)
 
TreeDiagramoperator= (const TreeDiagram &)
 
 TreeDiagram (const TreeDiagram &)
 

Detailed Description

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

Definition at line 111 of file diagram.cpp.

Constructor & Destructor Documentation

TreeDiagram::TreeDiagram ( ClassDef root,
bool  doBases 
)

Definition at line 409 of file diagram.cpp.

410 {
412  DiagramRow *row=new DiagramRow(this,0);
413  append(row);
414  row->insertClass(0,root,doBases,Public,Normal,0);
415 }
void append(const DiagramRow *d)
Definition: qlist.h:73
Definition: types.h:26
Definition: types.h:29
void insertClass(DiagramItem *parent, ClassDef *cd, bool doBases, Protection prot, Specifier virt, const char *ts)
Definition: diagram.cpp:357
void setAutoDelete(bool enable)
Definition: qlist.h:99
const bool TRUE
Definition: qglobal.h:371
TreeDiagram::~TreeDiagram ( )

Definition at line 417 of file diagram.cpp.

418 {
419 }
TreeDiagram::TreeDiagram ( const TreeDiagram )
private

Member Function Documentation

void TreeDiagram::computeExtremes ( uint labelWidth,
uint xpos 
)

Definition at line 555 of file diagram.cpp.

556 {
557  uint ml=0,mx=0;
558  QListIterator<DiagramRow> it(*this);
559  DiagramRow *dr;
560  bool done=FALSE;
561  for (;(dr=it.current()) && !done;++it)
562  {
564  DiagramItem *di;
565  for (;(di=rit.current());++rit)
566  {
567  if (di->isInList()) done=TRUE;
568  if (maxXPos) mx=QMAX(mx,(uint)di->xPos());
569  if (maxLabelLen) ml=QMAX(ml,Image::stringLength(di->label()));
570  }
571  }
572  if (maxLabelLen) *maxLabelLen=ml;
573  if (maxXPos) *maxXPos=mx;
574 }
int xPos() const
Definition: diagram.cpp:53
friend uint stringLength(const char *s)
Definition: image.cpp:314
bool isInList() const
Definition: diagram.cpp:62
const bool FALSE
Definition: qglobal.h:370
#define QMAX(a, b)
Definition: qglobal.h:390
QCString label() const
Definition: diagram.cpp:306
unsigned uint
Definition: qglobal.h:351
const bool TRUE
Definition: qglobal.h:371
void TreeDiagram::computeLayout ( )

Definition at line 475 of file diagram.cpp.

476 {
477  QListIterator<DiagramRow> it(*this);
478  DiagramRow *row;
479  for (;(row=it.current()) && row->count()<maxTreeWidth;++it) {}
480  if (row)
481  {
482  //printf("computeLayout() list row at %d\n",row->number());
483  QListIterator<DiagramItem> rit(*row);
484  DiagramItem *di;
485  DiagramItem *opi=0;
486  int delta=0;
487  bool first=TRUE;
488  for (;(di=rit.current());++rit)
489  {
490  DiagramItem *pi=di->parentItem();
491  if (pi==opi && !first) { delta-=gridWidth; }
492  first = pi!=opi;
493  opi=pi;
494  di->move(delta,0); // collapse all items in the same
495  // list (except the first)
496  di->putInList();
497  }
498  }
499 
500  // re-organize the diagram items
501  DiagramItem *root=getFirst()->getFirst();
502  while (layoutTree(root,0)) { }
503 
504  // move first items of the lists
505  if (row)
506  {
507  QListIterator<DiagramItem> rit(*row);
508  DiagramItem *di;
509  while ((di=rit.current()))
510  {
511  DiagramItem *pi=di->parentItem();
512  if (pi->getChildren()->count()>1)
513  {
514  di->move(gridWidth,0);
515  while (di && di->parentItem()==pi) { ++rit; di=rit.current(); }
516  }
517  else
518  {
519  ++rit;
520  }
521  }
522  }
523 }
void move(int dx, int dy)
Definition: diagram.cpp:52
void putInList()
Definition: diagram.cpp:61
const uint maxTreeWidth
Definition: diagram.cpp:141
DiagramItem * parentItem()
Definition: diagram.cpp:50
QCollection::Item first()
Definition: qglist.cpp:807
uint count() const
Definition: qlist.h:66
DiagramRow * getFirst() const
Definition: qlist.h:95
DiagramItemList * getChildren()
Definition: diagram.cpp:51
float pi
Definition: units.py:11
bool layoutTree(DiagramItem *root, int row)
Definition: diagram.cpp:434
const int gridWidth
Definition: diagram.cpp:142
const bool TRUE
Definition: qglobal.h:371
uint TreeDiagram::computeRows ( )

Definition at line 525 of file diagram.cpp.

526 {
527  //printf("TreeDiagram::computeRows()=%d\n",count());
528  int count=0;
529  QListIterator<DiagramRow> it(*this);
530  DiagramRow *row;
531  for (;(row=it.current()) && !row->getFirst()->isInList();++it)
532  {
533  count++;
534  }
535  //printf("count=%d row=%p\n",count,row);
536  if (row)
537  {
538  int maxListLen=0;
539  int curListLen=0;
540  DiagramItem *opi=0;
541  QListIterator<DiagramItem> rit(*row);
542  DiagramItem *di;
543  for (;(di=rit.current());++rit)
544  {
545  if (di->parentItem()!=opi) curListLen=1; else curListLen++;
546  if (curListLen>maxListLen) maxListLen=curListLen;
547  opi=di->parentItem();
548  }
549  //printf("maxListLen=%d\n",maxListLen);
550  count+=maxListLen;
551  }
552  return count;
553 }
bool isInList() const
Definition: diagram.cpp:62
DiagramItem * parentItem()
Definition: diagram.cpp:50
uint count() const
Definition: qlist.h:66
type * getFirst() const
Definition: qlist.h:95
void TreeDiagram::drawBoxes ( FTextStream t,
Image image,
bool  doBase,
bool  bitmap,
uint  baseRows,
uint  superRows,
uint  cellWidth,
uint  cellHeight,
QCString  relPath = "",
bool  generateMap = TRUE 
)

Definition at line 576 of file diagram.cpp.

582 {
583  QListIterator<DiagramRow> it(*this);
584  DiagramRow *dr;
585  if (!doBase) ++it;
586  bool done=FALSE;
587  bool firstRow = doBase;
588  for (;(dr=it.current()) && !done;++it)
589  {
590  int x=0,y=0;
591  float xf=0.0f,yf=0.0f;
593  DiagramItem *di = rit.current();
594  if (di->isInList()) // put boxes in a list
595  {
596  DiagramItem *opi=0;
597  if (doBase) rit.toLast(); else rit.toFirst();
598  while ((di=rit.current()))
599  {
600  if (di->parentItem()==opi)
601  {
602  if (bitmap)
603  {
604  if (doBase) y -= cellHeight+labelVertSpacing;
605  else y += cellHeight+labelVertSpacing;
606  }
607  else
608  {
609  if (doBase) yf += 1.0f;
610  else yf -= 1.0f;
611  }
612  }
613  else
614  {
615  if (bitmap)
616  {
617  x = di->xPos()*(cellWidth+labelHorSpacing)/gridWidth;
618  if (doBase)
619  {
620  y = image->getHeight()-
621  superRows*cellHeight-
622  (superRows-1)*labelVertSpacing-
623  di->yPos()*(cellHeight+labelVertSpacing)/gridHeight;
624  }
625  else
626  {
627  y = (baseRows-1)*(cellHeight+labelVertSpacing)+
628  di->yPos()*(cellHeight+labelVertSpacing)/gridHeight;
629  }
630  }
631  else
632  {
633  xf = di->xPos()/(float)gridWidth;
634  if (doBase)
635  {
636  yf = di->yPos()/(float)gridHeight+superRows-1;
637  }
638  else
639  {
640  yf = superRows-1-di->yPos()/(float)gridHeight;
641  }
642  }
643  }
644  opi=di->parentItem();
645 
646  if (bitmap)
647  {
648  bool hasDocs=di->getClassDef()->isLinkable();
649  writeBitmapBox(di,image,x,y,cellWidth,cellHeight,firstRow,
650  hasDocs,di->getChildren()->count()>0);
651  if (!firstRow && generateMap)
652  writeMapArea(t,di->getClassDef(),relPath,x,y,cellWidth,cellHeight);
653  }
654  else
655  {
656  writeVectorBox(t,di,xf,yf,di->getChildren()->count()>0);
657  }
658 
659  if (doBase) --rit; else ++rit;
660  }
661  done=TRUE;
662  }
663  else // draw a tree of boxes
664  {
665  for (rit.toFirst();(di=rit.current());++rit)
666  {
667  if (bitmap)
668  {
669  x = di->xPos()*(cellWidth+labelHorSpacing)/gridWidth;
670  if (doBase)
671  {
672  y = image->getHeight()-
673  superRows*cellHeight-
674  (superRows-1)*labelVertSpacing-
675  di->yPos()*(cellHeight+labelVertSpacing)/gridHeight;
676  }
677  else
678  {
679  y = (baseRows-1)*(cellHeight+labelVertSpacing)+
680  di->yPos()*(cellHeight+labelVertSpacing)/gridHeight;
681  }
682  bool hasDocs=di->getClassDef()->isLinkable();
683  writeBitmapBox(di,image,x,y,cellWidth,cellHeight,firstRow,hasDocs);
684  if (!firstRow && generateMap)
685  writeMapArea(t,di->getClassDef(),relPath,x,y,cellWidth,cellHeight);
686  }
687  else
688  {
689  xf=di->xPos()/(float)gridWidth;
690  if (doBase)
691  {
692  yf = di->yPos()/(float)gridHeight+superRows-1;
693  }
694  else
695  {
696  yf = superRows-1-di->yPos()/(float)gridHeight;
697  }
698  writeVectorBox(t,di,xf,yf);
699  }
700  }
701  }
702  firstRow=FALSE;
703  }
704 }
uint getHeight() const
Definition: image.h:43
int yPos() const
Definition: diagram.cpp:54
int xPos() const
Definition: diagram.cpp:53
ClassDef * getClassDef() const
Definition: diagram.cpp:63
bool isInList() const
Definition: diagram.cpp:62
const bool FALSE
Definition: qglobal.h:370
const int gridHeight
Definition: diagram.cpp:143
DiagramItem * parentItem()
Definition: diagram.cpp:50
static void writeBitmapBox(DiagramItem *di, Image *image, int x, int y, int w, int h, bool firstRow, bool hasDocs, bool children=FALSE)
Definition: diagram.cpp:227
uint count() const
Definition: qlist.h:66
const uint labelHorSpacing
Definition: diagram.cpp:145
bool isLinkable() const
Definition: classdef.cpp:2729
DiagramItemList * getChildren()
Definition: diagram.cpp:51
static void writeMapArea(FTextStream &t, ClassDef *cd, QCString relPath, int x, int y, int w, int h)
Definition: diagram.cpp:255
list x
Definition: train.py:276
static void writeVectorBox(FTextStream &t, DiagramItem *di, float x, float y, bool children=FALSE)
Definition: diagram.cpp:246
const int gridWidth
Definition: diagram.cpp:142
const bool TRUE
Definition: qglobal.h:371
const uint labelVertSpacing
Definition: diagram.cpp:146
void TreeDiagram::drawConnectors ( FTextStream t,
Image image,
bool  doBase,
bool  bitmap,
uint  baseRows,
uint  superRows,
uint  cellWidth,
uint  cellheight 
)

Definition at line 706 of file diagram.cpp.

710 {
711  QListIterator<DiagramRow> it(*this);
712  DiagramRow *dr;
713  bool done=FALSE;
714  for (;(dr=it.current()) && !done;++it) // for each row
715  {
717  DiagramItem *di = rit.current();
718  if (di->isInList()) // row consists of list connectors
719  {
720  int x=0,y=0,ys=0;
721  float xf=0.0f,yf=0.0f,ysf=0.0f;
722  for (;(di=rit.current());++rit)
723  {
724  DiagramItem *pi=di->parentItem();
725  DiagramItemList *dil=pi->getChildren();
726  DiagramItem *last=dil->getLast();
727  if (di==last) // single child
728  {
729  if (bitmap) // draw pixels
730  {
731  x = di->xPos()*(cellWidth+labelHorSpacing)/gridWidth + cellWidth/2;
732  if (doBase) // base classes
733  {
734  y = image->getHeight()-
735  (superRows-1)*(cellHeight+labelVertSpacing)-
736  di->yPos()*(cellHeight+labelVertSpacing)/gridHeight;
737  image->drawVertArrow(x,y,y+labelVertSpacing/2,
738  protToColor(di->protection()),
739  protToMask(di->protection()));
740  }
741  else // super classes
742  {
743  y = (baseRows-1)*(cellHeight+labelVertSpacing)-
745  di->yPos()*(cellHeight+labelVertSpacing)/gridHeight;
746  image->drawVertLine(x,y,y+labelVertSpacing/2,
747  protToColor(di->protection()),
748  protToMask(di->protection()));
749  }
750  }
751  else // draw vectors
752  {
753  t << protToString(di->protection()) << endl;
754  if (doBase)
755  {
756  t << "1 " << (di->xPos()/(float)gridWidth) << " "
757  << (di->yPos()/(float)gridHeight+superRows-1) << " in\n";
758  }
759  else
760  {
761  t << "0 " << (di->xPos()/(float)gridWidth) << " "
762  << ((float)superRows-0.25-di->yPos()/(float)gridHeight)
763  << " in\n";
764  }
765  }
766  }
767  else // multiple children, put them in a vertical list
768  {
769  if (bitmap)
770  {
771  x = di->parentItem()->xPos()*
772  (cellWidth+labelHorSpacing)/gridWidth+cellWidth/2;
773  if (doBase) // base classes
774  {
775  ys = image->getHeight()-
776  (superRows-1)*(cellHeight+labelVertSpacing)-
777  di->yPos()*(cellHeight+labelVertSpacing)/gridHeight;
778  y = ys - cellHeight/2;
779  }
780  else // super classes
781  {
782  ys = (baseRows-1)*(cellHeight+labelVertSpacing)+
783  di->yPos()*(cellHeight+labelVertSpacing)/gridHeight;
784  y = ys + cellHeight/2;
785  }
786  }
787  else
788  {
789  xf = di->parentItem()->xPos()/(float)gridWidth;
790  if (doBase)
791  {
792  ysf = di->yPos()/(float)gridHeight+superRows-1;
793  yf = ysf + 0.5f;
794  }
795  else
796  {
797  ysf = (float)superRows-0.25f-di->yPos()/(float)gridHeight;
798  yf = ysf - 0.25f;
799  }
800  }
801  while (di!=last) // more children to add
802  {
803  if (bitmap)
804  {
805  if (doBase) // base classes
806  {
807  image->drawHorzArrow(y,x,x+cellWidth/2+labelHorSpacing,
808  protToColor(di->protection()),
809  protToMask(di->protection()));
810  y -= cellHeight+labelVertSpacing;
811  }
812  else // super classes
813  {
814  image->drawHorzLine(y,x,x+cellWidth/2+labelHorSpacing,
815  protToColor(di->protection()),
816  protToMask(di->protection()));
817  y += cellHeight+labelVertSpacing;
818  }
819  }
820  else
821  {
822  t << protToString(di->protection()) << endl;
823  if (doBase)
824  {
825  t << "1 " << xf << " " << yf << " hedge\n";
826  yf += 1.0f;
827  }
828  else
829  {
830  t << "0 " << xf << " " << yf << " hedge\n";
831  yf -= 1.0f;
832  }
833  }
834  ++rit; di=rit.current();
835  }
836  // add last horizonal line and a vertical connection line
837  if (bitmap)
838  {
839  if (doBase) // base classes
840  {
841  image->drawHorzArrow(y,x,x+cellWidth/2+labelHorSpacing,
842  protToColor(di->protection()),
843  protToMask(di->protection()));
844  image->drawVertLine(x,y,ys+labelVertSpacing/2,
847  }
848  else // super classes
849  {
850  image->drawHorzLine(y,x,x+cellWidth/2+labelHorSpacing,
851  protToColor(di->protection()),
852  protToMask(di->protection()));
853  image->drawVertLine(x,ys-labelVertSpacing/2,y,
856  }
857  }
858  else
859  {
860  t << protToString(di->protection()) << endl;
861  if (doBase)
862  {
863  t << "1 " << xf << " " << yf << " hedge\n";
864  }
865  else
866  {
867  t << "0 " << xf << " " << yf << " hedge\n";
868  }
870  if (doBase)
871  {
872  t << xf << " " << ysf << " " << yf << " vedge\n";
873  }
874  else
875  {
876  t << xf << " " << (ysf + 0.25) << " " << yf << " vedge\n";
877  }
878  }
879  }
880  }
881  done=TRUE; // the tree is drawn now
882  }
883  else // normal tree connector
884  {
885  for (;(di=rit.current());++rit)
886  {
887  int x=0,y=0;
888  DiagramItemList *dil = di->getChildren();
889  DiagramItem *parent = di->parentItem();
890  if (parent) // item has a parent -> connect to it
891  {
892  if (bitmap) // draw pixels
893  {
894  x = di->xPos()*(cellWidth+labelHorSpacing)/gridWidth + cellWidth/2;
895  if (doBase) // base classes
896  {
897  y = image->getHeight()-
898  (superRows-1)*(cellHeight+labelVertSpacing)-
899  di->yPos()*(cellHeight+labelVertSpacing)/gridHeight;
900  /* write input line */
901  image->drawVertArrow(x,y,y+labelVertSpacing/2,
902  protToColor(di->protection()),
903  protToMask(di->protection()));
904  }
905  else // super classes
906  {
907  y = (baseRows-1)*(cellHeight+labelVertSpacing)-
909  di->yPos()*(cellHeight+labelVertSpacing)/gridHeight;
910  /* write output line */
911  image->drawVertLine(x,y,y+labelVertSpacing/2,
912  protToColor(di->protection()),
913  protToMask(di->protection()));
914  }
915  }
916  else // draw pixels
917  {
918  t << protToString(di->protection()) << endl;
919  if (doBase)
920  {
921  t << "1 " << di->xPos()/(float)gridWidth << " "
922  << (di->yPos()/(float)gridHeight+superRows-1) << " in\n";
923  }
924  else
925  {
926  t << "0 " << di->xPos()/(float)gridWidth << " "
927  << ((float)superRows-0.25-di->yPos()/(float)gridHeight)
928  << " in\n";
929  }
930  }
931  }
932  if (dil->count()>0)
933  {
935  uint mask=protToMask(p);
936  uint col=protToColor(p);
937  if (bitmap)
938  {
939  x = di->xPos()*(cellWidth+labelHorSpacing)/gridWidth + cellWidth/2;
940  if (doBase) // base classes
941  {
942  y = image->getHeight()-
943  (superRows-1)*(cellHeight+labelVertSpacing)-
944  cellHeight-labelVertSpacing/2-
945  di->yPos()*(cellHeight+labelVertSpacing)/gridHeight;
946  image->drawVertLine(x,y,y+labelVertSpacing/2-1,col,mask);
947  }
948  else // super classes
949  {
950  y = (baseRows-1)*(cellHeight+labelVertSpacing)+
951  cellHeight+
952  di->yPos()*(cellHeight+labelVertSpacing)/gridHeight;
953  image->drawVertArrow(x,y,y+labelVertSpacing/2-1,col,mask);
954  }
955  }
956  else
957  {
958  t << protToString(p) << endl;
959  if (doBase)
960  {
961  t << "0 " << di->xPos()/(float)gridWidth << " "
962  << (di->yPos()/(float)gridHeight+superRows-1) << " out\n";
963  }
964  else
965  {
966  t << "1 " << di->xPos()/(float)gridWidth << " "
967  << ((float)superRows-1.75-di->yPos()/(float)gridHeight)
968  << " out\n";
969  }
970  }
971  /* write input line */
972  DiagramItem *first = dil->getFirst();
973  DiagramItem *last = dil->getLast();
974  if (first!=last && !first->isInList()) /* connect with all base classes */
975  {
976  if (bitmap)
977  {
978  int xs = first->xPos()*(cellWidth+labelHorSpacing)/gridWidth
979  + cellWidth/2;
980  int xe = last->xPos()*(cellWidth+labelHorSpacing)/gridWidth
981  + cellWidth/2;
982  if (doBase) // base classes
983  {
984  image->drawHorzLine(y,xs,xe,col,mask);
985  }
986  else // super classes
987  {
988  image->drawHorzLine(y+labelVertSpacing/2,xs,xe,col,mask);
989  }
990  }
991  else
992  {
993  t << protToString(p) << endl;
994  if (doBase)
995  {
996  t << first->xPos()/(float)gridWidth << " "
997  << last->xPos()/(float)gridWidth << " "
998  << (first->yPos()/(float)gridHeight+superRows-1)
999  << " conn\n";
1000  }
1001  else
1002  {
1003  t << first->xPos()/(float)gridWidth << " "
1004  << last->xPos()/(float)gridWidth << " "
1005  << ((float)superRows-first->yPos()/(float)gridHeight)
1006  << " conn\n";
1007  }
1008  }
1009  }
1010  }
1011  }
1012  }
1013  }
1014 }
uint getHeight() const
Definition: image.h:43
static uint protToColor(Protection p)
Definition: diagram.cpp:174
int yPos() const
Definition: diagram.cpp:54
int xPos() const
Definition: diagram.cpp:53
void drawHorzArrow(int y, int xs, int xe, uchar colIndex, uint mask)
Definition: image.cpp:335
static Protection getMinProtectionLevel(DiagramItemList *dil)
Definition: diagram.cpp:210
void drawHorzLine(int y, int xs, int xe, uchar colIndex, uint mask)
Definition: image.cpp:325
Protection protection() const
Definition: diagram.cpp:59
bool isInList() const
Definition: diagram.cpp:62
const bool FALSE
Definition: qglobal.h:370
const int gridHeight
Definition: diagram.cpp:143
DiagramItem * parentItem()
Definition: diagram.cpp:50
QCollection::Item first()
Definition: qglist.cpp:807
uint count() const
Definition: qlist.h:66
static QCString protToString(Protection p)
Definition: diagram.cpp:186
type * getLast() const
Definition: qlist.h:96
const uint labelHorSpacing
Definition: diagram.cpp:145
p
Definition: test.py:223
type * getFirst() const
Definition: qlist.h:95
DiagramItemList * getChildren()
Definition: diagram.cpp:51
void drawVertArrow(int x, int ys, int ye, uchar colIndex, uint mask)
Definition: image.cpp:355
void drawVertLine(int x, int ys, int ye, uchar colIndex, uint mask)
Definition: image.cpp:346
Protection
Definition: types.h:26
list x
Definition: train.py:276
static uint protToMask(Protection p)
Definition: diagram.cpp:162
float pi
Definition: units.py:11
static constexpr double ys
Definition: Units.h:103
QCollection::Item last()
Definition: qglist.cpp:821
const int gridWidth
Definition: diagram.cpp:142
unsigned uint
Definition: qglobal.h:351
def parent(G, child, parent_type)
Definition: graph.py:67
const bool TRUE
Definition: qglobal.h:371
const uint labelVertSpacing
Definition: diagram.cpp:146
QTextStream & endl(QTextStream &s)
bool TreeDiagram::layoutTree ( DiagramItem root,
int  row 
)
private

Definition at line 434 of file diagram.cpp.

435 {
436  bool moved=FALSE;
437  //printf("layoutTree(%s,%d)\n",root->label().data(),r);
438 
439  DiagramItemList *dil=root->getChildren();
440  if (dil->count()>0)
441  {
442  uint k;
443  int pPos=root->xPos();
444  int cPos=root->avgChildPos();
445  if (pPos>cPos) // move children
446  {
447  DiagramRow *row=at(r+1);
448  //printf("Moving children %d-%d in row %d\n",
449  // dil->getFirst()->number(),row->count()-1,r+1);
450  for (k=dil->getFirst()->number();k<row->count();k++)
451  row->at(k)->move(pPos-cPos,0);
452  moved=TRUE;
453  }
454  else if (pPos<cPos) // move parent
455  {
456  DiagramRow *row=at(r);
457  //printf("Moving parents %d-%d in row %d\n",
458  // root->number(),row->count()-1,r);
459  for (k=root->number();k<row->count();k++)
460  row->at(k)->move(cPos-pPos,0);
461  moved=TRUE;
462  }
463 
464  // recurse to children
466  DiagramItem *di;
467  for (;(di=it.current()) && !moved && !di->isInList();++it)
468  {
469  moved = layoutTree(di,r+1);
470  }
471  }
472  return moved;
473 }
void move(int dx, int dy)
Definition: diagram.cpp:52
int xPos() const
Definition: diagram.cpp:53
bool isInList() const
Definition: diagram.cpp:62
const bool FALSE
Definition: qglobal.h:370
int number() const
Definition: diagram.cpp:58
type * at(uint i) const
Definition: qlist.h:94
int avgChildPos() const
Definition: diagram.cpp:333
uint count() const
Definition: qlist.h:66
int at() const
Definition: qglist.h:167
type * getFirst() const
Definition: qlist.h:95
DiagramItemList * getChildren()
Definition: diagram.cpp:51
bool layoutTree(DiagramItem *root, int row)
Definition: diagram.cpp:434
unsigned uint
Definition: qglobal.h:351
const bool TRUE
Definition: qglobal.h:371
void TreeDiagram::moveChildren ( DiagramItem root,
int  dx 
)

Definition at line 422 of file diagram.cpp.

423 {
424  DiagramItemList *dil=root->getChildren();
426  DiagramItem *di;
427  for (;(di=it.current());++it)
428  {
429  di->move(dx,0);
430  moveChildren(di,dx);
431  }
432 }
void move(int dx, int dy)
Definition: diagram.cpp:52
DiagramItemList * getChildren()
Definition: diagram.cpp:51
void moveChildren(DiagramItem *root, int dx)
Definition: diagram.cpp:422
TreeDiagram& TreeDiagram::operator= ( const TreeDiagram )
private

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