diagram.h

Go to the documentation of this file.
00001 /******************************************************************************
00002  *
00003  * $Id: diagram.h,v 1.11 2001/03/19 19:27:40 root Exp $
00004  *
00005  *
00006  * Copyright (C) 1997-2008 by Dimitri van Heesch.
00007  *
00008  * Permission to use, copy, modify, and distribute this software and its
00009  * documentation under the terms of the GNU General Public License is hereby 
00010  * granted. No representations are made about the suitability of this software 
00011  * for any purpose. It is provided "as is" without express or implied warranty.
00012  * See the GNU General Public License for more details.
00013  *
00014  * Documents produced by Doxygen are derivative works derived from the
00015  * input used in their production; they are not affected by this license.
00016  *
00017  */
00018 
00019 #include "qtbc.h"
00020 #include "entry.h"
00021 
00022 class ClassDef;
00023 class DiagramRow;
00024 class TreeDiagram;
00025 class ClassDiagram;
00026 class DiagramItemList;
00027 class Image;
00028 
00029 class DiagramItem 
00030 {
00031   public:
00032     DiagramItem(DiagramItem *p,int number,ClassDef *cd,
00033                 Protection prot,Specifier virt,const char *ts);
00034    ~DiagramItem();
00035     QCString label() const;
00036     QCString fileName() const;
00037     DiagramItem *parentItem() { return parent; } 
00038     DiagramItemList *getChildren() { return children; }
00039     void move(int dx,int dy) { x+=dx; y+=dy; }
00040     int xPos() const { return x; }
00041     int yPos() const { return y; }
00042     int avgChildPos() const;
00043     int numChildren() const;
00044     void addChild(DiagramItem *di);
00045     int number() const { return num; }
00046     Protection protection() const { return prot; }
00047     Specifier virtualness() const { return virt; }
00048     void putInList() { inList=TRUE; }
00049     bool isInList() const { return inList; } 
00050     ClassDef *getClassDef() const { return classDef; }
00051   private:
00052     DiagramItemList *children;
00053     DiagramItem *parent;
00054     int x,y;
00055     int num;
00056     Protection prot;
00057     Specifier virt;
00058     QCString templSpec;
00059     bool inList;
00060     ClassDef *classDef;
00061 };
00062 
00063 class DiagramItemList : public QList<DiagramItem>
00064 {
00065   public:
00066     DiagramItemList() : QList<DiagramItem>() {}
00067    ~DiagramItemList() {}
00068 };
00069 
00070 class DiagramRow : public QList<DiagramItem> 
00071 {
00072   public:
00073     DiagramRow(TreeDiagram *d,int l) : QList<DiagramItem>() 
00074     { 
00075       diagram=d; 
00076       level=l;
00077       setAutoDelete(TRUE); 
00078     }
00079     void insertClass(DiagramItem *parent,ClassDef *cd,bool doBases,
00080                      Protection prot,Specifier virt,const char *ts);
00081     uint number() { return level; }
00082   private:
00083     TreeDiagram *diagram;
00084     uint level;
00085 };
00086 
00087 class DiagramRowIterator : public QListIterator<DiagramRow>
00088 {
00089   public:
00090     DiagramRowIterator(const QList<DiagramRow> &d) 
00091       : QListIterator<DiagramRow>(d) {}
00092 };
00093 
00094 class TreeDiagram : public QList<DiagramRow>
00095 {
00096   public:
00097     TreeDiagram(ClassDef *root,bool doBases);
00098    ~TreeDiagram();
00099     void computeLayout();
00100     uint computeRows();
00101     //uint computeCols();
00102     void moveChildren(DiagramItem *root,int dx);
00103     void computeExtremes(uint *labelWidth,uint *xpos);
00104     void drawBoxes(QTextStream &t,Image *image,
00105                    bool doBase,bool bitmap,
00106                    uint baseRows,uint superRows,
00107                    uint cellWidth,uint cellHeight,
00108                    QCString relPath="",
00109                    bool generateMap=TRUE);
00110     void drawConnectors(QTextStream &t,Image *image,
00111                    bool doBase,bool bitmap,
00112                    uint baseRows,uint superRows,
00113                    uint cellWidth,uint cellheight);
00114   private:
00115     bool layoutTree(DiagramItem *root,int row);
00116     TreeDiagram &operator=(const TreeDiagram &);
00117     TreeDiagram(const TreeDiagram &);
00118 };
00119 
00120 class ClassDiagram
00121 {
00122   public:
00123     ClassDiagram(ClassDef *root);
00124    ~ClassDiagram();
00125     void writeFigure(QTextStream &t,const char *path,
00126                      const char *file) const;
00127     void writeImage(QTextStream &t,const char *path,const char *relPath,
00128                      const char *file,bool generateMap=TRUE) const;
00129   private:
00130     TreeDiagram *base;
00131     TreeDiagram *super;
00132 };



Generated on Mon Mar 31 10:58:34 2008 by  doxygen 1.5.1