File indexing completed on 2024-04-14 03:48:08

0001 // SPDX-License-Identifier: LGPL-2.1-or-later
0002 //
0003 // SPDX-FileCopyrightText: 2004-2007 Torsten Rahn <tackat@kde.org>
0004 // SPDX-FileCopyrightText: 2007-2008 Inge Wallin <ingwa@kde.org>
0005 //
0006 
0007 #ifndef MARBLE_TILECREATOR_H
0008 #define MARBLE_TILECREATOR_H
0009 
0010 #include <QString>
0011 #include <QThread>
0012 
0013 #include "marble_export.h"
0014 
0015 class QSize;
0016 class QImage;
0017 
0018 namespace Marble
0019 {
0020 
0021 class TileCreatorPrivate;
0022 
0023 /**
0024  * Base Class for custom tile source
0025  *
0026  * Implement this class to have more control over the tile creating process. This
0027  * is needed when creating with a high tileLevel where the whole source image can't
0028  * be loaded at once.
0029  **/
0030 class MARBLE_EXPORT TileCreatorSource
0031 {
0032 public:
0033     virtual ~TileCreatorSource() {}
0034 
0035     /**
0036      * Must return the full size of the source image
0037      */
0038     virtual QSize fullImageSize() const = 0;
0039 
0040     /**
0041      * Must return one specific tile
0042      *
0043      * tileLevel can be used to calculate the number of tiles in a row or column
0044      */
0045     virtual QImage tile( int n, int m, int tileLevel ) = 0;
0046 };
0047 
0048 class MARBLE_EXPORT TileCreator : public QThread
0049 {
0050     Q_OBJECT
0051 
0052  public:
0053     /**
0054      * Constructor for standard Image source
0055      */
0056     TileCreator( const QString& sourceDir, const QString& installMap, 
0057                  const QString& dem,       const QString& targetDir=QString() );
0058 
0059     /**
0060      * Constructor for own, custom source class
0061      *
0062      * Ownership of source is taken by TileCreator
0063      */
0064     TileCreator( TileCreatorSource *source, const QString& dem, const QString& targetDir );
0065 
0066     ~TileCreator() override;
0067 
0068     void cancelTileCreation();
0069 
0070     void setTileFormat( const QString &format );
0071     void setTileQuality( int quality );
0072     void setResume( bool resume );
0073     void setVerifyExactResult( bool verify );
0074     QString tileFormat() const;
0075     int tileQuality() const;
0076     bool resume() const;
0077     bool verifyExactResult() const;
0078 
0079  protected:
0080     void run() override;
0081 
0082  Q_SIGNALS:
0083     void  progress( int value );
0084 
0085 
0086  private:
0087     Q_DISABLE_COPY( TileCreator )
0088     TileCreatorPrivate  * const d;
0089 };
0090 
0091 }
0092 
0093 #endif