Skip to content

Commit

Permalink
Add test for DynamicSelect, ticket:3675
Browse files Browse the repository at this point in the history
  • Loading branch information
rfranke authored and OpenModelica-Hudson committed Oct 27, 2016
1 parent 73de300 commit 643fba6
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
1 change: 1 addition & 0 deletions openmodelica/interactive-API/Makefile
Expand Up @@ -32,6 +32,7 @@ ForStatement8.mos \
getClassNames.mos \
GetComponents.mos \
getDialogAnnotation.mos \
getIconAnnotation.mos \
IfStatementIllegal.mos \
IfStatement.mos\
interactive_api_annotations.mos \
Expand Down
45 changes: 45 additions & 0 deletions openmodelica/interactive-API/getIconAnnotation.mos
@@ -0,0 +1,45 @@
// name: getIconAnnotation.mos
// keywords: DynamicSelect textString visible
// status: correct
//

loadString("
package IconWithValues
model Component
parameter Real x;
Real y = sin(x);
Boolean neg = y < 0;
Boolean pos = not neg;
annotation(Icon(graphics = {
Rectangle(origin = {0, 0}, extent = {{-95, 95}, {95, -95}},
visible = DynamicSelect(false, neg)),
Text(origin = {-55, 35}, extent = {{-35, 15}, {50, -30}},
textString = \"x = \"),
Text(origin = {-55, 35}, extent = {{50, 15}, {150, -30}},
textString = DynamicSelect(\"x\", String(x))),
Text(origin = {-55, -30}, extent = {{-35, 15}, {150, -30}},
textString = DynamicSelect(\"%y\", String(y, significantDigits = 3)),
visible = DynamicSelect(true, pos)),
Text(origin = {-55, -30}, extent = {{-35, 15}, {150, -30}},
textString = DynamicSelect(\"%y\", String(y, significantDigits = 3)),
visible = DynamicSelect(false, neg), lineColor = {255, 0, 0})},
coordinateSystem(initialScale = 0.1)));
end Component;
model Test
Component component1(x = 5)
annotation(Placement(visible = true,
transformation(origin = {0, 0}, extent = {{-45, -45}, {45, 45}})));
end Test;
end IconWithValues;
"); getErrorString();
list(GetIconAnnotation); getErrorString();
getIconAnnotation(IconWithValues.Component); getErrorString();

// Result:
// true
// ""
// ""
// ""
// {-100.0,-100.0,100.0,100.0,true,0.1,2.0,2.0,{Rectangle({false, neg}, {0, 0}, 0, {0, 0, 0}, {0, 0, 0}, LinePattern.Solid, FillPattern.None, 0.25, BorderPattern.None, {{-95, 95}, {95, -95}}, 0), Text(true, {-55, 35}, 0, {0, 0, 0}, {0, 0, 0}, LinePattern.Solid, FillPattern.None, 0.25, {{-35, 15}, {50, -30}}, "x = ", 0, TextAlignment.Center), Text(true, {-55, 35}, 0, {0, 0, 0}, {0, 0, 0}, LinePattern.Solid, FillPattern.None, 0.25, {{50, 15}, {150, -30}}, {"x", x}, 0, TextAlignment.Center), Text({true, pos}, {-55, -30}, 0, {0, 0, 0}, {0, 0, 0}, LinePattern.Solid, FillPattern.None, 0.25, {{-35, 15}, {150, -30}}, {"%y", y, 3}, 0, TextAlignment.Center), Text({false, neg}, {-55, -30}, 0, {255, 0, 0}, {0, 0, 0}, LinePattern.Solid, FillPattern.None, 0.25, {{-35, 15}, {150, -30}}, {"%y", y, 3}, 0, TextAlignment.Center)}}
// ""
// endResult

0 comments on commit 643fba6

Please sign in to comment.