Skip to content

Commit

Permalink
Preserve the dynamic values while dumping the annotation (#11181)
Browse files Browse the repository at this point in the history
  • Loading branch information
adeas31 committed Sep 14, 2023
1 parent dc50c58 commit f81f6ed
Showing 1 changed file with 22 additions and 21 deletions.
43 changes: 22 additions & 21 deletions OMEdit/OMEditLIB/Element/Element.cpp
Expand Up @@ -1227,20 +1227,21 @@ QString Element::getTransformationAnnotation(bool ModelicaSyntax)
} else if (mpGraphicsView->getViewType() == StringHandler::Diagram) {
annotationString.append(ModelicaSyntax ? "transformation(" : "transformation=transformation(");
}
QStringList annotationStringList;
// add the origin
annotationString.append("origin={").append(QString::number(mTransformation.getOrigin().x())).append(",");
annotationString.append(QString::number(mTransformation.getOrigin().y())).append("}, ");
if (mTransformation.getOrigin().isDynamicSelectExpression() || mTransformation.getOrigin().toQString().compare(QStringLiteral("{0,0}")) != 0) {
annotationStringList.append(QString("origin=%1").arg(mTransformation.getOrigin().toQString()));

}
// add extent points
ExtentAnnotation extent = mTransformation.getExtent();
QPointF extent1 = extent.at(0);
QPointF extent2 = extent.at(1);
annotationString.append("extent={").append("{").append(QString::number(extent1.x()));
annotationString.append(",").append(QString::number(extent1.y())).append("},");
annotationString.append("{").append(QString::number(extent2.x())).append(",");
annotationString.append(QString::number(extent2.y())).append("}}, ");
if (mTransformation.getExtent().isDynamicSelectExpression() || mTransformation.getExtent().size() > 1) {
annotationStringList.append(QString("extent=%1").arg(mTransformation.getExtent().toQString()));
}
// add icon rotation
annotationString.append("rotation=").append(QString::number(mTransformation.getRotateAngle())).append(")");
return annotationString;
if (mTransformation.getRotateAngle().isDynamicSelectExpression() || mTransformation.getRotateAngle().toQString().compare(QStringLiteral("0")) != 0) {
annotationStringList.append(QString("rotation=%1").arg(mTransformation.getRotateAngle().toQString()));
}
return annotationString.append(annotationStringList.join(",")).append(")");
}

/*!
Expand All @@ -1254,30 +1255,30 @@ QString Element::getPlacementAnnotation(bool ModelicaSyntax)
// create the placement annotation string
QString placementAnnotationString = ModelicaSyntax ? "annotation(Placement(" : "annotate=Placement(";
if (mTransformation.isValid()) {
placementAnnotationString.append("visible=").append(mTransformation.getVisible() ? "true" : "false");
if (mTransformation.getVisible().isDynamicSelectExpression() || mTransformation.getVisible().toQString().compare(QStringLiteral("true")) != 0) {
placementAnnotationString.append(QString("visible=%1,").arg(mTransformation.getVisible().toQString()));
}
}
if ((mpLibraryTreeItem && mpLibraryTreeItem->isConnector()) || (mpGraphicsView->getModelWidget()->isNewApi() && mpModel->isConnector())) {
if (mpGraphicsView->getViewType() == StringHandler::Icon) {
// first get the component from diagram view and get the transformations
Element *pElement;
pElement = mpGraphicsView->getModelWidget()->getDiagramGraphicsView()->getElementObject(getName());
Element *pElement = mpGraphicsView->getModelWidget()->getDiagramGraphicsView()->getElementObject(getName());
if (pElement) {
placementAnnotationString.append(", ").append(pElement->getTransformationAnnotation(ModelicaSyntax));
placementAnnotationString.append(pElement->getTransformationAnnotation(ModelicaSyntax)).append(", ");
}
// then get the icon transformations
placementAnnotationString.append(", ").append(getTransformationAnnotation(ModelicaSyntax));
placementAnnotationString.append(getTransformationAnnotation(ModelicaSyntax));
} else if (mpGraphicsView->getViewType() == StringHandler::Diagram) {
// first get the component from diagram view and get the transformations
placementAnnotationString.append(", ").append(getTransformationAnnotation(ModelicaSyntax));
placementAnnotationString.append(getTransformationAnnotation(ModelicaSyntax)).append(", ");
// then get the icon transformations
Element *pElement;
pElement = mpGraphicsView->getModelWidget()->getIconGraphicsView()->getElementObject(getName());
Element *pElement = mpGraphicsView->getModelWidget()->getIconGraphicsView()->getElementObject(getName());
if (pElement) {
placementAnnotationString.append(", ").append(pElement->getTransformationAnnotation(ModelicaSyntax));
placementAnnotationString.append(pElement->getTransformationAnnotation(ModelicaSyntax));
}
}
} else {
placementAnnotationString.append(", ").append(getTransformationAnnotation(ModelicaSyntax));
placementAnnotationString.append(getTransformationAnnotation(ModelicaSyntax));
}
placementAnnotationString.append(ModelicaSyntax ? "))" : ")");
return placementAnnotationString;
Expand Down

0 comments on commit f81f6ed

Please sign in to comment.