ellipse editor : use QPropertyUndoCommand instead of ChangePartCommand

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4067 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
blacksun
2015-07-23 09:57:09 +00:00
parent a00bfdf00f
commit 65d4b08c86
5 changed files with 106 additions and 161 deletions

View File

@@ -159,74 +159,3 @@ void AbstractPartEllipse::setSpanAngle(const int &span_angle)
m_span_angle = span_angle;
emit spanAngleChanged();
}
/**
* @brief AbstractPartEllipse::setCenterX
* Like setCenter but Y keep unchanged
* See setCenter(const QPointF &center)
* @param x
*/
void AbstractPartEllipse::setCenterX(const qreal x)
{
QPointF pos = mapToParent(m_rect.center());
pos.setX(x);
setCenter(pos);
}
/**
* @brief AbstractPartEllipse::setCenterY
* Like setCenter but X keep unchanged
* See setCenter(const QPointF &center)
* @param y
*/
void AbstractPartEllipse::setCenterY(const qreal y)
{
QPointF pos = mapToParent(m_rect.center());
pos.setY(y);
setCenter(pos);
}
/**
* @brief AbstractPartEllipse::setCenter
* This is a convenience method to setPos().
* Adjust the position of this item,
* so that the center of the rectangle is at the given position(position in parent coordinates).
* @param center
*/
void AbstractPartEllipse::setCenter(const QPointF &center)
{
QPointF pos = center - m_rect.center();
setPos(pos);
}
/**
* @brief AbstractPartEllipse::setWidth
* Set new width for rectangle.
* The center of rectangle is unchanged,
* The coordinates of the left side and right side of the rectangle change
* @param w
*/
void AbstractPartEllipse::setWidth(const qreal w)
{
qreal new_width = qAbs(w);
QRectF current_rect = rect();
current_rect.translate((new_width - current_rect.width()) / -2.0, 0.0);
current_rect.setWidth(new_width);
setRect(current_rect);
}
/**
* @brief AbstractPartEllipse::setHeight
* Set new height for rectangle
* The center of rectangle is unchanged
* The coordinates of the top side and bottom side of the rectangle change
* @param h
*/
void AbstractPartEllipse::setHeight(const qreal h)
{
qreal new_height = qAbs(h);
QRectF current_rect = rect();
current_rect.translate(0.0, (new_height - current_rect.height()) / -2.0);
current_rect.setHeight(new_height);
setRect(current_rect);
}