Skip to content
Permalink
Browse files

Merge branch 'raster-pipes-2'

  • Loading branch information
mhugent committed Jul 25, 2012
2 parents d039c3f + 1bcd947 commit 42aed665ac31b68c5e47f1726ae354012ce10db8
Showing with 4,990 additions and 1,225 deletions.
  1. +7 −18 python/core/qgsrasterrenderer.sip
  2. +29 −0 python/core/qgsrasterresamplefilter.sip
  3. +2 −0 python/gui/gui.sip
  4. +61 −0 python/gui/qgsrasterformatsaveoptionswidget.sip
  5. +3 −2 python/plugins/GdalTools/tools/doMerge.py
  6. +6 −6 python/plugins/GdalTools/tools/widgetMerge.ui
  7. +4 −0 src/app/legend/qgslegendlayer.cpp
  8. +56 −4 src/app/qgisapp.cpp
  9. +4 −1 src/app/qgisapp.h
  10. +74 −13 src/app/qgsoptions.cpp
  11. +4 −0 src/app/qgsoptions.h
  12. +120 −12 src/app/qgsrasterlayerproperties.cpp
  13. +9 −0 src/app/qgsrasterlayerproperties.h
  14. +8 −0 src/core/CMakeLists.txt
  15. +2 −17 src/core/qgsproviderregistry.cpp
  16. +24 −1 src/core/qgsrasterdataprovider.cpp
  17. +51 −67 src/core/qgsrasterdataprovider.h
  18. +157 −14 src/core/qgsrasterprojector.cpp
  19. +27 −7 src/core/qgsrasterprojector.h
  20. +1 −1 src/core/raster/qgsbilinearrasterresampler.cpp
  21. +136 −154 src/core/raster/qgsmultibandcolorrenderer.cpp
  22. +3 −3 src/core/raster/qgsmultibandcolorrenderer.h
  23. +52 −80 src/core/raster/qgspalettedrasterrenderer.cpp
  24. +4 −2 src/core/raster/qgspalettedrasterrenderer.h
  25. +89 −0 src/core/raster/qgsrasterdrawer.cpp
  26. +48 −0 src/core/raster/qgsrasterdrawer.h
  27. +544 −0 src/core/raster/qgsrasterfilewriter.cpp
  28. +104 −0 src/core/raster/qgsrasterfilewriter.h
  29. +144 −0 src/core/raster/qgsrasterinterface.cpp
  30. +188 −0 src/core/raster/qgsrasterinterface.h
  31. +113 −0 src/core/raster/qgsrasteriterator.cpp
  32. +67 −0 src/core/raster/qgsrasteriterator.h
  33. +106 −26 src/core/raster/qgsrasterlayer.cpp
  34. +15 −4 src/core/raster/qgsrasterlayer.h
  35. +288 −0 src/core/raster/qgsrasterpipe.cpp
  36. +121 −0 src/core/raster/qgsrasterpipe.h
  37. +27 −273 src/core/raster/qgsrasterrenderer.cpp
  38. +29 −89 src/core/raster/qgsrasterrenderer.h
  39. +3 −2 src/core/raster/qgsrasterrendererregistry.h
  40. +229 −0 src/core/raster/qgsrasterresamplefilter.cpp
  41. +70 −0 src/core/raster/qgsrasterresamplefilter.h
  42. +1 −0 src/core/raster/qgsrastertransparency.cpp
  43. +28 −37 src/core/raster/qgssinglebandcolordatarenderer.cpp
  44. +3 −3 src/core/raster/qgssinglebandcolordatarenderer.h
  45. +71 −86 src/core/raster/qgssinglebandgrayrenderer.cpp
  46. +3 −3 src/core/raster/qgssinglebandgrayrenderer.h
  47. +55 −77 src/core/raster/qgssinglebandpseudocolorrenderer.cpp
  48. +3 −3 src/core/raster/qgssinglebandpseudocolorrenderer.h
  49. +6 −0 src/gui/CMakeLists.txt
  50. +45 −0 src/gui/qgsdialog.cpp
  51. +49 −0 src/gui/qgsdialog.h
  52. +488 −0 src/gui/qgsrasterformatsaveoptionswidget.cpp
  53. +90 −0 src/gui/qgsrasterformatsaveoptionswidget.h
  54. +201 −0 src/gui/qgsrasterlayersaveasdialog.cpp
  55. +45 −0 src/gui/qgsrasterlayersaveasdialog.h
  56. +268 −190 src/providers/gdal/qgsgdalprovider.cpp
  57. +25 −3 src/providers/gdal/qgsgdalprovider.h
  58. +2 −2 src/providers/grass/qgsgrassrasterprovider.cpp
  59. +2 −2 src/providers/grass/qgsgrassrasterprovider.h
  60. +3 −3 src/providers/wms/qgswmsprovider.cpp
  61. +2 −2 src/providers/wms/qgswmsprovider.h
  62. +70 −18 src/ui/qgsoptionsbase.ui
  63. +205 −0 src/ui/qgsrasterformatsaveoptionswidgetbase.ui
  64. +25 −0 src/ui/qgsrasterlayerpropertiesbase.ui
  65. +271 −0 src/ui/qgsrasterlayersaveasdialogbase.ui
@@ -29,9 +29,9 @@ class QgsRasterRenderer
virtual ~QgsRasterRenderer();

virtual QString type() const;
virtual void draw( QPainter* p, QgsRasterViewPort* viewPort, const QgsMapToPixel* theQgsMapToPixel ) = 0;
virtual void * readBlock( int bandNo, const QgsRectangle & extent, int width, int height );

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

void setOpacity( double opacity );
double opacity() const;
@@ -45,17 +45,6 @@ class QgsRasterRenderer
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;

@@ -76,7 +65,7 @@ class QgsPalettedRasterRenderer: QgsRasterRenderer
~QgsPalettedRasterRenderer();
static QgsRasterRenderer* create( const QDomElement& elem, QgsRasterDataProvider* provider );

void draw( QPainter* p, QgsRasterViewPort* viewPort, const QgsMapToPixel* theQgsMapToPixel );
void * readBlock( int bandNo, const QgsRectangle & extent, int width, int height );

/**Returns number of colors*/
int nColors() const;
@@ -101,7 +90,7 @@ class QgsMultiBandColorRenderer: QgsRasterRenderer

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

void draw( QPainter* p, QgsRasterViewPort* viewPort, const QgsMapToPixel* theQgsMapToPixel );
void * readBlock( int bandNo, const QgsRectangle & extent, int width, int height );

int redBand() const;
void setRedBand( int band );
@@ -137,7 +126,7 @@ class QgsSingleBandPseudoColorRenderer: QgsRasterRenderer

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

virtual void draw( QPainter* p, QgsRasterViewPort* viewPort, const QgsMapToPixel* theQgsMapToPixel );
void * readBlock( int bandNo, const QgsRectangle & extent, int width, int height );

/**Takes ownership of the shader*/
void setShader( QgsRasterShader* shader );
@@ -159,7 +148,7 @@ class QgsSingleBandGrayRenderer: QgsRasterRenderer

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

virtual void draw( QPainter* p, QgsRasterViewPort* viewPort, const QgsMapToPixel* theQgsMapToPixel );
void * readBlock( int bandNo, const QgsRectangle & extent, int width, int height );

int grayBand() const;
void setGrayBand( int band );
@@ -183,7 +172,7 @@ class QgsSingleBandColorDataRenderer: QgsRasterRenderer

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

virtual void draw( QPainter* p, QgsRasterViewPort* viewPort, const QgsMapToPixel* theQgsMapToPixel );
void * readBlock( int bandNo, const QgsRectangle & extent, int width, int height );

