# Class diagram

The class diagrams may be placed in a class view, an use case view or an use case.

A class diagram is created through the new static class diagram entry of the class view browser menus.

Note a class diagram can also be used to do a package diagram or a profile diagram.

## Browser menu

The node menu appearing with a right mouse click on its representation in the browser is something like these, supposing the diagram not read-only nor deleted :

### Browser Menu : show

show allows to show the diagram picture, and edit it in case it is not read only.

### Browser Menu : edit

edit allows to show/modify the diagram properties. In case the diagram is read-only, the fields of the dialog are also read-only.

#### class diagram dialog, tab Uml

The proposed stereotypes are the default one specified through the Default stereotypes dialog more the current one (empty here). It is possible to choose into the list or to give a new one, or to empty it. The stereotype of a diagram doesn't have a special meaning for BOUML.

The editor button visible above and associated here to the description, allows to edit the description in an other window, or to call an external editor (for instance Xcoral) specified through the environment dialog. Note that this external editor have to create an own window, its parameter is the pathname of the file containing the description, its execution is done in parallel with BOUML which looks each second at the file contents to get the new definition until the dialog is closed (I do not like very much this polling but this works even QT isn't compiled with the thread support).

### Browser Menu : edit drawing settings

This dialog allows to specify how the items of the diagram must be drawn by default, you may choose default for each value, in this case the effective value if specified in the upper level (which itself may specify default etc ... up to the project level).

- drawing language : to indicate in which language the operations must be written when the full definition is showed (see below), see class drawing in a class diagram.

- classes drawing mode : to draw the class using a rectangle or an icon, see drawing mode in a class diagram.

- hide classes attributes : to hide or not the attributes, it is also possible to specify the visibility for each one.

- hide classes operations : to hide or not the operations, it is also possible to specify the visibility for each one.

- show classes member full definition : to show all the attributes and operation profile or just their name

- show members visibility : to write or not the visibility

- show members stereotype : to write or not the stereotypes

- show context in members definition : to write or not the context of classes indicated in the full member definition

- show attributes multiplicity : to write or not the multiplicity of the attributes when the drawing language is UML and you ask to show for full members definition

- show attributes initialization : to write or not the default value of the attributes when you ask to show for full members definition

- member max width : to limit the width (in characters) used to produce the definition of the operations and attributes. When the width is greater that the max width, the string is cut and ... is added. Doesn't take into account the stereotype.

- show parameter direction : to write or not the direction of the operation's parameters

- show parameter name : to write or not the name of the operation's parameters

- draw all classes relations : to automatically draw or not the new relations, obviously a relation will be added in a diagram only when the start and end classes (may be the same) are drawn.

- package name in tab : to indicate if the package's name must be written in the tab which is the small rectangle on the top (note : a transparent package doesn't have shadow) :

- show classes and packages context : To indicate if the context where the class/package is defined must be written, and if yes, how. The context may be the “UML context” which is the path of the class/package in the browser, or the C++ or Php namespace, or the Java package, or the Python package or at least the Idl module. See class context and package context.

- automatic labels position : To ask BOUML to move or to not move the associated labels on the relations in a diagram when the relation is edited or the associated class pictures moved etc ...

- show information note : to show or not the constraints through note

- show stereotype properties : to indicate through a note the (non empty) value of the stereotype properties in case the element is stereotyped by a stereotype part of a profile. By default the stereotype properties are hidden.

### Browser Menu : duplicate

Clone the diagram in a new one

### Browser Menu : delete

The delete entry is only present when the diagram is not read-only.

Delete the diagram and all its representation in the opened diagrams. After that it is possible to undelete it (from the browser) until you close the project : obviously the deleted items are not saved !

### Menu : mark

See mark

### Browser Menu : tools

The menu entry tool is only present in case at least a plug-out may be applied on the diagram. The selected tool is called and applied on the current diagram.

## Picture menu

The diagram menu appearing with a right mouse click out off any item in the diagram picture is something like these, supposing the diagram not read-only :

### Picture Menu : add classes of the selected class view

Only appears when a class view is selected in the browser, all the classes of the class view whose are not yet present in the diagram are added in the diagram, allowing to not have to do several drag & drop from the browser to add these classes, but the position of the classes will probably not be the good one

### Picture Menu : add marked elements

Only appears when a elements whose can be added in the diagram are marked in the browser, all these elements whose are not yet present in the diagram are added in the diagram, allowing to not have to do several drag & drop from the browser to them, but their position will probably not be the good one

### Picture Menu : edit drawing settings

see edit drawing settings.

### Picture Menu : select all

Select all the items of the current diagram, may also be done through control a

### Picture Menu : find selected browser element

To find in the diagram a representation of the elements selected in the browser

### Picture Menu : optimal scale

Similar to the fit scale button, change scale to see all the diagram's elements at great as possible

### Picture Menu : optimal window size

Similar to the button , change the size of the windows to see all the diagram's elements with the current scale

### Picture Menu : copy optimal picture part

Copy all the diagram elements, equivalent to a optimal windows size followed by a copy visible picture part then a restore of the original windows size

### Picture Menu : copy visible picture part

Put the visible part of the current diagram in the clipboard (copy), it is a screen copy, the current scale have impact on the picture quality.

It is also possible to print all (not only the visible part) the current diagram on printer or a file through the button

### Picture Menu : save optimal picture part

To save all the diagram elements in a file, equivalent to a optimal windows size followed by a save visible picture part then a restore of the original windows size

### Picture Menu : save visible picture part

To save the visible part of the current diagram in a file, it is a screen copy, the current scale have impact on the picture quality.

### Picture Menu : set preferred size and scale

To memorize the current diagram sub window size and the current scale. These ones will be used the next time the diagram will be opened.

### Picture Menu : set preferred scale

To memorize the current scale. These one will be used the next time the diagram will be opened.

### Picture Menu : restore preferred size and scale

In case a preferred sub window size and preferred scale was set, follow them.

### Picture Menu : unset preferred and scale

To stop to define a preferred size and scale was set

### Picture Menu : format

By default the diagram's canvas size is 840 x 1188 points corresponding to an iso A4 format (210*4 x 297*4), all the available formats are :

- iso A5 : 592 x 840

- iso A4 : 840 x 1188

- iso A3 : 1188 x 1680

- iso A2 : 1680 x 2376

- iso A1 : 2376 x 3364

- iso A0 : 3364 x 4756

- USA A : 864 x 1116

- USA B : 1116 x 1728

- USA C : 1728 x 2236

- USA D : 2236 x 3456

- USA E : 3456 x 4472

- USA Letter : 864 x 1116

- USA Legal : 864 x 1424

- USA Tabloid : 1116 x 1728

Each format also exists in landscape (it is Ledger in case of Tabloid)

### Picture Menu : undo changes

Undo all the changes made since the diagram was opened the last time. Note that the diagram is restored independently of the the project saving. Obviously the deleted browser items was not restored !

## Default stereotypes

The dialog allowing to set the default stereotypes has a tab reserved for the diagrams :

## Drawing

A class diagram may contain classes, packages, fragment, notes, texts, diagram icons and the relations.

To place these elements in the diagram, use the buttons on the top (to create a new element or choose from the already defined ones) then click at the appropriate position in the diagram, or grab the element from the browser into the diagram.

To add a new relation between classes, select the appropriate relation through the buttons on the top of the diagram sub window, click on the start class with the left mouse button, move the mouse, each time the mouse button is raised a new line break is introduced, at least click on the end class. To abort a relation construction press the right mouse button or do a double click with the left mouse button.

A line may be broken, during its construction of after clicking on the line with the left mouse button and moving the mouse with the mouse button still pushed. To remove a line break, a double click on the point with the left mouse button is enough, or use the line break menu of the point using the right mouse button.

