[Marble-commits] KDE/kdeedu/marble/src
Bernhard Beschow
bbeschow at cs.tu-berlin.de
Sat Jul 10 10:34:27 CEST 2010
SVN commit 1148312 by beschow:
move tileSize() to GeoSceneTexture
M +1 -26 lib/AbstractScanlineTextureMapper.cpp
M +2 -10 lib/AbstractScanlineTextureMapper.h
M +4 -4 lib/DownloadRegionDialog.cpp
M +19 -0 lib/geodata/scene/GeoSceneTexture.cpp
M +4 -0 lib/geodata/scene/GeoSceneTexture.h
M +1 -0 tilecreator/CMakeLists.txt
--- trunk/KDE/kdeedu/marble/src/lib/AbstractScanlineTextureMapper.cpp #1148311:1148312
@@ -39,6 +39,7 @@
m_tilePosX( 0 ),
m_tilePosY( 0 ),
m_textureLayer( textureLayer ),
+ m_tileSize( textureLayer->tileSize() ), // cache tile size
m_tile( 0 ),
m_previousRadius( 0 ),
m_n( 0 ),
@@ -59,7 +60,6 @@
this, SLOT( notifyMapChanged() ) );
detectMaxTileLevel();
- initTileSize();
}
@@ -69,17 +69,6 @@
}
-void AbstractScanlineTextureMapper::setLayer( GeoSceneLayer * layer )
-{
- m_textureLayer = static_cast<GeoSceneTexture *>( layer->groundDataset() );
- m_tileProjection = m_textureLayer->projection();
- m_mapThemeIdHash = qHash( m_textureLayer->sourceDir() );
- m_tileLevel = -1;
- detectMaxTileLevel();
- initTileSize();
-}
-
-
void AbstractScanlineTextureMapper::selectTileLevel( ViewParams* viewParams )
{
const int radius = viewParams->radius();
@@ -608,18 +597,4 @@
* TileLoaderHelper::levelToRow( m_textureLayer->levelZeroRows(), m_tileLevel );
}
-void AbstractScanlineTextureMapper::initTileSize()
-{
- if ( !m_textureLayer || !m_tileLoader )
- return;
-
- Q_ASSERT( m_textureLayer );
- Q_ASSERT( m_tileLoader );
- TileId id( m_textureLayer->sourceDir(), 0, 0, 0 );
- StackedTile * const testTile = m_tileLoader->loadTile( id, DownloadBrowse );
- Q_ASSERT( testTile );
- m_tileSize = testTile->resultTile()->size();
- Q_ASSERT( !m_tileSize.isEmpty() );
-}
-
#include "AbstractScanlineTextureMapper.moc"
--- trunk/KDE/kdeedu/marble/src/lib/AbstractScanlineTextureMapper.h #1148311:1148312
@@ -41,14 +41,12 @@
virtual void mapTexture( ViewParams *viewParams ) = 0;
- void setLayer( GeoSceneLayer * layer );
void setMaxTileLevel( int level );
virtual void resizeMap( int width, int height );
void selectTileLevel( ViewParams* viewParams );
bool interlaced() const;
void setInterlaced( bool enabled );
int tileZoomLevel() const;
- QSize tileSize() const;
GeoSceneTexture const * textureLayer() const;
Q_SIGNALS:
@@ -131,11 +129,10 @@
Q_DISABLE_COPY( AbstractScanlineTextureMapper )
void initGlobalWidth();
void initGlobalHeight();
- void initTileSize();
- GeoSceneTexture *m_textureLayer;
+ GeoSceneTexture const * const m_textureLayer;
/// size of the tiles of of the current texture layer
- QSize m_tileSize;
+ QSize const m_tileSize;
GeoSceneTexture::Projection m_tileProjection;
StackedTile *m_tile;
int m_previousRadius;
@@ -168,11 +165,6 @@
m_interlaced = enabled;
}
-inline QSize AbstractScanlineTextureMapper::tileSize() const
-{
- return m_tileSize;
-}
-
inline GeoSceneTexture const * AbstractScanlineTextureMapper::textureLayer() const
{
return m_textureLayer;
--- trunk/KDE/kdeedu/marble/src/lib/DownloadRegionDialog.cpp #1148311:1148312
@@ -139,7 +139,7 @@
// copied from AbstractScanlineTextureMapper and slightly adjusted
int DownloadRegionDialog::Private::rad2PixelX( qreal const lon ) const
{
- qreal const globalWidth = textureMapper()->tileSize().width()
+ qreal const globalWidth = m_textureLayer->tileSize().width()
* TileLoaderHelper::levelToColumn( m_textureLayer->levelZeroColumns(),
m_visibleTileLevel );
return static_cast<int>( globalWidth * 0.5 + lon * ( globalWidth / ( 2.0 * M_PI ) ));
@@ -148,7 +148,7 @@
// copied from AbstractScanlineTextureMapper and slightly adjusted
int DownloadRegionDialog::Private::rad2PixelY( qreal const lat ) const
{
- qreal const globalHeight = textureMapper()->tileSize().height()
+ qreal const globalHeight = m_textureLayer->tileSize().height()
* TileLoaderHelper::levelToRow( m_textureLayer->levelZeroRows(), m_visibleTileLevel );
qreal const normGlobalHeight = globalHeight / M_PI;
switch ( m_textureLayer->projection() ) {
@@ -266,8 +266,8 @@
mDebug() << "north/west (x/y):" << westX << northY;
mDebug() << "south/east (x/y):" << eastX << southY;
- int const tileWidth = d->textureMapper()->tileSize().width();
- int const tileHeight = d->textureMapper()->tileSize().height();
+ int const tileWidth = d->m_textureLayer->tileSize().width();
+ int const tileHeight = d->m_textureLayer->tileSize().height();
mDebug() << "DownloadRegionDialog downloadRegion: tileSize:" << tileWidth << tileHeight;
int const visibleLevelX1 = qMin( westX, eastX );
--- trunk/KDE/kdeedu/marble/src/lib/geodata/scene/GeoSceneTexture.cpp #1148311:1148312
@@ -24,9 +24,12 @@
#include "DownloadPolicy.h"
#include "MarbleDebug.h"
+#include "MarbleDirs.h"
#include "ServerLayout.h"
#include "TileId.h"
+#include <QtGui/QImage>
+
namespace Marble
{
@@ -113,6 +116,22 @@
m_maximumTileLevel = maximumTileLevel;
}
+const QSize GeoSceneTexture::tileSize() const
+{
+ if ( !m_tileSize.isValid() ) {
+ const TileId id( sourceDir(), 0, 0, 0 );
+ const QString path = MarbleDirs::path( relativeTileFileName( id ));
+
+ QImage testTile( path );
+ Q_ASSERT( !testTile.isNull() );
+
+ m_tileSize = testTile.size();
+ Q_ASSERT( !tileSize().isEmpty() );
+ }
+
+ return m_tileSize;
+}
+
GeoSceneTexture::Projection GeoSceneTexture::projection() const
{
return m_projection;
--- trunk/KDE/kdeedu/marble/src/lib/geodata/scene/GeoSceneTexture.h #1148311:1148312
@@ -27,6 +27,7 @@
#include <QtCore/QStringList>
#include <QtCore/QUrl>
#include <QtCore/QVector>
+#include <QtCore/QSize>
#include "GeoSceneLayer.h"
#include "global.h"
@@ -72,6 +73,8 @@
int maximumTileLevel() const;
void setMaximumTileLevel( const int );
+ const QSize tileSize() const;
+
Projection projection() const;
void setProjection( const Projection );
@@ -104,6 +107,7 @@
int m_levelZeroColumns;
int m_levelZeroRows;
int m_maximumTileLevel;
+ mutable QSize m_tileSize;
Projection m_projection;
Blending const * m_blending;
--- trunk/KDE/kdeedu/marble/src/tilecreator/CMakeLists.txt #1148311:1148312
@@ -9,6 +9,7 @@
set( tilecreator_SRCS
../lib/DownloadPolicy.cpp
../lib/TileCreator.cpp
+ ../lib/TileId.cpp
../lib/TileLoaderHelper.cpp
../lib/ServerLayout.cpp
../lib/geodata/parser/GeoDocument.cpp
More information about the Marble-commits
mailing list