Marble

StackedTile.h
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2 //
3 // SPDX-FileCopyrightText: 2007-2010 Torsten Rahn <[email protected]>
4 // SPDX-FileCopyrightText: 2007 Inge Wallin <[email protected]>
5 // SPDX-FileCopyrightText: 2010 Jens-Michael Hoffmann <[email protected]>
6 // SPDX-FileCopyrightText: 2010-2013 Bernhard Beschow <[email protected]>
7 //
8 
9 #ifndef MARBLE_STACKEDTILE_H
10 #define MARBLE_STACKEDTILE_H
11 
12 #include <QSharedPointer>
13 #include <QVector>
14 #include <QImage>
15 
16 #include "Tile.h"
17 
18 namespace Marble
19 {
20 
21 class TextureTile;
22 
23 /*!
24  \class StackedTile
25  \brief A single tile that consists of a stack of Tile layers.
26 
27  The StackedTile is a tile container that covers a certain area and is used
28  for a particular zoom level. It consists of a <b>stack of several
29  individual thematic Tiles</b> that cover the very same area and
30  are used for the very same zoom level: This stack of Tiles is
31  built up from the ground: The first Tile at the bottom usually
32  represents the ground surface. Optionally there might be a range of other
33  Tiles stacked on top which cover e.g. relief, streets and clouds.
34 
35  For rendering the whole stack of tiles gets merged and blended into a
36  single QImage. This merging/blending operation is usually only performed
37  once the stack of tiles changes visually. As a result access to the visual
38  composition of all TextureTile layers is very fast since it is reduced to
39  a single QImage that also consumes very little memory.
40 
41  The whole mechanism is comparable to layers in applications like
42  Gimp or Photoshop (TM) which can be blended on top of each other via
43  so called filters and can be merged into a single layer if required.
44 
45  Restrictions: The Tiles that are part of the stack need to be of
46  the same size and need to cover the same area at the same zoom level using
47  the very same projection.
48 */
49 
50 class StackedTile : public Tile
51 {
52  public:
53  explicit StackedTile( TileId const &id, QImage const &resultImage, QVector<QSharedPointer<TextureTile> > const &tiles );
54  ~StackedTile() override;
55 
56  void setUsed( bool used );
57  bool used() const;
58 
59  int depth() const;
60  int byteCount() const;
61 
62 /*!
63  \brief Returns the stack of Tiles
64  \return A container of Tile objects.
65 */
67 
68 /*!
69  \brief Returns the QImage that describes the merged stack of Tiles
70  \return A non-zero pointer to the resulting QImage
71 */
72  QImage const * resultImage() const;
73 
74 /*!
75  \brief Returns the color value of the result tile at the given integer position.
76  \return The uint that describes the color value of the given pixel
77 
78  Note: for gray scale images the color value of a single pixel is described
79  via a uchar (1 byte) while for RGB(A) images uint (4 bytes) are used.
80 */
81  uint pixel( int x, int y ) const;
82 
83 /*!
84  \brief Returns the color value of the result tile at a given floating point position.
85  \return The uint that describes the color value of the given pixel
86 
87  Subpixel calculation is done via bilinear interpolation.
88 
89  Note: for gray scale images the color value of a single pixel is described
90  via a uchar (1 byte) while for RGB(A) images uint (4 bytes) are used.
91 */
92  uint pixelF( qreal x, qreal y ) const;
93  // This method passes the top left pixel (if known already) for better performance
94  uint pixelF( qreal x, qreal y, const QRgb& pixel ) const;
95 
96  private:
97  Q_DISABLE_COPY( StackedTile )
98 
99  const QImage m_resultImage;
100  const int m_depth;
101  const bool m_isGrayscale;
102  const QVector<QSharedPointer<TextureTile> > m_tiles;
103  const uchar **const jumpTable8;
104  const uint **const jumpTable32;
105  const int m_byteCount;
106  bool m_isUsed;
107 
108  static int calcByteCount( const QImage &resultImage, const QVector<QSharedPointer<TextureTile> > &tiles );
109 };
110 
111 }
112 
113 #endif
QVector< QSharedPointer< TextureTile > > tiles() const
Returns the stack of Tiles.
A single tile that consists of a stack of Tile layers.
Definition: StackedTile.h:50
const QImage * resultImage() const
Returns the QImage that describes the merged stack of Tiles.
A class that resembles a tile (then it is extended to TextureTile or Vectortile).
Definition: Tile.h:42
Binds a QML item to a specific geodetic location in screen coordinates.
uint pixelF(qreal x, qreal y) const
Returns the color value of the result tile at a given floating point position.
uint pixel(int x, int y) const
Returns the color value of the result tile at the given integer position.
Definition: StackedTile.cpp:93
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Tue Sep 26 2023 03:51:18 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.