.. _UML Diagrams:

UML Diagrams
============

.. |select| image:: ../../images/icons/obj16/graphviz_select.png
  :class: inline

.. |prefs| image:: ../../images/icons/obj16/graphviz_preferences.png
  :class: inline

You can create UML diagrams by right-clicking on a class in any of the views and selecting **Show Diagram** or from the editor, right-click on a class name and select **Show > Diagram**.

You can select the relevant classes for which to draw the diagram from the |select| **Select Types** button (see :ref:`UML Diagrams Select Types <UML Diagrams-Select Types>`).

For the *selected* classes, the diagram can display inheritance, associations (pointers) and class members |prefs| (see :ref:`UML Diagrams Preferences <UML Diagrams-Preferences>`).

.. note::
  
  To see the inherited pointers of a class, you need to *select* its parents and show at least one level of associations.

For the description of diagram drawing conventions go to :ref:`UML Diagrams Legend <UML Diagrams-Legend>`.

In the diagram editor you can right-click on classes and select **Go To Source** to jump to the source code.

You can jump to the declaration of a field, event, or method via right-click **Go To Source**.

To show or hide members of a class use right-click **Members**.

.. figure:: ../../images/vlogdt-class-diagram-new.png

.. _UML Diagrams-Select Types:

UML Diagrams - Select Types
~~~~~~~~~~~~~~~~~~~~~~~~~~~

A diagram is created around a set of relevant classes you specify. For example when you decide to show parents, children or associations by using :ref:`UML Diagrams Preferences <UML Diagrams-Preferences>`, it applies only to selected classes. In a diagram the selected classes are colored with yellow fill (see also the :ref:`UML Diagrams Legend <UML Diagrams-Legend>`).

The right list shows the selected classes. Use left/right arrows or double click to select the relevant classes.

.. figure:: ../../images/vlogdt-class-diagram-select-new.png

You can also add/remove an element to/from the current selection by right clicking on it in the diagram and choosing "Select Type"/"Deselect Type":

.. figure:: ../../images/vlogdt-class-diagram-select_classes_rightclick-new.png

.. _UML Diagrams-Preferences:

UML Diagrams - Preferences
~~~~~~~~~~~~~~~~~~~~~~~~~~

For the selected classes you can choose to show parents, children, associations (pointers), customize the graph layout etc.

.. figure:: ../../images/common/dvt-class-diagram-preferences-new.png

You may choose to:

-  Show all, selected only, a specified depth or no parents for selected classes
-  Show all, selected only, a specified depth or no children for selected classes
-  Show all, selected only, a specified depth or no associations (pointers) for selected classes
-  Show all, public or no members - fields, events, methods (functions, tasks) - for the selected classes
-  Customize the graph layout
-  Show full method signature
-  Show labels on association edges
-  Route edges orthogonally
-  Show package information
-  Group by package

.. _UML Diagrams-Legend:

UML Diagrams - Legend
~~~~~~~~~~~~~~~~~~~~~

.. list-table::

   * - .. figure:: ../../images/vlogdt-class-diagram-legend-a-class-new.png
     - A class.
   * - .. figure:: ../../images/vlogdt-class-diagram-legend-selected-class-new.png
     - A selected class.
   * - .. figure:: ../../images/vlogdt-class-diagram-legend-class-with-members-new.png
     - A selected class with members. The cells are (in order) for fields, events, and methods (functions and tasks). Each member name is preceded by an access modifier flag: ``+ (plus)`` for public, ``- (minus)`` for private, and ``# (hash)`` for protected.
   * - .. figure:: ../../images/vlogdt-class-diagram-legend-predefined-class-new.png
     - A predefined class.
   * - .. figure:: ../../images/vlogdt-class-diagram-legend-inheritance-new.png
     - Inheritance: ChildClass inherits from ParentClass.
   * - .. figure:: ../../images/vlogdt-class-diagram-legend-template-inheritance-new.png
     - Inheritance with parameters: SetParams inherits from AClassWithParams#(int) (sets T to int).
   * - .. figure:: ../../images/vlogdt-class-diagram-legend-interface-new.png
     - Implementation: AClass implements InterfaceClass.
   * - .. figure:: ../../images/vlogdt-class-diagram-legend-association-new.png
     - Association: AClass points to BClass (has a field f_bcl of type BClass).
