[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/base/marble
From: Inge Wallin <inge () lysator ! liu ! se>
Date: 2007-04-27 0:57:08
Message-ID: 1177635428.836009.14589.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 658403 by ingwa:
Clean class TileScissor
M +3 -0 ChangeLog
M +2 -2 src/CLEANING
M +96 -80 src/tilescissor.cpp
M +20 -10 src/tilescissor.h
--- trunk/playground/base/marble/ChangeLog #658402:658403
@@ -1,3 +1,6 @@
+26.04.07 - ingwa
+ Cleaned tilescissor.{h,cpp}
+
25.04.07 - ingwa
Lots of small cleaning
Cleaned placemarkmodel.{h,cpp}
--- trunk/playground/base/marble/src/CLEANING #658402:658403
@@ -16,6 +16,7 @@
GeoPolygon.h GeoPolygon.cpp
TileLoader.h TileLoader.cpp
+tilescissor.h tilescissor.cpp
TextureTile.h TextureTile.cpp
TextureMapper.h TextureMapper.cpp
@@ -28,6 +29,7 @@
placecontainer.h placecontainer.cpp
placemarkpainter.h placemarkpainter.cpp
placemarkmanager.h placemarkmanager.cpp
+placemarkmodel.h placemarkmodel.cpp
Model/View:
-----------
@@ -45,7 +47,6 @@
DOING
=====
-placemarkmodel.h placemarkmodel.cpp
TODO
@@ -62,7 +63,6 @@
maptheme.h maptheme.cpp
measuretool.h measuretool.cpp
texcolorizer.h texcolorizer.cpp
-tilescissor.h tilescissor.cpp
xmlhandler.h xmlhandler.cpp
Widgets:
--- trunk/playground/base/marble/src/tilescissor.cpp #658402:658403
@@ -1,17 +1,18 @@
#include "tilescissor.h"
+#include <QtCore/QDebug>
+#include <QtCore/QRect>
+#include <QtCore/QSize>
+#include <QtCore/QVector>
#include <QtGui/QApplication>
-#include <QtCore/QDebug>
#include <QtGui/QImage>
#include <QtGui/QImageReader>
#include <QtGui/QPainter>
-#include <QtCore/QRect>
-#include <QtCore/QSize>
-#include <QtCore/QVector>
#include "katlasdirs.h"
#include "TileLoader.h"
+
TileScissor::TileScissor(const QString& prefix, const QString& installmap,
const QString& dem)
: m_prefix(prefix),
@@ -34,26 +35,27 @@
QImageReader testimg( srcpath );
QVector<QRgb> legpal;
- for ( int count = 0; count <= 255; count++){
+ for ( int count = 0; count <= 255; count++) {
legpal.insert(count, qRgb(count, count, count));
}
- int imgw = testimg.size().width();
- int imgh = testimg.size().height();
- /*
+ int imgw = testimg.size().width();
+ int imgh = testimg.size().height();
+#if 0
if ( imgw > 10800 || imgh > 10800 ){
- qDebug("Install map too large!");
- exit(-1);
+ qDebug("Install map too large!");
+ exit(-1);
}
- */
- bool smooth = ( (imgw%675)%2 > 0 || (imgh%675)%2 > 0 ) ? true : false;
+#endif
+ bool smooth = ( ( imgw % 675 ) % 2 > 0
+ || ( imgh % 675 ) % 2 > 0 );
- int maxtilelevel = -1;
- int stdimgw = 0;
- int stdimgh = 0;
+ int maxtilelevel = -1;
+ int stdimgw = 0;
+ int stdimgh = 0;
int count = 0;
- while ( stdimgw < imgw ){
+ while ( stdimgw < imgw ) {
maxtilelevel = count;
stdimgw = 2 * 675 * TileLoader::levelToRow( maxtilelevel );
count++;
@@ -93,45 +95,53 @@
QString tilename;
// Creating directory structure for the highest level
+ QString dirname( KAtlasDirs::localDir()
+ + QString("/maps/earth/%1/%2").arg(m_prefix).arg(maxtilelevel) \
); + if ( !QDir( dirname ).exists() )
+ ( QDir::root() ).mkpath( dirname );
- QString dirname( KAtlasDirs::localDir() + \
QString("/maps/earth/%1/%2").arg(m_prefix).arg(maxtilelevel) );
- if ( QDir( dirname ).exists() == false )
- ( QDir::root() ).mkpath( dirname );
- for ( int n=0; n < nmax; n++) {
- QString dirname( KAtlasDirs::localDir() + \
QString("/maps/earth/%1/%2/%3").arg(m_prefix).arg(maxtilelevel).arg( n, 4, 10, \
QChar('0') ) );
- if ( QDir( dirname ).exists() == false )
+ for ( int n = 0; n < nmax; n++ ) {
+ QString dirname( KAtlasDirs::localDir()
+ + \
QString("/maps/earth/%1/%2/%3").arg(m_prefix).arg(maxtilelevel).arg( n, 4, 10, \
QChar('0') ) ); + if ( !QDir( dirname ).exists() )
( QDir::root() ).mkpath( dirname );
}
- for ( int n=0; n < nmax; n++){
+ for ( int n = 0; n < nmax; n++ ) {
QApplication::processEvents();
- QRect rowsrc( 0, (int)((float)(n*imgh)/(float)(nmax)), imgw, \
(int)((float)(imgh)/(float)(nmax)) ); + QRect rowsrc( 0, (int)( (float)( n * \
imgh ) / (float)(nmax)), + imgw, (int)((float)(imgh) / \
(float)(nmax) ) );
- QImage img( srcpath );
+ QImage img( srcpath );
- QImage row = img.copy( rowsrc );
- QSize destsize( stdimgw, 675 );
+ QImage row = img.copy( rowsrc );
+ QSize destsize( stdimgw, 675 );
- if ( smooth == true ){
- row = img.scaled(destsize, Qt::IgnoreAspectRatio, \
Qt::SmoothTransformation); + if ( smooth ) {
+ row = img.scaled( destsize,
+ Qt::IgnoreAspectRatio,
+ Qt::SmoothTransformation );
}
- if ( row.isNull() ) qDebug() << "Read-Error! Null QImage!";
+ if ( row.isNull() )
+ qDebug() << "Read-Error! Null QImage!";
- for ( int m=0; m < mmax; m++) {
+ for ( int m = 0; m < mmax; m++ ) {
QApplication::processEvents();
- QImage tile = row.copy( m*imgw/mmax, 0, 675, 675 );
+ QImage tile = row.copy( m * imgw / mmax, 0, 675, 675 );
tilename = destpath + QString("%1/%2/%2_%3.jpg").arg( maxtilelevel \
).arg( n, 4, 10, QChar('0') ).arg( m, 4, 10, QChar('0') );
- if ( m_dem == "true" ){
- tile=tile.convertToFormat(QImage::Format_Indexed8, legpal, \
Qt::ThresholdDither); + if ( m_dem == "true" ) {
+ tile = tile.convertToFormat(QImage::Format_Indexed8,
+ legpal, Qt::ThresholdDither);
}
- bool noerr = tile.save( tilename, "jpg", 100);
- if ( noerr == false ) qDebug() << "Error while writing Tile: " << \
tilename; + bool noerr = tile.save( tilename, "jpg", 100 );
+ if ( noerr == false )
+ qDebug() << "Error while writing Tile: " << tilename;
completed = (int) ( 90 * (float)(count) / (float)(maxcount) );
count++;
@@ -144,95 +154,99 @@
tilelevel = maxtilelevel - 1;
- // Now that we have the tiles at the highest resolution lets build them together \
four by four + // Now that we have the tiles at the highest resolution lets build
+ // them together four by four.
while( tilelevel >= 0 ) {
+ int nmaxit = TileLoader::levelToRow( tilelevel );;
- int nmaxit = TileLoader::levelToRow( tilelevel );;
- for ( int n=0; n < nmaxit; n++) {
- QString dirname( KAtlasDirs::localDir() + \
QString("/maps/earth/%1/%2/%3").arg(m_prefix).arg(tilelevel).arg( n, 4, 10, \
QChar('0') ) );
- // qDebug() << "dirname: " << dirname;
- if ( QDir( dirname ).exists() == false )
+ for ( int n = 0; n < nmaxit; n++ ) {
+ QString dirname( KAtlasDirs::localDir()
+ + \
QString("/maps/earth/%1/%2/%3").arg(m_prefix).arg(tilelevel).arg( n, 4, 10, \
QChar('0') ) ); +
+ // qDebug() << "dirname: " << dirname;
+ if ( !QDir( dirname ).exists() )
( QDir::root() ).mkpath( dirname );
- int mmaxit = TileLoader::levelToColumn( tilelevel );;
- for ( int m=0; m < mmaxit; m++){
+ int mmaxit = TileLoader::levelToColumn( tilelevel );;
+ for ( int m = 0; m < mmaxit; m++ ) {
tilename = destpath + QString("%1/%2/%2_%3.jpg").arg( tilelevel + 1 \
).arg( 2*n, 4, 10, QChar('0') ).arg( 2*m, 4, 10, QChar('0') );
- QImage img_topleft( tilename );
+ QImage img_topleft( tilename );
tilename = destpath + QString("%1/%2/%2_%3.jpg").arg( tilelevel + 1 \
).arg( 2*n, 4, 10, QChar('0') ).arg( 2*m+1, 4, 10, QChar('0') );
- QImage img_topright( tilename );
+ QImage img_topright( tilename );
tilename = destpath + QString("%1/%2/%2_%3.jpg").arg( tilelevel + 1 \
).arg( 2*n+1, 4, 10, QChar('0') ).arg( 2*m, 4, 10, QChar('0') );
- QImage img_bottomleft( tilename );
+ QImage img_bottomleft( tilename );
tilename = destpath + QString("%1/%2/%2_%3.jpg").arg( tilelevel + 1 \
).arg( 2*n+1, 4, 10, QChar('0') ).arg( 2*m+1, 4, 10, QChar('0') );
- QImage img_bottomright( tilename );
+ QImage img_bottomright( tilename );
- QImage tile = img_topleft;
+ QImage tile = img_topleft;
tile.setColorTable( legpal );
if ( tile.depth() == 8 ) {
uchar* destline;
- for ( int y=0; y < 338; ++y ){
+ for ( int y = 0; y < 338; ++y ) {
destline = tile.scanLine( y );
- const uchar* srcline = img_topleft.scanLine( 2*y );
- for ( int x=0; x < 338; ++x )
- destline[x]=srcline[2*x];
+ const uchar* srcline = img_topleft.scanLine( 2 * y );
+ for ( int x = 0; x < 338; ++x )
+ destline[x] = srcline[2*x];
}
- for ( int y=0; y < 338; ++y ){
+ for ( int y = 0; y < 338; ++y ) {
destline = tile.scanLine( y );
- const uchar* srcline = img_topright.scanLine( 2*y );
- for ( int x=338; x < 675; ++x )
- destline[x]=srcline[2*(x-338)];
+ const uchar* srcline = img_topright.scanLine( 2 * y );
+ for ( int x = 338; x < 675; ++x )
+ destline[x] = srcline[2*(x-338)];
}
- for ( int y=338; y < 675; ++y ){
+ for ( int y=338; y < 675; ++y ) {
destline = tile.scanLine( y );
const uchar* srcline = img_bottomleft.scanLine( 2 * ( y-338 \
) ); for ( int x=0; x < 338; ++x )
- destline[x]=srcline[2*x];
+ destline[x]=srcline[2 * x];
}
- for ( int y=338; y < 675; ++y ){
+ for ( int y = 338; y < 675; ++y ) {
destline = tile.scanLine( y );
const uchar* srcline = img_bottomright.scanLine( 2 * ( y-338 \
) );
- for ( int x=338; x < 675; ++x )
- destline[x]=srcline[2*(x-338)];
+ for ( int x = 338; x < 675; ++x )
+ destline[x] = srcline[2 * (x - 338)];
}
}
else {
QRgb* destline;
- for ( int y=0; y < 338; ++y ){
+ for ( int y = 0; y < 338; ++y ) {
destline = (QRgb*) tile.scanLine( y );
const QRgb* srcline = (QRgb*) img_topleft.scanLine( 2 * y );
- for ( int x=0; x < 338; ++x )
- destline[x]=srcline[2*x];
+ for ( int x = 0; x < 338; ++x )
+ destline[x] = srcline[2 * x];
}
- for ( int y=0; y < 338; ++y ){
+ for ( int y = 0; y < 338; ++y ) {
destline = (QRgb*) tile.scanLine( y );
const QRgb* srcline = (QRgb*) img_topright.scanLine( 2 * y \
);
- for ( int x=338; x < 675; ++x )
- destline[x]=srcline[2*(x-338)];
+ for ( int x = 338; x < 675; ++x )
+ destline[x] = srcline[2 * (x - 338)];
}
- for ( int y=338; y < 675; ++y ){
+ for ( int y = 338; y < 675; ++y ) {
destline = (QRgb*) tile.scanLine( y );
const QRgb* srcline = (QRgb*) img_bottomleft.scanLine( 2 * ( \
y-338 ) );
- for ( int x=0; x < 338; ++x )
- destline[x]=srcline[2*x];
+ for ( int x = 0; x < 338; ++x )
+ destline[x] = srcline[2*x];
}
- for ( int y=338; y < 675; ++y ){
+ for ( int y = 338; y < 675; ++y ) {
destline = (QRgb*) tile.scanLine( y );
const QRgb* srcline = (QRgb*) img_bottomright.scanLine( 2 * \
( y-338 ) );
- for ( int x=338; x < 675; ++x )
- destline[x]=srcline[2*(x-338)];
+ for ( int x = 338; x < 675; ++x )
+ destline[x] = srcline[2*(x-338)];
}
}
tilename = destpath + QString("%1/%2/%2_%3.jpg").arg( tilelevel \
).arg( n, 4, 10, QChar('0') ).arg( m, 4, 10, QChar('0') ); bool noerr = tile.save( \
tilename, "jpg", 100 );
- if ( noerr == false ) qDebug() << "Error while writing Tile: " << \
tilename;; + if ( noerr == false )
+ qDebug() << "Error while writing Tile: " << tilename;;
completed = (int) ( 90 * (float)(count) / (float)(maxcount) );
count++;
@@ -246,6 +260,7 @@
tilelevel--;
}
qDebug() << "Tile creation completed.";
+
// Applying correct JPEG compression
int microcount = 0;
int microcompleted = 0;
@@ -253,19 +268,20 @@
tilelevel = 0;
while ( tilelevel <= maxtilelevel ) {
int nmaxit = TileLoader::levelToRow( tilelevel );
- for ( int n=0; n < nmaxit; n++){
+ for ( int n = 0; n < nmaxit; n++) {
int mmaxit = TileLoader::levelToColumn( tilelevel );
- for ( int m=0; m < mmaxit; m++){
+ for ( int m = 0; m < mmaxit; m++) {
microcount++;
tilename = destpath + QString("%1/%2/%2_%3.jpg").arg( tilelevel \
).arg( n, 4, 10, QChar('0') ).arg( m, 4, 10, QChar('0') ); QImage tile( tilename );
bool noerr = tile.save( tilename, "jpg", 85 );
- if ( noerr == false ) qDebug() << "Error while writing Tile: " << \
tilename; + if ( noerr == false )
+ qDebug() << "Error while writing Tile: " << tilename;
microcompleted = (int) ( 100 * (float)(microcount) / \
(float)(maxcount) );
- emit progress( 90 + (int)( 0.1*(float)microcompleted ) );
+ emit progress( 90 + (int)( 0.1 * (float)microcompleted ) );
QApplication::processEvents();
}
}
@@ -275,9 +291,9 @@
completed = 100;
emit progress( 100 );
QApplication::processEvents();
-
}
+
#ifndef Q_OS_MACX
#include "tilescissor.moc"
#endif
--- trunk/playground/base/marble/src/tilescissor.h #658402:658403
@@ -8,29 +8,39 @@
//
// Copyright: See COPYING file that comes with this distribution
+
#ifndef TILESCISSOR_H
#define TILESCISSOR_H
+
#include <QtCore/QObject>
#include <QtCore/QString>
+
/**
@author Torsten Rahn
*/
-class TileScissor : public QObject {
- Q_OBJECT
-public:
- TileScissor( const QString& prefix, const QString& installmap, const QString& dem \
);
-signals:
- void progress( int value );
-public slots:
- void createTiles();
+class TileScissor : public QObject
+{
+ Q_OBJECT
-private:
- QString m_prefix, m_installmap, m_dem;
+ public:
+ TileScissor( const QString& prefix, const QString& installmap,
+ const QString& dem );
+ signals:
+ void progress( int value );
+
+ public slots:
+ void createTiles();
+
+ private:
+ QString m_prefix;
+ QString m_installmap;
+ QString m_dem;
};
+
#endif
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic