Added startUserTransformation() and handleUserTransformation() methods to the CustomElementPart class and all of its subclasses.

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2026 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
xavier
2013-02-08 22:05:12 +00:00
parent c2b69dd6da
commit 73fa01c7b9
20 changed files with 269 additions and 0 deletions

View File

@@ -198,3 +198,30 @@ QRectF PartCircle::boundingRect() const {
bool PartCircle::isUseless() const {
return(rect().isNull());
}
/**
Start the user-induced transformation, provided this primitive is contained
within the \a initial_selection_rect bounding rectangle.
*/
void PartCircle::startUserTransformation(const QRectF &initial_selection_rect) {
Q_UNUSED(initial_selection_rect)
saved_center_ = mapToScene(rect().center());
saved_diameter_ = rect().width();
}
/**
Handle the user-induced transformation from \a initial_selection_rect to \a new_selection_rect
*/
void PartCircle::handleUserTransformation(const QRectF &initial_selection_rect, const QRectF &new_selection_rect) {
QPointF new_center = mapPoints(initial_selection_rect, new_selection_rect, QList<QPointF>() << saved_center_).first();
qreal sx = new_selection_rect.width() / initial_selection_rect.width();
qreal sy = new_selection_rect.height() / initial_selection_rect.height();
qreal smallest_scale_factor = sx > sy ? sy : sx;
qreal new_diameter = saved_diameter_ * smallest_scale_factor;
QRectF new_rect(QPointF(), QSizeF(new_diameter, new_diameter));
new_rect.moveCenter(mapFromScene(new_center));
setRect(new_rect);
}