Skip to content
Permalink
Browse files

Merge branch 'master' of github.com:qgis/Quantum-GIS

  • Loading branch information
timlinux committed Jun 14, 2012
2 parents f3f1c43 + 9a006e4 commit 42a5eb9203ac6840d6f25119328dd882081eee94
Showing with 694 additions and 514 deletions.
  1. +5 −14 python/core/qgsrasterlayer.sip
  2. +189 −0 python/core/qgsrasterrenderer.sip
  3. +47 −0 python/core/qgsrasterresampler.sip
  4. +1 −1 python/gui/qgisinterface.sip
  5. +1 −1 src/app/legend/qgslegend.cpp
  6. +10 −43 src/app/qgisapp.cpp
  7. +2 −9 src/app/qgisapp.h
  8. +2 −3 src/app/qgisappinterface.cpp
  9. +1 −2 src/app/qgisappinterface.h
  10. +2 −28 src/app/qgsbrowserdockwidget.cpp
  11. +1 −27 src/browser/qgsbrowser.cpp
  12. +1 −6 src/core/qgsbrowsermodel.cpp
  13. +60 −0 src/core/qgsdatasourceuri.cpp
  14. +42 −0 src/core/qgsdatasourceuri.h
  15. +78 −0 src/core/qgsmaplayer.cpp
  16. +6 −4 src/core/qgsprojectfiletransform.cpp
  17. +1 −1 src/core/qgsprojectfiletransform.h
  18. +1 −1 src/core/raster/qgsbilinearrasterresampler.h
  19. +1 −1 src/core/raster/qgscubicrasterresampler.h
  20. +4 −4 src/core/raster/qgsmultibandcolorrenderer.cpp
  21. +1 −1 src/core/raster/qgsmultibandcolorrenderer.h
  22. +3 −3 src/core/raster/qgspalettedrasterrenderer.cpp
  23. +1 −1 src/core/raster/qgspalettedrasterrenderer.h
  24. +59 −141 src/core/raster/qgsrasterlayer.cpp
  25. +9 −29 src/core/raster/qgsrasterlayer.h
  26. +4 −4 src/core/raster/qgsrasterrenderer.cpp
  27. +2 −2 src/core/raster/qgsrasterrenderer.h
  28. +2 −2 src/core/raster/qgsrasterrendererregistry.h
  29. +1 −1 src/core/raster/qgsrastershader.cpp
  30. +1 −1 src/core/raster/qgssinglebandgrayrenderer.cpp
  31. +1 −1 src/core/raster/qgssinglebandgrayrenderer.h
  32. +1 −1 src/core/raster/qgssinglebandpseudocolorrenderer.cpp
  33. +1 −1 src/core/raster/qgssinglebandpseudocolorrenderer.h
  34. +1 −2 src/gui/qgisinterface.h
  35. +1 −1 src/gui/raster/qgsmultibandcolorrendererwidget.h
  36. +1 −1 src/gui/raster/qgspalettedrendererwidget.h
  37. +1 −1 src/gui/raster/qgsrasterrendererwidget.h
  38. +1 −1 src/gui/raster/qgssinglebandgrayrendererwidget.h
  39. +1 −1 src/gui/raster/qgssinglebandpseudocolorrendererwidget.h
  40. +8 −1 src/mapserver/qgsremoteowsbuilder.cpp
  41. +1 −2 src/plugins/grass/qgsgrassbrowser.cpp
  42. +1 −2 src/plugins/grass/qgsgrassmodule.cpp
  43. +1 −2 src/plugins/grass/qgsgrassplugin.cpp
  44. +15 −2 src/providers/wms/qgswmsconnection.cpp
  45. +3 −0 src/providers/wms/qgswmsconnection.h
  46. +18 −25 src/providers/wms/qgswmsdataitems.cpp
  47. +3 −2 src/providers/wms/qgswmsdataitems.h
  48. +73 −111 src/providers/wms/qgswmsprovider.cpp
  49. +2 −0 src/providers/wms/qgswmsprovider.h
  50. +19 −22 src/providers/wms/qgswmssourceselect.cpp
  51. +3 −5 src/providers/wms/qgswmssourceselect.h
@@ -35,15 +35,10 @@ public:
bool loadDefaultStyleFlag = true );

/** \brief [ data provider interface ] Constructor in provider mode */
QgsRasterLayer( int dummy,
const QString & baseName = QString(),
const QString & path = QString(),
const QString & providerLib = QString(),
const QStringList & layers = QStringList(),
const QStringList & styles = QStringList(),
const QString & format = QString(),
const QString & crs = QString());

QgsRasterLayer( const QString & uri,
const QString & baseName,
const QString & providerKey,
bool loadDefaultStyleFlag = true );

