Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Graphviz + Doxygen to generate UML class diagrams

I want to use Graphviz + Doxygen to generate a class diagram based on C++ code. This works already as Doxygen comes with a native DOT support; but is it possible, to produce a UML-like output with the corresponding access modificators (public, private etc.), return and parameter types of the class methods, similar to the diagram below?

I'm aware of thread How to use doxygen to create UML class diagrams from C++ source, but it doesn't answer the question, though.

enter image description here

like image 502
Eric Avatar asked Feb 28 '12 15:02

Eric


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 call graph in Doxygen?

You have to set HAVE_DOT , CALL_GRAPH and CALLER_GRAPH to YES . Also make sure the path to dot is in your PATH variable. If that still doesn't work, you might have to set EXTRACT_ALL and/or EXTRACT_STATIC , depending on your functions. Apologies, I do have HAVE_DOT, CALL_GRAPH, and CALLER_GRAPH set to YES.

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.


2 Answers

Create the following source file example.cpp:

class Animal {   public:     void die();     string name;     int age; };  class Dog : public Animal {   public:     void bark(); };  class Cat : public Animal {   public:     void meow(); }; 

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

EXTRACT_ALL            = YES HAVE_DOT               = YES UML_LOOK               = YES 

run doxygen and look at the output for the Animal class, it should be the similar as the above picture, although doxygen will not show the return types of the methods and fields.

like image 88
doxygen Avatar answered Sep 23 '22 00:09

doxygen


I had similar problem its successfully solved now.

Following are the steps(assuming that you are using GUI version of Doxygen-Doxywizard)

  1. Click on Expert button

  2. Go to Dot tab and select the DOT_PATH. Browse the folder where you have installed the program. e.g., " C:/Program Files (x86)/Graphviz2.32/bin "

Hope it helps, Anit

like image 42
Ani Avatar answered Sep 23 '22 00:09

Ani