ModelEditor: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
 
(11 intermediate revisions by the same user not shown)
Line 25: Line 25:
! Feature !! Prio || Version || Status
! Feature !! Prio || Version || Status
|-
|-
| Use only one document and one editor with a combobox to select open diagrams || 1 || 3.6 || Done
| Fix i18n and translate to German || 1 || 4.6 || Done
|-
|-
| Change key short cut for "Rename" (reserve F2 for "Goto source") to <Return> || 1 || 3.6 || Done
| Support High-DPI screen || 2 || 4.6 || Done
|-
|-
| Support model specific customization || 1 || 3.7 || Done
| Selecting a size- or drag-marker should always prefer already selected elements before selecting a new element || 1 || || Open
|-
|-
| Edit element name in diagram || 1 || 3.7 || Done
| Improve positioning of align buttons for small icons || 1 || || Open
|-
|-
| Implement user-configurable relations || 1 || || Open
| Show selection of size-locked elements || 1 || || Open
|-
|-
| Fix i18n and translate to German || 1 || In Work
| Add some more configurable element colors || 2 || || Open
|-
|-
| User may drag end of relation to different element on diagram || 2 || 3.7 || Done
| Implement temporary swimlane (with qualifier) for easier layout || 2 || || Open
|-
|-
| Implement action "open parent diagram" with key short cut Ctrl+Shift+P || 2 || 3.6 || Done
| Define custom definitions within qmodel file (additionally to separate files) || 2 || || Open
|-
|-
| Implement copy of diagram image to clipboard for selected elements || 2 || 3.7 || Done
| Support line width of shapes and relations || 2 || || Open
|-
|-
| Improve declaration parser of class members || 2 || 3.7 || Done
| Improve label layout of bold multi-line labels || 2 || || Open
|-
|-
| Restore last used toolbar for each diagram || 2 || 3.7 || Done
| Improve diagram zooming || 2 || || Open
|-
|-
| Export diagrams as PNG or SVG file || 2 || || Open
| Improve single- and multi-selection behavior || 2 || || Open
|-
|-
| Add horizontal and vertical swim lanes to diagrams || 2 || || Open
| Implement relation type for state diagram (auto counter) || 2 || || Open
|-
|-
| Implement command line tool for exporting diagrams || 2 || || Open
| Configure state diagram elements and toolbar || 2 || || Open
|-
|-
| Implement relation type for state diagram (auto counter) || 2 || || Open
| Implement semi-auto-layout for sequence diagrams || 2 || || Open
|-
|-
| Configure state diagram elements and toolbar || 2 || || Open
| Configure deployment diagram elements and toolbar || 2 || || Open
|-
|-
| Implement semi-auto layout for sequence diagrams || 2 || || Open
| Improve reverse-engineering of source with extra include directories or include files with glue code || 3 || || Open
|-
|-
| Configure sequence diagram elements and toolbar || 2 || || Open
| Implement hierarchical relations || 3 || || Open
|-
|-
| Implement printing of diagrams || 3 || || Open
| Implement printing of diagrams || 3 || || Open
Line 66: Line 66:
|-
|-
| Use a nice icon font for member attributes || 3 || || Open
| Use a nice icon font for member attributes || 3 || || Open
|-
| Implement command line tool for exporting diagrams || 3 || || Open
|}
|}
== New in Version 3.7 ==
Please note that version 3.7 is not released yet and some of the changes described here are even not finished on git master.
=== Model Specific Configuration ===
In version 3.6 customization definition files (icons and toolbars) are loaded from the QtCreator installation folder
(share/qtcreator/modeleditor/*.def).
Since version 3.7 a model may define another directory from where additional customization files (*.def) will be loaded.
The directory may be given as an absolute path or relative to the .qmodel file. It is entered in the properties of
the topmost package of the model.
=== Drag Relation Ends ===
Select one end of a relation, drag it to another item and drop it over the item. The relation will now connect to the
new item. Of course the new item must accept the relations of that type - only classes accept inheritances and
associtations.
=== Minor Improvements ===
==== Copy Diagram ====
''Since Version 3.6:'' When no element is selected on a diagram the menu item "Edit / Copy" (Ctrl+C) is enabled.
The complete diagram will be copied into the system's clipboard as a png image with about 300dpi.
'''New for Version 3.7:''' If some elements are selected only these elements and their ''secondary'' selected elements
will be copied into the clipboard as image. ''Secondary'' selected means all items which lays upon a selected
item (e.g. items within a ''Boundary'') or relations where both ends are selected.
==== Store Last Used Toolbar ====
For each diagram the toolbar that was used at last will be saved into the model file. When the model file is loaded
again opening a diagram will show the same toolbar again. This saves one mouse click to edit the different type of
diagrams.
==== Improved Class Member Editor ====
The parser for class members got some enhancments like new accepted C++ keywords, ignore member initialization,
ignore C comments. See below for detailed description of the parser's features and limitations.
==== New Syntax for Customization Definition Files ====
The customization definition files now uses a syntax which is similar to QML.


== Overview of Keyboard Qualifiers ==
== Overview of Keyboard Qualifiers ==
Line 133: Line 89:
| While creating a new relation or dragging an end of a relation create a new intermediate point || Shift
| While creating a new relation or dragging an end of a relation create a new intermediate point || Shift
|-
|-
| While creating a new realtion or dragging an end of a realtion delete the last intermediate point || Control
| While creating a new relation or dragging an end of a relation delete the last intermediate point || Control
|-
| Select a swim-lane and drag it without dragging all elements right/below it || Control + Shift
|-
|-
| ''To be continued...'' ||
| ''To be continued...'' ||
Line 149: Line 107:
==== Declarations may span several lines only in brackets ====
==== Declarations may span several lines only in brackets ====


This works: (since version 3.7)
This works: (since version 4.0)


<code>
<code>
Line 189: Line 147:


The parser is very simple. It is not a real C++ parser but a simple text parser - a real C++ parser  
The parser is very simple. It is not a real C++ parser but a simple text parser - a real C++ parser  
like it is used for code completion or refactoring need more context than is available in the class
like it is used for code completion or refactoring needs more context than is available in the class
members edit field.
members edit field.


Line 198: Line 156:
* Funtion pointer declarations are interpreted as methods.
* Funtion pointer declarations are interpreted as methods.
* throw() and noexpect() specifiers are not ignored but will make the declaration a method
* throw() and noexpect() specifiers are not ignored but will make the declaration a method
* Declarations with several comma separated names (e.g. int a,b;) are not correctly interpreted as such


== Screenshots ==
== Screenshots ==
Line 220: Line 179:
The elements for use-case diagrams (and activity diagrams) are configured with icon and color using a simple def-file format.
The elements for use-case diagrams (and activity diagrams) are configured with icon and color using a simple def-file format.


Example:
Example (new syntax since version 4.0):
  <nowiki>
  <nowiki>
Icon UseCase
Icon {
     Title: "Use-Case"
    id: UseCase
     Elements: item
     title: "Use-Case"
     Stereotype: 'usecase'
     elements: item
     Display: icon
     stereotype: 'usecase'
     Width: 40
     display: icon
     Height: 20
     width: 40
     BaseColor: #5fb4f0
     height: 20
Begin
     baseColor: #5fb4f0
    Ellipse 20, 10, 20, 10
    Shape {
End
        Ellipse { x: 20; y: 10; radiusX: 20; radiusY: 10 }
    }
}
</nowiki>
</nowiki>



Latest revision as of 12:05, 14 May 2020


ModelEditor plugin was released as an experimental plugin with QtCreator 3.6. You must manually enable the plugin in "Help / About Plugins" dialog.

If you want to try latest fixes and improvements, please compile QtCreator yourself from master branch or download latest unstable snapshot from http://download.qt.io/snapshots/qtcreator/master/. Of course there is no support for these versions. You have been warned! There are no binary packages of the plug-in available for QtCreator 3.5 (or older).

Features

  • Create UML-alike models with structured diagrams
  • Define packages, classes, components, use-cases and activities
  • Edit element properties including multi-selection (e.g. change color of many elements at once)
  • Design your diagrams with only a few clicks because of automatic coloring, easy alignment and automatic layout of labeling
  • Add C++ classes and components by simply dragging files from project explorer on diagrams
  • Navigate from class on diagram to source code
  • Configure your own model elements with custom icons
  • Store models and diagrams in a single xml file

Examples

The unfinished model of ModelEditor itself: modeleditor.qmodel

Planned Changes

Feature Prio Version Status
Fix i18n and translate to German 1 4.6 Done
Support High-DPI screen 2 4.6 Done
Selecting a size- or drag-marker should always prefer already selected elements before selecting a new element 1 Open
Improve positioning of align buttons for small icons 1 Open
Show selection of size-locked elements 1 Open
Add some more configurable element colors 2 Open
Implement temporary swimlane (with qualifier) for easier layout 2 Open
Define custom definitions within qmodel file (additionally to separate files) 2 Open
Support line width of shapes and relations 2 Open
Improve label layout of bold multi-line labels 2 Open
Improve diagram zooming 2 Open
Improve single- and multi-selection behavior 2 Open
Implement relation type for state diagram (auto counter) 2 Open
Configure state diagram elements and toolbar 2 Open
Implement semi-auto-layout for sequence diagrams 2 Open
Configure deployment diagram elements and toolbar 2 Open
Improve reverse-engineering of source with extra include directories or include files with glue code 3 Open
Implement hierarchical relations 3 Open
Implement printing of diagrams 3 Open
User may drag end of relation for nicer diagram layout 3 Open
Use a nice icon font for member attributes 3 Open
Implement command line tool for exporting diagrams 3 Open

Overview of Keyboard Qualifiers

ModelEditor uses Shift, Control and Alt qualifiers in a number of use-cases:

Use-Case Qualifier
Multi-select items on diagrams Control
Show vertical and horizontal alignment lines while dragging an item Shift
Drag item over package and drop it into it Alt
Click on relation to create a new intermediate point Shift
Click on relation's intermediate point to delete it Control
While creating a new relation or dragging an end of a relation create a new intermediate point Shift
While creating a new relation or dragging an end of a relation delete the last intermediate point Control
Select a swim-lane and drag it without dragging all elements right/below it Control + Shift
To be continued...

Class Member Editor

The class member editor supports a subset of C++ syntax to define attributes and methods in class items and some extensions to the C++ syntax.

Comments

If you copy some code into the member class text field C comments /* ... */ and C++ comments // ... are ignored.

Declarations may span several lines only in brackets

This works: (since version 4.0)

void method(int a,
            int b);

but this does not:

void
method(int a, int b);

Lazy parser

  • You don't need to write a colon after specifiers like "public" or "signals".
  • You don't need to write a semicolon at the end of a line

Stereotypes

A declaration may be pretended with a stereotype. Example:

<<setter>> void setPosition(const QPoint &pos);

Member grouping

Like "public:" or "slots:" you may use "[group]" to group members. Example:

[Geometry]
QPointF position;
QSizeF size;

Limitations

The parser is very simple. It is not a real C++ parser but a simple text parser - a real C++ parser like it is used for code completion or refactoring needs more context than is available in the class members edit field.

Because of that the parser cannot recognize all valid C++ syntax. Some limitations are:

  • Multi-line declarations (see above)
  • Preprocessor macros will not be translated. But some Qt keywords are known (e.g. Q_SLOT)
  • Funtion pointer declarations are interpreted as methods.
  • throw() and noexpect() specifiers are not ignored but will make the declaration a method
  • Declarations with several comma separated names (e.g. int a,b;) are not correctly interpreted as such

Screenshots


ModelEditor with toolbar, class diagram, model tree and selected element's properties

Several features help designing well structured diagrams easily:

  • Create a "Boundary" box with a dotted border and a title. Everything within that box will move as a group if you drag the box.
  • Use Shift-Click on a relation to create a new sampling point. Use Ctrl-Click on a sampling point to remove it again.
  • Press Shift while dragging an association from a class to create a new sampling point. Drop association over same class to create a self-association.
  • If possible the end-point of a relation is moved automatically to draw the line to its neighbored sampling point vertically or horizontally.


A package diagram

The depth of the elements on the diagram directly relates to the depth in the structured model. Elements stacked on other elements of same type are drawn in darker colors automatically.


A use-case diagram

The elements for use-case diagrams (and activity diagrams) are configured with icon and color using a simple def-file format.

Example (new syntax since version 4.0):

Icon {
    id: UseCase
    title: "Use-Case"
    elements: item
    stereotype: 'usecase'
    display: icon
    width: 40
    height: 20
    baseColor: #5fb4f0
    Shape {
        Ellipse { x: 20; y: 10; radiusX: 20; radiusY: 10 }
    }
}

With that def-file one can introduce new icons for stereotypes (e.g. the Entity, Boundary and Control icons for classes), new elements (e.g. the Use Case, Actor) or tool-bars.


An activities diagram
  • Use multi-selection to align elements easily.
  • Change color or stereotype of all selected elements simultaneously.


Add elements to model and diagrams
  • Press one of the small buttons in the upper right toolbar to add a new element to the model
  • Drag an icon from the toolbar to a diagram to create a new element
  • Drag a model element from the model tree to a diagram to add the element and all its relations to the diagram.
  • Drag a C++ source code from the project explorer to a diagram to add the file as a component or any of its declared classes.
  • Drag one of the arrows right to a selected element to another element on the diagram to create a new relation


Element's properties in detail
  • This is not standard UML: A namespace property
  • The attributes and methods are written as C++ declarations.
  • Only a few properties define the look of the elements: a color, a role and an extra enhancement flag.