void MainWindow::updateRotate(qreal value)
{
QTransform txf = QTransform();
rotateAngle = 360*value;
switch (rotateAxis)
{
case 0:
// Up arrow - Rotate along top axis
txf.translate(item->boundingRect().width()/2, 0);
txf.rotate(rotateAngle, Qt::XAxis);
txf.translate(-item->boundingRect().width()/2, 0);
//item->setTransformOriginPoint(item->boundingRect().width()/2, item->boundingRect().height()/2);
break;
case 1:
// Right arrow - Rotate along rigth axis
txf.translate(item->boundingRect().width(), item->boundingRect().height()/2);
txf.rotate(rotateAngle, Qt::YAxis);
txf.translate(-item->boundingRect().width(), -item->boundingRect().height()/2);
//item->setTransformOriginPoint(item->boundingRect().width(), item->boundingRect().height()/2);
break;
case 2:
// Left arrow - Rotate along left axis
txf.translate(0, item->boundingRect().height()/2);
txf.rotate(rotateAngle, Qt::YAxis);
txf.translate(0, -item->boundingRect().height()/2);
//item->setTransformOriginPoint(0, item->boundingRect().height()/2);
break;
case 3:
// Down arrow - Rotate along bottom axis
txf.translate(item->boundingRect().width()/2,item->boundingRect().height());
txf.rotate(rotateAngle, Qt::XAxis);
txf.translate(-item->boundingRect().width()/2,-item->boundingRect().height());
//item->setTransformOriginPoint(item->boundingRect().width()/2,item->boundingRect().height());
break;
}
item->setTransform(txf, false);
}
void MainWindow::updateRotate(qreal value)
{
QTransform txf = QTransform();
rotateAngle = 360*value;
switch (rotateAxis)
{
case 0:
// Up arrow - Rotate along top axis
txf.translate(item->boundingRect().width()/2, 0);
txf.rotate(rotateAngle, Qt::XAxis);
txf.translate(-item->boundingRect().width()/2, 0);
//item->setTransformOriginPoint(item->boundingRect().width()/2, item->boundingRect().height()/2);
break;
case 1:
// Right arrow - Rotate along rigth axis
txf.translate(item->boundingRect().width(), item->boundingRect().height()/2);
txf.rotate(rotateAngle, Qt::YAxis);
txf.translate(-item->boundingRect().width(), -item->boundingRect().height()/2);
//item->setTransformOriginPoint(item->boundingRect().width(), item->boundingRect().height()/2);
break;
case 2:
// Left arrow - Rotate along left axis
txf.translate(0, item->boundingRect().height()/2);
txf.rotate(rotateAngle, Qt::YAxis);
txf.translate(0, -item->boundingRect().height()/2);
//item->setTransformOriginPoint(0, item->boundingRect().height()/2);
break;
case 3:
// Down arrow - Rotate along bottom axis
txf.translate(item->boundingRect().width()/2,item->boundingRect().height());
txf.rotate(rotateAngle, Qt::XAxis);
txf.translate(-item->boundingRect().width()/2,-item->boundingRect().height());
//item->setTransformOriginPoint(item->boundingRect().width()/2,item->boundingRect().height());
break;
}
item->setTransform(txf, false);
}
To copy to clipboard, switch view to plain text mode
Bookmarks