3 #include "TileCoordsPyramid.h"
7 #include <MarbleDebug.h>
14 class Q_DECL_HIDDEN TileCoordsPyramid::Private
17 Private(
int const topLevel,
int const bottomLevel );
21 QRect m_bottomLevelCoords;
25 TileCoordsPyramid::Private::Private(
int const topLevel,
int const bottomLevel )
26 : m_topLevel( topLevel ),
27 m_bottomLevel( bottomLevel )
29 Q_ASSERT( m_topLevel <= m_bottomLevel );
33 TileCoordsPyramid::TileCoordsPyramid(
int const topLevel,
int const bottomLevel )
34 : d( new Private( topLevel, bottomLevel ))
38 TileCoordsPyramid::TileCoordsPyramid( TileCoordsPyramid
const & other )
39 : d( new Private( *other.d ))
43 TileCoordsPyramid::TileCoordsPyramid()
44 :d( new Private( 0, 0 ) )
49 TileCoordsPyramid & TileCoordsPyramid::operator=( TileCoordsPyramid
const & rhs )
51 TileCoordsPyramid temp( rhs );
56 TileCoordsPyramid::~TileCoordsPyramid()
61 int TileCoordsPyramid::topLevel()
const
66 int TileCoordsPyramid::bottomLevel()
const
68 return d->m_bottomLevel;
71 void TileCoordsPyramid::setBottomLevelCoords(
QRect const & coords )
73 d->m_bottomLevelCoords = coords;
76 QRect TileCoordsPyramid::coords(
int const level )
const
78 Q_ASSERT( d->m_topLevel <= level && level <= d->m_bottomLevel );
79 int bottomX1, bottomY1, bottomX2, bottomY2;
80 d->m_bottomLevelCoords.getCoords( &bottomX1, &bottomY1, &bottomX2, &bottomY2 );
81 int const deltaLevel = d->m_bottomLevel -
level;
82 int const x1 = bottomX1 >> deltaLevel;
83 int const y1 = bottomY1 >> deltaLevel;
84 int const x2 = bottomX2 >> deltaLevel;
85 int const y2 = bottomY2 >> deltaLevel;
91 void TileCoordsPyramid::setValidTileLevels(
const QVector<int> validLevels)
93 d->m_validLevels = validLevels;
98 return d->m_validLevels;
101 qint64 TileCoordsPyramid::tilesCount()
const
104 for (
int level = d->m_topLevel; level <= d->m_bottomLevel; ++level ) {
105 if (!d->m_validLevels.isEmpty() && !d->m_validLevels.contains(level))
continue;
107 QRect const levelCoords = coords( level );
109 result += qint64( levelCoords.
width() ) * levelCoords.
height();
114 void TileCoordsPyramid::swap( TileCoordsPyramid & other )
116 std::swap( d, other.d );