void writeXML( QDomDocument& doc, QDomElement& parentElem ) const;
};
@@ -0,0 +1,29 @@
class QgsRasterResampleFilter
{
%TypeHeaderCode
#include "qgsrasterresamplefilter.h"
%End

public:
QgsRasterResampleFilter( QgsRasterFace* input = 0 );
~QgsRasterResampleFilter();

void * readBlock( int bandNo, const QgsRectangle & extent, int width, int height );

/**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;

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 );
};

@@ -37,5 +37,7 @@
%Include qgsattributeeditor.sip
%Include qgsfieldvalidator.sip
%Include qgsquerybuilder.sip
%Include qgsrasterformatsaveoptionswidget.sip

%Include symbology-ng-gui.sip

@@ -0,0 +1,61 @@

class QgsRasterFormatSaveOptionsWidget : QWidget
{
%TypeHeaderCode
#include <qgsrasterformatsaveoptionswidget.h>
%End

public:

enum Type
{
Default, // everything except profile buttons (save as dlg)
Full, // everything (options dlg)
Table, // just table
LineEdit // just the line edit
};

QgsRasterFormatSaveOptionsWidget( QWidget* parent = 0, QString format = "GTiff",
QgsRasterFormatSaveOptionsWidget::Type type = Default,
QString provider = "gdal" );
~QgsRasterFormatSaveOptionsWidget();

void setFormat( QString format );
void setProvider( QString provider );
QStringList options() const;
void setType( QgsRasterFormatSaveOptionsWidget::Type type = Default );

public slots:

void apply();
void helpOptions();
bool validateOptions( bool gui = true );

private slots:

void on_mProfileNewButton_clicked();
void on_mProfileDeleteButton_clicked();
void on_mProfileResetButton_clicked();
void on_mOptionsAddButton_clicked();
void on_mOptionsDeleteButton_clicked();
void on_mOptionsLabel_clicked();
void on_mOptionsLineEdit_editingFinished();
void optionsTableChanged();
void optionsTableEnableDeleteButton();
void updateOptions();
void swapOptionsUI( int newIndex = -1 );

private:

QString settingsKey( QString profile ) const;
QString currentProfileKey() const;
QString createOptions( QString profile ) const;
void deleteCreateOptions( QString profile );
void setCreateOptions( );
void setCreateOptions( QString profile, QString options );
void setCreateOptions( QString profile, QStringList list );
QStringList profiles() const;
void updateProfiles();
bool eventFilter(QObject *obj, QEvent *event);

};
@@ -20,6 +20,8 @@ def __init__(self, iface):
self.inSelector.setType( self.inSelector.FILE )
self.outSelector.setType( self.outSelector.FILE )
self.recurseCheck.hide()
# use this for approx. previous UI
#self.creationOptionsTable.setType(QgsRasterFormatSaveOptionsWidget.Table)

self.outputFormat = Utils.fillRasterOutputFormat()
self.extent = None
@@ -33,8 +35,7 @@ def __init__(self, iface):
(self.recurseCheck, SIGNAL("stateChanged(int)"), self.inputDirCheck),
( self.separateCheck, SIGNAL( "stateChanged( int )" ) ),
( self.pctCheck, SIGNAL( "stateChanged( int )" ) ),
( self.intersectCheck, SIGNAL( "stateChanged( int )" ) ),
(self.creationOptionsTable, [SIGNAL("cellValueChanged(int, int)"), SIGNAL("rowRemoved()")], self.creationGroupBox)
( self.intersectCheck, SIGNAL( "stateChanged( int )" ) )
]
)

@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>345</width>
<height>276</height>
<width>371</width>
<height>284</height>
</rect>
</property>
<property name="sizePolicy">
@@ -117,11 +117,11 @@
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="bottomMargin">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="GdalToolsOptionsTable" name="creationOptionsTable" native="true"/>
<widget class="QgsRasterFormatSaveOptionsWidget" name="creationOptionsTable" native="true"/>
</item>
</layout>
</widget>
@@ -136,9 +136,9 @@
<container>1</container>
</customwidget>
<customwidget>
<class>GdalToolsOptionsTable</class>
<class>QgsRasterFormatSaveOptionsWidget</class>
<extends>QWidget</extends>
<header>optionsTable</header>
<header>qgis.gui</header>
<container>1</container>
</customwidget>
</customwidgets>
@@ -480,6 +480,10 @@ void QgsLegendLayer::addToPopupMenu( QMenu& theMenu )
theMenu.addAction( showNFeaturesAction );
theMenu.addSeparator();
}
else if ( lyr->type() == QgsMapLayer::RasterLayer )
{
theMenu.addAction( tr( "Save As..." ), QgisApp::instance(), SLOT( saveAsRasterFile() ) );
}

// properties goes on bottom of menu for consistency with normal ui standards
// e.g. kde stuff
@@ -159,9 +159,12 @@
#include "qgspythonrunner.h"
#include "qgsquerybuilder.h"
#include "qgsrastercalcdialog.h"
#include "qgsrasterfilewriter.h"
#include "qgsrasteriterator.h"
#include "qgsrasterlayer.h"
#include "qgsrasterlayerproperties.h"
#include "qgsrasterrenderer.h"
#include "qgsrasterlayersaveasdialog.h"
#include "qgsrectangle.h"
#include "qgsrenderer.h"
#include "qgsscalecombobox.h"
@@ -909,7 +912,7 @@ void QgisApp::createActions()
connect( mActionOpenTable, SIGNAL( triggered() ), this, SLOT( attributeTable() ) );
connect( mActionToggleEditing, SIGNAL( triggered() ), this, SLOT( toggleEditing() ) );
connect( mActionSaveEdits, SIGNAL( triggered() ), this, SLOT( saveEdits() ) );
connect( mActionLayerSaveAs, SIGNAL( triggered() ), this, SLOT( saveAsVectorFile() ) );
connect( mActionLayerSaveAs, SIGNAL( triggered() ), this, SLOT( saveAsFile() ) );
connect( mActionLayerSelectionSaveAs, SIGNAL( triggered() ), this, SLOT( saveSelectionAsVectorFile() ) );
connect( mActionRemoveLayer, SIGNAL( triggered() ), this, SLOT( removeLayer() ) );
connect( mActionSetLayerCRS, SIGNAL( triggered() ), this, SLOT( setLayerCRS() ) );
@@ -3865,8 +3868,56 @@ void QgisApp::attributeTable()
// the dialog will be deleted by itself on close
}

void QgisApp::saveAsVectorFile()
void QgisApp::saveAsRasterFile()
{
QgsRasterLayer* rasterLayer = qobject_cast<QgsRasterLayer *>( activeLayer() );
if ( !rasterLayer )
{
return;
}

QgsRasterLayerSaveAsDialog d( rasterLayer->dataProvider(), mMapCanvas->extent() );
if ( d.exec() == QDialog::Accepted )
{
QgsRasterFileWriter fileWriter( d.outputFileName() );
if ( d.tileMode() )
{
fileWriter.setTiledMode( true );
fileWriter.setMaxTileWidth( d.maximumTileSizeX() );
fileWriter.setMaxTileHeight( d.maximumTileSizeY() );
}

QProgressDialog pd( 0, tr( "Abort..." ), 0, 0 );
pd.setWindowModality( Qt::WindowModal );
QgsRasterDataProvider* provider = rasterLayer->dataProvider();
if ( !provider )
{
return;
}
QgsRasterIterator iterator( provider );
int nRows = -1; //calculate number of rows such that pixels are squares
if ( provider->capabilities() & QgsRasterDataProvider::ExactResolution )
{
nRows = d.nRows();
}
fileWriter.setCreateOptions( d.createOptions() );

fileWriter.writeRaster( &iterator, d.nColumns(), nRows, d.outputRectangle(), rasterLayer->crs(), &pd );
}
}

void QgisApp::saveAsFile()
{
QgsMapLayer* layer = activeLayer();
if ( layer )
{
QgsMapLayer::LayerType layerType = layer->type();
if ( layerType == QgsMapLayer::RasterLayer )
{
saveAsRasterFile();
}
return;
}
saveAsVectorFileGeneral( false );
}

@@ -6929,7 +6980,8 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
else if ( layer->type() == QgsMapLayer::RasterLayer )
{
const QgsRasterLayer *rlayer = qobject_cast<const QgsRasterLayer *>( layer );
if ( rlayer->dataProvider()->dataType( 1 ) != QgsRasterDataProvider::ARGBDataType )
if ( rlayer->dataProvider()->dataType( 1 ) != QgsRasterDataProvider::ARGB32
&& rlayer->dataProvider()->dataType( 1 ) != QgsRasterDataProvider::ARGB32_Premultiplied )
{
if ( rlayer->dataProvider()->capabilities() & QgsRasterDataProvider::Size )
{
@@ -6958,7 +7010,7 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
mActionOpenTable->setEnabled( false );
mActionToggleEditing->setEnabled( false );
mActionSaveEdits->setEnabled( false );
mActionLayerSaveAs->setEnabled( false );
mActionLayerSaveAs->setEnabled( true );
mActionLayerSelectionSaveAs->setEnabled( false );
mActionAddFeature->setEnabled( false );
mActionDeleteSelected->setEnabled( false );
@@ -819,9 +819,12 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
void saveEdits( QgsMapLayer *layer );

//! save current vector layer
void saveAsVectorFile();
void saveAsFile();
void saveSelectionAsVectorFile();

//! save current raster layer
void saveAsRasterFile();

//! show python console
void showPythonDialog();

0 comments on commit 42aed66

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