Rotate DrawViewPart around part centroid
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user