Skip to content

Commit 260b4a1

Browse files
committedDec 12, 2012
Merge branch 'master' of https://github.com/qgis/Quantum-GIS
2 parents d401a6e + f218a39 commit 260b4a1

28 files changed

+555
-150
lines changed
 
Lines changed: 241 additions & 0 deletions
Loading

‎python/core/qgsdistancearea.sip

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,6 @@ class QgsDistanceArea
7676
static QString textUnit( double value, int decimals, QGis::UnitType u, bool isArea, bool keepBaseUnit = false );
7777

7878
//! Helper for conversion between physical units
79-
void convertMeasurement( double &measure, QGis::UnitType &measureUnits, QGis::UnitType displayUnits, bool isArea );
79+
void convertMeasurement( double &measure /In,Out/, QGis::UnitType &measureUnits /In,Out/, QGis::UnitType displayUnits, bool isArea );
8080

8181
};

‎scripts/addcopyright.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ for i in $(<files); do
3232
author=volayaf
3333
;;
3434

35-
src/app/gps/qwtpolar-*|src/app/qtmain_android.cpp|src/core/spatialite/*|src/core/spatialindex/src/*|src/core/gps/qextserialport/*|src/plugins/grass/qtermwidget/*|src/astyle/*|python/pyspatialite/*|src/providers/sqlanywhere/sqlanyconnection/*)
35+
src/app/gps/qwtpolar-*|src/app/qtmain_android.cpp|src/core/spatialite/*|src/core/spatialindex/src/*|src/core/gps/qextserialport/*|src/astyle/*|python/pyspatialite/*|src/providers/sqlanywhere/sqlanyconnection/*)
3636
# Skip third party files
3737
echo $f skipped
3838
continue

‎src/app/qgsidentifyresults.cpp

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
#include "qgsmapcanvas.h"
2929
#include "qgsattributeaction.h"
3030
#include "qgsfeatureaction.h"
31+
#include "qgslogger.h"
32+
#include "qgsnetworkaccessmanager.h"
3133

3234
#include <QCloseEvent>
3335
#include <QLabel>
@@ -46,7 +48,36 @@
4648
#include <QDesktopServices>
4749
#include <QMessageBox>
4850

49-
#include "qgslogger.h"
51+
QgsWebView::QgsWebView( QWidget *parent ) : QWebView( parent )
52+
{
53+
page()->setNetworkAccessManager( QgsNetworkAccessManager::instance() );
54+
page()->setLinkDelegationPolicy( QWebPage::DelegateAllLinks );
55+
settings()->setAttribute( QWebSettings::LocalContentCanAccessRemoteUrls, true );
56+
#ifdef QGISDEBUG
57+
settings()->setAttribute( QWebSettings::DeveloperExtrasEnabled, true );
58+
#endif
59+
}
60+
61+
void QgsWebView::print( void )
62+
{
63+
QPrinter printer;
64+
QPrintDialog *dialog = new QPrintDialog( &printer );
65+
if ( dialog->exec() == QDialog::Accepted )
66+
QWebView::print( &printer );
67+
}
68+
69+
void QgsWebView::contextMenuEvent( QContextMenuEvent *e )
70+
{
71+
QMenu *menu = page()->createStandardContextMenu();
72+
if ( menu )
73+
{
74+
QAction *action = new QAction( tr( "Print" ), this );
75+
connect( action, SIGNAL( triggered() ), this, SLOT( print() ) );
76+
menu->addAction( action );
77+
menu->exec( e->globalPos() );
78+
delete menu;
79+
}
80+
}
5081

5182
class QgsIdentifyResultsDock : public QDockWidget
5283
{
@@ -289,15 +320,9 @@ void QgsIdentifyResults::addFeature( QgsRasterLayer *layer,
289320
QTreeWidgetItem *attrItem = new QTreeWidgetItem( QStringList() << attributes.begin().key() << "" );
290321
featItem->addChild( attrItem );
291322

292-
QWebView *wv = new QWebView( attrItem->treeWidget() );
323+
QgsWebView *wv = new QgsWebView( attrItem->treeWidget() );
293324
wv->setHtml( attributes.begin().value() );
294-
wv->page()->setLinkDelegationPolicy( QWebPage::DelegateAllLinks );
295-
296-
QAction *action = new QAction( tr( "Print" ), wv );
297-
connect( action, SIGNAL( triggered() ), this, SLOT( print() ) );
298-
wv->insertAction( 0, action );
299325

300-
wv->setContextMenuPolicy( Qt::ActionsContextMenu );
301326
mPrintToolButton->setVisible( true );
302327

303328
connect( wv, SIGNAL( linkClicked( const QUrl & ) ), this, SLOT( openUrl( const QUrl & ) ) );
@@ -1040,22 +1065,6 @@ void QgsIdentifyResults::openUrl( const QUrl &url )
10401065
}
10411066
}
10421067

1043-
void QgsIdentifyResults::print()
1044-
{
1045-
QAction *action = qobject_cast<QAction*>( sender() );
1046-
if ( !action )
1047-
return;
1048-
1049-
QWebView *wv = qobject_cast<QWebView*>( action->parent() );
1050-
if ( !wv )
1051-
return;
1052-
1053-
QPrinter printer;
1054-
QPrintDialog *dialog = new QPrintDialog( &printer );
1055-
if ( dialog->exec() == QDialog::Accepted )
1056-
wv->print( &printer );
1057-
}
1058-
10591068
void QgsIdentifyResults::printCurrentItem()
10601069
{
10611070
QTreeWidgetItem *item = lstResults->currentItem();

‎src/app/qgsidentifyresults.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
#include <QWidget>
2727
#include <QList>
28+
#include <QWebView>
2829

2930
class QCloseEvent;
3031
class QTreeWidgetItem;
@@ -119,7 +120,6 @@ class QgsIdentifyResults: public QDialog, private Ui::QgsIdentifyResultsBase
119120
void on_mCollapseToolButton_clicked( bool checked ) { Q_UNUSED( checked ); collapseAll(); }
120121

121122
void openUrl( const QUrl &url );
122-
void print();
123123
void printCurrentItem();
124124

125125
private:
@@ -148,4 +148,16 @@ class QgsIdentifyResults: public QDialog, private Ui::QgsIdentifyResultsBase
148148
QDockWidget *mDock;
149149
};
150150

151+
class QgsWebView : public QWebView
152+
{
153+
Q_OBJECT;
154+
public:
155+
QgsWebView( QWidget *parent = 0 );
156+
public slots:
157+
void print( void );
158+
protected:
159+
void contextMenuEvent( QContextMenuEvent* );
160+
};
161+
162+
151163
#endif

‎src/app/qgsmaptoolidentify.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ bool QgsMapToolIdentify::identifyVectorLayer( QgsVectorLayer *layer, int x, int
315315
convertMeasurement( calc, area, myDisplayUnits, true ); // area and myDisplayUnits are out params
316316
QString str = calc.textUnit( area, 3, myDisplayUnits, true );
317317
derivedAttributes.insert( tr( "Area" ), str );
318-
convertMeasurement( calc, perimeter, myDisplayUnits, false ); // area and myDisplayUnits are out params
318+
convertMeasurement( calc, perimeter, myDisplayUnits, false ); // perimeter and myDisplayUnits are out params
319319
str = calc.textUnit( perimeter, 3, myDisplayUnits, false );
320320
derivedAttributes.insert( tr( "Perimeter" ), str );
321321
}

‎src/core/composer/qgsatlascomposition.cpp

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,8 @@ void QgsAtlasComposition::setCoverageLayer( QgsVectorLayer* layer )
4848
{
4949
mCoverageLayer = layer;
5050

51-
if ( mCoverageLayer != 0 )
52-
{
53-
// update the number of features
54-
QgsVectorDataProvider* provider = mCoverageLayer->dataProvider();
55-
QgsExpression::setSpecialColumn( "$numfeatures", QVariant(( int )provider->featureCount() ) );
56-
}
51+
// update the number of features
52+
QgsExpression::setSpecialColumn( "$numfeatures", QVariant( (int)mFeatureIds.size() ) );
5753
}
5854

5955
void QgsAtlasComposition::beginRender()
@@ -93,6 +89,7 @@ void QgsAtlasComposition::beginRender()
9389
// We cannot use nextFeature() directly since the feature pointer is rewinded by the rendering process
9490
// We thus store the feature ids for future extraction
9591
QgsFeature feat;
92+
mFeatureIds.clear();
9693
while ( provider->nextFeature( feat ) )
9794
{
9895
mFeatureIds.push_back( feat.id() );
@@ -115,7 +112,7 @@ void QgsAtlasComposition::beginRender()
115112

116113
// special columns for expressions
117114
QgsExpression::setSpecialColumn( "$numpages", QVariant( mComposition->numPages() ) );
118-
QgsExpression::setSpecialColumn( "$numfeatures", QVariant(( int )provider->featureCount() ) );
115+
QgsExpression::setSpecialColumn( "$numfeatures", QVariant(( int )mFeatureIds.size() ) );
119116
}
120117

121118
void QgsAtlasComposition::endRender()
@@ -147,11 +144,7 @@ void QgsAtlasComposition::endRender()
147144

148145
size_t QgsAtlasComposition::numFeatures() const
149146
{
150-
if ( mCoverageLayer )
151-
{
152-
return mCoverageLayer->dataProvider()->featureCount();
153-
}
154-
return 0;
147+
return mFeatureIds.size();
155148
}
156149

157150
void QgsAtlasComposition::prepareForFeature( size_t featureI )

‎src/core/qgscoordinatereferencesystem.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,9 @@ void QgsCoordinateReferenceSystem::validate()
286286
mCustomSrsValidation( this );
287287

288288
if ( !mIsValidFlag )
289-
// set the default
290-
createFromOgcWmsCrs( GEO_EPSG_CRS_AUTHID );
289+
{
290+
*this = QgsCRSCache::instance()->crsByAuthId( GEO_EPSG_CRS_AUTHID );
291+
}
291292
}
292293

293294
bool QgsCoordinateReferenceSystem::createFromSrid( long id )

‎src/core/qgscoordinatetransform.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* *
1616
***************************************************************************/
1717
#include "qgscoordinatetransform.h"
18+
#include "qgscrscache.h"
1819
#include "qgsmessagelog.h"
1920
#include "qgslogger.h"
2021

