Skip to content

Commit

Permalink
[NewAPI] Do not use the icon annotation as fallback (#9594)
Browse files Browse the repository at this point in the history
* [NewAPI] Do not use the icon annotation as fallback

For connectors, the icon layer is used to represent a connector when it is shown in the icon layer of the enclosing model. The diagram layer of the connector is used to represent it when shown in the diagram layer of the enclosing model.

Fixes #9557

* Always use the icon annotation when element type is port
  • Loading branch information
adeas31 committed Oct 26, 2022
1 parent e07b698 commit acb08e9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 30 deletions.
44 changes: 15 additions & 29 deletions OMEdit/OMEditLIB/Element/Element.cpp
Expand Up @@ -2653,11 +2653,14 @@ void Element::createClassInheritedElements()
void Element::createClassShapes()
{
if (mpGraphicsView->getModelWidget()->isNewApi()) {
/* ticket:4505
* Only use the diagram annotation when connector is inside the component instance.
*/
QList<ModelInstance::Shape*> shapes;
if (mpModel->isConnector() && mpGraphicsView->getViewType() == StringHandler::Diagram && canUseDiagramAnnotation() && !mpModel->getDiagramAnnotation()->isGraphicsEmpty()) {
/* issue #9557
* For connectors, the icon layer is used to represent a connector when it is shown in the icon layer of the enclosing model.
* The diagram layer of the connector is used to represent it when shown in the diagram layer of the enclosing model.
*
* Always use the icon annotation when element type is port.
*/
if (mpModel->isConnector() && mpGraphicsView->getViewType() == StringHandler::Diagram && mElementType != Element::Port) {
shapes = mpModel->getDiagramAnnotation()->getGraphics();
} else {
shapes = mpModel->getIconAnnotation()->getGraphics();
Expand Down Expand Up @@ -2686,14 +2689,15 @@ void Element::createClassShapes()
pMainWindow->getLibraryWidget()->getLibraryTreeModel()->showModelWidget(mpLibraryTreeItem, false);
}
GraphicsView *pGraphicsView = mpLibraryTreeItem->getModelWidget()->getIconGraphicsView();
/* ticket:4505
* Only use the diagram annotation when connector is inside the component instance.
*/
if (mpLibraryTreeItem->isConnector() && mpGraphicsView->getViewType() == StringHandler::Diagram && canUseDiagramAnnotation()) {
/* issue #9557
* For connectors, the icon layer is used to represent a connector when it is shown in the icon layer of the enclosing model.
* The diagram layer of the connector is used to represent it when shown in the diagram layer of the enclosing model.
*
* Always use the icon annotation when element type is port.
*/
if (mpLibraryTreeItem->isConnector() && mpGraphicsView->getViewType() == StringHandler::Diagram && mElementType != Element::Port) {
mpLibraryTreeItem->getModelWidget()->loadDiagramView();
if (mpLibraryTreeItem->getModelWidget()->getDiagramGraphicsView()->hasAnnotation()) {
pGraphicsView = mpLibraryTreeItem->getModelWidget()->getDiagramGraphicsView();
}
pGraphicsView = mpLibraryTreeItem->getModelWidget()->getDiagramGraphicsView();
}
foreach (ShapeAnnotation *pShapeAnnotation, pGraphicsView->getShapesList()) {
if (dynamic_cast<LineAnnotation*>(pShapeAnnotation)) {
Expand Down Expand Up @@ -3057,24 +3061,6 @@ void Element::updateToolTip()
}
}

/*!
* \brief Element::canUseDiagramAnnotation
* If the component is a port component or has a port component as parent in the hirerchy
* then we should not use the diagram annotation.
* \return
*/
bool Element::canUseDiagramAnnotation()
{
Element *pElement = this;
while (pElement->getParentElement()) {
if (pElement->getElementType() == Element::Port) {
return false;
}
pElement = pElement->getParentElement();
}
return true;
}

void Element::updatePlacementAnnotation()
{
// Add component annotation.
Expand Down
1 change: 0 additions & 1 deletion OMEdit/OMEditLIB/Element/Element.h
Expand Up @@ -381,7 +381,6 @@ class Element : public QObject, public QGraphicsItem
QString getParameterDisplayStringFromExtendsParameters(QString parameterName, QString modifierString);
bool checkEnumerationDisplayString(QString &displayString, const QString &typeName);
void updateToolTip();
bool canUseDiagramAnnotation();
signals:
void added();
void transformChange(bool positionChanged);
Expand Down

0 comments on commit acb08e9

Please sign in to comment.