Skip to content

Commit

Permalink
Clear the annotation attributes before parsing new ones
Browse files Browse the repository at this point in the history
  • Loading branch information
adeas31 committed May 11, 2020
1 parent 57ea0be commit 2d50069
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions OMEdit/OMEditLIB/Annotations/PolygonAnnotation.cpp
Expand Up @@ -269,12 +269,14 @@ QString PolygonAnnotation::getShapeAnnotation()

void PolygonAnnotation::addPoint(QPointF point)
{
prepareGeometryChange();
mPoints.append(point);
mPoints.back() = mPoints.first();
}

void PolygonAnnotation::removePoint(int index)
{
prepareGeometryChange();
if (mPoints.size() > index) {
mPoints.removeAt(index);
}
Expand All @@ -287,6 +289,7 @@ void PolygonAnnotation::clearPoints()

void PolygonAnnotation::updateEndPoint(QPointF point)
{
prepareGeometryChange();
// we update the second last point for polygon since the last point is connected to first one
mPoints.replace(mPoints.size() - 2, point);
}
Expand Down
5 changes: 5 additions & 0 deletions OMEdit/OMEditLIB/Annotations/ShapeAnnotation.cpp
Expand Up @@ -371,10 +371,14 @@ void ShapeAnnotation::setDefaults()
mLineColor = QColor(0, 0, 0);
mLinePattern = StringHandler::LineSolid;
mLineThickness = 0.25;
mPoints.clear();
mGeometries.clear();
mArrow.clear();
mArrow.append(StringHandler::ArrowNone);
mArrow.append(StringHandler::ArrowNone);
mArrowSize = 3;
mSmooth = StringHandler::SmoothNone;
mExtents.clear();
mExtents.append(QPointF(0, 0));
mExtents.append(QPointF(0, 0));
mBorderPattern = StringHandler::BorderNone;
Expand All @@ -385,6 +389,7 @@ void ShapeAnnotation::setDefaults()
mTextString = "";
mFontSize = 0;
mFontName = Helper::systemFontInfo.family();
mTextStyles.clear();
mHorizontalAlignment = StringHandler::TextAlignmentCenter;
mOriginalFileName = "";
mFileName = "";
Expand Down
8 changes: 8 additions & 0 deletions OMEdit/OMEditLIB/Modeling/Commands.cpp
Expand Up @@ -133,6 +133,10 @@ UpdateShapeCommand::UpdateShapeCommand(ShapeAnnotation *pShapeAnnotation, QStrin
*/
void UpdateShapeCommand::redoInternal()
{
mpShapeAnnotation->GraphicItem::setDefaults();
mpShapeAnnotation->FilledShape::setDefaults();
mpShapeAnnotation->setDefaults();
mpShapeAnnotation->setUserDefaults();
mpShapeAnnotation->parseShapeAnnotation(mNewAnnotation);
/* If the shape is LineAnnotation then remove and draw the corner items
* since they might have been changed in number based on the annotation.
Expand All @@ -154,6 +158,10 @@ void UpdateShapeCommand::redoInternal()
*/
void UpdateShapeCommand::undo()
{
mpShapeAnnotation->GraphicItem::setDefaults();
mpShapeAnnotation->FilledShape::setDefaults();
mpShapeAnnotation->setDefaults();
mpShapeAnnotation->setUserDefaults();
mpShapeAnnotation->parseShapeAnnotation(mOldAnnotation);
/* If the shape is LineAnnotation then remove and draw the corner items
* since they might have been changed in number based on the annotation.
Expand Down

0 comments on commit 2d50069

Please sign in to comment.