Found an issue with the book? Report it on Github.

그래픽 주석(Graphical Annotations)

그래픽 주석(Graphical Annotations)

커넥터(Connectors) 를 지금 다루고 있지만, 여기서는 일반적인 모델 정의와 관련된 그래픽 주석을 다루겠습니다.따라서 여기에 제시된 정보는 모델리카와 관련한 여러 부분에서 유용한 참고 자료가 될 것입니다.

그래픽 레이어(Graphical Layers)

모델리카 엔터티의 모양을 설명할 때 선택할 수 있는 두 가지 표현이 있습니다. 하나는 "아이콘" 표현이라고 하고 다른 하나는 "다이어그램" 표현이라고 합니다.모델리카에서 아이콘 표현은 "외부"에서 무언가를 볼 때 사용합니다. 일반적으로 대체 항목(곧 다룰 예정임)을 통해 해당 엔티티에 대한 추가 정보와 함께 몇 가지 독특한 시각적 표현이 아이콘에 포함됩니다.

반면에 "다이어그램" 표현은 "내부"에서 구성 요소의 보기를 나타내는 데 사용합니다.다이어그램 표현은 일반적으로 "아이콘" 보기에 비해서는 매우 자세한 모델리카 구성 요소에 대한 추가 그래픽 문서를 포함하는 데 사용합니다.

이전의 그래픽 커넥터(Graphical Connectors) 에서 간략히 다루었듯이, "아이콘" 계층에서 정의의 그래픽 모양은 Icon 주석에 의해 지정됩니다.당연히 "다이어그램" 계층에서 정의의 그래픽 모양은 Diagram 주석에 의해 지정됩니다. 둘 다 정의에 직접 나타나는 주석이며, 선언 또는 extends 절과 같은 기존 요소와 연결되지 않습니다.

일반적으로 대부분의 정의에는 "아이콘" 표현을 사용하고 있으며, "다이어그램" 표현의 경우는 일부만 사용합니다.두가지 표현은 서로 다른 맥락에서 그리는 것이지만 그래픽 모양에 대한 사양은 서로 동일합니다.

공통의 그래픽 정의(Common Graphical Definitions)

이 섹션 전체에서 다음과 같은 정의가 참조됩니다.

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 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 Arrow = enumeration(None, Open, Filled, Half);
type TextStyle = enumeration(Bold, Italic, UnderLine);
type TextAlignment = enumeration(Left, Center, Right);

record FilledShape "Style attributes for filled shapes"
  Color lineColor = Black "Color of border line";
  Color fillColor = Black "Interior fill color";
  LinePattern pattern = LinePattern.Solid "Border line pattern";
  FillPattern fillPattern = FillPattern.None "Interior fill pattern";
  DrawingUnit lineThickness = 0.25 "Line thickness";
end FilledShape;

또한 논의할 많은 주석에는 다음 record 정의로 표현되는 일련의 공통 요소가 포함됩니다.

partial record GraphicItem
  Boolean visible = true;
  Point origin = {0, 0};
  Real rotation(quantity="angle", unit="deg")=0;
end GraphicItem;

공통 요소의 존재를 명시적으로 명확하게 만들기 위해 이 GraphicItem 으로 그래픽 요소를 나타내는 주석을 확장(extend) 하겠습니다.

아이콘 그리고 다이어그램 주석(Icon and Diagram Annotations)

모델의 아이콘 레이어에 나타나야 하는 요소는 다음 데이터로 설명할 수 있습니다.

record Icon "Representation of the icon layer"
  CoordinateSystem coordinateSystem(extent = {{-100, -100}, {100, 100}});
  GraphicItem[:] graphics;
end Icon;

여기서 좌표계 데이터는 다음과 같이 정의합니다.

record CoordinateSystem
  Extent extent;
  Boolean preserveAspectRatio=true;
  Real initialScale = 0.1;
  DrawingUnit grid[2];
end CoordinateSystem;

즉, Icon 주석에는 coordinateSystem 정의에 포함된 좌표계에 대한 정보가 포함되며 graphics 에 저장된 그래픽 항목 목록도 포함됩니다.``Diagram`` 주석의 정의는 동일합니다:

record Diagram "Representation of the diagram layer"
  CoordinateSystem coordinateSystem(extent = {{-100, -100}, {100, 100}});
  GraphicItem[:] graphics;
end Diagram;

그래픽 아이템(Graphical Items)

Icon 또는 Diagram 주석과 관련된 graphics 벡터를 구성하기 위해 사용하는 모델리카 사양(spec)에 정의된 다양한 그래픽 항목이 있습니다.참고를 위해 아래 예시로 정의를 살펴 보겠습니다.

선(Line)

