Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use doxygen to create UML class diagrams from C++ source

I have been searching for some material that describes how to generate simple class diagrams with doxygen, but couldn't find one. Can anybody help?

I need to create diagrams as shown below from a set of C++ files. alt text

If there are better tools to achieve this easier, please let me know.

like image 431
softwarematter Avatar asked Jan 21 '11 06:01

softwarematter


People also ask

Can Doxygen generate class diagram?

Doxygen Manual: Graphs and diagrams. Doxygen has built-in support to generate inheritance diagrams for C++ classes.

How do you create a dependency graph in Doxygen?

Make sure the following options are set in the Doxywizard dialog: In Wizard tab, under Output, select HTML output. In Wizard tab, under Diagrams, choose the option Use dot tool from the GraphViz package. Select the following two options below it: Include dependency graphs and Included by dependency graphs.


5 Answers

Hmm, this seems to be a bit of an old question, but since I've been messing about with Doxygen configuration last few days, while my head's still full of current info let's have a stab at it -

I think the previous answers almost have it:

The missing option is to add COLLABORATION_GRAPH = YES in the Doxyfile. I assume you can do the equivalent thing somewhere in the doxywizard GUI (I don't use doxywizard).

So, as a more complete example, typical "Doxyfile" options related to UML output that I tend to use are:

EXTRACT_ALL          = YES CLASS_DIAGRAMS      = YES HIDE_UNDOC_RELATIONS = NO HAVE_DOT             = YES CLASS_GRAPH          = YES COLLABORATION_GRAPH  = YES UML_LOOK             = YES UML_LIMIT_NUM_FIELDS = 50 TEMPLATE_RELATIONS   = YES DOT_GRAPH_MAX_NODES  = 100 MAX_DOT_GRAPH_DEPTH  = 0 DOT_TRANSPARENT      = YES 

These settings will generate both "inheritance" (CLASS_GRAPH=YES) and "collaboration" (COLLABORATION_GRAPH=YES) diagrams.

Depending on your target for "deployment" of the doxygen output, setting DOT_IMAGE_FORMAT = svg may also be of use. With svg output the diagrams are "scalable" instead of the fixed resolution of bitmap formats such as .png. Apparently, if viewing the output in browsers other than IE, there is also INTERACTIVE_SVG = YES which will allow "interactive zooming and panning" of the generated svg diagrams. I did try this some time ago, and the svg output was very visually attractive, but at the time, browser support for svg was still a bit inconsistent, so hopefully that situation may have improved lately.

As other comments have mentioned, some of these settings (DOT_GRAPH_MAX_NODES in particular) do have potential performance impacts, so YMMV.

I tend to hate "RTFM" style answers, so apologies for this sentence, but in this case the Doxygen documentation really is your friend, so check out the Doxygen docs on the above mentioned settings- last time I looked you can find the details at http://www.doxygen.nl/manual/config.html.

like image 128
user6092647 Avatar answered Sep 19 '22 04:09

user6092647


Doxygen creates inheritance diagrams but I dont think it will create an entire class hierachy. It does allow you to use the GraphViz tool. If you use the Doxygen GUI frontend tool you will find the relevant options in Step2: -> Wizard tab -> Diagrams. The DOT relation options are under the Expert Tab.

like image 32
DPD Avatar answered Sep 20 '22 04:09

DPD


Quote from this post (it's written by the author of doxygen himself) :

run doxygen -g and change the following options of the generated Doxyfile:

    EXTRACT_ALL            = YES
    HAVE_DOT               = YES
    UML_LOOK               = YES

run doxygen again
like image 34
wsdookadr Avatar answered Sep 20 '22 04:09

wsdookadr


Enterprise Architect will build a UML diagram from imported source code.

like image 34
zooropa Avatar answered Sep 18 '22 04:09

zooropa


I think you will need to edit the doxys file and set GENERATE_UML (something like that) to true. And you need to have dot/graphviz installed.

like image 45
fzhou Avatar answered Sep 18 '22 04:09

fzhou