20 #include <QTextStream>
33 : mMapUnitsPerPixel( mapUnitsPerPixel )
36 , mRotation( rotation )
39 , xMin( xc - ( mWidth * mMapUnitsPerPixel / 2.0 ) )
40 , yMin( yc - ( mHeight * mMapUnitsPerPixel / 2.0 ) )
42 Q_ASSERT( mapUnitsPerPixel > 0 );
47 : mMapUnitsPerPixel( 1 )
63 : mMapUnitsPerPixel( mapUnitsPerPixel )
89 void QgsMapToPixel::updateMatrix()
94 QgsDebugMsg( QString(
"XXX %7 -- xCent:%1 yCent:%2 mWidth:%3 mHeight:%4 uPP:%5 rot:%6" )
95 .arg( xCenter ).arg( yCenter ).arg( mWidth ).arg( mHeight )
96 .arg( mMapUnitsPerPixel ).arg( rotation ).arg(( quintptr )
this, QT_POINTER_SIZE *2, 15, QChar(
'0' ) ) );
107 mMatrix = QTransform::fromScale( 1.0 / mMapUnitsPerPixel, -1.0 / mMapUnitsPerPixel )
108 .translate( -xMin, - ( yMin + mHeight * mMapUnitsPerPixel ) );
114 mMatrix = QTransform::fromTranslate( cx, cy )
116 .scale( 1 / mMapUnitsPerPixel, -1 / mMapUnitsPerPixel )
117 .translate( -xCenter, -yCenter )
124 QTransform matrix = mMatrix.inverted( &invertible );
125 assert( invertible );
127 matrix.map( x, y, &mx, &my );
159 return mMapUnitsPerPixel;
170 mWidth = (( xCenter - xMin ) * 2 ) / mMapUnitsPerPixel;
183 yCenter = ymin + mHeight * mMapUnitsPerPixel / 2.0;
191 xCenter = xmin + mWidth * mMapUnitsPerPixel / 2.0;
203 xCenter = xmin + mWidth * mMapUnitsPerPixel / 2.0;
204 yCenter = ymin + mHeight * mMapUnitsPerPixel / 2.0;
221 mRotation = rotation;
222 xMin = xc - ( mWidth * mMapUnitsPerPixel / 2.0 );
223 yMin = yc - ( mHeight * mMapUnitsPerPixel / 2.0 );
230 QTextStream( &rep ) <<
"Map units/pixel: " << mMapUnitsPerPixel
231 <<
" center: " << xCenter <<
"," << yCenter
232 <<
" rotation: " << mRotation
233 <<
" size: " << mWidth <<
"x" << mHeight;
271 mMatrix.map( x, y, &mx, &my );