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

List:       kde-commits
Subject:    branches/extragear/graphics
From:       Michael Georg Hansen <mike () mghansen ! de>
Date:       2010-09-11 19:57:43
Message-ID: 20100911200212.DB550AC888 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1174285 by mghansen:

Add a function to KMap to adjust the viewport to show all markers and use this \
function in the GPS properties tab in Digikam.



 M  +3 -3      digikam/libs/imageproperties/imagepropertiesgpstab.cpp  
 M  +4 -1      libkmap/data/backend-googlemaps-js.js  
 M  +3 -2      libkmap/libkmap/backend-googlemaps.cpp  
 M  +1 -1      libkmap/libkmap/backend-googlemaps.h  
 M  +23 -1     libkmap/libkmap/backend-marble.cpp  
 M  +1 -1      libkmap/libkmap/backend-marble.h  
 M  +2 -2      libkmap/libkmap/html_widget.cpp  
 M  +1 -1      libkmap/libkmap/html_widget.h  
 M  +38 -0     libkmap/libkmap/kmap_widget.cpp  
 M  +2 -0      libkmap/libkmap/kmap_widget.h  
 M  +1 -1      libkmap/libkmap/map-backend.h  


--- branches/extragear/graphics/digikam/libs/imageproperties/imagepropertiesgpstab.cpp \
#1174284:1174285 @@ -392,9 +392,9 @@
 
     if (!d->map->getStickyModeState())
     {
-        // TODO: adjust the zoom and map boundaries to show all images
-        const GPSInfo firstInfo = d->gpsInfoList.first();
-        d->map->setCenter(KMap::GeoCoordinates(firstInfo.latitude, \
firstInfo.longitude)); +        // TODO: check whether the widget is currently \
active, +        //       otherwise remember to call this function later!
+        d->map->adjustBoundariesToGroupedMarkers();
     }
 }
 
--- branches/extragear/graphics/libkmap/data/backend-googlemaps-js.js \
#1174284:1174285 @@ -511,7 +511,7 @@
 
 }
 
-function setMapBoundaries(west, north, east, south){
+function setMapBoundaries(west, north, east, south, useSaneZoomLevel){
 
     firstPoint = new google.maps.LatLng(south, west, true);
     secondPoint = new google.maps.LatLng(north, east, true);
@@ -519,7 +519,10 @@
     newBounds = new google.maps.LatLngBounds(firstPoint, secondPoint);
     map.fitBounds(newBounds);
 
+    if (useSaneZoomLevel && (map.getZoom()>17)) {
+        map.setZoom(17);
 }
+}
 
 
 function initialize() {
--- branches/extragear/graphics/libkmap/libkmap/backend-googlemaps.cpp \
#1174284:1174285 @@ -1007,14 +1007,15 @@
 {
 }
 
-void BackendGoogleMaps::centerOn( const Marble::GeoDataLatLonBox& latLonBox)
+void BackendGoogleMaps::centerOn( const Marble::GeoDataLatLonBox& latLonBox, const \
bool useSaneZoomLevel)  {
     const qreal boxWest  = latLonBox.west(Marble::GeoDataCoordinates::Degree);
     const qreal boxNorth = latLonBox.north(Marble::GeoDataCoordinates::Degree);
     const qreal boxEast  = latLonBox.east(Marble::GeoDataCoordinates::Degree);
     const qreal boxSouth = latLonBox.south(Marble::GeoDataCoordinates::Degree);
 
-    d->htmlWidget->centerOn(boxWest, boxNorth, boxEast, boxSouth);
+    d->htmlWidget->centerOn(boxWest, boxNorth, boxEast, boxSouth, useSaneZoomLevel);
+    kDebug()<<getZoom();
 }
 
 void BackendGoogleMaps::setActive(const bool state)
--- branches/extragear/graphics/libkmap/libkmap/backend-googlemaps.h #1174284:1174285
@@ -96,7 +96,7 @@
     virtual void mouseModeChanged(const MouseModes mouseMode);
 
     virtual void setSelectionStatus(const bool status);
-    virtual void centerOn(const Marble::GeoDataLatLonBox& latLonBox);
+    virtual void centerOn(const Marble::GeoDataLatLonBox& latLonBox, const bool \
useSaneZoomLevel);  virtual void setActive(const bool state);
 
 public Q_SLOTS:
--- branches/extragear/graphics/libkmap/libkmap/backend-marble.cpp #1174284:1174285
@@ -363,6 +363,13 @@
     setShowCompass(d->cacheShowCompass);
     setShowOverviewMap(d->cacheShowOverviewMap);
 
+    // make sure the zoom level is okay
+    if ( (d->marbleWidget->zoom()>d->marbleWidget->maximumZoom()) ||
+         (d->marbleWidget->zoom()<d->marbleWidget->minimumZoom()) )
+    {
+        d->marbleWidget->zoomView(d->marbleWidget->maximumZoom());
+    }
+
     updateActionAvailability();
 }
 
@@ -1395,11 +1402,26 @@
 {
 }
 
-void BackendMarble::centerOn(const Marble::GeoDataLatLonBox& box)
+void BackendMarble::centerOn(const Marble::GeoDataLatLonBox& box, const bool \
useSaneZoomLevel)  {
+    Q_UNUSED(useSaneZoomLevel)
+
     d->marbleWidget->centerOn(box, false);
 
+    // simple check to see whether the zoom level is now too high
+    // TODO: for very small boxes, Marbles zoom becomes -2billion. Catch this case \
here. +    // TODO: determine a more sane zoom level to stop at and handle the \
useSaneZoomLevel parameter +    int maxZoomLevel = d->marbleWidget->maximumZoom();
+    if (useSaneZoomLevel)
+    {
+        maxZoomLevel = qMin(maxZoomLevel, 3400);
 }
+    if ( (d->marbleWidget->zoom()>maxZoomLevel) ||
+         (d->marbleWidget->zoom()<d->marbleWidget->minimumZoom()) )
+    {
+        d->marbleWidget->zoomView(maxZoomLevel);
+    }
+}
 
 void BackendMarble::setActive(const bool state)
 {
--- branches/extragear/graphics/libkmap/libkmap/backend-marble.h #1174284:1174285
@@ -108,7 +108,7 @@
     virtual void mouseModeChanged(const MouseModes mouseMode);
 
     virtual void setSelectionStatus(const bool status);
-    virtual void centerOn(const Marble::GeoDataLatLonBox& box); 
+    virtual void centerOn(const Marble::GeoDataLatLonBox& box, const bool \
useSaneZoomLevel);   virtual void setActive(const bool state);
 
 public Q_SLOTS:
--- branches/extragear/graphics/libkmap/libkmap/html_widget.cpp #1174284:1174285
@@ -357,10 +357,10 @@
     }
 }
 
-void HTMLWidget::centerOn(const qreal west, const qreal north, const qreal east, \
const qreal south) +void HTMLWidget::centerOn(const qreal west, const qreal north, \
const qreal east, const qreal south, const bool useSaneZoomLevel)  {
 //    kDebug()<<"West:"<<west<<" North:"<<north<<" East:"<<east<<" South:"<<south;
-    runScript(QString("setMapBoundaries(%1, %2, %3, \
%4);").arg(west).arg(north).arg(east).arg(south)); +    \
runScript(QString("setMapBoundaries(%1, %2, %3, %4, \
%5);").arg(west).arg(north).arg(east).arg(south).arg(useSaneZoomLevel?1:0));  }
 
 } /* namespace KMap */
--- branches/extragear/graphics/libkmap/libkmap/html_widget.h #1174284:1174285
@@ -55,7 +55,7 @@
     void mouseModeChanged(const MouseModes mouseMode);
     void setSelectionRectangle(const GeoCoordinates::Pair& searchCoordinates);
     GeoCoordinates::Pair getSelectionRectangle();
-    void centerOn(const qreal west, const qreal north, const qreal east, const qreal \
south); +    void centerOn(const qreal west, const qreal north, const qreal east, \
const qreal south, const bool useSaneZoomLevel = true);  void \
removeSelectionRectangle();  
 protected:
--- branches/extragear/graphics/libkmap/libkmap/kmap_widget.cpp #1174284:1174285
@@ -2320,5 +2320,43 @@
     slotRequestLazyReclustering();
 }
 
+/**
+ * @brief Adjusts the visible map area such that all grouped markers are visible.
+ *
+ * Note that a call to this function currently has no effect if the widget has been
+ * set inactive via setActive() or the backend is not yet ready.
+ *
+ * @param useSaneZoomLevel Stop zooming at a sane level, if markers are too close \
together. + */
+void KMapWidget::adjustBoundariesToGroupedMarkers(const bool useSaneZoomLevel)
+{
+    if ( (!d->activeState) || (!s->markerModel) || (!d->currentBackend) )
+        return;
+
+    Marble::GeoDataLineString tileString;
+
+    // TODO: not sure that this is the best way to find the bounding box of all \
items +    for (AbstractMarkerTiler::NonEmptyIterator tileIterator(s->markerModel, \
AbstractMarkerTiler::TileIndex::MaxLevel); !tileIterator.atEnd(); \
tileIterator.nextIndex()) +    {
+        const AbstractMarkerTiler::TileIndex tileIndex = \
tileIterator.currentIndex(); +        for(int corner=1; corner<=4; corner++)
+        {
+            GeoCoordinates currentTileCoordinate = tileIndex.toCoordinates();
+
+            const Marble::GeoDataCoordinates \
tileCoordinate(currentTileCoordinate.lon(), +                                         \
currentTileCoordinate.lat(), +                                                        \
0, +                                                            \
Marble::GeoDataCoordinates::Degree); +
+            tileString.append(tileCoordinate);
+        }
+    }
+
+    Marble::GeoDataLatLonBox latLonBox = \
Marble::GeoDataLatLonBox::fromLineString(tileString); +
+    // TODO: use a sane zoom level
+    d->currentBackend->centerOn(latLonBox, useSaneZoomLevel);
+}
+
 } /* namespace KMap */
 
--- branches/extragear/graphics/libkmap/libkmap/kmap_widget.h #1174284:1174285
@@ -100,6 +100,8 @@
 
     void setZoom(const QString& newZoom);
     QString getZoom();
+
+    void adjustBoundariesToGroupedMarkers(const bool useSaneZoomLevel = true);
     //@}
 
     /// @name Appearance
--- branches/extragear/graphics/libkmap/libkmap/map-backend.h #1174284:1174285
@@ -117,7 +117,7 @@
 
     virtual void setSelectionStatus(const bool status) = 0;
     //virtual bool getSelectionStatus(
-    virtual void centerOn(const Marble::GeoDataLatLonBox& box) = 0;
+    virtual void centerOn(const Marble::GeoDataLatLonBox& box, const bool \
useSaneZoomLevel = true) = 0;  virtual void setActive(const bool state) = 0;
 
 public Q_SLOTS:


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

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