raster layer update - first step

git-svn-id: http://svn.osgeo.org/qgis/trunk@15735 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
rblazek 2011-04-16 19:03:21 +00:00
parent e93c18416f
commit 3f9ac65f7f
8 changed files with 111 additions and 11 deletions

View File

@ -92,6 +92,8 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer* lyr, QgsMapCanv
connect( leBlueMax, SIGNAL( textEdited( QString ) ), this, SLOT( userDefinedMinMax_textEdited( QString ) ) );
connect( mColormapTreeWidget, SIGNAL( itemDoubleClicked( QTreeWidgetItem*, int ) ), this, SLOT( handleColormapTreeWidgetDoubleClick( QTreeWidgetItem*, int ) ) );
connect( mRasterLayer, SIGNAL( dataChanged( int ) ), this, SLOT( dataChanged( int ) ) );
// set up the scale based layer visibility stuff....
chkUseScaleDependentRendering->setChecked( lyr->hasScaleBasedVisibility() );
leMinimumScale->setText( QString::number( lyr->minimumScale(), 'f' ) );
@ -3033,3 +3035,8 @@ void QgsRasterLayerProperties::on_btnResetNull_clicked( )
leNoDataValue->clear();
}
}
void QgsRasterLayerProperties::dataChanged( int change )
{
QgsDebugMsg( "entered." );
}

View File

@ -99,6 +99,9 @@ class QgsRasterLayerProperties : public QDialog, private Ui::QgsRasterLayerPrope
/** \brief this slot sets StdDev switch box to 0.00 when user enters min max values */
void userDefinedMinMax_textEdited( QString );
/** \brief data changed reciever */
void dataChanged( int change );
private slots:
/** This slow handles necessary interface modifications (i.e. loading min max values) */
void on_cboBlue_currentIndexChanged( const QString& );

View File

@ -17,7 +17,7 @@
#ifndef QQGSDATAPROVIDER_H
#define QQGSDATAPROVIDER_H
#include <QDateTime>
#include <QObject>
#include <QString>
#include <QStringList>
@ -271,6 +271,15 @@ class CORE_EXPORT QgsDataProvider : public QObject
synchronize with changes in the data source*/
virtual void reloadData() {}
/** Time stamp of data source in the moment when data/metadata were loaded by provider */
virtual QDateTime timestamp() const { return mTimestamp; }
/** Current time stamp of data source */
virtual QDateTime dataTimestamp() const { return QDateTime(); }
/** test if at least one of specified data/metadata changed since provider was loaded */
virtual bool changed( int change ) { return false; }
signals:
/**
@ -287,6 +296,13 @@ class CORE_EXPORT QgsDataProvider : public QObject
*/
void dataChanged();
/**
* This is emitted whenever data or metadata (e.g. color table, extent) has changed
* @param changed binary combination of changes
* @note added in 1.7
*/
void dataChanged( int change );
private:
/**
@ -295,6 +311,10 @@ class CORE_EXPORT QgsDataProvider : public QObject
*/
QString mDataSourceURI;
/**
* Timestamp of data in the moment when the data were loaded by provider.
*/
QDateTime mTimestamp;
};

View File

