Define graphical layout of the parameter menu.
annotation(Dialog(enable = true, tab = "General", group = "Parameters", showStartAttribute = false, colorSelector = false, groupImage = "modelica://MyPackage/Resources/Images/image.png", connectorSizing = false));
The annotations tab
and
group
define the placement of the
component or of variables in a dialog with optional tab and group
specification. If enable = false
, the
input field may be disabled [and no input can be given]. If
showStartAttribute = true
the dialog
should allow the user to set the start-value and the fixed
attribute for the variable instead of the value-attribute [this is
primarily intended for non-parameter values and avoids introducing
a separate parameter for the start-value of the variable].
If colorSelector=true
, it indicates that an
rgb-value selector can be presented for a vector of three elements
and generate values 0..255
(the annotation should be
useable both for vectors of Integers and Reals).
The annotation groupImage
references an image using an Modelica URI, and the image is
intended to be shown together with the parameter-group (only one
image per group is supported). Disabling the input field will not
disable the image.
The value of the connectorSizing
annotation must be a literal false or true value [since if the
value is an expression, the connectorSizing
functionality is conditional and this will then lead easily to
wrong models]. If connectorSizing = false
, this
annotation has no effect. If connectorSizing = true
,
the corresponding variable must be declared with the parameter
prefix, must be a subtype of a scalar Integer and must have a
literal default value of zero [since this annotation is designed
for a parameter that is used as vector dimension and the dimension
of the vector should be zero when the component is dragged or
redeclared; furthermore, when a tool does not support the
connectorSizing annotation, dragging will still result in a correct
model]. If connectorSizing = true
, a tool may set the
parameter value in a modifier automatically, if used as dimension
size of a vector of connectors. [The connectorSizing
annotation is used in cases where connections to a vector of
connectors shall be made and a new connection requires to resize
the vector and to connect to the new index (unary connections). The
annotation allows a tool to perform these two actions in many cases
automatically. This is, e.g., very useful for state machines and
for certain components of fluid libraries.]
Annotation "Dialog" is defined as:
record Dialog parameter String tab = "General"; parameter String group = "Parameters"; parameter String groupImage = ""; parameter Boolean enable = true; parameter Boolean showStartAttribute = false; parameter Boolean connectorSizing = false; parameter Boolean colorSelector = false; parameter Selector loadSelector; parameter Selector saveSelector; end Dialog; record Selector parameter String filter=""; parameter String caption=""; end Selector;
A parameter dialog is a sequence of tabs with a sequence of groups inside them.
A Selector
displays a file dialog to select a file:
Parameter filter
only shows files that fulfill the
given pattern defined by "text1 (*.ext1);;text2
(*.ext2);
" to show only files with file extension
*.ext1
or *.ext2
and displaying a
description text "text1
" and "text2
",
respectively. Parameter caption is the text displayed in the dialog
menu. Parameter loadSelector
is used to select an
existing file for reading, whereas parameter
saveSelector
is used to define a file for writing.
model DialogDemo parameter Boolean b = true "Boolean parameter"; parameter Modelica.SIunits.Length length "Real parameter with unit"; parameter Integer nInports=0 annotation(Dialog(connectorSizing=true)); parameter Real r1 "Real parameter in Group 1" annotation(Dialog(group="Group 1")); parameter Real r2 "Disabled Real parameter in group 1" annotation(Dialog(group="Group 1", enable = not b)); parameter Real r3 "Real parameter in Tab 1" annotation(Dialog(tab="Tab 1")); parameter Real r4 "Real parameter in Tab 1 and Group 2" annotation(Dialog(tab="Tab 1", group="Group 2")); StepIn stepIn[nInports]; ... end DialogDemo;