File indexing completed on 2024-04-28 03:49:23

0001 // SPDX-License-Identifier: LGPL-2.1-or-later
0002 //
0003 // SPDX-FileCopyrightText: 2010, 2011 Bernhard Beschow <bbeschow@cs.tu-berlin.de>
0004 //
0005 
0006 #ifndef MARBLE_MARBLETEXTURELAYER_H
0007 #define MARBLE_MARBLETEXTURELAYER_H
0008 
0009 #include "TileLayer.h"
0010 
0011 #include "MarbleGlobal.h"
0012 
0013 class QAbstractItemModel;
0014 class QImage;
0015 class QSize;
0016 
0017 namespace Marble
0018 {
0019 
0020 class GeoPainter;
0021 class GeoDataDocument;
0022 class GeoSceneGroup;
0023 class GeoSceneAbstractTileProjection;
0024 class GeoSceneTextureTileDataset;
0025 class HttpDownloadManager;
0026 class SunLocator;
0027 class TileId;
0028 class ViewportParams;
0029 class PluginManager;
0030 
0031 class MARBLE_EXPORT TextureLayer : public TileLayer
0032 {
0033     Q_OBJECT
0034 
0035  public:
0036     TextureLayer( HttpDownloadManager *downloadManager,
0037                   PluginManager* pluginManager,
0038                   const SunLocator *sunLocator,
0039                   QAbstractItemModel *groundOverlayModel );
0040 
0041     ~TextureLayer() override;
0042 
0043     void addSeaDocument( const GeoDataDocument *seaDocument );
0044 
0045     void addLandDocument( const GeoDataDocument *landDocument );
0046 
0047     int layerCount() const;
0048 
0049     /**
0050      * @brief Adds texture sublayer, taking ownership of the object's memory
0051      *        Does nothing if a texture with the same source directory was already
0052      *        added with this method.
0053      * @return returned string is the key for the texture that can be later used to remove it
0054      */
0055     QString addTextureLayer(GeoSceneTextureTileDataset *texture);
0056 
0057     /**
0058      * @brief Removes texture sublayer identified by a key.
0059      *        Deletes the texture object. Does nothing if key is not found.
0060      * @param A key to identify the texture, returned from addTextureLayer
0061      */
0062     void removeTextureLayer(const QString &key);
0063 
0064     bool showSunShading() const;
0065     bool showCityLights() const;
0066 
0067     /**
0068      * @brief Return the current tile zoom level. For example for OpenStreetMap
0069      *        possible values are 1..18, for BlueMarble 0..6.
0070      */
0071     int tileZoomLevel() const;
0072 
0073     QSize tileSize() const;
0074 
0075     const GeoSceneAbstractTileProjection *tileProjection() const;
0076 
0077     int tileColumnCount( int level ) const;
0078     int tileRowCount( int level ) const;
0079 
0080     quint64 volatileCacheLimit() const;
0081 
0082     int preferredRadiusCeil( int radius ) const;
0083     int preferredRadiusFloor( int radius ) const;
0084 
0085     RenderState renderState() const override;
0086 
0087     QString runtimeTrace() const override;
0088 
0089     bool render( GeoPainter *painter, ViewportParams *viewport,
0090                          const QString &renderPos = QLatin1String("NONE"),
0091                          GeoSceneLayer *layer = nullptr ) override;
0092 
0093 public Q_SLOTS:
0094     void setShowRelief( bool show );
0095 
0096     void setShowSunShading( bool show );
0097 
0098     void setShowCityLights( bool show );
0099 
0100     void setShowTileId( bool show );
0101 
0102     /**
0103      * @brief  Set the Projection used for the map
0104      * @param  projection projection type (e.g. Spherical, Equirectangular, Mercator)
0105      */
0106     void setProjection( Projection projection );
0107 
0108     void setNeedsUpdate();
0109 
0110     void setMapTheme( const QVector<const GeoSceneTextureTileDataset *> &textures, const GeoSceneGroup *textureLayerSettings, const QString &seaFile, const QString &landFile );
0111 
0112     void setVolatileCacheLimit( quint64 kilobytes );
0113 
0114     void reset();
0115 
0116     void reload();
0117 
0118     void downloadStackedTile( const TileId &stackedTileId );
0119 
0120  Q_SIGNALS:
0121     void tileLevelChanged( int );
0122     void repaintNeeded();
0123 
0124  private:
0125     Q_PRIVATE_SLOT( d, void requestDelayedRepaint() )
0126     Q_PRIVATE_SLOT( d, void updateTextureLayers() )
0127     Q_PRIVATE_SLOT( d, void updateTile( const TileId &tileId, const QImage &tileImage ) )
0128     Q_PRIVATE_SLOT( d, void addGroundOverlays( const QModelIndex& parent, int first, int last ) )
0129     Q_PRIVATE_SLOT( d, void removeGroundOverlays( const QModelIndex& parent, int first, int last ) )
0130     Q_PRIVATE_SLOT( d, void resetGroundOverlaysCache() )
0131 
0132  private:
0133     class Private;
0134     Private *const d;
0135 };
0136 
0137 }
0138 
0139 #endif