Commit 723ff6ff authored by Bernhard Beschow's avatar Bernhard Beschow
Browse files

let +/- buttons set the radius to the native map width for each tile zoom level

BUG: 199259
parent 812778c8
......@@ -354,6 +354,24 @@ void MarbleMap::setRadius( int radius )
}
int MarbleMap::preferredRadiusCeil( int radius )
{
if ( d->m_textureLayer.tileZoomLevel() < 0 )
return radius;
return d->m_textureLayer.preferredRadiusCeil( radius );
}
int MarbleMap::preferredRadiusFloor( int radius )
{
if ( d->m_textureLayer.tileZoomLevel() < 0 )
return radius;
return d->m_textureLayer.preferredRadiusFloor( radius );
}
int MarbleMap::tileZoomLevel() const
{
return d->m_textureLayer.tileZoomLevel();
......
......@@ -146,6 +146,9 @@ class MARBLE_EXPORT MarbleMap : public QObject
*/
void setRadius( int radius );
int preferredRadiusCeil( int radius );
int preferredRadiusFloor( int radius );
int tileZoomLevel() const;
/**
......
......@@ -548,12 +548,30 @@ void MarbleWidget::zoomViewBy( int zoomStep, FlyToMode mode )
void MarbleWidget::zoomIn( FlyToMode mode )
{
zoomViewBy( d->m_zoomStep, mode );
if ( d->m_map->tileZoomLevel() < 0 ) {
zoomViewBy( d->m_zoomStep, mode );
} else {
const int radius = d->m_map->preferredRadiusCeil( d->m_map->radius() + 10 ) + 2;
GeoDataLookAt target = lookAt();
target.setRange( KM2METER * distanceFromRadius( radius ) );
flyTo( target, mode );
}
}
void MarbleWidget::zoomOut( FlyToMode mode )
{
zoomViewBy( -d->m_zoomStep, mode );
if ( d->m_map->tileZoomLevel() < 0 ) {
zoomViewBy( -d->m_zoomStep, mode );
} else {
const int radius = d->m_map->preferredRadiusFloor( d->m_map->radius() - 10 ) + 2;
GeoDataLookAt target = lookAt();
target.setRange( KM2METER * distanceFromRadius( radius ) );
flyTo( target, mode );
}
}
void MarbleWidget::rotateBy( const Quaternion& incRot )
......
......@@ -8,11 +8,11 @@
// Copyright 2006-2007 Torsten Rahn <tackat@kde.org>
// Copyright 2007 Inge Wallin <ingwa@kde.org>
// Copyright 2008, 2009, 2010 Jens-Michael Hoffmann <jmho@c-xx.com>
// Copyright 2010 Bernhard Beschow <bbeschow@cs.tu-berlin.de>
//
// Copyright 2010,2011 Bernhard Beschow <bbeschow@cs.tu-berlin.de>//
#include "TextureLayer.h"
#include <QtCore/qmath.h>
#include <QtCore/QCache>
#include <QtCore/QTimer>
......@@ -296,6 +296,28 @@ qint64 TextureLayer::volatileCacheLimit() const
return d->m_tileLoader.volatileCacheLimit();
}
int TextureLayer::preferredRadiusCeil( int radius ) const
{
const int tileWidth = d->m_tileLoader.tileSize().width();
const int levelZeroColumns = d->m_tileLoader.tileColumnCount( 0 );
const qreal linearLevel = 4.0 * (qreal)( radius ) / (qreal)( tileWidth * levelZeroColumns );
const qreal tileLevelF = log( linearLevel ) / log( 2.0 );
const int tileLevel = qCeil( tileLevelF );
return tileWidth * d->m_tileLoader.tileColumnCount( tileLevel ) / 4;
}
int TextureLayer::preferredRadiusFloor( int radius ) const
{
const int tileWidth = d->m_tileLoader.tileSize().width();
const int levelZeroColumns = d->m_tileLoader.tileColumnCount( 0 );
const qreal linearLevel = 4.0 * (qreal)( radius ) / (qreal)( tileWidth * levelZeroColumns );
const qreal tileLevelF = log( linearLevel ) / log( 2.0 );
const int tileLevel = qFloor( tileLevelF );
return tileWidth * d->m_tileLoader.tileColumnCount( tileLevel ) / 4;
}
}
#include "TextureLayer.moc"
......@@ -5,7 +5,7 @@
// find a copy of this license in LICENSE.txt in the top directory of
// the source code.
//
// Copyright 2010 Bernhard Beschow <bbeschow@cs.tu-berlin.de>
// Copyright 2010,2011 Bernhard Beschow <bbeschow@cs.tu-berlin.de>
//
#ifndef MARBLE_MARBLETEXTURELAYER_H
......@@ -56,6 +56,9 @@ class TextureLayer : public QObject
qint64 volatileCacheLimit() const;
int preferredRadiusCeil( int radius ) const;
int preferredRadiusFloor( int radius ) const;
public Q_SLOTS:
void paintGlobe( GeoPainter *painter,
ViewParams *viewParams,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment