Skip to content

Commit

Permalink
Fetch the diagram annotation when adding component to the diagram (#1…
Browse files Browse the repository at this point in the history
…1447)

This is needed for connectors since they have different representation on icon and diagram layer.
  • Loading branch information
adeas31 committed Oct 25, 2023
1 parent 3b8419c commit 2036284
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion OMEdit/OMEditLIB/Modeling/ModelWidgetContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -923,7 +923,7 @@ ModelInstance::Component *GraphicsView::createModelInstanceComponent(ModelInstan
ModelInstance::Component *pComponent = new ModelInstance::Component(pModelInstance);
pComponent->setName(name);
pComponent->setType(className);
/* We use getModelInstanceIcon here for bettter performance
/* We use getModelInstanceAnnotation here for bettter performance
* This model will be updated right after this so it doesn't matter if the Component has complete model or not.
*/
pComponent->setModel(new ModelInstance::Model(MainWindow::instance()->getOMCProxy()->getModelInstance(className, "", false, true)));
Expand Down
7 changes: 4 additions & 3 deletions OMEdit/OMEditLIB/OMC/OMCProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3471,10 +3471,11 @@ QJsonObject OMCProxy::getModelInstance(const QString &className, const QString &

QString modelInstanceJson = "";
if (icon) {
modelInstanceJson = mpOMCInterface->getModelInstanceAnnotation(className, {"Icon", "IconMap"}, prettyPrint);
modelInstanceJson = mpOMCInterface->getModelInstanceAnnotation(className, {"Icon", "IconMap", "Diagram", "DiagramMap"}, prettyPrint);
if (modelInstanceJson.isEmpty()) {
if (MainWindow::instance()->isDebug()) {
QString msg = QString("<b>getModelInstanceAnnotation(%1, {\"Icon\", \"IconMap\"}, %2)</b> failed. Using <b>getModelInstance(%1, %2)</b>.").arg(className).arg(prettyPrint ? "true" : "false");
QString msg = QString("<b>getModelInstanceAnnotation(%1, {\"Icon\", \"IconMap\", \"Diagram\", \"DiagramMap\"}, %2)</b> failed. Using <b>getModelInstance(%1, %2)</b>.")
.arg(className).arg(prettyPrint ? "true" : "false");
MessageItem messageItem(MessageItem::Modelica, msg, Helper::scriptingKind, Helper::errorLevel);
MessagesWidget::instance()->addGUIMessage(messageItem);
printMessagesStringInternal();
Expand All @@ -3488,7 +3489,7 @@ QJsonObject OMCProxy::getModelInstance(const QString &className, const QString &
}

if (MainWindow::instance()->isNewApiProfiling()) {
const QString api = icon ? "getModelInstanceIcon" : "getModelInstance";
const QString api = icon ? "getModelInstanceAnnotation" : "getModelInstance";
double elapsed = (double)timer.elapsed() / 1000.0;
MainWindow::instance()->writeNewApiProfiling(QString("Time for %1 %2 secs").arg(api, QString::number(elapsed, 'f', 6)));
}
Expand Down

0 comments on commit 2036284

Please sign in to comment.