Rotate DrawViewPart around part centroid

This commit is contained in:
WandererFan
2017-10-19 20:17:11 -04:00
parent 03f439caf7
commit 44fd200166
10 changed files with 89 additions and 15 deletions

View File

@@ -267,19 +267,25 @@ void QGIView::updateView(bool update)
if (update ||
getViewObject()->Rotation.isTouched() ) {
//NOTE: QPainterPaths have to be rotated individually. This transform handles Rotation for everything else.
//Scale is handled in GeometryObject for DVP & descendents
//Objects not descended from DVP must setScale for themselves
//note that setTransform(,,rotation,,) is not the same as setRotation!!!
double rot = getViewObject()->Rotation.getValue();
QPointF centre = boundingRect().center();
setTransform(QTransform().translate(centre.x(), centre.y()).rotate(-rot).translate(-centre.x(), -centre.y()));
rotateView();
}
if (update)
QGraphicsItem::update();
}
//QGIVP derived classes do not need a rotate view method as rotation is handled on App side.
void QGIView::rotateView(void)
{
//NOTE: QPainterPaths have to be rotated individually. This transform handles Rotation for everything else.
//Scale is handled in GeometryObject for DVP & descendents
//Objects not descended from DVP must setScale for themselves
//note that setTransform(,,rotation,,) is not the same as setRotation!!!
double rot = getViewObject()->Rotation.getValue();
QPointF centre = boundingRect().center();
setTransform(QTransform().translate(centre.x(), centre.y()).rotate(-rot).translate(-centre.x(), -centre.y()));
}
const char * QGIView::getViewName() const
{
return viewName.c_str();