[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdeedu/marble
From:       Inge Wallin <inge () lysator ! liu ! se>
Date:       2008-05-31 23:11:04
Message-ID: 1212275464.582174.21781.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 815022 by ingwa:

Fix some issues with the active area in the image.


 M  +9 -0      ChangeLog  
 M  +14 -2     src/lib/Projections/EquirectProjectionHelper.cpp  
 M  +11 -10    src/lib/Projections/SphericalProjectionHelper.cpp  


--- trunk/KDE/kdeedu/marble/ChangeLog #815021:815022
@@ -1,3 +1,12 @@
+2008-06-01  Inge Wallin  <inge@lysator.liu.se>
+
+	Fix some issues with the active area in the image.
+	* src/lib/Projections/EquirectProjectionHelper.cpp (setActiveRegion):
+	Bound the active area to the viewport.
+
+	* src/lib/Projections/SphericalProjectionHelper.cpp (setActiveRegion):
+	Comment the code better and use mapCoversViewport()
+
 2008-05-31  Jens-Michael Hoffmann  <jensmh@gmx.de>
 
     * src/lib/kml
--- trunk/KDE/kdeedu/marble/src/lib/Projections/EquirectProjectionHelper.cpp #815021:815022
@@ -46,6 +46,7 @@
     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;
 
@@ -55,7 +56,10 @@
 
 void EquirectProjectionHelper::setActiveRegion( ViewportParams *viewport )
 {
+    // Convenience variables
     int  radius = viewport->radius();
+    int  width  = viewport->width();
+    int  height = viewport->height();
 
     // Calculate translation of center point
     double  centerLon;
@@ -63,7 +67,15 @@
     viewport->centerCoordinates( centerLon, centerLat );
 
     int yCenterOffset = (int)((double)( 2 * radius ) / M_PI * centerLat);
-    int yTop          = viewport->height() / 2 - radius + yCenterOffset;
-    d->activeRegion = QRegion( 0, yTop, viewport->width(), 2 * radius,
+    int yTop          = height / 2 - radius + yCenterOffset;
+    int yBottom       = yTop + 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 < 25 )
+	yTop = 25;
+    if ( yBottom > height - 25 )
+	yBottom =  height - 25;
+    d->activeRegion = QRegion( 25, yTop, width - 50, yBottom - yTop,
 			       QRegion::Rectangle );
 }
--- trunk/KDE/kdeedu/marble/src/lib/Projections/SphericalProjectionHelper.cpp #815021:815022
@@ -34,8 +34,8 @@
 					   QBrush         &brush,
 					   bool            antialiasing )
 {
-    int      imgrx = viewport->width() / 2;
-    int      imgry = viewport->height() / 2;
+    int      imgrx      = viewport->width() / 2;
+    int      imgry      = viewport->height() / 2;
     int      radius     = viewport->radius();
     quint64  imgradius2 = ( (quint64)imgrx * (quint64)imgrx
 			    + (quint64)imgry * (quint64)imgry );
@@ -45,7 +45,7 @@
     painter->setPen( pen );
     painter->setBrush( brush );
 
-    if ( imgradius2 < (double)radius * (double)radius ) {
+    if ( imgradius2 < (quint64)radius * (quint64)radius ) {
         painter->drawRect( 0, 0, 
 			   viewport->width() - 1, viewport->height() - 1 );
     }
@@ -62,16 +62,17 @@
     int  imgWidth  = viewport->width();
     int  imgHeight = viewport->height();
 
-    // FIXME: Use mapCoversArea()
-    // Use sqrt() here as setActiveRegion doesn't get called often anyways.
-    if ( radius < sqrt( (double)( imgWidth * imgWidth + imgHeight * imgHeight ) ) / 2 ) {
+    // If the globe covers the whole image, then the active region is
+    // all of the image except a strip 25 pixels wide in all
+    // directions.  Otherwise the active region is the globe.
+    if ( viewport->mapCoversViewport() ) {
+    	d->activeRegion = QRegion( 25, 25, imgWidth - 50, imgHeight - 50,
+				   QRegion::Rectangle );
+    }
+    else {
     	d->activeRegion = QRegion( imgWidth  / 2 - radius,
 				   imgHeight / 2 - radius,
 				   2 * radius, 2 * radius,
 				   QRegion::Ellipse );
     }
-    else {
-    	d->activeRegion = QRegion( 25, 25, imgWidth - 50, imgHeight - 50,
-				   QRegion::Rectangle );
-    }
 }
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic