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

List:       kde-commits
Subject:    =?utf-8?q?=5Bmarble=5D_src/lib=3A_MarbleWidget=3A_fixt_centerOn?=
From:       Thibaut Gridel <tgridel () free ! fr>
Date:       2011-06-30 20:54:14
Message-ID: 20110630205414.9E293A60A6 () git ! kde ! org
[Download RAW message or body]

Git commit c6dc4b4320d0a563d9fecdd7a09b4a28727e6505 by Thibaut Gridel.
Committed on 30/06/2011 at 22:48.
Pushed by tgridel into branch 'master'.

MarbleWidget: fixt centerOn(GeoDataLatLonBox) so that zoom and position is done in \
one shot

M  +9    -10   src/lib/MarbleWidget.cpp     

http://commits.kde.org/marble/c6dc4b4320d0a563d9fecdd7a09b4a28727e6505

diff --git a/src/lib/MarbleWidget.cpp b/src/lib/MarbleWidget.cpp
index baebd84..d9f7273 100644
--- a/src/lib/MarbleWidget.cpp
+++ b/src/lib/MarbleWidget.cpp
@@ -622,30 +622,29 @@ void MarbleWidget::centerOn( const qreal lon, const qreal lat, \
bool animated )  void MarbleWidget::centerOn( const GeoDataCoordinates &position, \
bool animated )  {
     GeoDataLookAt target = lookAt();
-    target.setLongitude( position.longitude() );
-    target.setLatitude( position.latitude() );
+    target.setCoordinates( position );
     flyTo( target, animated ? Automatic : Instant );
 }
 
 void MarbleWidget::centerOn( const GeoDataLatLonBox &box, bool animated )
 {
+    int newRadius = radius();
     ViewportParams* viewparams = viewport();
     //prevent divide by zero
     if( box.height() && box.width() ) {
         //work out the needed zoom level
         int const horizontalRadius = ( 0.25 * M_PI ) * ( viewparams->height() / \
                box.height() );
         int const verticalRadius = ( 0.25 * M_PI ) * ( viewparams->width() / \
                box.width() );
-        int const radius = qMin<int>( horizontalRadius, verticalRadius );
-        // radius < 0 can happen if the box size approaches zero
-        setRadius( radius < 0 ? d->radius( maximumZoom() ) : radius );
+        newRadius = qMin<int>( horizontalRadius, verticalRadius );
+        newRadius = qMax<int>( d->radius( minimumZoom() ), qMin<int>( newRadius, \
d->radius( maximumZoom() ) ) );  }
 
     //move the map
-    centerOn( box.center().longitude( GeoDataCoordinates::Degree ),
-              box.center().latitude( GeoDataCoordinates::Degree ),
-              animated );
-
-    repaint();
+    GeoDataLookAt target;
+    target.setCoordinates( box.center() );
+    target.setAltitude( box.center().altitude() );
+    target.setRange(KM2METER * distanceFromRadius( newRadius ));
+    flyTo( target, animated ? Automatic : Instant );
 }
 
 void MarbleWidget::centerOn( const GeoDataPlacemark& placemark, bool animated )


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

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