/** \brief The destructor */
~QgsRasterLayer();
@@ -195,11 +190,7 @@ public:
QString redBandName();

/** [ data provider interface ] Set the data provider */
void setDataProvider( const QString & provider,
const QStringList & layers,
const QStringList & styles,
const QString & format,
const QString & crs );
void setDataProvider( const QString & provider );

/** \brief Mutator for drawing style */
void setDrawingStyle( const DrawingStyle & theDrawingStyle );
@@ -0,0 +1,189 @@
class QgsRasterRenderer
{
%TypeHeaderCode
#include "qgsrasterrenderer.h"
#include "qgspalettedrasterrenderer.h"
#include "qgsmultibandcolorrenderer.h"
#include "qgssinglebandpseudocolorrenderer.h"
#include "qgssinglebandgrayrenderer.h"
#include "qgssinglebandcolordatarenderer.h"
%End

%ConvertToSubClassCode
if (dynamic_cast<QgsPalettedRasterRenderer*>(sipCpp) != NULL)
sipClass = sipClass_QgsPalettedRasterRenderer;
else if (dynamic_cast<QgsMultiBandColorRenderer*>(sipCpp) != NULL)
sipClass = sipClass_QgsMultiBandColorRenderer;
else if (dynamic_cast<QgsSingleBandPseudoColorRenderer*>(sipCpp) != NULL)
sipClass = sipClass_QgsSingleBandPseudoColorRenderer;
else if (dynamic_cast<QgsSingleBandGrayRenderer*>(sipCpp) != NULL)
sipClass = sipClass_QgsSingleBandGrayRenderer;
else if (dynamic_cast<QgsSingleBandGrayRenderer*>(sipCpp) != NULL)
sipClass = sipClass_QgsSingleBandGrayRenderer;
else
sipClass = 0;
%End

public:
QgsRasterRenderer( QgsRasterDataProvider* provider, const QString& type );
virtual ~QgsRasterRenderer();

virtual QString type() const;
virtual void draw( QPainter* p, QgsRasterViewPort* viewPort, const QgsMapToPixel* theQgsMapToPixel ) = 0;

bool usesTransparency( QgsCoordinateReferenceSystem& srcSRS, QgsCoordinateReferenceSystem& dstSRS ) const;

void setOpacity( double opacity );
double opacity() const;

void setRasterTransparency( QgsRasterTransparency* t );
const QgsRasterTransparency* rasterTransparency() const;

void setAlphaBand( int band );
int alphaBand() const;

void setInvertColor( bool invert );
bool invertColor() const;

/**Set resampler for zoomed in scales. Takes ownership of the object*/
void setZoomedInResampler( QgsRasterResampler* r );
const QgsRasterResampler* zoomedInResampler();

/**Set resampler for zoomed out scales. Takes ownership of the object*/
void setZoomedOutResampler( QgsRasterResampler* r );
const QgsRasterResampler* zoomedOutResampler() const;

void setMaxOversampling( double os );
double maxOversampling() const;

/**Get symbology items if provided by renderer*/
virtual void legendSymbologyItems( QList< QPair< QString, QColor > >& symbolItems ) const;

virtual void writeXML( QDomDocument& doc, QDomElement& parentElem ) const = 0;

/**Sets base class members from xml. Usually called from create() methods of subclasses*/
void readXML( const QDomElement& rendererElem );
};

class QgsPalettedRasterRenderer: public QgsRasterRenderer
{
%TypeHeaderCode
#include "qgspalettedrasterrenderer.h"
%End
public:
/**Renderer owns color array*/
QgsPalettedRasterRenderer( QgsRasterDataProvider* provider, int bandNumber, QColor* colorArray, int nColors );
~QgsPalettedRasterRenderer();
static QgsRasterRenderer* create( const QDomElement& elem, QgsRasterDataProvider* provider );

void draw( QPainter* p, QgsRasterViewPort* viewPort, const QgsMapToPixel* theQgsMapToPixel );

/**Returns number of colors*/
int nColors() const;
/**Returns copy of color array (caller takes ownership)*/
QColor* colors() const;

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

void legendSymbologyItems( QList< QPair< QString, QColor > >& symbolItems ) const;
};