@@ -148,9 +149,8 @@ void QgsCoordinateTransform::initialise()
148149
if ( !mDestCRS.isValid() )
149150
{
150151
//No destination projection is set so we set the default output projection to
151-
//be the same as input proj. This only happens on the first layer loaded
152-
//whatever that may be...
153-
mDestCRS.createFromOgcWmsCrs( mSourceCRS.authid() );
152+
//be the same as input proj.
153+
mDestCRS = QgsCRSCache::instance()->crsByAuthId( mSourceCRS.authid() );
154154
}
155155

156156
// init the projections (destination and source)

‎src/core/raster/qgspalettedrasterrenderer.cpp

Lines changed: 41 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,17 @@
2525

2626
QgsPalettedRasterRenderer::QgsPalettedRasterRenderer( QgsRasterInterface* input, int bandNumber,
2727
QColor* colorArray, int nColors ):
28+
QgsRasterRenderer( input, "paletted" ), mBand( bandNumber ), mNColors( nColors )
29+
{
30+
mColors = new QRgb[nColors];
31+
for ( int i = 0; i < nColors; ++i )
32+
{
33+
mColors[i] = colorArray[i].rgba();
34+
}
35+
delete[] colorArray;
36+
}
37+
38+
QgsPalettedRasterRenderer::QgsPalettedRasterRenderer( QgsRasterInterface* input, int bandNumber, QRgb* colorArray, int nColors ):
2839
QgsRasterRenderer( input, "paletted" ), mBand( bandNumber ), mColors( colorArray ), mNColors( nColors )
2940
{
3041
}
@@ -36,7 +47,7 @@ QgsPalettedRasterRenderer::~QgsPalettedRasterRenderer()
3647

