Skip to content

Commit

Permalink
- API CHANGE for getNthConnectionAnnotation. It was only working if c…
Browse files Browse the repository at this point in the history
…onnection annotation starts with Line primitive, but now it will return the list of all annotations.

------------------------------------------
- Test (see new output below):
----------- test.mos ---------------------
loadModel(Modelica);
getErrorString();
getNthConnectionAnnotation(Modelica.Mechanics.MultiBody.Examples.Systems.RobotR3.fullRobot, 6);
getErrorString();
getNthConnectionAnnotation(Modelica.Mechanics.MultiBody.Examples.Systems.RobotR3.fullRobot, 9);
getErrorString();
adeas31@IDA-LIU085 /c/OpenModelica/trunk/build/bin
$ omc.exe /c/TestModels/test.mos 
true
""
{Line(true,{0.0,0.0},0,{{-5.0,35.0},{20.0,35.0},{20.0,14.5},{33.5,14.5}},{0,0,0},LinePattern.Solid,0.25,{Arrow.None,Arrow.None},3,Smooth.None)}
""
{Text(error), Line(true,{0.0,0.0},0,{{-80.0,-10.0},{-79.0,-10.0},{-79.0,-15.0},{-62.5,-15.0},{-62.5,-45.0},{-25.0,-45.0}},{255,204,51},LinePattern.Solid,0.5,{Arrow.None,Arrow.None},3,Smooth.None)}
""
------------------------------------------
- The output shows Text(error) because OMC was unable to elaborate graphics expression of such kind :: 
connect(controlBus.axisControlBus2, axis2.axisControlBus) annotation (
    __Dymola_Text(
      string="%first",
      index=-1,
      extent=[-6,3; -6,3]), Line(
      points={{-80,-10},{-79,-10},{-79,-15},{-62.5,-15},{-62.5,-45},{-25,-45}},
      color={255,204,51},
      thickness=0.5));

- Made some changes in OMEdit for new getNthConnectionAnnotation.

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@9590 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adeas31 committed Aug 3, 2011
1 parent f91c010 commit 7e90943
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
17 changes: 12 additions & 5 deletions OMEdit/OMEditGUI/Component.cpp
Expand Up @@ -1086,12 +1086,19 @@ void Component::getClassComponents(QString className, int type, Component *pPare
for (int i = 1 ; i <= connections ; i++)
{
QString result = mpOMCProxy->getNthConnectionAnnotation(className, i);
if (result.contains("Line"))
QStringList shapesList;
shapesList = StringHandler::getStrings(StringHandler::removeFirstLastCurlBrackets(result), '(', ')');
// Now parse the shapes available in list
foreach (QString shape, shapesList)
{
result = result.mid(QString("Line").length());
result = StringHandler::removeFirstLastBrackets(result);
LineAnnotation *lineAnnotation = new LineAnnotation(result, pParent);
Q_UNUSED(lineAnnotation);
shape = StringHandler::removeFirstLastCurlBrackets(shape);
if (shape.startsWith("Line"))
{
shape = shape.mid(QString("Line").length());
result = StringHandler::removeFirstLastBrackets(shape);
LineAnnotation *lineAnnotation = new LineAnnotation(result, pParent);
Q_UNUSED(lineAnnotation);
}
}
}
}
Expand Down
17 changes: 12 additions & 5 deletions OMEdit/OMEditGUI/ProjectTabWidget.cpp
Expand Up @@ -2048,12 +2048,19 @@ void ProjectTab::getModelConnections()

// get the connector annotations from OMC
QString connectionAnnotationString;
QStringList connectionAnnotationList;
QStringList connectionAnnotationList, shapesList;
connectionAnnotationString = pMainWindow->mpOMCProxy->getNthConnectionAnnotation(mModelNameStructure, i);

connectionAnnotationString = connectionAnnotationString.mid(QString("Line").length());
connectionAnnotationString = StringHandler::removeFirstLastBrackets(connectionAnnotationString);

shapesList = StringHandler::getStrings(StringHandler::removeFirstLastCurlBrackets(connectionAnnotationString), '(', ')');
// Now parse the shapes available in list
foreach (QString shape, shapesList)
{
shape = StringHandler::removeFirstLastCurlBrackets(shape);
if (shape.startsWith("Line"))
{
shape = shape.mid(QString("Line").length());
connectionAnnotationString = StringHandler::removeFirstLastBrackets(shape);
}
}
connectionAnnotationList = StringHandler::getStrings(connectionAnnotationString);
// if the connectionAnnotationString is empty then continue the loop,
// because connection is not valid then
Expand Down

0 comments on commit 7e90943

Please sign in to comment.