Skip to content

Commit

Permalink
Remove presumably unintended indentation inside lstlisting environmen…
Browse files Browse the repository at this point in the history
…ts (modelica#2595)

* Remove presumably unintended indentation inside lstlisting environments
* Cleanup related to \lstinline in examples of 'each'
  • Loading branch information
henrikt-ma committed Jun 26, 2020
1 parent ddb4483 commit 8c6a887
Show file tree
Hide file tree
Showing 14 changed files with 315 additions and 313 deletions.
114 changes: 56 additions & 58 deletions chapters/annotations.tex
Original file line number Diff line number Diff line change
Expand Up @@ -348,11 +348,10 @@ \subsection{Common Definitions}\doublelabel{common-definitions}

The following common definitions are used to define graphical
annotations in the later sections.

\begin{lstlisting}[language=modelica]
type DrawingUnit = Real(final unit="mm");
type Point = DrawingUnit[2] "{x, y}";
type Extent = Point[2] "Defines a rectangular area {{x1, y1}, {x2, y2}}";
type DrawingUnit = Real(final unit="mm");
type Point = DrawingUnit[2] "{x, y}";
type Extent = Point[2] "Defines a rectangular area {{x1, y1}, {x2, y2}}";
\end{lstlisting}
The interpretation of \lstinline!unit! is with respect to printer output in
natural size (not zoomed).
Expand Down Expand Up @@ -447,17 +446,16 @@ \subsubsection{Graphical Properties}\doublelabel{graphical-properties}

Properties of graphical objects and connection lines are described using
the following attribute types.

\begin{lstlisting}[language=modelica]
type Color = Integer[3](min=0, max=255) "RGB representation";
type Color = Integer[3](min=0, max=255) "RGB representation";

constant Color Black = zeros(3);
type LinePattern = enumeration(None, Solid, Dash, Dot, DashDot, DashDotDot);
type FillPattern = enumeration(None, Solid, Horizontal, Vertical,
Cross, Forward, Backward, CrossDiag, HorizontalCylinder, VerticalCylinder, Sphere);
type BorderPattern = enumeration(None, Raised, Sunken, Engraved);
type Smooth = enumeration(None, Bezier);
type EllipseClosure = enumeration(None, Chord, Radial);
constant Color Black = zeros(3);
type LinePattern = enumeration(None, Solid, Dash, Dot, DashDot, DashDotDot);
type FillPattern = enumeration(None, Solid, Horizontal, Vertical,
Cross, Forward, Backward, CrossDiag, HorizontalCylinder, VerticalCylinder, Sphere);
type BorderPattern = enumeration(None, Raised, Sunken, Engraved);
type Smooth = enumeration(None, Bezier);
type EllipseClosure = enumeration(None, Chord, Radial);
\end{lstlisting}
The \lstinline!LinePattern! attribute \lstinline!Solid! indicates a normal line, \lstinline!None! an
invisible line, and the other attributes various forms of dashed/dotted
Expand Down Expand Up @@ -513,9 +511,9 @@ \subsubsection{Graphical Properties}\doublelabel{graphical-properties}
endpoints of an elliptical arc are to be joined (see \autoref{ellipse} Ellipse).

\begin{lstlisting}[language=modelica]
type Arrow = enumeration(None, Open, Filled, Half);
type TextStyle = enumeration(Bold, Italic, UnderLine);
type TextAlignment = enumeration(Left, Center, Right);
type Arrow = enumeration(None, Open, Filled, Half);
type TextStyle = enumeration(Bold, Italic, UnderLine);
type TextAlignment = enumeration(Left, Center, Right);
\end{lstlisting}
Filled shapes have the following attributes for the border and interior.

Expand Down Expand Up @@ -656,8 +654,8 @@ \subsection{Connections}\doublelabel{connections1}

\begin{example}
\begin{lstlisting}[language=modelica]
connect(a.x, b.x)
annotation(Line(points={{-25,30}, {10,30}, {10, -20}, {40,-20}}));
connect(a.x, b.x)
annotation(Line(points={{-25,30}, {10,30}, {10, -20}, {40,-20}}));
\end{lstlisting}
\end{example}

Expand Down Expand Up @@ -697,10 +695,9 @@ \subsection{Connections}\doublelabel{connections1}

\begin{example}
\begin{lstlisting}[language=modelica]
connect(controlBus.axisControlBus1, axis1.axisControlBus) annotation (
Text(string="%first", index=-1, extent=[-6,3; -6,7]),
Line(points={{-80,-10},{-80,-14.5},{-79,-14.5},{-79,-17},{-65,-17},{-65,-65},
{-25,-65}}));
connect(controlBus.axisControlBus1, axis1.axisControlBus) annotation (
Text(string="%first", index=-1, extent=[-6,3; -6,7]),
Line(points={{-80,-10},{-80,-14.5},{-79,-14.5},{-79,-17},{-65,-17},{-65,-65},{-25,-65}}));
\end{lstlisting}
Draws a connection line and adds the text \emph{axisControlBus1}
ending at \{-6, 3\}+\{-25, -65\} and 4 vertical units of space for the text.
Expand Down Expand Up @@ -937,12 +934,12 @@ \subsection{Variable Graphics and Schematic Animation}\doublelabel{variable-grap
rectangle expanding in vertical direction and its color depending on a
variable overflow:
\begin{lstlisting}[language=modelica]
annotation (
Icon(graphics={Rectangle(
extent=DynamicSelect({{0,0},{20,20}},{{0,0},{20,level}}),
fillColor=DynamicSelect({0,0,255},
if overflow then {255,0,0} else {0,0,255}))}
);
annotation (
Icon(graphics={Rectangle(
extent=DynamicSelect({{0,0},{20,20}},{{0,0},{20,level}}),
fillColor=DynamicSelect({0,0,255},
if overflow then {255,0,0} else {0,0,255}))})
);
\end{lstlisting}
\end{example}

Expand Down Expand Up @@ -973,10 +970,11 @@ \subsubsection{Mouse input}\doublelabel{mouse-input}
A button can be represented by a rectangle changing color depending on a \lstinline!Boolean! variable \lstinline!on! and toggles the
variable when the rectangle is clicked on:
\begin{lstlisting}[language=modelica]
annotation (Icon(graphics={Rectangle(extent=[0,0; 20,20],
fillColor=if on then {255,0,0} else
{0,0,255})},
interaction={ OnMouseDownSetBoolean (on, not on)}));
annotation (Icon(
graphics={Rectangle(
extent=[0,0; 20,20],
fillColor=if on then {255,0,0} else {0,0,255})},
interaction={OnMouseDownSetBoolean (on, not on)}));
\end{lstlisting}
\end{example}

Expand Down Expand Up @@ -1062,12 +1060,12 @@ \section{Annotations for the Graphical User Interface}\doublelabel{annotations-f
When creating a component of the given class, the recommended component name is \emph{name}.

\begin{lstlisting}[language=modelica]
annotation(defaultComponentPrefixes = "prefixes")
annotation(defaultComponentPrefixes = "prefixes")
\end{lstlisting}

When creating a component, it is recommended to generate a declaration of the form
\begin{lstlisting}[language=grammar]
type-prefix type-specifier component-declaration
type-prefix type-specifier component-declaration
\end{lstlisting}

The following prefixes may be included in the string \lstinline!prefixes!: \lstinline!inner!,
Expand All @@ -1080,7 +1078,7 @@ \section{Annotations for the Graphical User Interface}\doublelabel{annotations-f
\end{nonnormative}

\begin{lstlisting}[language=modelica]
annotation(missingInnerMessage = "message")
annotation(missingInnerMessage = "message")
\end{lstlisting}

When an \lstinline!outer! component of the class does not have a corresponding \lstinline!inner!
Expand All @@ -1099,13 +1097,13 @@ \section{Annotations for the Graphical User Interface}\doublelabel{annotations-f
When an instance of model \lstinline!World! is dragged in to the diagram layer, the
following declaration is generated:
\begin{lstlisting}[language=modelica]
inner replaceable World world;
inner replaceable World world;
\end{lstlisting}
\end{example}

A simple type or component of a simple type may have:
\begin{lstlisting}[language=modelica]
annotation(absoluteValue=false);
annotation(absoluteValue=false);
\end{lstlisting}

If \lstinline!false!, then the variable defines a relative quantity, and if true an
Expand All @@ -1120,7 +1118,7 @@ \section{Annotations for the Graphical User Interface}\doublelabel{annotations-f

A model or block definition may contain:
\begin{lstlisting}[language=modelica]
annotation(defaultConnectionStructurallyInconsistent=true)
annotation(defaultConnectionStructurallyInconsistent=true)
\end{lstlisting}

If \lstinline!true!, it is stated that a default connection will result in a
Expand Down Expand Up @@ -1148,7 +1146,7 @@ \section{Annotations for the Graphical User Interface}\doublelabel{annotations-f

A class may have the following annotation:
\begin{lstlisting}[language=modelica]
annotation(obsolete = "message");
annotation(obsolete = "message");
\end{lstlisting}

It indicates that the class ideally should not be used anymore and gives
Expand All @@ -1160,7 +1158,7 @@ \section{Annotations for the Graphical User Interface}\doublelabel{annotations-f

A declaration may have the following annotations:
\begin{lstlisting}[language=modelica]
annotation(unassignedMessage = "message");
annotation(unassignedMessage = "message");
\end{lstlisting}

When the variable to which this annotation is attached in the
Expand Down Expand Up @@ -1348,17 +1346,17 @@ \section{Annotations for the Graphical User Interface}\doublelabel{annotations-f
of a (\lstinline!connectorSizing!) parameter. \emph{Example:} Assume there is a
connector \lstinline!inPorts! and a component \lstinline!step1!:
\begin{lstlisting}[language=modelica]
parameter Integer nIn=0 annotation(Dialog(connectorSizing=true));
StepIn inPorts[nIn];
Step step1(nIn=0);
parameter Integer nIn=0 annotation(Dialog(connectorSizing=true));
StepIn inPorts[nIn];
Step step1(nIn=0);
\end{lstlisting}
Drawing a connection line between connectors \lstinline!inPorts! and
\lstinline!step1.inPorts! results in:
\begin{lstlisting}[language=modelica]
parameter Integer nIn=0 annotation(Dialog(connectorSizing=true));
StepIn inPorts[nIn];
Step step1(nIn=nIn); // nIn=0 changed to nIn=nIn
equation
equation
connect(inPorts, step1.inPorts); // new connect equation
\end{lstlisting}
\item
Expand All @@ -1369,9 +1367,9 @@ \section{Annotations for the Graphical User Interface}\doublelabel{annotations-f
\emph{Example:} Assume the connection line in (3) is removed.
This results in:
\begin{lstlisting}[language=modelica]
parameter Integer nIn=0 annotation(Dialog(connectorSizing=true));
StepIn inPorts[nIn];
Step step1; // modifier nIn=nIn is removed
parameter Integer nIn=0 annotation(Dialog(connectorSizing=true));
StepIn inPorts[nIn];
Step step1; // modifier nIn=nIn is removed
\end{lstlisting}
\item
If a new connection line is drawn to an inside connector with
Expand All @@ -1380,9 +1378,9 @@ \section{Annotations for the Graphical User Interface}\doublelabel{annotations-f
index. \emph{Example:} Assume that 3 connections are present and a new
connection is performed. The result is:
\begin{lstlisting}[language=modelica]
Step step1(nIn=4); // index changed from nIn=3 to nIn=4
equation
connect(.., step1.inPorts[4]); // new connect equation
Step step1(nIn=4); // index changed from nIn=3 to nIn=4
equation
connect(.., step1.inPorts[4]); // new connect equation
\end{lstlisting}
In some applications, like state machines, the vector index is
used as a priority, e.g., to define which transition is firing if
Expand Down Expand Up @@ -1615,13 +1613,13 @@ \subsubsection{Conversion rules}\doublelabel{conversion-rules}
\end{lstlisting}
This implies that
\begin{lstlisting}[language=modelica]
Modelica.Mechanics.MultiBody.World world(mue=2);
function f=Modelica.Mechanics.MultiBody.World.gravityAcceleration(mue=4);
Modelica.Mechanics.MultiBody.World world(mue=2);
function f=Modelica.Mechanics.MultiBody.World.gravityAcceleration(mue=4);
\end{lstlisting}
is converted to:
\begin{lstlisting}[language=modelica]
Modelica.Mechanics.MultiBody.World world(mu=2);
function f=Modelica.Mechanics.MultiBody.World.gravityAcceleration(mu=4);
Modelica.Mechanics.MultiBody.World world(mu=2);
function f=Modelica.Mechanics.MultiBody.World.gravityAcceleration(mu=4);
\end{lstlisting}
\end{example}

Expand Down Expand Up @@ -1923,10 +1921,10 @@ \subsection{Protection of Classes}\doublelabel{protection-of-classes}
(if a class is encrypted and no Protection annotation is defined, the access annotation has the default value
\lstinline!Access.documentation!):
\begin{lstlisting}[language=modelica]
type Access = enumeration(hide, icon, documentation,
diagram, nonPackageText, nonPackageDuplicate,
packageText, packageDuplicate);
annotation(Protection(access = Access.documentation));
type Access = enumeration(hide, icon, documentation,
diagram, nonPackageText, nonPackageDuplicate,
packageText, packageDuplicate);
annotation(Protection(access = Access.documentation));
\end{lstlisting}

The items of the Access enumeration have the following meaning:
Expand Down
12 changes: 6 additions & 6 deletions chapters/classes.tex
Original file line number Diff line number Diff line change
Expand Up @@ -134,25 +134,25 @@ \subsection{Syntax and Examples of Component Declarations}\doublelabel{syntax-an
following single declaration (\lstinline!component-clause!) of two matrix
variables:
\begin{lstlisting}[language=modelica]
Real[2,2] A, B;
Real[2,2] A, B;
\end{lstlisting}
That declaration has the same meaning as the following two
declarations together:
\begin{lstlisting}[language=modelica]
Real[2,2] A;
Real[2,2] B;
Real[2,2] A;
Real[2,2] B;
\end{lstlisting}
The array dimension descriptors may instead be placed after the
variable name, giving the two declarations below, with the same meaning
as in the previous example:
\begin{lstlisting}[language=modelica]
Real A[2,2];
Real B[2,2];
Real A[2,2];
Real B[2,2];
\end{lstlisting}
The following declaration is different, meaning that the variable
a is a scalar but B is a matrix as above:
\begin{lstlisting}[language=modelica]
Real a, B[2,2];
Real a, B[2,2];
\end{lstlisting}
\end{nonnormative}

Expand Down
Loading

0 comments on commit 8c6a887

Please sign in to comment.