Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
MarkusOlssonModelon opened this issue Jul 27, 2022 · 2 comments · Fixed by #3253
Closed

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

MarkusOlssonModelon opened this issue Jul 27, 2022 · 2 comments · Fixed by #3253

Comments

@MarkusOlssonModelon
Copy link

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?

@henrikt-ma
Copy link
Collaborator

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

I agree.

@HansOlsson
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants