Skip to content

Commit

Permalink
raster layer update - first step
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@15735 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
rblazek committed Apr 16, 2011
1 parent a09158c commit 87460ac
Show file tree
Hide file tree
Showing 8 changed files with 111 additions and 11 deletions.
7 changes: 7 additions & 0 deletions src/app/qgsrasterlayerproperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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' ) );
Expand Down Expand Up @@ -3033,3 +3035,8 @@ void QgsRasterLayerProperties::on_btnResetNull_clicked( )
leNoDataValue->clear();
}
}

void QgsRasterLayerProperties::dataChanged( int change )
{
QgsDebugMsg( "entered." );
}
3 changes: 3 additions & 0 deletions src/app/qgsrasterlayerproperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -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& );
Expand Down
22 changes: 21 additions & 1 deletion src/core/qgsdataprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#ifndef QQGSDATAPROVIDER_H
#define QQGSDATAPROVIDER_H


#include <QDateTime>
#include <QObject>
#include <QString>
#include <QStringList>
Expand Down Expand Up @@ -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:

/**
Expand All @@ -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:

/**
Expand All @@ -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;
};


Expand Down
26 changes: 26 additions & 0 deletions src/core/qgsrasterdataprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#ifndef QGSRASTERDATAPROVIDER_H
#define QGSRASTERDATAPROVIDER_H

#include <QDateTime>

#include "qgslogger.h"
#include "qgsrectangle.h"
#include "qgsdataprovider.h"
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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
Expand Down
41 changes: 32 additions & 9 deletions src/core/raster/qgsrasterlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
7 changes: 7 additions & 0 deletions src/core/raster/qgsrasterlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
13 changes: 13 additions & 0 deletions src/providers/grass/qgsgrassrasterprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 )
//{
//}
Expand Down
3 changes: 2 additions & 1 deletion src/providers/grass/qgsgrassrasterprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,8 @@ class QgsGrassRasterProvider : public QgsRasterDataProvider
bool theThoroughBandScanFlag = false
);


int changed( );
bool reload( );
private:

/**
Expand Down

0 comments on commit 87460ac

Please sign in to comment.