Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Education
Marble
Commits
723ff6ff
Commit
723ff6ff
authored
May 12, 2011
by
Bernhard Beschow
Browse files
let +/- buttons set the radius to the native map width for each tile zoom level
BUG: 199259
parent
812778c8
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/lib/MarbleMap.cpp
View file @
723ff6ff
...
...
@@ -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
();
...
...
src/lib/MarbleMap.h
View file @
723ff6ff
...
...
@@ -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
;
/**
...
...
src/lib/MarbleWidget.cpp
View file @
723ff6ff
...
...
@@ -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
)
...
...
src/lib/TextureLayer.cpp
View file @
723ff6ff
...
...
@@ -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"
src/lib/TextureLayer.h
View file @
723ff6ff
...
...
@@ -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
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment