creating UML or class diagram manually from existing project - c++

Is there anyway to build manually a class or UML diagram from some part of existing code in Visual Studio Professional? Assume there are plenty of project and classes. Can i manually select some of the classes (with only some of its base/derived classes and member functions) I am interested in, and they are automatically transferred to boxes with arrows and so on...?
The trivial and slow solution is to draw some boxes and corresponding arrows and then write the name of classes or member functions into boxes (With some drawing programs like Dia). However, can it be done maybe using a more efficient way with any plugin or extension?
Because, my final aim is to make my own documentation (visually) from the code i am working at. The code is big and I want to develope my own documentation only on some selective parts during the next years...

You can install the Class Designer component.
In addition, UML Designers have been removed.

Related

Reverse engineered project to graphical UML diagram

I've started to work on a quite big C++ project. I've used BOUML to import the code base with the intention to create a visual UML diagram.
Now I've reversed the project and I see the classes, namespaces, methods and such in the project browser but I can't figure out how to create a graphical UMl from it, may anyone here help me?
Manually draggign the elements from the browser into the main area doesn't seem to be allowed as the cursor gets a forbidden icon and dropping the elments doesn't do anything then... how do I even create the UML myself?
muszeo2 is right, the reverse create the packages / views / artifacts and classes and their members, after you have to create the diagrams by yourself. Sorry but BoUML is not extra lucid and it cannot by itself create the right diagrams of the right kind containing the right elements with the right drawing options ;-) So create your diagrams and drag&drop the elements you want to show etc, they are several features helping you to make diagrams with elements already created or not.
I also made some video tutorials available on https://www.bouml.fr/documentation.html, I encourage you to look at them, starting by starting.wmv then cpp_example.wmv for instance, but you can also look at the others because the rules are quite identicals. These video tutorials are old and many features was added since I made them, but this is a good start.
You cannot drag&drop from browser to no where (I mean not into an opened diagram) nor when the element cannot be added in a diagram

Visual Studios 2015 C++ UML diagramm creating associations

I wrote an c++ application using Visual Studios 2015 for a class project in my school. Therefor, I have to submit an UML-Classdiagramm. I already heard of VS's ability of auto-generating UML diagramms from my written classes.
So I right-clicked on my solution explorer and generated this UML. I removed some unnecessary classes and already displayed some Members as association.
Now I want to associate some classes with each other because VS didn't do this for me. Those are one-to-many-associations like one bag associates with many items in it.
In code, I did this with a vector. but when I right-click the property and select "Show as Association" (or something similar :D) it keeps adding the vector-class instead of drawing my association to the class-type stored in this vector.
I also tried to add the associations manually but I can't because all the UML-classdiagramm-Items in my Toolbox are gray and not usable.
Any help is appreciated :)
I had the same problem. Visual Studio doesn't support this for C++. You have to create a new Diagram Project (not just adding it to your current project) and design your classes manually. The auto-generated class diagram works for C# (only?).

How to create class diagram from source code using either Enterprise Architect or Rational Software Architect?

