ModelicaSpecification icon indicating copy to clipboard operation
ModelicaSpecification copied to clipboard

Should extent be inherited if local coordinate system has no extent?

Open MarkusOlssonModelon opened this issue 3 years ago • 2 comments

If a class defines a local coordinate system to modify one the attributes that are not extent, e.g., preserveAspectRatio, should the extent be inherited? My interpretation of the specification is that it should not be inherited (from point 1 below). Is this the desired behavior? I think it would be more natural if the attributes of the coordinate system were inherited separately.

From section 18.6.1.1 Coordinate Systems:

The coordinate system (including preserveAspectRatio) of a class is defined by the following priority:

  1. The coordinate system annotation given in the class (if specified).
  2. The coordinate systems of the first base class where the extent on the extends-clause specifies a null-region (if any). Note that null-region is the default for base classes, see section 18.6.3.
  3. The default coordinate system CoordinateSystem(extent = {{-100, -100}, {100, 100}}).

Example

model BaseClass
    annotation(Icon(coordinateSystem(extent={{0,0},{100,100}})));
end BaseClass;

model Example
    extends BaseClass;
    annotation(Icon(coordinateSystem(preserveAspectRatio=false)));
end Example;

What is the extent for the icon of Example?

MarkusOlssonModelon avatar Jul 27 '22 13:07 MarkusOlssonModelon

I think it would be more natural if the attributes of the coordinate system were inherited separately.

I agree.

henrikt-ma avatar Aug 15 '22 13:08 henrikt-ma

If a class defines a local coordinate system to modify one the attributes that are not extent, e.g., preserveAspectRatio, should the extent be inherited? My interpretation of the specification is that it should not be inherited (from point 1 below). Is this the desired behavior? I think it would be more natural if the attributes of the coordinate system were inherited separately.

I agree for this example, and to me the problem is that if you just set preserveAspectRatio there is no extent defined in step 1 (no default for the extent), so it makes sense that we inherit the extent in step 2 as there isn't any value in step 1.

However, if you on the other hand have:

model BaseClass
    annotation(Icon(coordinateSystem(preserveAspectRatio=false)));
end BaseClass;

model Example
    extends BaseClass;
    annotation(Icon(coordinateSystem(extent={{0,0},{100,100}})));
end Example;

there does exist a default for preserveAspectRatio in CoordinateSystem, and thus preserveAspectRatio=true shall be used.

That is consistent with the goal when we introduced the slightly complicated rules:

  • If you want to specify the coordinate-system do it, you have just have to give the extent.
  • If you want to inherit the coordinate-system don't specify it.
  • The default is preserveAspectRatio=true.

Note models normally don't specify preserveAspectRatio, and of the ones that do most also give the extent. I believe there are about 20 cases of specifying coordinatesystem without extent in MSL; and I haven't found any cases where these rules matter.

HansOlsson avatar Aug 15 '22 14:08 HansOlsson