Skip to content

Commit 0db0e7a

Browse files
vinayanmhugent
authored andcommitted
Fixed Rotation anchor issue while zooming panning
1 parent 68e7b01 commit 0db0e7a

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

src/app/qgsmaptoolrotatefeature.cpp

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/***************************************************************************
2+
qgsmaptoolrotatefeature.cpp - map tool for rotating features by mouse drag
3+
---------------------
4+
begin : January 2012
5+
copyright : (C) 2012 by Vinayan Parameswaran
6+
email : vinayan123 at gmail dot com
7+
***************************************************************************
8+
* *
9+
* This program is free software; you can redistribute it and/or modify *
10+
* it under the terms of the GNU General Public License as published by *
11+
* the Free Software Foundation; either version 2 of the License, or *
12+
* (at your option) any later version. *
13+
* *
14+
***************************************************************************/
15+
116
#include "qgsmaptoolrotatefeature.h"
217
#include "qgsgeometry.h"
318
#include "qgslogger.h"
@@ -33,17 +48,19 @@ void QgsMapToolRotateFeature::canvasMoveEvent( QMouseEvent * e )
3348
mAnchorPoint->setCenter(toMapCoordinates(e->pos()));
3449
mStartPointMapCoords = toMapCoordinates(e->pos());
3550
mStPoint = e->pos();
36-
return;
51+
return;
3752
}
3853
if ( mRubberBand )
3954
{
4055
double XDistance = mStPoint.x() - e->pos().x();
4156
double YDistance = mStPoint.y() - e->pos().y();
4257
mRotation = atan2(YDistance, XDistance) * (180/PI);
4358

59+
mStPoint = toCanvasCoordinates(mStartPointMapCoords);
4460
double offsetX = mStPoint.x() - mRubberBand->x();
4561
double offsetY = mStPoint.y() - mRubberBand->y();
46-
mRubberBand->setTransform(QTransform().translate(offsetX, offsetY).rotate(mRotation).translate(-1 * offsetX, -1 * offsetY));
62+
63+
mRubberBand->setTransform(QTransform().translate(offsetX,offsetY).rotate(mRotation).translate(-1 * offsetX, -1 * offsetY));
4764
mRubberBand->update();
4865
}
4966
}
@@ -101,7 +118,7 @@ void QgsMapToolRotateFeature::canvasReleaseEvent( QMouseEvent * e )
101118
return;
102119
}
103120

104-
//calculations for affine transformation..
121+
//calculations for affine transformation
105122
double angle = -1 * mRotation * (PI/180);
106123
QgsPoint anchorPoint = mStartPointMapCoords;
107124
double a = cos(angle);

src/app/qgsmaptoolrotatefeature.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/***************************************************************************
2-
qgsmaptoolmovefeature.h - map tool for translating features by mouse drag
2+
qgsmaptoolrotatefeature.h - map tool for rotating features by mouse drag
33
---------------------
4-
begin : Juli 2007
5-
copyright : (C) 2007 by Marco Hugentobler
6-
email : marco dot hugentobler at karto dot baug dot ethz dot ch
4+
begin : January 2013
5+
copyright : (C) 2013 by Vinayan Parameswaran
6+
email : vinayan123 at gmail dot com
77
***************************************************************************
88
* *
99
* This program is free software; you can redistribute it and/or modify *

0 commit comments

Comments
 (0)