Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve getModelInstanceIcon (#10078)
- Instantiate the scope of an annotation if the annotation contains component references that we need to be able to look up.
- Loading branch information
Showing
5 changed files
with
203 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
137 changes: 137 additions & 0 deletions
137
testsuite/openmodelica/instance-API/GetModelInstanceIcon3.mos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
// name: GetModelInstanceIcon3 | ||
// keywords: | ||
// status: correct | ||
// cflags: -d=newInst | ||
// | ||
// | ||
|
||
loadString(" | ||
package Icons | ||
partial model Example | ||
parameter Boolean visible = true; | ||
annotation (Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},{100,100}}), graphics={ | ||
Ellipse(visible = visible, | ||
lineColor = {75,138,73}, | ||
fillColor={255,255,255}, | ||
fillPattern = FillPattern.Solid, | ||
extent = {{-100,-100},{100,100}})}), | ||
IconMap(extent = {{0, 0}, {0, 0}})); | ||
end Example; | ||
end Icons; | ||
|
||
model M | ||
extends Icons.Example; | ||
annotation (Icon(coordinateSystem(preserveAspectRatio=true))); | ||
end M; | ||
"); | ||
|
||
getModelInstanceIcon(M, prettyPrint=true); | ||
|
||
// Result: | ||
// true | ||
// "{ | ||
// \"name\": \"M\", | ||
// \"extends\": [ | ||
// { | ||
// \"baseClass\": { | ||
// \"name\": \"Icons.Example\", | ||
// \"annotation\": { | ||
// \"Icon\": { | ||
// \"coordinateSystem\": { | ||
// \"preserveAspectRatio\": false, | ||
// \"extent\": [ | ||
// [ | ||
// -100, | ||
// -100 | ||
// ], | ||
// [ | ||
// 100, | ||
// 100 | ||
// ] | ||
// ] | ||
// }, | ||
// \"graphics\": [ | ||
// { | ||
// \"$kind\": \"record\", | ||
// \"name\": \"Ellipse\", | ||
// \"elements\": [ | ||
// { | ||
// \"$kind\": \"cref\", | ||
// \"parts\": [ | ||
// { | ||
// \"name\": \"visible\" | ||
// } | ||
// ] | ||
// }, | ||
// [ | ||
// 0, | ||
// 0 | ||
// ], | ||
// 0, | ||
// [ | ||
// 75, | ||
// 138, | ||
// 73 | ||
// ], | ||
// [ | ||
// 255, | ||
// 255, | ||
// 255 | ||
// ], | ||
// { | ||
// \"$kind\": \"enum\", | ||
// \"name\": \"LinePattern.Solid\", | ||
// \"index\": 2 | ||
// }, | ||
// { | ||
// \"$kind\": \"enum\", | ||
// \"name\": \"FillPattern.Solid\", | ||
// \"index\": 2 | ||
// }, | ||
// 0.25, | ||
// [ | ||
// [ | ||
// -100, | ||
// -100 | ||
// ], | ||
// [ | ||
// 100, | ||
// 100 | ||
// ] | ||
// ], | ||
// 0, | ||
// 360, | ||
// { | ||
// \"$kind\": \"enum\", | ||
// \"name\": \"EllipseClosure.Chord\", | ||
// \"index\": 2 | ||
// } | ||
// ] | ||
// } | ||
// ] | ||
// }, | ||
// \"IconMap\": { | ||
// \"extent\": [ | ||
// [ | ||
// 0, | ||
// 0 | ||
// ], | ||
// [ | ||
// 0, | ||
// 0 | ||
// ] | ||
// ] | ||
// } | ||
// } | ||
// } | ||
// } | ||
// ], | ||
// \"annotation\": { | ||
// \"Icon\": { | ||
// \"coordinateSystem\": { | ||
// \"preserveAspectRatio\": true | ||
// } | ||
// } | ||
// } | ||
// }" | ||
// endResult |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters