OMEdit – OpenModelica Connection Editor is the new Graphical User
Interface for graphical model editing in OpenModelica. It is implemented
in C++ using the Qt graphical user interface library and supports
the Modelica Standard Library that is included in the latest
OpenModelica installation. This chapter gives a brief introduction to
OMEdit and also demonstrates how to create a DCMotor model using the
editor.

OMEdit provides several user friendly features for creating, browsing,
editing, and simulating models:

OMEdit can be launched using the executable placed in
OpenModelicaInstallationDirectory/bin/OMEdit/OMEdit.exe. Alternately,
choose OpenModelica > OpenModelica Connection Editor from the start menu
in Windows.

The default location of the browsers are shown in Figure 6.
All browsers except for Message Browser can be docked into left or right
column. The Messages Browser can be docked into top or bottom
areas. If you want OMEdit to remember the new docked position of the
browsers then you must enable Preserve User's GUI Customizations option,
see section General.

To view the Libraries Browser click View > Windows > Libraries Browser.
Shows the list of loaded Modelica classes. Each item of the Libraries
Browser has right click menu for easy manipulation and usage of the
class. The classes are shown in a tree structure with name and icon. The
protected classes are not shown by default. If you want to see the
protected classes then you must enable the Show Protected Classes
option, see section General.

Displays the HTML documentation of Modelica classes. It contains the
navigation buttons for moving forward and backward. It also contains
a WYSIWYG editor which allows writing class documentation in HTML format.
To see documentation of any class, right click the Modelica class
in Libraries Browser and choose View Documentation.

The class variables are structured in the form of the tree and are
displayed in the Variables Browser. Each variable has a checkbox.
Ticking the checkbox will plot the variable values. There is a find box
on the top for filtering the variable in the tree. The filtering can be
done using Regular Expression, Wildcard and Fixed String. The complete
Variables Browser can be collapsed and expanded using the Collapse All
and Expand All buttons.

The browser allows manipulation of changeable parameters for
Re-simulating a Model. It also displays the unit and
description of the variable.

The Welcome Perspective shows the list of recent files and the list of
latest news from https://www.openmodelica.org/.
See Figure 10. The orientation of recent files and latest news can be
horizontal or vertical. User is allowed to show/hide the latest news.
See section General.

The Plotting Perspective shows the simulation results of the models.
Plotting Perspective will automatically become active when the
simulation of the model is finished successfully. It will also become
active when user opens any of the OpenModelica’s supported result file.
Similar to Modeling Perspective this perspective can also be viewed in
two different modes, the tabbed view and subwindow view, see section
General.

For each Modelica class one Model Widget is created. It has a statusbar
and a view area. The statusbar contains buttons for navigation between
the views and labels for information. The view area is used to display
the icon, diagram and text layers of Modelica class. See Figure 14.

In order to connect one component model to another the user first needs
to enable the connect mode () from the toolbar.

Move the mouse over the connector. The mouse cursor will change from arrow cursor to cross cursor.
To start the connection press left button and move while keeping the button pressed. Now release the left button.
Move towards the end connector and click when cursor changes to cross cursor.

Successful simulation of model produces the result file which contains
the instance variables that are candidate for plotting. Variables
Browser will show the list of such instance variables. Each variable has
a checkbox, checking it will plot the variable. See Figure 12.

Draws a two-dimensional parametric diagram, between variables x and y,
with y as a function of x. You can have multiple Plot Parametric
windows by clicking on the New Plot Parametric toolbar button ().

Plots an array variable so that the array elements' indexes are on the x-axis and corresponding
elements' values are on the y-axis. The time is controlled by the slider above the variable tree.
When an array is present in the model, it has a principal array node in the variable tree.
To plot this array as an Array Plot, match the principal node. The principal node may be expanded
into particular array elements. To plot a single element in the Time Plot, match the element.
A new Array Plot window is opened using the New Array Plot Window toolbar button ().

Plots the first array elements' values on the x-axis versus the second array elements' values on the y-axis. The time
is controlled by the slider above the variable tree. To create a new Array Parametric Plot, press
the New Array Parametric Plot Window toolbar button (), then match the principle
array node in the variable tree view to be plotted on the x-axis and match the principle array node to be plotted
on the y-axis.

The Variables Browser allows manipulation of changeable
parameters for re-simulation.
After changing the parameter values user can click on the re-simulate
toolbar button (), or right click the model in Variables Browser and choose
re-simulate from the menu.

The 3d visualization is based on OpenSceneGraph. In order to run the
visualization simply right click the class in Libraries Browser an
choose “Simulate with Animation” as shown in Figure 15.

Figure 15 OMEdit Simulate with Animation.

One can also run the visualization via Simulation > Simulate with Animation from the menu.

When simulating a model in animation mode, the flag +d=visxml is set.
Hence, the compiler will generate a scene description file _visual.xml which stores all information on the multibody shapes.
This scene description references all variables which are needed for the animation of the multibody system.
When simulating with +d=visxml, the compiler will always generate results for these variables.

After the successful simulation of the model, the visualization window will
show up automatically as shown in Figure 16.

Figure 16 OMEdit 3D Visualization.

The animation starts with pushing the play button. The animation is played until stopTime or until the pause button is pushed.
By pushing the previous button, the animation jumps to the initial point of time.
Points of time can be selected by moving the time slider or by inserting a simulation time in the Time-box.
The speed factor of animation in relation to realtime can be set in the Speed-dialog.
Other animations can be openend by using the open file button and selecting a result file with a corresping scene description file.

The 3D camera view can be manipulated as follows:

Operation

Key

Mouse Action

Move Closer/Further

none

Wheel

Move Closer/Further

Right Mouse Hold

Up/Down

Move Up/Down/Left/Right

Middle Mouse Hold

Move Mouse

Move Up/Down/Left/Right

Left and Right Mouse Hold

Move Mouse

Rotate

Left Mouse Hold

Move Mouse

Shape context menu

Right Mouse + Shift

Predefined views (Isometric, Side, Front, Top) can be selected and the scene can be tilted by 90° either clock or anticlockwise with the rotation buttons.

The shapes that are displayed in the viewer can be selected with shift + right click.
If a shape is selected, a context menu pops up that offers additional visualization features

The following features can be selected:

Menu

Description

Change Transparency

The shape becomes either transparent or intransparent.

Make Shape Invisible

The shape becomes invisible.

Change Color

A color dialog pops up and the color of the shape can be set.

Apply Check Texture

A checked texture is applied to the shape.

Apply Custom Texture

A file selection dialog pops up and an image file can be selected as a texture.

Interactive simulation is enabled by selecting interactive
simulation in the General tab of the simulation settings.

There are two main modes of execution: asynchronous and synchronous
(simulate with steps). The difference is that in synchronous (step mode),
OMEdit sends a command to the simulation for each step that the simulation
should take. The asynchronous mode simply tells the simulation to run and
samples variables values in real-time; if the simulation runs very fast,
fewer values will be sampled.

When running in asynchronous mode, it is possible to simulate the model
in real-time (with a scaling factor just like simulation flag
-rt, but with the ability to change the scaling
factor during the interactive simulation). In the synchronous mode, the
speed of the simulation does not directly correspond to real-time.

Users can create shapes of their own by using the shape creation tools
available in OMEdit.

Line Tool – Draws a line. A line is created with a minimum of two

points. In order to create a line, the user first selects the
line tool from the toolbar and then click on the Icon/Diagram
View; this will start creating a line. If a user clicks again on
the Icon/Diagram View a new line point is created. In order to
finish the line creation, user has to double click on the
Icon/Diagram View.

Polygon Tool – Draws a polygon. A polygon is created in a similar

fashion as a line is created. The only difference between a line
and a polygon is that, if a polygon contains two points it will
look like a line and if a polygon contains more than two points
it will become a closed polygon shape.

Rectangle Tool – Draws a rectangle. The rectangle only contains two

points where first point indicates the starting point and the
second point indicates the ending the point. In order to create
rectangle, the user has to select the rectangle tool from the
toolbar and then click on the Icon/Diagram View, this click will
become the first point of rectangle. In order to finish the
rectangle creation, the user has to click again on the
Icon/Diagram View where he/she wants to finish the rectangle. The
second click will become the second point of rectangle.

The user can select any of the shape tools and start drawing on the
Icon/Diagram View. The shapes created on the Diagram View of Model
Widget are part of the diagram and the shapes created on the Icon View
will become the icon representation of the model.

For example, if a user creates a model with name testModel and add a
rectangle using the rectangle tool and a polygon using the polygon tool,
in the Icon View of the model. The model’s Modelica Text will appear as
follows:

In the above code snippet of testModel, the rectangle and a polygon are
added to the icon annotation of the model. Similarly, any user defined
shape drawn on a Diagram View of the model will be added to the diagram
annotation of the model.

If you want to use same styles or same JavaScript for the classes contained inside a package then
you can define __OpenModelica_infoHeader annotation inside the Documentation annotation of a package.
For example,

In the above example model M does not need to define the javascript function HelloWorld.
It is only defined once at the package level using the __OpenModelica_infoHeader and then all classes
contained in the package can use it.

In addition styles and JavaScript can be added from file locations using Modelica URIs.
Example:

Show Protected Classes – If enabled then Libraries Browser will also list the protected classes.

Modeling View Mode

Tabbed View/SubWindow View – Sets the view mode for modeling.

Default View

Icon View/DiagramView/Modelica Text View/Documentation View – If no
preferredView annotation is defined then this setting is used to show
the respective view when user double clicks on the class in the
Libraries Browser.

Enable Code Folding - Enable/Disable the code folding. When code
folding is enabled multi-line annotations are collapsed into a
compact icon (a rectangle containing "...)"). A marker containing
a "+" sign becomes available at the left-side of the involved line,
allowing the code to be expanded/re-collapsed at will.

Match Parentheses within Comments and Quotes – Enable/Disable the matching of parentheses within comments and quotes.

Enable Line Wrapping – Enable/Disable the line wrapping.

Font

Font Family – Shows the names list of available fonts.
Sets the font for the editor.

OpenModelica specific annotation to define the command line options needed to simulate the model.
For example if you always want to simulate the model with a specific matching algorithm and index
reduction method instead of the default ones then you can write the following code,

The annotation is a space separated list of options where each option is either just a command line
flag or a flag with a value.

In OMEdit right click inside the icon/diagram view of the model and choose Properties.
Then OMC Flags and in the text field write --matchingAlgorithm=BFSB --indexReductionMethod=dynamicStateSelection.

If you want to ignore this annotation then use setCommandLineOptions("--ignoreCommandLineOptionsAnnotation=true").
In OMEdit Tools > Options > Simulation check Ignore __OpenModelica_commandLineOptions annotation.

OpenModelica specific annotation to define the simulation options needed to simulate the model.
For example if you always want to simulate the model with a specific solver instead of the
default DASSL and would also like to see the cpu time then you can write the following code,

The annotation is a comma separated list of options where each option is a simulation flag
with a value. For flags that doesn't have any value use () (See the above code example).

In OMEdit open the Simulation Setup and set the Simulation Flags then
in the bottom check Save __OpenModelica_simulationFlags annotation inside model and click on OK.

If you want to ignore this annotation then use setCommandLineOptions("--ignoreSimulationFlagsAnnotation=true").
In OMEdit Tools > Options > Simulation check Ignore __OpenModelica_simulationFlags annotation.

By default OMEdit loads the Modelica Standard Library (MSL) as a system library. System libraries are read-only.
If you want to edit MSL you need to load it as user library instead of system library. We don't recommend editing
MSL but if you really need to and understand the consequences then follow these steps,

In order to make a transition from one state to another the user first needs
to enable the transition mode () from the toolbar.

Move the mouse over the state. The mouse cursor will change from arrow cursor to cross cursor.
To start the transition press left button and move while keeping the button pressed. Now release the left button.
Move towards the end state and click when cursor changes to cross cursor.

A Create Transition dialog box will appear which allows you to set the transition attributes.
Cancelling the dialog will cancel the transition.

Double click the transition or right click and choose Edit Transition to modify the transition attributes.

Support for Modelica state machines was added in the Modelica Language Specification
v3.3. A subtle problem can occur if Modelica v3.2 libraries are loaded, e.g., the
Modelica Standard Library v3.2.2, because
in this case OMC automatically switches into Modelica v3.2 compatibility mode.
Trying to simulate a state machine in Modelica v3.2 compatibility mode results
in an error. It is possible to use the OMC flag --std=latest in order to ensure
(at least) Modelica v3.3 support. In OMEdit this can be achieved by
setting that flag in the Tools > Options > Simulation dialog.