I am not fluent in UML, but I would like to create a class diagram based on existing C++ code. Other StackOverflow questions have indicated that two programs - Enterprise Architect and Rational Software Architect - are fairly good at "reverse engineering" C++ code (i.e., creating UML class diagrams based on existing C++ code).
I have downloaded the trial version for both of these applications. However, I cannot make any headway into understanding what to do to create a class diagram in either of these applications.
In Rational Software Architect, I have created a UML project, but I cannot find any way within the program to select, and reverse engineer, my existing C++ code.
In Enterprise Architect, I was able to import my C++ code, but all the elements (classes) appeared in a useless, overlapping diagonal line within the diagram. I attempted other settings, such as circle, but these were equally impossible to read because the diagrams were so large (due to the attributes and methods taking up alot of space) that no amount of panning and zooming was useful. What I would like is to hide everything except the class names (i.e., not display any methods or attributes) so that all 20 classes appear conveniently and legibly in one screen.
However, I am unable to find a way to hide everything except the class names. Rather, when I found an option (in Enterprise Architect) that seemed like it might hide everything but the class names, for some reason the elements all vanished in the class diagram, and no amount of repeating the steps & deleting and re-adding packages made the class diagram reappear.
Note: My C++ code (at least those files I selected for import into Enterprise Architect) amount to only about 20 classes.
Sadly, a very careful search of the documentation for both of these programs provides only generalities - no specific instructions are given regarding reverse engineering for either of these programs, so far as I could find.
I would be grateful if someone could tell me the basic steps to create a legible, easy-to-navigate diagram via. reverse engineering (i.e., C++-to-UML) that shows only the class names, so that about 20 classes fit (legibly) on one screen, using either Enterprise Architect, or Rational Software Architect - OR any other tool whatsoever that is capable of doing this (I suggest EA and Rational only because they have been highlighted in other StackOverflow answers as the best programs available for this purpose).
This answer applies to EA.
You can import individual files or whole directories, recursively or no. Directory import is by far the most common case; single file import does not allow you to create a diagram automatically.
When you import a source directory, you have the option of creating diagrams for each UML package, or no diagrams at all. You also decide whether to create packages for each source code directory, namespace (default) or file.
If your code constists of only 20 classes then it's likely they're in a single directory and/or namespace, so play around with that option (Package Structure in the Import Source dialog) to get the right number of diagrams.
In the same dialog, there's a button "New Diagram Options," which opens another config dialog where you can choose whether the diagrams should contain the classes' attributes and/or operations. You can also make the decision on a visibility basis, eg show public members only.
This dialog only affects what's shown in the diagrams when they are created. The members are still imported, just not displayed. This sounds like what you're after.
You can change the display options for any diagram by double-clicking an empty area of it, or right-clicking and selecting Properties. It sounds like you got into this dialog and changed something around, but I can't really tell what. The situation you describe, where you can't get the display back the way it was, is not one I've ever encountered in EA.
It is also possible to select display options on a per-class basis by right-clicking it in the diagram and selecting Feature Visibility. I don't recommend you use this in reverse-engineered diagrams, I'm just mentioning it for completeness.
The layout you describe, with all classes in a meaningless diagonal, suggests to me that the diagram isn't being laid out properly after creation. The diagram creation is a two-step process; first all the classes are dropped onto it, then the layout is applied.
This is strange, as EA automatically lays out generated diagrams and I haven't been able to find an option which allows you to deselect this behaviour. If this persists, send a bug report to Sparx Systems. You can always lay out the diagram by opening it and selecting Layout Diagram from the top-level Diagram menu.
If, finally, your classes are spread out among different packages and namespaces so that EA generates multiple diagrams for them, you'll have to merge them manually. Do this by opening both diagrams, selecting all (Ctrl-A) in one, copying (Ctrl-C) and pasting (Ctrl-V) into the other, then ask EA to Layout Diagram again.
So:
Right-click an empty package in the project browser, select Code Engineering - Import Source Directory.
In the dialog, select the root directory and source type.
Tick "Create Logical Diagram for Each Package" and select the Package Structure which best fits your source structure.
Click "New Diagram Options" and in the new dialog untick "Show Attributes," "Show Operations" and "Show Property Methods" if applicable.
OK both dialogs.
If multiple diagrams have been created, copy all classes into a single diagram.
If the layout looks bad, select Diagram - Layout Diagram.
Hope this helps.

C++ code visualization

