Skip to content

Commit

Permalink
When a shape is updated then update the reference shape and the class…
Browse files Browse the repository at this point in the history
… icon.

Call prepareGeometryChange if we are changing the item boundingRect otherwise we get unexpected paint events.
  • Loading branch information
adeas31 committed Nov 20, 2015
1 parent ef0a109 commit 3035e11
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 10 deletions.
2 changes: 1 addition & 1 deletion OMEdit/OMEditGUI/Annotations/LineAnnotation.cpp
Expand Up @@ -684,6 +684,7 @@ void LineAnnotation::handleComponentMoved()
if (mPoints.size() < 2) {
return;
}
prepareGeometryChange();
if (mpStartComponent) {
Component *pComponent = qobject_cast<Component*>(sender());
if (pComponent == mpStartComponent->getRootParentComponent()) {
Expand All @@ -696,7 +697,6 @@ void LineAnnotation::handleComponentMoved()
updateEndPoint(mpGraphicsView->roundPoint(mpEndComponent->mapToScene(mpEndComponent->boundingRect().center())));
}
}
update();
}

/*!
Expand Down
10 changes: 3 additions & 7 deletions OMEdit/OMEditGUI/Annotations/PolygonAnnotation.cpp
Expand Up @@ -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;
}
}
Expand All @@ -164,8 +161,7 @@ void PolygonAnnotation::paint(QPainter *painter, const QStyleOptionGraphicsItem
{
Q_UNUSED(option);
Q_UNUSED(widget);
if (mVisible)
{
if (mVisible) {
drawPolygonAnnotaion(painter);
}
}
Expand Down
4 changes: 4 additions & 0 deletions OMEdit/OMEditGUI/Annotations/ShapeAnnotation.cpp
Expand Up @@ -1023,17 +1023,20 @@ void ShapeAnnotation::referenceShapeChanged()
ShapeAnnotation *pShapeAnnotation = qobject_cast<ShapeAnnotation*>(sender());
if (pShapeAnnotation) {
if (mpGraphicsView) {
prepareGeometryChange();
updateShape(pShapeAnnotation);
setTransform(pShapeAnnotation->mTransformation.getTransformationMatrix());
removeCornerItems();
drawCornerItems();
setCornerItemsActiveOrPassive();
update();
} else if (mpParentComponent) {
prepareGeometryChange();
updateShape(pShapeAnnotation);
setPos(mOrigin);
setRotation(mRotation);
update();
mpParentComponent->shapeUpdated();
}
}
}
Expand Down Expand Up @@ -1372,6 +1375,7 @@ void ShapeAnnotation::cornerItemReleased()
*/
void ShapeAnnotation::updateCornerItemPoint(int index, QPointF point)
{
prepareGeometryChange();
if (dynamic_cast<LineAnnotation*>(this)) {
LineAnnotation *pLineAnnotation = dynamic_cast<LineAnnotation*>(this);
if (pLineAnnotation->getLineType() == LineAnnotation::ConnectionType) {
Expand Down
1 change: 1 addition & 0 deletions OMEdit/OMEditGUI/Annotations/ShapeAnnotation.h
Expand Up @@ -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();
Expand Down
20 changes: 20 additions & 0 deletions OMEdit/OMEditGUI/Component/Component.cpp
Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -1291,6 +1310,7 @@ void Component::referenceComponentDeleted()
*/
void Component::prepareResizeComponent(ResizerItem *pResizerItem)
{
prepareGeometryChange();
mOldTransformation = mTransformation;
mpSelectedResizerItem = pResizerItem;
mTransform = transform();
Expand Down
1 change: 1 addition & 0 deletions OMEdit/OMEditGUI/Component/Component.h
Expand Up @@ -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);
Expand Down
2 changes: 0 additions & 2 deletions OMEdit/OMEditGUI/Modeling/Commands.cpp
Expand Up @@ -109,7 +109,6 @@ void UpdateShapeCommand::redo()
mpShapeAnnotation->removeCornerItems();
mpShapeAnnotation->drawCornerItems();
mpShapeAnnotation->setCornerItemsActiveOrPassive();
mpShapeAnnotation->update();
mpShapeAnnotation->emitChanged();
mpShapeAnnotation->getGraphicsView()->setAddClassAnnotationNeeded(true);
}
Expand All @@ -125,7 +124,6 @@ void UpdateShapeCommand::undo()
mpShapeAnnotation->removeCornerItems();
mpShapeAnnotation->drawCornerItems();
mpShapeAnnotation->setCornerItemsActiveOrPassive();
mpShapeAnnotation->update();
mpShapeAnnotation->emitChanged();
mpShapeAnnotation->getGraphicsView()->setAddClassAnnotationNeeded(true);
}
Expand Down

0 comments on commit 3035e11

Please sign in to comment.