SVN commit 815031 by ingwa: Bound the top and bottom values of the rectangle M +6 -0 ChangeLog M +16 -6 src/lib/Projections/EquirectProjectionHelper.cpp --- trunk/KDE/kdeedu/marble/ChangeLog #815030:815031 @@ -1,3 +1,9 @@ +2008-06-01 Inge Wallin + + Fix issue with paintBase + * src/lib/Projections/EquirectProjectionHelper.cpp (paintBase): + Bound the top and bottom values of the rectangle. + 2008-06-01 Torsten Rahn * src/lib/TextureTile.cpp: --- trunk/KDE/kdeedu/marble/src/lib/Projections/EquirectProjectionHelper.cpp #815030:815031 @@ -34,10 +34,13 @@ QBrush &brush, bool antialiasing ) { + // Convenience variables int radius = viewport->radius(); + int width = viewport->width(); + int height = viewport->height(); + // Igor, prepare the painter! painter->setRenderHint( QPainter::Antialiasing, antialiasing ); - painter->setPen( pen ); painter->setBrush( brush ); @@ -46,11 +49,18 @@ double centerLat; viewport->centerCoordinates( centerLon, centerLat ); - // yCenterOffset is the number of pixels that the - int yCenterOffset = (int)( centerLat * (double)( 2 * radius ) / M_PI ); - int yTop = viewport->height() / 2 - radius + yCenterOffset; + int yCenterOffset = (int)(centerLat * (double)( 2 * radius ) / M_PI ); + int yTop = height / 2 - radius + yCenterOffset; + int yBottom = yTop + 2 * radius; - painter->drawRect( 0, yTop, viewport->width(), 2 * radius); + // Don't let the active area be outside the image, and also let a + // thin strip 25 pixels wide be outside it. + if ( yTop < 0 ) + yTop = 0; + if ( yBottom > height ) + yBottom = height; + + painter->drawRect( 0, yTop, width, yBottom - yTop ); } @@ -66,7 +76,7 @@ double centerLat; viewport->centerCoordinates( centerLon, centerLat ); - int yCenterOffset = (int)((double)( 2 * radius ) / M_PI * centerLat); + int yCenterOffset = (int)( centerLat * (double)( 2 * radius ) / M_PI ); int yTop = height / 2 - radius + yCenterOffset; int yBottom = yTop + 2 * radius;