3748
QgsRasterInterface * QgsPalettedRasterRenderer::clone() const
3849
{
39-
QgsPalettedRasterRenderer * renderer = new QgsPalettedRasterRenderer( 0, mBand, colors(), mNColors );
50+
QgsPalettedRasterRenderer * renderer = new QgsPalettedRasterRenderer( 0, mBand, rgbArray(), mNColors );
4051
renderer->setOpacity( mOpacity );
4152
renderer->setAlphaBand( mAlphaBand );
4253
renderer->setRasterTransparency( mRasterTransparency );
@@ -52,14 +63,14 @@ QgsRasterRenderer* QgsPalettedRasterRenderer::create( const QDomElement& elem, Q
5263

5364
int bandNumber = elem.attribute( "band", "-1" ).toInt();
5465
int nColors = 0;
55-
QColor* colors = 0;
66+
QRgb* colors = 0;
5667

5768
QDomElement paletteElem = elem.firstChildElement( "colorPalette" );
5869
if ( !paletteElem.isNull() )
5970
{
6071
QDomNodeList paletteEntries = paletteElem.elementsByTagName( "paletteEntry" );
6172
nColors = paletteEntries.size();
62-
colors = new QColor[ nColors ];
73+
colors = new QRgb[ nColors ];
6374

6475
int value = 0;
6576
QDomElement entryElem;
@@ -68,7 +79,7 @@ QgsRasterRenderer* QgsPalettedRasterRenderer::create( const QDomElement& elem, Q
6879
entryElem = paletteEntries.at( i ).toElement();
6980
value = entryElem.attribute( "value", "0" ).toInt();
7081
QgsDebugMsg( entryElem.attribute( "color", "#000000" ) );
71-
colors[value] = QColor( entryElem.attribute( "color", "#000000" ) );
82+
colors[value] = QColor( entryElem.attribute( "color", "#000000" ) ).rgba();
7283
}
7384
}
7485
QgsRasterRenderer* r = new QgsPalettedRasterRenderer( input, bandNumber, colors, nColors );
@@ -85,11 +96,25 @@ QColor* QgsPalettedRasterRenderer::colors() const
8596
QColor* colorArray = new QColor[ mNColors ];
8697
for ( int i = 0; i < mNColors; ++i )
8798
{
88-
colorArray[i] = mColors[i];
99+
colorArray[i] = QColor( mColors[i] );
89100
}
90101
return colorArray;
91102
}
92103

104+
QRgb* QgsPalettedRasterRenderer::rgbArray() const
105+
{
106+
if ( mNColors < 1 )
107+
{
108+
return 0;
109+
}
110+
QRgb* rgbValues = new QRgb[mNColors];
111+
for ( int i = 0; i < mNColors; ++i )
112+
{
113+
rgbValues[i] = mColors[i];
114+
}
115+
return rgbValues;
116+
}
117+
93118
QgsRasterBlock * QgsPalettedRasterRenderer::block( int bandNo, QgsRectangle const & extent, int width, int height )
94119
{
95120
QgsRasterBlock *outputBlock = new QgsRasterBlock();
@@ -146,7 +171,12 @@ QgsRasterBlock * QgsPalettedRasterRenderer::block( int bandNo, QgsRectangle con
146171
return outputBlock;
147172
}
148173

149-
for ( size_t i = 0; i < ( size_t )width*height; i++ )
174+
//use direct data access instead of QgsRasterBlock::setValue
175+
//because of performance
176+
unsigned int* outputData = ( unsigned int* )( outputBlock->data() );
177+
178+
size_t rasterSize = ( size_t )width * height;
179+
for ( size_t i = 0; i < rasterSize; ++i )
150180
{
151181
int val = ( int ) inputBlock->value( i );
152182
if ( inputBlock->isNoDataValue( val ) )
@@ -156,14 +186,7 @@ QgsRasterBlock * QgsPalettedRasterRenderer::block( int bandNo, QgsRectangle con
156186
}
157187
if ( !hasTransparency )
158188
{
159-
if ( val < 0 || val > mNColors )
160-
{
161-
outputBlock->setColor( i, myDefaultColor );
162-
}
163-
else
164-
{
165-
outputBlock->setColor( i, mColors[ val ].rgba() );
166-
}
189+
outputData[i] = mColors[ val ];
167190
}
168191
else
169192
{
@@ -176,9 +199,8 @@ QgsRasterBlock * QgsPalettedRasterRenderer::block( int bandNo, QgsRectangle con
176199
{
177200
currentOpacity *= alphaBlock->value( i ) / 255.0;
178201
}
179-
QColor& currentColor = mColors[val];
180-
181-
outputBlock->setColor( i, qRgba( currentOpacity * currentColor.red(), currentOpacity * currentColor.green(), currentOpacity * currentColor.blue(), currentOpacity * 255 ) );
202+
QColor currentColor = QColor( mColors[val] );
203+
outputData[i] = qRgba( currentOpacity * currentColor.red(), currentOpacity * currentColor.green(), currentOpacity * currentColor.blue(), currentOpacity * 255 );
182204
}
183205
}
184206

@@ -207,7 +229,7 @@ void QgsPalettedRasterRenderer::writeXML( QDomDocument& doc, QDomElement& parent
207229
{
208230
QDomElement colorElem = doc.createElement( "paletteEntry" );
209231
colorElem.setAttribute( "value", i );
210-
colorElem.setAttribute( "color", mColors[i].name() );
232+
colorElem.setAttribute( "color", QColor( mColors[i] ).name() );
211233
colorPaletteElem.appendChild( colorElem );
212234
}
213235
rasterRendererElem.appendChild( colorPaletteElem );
@@ -219,7 +241,7 @@ void QgsPalettedRasterRenderer::legendSymbologyItems( QList< QPair< QString, QCo
219241
{
220242
for ( int i = 0; i < mNColors; ++i )
221243
{
222-
symbolItems.push_back( qMakePair( QString::number( i ), mColors[i] ) );
244+
symbolItems.push_back( qMakePair( QString::number( i ), QColor( mColors[i] ) ) );
223245
}
224246
}
225247

‎src/core/raster/qgspalettedrasterrenderer.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class CORE_EXPORT QgsPalettedRasterRenderer: public QgsRasterRenderer
3131
public:
3232
/**Renderer owns color array*/
3333
QgsPalettedRasterRenderer( QgsRasterInterface* input, int bandNumber, QColor* colorArray, int nColors );
34+
QgsPalettedRasterRenderer( QgsRasterInterface* input, int bandNumber, QRgb* colorArray, int nColors );
3435
~QgsPalettedRasterRenderer();
3536
QgsRasterInterface * clone() const;
3637
static QgsRasterRenderer* create( const QDomElement& elem, QgsRasterInterface* input );
@@ -43,6 +44,8 @@ class CORE_EXPORT QgsPalettedRasterRenderer: public QgsRasterRenderer
4344
int nColors() const { return mNColors; }
4445
/**Returns copy of color array (caller takes ownership)*/
4546
QColor* colors() const;
47+
/**Returns copy of rgb array (caller takes ownership)*/
48+
QRgb* rgbArray() const;
4649

4750
void writeXML( QDomDocument& doc, QDomElement& parentElem ) const;
4851

@@ -53,7 +56,7 @@ class CORE_EXPORT QgsPalettedRasterRenderer: public QgsRasterRenderer
5356
private:
5457
int mBand;
5558
/**Color array*/
56-
QColor* mColors;
59+
QRgb* mColors;
5760
/**Number of colors*/
5861
int mNColors;
5962
};

‎src/core/raster/qgsrasterblock.cpp

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -239,28 +239,6 @@ bool QgsRasterBlock::isNoDataValue( double value, double noDataValue )
239239
return false;
240240
}
241241

242-
bool QgsRasterBlock::isNoDataValue( double value ) const
243-
{
244-
// More precise would be qIsNaN(value) && qIsNaN(noDataValue(bandNo)), but probably
245-
// not important and slower
246-
if ( qIsNaN( value ) ||
247-
doubleNear( value, mNoDataValue ) )
248-
{
249-
return true;
250-
}
251-
return false;
252-
}
253-
254-
double QgsRasterBlock::value( size_t index ) const
255-
{
256-
if ( index >= ( size_t )mWidth*mHeight )
257-
{
258-
QgsDebugMsg( QString( "Index %1 out of range (%2 x %3)" ).arg( index ).arg( mWidth ).arg( mHeight ) );
259-
return mNoDataValue;
260-
}
261-
return readValue( mData, mDataType, index );
262-
}
263-
264242
double QgsRasterBlock::value( int row, int column ) const
265243
{
266244
return value(( size_t )row*mWidth + column );

‎src/core/raster/qgsrasterblock.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,28 @@ inline bool QgsRasterBlock::valueInRange( double value, const QList<QgsRasterBlo
430430
return false;
431431
}
432432

433+
inline double QgsRasterBlock::value( size_t index ) const
434+
{
435+
/*if ( index >= ( size_t )mWidth*mHeight )
436+
{
437+
QgsDebugMsg( QString( "Index %1 out of range (%2 x %3)" ).arg( index ).arg( mWidth ).arg( mHeight ) );
438+
return mNoDataValue;
439+
}*/
440+
return readValue( mData, mDataType, index );
441+
}
442+
443+
inline bool QgsRasterBlock::isNoDataValue( double value ) const
444+
{
445+
// More precise would be qIsNaN(value) && qIsNaN(noDataValue(bandNo)), but probably
446+
// not important and slower
447+
if ( qIsNaN( value ) ||
448+
doubleNear( value, mNoDataValue ) )
449+
{
450+
return true;
451+
}
452+
return false;
453+
}
454+
433455
#endif
434456

435457

‎src/mapserver/qgis_map_serv.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ map service syntax for SOAP/HTTP POST
2929
#include "qgswfsserver.h"
3030
#include "qgsmaprenderer.h"
3131
#include "qgsmapserviceexception.h"
32+
#include "qgspallabeling.h"
3233
#include "qgsprojectparser.h"
3334
#include "qgssldparser.h"
3435
#include <QDomDocument>
@@ -198,6 +199,7 @@ int main( int argc, char * argv[] )
198199

199200
//creating QgsMapRenderer is expensive (access to srs.db), so we do it here before the fcgi loop
200201
QgsMapRenderer* theMapRenderer = new QgsMapRenderer();
202+
theMapRenderer->setLabelingEngine( new QgsPalLabeling() );
201203

202204
while ( fcgi_accept() >= 0 )
203205
{

‎src/mapserver/qgswmsserver.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#include "qgsmaplayerregistry.h"
2525
#include "qgsmaprenderer.h"
2626
#include "qgsmaptopixel.h"
27-
#include "qgspallabeling.h"
2827
#include "qgsproject.h"
2928
#include "qgsrasterlayer.h"
3029
#include "qgsscalecalculator.h"
@@ -941,7 +940,6 @@ QImage* QgsWMSServer::initializeRendering( QStringList& layersList, QStringList&
941940
delete theImage;
942941
return 0;
943942
}
944-
mMapRenderer->setLabelingEngine( new QgsPalLabeling() );
945943

946944
//find out the current scale denominater and set it to the SLD parser
947945
QgsScaleCalculator scaleCalc(( theImage->logicalDpiX() + theImage->logicalDpiY() ) / 2 , mMapRenderer->destinationCrs().mapUnits() );

‎src/plugins/grass/qtermwidget/ColorTables.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
/***************************************************************************
2+
ColorTables.h
3+
---------------------
4+
begin : April 2009
5+
copyright : (C) 2009 by Paolo Cavallini
6+
email : cavallini at faunalia dot it
7+
***************************************************************************
8+
* *
9+
* This program is free software; you can redistribute it and/or modify *
10+
* it under the terms of the GNU General Public License as published by *
11+
* the Free Software Foundation; either version 2 of the License, or *
12+
* (at your option) any later version. *
13+
* *
14+
***************************************************************************/
115
#ifndef _COLOR_TABLE_H
216
#define _COLOR_TABLE_H
317

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,16 @@
1+
/***************************************************************************
2+
DefaultTranslatorText.h
3+
---------------------
4+
begin : April 2009
5+
copyright : (C) 2009 by Paolo Cavallini
6+
email : cavallini at faunalia dot it
7+
***************************************************************************
8+
* *
9+
* This program is free software; you can redistribute it and/or modify *
10+
* it under the terms of the GNU General Public License as published by *
11+
* the Free Software Foundation; either version 2 of the License, or *
12+
* (at your option) any later version. *
13+
* *
14+
***************************************************************************/
115
"keyboard \"Fallback Key Translator\"\n"
216
"key Tab : \"\\t\" \0"

‎src/plugins/grass/qtermwidget/ExtendedDefaultTranslator.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
/***************************************************************************
2+
ExtendedDefaultTranslator.h
3+
---------------------
4+
begin : April 2009
5+
copyright : (C) 2009 by Paolo Cavallini
6+
email : cavallini at faunalia dot it
7+
***************************************************************************
8+
* *
9+
* This program is free software; you can redistribute it and/or modify *
10+
* it under the terms of the GNU General Public License as published by *
11+
* the Free Software Foundation; either version 2 of the License, or *
12+
* (at your option) any later version. *
13+
* *
14+
***************************************************************************/
115
"keyboard \"Default (XFree 4)\""
216
"key Escape : \"\\E\""
317
"key Tab -Shift : \"\\t\"\n"

‎src/plugins/grass/qtermwidget/konsole_wcwidth.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* <http://www.UNIX-systems.org/online.html>
55
*
66
* Markus Kuhn -- 2001-01-12 -- public domain
7+
* this file is in the public domain
78
*/
89

910
#include "konsole_wcwidth.h"

‎src/plugins/grass/qtermwidget/konsole_wcwidth.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
/* Adaptions for KDE by Waldo Bastian <bastian@kde.org> */
33
/*
44
Rewritten for QT4 by e_k <e_k at users.sourceforge.net>
5+
6+
* This file is in the public domain
57
*/
68

79

‎src/providers/gdal/qgsgdalprovider.cpp

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -395,14 +395,17 @@ void QgsGdalProvider::readBlock( int theBandNo, QgsRectangle const & theExtent,
395395

396396
int dataSize = dataTypeSize( theBandNo );
397397

398-
// fill with null values
399-
QByteArray ba = QgsRasterBlock::valueBytes( dataType( theBandNo ), noDataValue( theBandNo ) );
400-
char *nodata = ba.data();
401-
char *block = ( char * ) theBlock;
402-
for ( int i = 0; i < thePixelWidth * thePixelHeight; i++ )
398+
if ( !mExtent.contains( theExtent ) )
403399
{
404-
memcpy( block, nodata, dataSize );
405-
block += dataSize;
400+
// fill with null values
401+
QByteArray ba = QgsRasterBlock::valueBytes( dataType( theBandNo ), noDataValue( theBandNo ) );
402+
char *nodata = ba.data();
403+
char *block = ( char * ) theBlock;
404+
for ( int i = 0; i < thePixelWidth * thePixelHeight; i++ )
405+
{
406+
memcpy( block, nodata, dataSize );
407+
block += dataSize;
408+
}
406409
}
407410

408411
QgsRectangle myRasterExtent = theExtent.intersect( &mExtent );
@@ -561,23 +564,28 @@ void QgsGdalProvider::readBlock( int theBandNo, QgsRectangle const & theExtent,
561564
double tmpXRes = srcWidth * srcXRes / tmpWidth;
562565
double tmpYRes = srcHeight * srcYRes / tmpHeight; // negative
563566

567+
double y = myRasterExtent.yMaximum() - 0.5 * yRes;
564568
for ( int row = 0; row < height; row++ )
565569
{
566-
double y = myRasterExtent.yMaximum() - ( row + 0.5 ) * yRes;
567570
int tmpRow = static_cast<int>( floor( -1. * ( tmpYMax - y ) / tmpYRes ) );
568571

569572
char *srcRowBlock = tmpBlock + dataSize * tmpRow * tmpWidth;
570573
char *dstRowBlock = ( char * )theBlock + dataSize * ( top + row ) * thePixelWidth;
571-
for ( int col = 0; col < width; col++ )
574+
575+
double x = myRasterExtent.xMinimum() + 0.5 * xRes; // cell center
576+
char* dst = dstRowBlock + dataSize * left;
577+
char* src = 0;
578+
int tmpCol = 0;
579+
for ( int col = 0; col < width; ++col )
572580
{
573-
// cell center
574-
double x = myRasterExtent.xMinimum() + ( col + 0.5 ) * xRes;
575581
// floor() is quite slow! Use just cast to int.
576-
int tmpCol = static_cast<int>(( x - tmpXMin ) / tmpXRes ) ;
577-
char *src = srcRowBlock + dataSize * tmpCol;
578-
char *dst = dstRowBlock + dataSize * ( left + col );
582+
tmpCol = static_cast<int>(( x - tmpXMin ) / tmpXRes ) ;
583+
src = srcRowBlock + dataSize * tmpCol;
579584
memcpy( dst, src, dataSize );
585+
dst += dataSize;
586+
x += xRes;
580587
}
588+
y -= yRes;
581589
}
582590

583591
QgsFree( tmpBlock );

‎src/providers/grass/CMakeLists.txt

Lines changed: 72 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,17 @@ ENDIF (APPLE)
5858
# Create list of functions to be mapped
5959
SET ( FUNCTIONS
6060
"G_add_color_rule"
61+
"G_add_c_raster_color_rule"
62+
"G_add_d_raster_color_rule"
63+
"G_add_f_raster_color_rule"
64+
"G_add_raster_color_rule"
6165
"G_adjust_Cell_head"
6266
"G_align_window"
6367
"G_allocate_cell_buf"
68+
"G_allocate_c_raster_buf"
69+
"G_allocate_d_raster_buf"
70+
"G_allocate_f_raster_buf"
71+
"G_allocate_null_buf"
6472
"G_allocate_raster_buf"
6573
"G__calloc"
6674
"G_col_to_easting"
@@ -71,17 +79,17 @@ SET ( FUNCTIONS
7179
"G_define_standard_option"
7280
"G_free"
7381
"G_free_raster_cats"
74-
"G__getenv"
7582
"G_get_fp_range_min_max"
7683
"G_get_range_min_max"
77-
"G_get_window"
7884
"G_get_set_window"
79-
"G__init_null_patterns"
85+
"G_gettext"
86+
"G_get_window"
8087
"G_incr_void_ptr"
8188
"G_init_colors"
8289
"G_init_fp_range"
83-
"G_init_raster_cats"
90+
"G__init_null_patterns"
8491
"G_init_range"
92+
"G_init_raster_cats"
8593
"G_is_c_null_value"
8694
"G_is_d_null_value"
8795
"G_is_f_null_value"
@@ -93,19 +101,20 @@ SET ( FUNCTIONS
93101
"G_quant_free"
94102
"G_quant_get_limits"
95103
"G_quant_init"
96-
"G__realloc"
97104
"G_raster_size"
105+
"G__realloc"
98106
"G_row_to_northing"
99107
"G_set_c_null_value"
100108
"G_set_d_null_value"
101-
"G_set_f_null_value"
102109
"G_set_d_raster_cat"
110+
"G_setenv"
111+
"G_set_f_null_value"
103112
"G_set_gisrc_mode"
104113
"G_set_null_value"
114+
"G_set_raster_cat"
105115
"G_set_raster_cats_title"
106116
"G_set_raster_value_d"
107117
"G_set_window"
108-
"G_setenv"
109118
"G_strip"
110119
"G_suppress_masking"
111120
"G_trim_decimal"
@@ -116,60 +125,79 @@ SET ( FUNCTIONS
116125
"G_zero"
117126
)
118127

128+
# If a function, say G_1 called in true GRASS gis lib (loaded by QLibrary)
129+
# calls another function G_2 which does not have to be reimplemented in gis fake lib:
130+
# - on Linux: G_2 is resolved in original GRASS true gis lib and it is not necessary
131+
# to add it to functions mapped in fake lib
132+
# - on Windows: it seems that dynamic linker is searching for G_2 in the first loaded
133+
# module of the same name, i.e. in our fake library, not in the original
134+
# true GRASS gis lib, so we have to add all functions called in true lib
135+
# also to mapped functions in fake lib
136+
137+
IF(MSVC)
138+
SET ( FUNCTIONS
139+
${FUNCTIONS}
140+
"G__getenv"
141+
)
142+
ENDIF(MSVC)
143+
119144
# List of functions which are implemented in qgsgrassgislib.cpp and
120145
# thus we only need prototype
121146
SET ( FUNCTION_PROTOTYPES
122-
"G__gisinit"
123-
"G_parser"
124-
"G_set_error_routine"
125-
"G_warning"
126-
"G_fatal_error"
127-
"G_done_msg"
128-
"*G_find_cell2"
129-
"*G_find_cell"
130-
"G_open_cell_old"
147+
"G_asprintf"
148+
"G_begin_distance_calculations"
149+
"G_check_input_output_name"
131150
"G_close_cell"
132-
"G_open_raster_new"
133-
"G_open_cell_new"
134-
"G_raster_map_is_fp"
135-
"G_read_fp_range"
136-
"G_read_range"
151+
"G_command_history"
152+
"G_database_units_to_meters_factor"
137153
"G_debug"
138-
"G_message"
139-
"G_verbose_message"
140-
"G_set_quant_rules"
141-
"G_get_raster_row"
142-
"G_get_raster_row_nomask"
154+
"G_distance"
155+
"G_done_msg"
156+
"G_fatal_error"
157+
"G_find_cell"
158+
"G_find_cell2"
159+
"G_get_cellhd"
143160
"G_get_c_raster_row"
144161
"G_get_c_raster_row_nomask"
145-
"G_get_f_raster_row"
146-
"G_get_f_raster_row_nomask"
147162
"G_get_d_raster_row"
148163
"G_get_d_raster_row_nomask"
164+
"G_get_f_raster_row"
165+
"G_get_f_raster_row_nomask"
149166
"G_get_map_row"
150167
"G_get_map_row_nomask"
151-
"G_put_raster_row"
152-
"G_check_input_output_name"
153-
"G_get_cellhd"
154-
"G_database_units_to_meters_factor"
155-
"G_begin_distance_calculations"
156-
"G_distance"
168+
"G_get_raster_map_type"
169+
"G_get_raster_row"
170+
"G_get_raster_row_nomask"
171+
"G__gisinit"
157172
"G_legal_filename"
158-
"G_tempfile"
159-
"G_mapset"
160173
"G_location"
161-
"G_write_colors"
174+
"G_make_aspect_fp_colors"
175+
"G_mapset"
176+
"G_maskfd"
177+
"G_message"
178+
"G_open_cell_new"
179+
"G_open_cell_old"
180+
"G_open_raster_new"
181+
"G_parser"
182+
"G_put_raster_row"
162183
"G_quantize_fp_map_range"
184+
"G_raster_map_is_fp"
185+
"G_read_colors"
186+
"G_read_fp_range"
187+
"G_read_history"
188+
"G_read_range"
163189
"G_read_raster_cats"
164-
"G_write_raster_cats"
190+
"G_set_cats_title"
191+
"G_set_error_routine"
192+
"G_set_quant_rules"
165193
"G_short_history"
194+
"G_tempfile"
195+
"G_vasprintf"
196+
"G_verbose_message"
197+
"G_warning"
198+
"G_write_colors"
166199
"G_write_history"
167-
"G_maskfd"
168-
"G_command_history"
169-
"G_set_cats_title"
170-
"G_read_history"
171-
"G_read_colors"
172-
"G_make_aspect_fp_colors"
200+
"G_write_raster_cats"
173201
)
174202

175203
SET ( FUNCTIONS_ALL

‎src/providers/grass/qgsgrassgislib.cpp

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
#include <stdarg.h>
1919
#include <QtGlobal>
2020

21-
// If qgsgrassgislibfunctions.h is included on Linux, symbols defined here
22-
// cannot be found (undefined symbol error) even if they are present in
23-
// the library (in code section) - why?
21+
// If qgsgrassgislibfunctions.h is included on Linux, symbols defined here
22+
// cannot be found (undefined symbol error) even if they are present in
23+
// the library (in code section) - why?
2424
#ifdef Q_OS_WIN
2525
#include "qgsgrassgislibfunctions.h"
2626
#endif
@@ -975,6 +975,24 @@ RASTER_MAP_TYPE QgsGrassGisLib::grassRasterType( QgsRasterBlock::DataType qgisTy
975975
}
976976
}
977977

978+
typedef int G_vasprintf_type( char **, const char *, va_list );
979+
int G_vasprintf( char **out, const char *fmt, va_list ap )
980+
{
981+
G_vasprintf_type* fn = ( G_vasprintf_type* ) cast_to_fptr( QgsGrassGisLib::instance()->resolve( "G_vasprintf_type" ) );
982+
return fn( out, fmt, ap );
983+
}
984+
985+
typedef int G_asprintf_type( char **, const char *, ... );
986+
int G_asprintf( char **out, const char *fmt, ... )
987+
{
988+
G_asprintf_type* fn = ( G_asprintf_type* ) cast_to_fptr( QgsGrassGisLib::instance()->resolve( "G_asprintf_type" ) );
989+
va_list ap;
990+
va_start( ap, fmt );
991+
int ret = fn( out, fmt, ap );
992+
va_end( ap );
993+
return ret;
994+
}
995+
978996
char GRASS_LIB_EXPORT *G_tempfile( void )
979997
{
980998
QTemporaryFile file( "qgis-grass-temp.XXXXXX" );

‎tests/qt_modeltest/dynamictreemodel.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
**
77
** This file is part of the test suite of the Qt Toolkit.
88
**
9+
** This file is free software: you can redistribute it and/or modify
10+
** it under the terms of the GNU General Public License as published by
11+
** the Free Software Foundation, either version 3 of the License, or
12+
** (at your option) any later version.
13+
**
914
** $QT_BEGIN_LICENSE:LGPL$
1015
** GNU Lesser General Public License Usage
1116
** This file may be used under the terms of the GNU Lesser General Public

‎tests/qt_modeltest/dynamictreemodel.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
**
77
** This file is part of the test suite of the Qt Toolkit.
88
**
9+
** This file is free software: you can redistribute it and/or modify
10+
** it under the terms of the GNU General Public License as published by
11+
** the Free Software Foundation, either version 3 of the License, or
12+
** (at your option) any later version.
13+
**
914
** $QT_BEGIN_LICENSE:LGPL$
1015
** GNU Lesser General Public License Usage
1116
** This file may be used under the terms of the GNU Lesser General Public

‎tests/qt_modeltest/modeltest.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
**
77
** This file is part of the test suite of the Qt Toolkit.
88
**
9+
** This file is free software: you can redistribute it and/or modify
10+
** it under the terms of the GNU General Public License as published by
11+
** the Free Software Foundation, either version 3 of the License, or
12+
** (at your option) any later version.
13+
**
914
** $QT_BEGIN_LICENSE:LGPL$
1015
** GNU Lesser General Public License Usage
1116
** This file may be used under the terms of the GNU Lesser General Public

‎tests/qt_modeltest/modeltest.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
**
77
** This file is part of the test suite of the Qt Toolkit.
88
**
9+
** This file is free software: you can redistribute it and/or modify
10+
** it under the terms of the GNU General Public License as published by
11+
** the Free Software Foundation, either version 3 of the License, or
12+
** (at your option) any later version.
13+
**
914
** $QT_BEGIN_LICENSE:LGPL$
1015
** GNU Lesser General Public License Usage
1116
** This file may be used under the terms of the GNU Lesser General Public

‎tests/qt_modeltest/tst_modeltest.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
**
77
** This file is part of the test suite of the Qt Toolkit.
88
**
9+
** This file is free software: you can redistribute it and/or modify
10+
** it under the terms of the GNU General Public License as published by
11+
** the Free Software Foundation, either version 3 of the License, or
12+
** (at your option) any later version.
13+
**
914
** $QT_BEGIN_LICENSE:LGPL$
1015
** GNU Lesser General Public License Usage
1116
** This file may be used under the terms of the GNU Lesser General Public

2 commit comments

Comments
 (2)

slarosa commented on Dec 12, 2012

@slarosa
Member

Hi Victor,
Something seems gone wrong in this commit ! I cannot build anymore !
Please, could you fix it ?

Thanks !

slarosa commented on Dec 12, 2012

@slarosa
Member

Sorry, I meant this commit 7197a31

Please sign in to comment.