• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

marble

  • sources
  • kde-4.14
  • kdeedu
  • marble
  • src
  • lib
  • marble
TileCoordsPyramid.cpp
Go to the documentation of this file.
1 // This library is free software; you can redistribute it and/or
2 // modify it under the terms of the GNU Lesser General Public
3 // License as published by the Free Software Foundation; either
4 // version 2.1 of the License, or (at your option) any later version.
5 //
6 // This library is distributed in the hope that it will be useful,
7 // but WITHOUT ANY WARRANTY; without even the implied warranty of
8 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9 // Lesser General Public License for more details.
10 //
11 // You should have received a copy of the GNU Lesser General Public
12 // License along with this library. If not, see <http://www.gnu.org/licenses/>.
13 
14 #include "TileCoordsPyramid.h"
15 
16 #include <algorithm>
17 
18 namespace Marble
19 {
20 
21 class TileCoordsPyramid::Private
22 {
23 public:
24  Private( int const topLevel, int const bottomLevel );
25 
26  int m_topLevel;
27  int m_bottomLevel;
28  QRect m_bottomLevelCoords;
29 };
30 
31 TileCoordsPyramid::Private::Private( int const topLevel, int const bottomLevel )
32  : m_topLevel( topLevel ),
33  m_bottomLevel( bottomLevel )
34 {
35  Q_ASSERT( m_topLevel <= m_bottomLevel );
36 }
37 
38 
39 TileCoordsPyramid::TileCoordsPyramid( int const topLevel, int const bottomLevel )
40  : d( new Private( topLevel, bottomLevel ))
41 {
42 }
43 
44 TileCoordsPyramid::TileCoordsPyramid( TileCoordsPyramid const & other )
45  : d( new Private( *other.d ))
46 {
47 }
48 
49 TileCoordsPyramid::TileCoordsPyramid()
50  :d( new Private( 0, 0 ) )
51 {
52 
53 }
54 
55 TileCoordsPyramid & TileCoordsPyramid::operator=( TileCoordsPyramid const & rhs )
56 {
57  TileCoordsPyramid temp( rhs );
58  swap( temp );
59  return *this;
60 }
61 
62 TileCoordsPyramid::~TileCoordsPyramid()
63 {
64  delete d;
65 }
66 
67 int TileCoordsPyramid::topLevel() const
68 {
69  return d->m_topLevel;
70 }
71 
72 int TileCoordsPyramid::bottomLevel() const
73 {
74  return d->m_bottomLevel;
75 }
76 
77 void TileCoordsPyramid::setBottomLevelCoords( QRect const & coords )
78 {
79  d->m_bottomLevelCoords = coords;
80 }
81 
82 QRect TileCoordsPyramid::coords( int const level ) const
83 {
84  Q_ASSERT( d->m_topLevel <= level && level <= d->m_bottomLevel );
85  int bottomX1, bottomY1, bottomX2, bottomY2;
86  d->m_bottomLevelCoords.getCoords( &bottomX1, &bottomY1, &bottomX2, &bottomY2 );
87  int const deltaLevel = d->m_bottomLevel - level;
88  int const x1 = bottomX1 >> deltaLevel;
89  int const y1 = bottomY1 >> deltaLevel;
90  int const x2 = bottomX2 >> deltaLevel;
91  int const y2 = bottomY2 >> deltaLevel;
92  QRect result;
93  result.setCoords( x1, y1, x2, y2 );
94  return result;
95 }
96 
97 qint64 TileCoordsPyramid::tilesCount() const
98 {
99  qint64 result = 0;
100  for ( int level = d->m_topLevel; level <= d->m_bottomLevel; ++level ) {
101  QRect const levelCoords = coords( level );
102  result += levelCoords.width() * levelCoords.height();
103  }
104  return result;
105 }
106 
107 void TileCoordsPyramid::swap( TileCoordsPyramid & other )
108 {
109  std::swap( d, other.d );
110 }
111 
112 }
TileCoordsPyramid.h
Marble::TileCoordsPyramid::operator=
TileCoordsPyramid & operator=(TileCoordsPyramid const &rhs)
Definition: TileCoordsPyramid.cpp:55
Marble::TileCoordsPyramid::coords
QRect coords(int const level) const
Definition: TileCoordsPyramid.cpp:82
QRect::height
int height() const
Marble::TileCoordsPyramid::bottomLevel
int bottomLevel() const
Definition: TileCoordsPyramid.cpp:72
QRect
Marble::TileCoordsPyramid
Definition: TileCoordsPyramid.h:23
QRect::setCoords
void setCoords(int x1, int y1, int x2, int y2)
Marble::TileCoordsPyramid::tilesCount
qint64 tilesCount() const
returns the number of tiles covered by one pyramid
Definition: TileCoordsPyramid.cpp:97
Marble::TileCoordsPyramid::~TileCoordsPyramid
~TileCoordsPyramid()
Definition: TileCoordsPyramid.cpp:62
QRect::width
int width() const
Marble::TileCoordsPyramid::topLevel
int topLevel() const
Definition: TileCoordsPyramid.cpp:67
Marble::TileCoordsPyramid::setBottomLevelCoords
void setBottomLevelCoords(QRect const &coords)
Definition: TileCoordsPyramid.cpp:77
Marble::TileCoordsPyramid::TileCoordsPyramid
TileCoordsPyramid()
Definition: TileCoordsPyramid.cpp:49
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:13:42 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

marble

Skip menu "marble"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal