Skip to content

Commit 3f9ac65

Browse files
author
rblazek
committedApr 16, 2011
raster layer update - first step
git-svn-id: http://svn.osgeo.org/qgis/trunk@15735 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent e93c184 commit 3f9ac65

File tree

8 files changed

+111
-11
lines changed

8 files changed

+111
-11
lines changed
 

‎src/app/qgsrasterlayerproperties.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer* lyr, QgsMapCanv
9292
connect( leBlueMax, SIGNAL( textEdited( QString ) ), this, SLOT( userDefinedMinMax_textEdited( QString ) ) );
9393
connect( mColormapTreeWidget, SIGNAL( itemDoubleClicked( QTreeWidgetItem*, int ) ), this, SLOT( handleColormapTreeWidgetDoubleClick( QTreeWidgetItem*, int ) ) );
9494

95+
connect( mRasterLayer, SIGNAL( dataChanged( int ) ), this, SLOT( dataChanged( int ) ) );
96+
9597
// set up the scale based layer visibility stuff....
9698
chkUseScaleDependentRendering->setChecked( lyr->hasScaleBasedVisibility() );
9799
leMinimumScale->setText( QString::number( lyr->minimumScale(), 'f' ) );
@@ -3033,3 +3035,8 @@ void QgsRasterLayerProperties::on_btnResetNull_clicked( )
30333035
leNoDataValue->clear();
30343036
}
30353037
}
3038+
3039+
void QgsRasterLayerProperties::dataChanged( int change )
3040+
{
3041+
QgsDebugMsg( "entered." );
3042+
}

‎src/app/qgsrasterlayerproperties.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ class QgsRasterLayerProperties : public QDialog, private Ui::QgsRasterLayerPrope
9999
/** \brief this slot sets StdDev switch box to 0.00 when user enters min max values */
100100
void userDefinedMinMax_textEdited( QString );
101101

102+
/** \brief data changed reciever */
103+
void dataChanged( int change );
104+
102105
private slots:
103106
/** This slow handles necessary interface modifications (i.e. loading min max values) */
104107
void on_cboBlue_currentIndexChanged( const QString& );

‎src/core/qgsdataprovider.h

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#ifndef QQGSDATAPROVIDER_H
1818
#define QQGSDATAPROVIDER_H
1919

20-
20+
#include <QDateTime>
2121
#include <QObject>
2222
#include <QString>
2323
#include <QStringList>
@@ -271,6 +271,15 @@ class CORE_EXPORT QgsDataProvider : public QObject
271271
synchronize with changes in the data source*/
272272
virtual void reloadData() {}
273273

274+
/** Time stamp of data source in the moment when data/metadata were loaded by provider */
275+
virtual QDateTime timestamp() const { return mTimestamp; }
276+
277+
/** Current time stamp of data source */
278+
virtual QDateTime dataTimestamp() const { return QDateTime(); }
279+
280+
/** test if at least one of specified data/metadata changed since provider was loaded */
281+
virtual bool changed( int change ) { return false; }
282+
274283
signals:
275284

276285
/**
@@ -287,6 +296,13 @@ class CORE_EXPORT QgsDataProvider : public QObject
287296
*/
288297
void dataChanged();
289298

299+
/**
300+
* This is emitted whenever data or metadata (e.g. color table, extent) has changed
301+
* @param changed binary combination of changes
302+
* @note added in 1.7
303+
*/
304+
void dataChanged( int change );
305+
290306
private:
291307

292308
/**
@@ -295,6 +311,10 @@ class CORE_EXPORT QgsDataProvider : public QObject
295311
*/
296312
QString mDataSourceURI;
297313

314+
/**
315+
* Timestamp of data in the moment when the data were loaded by provider.
316+
*/
317+
QDateTime mTimestamp;
298318
};
299319

300320

‎src/core/qgsrasterdataprovider.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#ifndef QGSRASTERDATAPROVIDER_H
2222
#define QGSRASTERDATAPROVIDER_H
2323

24+
#include <QDateTime>
25+
2426
#include "qgslogger.h"
2527
#include "qgsrectangle.h"
2628
#include "qgsdataprovider.h"
@@ -114,6 +116,17 @@ class CORE_EXPORT QgsRasterDataProvider : public QgsDataProvider
114116
ProgressPyramids = 1
115117
};
116118

119+
enum Change
120+
{
121+
NoChange = 0,
122+
ValuesChange = 1,
123+
ExtentChange = 1 << 1,
124+
CrsChange = 1 << 2,
125+
DataTypeChange = 1 << 3,
126+
ColorTableChange = 1 << 4,
127+
SizeChange = 1 << 5
128+
};
129+
117130
QgsRasterDataProvider();
118131

119132
QgsRasterDataProvider( QString const & uri );
@@ -467,11 +480,24 @@ class CORE_EXPORT QgsRasterDataProvider : public QgsDataProvider
467480
/** \brief Set null value in char */
468481
QByteArray noValueBytes( int theBandNo );
469482

483+
/** Current time stamp of data source */
484+
virtual QDateTime dataTimestamp() const { return QDateTime(); }
485+
486+
/** Give list of changed data/metadata since provider was loaded */
487+
virtual int changed( ) { return NoChange; }
488+
470489
signals:
471490
/** Emit a signal to notify of the progress event.
472491
* Emited theProgress is in percents (0.0-100.0) */
473492
void progress( int theType, double theProgress, QString theMessage );
474493

494+
/**
495+
* This is emitted whenever data or metadata (e.g. color table, extent) has changed
496+
* @param changed binary combination of changes
497+
* @note added in 1.7
498+
*/
499+
void dataChanged( int change );
500+
475501
protected:
476502
/**Dots per intch. Extended WMS (e.g. QGIS mapserver) support DPI dependent output and therefore
477503
are suited for printing. A value of -1 means it has not been set

‎src/core/raster/qgsrasterlayer.cpp

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2479,7 +2479,7 @@ void QgsRasterLayer::setDataProvider( QString const & provider,
24792479
// read standard deviations
24802480
if ( mContrastEnhancementAlgorithm == QgsContrastEnhancement::StretchToMinimumMaximum )
24812481
{
2482-
setStandardDeviations( myQSettings.value( "/Raster/defaultStandardDeviation", 1.0 ).toInt() );
2482+
setStandardDeviations( myQSettings.value( "/Raster/defaultStandardDeviation", 1.0 ).toInt() );
24832483
}
24842484
}
24852485
// Debug
@@ -4414,18 +4414,41 @@ double QgsRasterLayer::readValue( void *data, int type, int index )
44144414
bool QgsRasterLayer::update()
44154415
{
44164416
QgsDebugMsg( "entered." );
4417-
4418-
if ( mLastModified < QgsRasterLayer::lastModified( source() ) )
4417+
// Check if data changed
4418+
//if ( mLastModified < QgsRasterLayer::lastModified( source() ) )
4419+
//{
4420+
// TODO: lastModified to provider -> outdated
4421+
// TODO: check what has to be cleard, rebuild
4422+
int change = mDataProvider->changed();
4423+
if ( change != QgsRasterDataProvider::NoChange )
44194424
{
4420-
// TODO: lastModified to provider -> outdated
4421-
// TODO: check what has to be cleard, rebuild
4422-
mHasPyramids = false;
4423-
mPyramidList.clear();
4425+
QgsDebugMsg( "reload data" );
4426+
//mHasPyramids = false;
4427+
//mPyramidList.clear();
44244428

4425-
mRasterStatsList.clear();
4429+
//mRasterStatsList.clear();
44264430
mValid = mDataProvider->reload();
4431+
4432+
for ( int i = 1; i <= mBandCount; i++ )
4433+
{
4434+
// TODO : refresh all data, move to separate method from constructor
4435+
// Reload color table
4436+
if ( i - 1 < mRasterStatsList.size() )
4437+
{
4438+
QList<QgsColorRampShader::ColorRampItem> ct;
4439+
ct = mDataProvider->colorTable( i );
4440+
4441+
mRasterStatsList[i-1].colorTable = ct;
4442+
if ( mRasterType == Palette )
4443+
{
4444+
QgsColorRampShader* myColorRampShader = ( QgsColorRampShader* ) mRasterShader->rasterShaderFunction();
4445+
myColorRampShader->setColorRampItemList( *colorTable( 1 ) );
4446+
}
4447+
}
4448+
}
4449+
emit dataChanged( change );
44274450
}
4428-
return true;
4451+
return mValid;
44294452
}
44304453

44314454
bool QgsRasterLayer::usesProvider()

‎src/core/raster/qgsrasterlayer.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,13 @@ class CORE_EXPORT QgsRasterLayer : public QgsMapLayer
681681
/** \brief Signal for notifying listeners of long running processes */
682682
void progressUpdate( int theValue );
683683

684+
/**
685+
* This is emitted whenever data or metadata (e.g. color table, extent) has changed
686+
* @param changed binary combination of changes, defined in QgsRasterDataProvider
687+
* @note added in 1.7
688+
*/
689+
void dataChanged( int change );
690+
684691
protected:
685692

686693
/** \brief Read the symbology for the current layer from the Dom node supplied */

‎src/providers/grass/qgsgrassrasterprovider.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ double QgsGrassRasterProvider::maximumValue( int bandNo ) const
275275

276276
QList<QgsColorRampShader::ColorRampItem> QgsGrassRasterProvider::colorTable( int bandNo )const
277277
{
278+
QgsDebugMsg( "Entered" );
278279
QList<QgsColorRampShader::ColorRampItem> ct;
279280

280281
// TODO: check if color can be realy discontinuous in GRASS,
@@ -484,6 +485,18 @@ QString QgsGrassRasterProvider::description() const
484485
return PROVIDER_DESCRIPTION;
485486
}
486487

488+
int QgsGrassRasterProvider::changed()
489+
{
490+
QgsDebugMsg( "Entered" );
491+
// TODO
492+
return ValuesChange | ExtentChange | CrsChange | DataTypeChange | ColorTableChange | SizeChange;
493+
}
494+
495+
bool QgsGrassRasterProvider::reload()
496+
{
497+
QgsDebugMsg( "Entered" );
498+
return true;
499+
}
487500
//void QgsGrassRasterProvider::buildSupportedRasterFileFilter( QString & theFileFiltersString )
488501
//{
489502
//}

‎src/providers/grass/qgsgrassrasterprovider.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,8 @@ class QgsGrassRasterProvider : public QgsRasterDataProvider
244244
bool theThoroughBandScanFlag = false
245245
);
246246

247-
247+
int changed( );
248+
bool reload( );
248249
private:
249250

250251
/**

0 commit comments

Comments
 (0)