A sort of follow up/related question to this.
I'm trying to get a grip on a large code base that has hundreds and hundreds of classes and a large inheritance hierarchy. I want to be able to see the "main veins" of the inheritance hierarchy at a glance - not all the "peripheral" classes that only do some very specific / specialized thing. Visual Studio's "View Class Diagram" makes something that looks like a train and its sprawled horizontally across the screen and isn't very organized. You can't grok it easily.
I've just tried doxygen and graphviz but the results are .. somewhat similar to Visual Studio. I'm getting sweet looking call graphs but again too much detail for what I'm trying to get.
I need a quick way to generate the inheritance hierarchy, in some kind of collapsible view.
Why not just do it manually, it is a great learning experience when starting to work with a large code base. I usually just look at what class inherits from what, and what class contain what instances, references or pointers to other classes. Have a piece of paper next to you and get drawing...
Instead of going into the full Class Designer tool, just use the "Class View" or the "Object Browser" in Visual Studio - they present fully collapsible class heirarchies.
A good UML tool should do the trick.
Here is a list of generic UMl tools: http://en.wikipedia.org/wiki/List_of_UML_tools
There are lots out there, all with varying feature sets. Try playing with a few to see if you get the output you desire. If they free ones fail you, you might have to shell out for a good commercial grade UML tool
You can try CppDepend, it doesn't create a class hierarchy like Doxygen does but it can show 'the big picture' for your project, it also shows some code metrics.
I've had most success with valgrind and kcachegrind to do this. You run valgrind against your debugging binary, perform whatever actions your interested in, then import the output into kcachegrind to see everything you'd ever want to know about who called what, how often, and when. Plus, because your doing it dynamically, it catches cases that static analysis likely wont.
I've also had some success using Enterprise Architect's reverse engineering features, although this doesn't end up nearly as nicely (but you get a workable UML model which is nice!).
And finally, a tool called "Understand". This is pretty good at static OO analysis, but I think quite pricey and not that widely used.
Try Source Insight it is possible to configure the depth of the generated graph in this tool.
See also C/C++ call-graph utility for Windows platform
Check out SourceNavigator, it's open source, works on a bunch of platforms and has a Hierarchy Browser, a Class Browser, a Cross-Reference Browser and more that will allow you navigate and understand the code.
I'm using it for some time now especially when I have new code to go through and understand.
For a reasonably priced commercial product, you may want to check out SolidSX from Vizlogix (www.vizlogix.com). (If you are outside of North America, go to SolidSource -- www.solidsourceit.com.)
It generates a radial diagram that can be collapsed and expanded. It also integrates with Visual Studio (both BSC and .NET).
What's your definition of 'main vein'? You either want a graph reducer or skeletizer (you could find or write one and apply it to what Doxygen and the rest produce) or, 'main vein' has something to do with the function of the code and, I don't think an automated tool can help you with that. Unless you can point out to it 'These are the important bits that do input and output, show me only elements that are one or two steps away from the paths between these'. Hum, sounds like a cool tool to write :)
... the inheritance hierarchy, in some kind of collapsible view.
again, a sweet idea for a tool!

Creating a C++ Class Diagram

In Visual Studio .NET projects you can add a "Class Diagram" to the project which renders a visual representation of all namespaces, classes, methods, and properties. Is there any way to do this for Win32 (not .NET) C++ projects? Either through Visual Studio itself or with a 3rd party tool?
If you have a Visual Studio 2008 solution composed of multiple C++ projects, you can only generate one class diagram per project.
For example, if you have one application project linking to 10 library projects, you'll have to generate 11 separate class diagrams.
There are two ways to work around this, neither of which is pleasant:
Cram all the source into a single project.
Create a class diagram for one project (the application, perhaps) and then drag files from all the other projects into the class diagram.
A more thorough exploration of the capabilities of the Visual Studio class designer is given in Visual C++ Class Designer.
Given the poor support for C++ class diagrams in Visual Studio, you're probably better off going with a commercial tool if you want anything more than a simple list of what classes you have. WinTranslator from Excel Software might be worth looking at, and someone I work with uses Source Insight.
Most UML tools should be able to do that. I know that Sparx Systems Enterprise Architect does.
I've got VS2008 SP1 Professional and class diagrams are working fine for C++ WIN32 and Makefile projects.
If you're using Visual Studio, class diagrams for C++ were not correctly implemented until Visual Studio 2008.
Class designer is not meant for C++, even in VS 2008. You will be better off with some more specialized tool. It works for simple projects which don't heavily use templates. Also, get modeling power toys from codeplex.
Try doing partial specializations and watch how it crams everything into a single shape.
A cheap way would be to document your source with Doxygen and let this tool create the class diagrams for you.
If your project is a c++ based project then you have to drawn class diagram of c++ first,If your project contain 'n' number of sub-projects then you have to drawn 'n+1' number of class diagram.
Basically a class diagram contains
class variables.
class functions.
Relation between classes.
You should place all the properties which are required for a class inside a class diagram. It looks like a table (graphical structure) having 3 rows type box.
Row 1. class name(If it is an Object diagram it should and must under lined).
Row 2. Variable list(One variable in one line).
Row 3. Function list(One function in one line)
You have to make the Relation between one class to another class.