@@ -46,48 +46,49 @@ int QgsMapToPixel::mapHeight() const
46
46
47
47
int QgsMapToPixel::mapWidth () const
48
48
{
49
- return ((xCenter-xMin)*2 )/ mMapUnitsPerPixel ;
49
+ return (( xCenter -xMin )*2 ) / mMapUnitsPerPixel ;
50
50
}
51
51
52
52
QTransform QgsMapToPixel::getMatrix () const
53
53
{
54
- double cy = mapHeight ()/ 2.0 ;
55
- double cx = mapWidth ()/ 2.0 ;
54
+ double cy = mapHeight () / 2.0 ;
55
+ double cx = mapWidth () / 2.0 ;
56
56
double rotation = mapRotation ();
57
57
58
58
#if 0 // debugging
59
- QgsDebugMsg(QString("XXX %7 -- xCent:%1 yCent:%2 mWidth:%3 mHeight:%4 uPP:%5 rot:%6")
60
- .arg(xCenter).arg(yCenter).arg(mWidth).arg(mHeight)
61
- .arg(mMapUnitsPerPixel).arg(rotation).arg((quintptr)this,QT_POINTER_SIZE *2, 15, QChar('0')) );
59
+ QgsDebugMsg( QString( "XXX %7 -- xCent:%1 yCent:%2 mWidth:%3 mHeight:%4 uPP:%5 rot:%6" )
60
+ .arg( xCenter ).arg( yCenter ).arg( mWidth ).arg( mHeight )
61
+ .arg( mMapUnitsPerPixel ).arg( rotation ).arg(( quintptr )this, QT_POINTER_SIZE *2, 15, QChar( '0' ) ) );
62
62
#endif
63
63
64
64
// NOTE: operations are done in the reverse order in which
65
65
// they are configured, so translation to geographical
66
66
// center happens first, then scaling, then rotation
67
67
// and finally translation to output viewport center
68
68
69
- if ( ! rotation ) {
69
+ if ( ! rotation )
70
+ {
70
71
// Returning a simplified matrix in hope it'll give expected
71
72
// results from an existing test, see
72
73
// https://travis-ci.org/qgis/QGIS/builds/42508945
73
- return QTransform::fromScale ( 1.0 / mMapUnitsPerPixel , -1.0 / mMapUnitsPerPixel )
74
- .translate ( -xMin, - ( yMin + mHeight *mMapUnitsPerPixel ) );
74
+ return QTransform::fromScale ( 1.0 / mMapUnitsPerPixel , -1.0 / mMapUnitsPerPixel )
75
+ .translate ( -xMin, - ( yMin + mHeight *mMapUnitsPerPixel ) );
75
76
}
76
77
77
78
return QTransform::fromTranslate ( cx, cy )
78
79
.rotate ( rotation )
79
- .scale ( 1 / mMapUnitsPerPixel , -1 / mMapUnitsPerPixel )
80
- .translate ( -xCenter, -yCenter )
80
+ .scale ( 1 / mMapUnitsPerPixel , -1 / mMapUnitsPerPixel )
81
+ .translate ( -xCenter, -yCenter )
81
82
;
82
83
}
83
84
84
85
QgsPoint QgsMapToPixel::toMapPoint ( double x, double y ) const
85
86
{
86
87
bool invertible;
87
- QTransform matrix = getMatrix ().inverted (&invertible);
88
- assert (invertible);
88
+ QTransform matrix = getMatrix ().inverted ( &invertible );
89
+ assert ( invertible );
89
90
double mx, my;
90
- matrix.map (x, y, &mx, &my);
91
+ matrix.map ( x, y, &mx, &my );
91
92
QgsPoint ret ( mx, my );
92
93
93
94
// QgsDebugMsg(QString("XXX toMapPoint x:%1 y:%2 -> x:%3 y:%4").arg(x).arg(y).arg(mx).arg(my));
@@ -126,8 +127,8 @@ void QgsMapToPixel::setMapRotation( double degrees, double cx, double cy )
126
127
mMapRotation = degrees;
127
128
xCenter = cx;
128
129
yCenter = cy;
129
- assert (xCenter >= xMin);
130
- assert (yCenter >= yMin);
130
+ assert ( xCenter >= xMin );
131
+ assert ( yCenter >= yMin );
131
132
// assert(yCenter <= yMin + mHeight*mMapUnitsPerPixel;
132
133
}
133
134
@@ -206,7 +207,7 @@ void QgsMapToPixel::transformInPlace( qreal& x, qreal& y ) const
206
207
207
208
QTransform matrix = getMatrix ();
208
209
double mx, my;
209
- matrix.map (x, y, &mx, &my);
210
+ matrix.map ( x, y, &mx, &my );
210
211
// QgsDebugMsg(QString("XXX transformInPlace X : %1-->%2, Y: %3 -->%4").arg(x).arg(mx).arg(y).arg(my));
211
212
x = mx; y = my;
212
213
}
0 commit comments