Skip to content
Permalink
Browse files
Fixed Rotation anchor issue while zooming panning
  • Loading branch information
vinayan authored and mhugent committed Jan 12, 2013
1 parent 68e7b01 commit 0db0e7a199dc3a6f998c9edfad8b4ea62229da64
Showing with 24 additions and 7 deletions.
  1. +20 −3 src/app/qgsmaptoolrotatefeature.cpp
  2. +4 −4 src/app/qgsmaptoolrotatefeature.h
@@ -1,3 +1,18 @@
/***************************************************************************
qgsmaptoolrotatefeature.cpp - map tool for rotating features by mouse drag
---------------------
begin : January 2012
copyright : (C) 2012 by Vinayan Parameswaran
email : vinayan123 at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#include "qgsmaptoolrotatefeature.h"
#include "qgsgeometry.h"
#include "qgslogger.h"
@@ -33,17 +48,19 @@ void QgsMapToolRotateFeature::canvasMoveEvent( QMouseEvent * e )
mAnchorPoint->setCenter(toMapCoordinates(e->pos()));
mStartPointMapCoords = toMapCoordinates(e->pos());
mStPoint = e->pos();
return;
return;
}
if ( mRubberBand )
{
double XDistance = mStPoint.x() - e->pos().x();
double YDistance = mStPoint.y() - e->pos().y();
mRotation = atan2(YDistance, XDistance) * (180/PI);

mStPoint = toCanvasCoordinates(mStartPointMapCoords);
double offsetX = mStPoint.x() - mRubberBand->x();
double offsetY = mStPoint.y() - mRubberBand->y();
mRubberBand->setTransform(QTransform().translate(offsetX, offsetY).rotate(mRotation).translate(-1 * offsetX, -1 * offsetY));

mRubberBand->setTransform(QTransform().translate(offsetX,offsetY).rotate(mRotation).translate(-1 * offsetX, -1 * offsetY));
mRubberBand->update();
}
}
@@ -101,7 +118,7 @@ void QgsMapToolRotateFeature::canvasReleaseEvent( QMouseEvent * e )
return;
}

//calculations for affine transformation..
//calculations for affine transformation
double angle = -1 * mRotation * (PI/180);
QgsPoint anchorPoint = mStartPointMapCoords;
double a = cos(angle);
@@ -1,9 +1,9 @@
/***************************************************************************
qgsmaptoolmovefeature.h - map tool for translating features by mouse drag
qgsmaptoolrotatefeature.h - map tool for rotating features by mouse drag
---------------------
begin : Juli 2007
copyright : (C) 2007 by Marco Hugentobler
email : marco dot hugentobler at karto dot baug dot ethz dot ch
begin : January 2013
copyright : (C) 2013 by Vinayan Parameswaran
email : vinayan123 at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *

0 comments on commit 0db0e7a

Please sign in to comment.