@ -21,6 +21,8 @@
#ifndef QGSRASTERDATAPROVIDER_H
#define QGSRASTERDATAPROVIDER_H
#include <QDateTime>
#include "qgslogger.h"
#include "qgsrectangle.h"
#include "qgsdataprovider.h"
@ -114,6 +116,17 @@ class CORE_EXPORT QgsRasterDataProvider : public QgsDataProvider
ProgressPyramids = 1
};
enum Change
{
NoChange = 0,
ValuesChange = 1,
ExtentChange = 1 << 1,
CrsChange = 1 << 2,
DataTypeChange = 1 << 3,
ColorTableChange = 1 << 4,
SizeChange = 1 << 5
};
QgsRasterDataProvider();
QgsRasterDataProvider( QString const & uri );
@ -467,11 +480,24 @@ class CORE_EXPORT QgsRasterDataProvider : public QgsDataProvider
/** \brief Set null value in char */
QByteArray noValueBytes( int theBandNo );
/** Current time stamp of data source */
virtual QDateTime dataTimestamp() const { return QDateTime(); }
/** Give list of changed data/metadata since provider was loaded */
virtual int changed( ) { return NoChange; }
signals:
/** Emit a signal to notify of the progress event.
* Emited theProgress is in percents (0.0-100.0) */
void progress( int theType, double theProgress, QString theMessage );
/**
* This is emitted whenever data or metadata (e.g. color table, extent) has changed
* @param changed binary combination of changes
* @note added in 1.7
*/
void dataChanged( int change );
protected:
/**Dots per intch. Extended WMS (e.g. QGIS mapserver) support DPI dependent output and therefore
are suited for printing. A value of -1 means it has not been set

View File

@ -2479,7 +2479,7 @@ void QgsRasterLayer::setDataProvider( QString const & provider,
// read standard deviations
if ( mContrastEnhancementAlgorithm == QgsContrastEnhancement::StretchToMinimumMaximum )
{
setStandardDeviations( myQSettings.value( "/Raster/defaultStandardDeviation", 1.0 ).toInt() );
setStandardDeviations( myQSettings.value( "/Raster/defaultStandardDeviation", 1.0 ).toInt() );
}
}
// Debug
@ -4414,18 +4414,41 @@ double QgsRasterLayer::readValue( void *data, int type, int index )
bool QgsRasterLayer::update()
{
QgsDebugMsg( "entered." );
if ( mLastModified < QgsRasterLayer::lastModified( source() ) )
// Check if data changed
//if ( mLastModified < QgsRasterLayer::lastModified( source() ) )
//{
// TODO: lastModified to provider -> outdated
// TODO: check what has to be cleard, rebuild
int change = mDataProvider->changed();
if ( change != QgsRasterDataProvider::NoChange )
{
// TODO: lastModified to provider -> outdated
// TODO: check what has to be cleard, rebuild
mHasPyramids = false;
mPyramidList.clear();
QgsDebugMsg( "reload data" );
//mHasPyramids = false;
//mPyramidList.clear();
mRasterStatsList.clear();
//mRasterStatsList.clear();
mValid = mDataProvider->reload();
for ( int i = 1; i <= mBandCount; i++ )
{
// TODO : refresh all data, move to separate method from constructor
// Reload color table
if ( i - 1 < mRasterStatsList.size() )
{
QList<QgsColorRampShader::ColorRampItem> ct;
ct = mDataProvider->colorTable( i );
mRasterStatsList[i-1].colorTable = ct;
if ( mRasterType == Palette )
{
QgsColorRampShader* myColorRampShader = ( QgsColorRampShader* ) mRasterShader->rasterShaderFunction();
myColorRampShader->setColorRampItemList( *colorTable( 1 ) );
}
}
}
emit dataChanged( change );
}
return true;
return mValid;
}
bool QgsRasterLayer::usesProvider()

View File

@ -681,6 +681,13 @@ class CORE_EXPORT QgsRasterLayer : public QgsMapLayer
/** \brief Signal for notifying listeners of long running processes */
void progressUpdate( int theValue );
/**
* This is emitted whenever data or metadata (e.g. color table, extent) has changed
* @param changed binary combination of changes, defined in QgsRasterDataProvider
* @note added in 1.7
*/
void dataChanged( int change );
protected:
/** \brief Read the symbology for the current layer from the Dom node supplied */

View File

@ -275,6 +275,7 @@ double QgsGrassRasterProvider::maximumValue( int bandNo ) const
QList<QgsColorRampShader::ColorRampItem> QgsGrassRasterProvider::colorTable( int bandNo )const
{
QgsDebugMsg( "Entered" );
QList<QgsColorRampShader::ColorRampItem> ct;
// TODO: check if color can be realy discontinuous in GRASS,
@ -484,6 +485,18 @@ QString QgsGrassRasterProvider::description() const
return PROVIDER_DESCRIPTION;
}
int QgsGrassRasterProvider::changed()
{
QgsDebugMsg( "Entered" );
// TODO
return ValuesChange | ExtentChange | CrsChange | DataTypeChange | ColorTableChange | SizeChange;
}
bool QgsGrassRasterProvider::reload()
{
QgsDebugMsg( "Entered" );
return true;
}
//void QgsGrassRasterProvider::buildSupportedRasterFileFilter( QString & theFileFiltersString )
//{
//}

View File

@ -244,7 +244,8 @@ class QgsGrassRasterProvider : public QgsRasterDataProvider
bool theThoroughBandScanFlag = false
);
int changed( );
bool reload( );
private:
/**