diff options
Diffstat (limited to 'src/diagram.cpp')
-rw-r--r-- | src/diagram.cpp | 528 |
1 files changed, 265 insertions, 263 deletions
diff --git a/src/diagram.cpp b/src/diagram.cpp index 80c85c6..0f20636 100644 --- a/src/diagram.cpp +++ b/src/diagram.cpp @@ -15,10 +15,8 @@ #include <stdio.h> #include <stdlib.h> -#include <qlist.h> -#include <qarray.h> -#include "ftextstream.h" -#include <qfile.h> +#include <fstream> +#include <algorithm> #include "diagram.h" #include "image.h" @@ -30,6 +28,7 @@ #include "portable.h" #include "index.h" #include "classlist.h" +#include "textstream.h" //----------------------------------------------------------------------------- @@ -42,7 +41,7 @@ class DiagramItem { public: DiagramItem(DiagramItem *p,uint number,const ClassDef *cd, - Protection prot,Specifier virt,const char *ts); + Protection prot,Specifier virt,const QCString &ts); QCString label() const; QCString fileName() const; DiagramItem *parentItem() { return m_parent; } @@ -82,7 +81,7 @@ class DiagramRow using reverse_iterator = typename Vec::reverse_iterator; DiagramRow(TreeDiagram *d,uint l) : m_diagram(d), m_level(l) {} void insertClass(DiagramItem *parent,const ClassDef *cd,bool doBases, - Protection prot,Specifier virt,const char *ts); + Protection prot,Specifier virt,const QCString &ts); uint number() { return m_level; } DiagramItem *item(int index) { return m_items.at(index).get(); } @@ -109,13 +108,13 @@ class TreeDiagram uint computeRows(); void moveChildren(DiagramItem *root,int dx); void computeExtremes(uint *labelWidth,uint *xpos); - void drawBoxes(FTextStream &t,Image *image, + void drawBoxes(TextStream &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, + void drawConnectors(TextStream &t,Image *image, bool doBase,bool bitmap, uint baseRows,uint superRows, uint cellWidth,uint cellheight); @@ -178,7 +177,7 @@ static QCString protToString(Protection p) case Protected: return "dashed"; case Private: return "dotted"; } - return 0; + return QCString(); } static uint virtToMask(Specifier p) @@ -234,7 +233,7 @@ static void writeBitmapBox(DiagramItem *di,Image *image, } } -static void writeVectorBox(FTextStream &t,DiagramItem *di, +static void writeVectorBox(TextStream &t,DiagramItem *di, float x,float y,bool children=FALSE) { if (di->virtualness()==Virtual) t << "dashed\n"; @@ -243,7 +242,7 @@ static void writeVectorBox(FTextStream &t,DiagramItem *di, if (di->virtualness()==Virtual) t << "solid\n"; } -static void writeMapArea(FTextStream &t,const ClassDef *cd,QCString relPath, +static void writeMapArea(TextStream &t,const ClassDef *cd,QCString relPath, uint x,uint y,uint w,uint h) { if (cd->isLinkable()) @@ -269,13 +268,13 @@ static void writeMapArea(FTextStream &t,const ClassDef *cd,QCString relPath, } t << "alt=\"" << convertToXML(cd->displayName()); t << "\" shape=\"rect\" coords=\"" << x << "," << y << ","; - t << (x+w) << "," << (y+h) << "\"/>" << endl; + t << (x+w) << "," << (y+h) << "\"/>\n"; } } //----------------------------------------------------------------------------- DiagramItem::DiagramItem(DiagramItem *p,uint number,const ClassDef *cd, - Protection pr,Specifier vi,const char *ts) + Protection pr,Specifier vi,const QCString &ts) : m_parent(p), m_num(number), m_prot(pr), m_virt(vi), m_templSpec(ts), m_classDef(cd) { } @@ -334,7 +333,7 @@ void DiagramItem::addChild(DiagramItem *di) //--------------------------------------------------------------------------- void DiagramRow::insertClass(DiagramItem *parent,const ClassDef *cd,bool doBases, - Protection prot,Specifier virt,const char *ts) + Protection prot,Specifier virt,const QCString &ts) { auto di = std::make_unique<DiagramItem>(parent, m_diagram->row(m_level)->numItems(), cd,prot,virt,ts); @@ -367,7 +366,7 @@ void DiagramRow::insertClass(DiagramItem *parent,const ClassDef *cd,bool doBases { row->insertClass(di_ptr,ccd,doBases,bcd.prot, doBases?bcd.virt:Normal, - doBases?bcd.templSpecifiers.data():""); + doBases?bcd.templSpecifiers:QCString()); } } } @@ -380,7 +379,7 @@ TreeDiagram::TreeDiagram(const ClassDef *root,bool doBases) auto row = std::make_unique<DiagramRow>(this,0); DiagramRow *row_ptr = row.get(); m_rows.push_back(std::move(row)); - row_ptr->insertClass(0,root,doBases,Public,Normal,0); + row_ptr->insertClass(0,root,doBases,Public,Normal,QCString()); } void TreeDiagram::moveChildren(DiagramItem *root,int dx) @@ -395,7 +394,7 @@ void TreeDiagram::moveChildren(DiagramItem *root,int dx) bool TreeDiagram::layoutTree(DiagramItem *root,uint r) { bool moved=FALSE; - //printf("layoutTree(%s,%d)\n",root->label().data(),r); + //printf("layoutTree(%s,%d)\n",qPrint(root->label()),r); if (root->numChildren()>0) { @@ -522,8 +521,8 @@ void TreeDiagram::computeExtremes(uint *maxLabelLen,uint *maxXPos) for (const auto &di : *dr) // for each item in a row { if (di->isInList()) done=TRUE; - if (maxXPos) mx=QMAX(mx,(uint)di->xPos()); - if (maxLabelLen) ml=QMAX(ml,Image::stringLength(di->label())); + if (maxXPos) mx=std::max(mx,(uint)di->xPos()); + if (maxLabelLen) ml=std::max(ml,Image::stringLength(di->label())); } if (done) break; } @@ -566,7 +565,7 @@ class DualDirIterator typename C::reverse_iterator m_rit; }; -void TreeDiagram::drawBoxes(FTextStream &t,Image *image, +void TreeDiagram::drawBoxes(TextStream &t,Image *image, bool doBase,bool bitmap, uint baseRows,uint superRows, uint cellWidth,uint cellHeight, @@ -696,7 +695,7 @@ void TreeDiagram::drawBoxes(FTextStream &t,Image *image, } } -void TreeDiagram::drawConnectors(FTextStream &t,Image *image, +void TreeDiagram::drawConnectors(TextStream &t,Image *image, bool doBase,bool bitmap, uint baseRows,uint superRows, uint cellWidth,uint cellHeight) @@ -744,7 +743,7 @@ void TreeDiagram::drawConnectors(FTextStream &t,Image *image, } else // draw vectors { - t << protToString(di->protection()) << endl; + t << protToString(di->protection()) << "\n"; if (doBase) { t << "1 " << (di->xPos()/(float)gridWidth) << " " @@ -813,7 +812,7 @@ void TreeDiagram::drawConnectors(FTextStream &t,Image *image, } else { - t << protToString(di->protection()) << endl; + t << protToString(di->protection()) << "\n"; if (doBase) { t << "1 " << xf << " " << yf << " hedge\n"; @@ -852,7 +851,7 @@ void TreeDiagram::drawConnectors(FTextStream &t,Image *image, } else { - t << protToString(di->protection()) << endl; + t << protToString(di->protection()) << "\n"; if (doBase) { t << "1 " << xf << " " << yf << " hedge\n"; @@ -861,7 +860,7 @@ void TreeDiagram::drawConnectors(FTextStream &t,Image *image, { t << "0 " << xf << " " << yf << " hedge\n"; } - t << protToString(getMinProtectionLevel(dil)) << endl; + t << protToString(getMinProtectionLevel(dil)) << "\n"; if (doBase) { t << xf << " " << ysf << " " << yf << " vedge\n"; @@ -911,7 +910,7 @@ void TreeDiagram::drawConnectors(FTextStream &t,Image *image, } else // draw pixels { - t << protToString(di->protection()) << endl; + t << protToString(di->protection()) << "\n"; if (doBase) { t << "1 " << di->xPos()/(float)gridWidth << " " @@ -951,7 +950,7 @@ void TreeDiagram::drawConnectors(FTextStream &t,Image *image, } else { - t << protToString(p) << endl; + t << protToString(p) << "\n"; if (doBase) { t << "0 " << di->xPos()/(float)gridWidth << " " @@ -986,7 +985,7 @@ void TreeDiagram::drawConnectors(FTextStream &t,Image *image, } else { - t << protToString(p) << endl; + t << protToString(p) << "\n"; if (doBase) { t << first->xPos()/(float)gridWidth << " " @@ -1045,8 +1044,8 @@ ClassDiagram::~ClassDiagram() { } -void ClassDiagram::writeFigure(FTextStream &output,const char *path, - const char *fileName) const +void ClassDiagram::writeFigure(TextStream &output,const QCString &path, + const QCString &fileName) const { uint baseRows=p->base.computeRows(); uint superRows=p->super.computeRows(); @@ -1054,12 +1053,12 @@ void ClassDiagram::writeFigure(FTextStream &output,const char *path, p->base.computeExtremes(&baseMaxLabelWidth,&baseMaxX); p->super.computeExtremes(&superMaxLabelWidth,&superMaxX); - uint rows=QMAX(1,baseRows+superRows-1); - uint cols=(QMAX(baseMaxX,superMaxX)+gridWidth*2-1)/gridWidth; + uint rows=std::max(1u,baseRows+superRows-1); + uint cols=(std::max(baseMaxX,superMaxX)+gridWidth*2-1)/gridWidth; // Estimate the image aspect width and height in pixels. uint estHeight = rows*40; - uint estWidth = cols*(20+QMAX(baseMaxLabelWidth,superMaxLabelWidth)); + uint estWidth = cols*(20+std::max(baseMaxLabelWidth,superMaxLabelWidth)); //printf("Estimated size %d x %d\n",estWidth,estHeight); const float pageWidth = 14.0f; // estimated page width in cm. @@ -1067,8 +1066,8 @@ void ClassDiagram::writeFigure(FTextStream &output,const char *path, // errors. // compute the image height in centimeters based on the estimates - float realHeight = QMIN(rows,12); // real height in cm - float realWidth = realHeight * estWidth/(float)estHeight; + float realHeight = static_cast<float>(std::min(rows,12u)); // real height in cm + float realWidth = realHeight * estWidth/static_cast<float>(estHeight); if (realWidth>pageWidth) // assume that the page width is about 15 cm { realHeight*=pageWidth/realWidth; @@ -1080,7 +1079,7 @@ void ClassDiagram::writeFigure(FTextStream &output,const char *path, "\\begin{center}\n" "\\leavevmode\n"; output << "\\includegraphics[height=" << realHeight << "cm]{" - << fileName << "}" << endl; + << fileName << "}\n"; output << "\\end{center}\n" "\\end{figure}\n"; @@ -1088,244 +1087,247 @@ void ClassDiagram::writeFigure(FTextStream &output,const char *path, QCString epsBaseName=(QCString)path+"/"+fileName; QCString epsName=epsBaseName+".eps"; - QFile f1; - f1.setName(epsName.data()); - if (!f1.open(IO_WriteOnly)) + std::ofstream f(epsName.str(),std::ofstream::out | std::ofstream::binary); + if (!f.is_open()) { - term("Could not open file %s for writing\n",f1.name().data()); + term("Could not open file %s for writing\n",qPrint(epsName)); } - FTextStream t(&f1); - - //printf("writeEPS() rows=%d cols=%d\n",rows,cols); - - // generate EPS header and postscript variables and procedures - - t << "%!PS-Adobe-2.0 EPSF-2.0\n"; - t << "%%Title: ClassName\n"; - t << "%%Creator: Doxygen\n"; - t << "%%CreationDate: Time\n"; - t << "%%For: \n"; - t << "%Magnification: 1.00\n"; - t << "%%Orientation: Portrait\n"; - t << "%%BoundingBox: 0 0 500 " << estHeight*500.0f/(float)estWidth << "\n"; - t << "%%Pages: 0\n"; - t << "%%BeginSetup\n"; - t << "%%EndSetup\n"; - t << "%%EndComments\n"; - t << "\n"; - t << "% ----- variables -----\n"; - t << "\n"; - t << "/boxwidth 0 def\n"; - t << "/boxheight 40 def\n"; - t << "/fontheight 24 def\n"; - t << "/marginwidth 10 def\n"; - t << "/distx 20 def\n"; - t << "/disty 40 def\n"; - t << "/boundaspect " << estWidth/(float)estHeight << " def % aspect ratio of the BoundingBox (width/height)\n"; - t << "/boundx 500 def\n"; - t << "/boundy boundx boundaspect div def\n"; - t << "/xspacing 0 def\n"; - t << "/yspacing 0 def\n"; - t << "/rows " << rows << " def\n"; - t << "/cols " << cols << " def\n"; - t << "/scalefactor 0 def\n"; - t << "/boxfont /Times-Roman findfont fontheight scalefont def\n"; - t << "\n"; - t << "% ----- procedures -----\n"; - t << "\n"; - t << "/dotted { [1 4] 0 setdash } def\n"; - t << "/dashed { [5] 0 setdash } def\n"; - t << "/solid { [] 0 setdash } def\n"; - t << "\n"; - t << "/max % result = MAX(arg1,arg2)\n"; - t << "{\n"; - t << " /a exch def\n"; - t << " /b exch def\n"; - t << " a b gt {a} {b} ifelse\n"; - t << "} def\n"; - t << "\n"; - t << "/xoffset % result = MAX(0,(scalefactor-(boxwidth*cols+distx*(cols-1)))/2)\n"; - t << "{\n"; - t << " 0 scalefactor boxwidth cols mul distx cols 1 sub mul add sub 2 div max\n"; - t << "} def\n"; - t << "\n"; - t << "/cw % boxwidth = MAX(boxwidth, stringwidth(arg1))\n"; - t << "{\n"; - t << " /str exch def\n"; - t << " /boxwidth boxwidth str stringwidth pop max def\n"; - t << "} def\n"; - t << "\n"; - t << "/box % draws a box with text 'arg1' at grid pos (arg2,arg3)\n"; - t << "{ gsave\n"; - t << " 2 setlinewidth\n"; - t << " newpath\n"; - t << " exch xspacing mul xoffset add\n"; - t << " exch yspacing mul\n"; - t << " moveto\n"; - t << " boxwidth 0 rlineto \n"; - t << " 0 boxheight rlineto \n"; - t << " boxwidth neg 0 rlineto \n"; - t << " 0 boxheight neg rlineto \n"; - t << " closepath\n"; - t << " dup stringwidth pop neg boxwidth add 2 div\n"; - t << " boxheight fontheight 2 div sub 2 div\n"; - t << " rmoveto show stroke\n"; - t << " grestore\n"; - t << "} def \n"; - t << "\n"; - t << "/mark\n"; - t << "{ newpath\n"; - t << " exch xspacing mul xoffset add boxwidth add\n"; - t << " exch yspacing mul\n"; - t << " moveto\n"; - t << " 0 boxheight 4 div rlineto\n"; - t << " boxheight neg 4 div boxheight neg 4 div rlineto\n"; - t << " closepath\n"; - t << " eofill\n"; - t << " stroke\n"; - t << "} def\n"; - t << "\n"; - t << "/arrow\n"; - t << "{ newpath\n"; - t << " moveto\n"; - t << " 3 -8 rlineto\n"; - t << " -6 0 rlineto\n"; - t << " 3 8 rlineto\n"; - t << " closepath\n"; - t << " eofill\n"; - t << " stroke\n"; - t << "} def\n"; - t << "\n"; - t << "/out % draws an output connector for the block at (arg1,arg2)\n"; - t << "{\n"; - t << " newpath\n"; - t << " exch xspacing mul xoffset add boxwidth 2 div add\n"; - t << " exch yspacing mul boxheight add\n"; - t << " /y exch def\n"; - t << " /x exch def\n"; - t << " x y moveto\n"; - t << " 0 disty 2 div rlineto \n"; - t << " stroke\n"; - t << " 1 eq { x y disty 2 div add arrow } if\n"; - t << "} def\n"; - t << "\n"; - t << "/in % draws an input connector for the block at (arg1,arg2)\n"; - t << "{\n"; - t << " newpath\n"; - t << " exch xspacing mul xoffset add boxwidth 2 div add\n"; - t << " exch yspacing mul disty 2 div sub\n"; - t << " /y exch def\n"; - t << " /x exch def\n"; - t << " x y moveto\n"; - t << " 0 disty 2 div rlineto\n"; - t << " stroke\n"; - t << " 1 eq { x y disty 2 div add arrow } if\n"; - t << "} def\n"; - t << "\n"; - t << "/hedge\n"; - t << "{\n"; - t << " exch xspacing mul xoffset add boxwidth 2 div add\n"; - t << " exch yspacing mul boxheight 2 div sub\n"; - t << " /y exch def\n"; - t << " /x exch def\n"; - t << " newpath\n"; - t << " x y moveto\n"; - t << " boxwidth 2 div distx add 0 rlineto\n"; - t << " stroke\n"; - t << " 1 eq\n"; - t << " { newpath x boxwidth 2 div distx add add y moveto\n"; - t << " -8 3 rlineto\n"; - t << " 0 -6 rlineto\n"; - t << " 8 3 rlineto\n"; - t << " closepath\n"; - t << " eofill\n"; - t << " stroke\n"; - t << " } if\n"; - t << "} def\n"; - t << "\n"; - t << "/vedge\n"; - t << "{\n"; - t << " /ye exch def\n"; - t << " /ys exch def\n"; - t << " /xs exch def\n"; - t << " newpath\n"; - t << " xs xspacing mul xoffset add boxwidth 2 div add dup\n"; - t << " ys yspacing mul boxheight 2 div sub\n"; - t << " moveto\n"; - t << " ye yspacing mul boxheight 2 div sub\n"; - t << " lineto\n"; - t << " stroke\n"; - t << "} def\n"; - t << "\n"; - t << "/conn % connections the blocks from col 'arg1' to 'arg2' of row 'arg3'\n"; - t << "{\n"; - t << " /ys exch def\n"; - t << " /xe exch def\n"; - t << " /xs exch def\n"; - t << " newpath\n"; - t << " xs xspacing mul xoffset add boxwidth 2 div add\n"; - t << " ys yspacing mul disty 2 div sub\n"; - t << " moveto\n"; - t << " xspacing xe xs sub mul 0\n"; - t << " rlineto\n"; - t << " stroke\n"; - t << "} def\n"; - t << "\n"; - t << "% ----- main ------\n"; - t << "\n"; - t << "boxfont setfont\n"; - t << "1 boundaspect scale\n"; - - - for (const auto &dr : p->base) + else { - bool done=FALSE; - for (const auto &di : *dr) + TextStream t(&f); + + //printf("writeEPS() rows=%d cols=%d\n",rows,cols); + + // generate EPS header and postscript variables and procedures + + t << "%!PS-Adobe-2.0 EPSF-2.0\n"; + t << "%%Title: ClassName\n"; + t << "%%Creator: Doxygen\n"; + t << "%%CreationDate: Time\n"; + t << "%%For: \n"; + t << "%Magnification: 1.00\n"; + t << "%%Orientation: Portrait\n"; + t << "%%BoundingBox: 0 0 500 " << estHeight*500.0f/(float)estWidth << "\n"; + t << "%%Pages: 0\n"; + t << "%%BeginSetup\n"; + t << "%%EndSetup\n"; + t << "%%EndComments\n"; + t << "\n"; + t << "% ----- variables -----\n"; + t << "\n"; + t << "/boxwidth 0 def\n"; + t << "/boxheight 40 def\n"; + t << "/fontheight 24 def\n"; + t << "/marginwidth 10 def\n"; + t << "/distx 20 def\n"; + t << "/disty 40 def\n"; + t << "/boundaspect " << estWidth/(float)estHeight << " def % aspect ratio of the BoundingBox (width/height)\n"; + t << "/boundx 500 def\n"; + t << "/boundy boundx boundaspect div def\n"; + t << "/xspacing 0 def\n"; + t << "/yspacing 0 def\n"; + t << "/rows " << rows << " def\n"; + t << "/cols " << cols << " def\n"; + t << "/scalefactor 0 def\n"; + t << "/boxfont /Times-Roman findfont fontheight scalefont def\n"; + t << "\n"; + t << "% ----- procedures -----\n"; + t << "\n"; + t << "/dotted { [1 4] 0 setdash } def\n"; + t << "/dashed { [5] 0 setdash } def\n"; + t << "/solid { [] 0 setdash } def\n"; + t << "\n"; + t << "/max % result = MAX(arg1,arg2)\n"; + t << "{\n"; + t << " /a exch def\n"; + t << " /b exch def\n"; + t << " a b gt {a} {b} ifelse\n"; + t << "} def\n"; + t << "\n"; + t << "/xoffset % result = MAX(0,(scalefactor-(boxwidth*cols+distx*(cols-1)))/2)\n"; + t << "{\n"; + t << " 0 scalefactor boxwidth cols mul distx cols 1 sub mul add sub 2 div max\n"; + t << "} def\n"; + t << "\n"; + t << "/cw % boxwidth = MAX(boxwidth, stringwidth(arg1))\n"; + t << "{\n"; + t << " /str exch def\n"; + t << " /boxwidth boxwidth str stringwidth pop max def\n"; + t << "} def\n"; + t << "\n"; + t << "/box % draws a box with text 'arg1' at grid pos (arg2,arg3)\n"; + t << "{ gsave\n"; + t << " 2 setlinewidth\n"; + t << " newpath\n"; + t << " exch xspacing mul xoffset add\n"; + t << " exch yspacing mul\n"; + t << " moveto\n"; + t << " boxwidth 0 rlineto \n"; + t << " 0 boxheight rlineto \n"; + t << " boxwidth neg 0 rlineto \n"; + t << " 0 boxheight neg rlineto \n"; + t << " closepath\n"; + t << " dup stringwidth pop neg boxwidth add 2 div\n"; + t << " boxheight fontheight 2 div sub 2 div\n"; + t << " rmoveto show stroke\n"; + t << " grestore\n"; + t << "} def \n"; + t << "\n"; + t << "/mark\n"; + t << "{ newpath\n"; + t << " exch xspacing mul xoffset add boxwidth add\n"; + t << " exch yspacing mul\n"; + t << " moveto\n"; + t << " 0 boxheight 4 div rlineto\n"; + t << " boxheight neg 4 div boxheight neg 4 div rlineto\n"; + t << " closepath\n"; + t << " eofill\n"; + t << " stroke\n"; + t << "} def\n"; + t << "\n"; + t << "/arrow\n"; + t << "{ newpath\n"; + t << " moveto\n"; + t << " 3 -8 rlineto\n"; + t << " -6 0 rlineto\n"; + t << " 3 8 rlineto\n"; + t << " closepath\n"; + t << " eofill\n"; + t << " stroke\n"; + t << "} def\n"; + t << "\n"; + t << "/out % draws an output connector for the block at (arg1,arg2)\n"; + t << "{\n"; + t << " newpath\n"; + t << " exch xspacing mul xoffset add boxwidth 2 div add\n"; + t << " exch yspacing mul boxheight add\n"; + t << " /y exch def\n"; + t << " /x exch def\n"; + t << " x y moveto\n"; + t << " 0 disty 2 div rlineto \n"; + t << " stroke\n"; + t << " 1 eq { x y disty 2 div add arrow } if\n"; + t << "} def\n"; + t << "\n"; + t << "/in % draws an input connector for the block at (arg1,arg2)\n"; + t << "{\n"; + t << " newpath\n"; + t << " exch xspacing mul xoffset add boxwidth 2 div add\n"; + t << " exch yspacing mul disty 2 div sub\n"; + t << " /y exch def\n"; + t << " /x exch def\n"; + t << " x y moveto\n"; + t << " 0 disty 2 div rlineto\n"; + t << " stroke\n"; + t << " 1 eq { x y disty 2 div add arrow } if\n"; + t << "} def\n"; + t << "\n"; + t << "/hedge\n"; + t << "{\n"; + t << " exch xspacing mul xoffset add boxwidth 2 div add\n"; + t << " exch yspacing mul boxheight 2 div sub\n"; + t << " /y exch def\n"; + t << " /x exch def\n"; + t << " newpath\n"; + t << " x y moveto\n"; + t << " boxwidth 2 div distx add 0 rlineto\n"; + t << " stroke\n"; + t << " 1 eq\n"; + t << " { newpath x boxwidth 2 div distx add add y moveto\n"; + t << " -8 3 rlineto\n"; + t << " 0 -6 rlineto\n"; + t << " 8 3 rlineto\n"; + t << " closepath\n"; + t << " eofill\n"; + t << " stroke\n"; + t << " } if\n"; + t << "} def\n"; + t << "\n"; + t << "/vedge\n"; + t << "{\n"; + t << " /ye exch def\n"; + t << " /ys exch def\n"; + t << " /xs exch def\n"; + t << " newpath\n"; + t << " xs xspacing mul xoffset add boxwidth 2 div add dup\n"; + t << " ys yspacing mul boxheight 2 div sub\n"; + t << " moveto\n"; + t << " ye yspacing mul boxheight 2 div sub\n"; + t << " lineto\n"; + t << " stroke\n"; + t << "} def\n"; + t << "\n"; + t << "/conn % connections the blocks from col 'arg1' to 'arg2' of row 'arg3'\n"; + t << "{\n"; + t << " /ys exch def\n"; + t << " /xe exch def\n"; + t << " /xs exch def\n"; + t << " newpath\n"; + t << " xs xspacing mul xoffset add boxwidth 2 div add\n"; + t << " ys yspacing mul disty 2 div sub\n"; + t << " moveto\n"; + t << " xspacing xe xs sub mul 0\n"; + t << " rlineto\n"; + t << " stroke\n"; + t << "} def\n"; + t << "\n"; + t << "% ----- main ------\n"; + t << "\n"; + t << "boxfont setfont\n"; + t << "1 boundaspect scale\n"; + + + for (const auto &dr : p->base) { - done=di->isInList(); - t << "(" << convertToPSString(di->label()) << ") cw\n"; + bool done=FALSE; + for (const auto &di : *dr) + { + done=di->isInList(); + t << "(" << convertToPSString(di->label()) << ") cw\n"; + } + if (done) break; } - if (done) break; - } - auto it = p->super.begin(); - if (it!=p->super.end()) ++it; - for (;it!=p->super.end();++it) - { - const auto &dr = *it; - bool done=FALSE; - for (const auto &di : *dr) + auto it = p->super.begin(); + if (it!=p->super.end()) ++it; + for (;it!=p->super.end();++it) { - done=di->isInList(); - t << "(" << convertToPSString(di->label()) << ") cw\n"; + const auto &dr = *it; + bool done=FALSE; + for (const auto &di : *dr) + { + done=di->isInList(); + t << "(" << convertToPSString(di->label()) << ") cw\n"; + } + if (done) break; } - if (done) break; - } - t << "/boxwidth boxwidth marginwidth 2 mul add def\n" - << "/xspacing boxwidth distx add def\n" - << "/yspacing boxheight disty add def\n" - << "/scalefactor \n" - << " boxwidth cols mul distx cols 1 sub mul add\n" - << " boxheight rows mul disty rows 1 sub mul add boundaspect mul \n" - << " max def\n" - << "boundx scalefactor div boundy scalefactor div scale\n"; + t << "/boxwidth boxwidth marginwidth 2 mul add def\n" + << "/xspacing boxwidth distx add def\n" + << "/yspacing boxheight disty add def\n" + << "/scalefactor \n" + << " boxwidth cols mul distx cols 1 sub mul add\n" + << " boxheight rows mul disty rows 1 sub mul add boundaspect mul \n" + << " max def\n" + << "boundx scalefactor div boundy scalefactor div scale\n"; - t << "\n% ----- classes -----\n\n"; - p->base.drawBoxes(t,0,TRUE,FALSE,baseRows,superRows,0,0); - p->super.drawBoxes(t,0,FALSE,FALSE,baseRows,superRows,0,0); + t << "\n% ----- classes -----\n\n"; + p->base.drawBoxes(t,0,TRUE,FALSE,baseRows,superRows,0,0); + p->super.drawBoxes(t,0,FALSE,FALSE,baseRows,superRows,0,0); - t << "\n% ----- relations -----\n\n"; - p->base.drawConnectors(t,0,TRUE,FALSE,baseRows,superRows,0,0); - p->super.drawConnectors(t,0,FALSE,FALSE,baseRows,superRows,0,0); + t << "\n% ----- relations -----\n\n"; + p->base.drawConnectors(t,0,TRUE,FALSE,baseRows,superRows,0,0); + p->super.drawConnectors(t,0,FALSE,FALSE,baseRows,superRows,0,0); + + } + f.close(); - f1.close(); if (Config_getBool(USE_PDFLATEX)) { QCString epstopdfArgs(4096); epstopdfArgs.sprintf("\"%s.eps\" --outfile=\"%s.pdf\"", - epsBaseName.data(),epsBaseName.data()); - //printf("Converting eps using '%s'\n",epstopdfArgs.data()); + qPrint(epsBaseName),qPrint(epsBaseName)); + //printf("Converting eps using '%s'\n",qPrint(epstopdfArgs)); Portable::sysTimerStart(); if (Portable::system("epstopdf",epstopdfArgs)!=0) { @@ -1338,8 +1340,8 @@ void ClassDiagram::writeFigure(FTextStream &output,const char *path, } -void ClassDiagram::writeImage(FTextStream &t,const char *path, - const char *relPath,const char *fileName, +void ClassDiagram::writeImage(TextStream &t,const QCString &path, + const QCString &relPath,const QCString &fileName, bool generateMap) const { uint baseRows=p->base.computeRows(); @@ -1350,9 +1352,9 @@ void ClassDiagram::writeImage(FTextStream &t,const char *path, p->base.computeExtremes(&lb,&xb); p->super.computeExtremes(&ls,&xs); - uint cellWidth = QMAX(lb,ls)+labelHorMargin*2; - uint maxXPos = QMAX(xb,xs); - uint labelVertMargin = 6; //QMAX(6,(cellWidth-fontHeight)/6); // aspect at least 1:3 + uint cellWidth = std::max(lb,ls)+labelHorMargin*2; + uint maxXPos = std::max(xb,xs); + uint labelVertMargin = 6; //std::max(6,(cellWidth-fontHeight)/6); // aspect at least 1:3 uint cellHeight = labelVertMargin*2+fontHeight; uint imageWidth = (maxXPos+gridWidth)*cellWidth/gridWidth+ (maxXPos*labelHorSpacing)/gridWidth; |