|
| 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 | + |
1 | 16 | #include "qgsmaptoolrotatefeature.h" |
2 | 17 | #include "qgsgeometry.h" |
3 | 18 | #include "qgslogger.h" |
@@ -33,17 +48,19 @@ void QgsMapToolRotateFeature::canvasMoveEvent( QMouseEvent * e ) |
33 | 48 | mAnchorPoint->setCenter(toMapCoordinates(e->pos())); |
34 | 49 | mStartPointMapCoords = toMapCoordinates(e->pos()); |
35 | 50 | mStPoint = e->pos(); |
36 | | - return; |
| 51 | + return; |
37 | 52 | } |
38 | 53 | if ( mRubberBand ) |
39 | 54 | { |
40 | 55 | double XDistance = mStPoint.x() - e->pos().x(); |
41 | 56 | double YDistance = mStPoint.y() - e->pos().y(); |
42 | 57 | mRotation = atan2(YDistance, XDistance) * (180/PI); |
43 | 58 |
|
| 59 | + mStPoint = toCanvasCoordinates(mStartPointMapCoords); |
44 | 60 | double offsetX = mStPoint.x() - mRubberBand->x(); |
45 | 61 | 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)); |
47 | 64 | mRubberBand->update(); |
48 | 65 | } |
49 | 66 | } |
@@ -101,7 +118,7 @@ void QgsMapToolRotateFeature::canvasReleaseEvent( QMouseEvent * e ) |
101 | 118 | return; |
102 | 119 | } |
103 | 120 |
|
104 | | - //calculations for affine transformation.. |
| 121 | + //calculations for affine transformation |
105 | 122 | double angle = -1 * mRotation * (PI/180); |
106 | 123 | QgsPoint anchorPoint = mStartPointMapCoords; |
107 | 124 | double a = cos(angle); |
|
0 commit comments