[Doxygen-develop] [PATCH] Word wrapping long class names in DOT diagrams
Brought to you by:
dimitri
From: David W. <da...@te...> - 2005-06-15 03:56:39
|
I have noticed that when using the doxygen-generated inheritance diagrams and collaboration diagrams, class names are always drawn on a single line. This can lead to needlessly large diagrams (4000+ pixels wide) if you have a C++ class with several template arguments, for example. The following patch to doxygen 1.4.3 solves this problem for many of the cases I tried, by trying to word-wrap the class name once it exceeds 30 characters. Line breaks are inserted after space or comma. The same line-breaking method will also be used for arrow labels.=20 One inheritance graph (for a template class instantiated with 8 template parameters) went from 4010 to 979 pixels width after this patch and is much more readable. Also, this patch corrects a small bug with collaboration diagrams. When multiple member variables have the same type, this was showing up in the collaboration diagram as "m_one\nm_two\nm_three" next to the dashed purple arrow, rather than showing "m_one", "m_two", "m_three" on separate lines. Regards Dave diff -ur doxygen-1.4.3.orig/src/dot.cpp doxygen-1.4.3/src/dot.cpp --- doxygen-1.4.3.orig/src/dot.cpp 2005-04-18 02:55:55.000000000 +1000 +++ doxygen-1.4.3/src/dot.cpp 2005-06-14 12:41:17.000000000 +1000 @@ -561,15 +561,27 @@ QCString result; const char *p=3Dl.data(); char c; + int line=3D0; while ((c=3D*p++)) { + ++line; switch(c) { + case '\n': result+=3D"\\n"; line=3D0; break; case '\\': result+=3D"\\\\"; break; case '<': result+=3D"\\<"; break; case '>': result+=3D"\\>"; break; case '|': result+=3D"\\|"; break; case '"': result+=3D"\\\""; break; + case ' ': + case ',': + // these are used to break lines over 30 characters + result +=3D c; + if(line >=3D 30 && strlen(p) > 1) { // orphan control: = don't leave dangling '>' on last line + result +=3D "\\l "; + line =3D 0; + } + break; default: result+=3Dc; break; } } @@ -1446,7 +1458,7 @@ } else { - label+=3DQCString("\\n")+s; + label+=3DQCString("\n")+s; } } addClass(ucd->classDef,n,EdgeInfo::Purple,label,distance,0, |