diff --git a/OMEdit/OMEditGUI/Annotations/LineAnnotation.cpp b/OMEdit/OMEditGUI/Annotations/LineAnnotation.cpp index db569e1acb5..c4269bf9f78 100644 --- a/OMEdit/OMEditGUI/Annotations/LineAnnotation.cpp +++ b/OMEdit/OMEditGUI/Annotations/LineAnnotation.cpp @@ -684,6 +684,7 @@ void LineAnnotation::handleComponentMoved() if (mPoints.size() < 2) { return; } + prepareGeometryChange(); if (mpStartComponent) { Component *pComponent = qobject_cast(sender()); if (pComponent == mpStartComponent->getRootParentComponent()) { @@ -696,7 +697,6 @@ void LineAnnotation::handleComponentMoved() updateEndPoint(mpGraphicsView->roundPoint(mpEndComponent->mapToScene(mpEndComponent->boundingRect().center()))); } } - update(); } /*! diff --git a/OMEdit/OMEditGUI/Annotations/PolygonAnnotation.cpp b/OMEdit/OMEditGUI/Annotations/PolygonAnnotation.cpp index 28ef9b95f73..42989a24f18 100644 --- a/OMEdit/OMEditGUI/Annotations/PolygonAnnotation.cpp +++ b/OMEdit/OMEditGUI/Annotations/PolygonAnnotation.cpp @@ -150,12 +150,9 @@ QRectF PolygonAnnotation::boundingRect() const QPainterPath PolygonAnnotation::shape() const { QPainterPath path = getShape(); - if (mFillPattern == StringHandler::FillNone) - { + if (mFillPattern == StringHandler::FillNone) { return addPathStroker(path); - } - else - { + } else { return path; } } @@ -164,8 +161,7 @@ void PolygonAnnotation::paint(QPainter *painter, const QStyleOptionGraphicsItem { Q_UNUSED(option); Q_UNUSED(widget); - if (mVisible) - { + if (mVisible) { drawPolygonAnnotaion(painter); } } diff --git a/OMEdit/OMEditGUI/Annotations/ShapeAnnotation.cpp b/OMEdit/OMEditGUI/Annotations/ShapeAnnotation.cpp index 26c00852d40..f702a0e4baa 100644 --- a/OMEdit/OMEditGUI/Annotations/ShapeAnnotation.cpp +++ b/OMEdit/OMEditGUI/Annotations/ShapeAnnotation.cpp @@ -1023,6 +1023,7 @@ void ShapeAnnotation::referenceShapeChanged() ShapeAnnotation *pShapeAnnotation = qobject_cast(sender()); if (pShapeAnnotation) { if (mpGraphicsView) { + prepareGeometryChange(); updateShape(pShapeAnnotation); setTransform(pShapeAnnotation->mTransformation.getTransformationMatrix()); removeCornerItems(); @@ -1030,10 +1031,12 @@ void ShapeAnnotation::referenceShapeChanged() setCornerItemsActiveOrPassive(); update(); } else if (mpParentComponent) { + prepareGeometryChange(); updateShape(pShapeAnnotation); setPos(mOrigin); setRotation(mRotation); update(); + mpParentComponent->shapeUpdated(); } } } @@ -1372,6 +1375,7 @@ void ShapeAnnotation::cornerItemReleased() */ void ShapeAnnotation::updateCornerItemPoint(int index, QPointF point) { + prepareGeometryChange(); if (dynamic_cast(this)) { LineAnnotation *pLineAnnotation = dynamic_cast(this); if (pLineAnnotation->getLineType() == LineAnnotation::ConnectionType) { diff --git a/OMEdit/OMEditGUI/Annotations/ShapeAnnotation.h b/OMEdit/OMEditGUI/Annotations/ShapeAnnotation.h index 77dc895f5e1..c41e6ce87ba 100644 --- a/OMEdit/OMEditGUI/Annotations/ShapeAnnotation.h +++ b/OMEdit/OMEditGUI/Annotations/ShapeAnnotation.h @@ -192,6 +192,7 @@ class ShapeAnnotation : public QObject, public QGraphicsItem, public GraphicItem void emitAdded() {emit added();} void emitChanged() {emit changed();} void emitDeleted() {emit deleted();} + void emitPrepareGeometryChange() {prepareGeometryChange();} signals: void updateReferenceShapes(); void added(); diff --git a/OMEdit/OMEditGUI/Component/Component.cpp b/OMEdit/OMEditGUI/Component/Component.cpp index b4b90a653f7..048d63e019d 100644 --- a/OMEdit/OMEditGUI/Component/Component.cpp +++ b/OMEdit/OMEditGUI/Component/Component.cpp @@ -818,6 +818,10 @@ QString Component::getParameterDisplayString(QString parameterName) return displayString; } +/*! + * \brief Component::shapeAdded + * Called when a reference shape is added in its actual class. + */ void Component::shapeAdded() { mpNonExistingComponentLine->setVisible(false); @@ -828,6 +832,21 @@ void Component::shapeAdded() } } +/*! + * \brief Component::shapeUpdated + * Called when a reference shape is updated in its actual class. + */ +void Component::shapeUpdated() +{ + if (mpGraphicsView->getViewType() == StringHandler::Icon) { + mpGraphicsView->getModelWidget()->getLibraryTreeItem()->handleIconUpdated(); + } +} + +/*! + * \brief Component::shapeDeleted + * Called when a reference shape is deleted in its actual class. + */ void Component::shapeDeleted() { mpNonExistingComponentLine->setVisible(false); @@ -1291,6 +1310,7 @@ void Component::referenceComponentDeleted() */ void Component::prepareResizeComponent(ResizerItem *pResizerItem) { + prepareGeometryChange(); mOldTransformation = mTransformation; mpSelectedResizerItem = pResizerItem; mTransform = transform(); diff --git a/OMEdit/OMEditGUI/Component/Component.h b/OMEdit/OMEditGUI/Component/Component.h index 72854effaa6..5d8b78d669a 100644 --- a/OMEdit/OMEditGUI/Component/Component.h +++ b/OMEdit/OMEditGUI/Component/Component.h @@ -182,6 +182,7 @@ class Component : public QObject, public QGraphicsItem void componentParameterHasChanged(); QString getParameterDisplayString(QString parameterName); void shapeAdded(); + void shapeUpdated(); void shapeDeleted(); void addInterfacePoint(TLMInterfacePointInfo *pTLMInterfacePointInfo); void removeInterfacePoint(TLMInterfacePointInfo *pTLMInterfacePointInfo); diff --git a/OMEdit/OMEditGUI/Modeling/Commands.cpp b/OMEdit/OMEditGUI/Modeling/Commands.cpp index 364bdf02cff..eb365c4ffac 100644 --- a/OMEdit/OMEditGUI/Modeling/Commands.cpp +++ b/OMEdit/OMEditGUI/Modeling/Commands.cpp @@ -109,7 +109,6 @@ void UpdateShapeCommand::redo() mpShapeAnnotation->removeCornerItems(); mpShapeAnnotation->drawCornerItems(); mpShapeAnnotation->setCornerItemsActiveOrPassive(); - mpShapeAnnotation->update(); mpShapeAnnotation->emitChanged(); mpShapeAnnotation->getGraphicsView()->setAddClassAnnotationNeeded(true); } @@ -125,7 +124,6 @@ void UpdateShapeCommand::undo() mpShapeAnnotation->removeCornerItems(); mpShapeAnnotation->drawCornerItems(); mpShapeAnnotation->setCornerItemsActiveOrPassive(); - mpShapeAnnotation->update(); mpShapeAnnotation->emitChanged(); mpShapeAnnotation->getGraphicsView()->setAddClassAnnotationNeeded(true); }