Thread: [Doxygen-develop] [Doxygen] SVG/Layout
Brought to you by:
dimitri
From: Fred P. <j2...@ho...> - 2004-03-15 09:57:55
|
Hi Dimitry, I was wondering about your layout/routing algorithm for the DOT program output. http://j2k.sourceforge.net/docs/example/classVectorialImageFileIOStream.html http://j2k.sourceforge.net/docs/example/classJFileInStream.html i.e. The way you draw arrows and box: positionate them, draw them. I was reading your source code (diagram.* dot.*) bool TreeDiagram::layoutTree(DiagramItem *root,int r); void TreeDiagram::moveChildren(DiagramItem *root,int dx); void TreeDiagram::computeLayout(); uint TreeDiagram::computeRows(); void TreeDiagram::computeExtremes(uint *maxLabelLen,uint *maxXPos); I'm just wondering what are the "strict" dependancies on those... Also, I wanted to add SVG output support via 1) external SVG files (instead of PNG) 2) ActiveX embedded SVG within html (for ASV3 and ASV6pr1) [ Adobe SVG Viewer http://www.adobe.com/svg/ ] Looking at the doxygen source doxygened callgraphs, modifying diagram/dot/image should probably be sufficient, but I would like to make a patch and submitted to you, so others can benefit from it. It's not hard at all to have SVG, it's just a question of duplicating the code and make the appropriate changes... see below. I'm just confuse where what is what and what is needed to perform things to translate layout into JavaScript, the overall minimal Qt infrastructure for those class was translatate in JS, including a good part of them. Here some SVG possible things to do: void ClassDiagram::writeImage(QTextStream &t,const char *path, const char *fileName, bool generateMap) { uint baseRows=base->computeRows(); uint superRows=super->computeRows(); uint rows=baseRows+superRows-1; uint lb,ls,xb,xs; base->computeExtremes(&lb,&xb); 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 cellHeight = labelVertMargin*2+fontHeight; uint imageWidth = (maxXPos+gridWidth)*cellWidth/gridWidth+ (maxXPos*labelHorSpacing)/gridWidth; uint imageHeight = rows*cellHeight+(rows-1)*labelVertSpacing; Image image(imageWidth,imageHeight); base->drawBoxes(t,&image,TRUE,TRUE,baseRows,superRows,cellWidth,cellHeight,generateMap); super->drawBoxes(t,&image,FALSE,TRUE,baseRows,superRows,cellWidth,cellHeight,generateMap); base->drawConnectors(t,&image,TRUE,TRUE,baseRows,superRows,cellWidth,cellHeight); super->drawConnectors(t,&image,FALSE,TRUE,baseRows,superRows,cellWidth,cellHeight); image.save((QCString)path+'/'+fileName+'.png'); if (generateMap) t << '</map>' << endl; } I want to add embedded html inlined <svg> diagrams output instead of png. image->fillRect(x+1,y+1,w-2,h-2,colFill,mask); image->drawRect(x,y,w,h,colBorder,mask); image->writeString(x+(w-l)/2, y+(h-fontHeight)/2, di->label(),1); For instance get transformed into: See the following SVG documentation http://www.w3.org/TR/SVG/shapes.html#RectElement http://www.w3.org/TR/SVG/text.html#TextElement char[] getHexRGBColor( uchar color ) { char buffer[8]; Color c = palette2[ color ]; snprintf( buffer, 8, "%.2x%.2x%.2x", c.red, c.green, c.blue ); return buffer; } snprintf( buffer, BUFFER_SIZE, "<svg:rect x='%d' y='%d' width='%d' height='%d' fill='#%s' mask='%s' stroke='#%s' />", x+1,y+1,w-2,h-2, getHexRGBColor( colFill ),mask, getHexRGBColor( colBorder ) ); snprintf( buffer, BUFFER_SIZE, "<svg:text x='%d' y='%d' fill='#%s'>%s</text>", x+(w-l)/2, y+(h-fontHeight)/2, getHexRGBColor( 1 ), di->label() ); another way would be to have: void Image::setPixel(int x,int y,uchar val) { if (x>=0 && x<width && y>=0 && y<height) data[y*width+x] = val; } being: char[] Image::putPixel(int x,int y,uchar val) { char buffer[100]; snprintf( buffer, 100, "<svg:rect x='%5d' y='%5d' width='1' height='1' fill='#%s'/>\n", x, y, getHexRGBColor( val ) ); return buffer; } Image::Image(int w,int h) { printSvgHeader( w, h ); } char[] printSvgHeader( int w, int h) { char buffer[400]; snprintf( buffer, 400, "\n <svg:svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' " "\n width='%5d' height='%5d' enableZoomAndPanControls='false' " "\n style=' font-family: \"Ms Sans Serif\"; font-weight: normal; font-size: 9pt; fill: black; " "shape-rendering: optimizeSpeed; text-rendering: optimizeLegibility; ' " ">", w, h ); return buffer; } char* printSvgFooter() { return "\n</svg:svg>\n"; } char[] printHtmlHeader() { char buffer[600]; snprintf( buffer, 600, "<?xml version='1.0' encoding='iso-8859-1'?> " "\n<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'> " "\n<html " "\n xmlns:svg='http://www.w3.org/2000/svg' " "\n xmlns='http://www.w3.org/1999/xhtml' " "\n xml:lang='en' lang='en'> " "\n<head><!-- ASV6pr1 ActiveX entry tag -->" "\n<object id='AdobeSVG' classid='clsid:78156a80-c6a1-4bbf-8e6a-3cd390eeb4e2'></object>" "\n<?import namespace='svg' implementation='#AdobeSVG'?> " "\n</head>" "\n<body>" ); return buffer; } If you were kind enough to give me some hint, I would really appreciate. Fred 'diving into Doxygen source' P. _________________________________________________________________ Free yourself from those irritating pop-up ads with MSn Premium. Get 2months FREE* http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines |
From: Dimitri v. H. <di...@st...> - 2004-03-20 16:10:38
|
On Mon, Mar 15, 2004 at 09:57:47AM +0000, Fred P. wrote: > Hi Dimitry, > > I was wondering about your layout/routing algorithm for the DOT program > output. > > http://j2k.sourceforge.net/docs/example/classVectorialImageFileIOStream.html > http://j2k.sourceforge.net/docs/example/classJFileInStream.html > > i.e. The way you draw arrows and box: positionate them, draw them. > I was reading your source code (diagram.* dot.*) > > bool TreeDiagram::layoutTree(DiagramItem *root,int r); > void TreeDiagram::moveChildren(DiagramItem *root,int dx); > void TreeDiagram::computeLayout(); > uint TreeDiagram::computeRows(); > void TreeDiagram::computeExtremes(uint *maxLabelLen,uint *maxXPos); For your info. Doxygen has a build in diagram generator (TreeDiagram in src/diagram.*) which can only do trees. All new development is done with the DOT tool (as shown by your links), where doxygen only generates the graph description and DOT takes care of all the layouting. > I'm just wondering what are the "strict" dependancies on those... > > Also, I wanted to add SVG output support via > 1) external SVG files (instead of PNG) > 2) ActiveX embedded SVG within html (for ASV3 and ASV6pr1) > [ Adobe SVG Viewer http://www.adobe.com/svg/ ] Recent version of DOT can already do SVG output, so it is probably very easy to add SVG as an output format (besides jpg, gif, and png). > Looking at the doxygen source doxygened callgraphs, > modifying diagram/dot/image should probably be sufficient, > but I would like to make a patch and submitted to you, > so others can benefit from it. > > It's not hard at all to have SVG, it's just a question of duplicating the > code > and make the appropriate changes... see below. I think that with using dot, duplication can be avoided. > I'm just confuse where what is what and what is needed to perform things > to translate layout into JavaScript, the overall minimal Qt infrastructure > for those class was translatate in JS, including a good part of them. > > Here some SVG possible things to do: > > If you were kind enough to give me some hint, > I would really appreciate. I suggest to look src/dot.cpp and look for places where DOT_IMAGE_FORMAT is used. I think SVG could be added to the possible formats, and then it is just a matter of tweaking the output (if needed at all). Regards, Dimitri |