|
1 /****************************************************************************** |
|
2 * |
|
3 * |
|
4 * |
|
5 * |
|
6 * Copyright (C) 1997-2008 by Dimitri van Heesch. |
|
7 * |
|
8 * Permission to use, copy, modify, and distribute this software and its |
|
9 * documentation under the terms of the GNU General Public License is hereby |
|
10 * granted. No representations are made about the suitability of this software |
|
11 * for any purpose. It is provided "as is" without express or implied warranty. |
|
12 * See the GNU General Public License for more details. |
|
13 * |
|
14 * Documents produced by Doxygen are derivative works derived from the |
|
15 * input used in their production; they are not affected by this license. |
|
16 * |
|
17 */ |
|
18 |
|
19 #include "qtbc.h" |
|
20 #include "entry.h" |
|
21 |
|
22 class ClassDef; |
|
23 class DiagramRow; |
|
24 class TreeDiagram; |
|
25 class ClassDiagram; |
|
26 class DiagramItemList; |
|
27 class Image; |
|
28 |
|
29 class DiagramItem |
|
30 { |
|
31 public: |
|
32 DiagramItem(DiagramItem *p,int number,ClassDef *cd, |
|
33 Protection prot,Specifier virt,const char *ts); |
|
34 ~DiagramItem(); |
|
35 QCString label() const; |
|
36 QCString fileName() const; |
|
37 DiagramItem *parentItem() { return parent; } |
|
38 DiagramItemList *getChildren() { return children; } |
|
39 void move(int dx,int dy) { x+=dx; y+=dy; } |
|
40 int xPos() const { return x; } |
|
41 int yPos() const { return y; } |
|
42 int avgChildPos() const; |
|
43 int numChildren() const; |
|
44 void addChild(DiagramItem *di); |
|
45 int number() const { return num; } |
|
46 Protection protection() const { return prot; } |
|
47 Specifier virtualness() const { return virt; } |
|
48 void putInList() { inList=TRUE; } |
|
49 bool isInList() const { return inList; } |
|
50 ClassDef *getClassDef() const { return classDef; } |
|
51 private: |
|
52 DiagramItemList *children; |
|
53 DiagramItem *parent; |
|
54 int x,y; |
|
55 int num; |
|
56 Protection prot; |
|
57 Specifier virt; |
|
58 QCString templSpec; |
|
59 bool inList; |
|
60 ClassDef *classDef; |
|
61 }; |
|
62 |
|
63 class DiagramItemList : public QList<DiagramItem> |
|
64 { |
|
65 public: |
|
66 DiagramItemList() : QList<DiagramItem>() {} |
|
67 ~DiagramItemList() {} |
|
68 }; |
|
69 |
|
70 class DiagramRow : public QList<DiagramItem> |
|
71 { |
|
72 public: |
|
73 DiagramRow(TreeDiagram *d,int l) : QList<DiagramItem>() |
|
74 { |
|
75 diagram=d; |
|
76 level=l; |
|
77 setAutoDelete(TRUE); |
|
78 } |
|
79 void insertClass(DiagramItem *parent,ClassDef *cd,bool doBases, |
|
80 Protection prot,Specifier virt,const char *ts); |
|
81 uint number() { return level; } |
|
82 private: |
|
83 TreeDiagram *diagram; |
|
84 uint level; |
|
85 }; |
|
86 |
|
87 class DiagramRowIterator : public QListIterator<DiagramRow> |
|
88 { |
|
89 public: |
|
90 DiagramRowIterator(const QList<DiagramRow> &d) |
|
91 : QListIterator<DiagramRow>(d) {} |
|
92 }; |
|
93 |
|
94 class TreeDiagram : public QList<DiagramRow> |
|
95 { |
|
96 public: |
|
97 TreeDiagram(ClassDef *root,bool doBases); |
|
98 ~TreeDiagram(); |
|
99 void computeLayout(); |
|
100 uint computeRows(); |
|
101 //uint computeCols(); |
|
102 void moveChildren(DiagramItem *root,int dx); |
|
103 void computeExtremes(uint *labelWidth,uint *xpos); |
|
104 void drawBoxes(QTextStream &t,Image *image, |
|
105 bool doBase,bool bitmap, |
|
106 uint baseRows,uint superRows, |
|
107 uint cellWidth,uint cellHeight, |
|
108 QCString relPath="", |
|
109 bool generateMap=TRUE); |
|
110 void drawConnectors(QTextStream &t,Image *image, |
|
111 bool doBase,bool bitmap, |
|
112 uint baseRows,uint superRows, |
|
113 uint cellWidth,uint cellheight); |
|
114 private: |
|
115 bool layoutTree(DiagramItem *root,int row); |
|
116 TreeDiagram &operator=(const TreeDiagram &); |
|
117 TreeDiagram(const TreeDiagram &); |
|
118 }; |
|
119 |
|
120 class ClassDiagram |
|
121 { |
|
122 public: |
|
123 ClassDiagram(ClassDef *root); |
|
124 ~ClassDiagram(); |
|
125 void writeFigure(QTextStream &t,const char *path, |
|
126 const char *file) const; |
|
127 void writeImage(QTextStream &t,const char *path,const char *relPath, |
|
128 const char *file,bool generateMap=TRUE) const; |
|
129 private: |
|
130 TreeDiagram *base; |
|
131 TreeDiagram *super; |
|
132 }; |