record Line
  extends GraphicItem;
  Point points[:];
  Color color = Black;
  LinePattern pattern = LinePattern.Solid;
  DrawingUnit thickness = 0.25;
  Arrow arrow[2] = {Arrow.None, Arrow.None} "{start arrow, end arrow}";
  DrawingUnit arrowSize=3;
  Smooth smooth = Smooth.None "Spline";
end Line;

다각형(Polygon)

record Polygon
  extends GraphicItem;
  extends FilledShape;
  Point points[:];
  Smooth smooth = Smooth.None "Spline outline";
end Polygon;

사각형(Rectangle)

record Rectangle
  extends GraphicItem;
  extends FilledShape;
  BorderPattern borderPattern = BorderPattern.None;
  Extent extent;
  DrawingUnit radius = 0 "Corner radius";
end Rectangle;

타원(Ellipse)

record Ellipse
  extends GraphicItem;
  extends FilledShape;
  Extent extent;
  Real startAngle(quantity="angle", unit="deg")=0;
  Real endAngle(quantity="angle", unit="deg")=360;
end Ellipse;

문자(Text)

record Text
  extends GraphicItem;
  extends FilledShape;
  Extent extent;
  String textString;
  Real fontSize = 0 "unit pt";
  String fontName;
  TextStyle textStyle[:];
  Color textColor=lineColor;
  TextAlignment horizontalAlignment = TextAlignment.Center;
end Text;

비트맵(Bitmap)

record Bitmap
  extends GraphicItem;
  Extent extent;
  String fileName "Name of bitmap file";
  String imageSource "Base64 representation of bitmap";
end Bitmap;

그래픽 주석 상속(Inheriting Graphical Annotations)

한 모델 정의가 다른 모델 정의에서 상속되면 기본적으로 그래픽 주석이 상속됩니다. 그러나 이 동작은 다음 데이터로 extends 절에 주석을 달아 제어할 수 있습니다(각각 아이콘 및 다이어그램 레이어에 대해).

record IconMap
  Extent extent = {{0, 0}, {0, 0}};
  Boolean primitivesVisible = true;
end IconMap;

record DiagramMap
  Extent extent = {{0, 0}, {0, 0}};
  Boolean primitivesVisible = true;
end DiagramMap;

두 경우 모두 extent 데이터를 통해 상속된 그래픽 요소의 위치를 조정할 수 있습니다. primitivesVisiblefalse 로 설정하면 상속된 그래픽 요소의 렌더링이 억제됩니다.

치환(Substitutions)

문자(Text) 주석으로 작업 할때와 같이 textString 필드는 특정 대체 패턴을 사용할 수 있는데, 모델리카 에서는 다음 대체 패턴이 지원됩니다.

  • %name - 이 패턴은 주어진 정의의 인스턴스 이름으로 대체합니다.

  • %class - 이 패턴은 이 정의의 이름으로 대체합니다.

  • %<name> 여기서 <name> 은 파라미터 이름 - 이 패턴은 명명된 파라미터의 으로 대체합니다.

  • %% - 이 패턴은 % 로 대체합니다.

종합하여 모음(Putting It All Together)

그래픽 주석의 전체를 다루었으므로, 그래픽 커넥터(Graphical Connectors) 에서 앞서 다루면서 제시된 아이콘 정의를 모아서 살펴 보겠습니다.

      Icon(graphics={
          Ellipse(
            extent={{-100,100},{100,-100}},
            lineColor={0,0,255},
            fillColor={85,170,255},
            fillPattern=FillPattern.Solid),
          Rectangle(
            extent={{-10,58},{10,-62}},
            fillColor={0,128,255},
            fillPattern=FillPattern.Solid,
            pattern=LinePattern.None),
          Rectangle(
            extent={{-60,10},{60,-10}},
            fillColor={0,128,255},
            fillPattern=FillPattern.Solid,
            pattern=LinePattern.None,
            lineColor={0,0,0}),
          Text(
            extent={{-100,-100},{100,-140}},
            lineColor={0,0,255},
            fillColor={85,170,255},
            fillPattern=FillPattern.Solid,
            textString="%name")}),

위에 보이는 예시에서 PositivePin 정의와 관련된 annotation 이 모델 주석이고, 이와 관련된 Icon 데이터에 그래픽 항목 목록이 포함되어 있다는 것을 알 수 있습니다. 첫 번째 그래픽 항목은 타원(Ellipse) 주석입니다. 그 다음에는 두 개의 사각형(Rectangle) 주석과 마지막으로 (이전에 논의한 치환(Substitutions) 에서도 사용하는) 문자(Text) 가 있습니다.

annotation 에 표시되는 데이터가 앞에서 논의한 레코드 정의에 설명된 데이터와 어떻게 일치하는지 살펴 볼 수 있습니다.