By default the lines go to the center of their extremities, to decenter a line click near the desired extremity and move the mouse click down. To come back to a center line, use the menu geometry

The scale may be changed from 30 up to 200 %. To allows to see the operation/message kinds even with a small scale, the size of the arrows is unmodified.

fit% allows to set the largest scale allowing to show all the picture, as it is possible. Because of the scrollbar management, hitting several times on fit% may give several scales.

Classically, the left mouse click may be used to select an element, or several when the control key is down, a multiple selection may also be done defining a region using the mouse left click out of any element and moving the mouse with the click and maintaining the click down. The diagram's elements may be moved after a left mouse click on an element and maintaining the click down during the mouse move. The right mouse click is used to show context dependent menus.

control s is a shortcut to save the project

control shift s is a shortcut to save the project in a new one

control p is a shortcut to print the active diagram

control a is a shortcut to select all the diagram's elements

control d is a shortcut to delete the selected element(s), the model is affected

suppr is a shortcut to remove the selected element(s) from the diagram, these elements are not deleted

control c is a shortcut to copy the selected diagram's elements

control x is a shortcut to cut (remove from diagram) the selected diagram's elements

control v is a shortcut to paste the selected diagram's elements

control z and control u are a shortcut of undo

control r and control y are a shortcut of redo

the keyboard arrows allow to move the selected items

You can define your own shortcut using the shortcut editor through the Miscellaneous menu.

When several diagram's elements are selected, the menu appearing on a left mouse click allows to align or resize them :

If all the selected elements has the same kind (for instance all are a class), you can edit their drawing settings globally :

and for instance when the elements are classes in a class diagram :

The settings valuing <unchanged> are not changed for the selected elements, in the other case the same value is set for all the elements.

You can also reuse the drawing settings set for the first selected element for the other selected elements.

### Fragment

A fragment is resizeable. To change the fragment's name choose the edit entry of its menu or double click on it

A right mouse click on a note show the following menu :

Edit drawing settings allows to change the fill color

### Note

A note may contain any text, a note is resizeable. To change the text of a note choose the edit entry of its menu or double click on it, this open a window containing the text, close the window to end the edition :

A right click on the edited note calls a dialog allowing some text manipulations thanks Qt.

A right mouse click on a note show the following menu :

The font may be changed, by default the font is the one used to write the other texts.

The color of the text may be changed, a text is black by default.

Edit drawing settings allows to change the fill color

Select linked items select all the items connected this the current one through any line, in the previous picture this select all except the package, the text “upper diagram :” and the use case diagram icon.

### Text

Text is another way to write a text, contrary to the note a text is written alone (see “upper diagram :” on the picture below), by default a text contains blabla: a text cannot be empty. The edition of a text is done like for a note. A text is resizeable, a resize is not automatically done when the contains is modified.

A right mouse click on a text show the following menu :

### Image

You can directly insert an image independently of the use of stereotype part of a profile, the size of the image is followed when the zoom if 100%, else the image is resized accordingly to the zoom. Like for a profile the image can be specified through an absolute path, or a path relative to the root directory for the icons or relative to the project directory. In case the path of an icon is not absolute, the icon are searched first using the root directory for the icons, then using the current directory, then using the project directory.

When you insert an image or edit one the following dialog appears :

A right mouse click on an image show the following menu :

### Diagram icon

A diagram icon is a shortcut to a diagram, this allows to quickly navigate through the diagram without limitation (a class or some other item kinds may be associated to only one diagram). The used icon indicates the diagram kind, but its name is not written.

A double mouse left click on a diagram icon opens the diagram, the open entry of the diagram icon menu does the same thing.

A right mouse click on a diagram icon show the following menu :

The other diagram's elements have an own chapter, refer to them.

Previous : collaboration diagram

Next : object diagram