Fix bug with resize rectangle. Wrong scale factor.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2017-03-14 13:19:34 +02:00
parent cf47ab8aa9
commit f48325cc52
2 changed files with 25 additions and 17 deletions

View File

@ -145,6 +145,7 @@ void VGrainlineItem::paint(QPainter* pP, const QStyleOptionGraphicsItem* pOption
if (m_eMode != mRotate)
{
pP->setBrush(clr);
UpdatePolyResize();
pP->drawPolygon(m_polyResize);
}
@ -565,23 +566,7 @@ void VGrainlineItem::UpdateRectangle()
m_rectBoundingBox = m_polyBound.boundingRect();
setTransformOriginPoint(m_rectBoundingBox.center());
m_polyResize.clear();
QPointF ptA = m_polyBound.at(1);
m_polyResize << ptA;
const double dSize = m_dScale * RESIZE_RECT_SIZE;
ptA.setX(ptA.x() - dSize*cos(m_dRotation - M_PI/2));
ptA.setY(ptA.y() + dSize*sin(m_dRotation - M_PI/2));
m_polyResize << ptA;
ptA.setX(ptA.x() + dSize*cos(m_dRotation));
ptA.setY(ptA.y() - dSize*sin(m_dRotation));
m_polyResize << ptA;
ptA.setX(ptA.x() - dSize*cos(m_dRotation + M_PI/2));
ptA.setY(ptA.y() + dSize*sin(m_dRotation + M_PI/2));
m_polyResize << ptA;
UpdatePolyResize();
prepareGeometryChange();
}
@ -765,3 +750,24 @@ void VGrainlineItem::UserMoveAndResize(const QPointF &pos)
SetOverrideCursor(cursorArrowCloseHand, 1, 1);
}
}
//---------------------------------------------------------------------------------------------------------------------
void VGrainlineItem::UpdatePolyResize()
{
m_polyResize.clear();
QPointF ptA = m_polyBound.at(1);
m_polyResize << ptA;
const double dSize = m_dScale * RESIZE_RECT_SIZE;
ptA.setX(ptA.x() - dSize*cos(m_dRotation - M_PI/2));
ptA.setY(ptA.y() + dSize*sin(m_dRotation - M_PI/2));
m_polyResize << ptA;
ptA.setX(ptA.x() + dSize*cos(m_dRotation));
ptA.setY(ptA.y() - dSize*sin(m_dRotation));
m_polyResize << ptA;
ptA.setX(ptA.x() - dSize*cos(m_dRotation + M_PI/2));
ptA.setY(ptA.y() + dSize*sin(m_dRotation + M_PI/2));
m_polyResize << ptA;
}

View File

@ -93,6 +93,8 @@ private:
void AllUserModifications(const QPointF &pos);
void UserRotateAndMove();
void UserMoveAndResize(const QPointF &pos);
void UpdatePolyResize();
};
#endif // VGRAINLINEITEM_H