class QgsMultiBandColorRenderer: public QgsRasterRenderer
{
%TypeHeaderCode
#include "qgsmultibandcolorrenderer.h"
%End
public:
QgsMultiBandColorRenderer( QgsRasterDataProvider* provider, int redBand, int greenBand, int blueBand,
QgsContrastEnhancement* redEnhancement = 0, QgsContrastEnhancement* greenEnhancement = 0,
QgsContrastEnhancement* blueEnhancement = 0 );
~QgsMultiBandColorRenderer();

static QgsRasterRenderer* create( const QDomElement& elem, QgsRasterDataProvider* provider );

void draw( QPainter* p, QgsRasterViewPort* viewPort, const QgsMapToPixel* theQgsMapToPixel );

int redBand() const;
void setRedBand( int band );
int greenBand() const;
void setGreenBand( int band );
int blueBand() const;
void setBlueBand( int band );

const QgsContrastEnhancement* redContrastEnhancement() const;
/**Takes ownership*/
void setRedContrastEnhancement( QgsContrastEnhancement* ce );

const QgsContrastEnhancement* greenContrastEnhancement() const;
/**Takes ownership*/
void setGreenContrastEnhancement( QgsContrastEnhancement* ce );

const QgsContrastEnhancement* blueContrastEnhancement() const;
/**Takes ownership*/
void setBlueContrastEnhancement( QgsContrastEnhancement* ce );

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

class QgsSingleBandPseudoColorRenderer: public QgsRasterRenderer
{
%TypeHeaderCode
#include "qgssinglebandpseudocolorrenderer.h"
%End
public:
/**Note: takes ownership of QgsRasterShader*/
QgsSingleBandPseudoColorRenderer( QgsRasterDataProvider* provider, int band, QgsRasterShader* shader );
~QgsSingleBandPseudoColorRenderer();

static QgsRasterRenderer* create( const QDomElement& elem, QgsRasterDataProvider* provider );

virtual void draw( QPainter* p, QgsRasterViewPort* viewPort, const QgsMapToPixel* theQgsMapToPixel );

/**Takes ownership of the shader*/
void setShader( QgsRasterShader* shader );
QgsRasterShader* shader();

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

void legendSymbologyItems( QList< QPair< QString, QColor > >& symbolItems ) const;
};

class QgsSingleBandGrayRenderer: public QgsRasterRenderer
{
%TypeHeaderCode
#include "qgssinglebandgrayrenderer.h"
%End
public:
QgsSingleBandGrayRenderer( QgsRasterDataProvider* provider, int grayBand );
~QgsSingleBandGrayRenderer();

static QgsRasterRenderer* create( const QDomElement& elem, QgsRasterDataProvider* provider );

virtual void draw( QPainter* p, QgsRasterViewPort* viewPort, const QgsMapToPixel* theQgsMapToPixel );

int grayBand() const;
void setGrayBand( int band );
const QgsContrastEnhancement* contrastEnhancement() const;
/**Takes ownership*/
void setContrastEnhancement( QgsContrastEnhancement* ce );

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

void legendSymbologyItems( QList< QPair< QString, QColor > >& symbolItems ) const;
};

class QgsSingleBandColorDataRenderer: public QgsRasterRenderer
{
%TypeHeaderCode
#include "qgssinglebandcolordatarenderer.h"
%End
public:
QgsSingleBandColorDataRenderer( QgsRasterDataProvider* provider, int band );
~QgsSingleBandColorDataRenderer();

static QgsRasterRenderer* create( const QDomElement& elem, QgsRasterDataProvider* provider );

virtual void draw( QPainter* p, QgsRasterViewPort* viewPort, const QgsMapToPixel* theQgsMapToPixel );

void writeXML( QDomDocument& doc, QDomElement& parentElem ) const;
};
@@ -0,0 +1,47 @@
class QgsRasterResampler
{
%TypeHeaderCode
#include "qgsrasterresampler.h"
#include "qgsbilinearrasterresampler.h"
#include "qgscubicrasterresampler.h"

%End

%ConvertToSubClassCode
if (dynamic_cast<QgsBilinearRasterResampler*>(sipCpp) != NULL)
sipClass = sipClass_QgsBilinearRasterResampler;
else if (dynamic_cast<QgsCubicRasterResampler*>(sipCpp) != NULL)
sipClass = sipClass_QgsCubicRasterResampler;
else
sipClass = 0;
%End

public:
virtual void resample( const QImage& srcImage, QImage& dstImage ) = 0;
virtual QString type() const = 0;
};

class QgsBilinearRasterResampler: public QgsRasterResampler
{
%TypeHeaderCode
#include "qgsbilinearrasterresampler.h"
%End
public:
QgsBilinearRasterResampler();
~QgsBilinearRasterResampler();

void resample( const QImage& srcImage, QImage& dstImage );
QString type() const;
};

class QgsCubicRasterResampler: public QgsRasterResampler
{
%TypeHeaderCode
#include "qgscubicrasterresampler.h"
%End
public:
QgsCubicRasterResampler();
~QgsCubicRasterResampler();
void resample( const QImage& srcImage, QImage& dstImage );
QString type() const;
};
@@ -46,7 +46,7 @@ class QgisInterface : QObject
//! Add a raster layer given a raster layer file name
virtual QgsRasterLayer* addRasterLayer(QString rasterLayerPath, QString baseName = QString())=0;
//! Add a WMS layer
virtual QgsRasterLayer* addRasterLayer(const QString& url, const QString& layerName, const QString& providerKey, const QStringList& layers, const QStringList& styles, const QString& format, const QString& crs) = 0;
virtual QgsRasterLayer* addRasterLayer(const QString& uri, const QString& baseName, const QString& providerKey) = 0;

//! Add a project
virtual bool addProject(QString theProject)=0;
@@ -2541,7 +2541,7 @@ void QgsLegend::groupSelectedLayers()
//avoid multiple refreshes of map canvas because of itemChanged signal
blockSignals( true );

QTreeWidgetItem * parent;
QTreeWidgetItem * parent = 0;
foreach( QTreeWidgetItem* item, selectedItems() )
{
parent = item->parent();
@@ -753,7 +753,7 @@ void QgisApp::dropEvent( QDropEvent *event )
}
else if ( u.layerType == "raster" )
{
addRasterLayer( u.uri, u.name, u.providerKey, QStringList(), QStringList(), QString(), QString() );
addRasterLayer( u.uri, u.name, u.providerKey );
}
}
}
@@ -2632,10 +2632,8 @@ void QgisApp::addWmsLayer()
QMessageBox::warning( this, tr( "WMS" ), tr( "Cannot get WMS select dialog from provider." ) );
return;
}
connect( wmss , SIGNAL( addRasterLayer( QString const &, QString const &, QString const &, QStringList const &, QStringList const &, QString const &,
QString const & ) ),
this , SLOT( addRasterLayer( QString const &, QString const &, QString const &, QStringList const &, QStringList const &, QString const &,
QString const & ) ) );
connect( wmss , SIGNAL( addRasterLayer( QString const &, QString const &, QString const & ) ),
this , SLOT( addRasterLayer( QString const &, QString const &, QString const & ) ) );
wmss->exec();
delete wmss;
}
@@ -6813,22 +6811,17 @@ QgsRasterLayer* QgisApp::addRasterLayer( QString const & rasterFile, QString con

/** Add a raster layer directly without prompting user for location
The caller must provide information compatible with the provider plugin
using the rasterLayerPath and baseName. The provider can use these
using the uri and baseName. The provider can use these
parameters in any way necessary to initialize the layer. The baseName
parameter is used in the Map Legend so it should be formed in a meaningful
way.
\note Copied from the equivalent addVectorLayer function in this file
TODO Make it work for rasters specifically.
*/
QgsRasterLayer* QgisApp::addRasterLayer(
QString const &rasterLayerPath,
QString const &uri,
QString const &baseName,
QString const &providerKey,
QStringList const & layers,
QStringList const & styles,
QString const &format,
QString const &crs )
QString const &providerKey )
{
QgsDebugMsg( "about to get library for " + providerKey );

@@ -6839,42 +6832,20 @@ QgsRasterLayer* QgisApp::addRasterLayer(

mMapCanvas->freeze();

// Let render() do its own cursor management
// QApplication::setOverrideCursor(Qt::WaitCursor);

// create the layer
QgsRasterLayer *layer;
/* Eliminate the need to instantiate the layer based on provider type.
The caller is responsible for cobbling together the needed information to
open the layer
*/
QgsDebugMsg( "Creating new raster layer using " + rasterLayerPath
+ " with baseName of " + baseName
+ " and layer list of " + layers.join( ", " )
+ " and style list of " + styles.join( ", " )
+ " and format of " + format
+ " and providerKey of " + providerKey
+ " and CRS of " + crs );
QgsDebugMsg( "Creating new raster layer using " + uri
+ " with baseName of " + baseName );

// TODO: Remove the 0 when the raster layer becomes a full provider gateway.
layer = new QgsRasterLayer( 0, rasterLayerPath, baseName, providerKey, layers, styles, format, crs );
layer = new QgsRasterLayer( uri, baseName, providerKey );

QgsDebugMsg( "Constructed new layer." );

if ( layer && shouldAskUserForGDALSublayers( layer ) )
{
askUserForGDALSublayers( layer );

// The first layer loaded is not useful in that case. The user can select it in
// the list if he wants to load it.
delete layer;
}
else if ( layer && layer->isValid() )
if ( layer && layer->isValid() )
{
addRasterLayer( layer );

statusBar()->showMessage( mMapCanvas->extent().toString( 2 ) );

}
else
{
@@ -6889,10 +6860,6 @@ QgsRasterLayer* QgisApp::addRasterLayer(
mMapCanvas->refresh();

return layer;

// Let render() do its own cursor management
// QApplication::restoreOverrideCursor();

} // QgisApp::addRasterLayer


0 comments on commit 42a5eb9

Please sign in to comment.
You can’t perform that action at this time.