Skip to content

Commit

Permalink
Fixes #3731. Don't create empty Icon & Diagram annotations when creat…
Browse files Browse the repository at this point in the history
…ing a class.
  • Loading branch information
adeas31 committed Feb 29, 2016
1 parent 46bef23 commit 77fc815
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
9 changes: 8 additions & 1 deletion OMEdit/OMEditGUI/Modeling/ModelWidgetContainer.cpp
Expand Up @@ -1167,8 +1167,9 @@ void GraphicsView::clearSelection()
* \brief GraphicsView::addClassAnnotation
* Adds the annotation string of Icon and Diagram layer to the model. Also creates the model icon in the tree.
* If some custom models are cross referenced then update them accordingly.
* \param alwaysAdd - if false then skip the OMCProxy::addClassAnnotation() if annotation is empty.
*/
void GraphicsView::addClassAnnotation()
void GraphicsView::addClassAnnotation(bool alwaysAdd)
{
if (mpModelWidget->getLibraryTreeItem()->isSystemLibrary()) {
return;
Expand Down Expand Up @@ -1219,6 +1220,12 @@ void GraphicsView::addClassAnnotation()
annotationString = QString("annotate=%1(graphics={%2})").arg(viewType).arg(graphicsList.join(","));
} else {
annotationString = QString("annotate=%1()").arg(viewType);
/* Ticket #3731
* Return from here since we don't want empty Icon & Diagram annotations.
*/
if (!alwaysAdd) {
return;
}
}
// add the class annotation to model through OMC
if (pMainWindow->getOMCProxy()->addClassAnnotation(mpModelWidget->getLibraryTreeItem()->getNameStructure(), annotationString)) {
Expand Down
2 changes: 1 addition & 1 deletion OMEdit/OMEditGUI/Modeling/ModelWidgetContainer.h
Expand Up @@ -250,7 +250,7 @@ public slots:
void zoomOut();
void selectAll();
void clearSelection();
void addClassAnnotation();
void addClassAnnotation(bool alwaysAdd = true);
void showGraphicsViewProperties();
void manhattanizeItems();
void deleteItems();
Expand Down
4 changes: 2 additions & 2 deletions OMEdit/OMEditGUI/Modeling/ModelicaClassDialog.cpp
Expand Up @@ -357,8 +357,8 @@ void ModelicaClassDialog::createModelicaClass()
// show the ModelWidget
pLibraryTreeModel->showModelWidget(pLibraryTreeItem, "", true);
if (pLibraryTreeItem->getModelWidget()) {
pLibraryTreeItem->getModelWidget()->getIconGraphicsView()->addClassAnnotation();
pLibraryTreeItem->getModelWidget()->getDiagramGraphicsView()->addClassAnnotation();
pLibraryTreeItem->getModelWidget()->getIconGraphicsView()->addClassAnnotation(false);
pLibraryTreeItem->getModelWidget()->getDiagramGraphicsView()->addClassAnnotation(false);
pLibraryTreeItem->getModelWidget()->updateModelicaText();
}
accept();
Expand Down

0 comments on commit 77fc815

Please sign in to comment.