20 #include <QTextStream> 
   35   , mMapUnitsPerPixel( mapUnitsPerPixel )
 
   38   , mRotation( rotation )
 
   41   , mXMin( xc - ( mWidth * mMapUnitsPerPixel / 2.0 ) )
 
   42   , mYMin( yc - ( mHeight * mMapUnitsPerPixel / 2.0 ) )
 
   50   , mMapUnitsPerPixel( mapUnitsPerPixel )
 
   61   const double metersPerPixel = 25.4 / dpi / 1000.0;
 
   71 bool QgsMapToPixel::updateMatrix()
 
   76   if ( !newMatrix.isInvertible() )
 
   87   const double oldUnits = mMapUnitsPerPixel;
 
   89   if ( !updateMatrix() )
 
   91     mMapUnitsPerPixel = oldUnits;
 
   99   const double oldRotation = mRotation;
 
  100   const double oldXCenter = mXCenter;
 
  101   const double oldYCenter = mYCenter;
 
  102   const double oldWidth = mWidth;
 
  110     mWidth = ( ( mXCenter - mXMin ) * 2 ) / mMapUnitsPerPixel;
 
  113   if ( !updateMatrix() )
 
  115     mRotation = oldRotation;
 
  116     mXCenter = oldXCenter;
 
  117     mYCenter = oldYCenter;
 
  132   const double oldMUPP = mMapUnitsPerPixel;
 
  133   const double oldXCenter = mXCenter;
 
  134   const double oldYCenter = mYCenter;
 
  135   const double oldWidth = mWidth;
 
  136   const double oldHeight = mHeight;
 
  137   const double oldRotation = mRotation;
 
  138   const double oldXMin = mXMin;
 
  139   const double oldYMin = mYMin;
 
  146   mRotation = rotation;
 
  147   mXMin = xc - ( mWidth * mMapUnitsPerPixel / 2.0 );
 
  148   mYMin = yc - ( mHeight * mMapUnitsPerPixel / 2.0 );
 
  150   if ( !updateMatrix() )
 
  152     mMapUnitsPerPixel = oldMUPP;
 
  153     mXCenter = oldXCenter;
 
  154     mYCenter = oldYCenter;
 
  157     mRotation = oldRotation;
 
  183   QTextStream( &rep ) << 
"Map units/pixel: " << mMapUnitsPerPixel
 
  184                       << 
" center: " << mXCenter << 
',' << mYCenter
 
  185                       << 
" rotation: " << mRotation
 
  186                       << 
" size: " << mWidth << 
'x' << mHeight;
 
  201     return QTransform::fromScale( 1.0 / mMapUnitsPerPixel, -1.0 / mMapUnitsPerPixel )
 
  202            .translate( -mXMin, - ( mYMin + mHeight * mMapUnitsPerPixel ) );
 
  208     return QTransform::fromTranslate( cx, cy )
 
  210            .scale( 1 / mMapUnitsPerPixel, -1 / mMapUnitsPerPixel )
 
  211            .translate( -mXCenter, -mYCenter );